Skip to content

Commit da073f1

Browse files
authored
Wellfounded proof for sum relations (#1920)
1 parent 7772dee commit da073f1

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,15 @@ Other minor changes
22542254
map f (map g h) ∘ assocʳ ≗ assocʳ ∘ map (map f g) h
22552255
```
22562256

2257+
* Adden new proof in `Data.Sum.Relation.Binary.LeftOrder` :
2258+
```
2259+
⊎-<-wellFounded : WellFounded ∼₁ → WellFounded ∼₂ → WellFounded (∼₁ ⊎-< ∼₂)
2260+
```
2261+
* Adden new proof in `Data.Sum.Relation.Binary.Pointwise` :
2262+
```
2263+
⊎-wellFounded : WellFounded ∼₁ → WellFounded ∼₂ → WellFounded (Pointwise ∼₁ ∼₂)
2264+
```
2265+
22572266
* Made `Map` public in `Data.Tree.AVL.IndexedMap`
22582267

22592268
* Added new definitions in `Data.Vec.Base`:

src/Data/Sum/Relation/Binary/LeftOrder.agda

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ open import Data.Sum.Relation.Binary.Pointwise as PW
1414
open import Data.Product
1515
open import Data.Empty
1616
open import Function
17+
open import Induction.WellFounded
1718
open import Level
1819
open import Relation.Nullary
1920
import Relation.Nullary.Decidable as Dec
@@ -78,6 +79,20 @@ module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂}
7879
⊎-<-decidable dec₁ dec₂ (inj₂ x) (inj₁ y) = no λ()
7980
⊎-<-decidable dec₁ dec₂ (inj₂ x) (inj₂ y) = Dec.map′ ₂∼₂ drop-inj₂ (dec₂ x y)
8081

82+
⊎-<-wellFounded : WellFounded ∼₁ WellFounded ∼₂ WellFounded (∼₁ ⊎-< ∼₂)
83+
⊎-<-wellFounded wf₁ wf₂ x = acc (⊎-<-acc x)
84+
where
85+
⊎-<-acc₁ : {x} Acc ∼₁ x WfRec (∼₁ ⊎-< ∼₂) (Acc (∼₁ ⊎-< ∼₂)) (inj₁ x)
86+
⊎-<-acc₁ (acc rec) (inj₁ y) (₁∼₁ x∼₁y) = acc (⊎-<-acc₁ (rec y x∼₁y))
87+
88+
⊎-<-acc₂ : {x} Acc ∼₂ x WfRec (∼₁ ⊎-< ∼₂) (Acc (∼₁ ⊎-< ∼₂)) (inj₂ x)
89+
⊎-<-acc₂ (acc rec) (inj₁ y) ₁∼₂ = acc (⊎-<-acc₁ (wf₁ y))
90+
⊎-<-acc₂ (acc rec) (inj₂ y) (₂∼₂ x∼₂y) = acc (⊎-<-acc₂ (rec y x∼₂y))
91+
92+
⊎-<-acc : x WfRec (∼₁ ⊎-< ∼₂) (Acc (∼₁ ⊎-< ∼₂)) x
93+
⊎-<-acc (inj₁ x) = ⊎-<-acc₁ (wf₁ x)
94+
⊎-<-acc (inj₂ x) = ⊎-<-acc₂ (wf₂ x)
95+
8196
module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂}
8297
{ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {≈₁ : Rel A₁ ℓ₂}
8398
{ℓ₃ ℓ₄} {∼₂ : Rel A₂ ℓ₃} {≈₂ : Rel A₂ ℓ₄}

src/Data/Sum/Relation/Binary/Pointwise.agda

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Data.Sum.Relation.Binary.Pointwise where
1111
open import Data.Product using (_,_)
1212
open import Data.Sum.Base as Sum
1313
open import Data.Sum.Properties
14+
open import Induction.WellFounded
1415
open import Level using (_⊔_)
1516
open import Function.Base using (_∘_; id)
1617
open import Function.Inverse using (Inverse)
@@ -74,6 +75,19 @@ module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂}
7475
⊎-decidable _≟₁_ _≟₂_ (inj₂ x) (inj₁ y) = no λ()
7576
⊎-decidable _≟₁_ _≟₂_ (inj₂ x) (inj₂ y) = Dec.map′ inj₂ drop-inj₂ (x ≟₂ y)
7677

78+
⊎-wellFounded : WellFounded ∼₁ WellFounded ∼₂ WellFounded (Pointwise ∼₁ ∼₂)
79+
⊎-wellFounded wf₁ wf₂ x = acc (⊎-acc x)
80+
where
81+
⊎-acc₁ : {x} Acc ∼₁ x WfRec (Pointwise ∼₁ ∼₂) (Acc (Pointwise ∼₁ ∼₂)) (inj₁ x)
82+
⊎-acc₁ (acc rec) (inj₁ y) (inj₁ x∼₁y) = acc (⊎-acc₁ (rec y x∼₁y))
83+
84+
⊎-acc₂ : {x} Acc ∼₂ x WfRec (Pointwise ∼₁ ∼₂) (Acc (Pointwise ∼₁ ∼₂)) (inj₂ x)
85+
⊎-acc₂ (acc rec) (inj₂ y) (inj₂ x∼₂y) = acc (⊎-acc₂ (rec y x∼₂y))
86+
⊎-acc : x WfRec (Pointwise ∼₁ ∼₂) (Acc (Pointwise ∼₁ ∼₂)) x
87+
88+
⊎-acc (inj₁ x) = ⊎-acc₁ (wf₁ x)
89+
⊎-acc (inj₂ x) = ⊎-acc₂ (wf₂ x)
90+
7791
module _ {a₁ a₂} {A₁ : Set a₁} {A₂ : Set a₂}
7892
{ℓ₁ ℓ₂} {∼₁ : Rel A₁ ℓ₁} {≈₁ : Rel A₁ ℓ₂}
7993
{ℓ₃ ℓ₄} {∼₂ : Rel A₂ ℓ₃} {≈₂ : Rel A₂ ℓ₄} where

0 commit comments

Comments
 (0)