@@ -13,51 +13,86 @@ module Data.Product.Relation.Binary.Lex.NonStrict where
13
13
14
14
open import Data.Product using (_×_; _,_; proj₁; proj₂)
15
15
open import Data.Sum.Base using (inj₁; inj₂)
16
+ open import Level using (Level)
16
17
open import Relation.Binary
17
18
open import Relation.Binary.Consequences
18
19
import Relation.Binary.Construct.NonStrictToStrict as Conv
19
20
open import Data.Product.Relation.Binary.Pointwise.NonDependent as Pointwise
20
21
using (Pointwise)
21
22
import Data.Product.Relation.Binary.Lex.Strict as Strict
22
23
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
24
29
25
30
------------------------------------------------------------------------
26
- -- A lexicographic ordering over products
31
+ -- Definition
27
32
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._<_ _≈₁_ _≤₁_) _≤₂_
30
36
31
37
------------------------------------------------------------------------
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 {_≈₁_ = _≈₁_} {_<₂_ = _≤₂_}
47
56
isEquivalence (Conv.<-resp-≈ _ _ isEquivalence ≤-resp-≈)
48
57
(Conv.<-trans _ _ po₁)
49
- {_≤₂_} trans₂
58
+ trans₂
50
59
where open IsPartialOrder po₁
51
60
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₂
61
96
where
62
97
open IsPartialOrder po₁
63
98
open Eq renaming (refl to ≈-refl₁; sym to ≈-sym₁)
@@ -69,77 +104,48 @@ module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where
69
104
asym₁ = trans∧irr⟶asym {_≈_ = _≈₁_}
70
105
≈-refl₁ (Conv.<-trans _ _ po₁) irrefl₁
71
106
72
- ×-respects₂ :
73
- ∀ {_≈₁_ _≤₁_} → IsEquivalence _≈₁_ → _≤₁_ Respects₂ _≈₁_ →
74
- ∀ {_≈₂_ _≤₂_ : Rel A₂ ℓ₂} → _≤₂_ Respects₂ _≈₂_ →
75
- (×-Lex _≈₁_ _≤₁_ _≤₂_) Respects₂ (Pointwise _≈₁_ _≈₂_)
107
+ ×-respects₂ : IsEquivalence _≈₁_ →
108
+ _≤₁_ Respects₂ _≈₁_ → _≤₂_ Respects₂ _≈₂_ →
109
+ _≤ₗₑₓ_ Respects₂ _≋_
76
110
×-respects₂ eq₁ resp₁ resp₂ =
77
111
Strict.×-respects₂ eq₁ (Conv.<-resp-≈ _ _ eq₁ resp₁) resp₂
78
112
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₂))
103
113
104
- -- Some collections of properties which are preserved by ×-Lex
105
- -- (under certain assumptions).
114
+ ------------------------------------------------------------------------
115
+ -- Structures
106
116
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
113
121
{ isPreorder = record
114
122
{ isEquivalence = Pointwise.×-isEquivalence
115
123
(isEquivalence po₁)
116
124
(isEquivalence po₂)
117
125
; reflexive = ×-reflexive _≈₁_ _≤₁_ _≤₂_ (reflexive po₂)
118
- ; trans = ×-transitive po₁ {_≤₂_ = _≤₂_} (trans po₂)
126
+ ; trans = ×-transitive {_≤₂_ = _≤₂_} po₁ (trans po₂)
119
127
}
120
- ; antisym = ×-antisymmetric {_≤₁_ = _≤₁_} po₁
121
- {_≤₂_ = _≤₂_} (antisym po₂)
128
+ ; antisym = ×-antisymmetric po₁ (antisym po₂)
122
129
}
123
130
where open IsPartialOrder
124
131
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
130
137
{ isPartialOrder = ×-isPartialOrder
131
138
(isPartialOrder to₁) (isPartialOrder to₂)
132
- ; total = ×-total {_≤₁_ = _≤₁_} (Eq.sym to₁) ≈₁-dec
139
+ ; total = ×-total (Eq.sym to₁) ≈₁-dec
133
140
(antisym to₁) (total to₁)
134
- {_≤₂_ = _≤₂_} (total to₂)
141
+ (total to₂)
135
142
}
136
143
where open IsTotalOrder
137
144
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
143
149
{ isTotalOrder = ×-isTotalOrder (_≟_ to₁)
144
150
(isTotalOrder to₁)
145
151
(isTotalOrder to₂)
@@ -149,31 +155,26 @@ module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where
149
155
where open IsDecTotalOrder
150
156
151
157
------------------------------------------------------------------------
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₂
177
178
178
179
------------------------------------------------------------------------
179
180
-- DEPRECATED NAMES
0 commit comments