Skip to content

Commit ef78949

Browse files
Deprecated Induction.WellFounded.Lexicographic (#1094)
1 parent ecfa18d commit ef78949

File tree

4 files changed

+336
-254
lines changed

4 files changed

+336
-254
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@ discourage their use.
235235

236236
* `Algebra.Solver.Monoid` and `Data.List.Solver`
237237

238+
* The module `Data.Induction.WellFounded.Lexicographic` is deprecated.
239+
Please use the proofs in `Data.Product.Relation.Binary.Lex.Strict` instead.
240+
238241
Deprecated names
239242
----------------
240243

@@ -742,6 +745,16 @@ Other minor additions
742745
⊓-pres-m< : m < n → m < o → m < n ⊓ o
743746
```
744747

748+
* Improved the universe polymorphism of
749+
`Data.Product.Relation.Binary.Lex.Strict/NonStrict`
750+
so that the equality and order relations need not live at the
751+
same universe level.
752+
753+
* Added new proofs to `Data.Product.Relation.Binary.Lex.Strict`:
754+
```
755+
×-wellFounded : WellFounded _<₁_ → WellFounded _<₂_ → WellFounded _<ₗₑₓ_
756+
```
757+
745758
* Added new proofs to `Data.String.Unsafe`:
746759
```agda
747760
toList-++ : toList (s ++ t) ≡ toList s ++ toList t
@@ -791,6 +804,7 @@ Other minor additions
791804

792805
* Added new proofs to `Induction.WellFounded`:
793806
```agda
807+
Acc-resp-≈ : Symmetric _≈_ → _<_ Respectsʳ _≈_ → (Acc _<_) Respects _≈_
794808
some-wfRec-irrelevant : Some.wfRec P f x q ≡ Some.wfRec P f x q'
795809
wfRecBuilder-wfRec : All.wfRecBuilder P f x y y<x ≡ All.wfRec P f y
796810
unfold-wfRec : All.wfRec P f x ≡ f x λ y _ → All.wfRec P f y

src/Data/Product/Relation/Binary/Lex/NonStrict.agda

Lines changed: 106 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,86 @@ module Data.Product.Relation.Binary.Lex.NonStrict where
1313

1414
open import Data.Product using (_×_; _,_; proj₁; proj₂)
1515
open import Data.Sum.Base using (inj₁; inj₂)
16+
open import Level using (Level)
1617
open import Relation.Binary
1718
open import Relation.Binary.Consequences
1819
import Relation.Binary.Construct.NonStrictToStrict as Conv
1920
open import Data.Product.Relation.Binary.Pointwise.NonDependent as Pointwise
2021
using (Pointwise)
2122
import Data.Product.Relation.Binary.Lex.Strict as Strict
2223

23-
module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where
24+
private
25+
variable
26+
a b ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level
27+
A : Set a
28+
B : Set b
2429

2530
------------------------------------------------------------------------
26-
-- A lexicographic ordering over products
31+
-- Definition
2732

28-
×-Lex : (_≈₁_ _≤₁_ : Rel A₁ ℓ₁) (_≤₂_ : Rel A₂ ℓ₂) Rel (A₁ × A₂) _
29-
×-Lex _≈₁_ _≤₁_ _≤₂_ = Strict.×-Lex _≈₁_ (Conv._<_ _≈₁_ _≤₁_) _≤₂_
33+
×-Lex : (_≈₁_ : Rel A ℓ₁) (_≤₁_ : Rel A ℓ₂) (_≤₂_ : Rel B ℓ₃)
34+
Rel (A × B) _
35+
×-Lex _≈₁_ _≤₁_ _≤₂_ = Strict.×-Lex _≈₁_ (Conv._<_ _≈₁_ _≤₁_) _≤₂_
3036

3137
------------------------------------------------------------------------
32-
-- Some properties which are preserved by ×-Lex (under certain
33-
-- assumptions).
34-
35-
×-reflexive : _≈₁_ _≤₁_ {_≈₂_} _≤₂_
36-
_≈₂_ ⇒ _≤₂_
37-
(Pointwise _≈₁_ _≈₂_) ⇒ (×-Lex _≈₁_ _≤₁_ _≤₂_)
38-
×-reflexive _≈₁_ _≤₁_ _≤₂_ refl₂ =
39-
Strict.×-reflexive _≈₁_ (Conv._<_ _≈₁_ _≤₁_) _≤₂_ refl₂
40-
41-
×-transitive : {_≈₁_ _≤₁_} IsPartialOrder _≈₁_ _≤₁_
42-
{_≤₂_} Transitive _≤₂_
43-
Transitive (×-Lex _≈₁_ _≤₁_ _≤₂_)
44-
×-transitive {_≈₁_} {_≤₁_} po₁ {_≤₂_} trans₂ =
45-
Strict.×-transitive
46-
{_<₁_ = Conv._<_ _≈₁_ _≤₁_}
38+
-- Properties
39+
40+
×-reflexive : (_≈₁_ : Rel A ℓ₁) (_≤₁_ : Rel A ℓ₂)
41+
{_≈₂_ : Rel B ℓ₃} (_≤₂_ : Rel B ℓ₄)
42+
_≈₂_ ⇒ _≤₂_
43+
(Pointwise _≈₁_ _≈₂_) ⇒ (×-Lex _≈₁_ _≤₁_ _≤₂_)
44+
×-reflexive _≈₁_ _≤₁_ _≤₂_ refl₂ =
45+
Strict.×-reflexive _≈₁_ (Conv._<_ _≈₁_ _≤₁_) _≤₂_ refl₂
46+
47+
module _ {_≈₁_ : Rel A ℓ₁} {_≤₁_ : Rel A ℓ₂} {_≤₂_ : Rel B ℓ₃} where
48+
49+
private
50+
_≤ₗₑₓ_ = ×-Lex _≈₁_ _≤₁_ _≤₂_
51+
52+
×-transitive : IsPartialOrder _≈₁_ _≤₁_ Transitive _≤₂_
53+
Transitive _≤ₗₑₓ_
54+
×-transitive po₁ trans₂ =
55+
Strict.×-transitive {_≈₁_ = _≈₁_} {_<₂_ = _≤₂_}
4756
isEquivalence (Conv.<-resp-≈ _ _ isEquivalence ≤-resp-≈)
4857
(Conv.<-trans _ _ po₁)
49-
{_≤₂_} trans₂
58+
trans₂
5059
where open IsPartialOrder po₁
5160

52-
×-antisymmetric :
53-
{_≈₁_ _≤₁_} IsPartialOrder _≈₁_ _≤₁_
54-
{_≈₂_ _≤₂_} Antisymmetric _≈₂_ _≤₂_
55-
Antisymmetric (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
56-
×-antisymmetric {_≈₁_} {_≤₁_}
57-
po₁ {_≤₂_ = _≤₂_} antisym₂ =
58-
Strict.×-antisymmetric {_<₁_ = Conv._<_ _≈₁_ _≤₁_}
59-
≈-sym₁ irrefl₁ asym₁
60-
{_≤₂_ = _≤₂_} antisym₂
61+
×-total : Symmetric _≈₁_ Decidable _≈₁_ Antisymmetric _≈₁_ _≤₁_
62+
Total _≤₁_ Total _≤₂_ Total _≤ₗₑₓ_
63+
×-total sym₁ dec₁ antisym₁ total₁ total₂ =
64+
total
65+
where
66+
tri₁ : Trichotomous _≈₁_ (Conv._<_ _≈₁_ _≤₁_)
67+
tri₁ = Conv.<-trichotomous _ _ sym₁ dec₁ antisym₁ total₁
68+
69+
total : Total _≤ₗₑₓ_
70+
total x y with tri₁ (proj₁ x) (proj₁ y)
71+
... | tri< x₁<y₁ x₁≉y₁ x₁≯y₁ = inj₁ (inj₁ x₁<y₁)
72+
... | tri> x₁≮y₁ x₁≉y₁ x₁>y₁ = inj₂ (inj₁ x₁>y₁)
73+
... | tri≈ x₁≮y₁ x₁≈y₁ x₁≯y₁ with total₂ (proj₂ x) (proj₂ y)
74+
... | inj₁ x₂≤y₂ = inj₁ (inj₂ (x₁≈y₁ , x₂≤y₂))
75+
... | inj₂ x₂≥y₂ = inj₂ (inj₂ (sym₁ x₁≈y₁ , x₂≥y₂))
76+
77+
×-decidable : Decidable _≈₁_ Decidable _≤₁_ Decidable _≤₂_
78+
Decidable _≤ₗₑₓ_
79+
×-decidable dec-≈₁ dec-≤₁ dec-≤₂ =
80+
Strict.×-decidable dec-≈₁ (Conv.<-decidable _ _ dec-≈₁ dec-≤₁)
81+
dec-≤₂
82+
83+
module _ {_≈₁_ : Rel A ℓ₁} {_≤₁_ : Rel A ℓ₂}
84+
{_≈₂_ : Rel B ℓ₃} {_≤₂_ : Rel B ℓ₄}
85+
where
86+
87+
private
88+
_≤ₗₑₓ_ = ×-Lex _≈₁_ _≤₁_ _≤₂_
89+
_≋_ = Pointwise _≈₁_ _≈₂_
90+
91+
×-antisymmetric : IsPartialOrder _≈₁_ _≤₁_ Antisymmetric _≈₂_ _≤₂_
92+
Antisymmetric _≋_ _≤ₗₑₓ_
93+
×-antisymmetric po₁ antisym₂ =
94+
Strict.×-antisymmetric {_≈₁_ = _≈₁_} {_<₂_ = _≤₂_}
95+
≈-sym₁ irrefl₁ asym₁ antisym₂
6196
where
6297
open IsPartialOrder po₁
6398
open Eq renaming (refl to ≈-refl₁; sym to ≈-sym₁)
@@ -69,77 +104,48 @@ module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where
69104
asym₁ = trans∧irr⟶asym {_≈_ = _≈₁_}
70105
≈-refl₁ (Conv.<-trans _ _ po₁) irrefl₁
71106

72-
×-respects₂ :
73-
{_≈₁_ _≤₁_} IsEquivalence _≈₁_ _≤₁_ Respects₂ _≈₁_
74-
{_≈₂_ _≤₂_ : Rel A₂ ℓ₂} _≤₂_ Respects₂ _≈₂_
75-
(×-Lex _≈₁_ _≤₁_ _≤₂_) Respects₂ (Pointwise _≈₁_ _≈₂_)
107+
×-respects₂ : IsEquivalence _≈₁_
108+
_≤₁_ Respects₂ _≈₁_ _≤₂_ Respects₂ _≈₂_
109+
_≤ₗₑₓ_ Respects₂ _≋_
76110
×-respects₂ eq₁ resp₁ resp₂ =
77111
Strict.×-respects₂ eq₁ (Conv.<-resp-≈ _ _ eq₁ resp₁) resp₂
78112

79-
×-decidable : {_≈₁_ _≤₁_} Decidable _≈₁_ Decidable _≤₁_
80-
{_≤₂_} Decidable _≤₂_
81-
Decidable (×-Lex _≈₁_ _≤₁_ _≤₂_)
82-
×-decidable dec-≈₁ dec-≤₁ dec-≤₂ =
83-
Strict.×-decidable dec-≈₁ (Conv.<-decidable _ _ dec-≈₁ dec-≤₁)
84-
dec-≤₂
85-
86-
×-total : {_≈₁_ _≤₁_} Symmetric _≈₁_ Decidable _≈₁_
87-
Antisymmetric _≈₁_ _≤₁_ Total _≤₁_
88-
{_≤₂_} Total _≤₂_
89-
Total (×-Lex _≈₁_ _≤₁_ _≤₂_)
90-
×-total {_≈₁_} {_≤₁_} sym₁ dec₁ antisym₁ total₁ {_≤₂_} total₂ =
91-
total
92-
where
93-
tri₁ : Trichotomous _≈₁_ (Conv._<_ _≈₁_ _≤₁_)
94-
tri₁ = Conv.<-trichotomous _ _ sym₁ dec₁ antisym₁ total₁
95-
96-
total : Total (×-Lex _≈₁_ _≤₁_ _≤₂_)
97-
total x y with tri₁ (proj₁ x) (proj₁ y)
98-
... | tri< x₁<y₁ x₁≉y₁ x₁≯y₁ = inj₁ (inj₁ x₁<y₁)
99-
... | tri> x₁≮y₁ x₁≉y₁ x₁>y₁ = inj₂ (inj₁ x₁>y₁)
100-
... | tri≈ x₁≮y₁ x₁≈y₁ x₁≯y₁ with total₂ (proj₂ x) (proj₂ y)
101-
... | inj₁ x₂≤y₂ = inj₁ (inj₂ (x₁≈y₁ , x₂≤y₂))
102-
... | inj₂ x₂≥y₂ = inj₂ (inj₂ (sym₁ x₁≈y₁ , x₂≥y₂))
103113

104-
-- Some collections of properties which are preserved by ×-Lex
105-
-- (under certain assumptions).
114+
------------------------------------------------------------------------
115+
-- Structures
106116

107-
×-isPartialOrder :
108-
{_≈₁_ _≤₁_} IsPartialOrder _≈₁_ _≤₁_
109-
{_≈₂_ _≤₂_} IsPartialOrder _≈₂_ _≤₂_
110-
IsPartialOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
111-
×-isPartialOrder {_≈₁_} {_≤₁_} po₁
112-
{_≤₂_ = _≤₂_} po₂ = record
117+
×-isPartialOrder : IsPartialOrder _≈₁_ _≤₁_
118+
IsPartialOrder _≈₂_ _≤₂_
119+
IsPartialOrder _≋_ _≤ₗₑₓ_
120+
×-isPartialOrder po₁ po₂ = record
113121
{ isPreorder = record
114122
{ isEquivalence = Pointwise.×-isEquivalence
115123
(isEquivalence po₁)
116124
(isEquivalence po₂)
117125
; reflexive = ×-reflexive _≈₁_ _≤₁_ _≤₂_ (reflexive po₂)
118-
; trans = ×-transitive po₁ {_≤₂_ = _≤₂_} (trans po₂)
126+
; trans = ×-transitive {_≤₂_ = _≤₂_} po₁ (trans po₂)
119127
}
120-
; antisym = ×-antisymmetric {_≤₁_ = _≤₁_} po₁
121-
{_≤₂_ = _≤₂_} (antisym po₂)
128+
; antisym = ×-antisymmetric po₁ (antisym po₂)
122129
}
123130
where open IsPartialOrder
124131

125-
×-isTotalOrder :
126-
{_≈₁_ _≤₁_} Decidable _≈₁_ IsTotalOrder _≈₁_ _≤₁_
127-
{_≈₂_ _≤₂_} IsTotalOrder _≈₂_ _≤₂_
128-
IsTotalOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
129-
×-isTotalOrder {_≤₁_ = _≤₁_} ≈₁-dec to₁ {_≤₂_ = _≤₂_} to₂ = record
132+
×-isTotalOrder : Decidable _≈₁_
133+
IsTotalOrder _≈₁_ _≤₁_
134+
IsTotalOrder _≈₂_ _≤₂_
135+
IsTotalOrder _≋_ _≤ₗₑₓ_
136+
×-isTotalOrder ≈₁-dec to₁ to₂ = record
130137
{ isPartialOrder = ×-isPartialOrder
131138
(isPartialOrder to₁) (isPartialOrder to₂)
132-
; total = ×-total {_≤₁_ = _≤₁_} (Eq.sym to₁) ≈₁-dec
139+
; total = ×-total (Eq.sym to₁) ≈₁-dec
133140
(antisym to₁) (total to₁)
134-
{_≤₂_ = _≤₂_} (total to₂)
141+
(total to₂)
135142
}
136143
where open IsTotalOrder
137144

138-
×-isDecTotalOrder :
139-
{_≈₁_ _≤₁_} IsDecTotalOrder _≈₁_ _≤₁_
140-
{_≈₂_ _≤₂_} IsDecTotalOrder _≈₂_ _≤₂_
141-
IsDecTotalOrder (Pointwise _≈₁_ _≈₂_) (×-Lex _≈₁_ _≤₁_ _≤₂_)
142-
×-isDecTotalOrder {_≤₁_ = _≤₁_} to₁ {_≤₂_ = _≤₂_} to₂ = record
145+
×-isDecTotalOrder : IsDecTotalOrder _≈₁_ _≤₁_
146+
IsDecTotalOrder _≈₂_ _≤₂_
147+
IsDecTotalOrder _≋_ _≤ₗₑₓ_
148+
×-isDecTotalOrder to₁ to₂ = record
143149
{ isTotalOrder = ×-isTotalOrder (_≟_ to₁)
144150
(isTotalOrder to₁)
145151
(isTotalOrder to₂)
@@ -149,31 +155,26 @@ module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where
149155
where open IsDecTotalOrder
150156

151157
------------------------------------------------------------------------
152-
-- "Bundles" can also be combined.
153-
154-
module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} where
155-
156-
×-poset : Poset ℓ₁ ℓ₂ _ Poset ℓ₃ ℓ₄ _ Poset _ _ _
157-
×-poset p₁ p₂ = record
158-
{ isPartialOrder = ×-isPartialOrder
159-
(isPartialOrder p₁) (isPartialOrder p₂)
160-
} where open Poset
161-
162-
×-totalOrder : DecTotalOrder ℓ₁ ℓ₂ _ TotalOrder ℓ₃ ℓ₄ _
163-
TotalOrder _ _ _
164-
×-totalOrder t₁ t₂ = record
165-
{ isTotalOrder = ×-isTotalOrder T₁._≟_ T₁.isTotalOrder T₂.isTotalOrder
166-
}
167-
where
168-
module T₁ = DecTotalOrder t₁
169-
module T₂ = TotalOrder t₂
170-
171-
×-decTotalOrder : DecTotalOrder ℓ₁ ℓ₂ _ DecTotalOrder ℓ₃ ℓ₄ _
172-
DecTotalOrder _ _ _
173-
×-decTotalOrder t₁ t₂ = record
174-
{ isDecTotalOrder = ×-isDecTotalOrder
175-
(isDecTotalOrder t₁) (isDecTotalOrder t₂)
176-
} where open DecTotalOrder
158+
-- Bundles
159+
160+
×-poset : Poset a ℓ₁ ℓ₂ Poset b ℓ₃ ℓ₄ Poset _ _ _
161+
×-poset p₁ p₂ = record
162+
{ isPartialOrder = ×-isPartialOrder O₁.isPartialOrder O₂.isPartialOrder
163+
} where module O₁ = Poset p₁; module O₂ = Poset p₂
164+
165+
×-totalOrder : DecTotalOrder a ℓ₁ ℓ₂
166+
TotalOrder b ℓ₃ ℓ₄
167+
TotalOrder _ _ _
168+
×-totalOrder t₁ t₂ = record
169+
{ isTotalOrder = ×-isTotalOrder T₁._≟_ T₁.isTotalOrder T₂.isTotalOrder
170+
} where module T₁ = DecTotalOrder t₁; module T₂ = TotalOrder t₂
171+
172+
×-decTotalOrder : DecTotalOrder a ℓ₁ ℓ₂
173+
DecTotalOrder b ℓ₃ ℓ₄
174+
DecTotalOrder _ _ _
175+
×-decTotalOrder t₁ t₂ = record
176+
{ isDecTotalOrder = ×-isDecTotalOrder O₁.isDecTotalOrder O₂.isDecTotalOrder
177+
} where module O₁ = DecTotalOrder t₁; module O₂ = DecTotalOrder t₂
177178

178179
------------------------------------------------------------------------
179180
-- DEPRECATED NAMES

0 commit comments

Comments
 (0)