1
1
------------------------------------------------------------------------
2
2
-- The Agda standard library
3
3
--
4
- -- Defintions for domain theory
4
+ -- Definitions for domain theory
5
5
------------------------------------------------------------------------
6
6
7
7
module Relation.Binary.Domain.Definitions where
@@ -14,15 +14,14 @@ open import Data.Product using (∃-syntax; _×_; _,_; proj₁; proj₂)
14
14
open import Relation.Unary using (Pred)
15
15
open import Relation.Binary.PropositionalEquality using (_≡_; subst; cong)
16
16
open import Relation.Binary.Reasoning.PartialOrder
17
- open import Relation.Binary.Structures
18
- open import Data.Bool using (Bool; true; false; if_then_else_)
19
17
open import Relation.Binary.Morphism.Structures
20
18
open import Relation.Binary.Morphism.Structures using (IsOrderHomomorphism)
21
19
open import Data.Nat.Properties using (≤-trans)
22
20
23
21
private variable
24
- o ℓ e o' ℓ' e' ℓ₂ : Level
22
+ c o ℓ e o' ℓ' e' ℓ₂ : Level
25
23
Ix A B : Set o
24
+ P : Poset c ℓ e
26
25
27
26
module _ where
28
27
IsMonotone : (P : Poset o ℓ e) → (Q : Poset o' ℓ' e') → (f : Poset.Carrier P → Poset.Carrier Q) → Set (o ⊔ ℓ ⊔ e ⊔ ℓ' ⊔ e')
@@ -33,207 +32,4 @@ module _ {c ℓ₁ ℓ₂ : Level} (P : Poset c ℓ₁ ℓ₂) where
33
32
34
33
IsSemidirectedFamily : ∀ {Ix : Set c} → (s : Ix → Carrier) → Set _
35
34
IsSemidirectedFamily s = ∀ i j → ∃[ k ] (s i ≤ s k × s j ≤ s k)
36
-
37
- record IsDirectedFamily {Ix : Set c} (s : Ix → Carrier) : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
38
- no-eta-equality
39
- field
40
- elt : Ix
41
- SemiDirected : IsSemidirectedFamily s
42
-
43
- record IsLub {Ix : Set c} (s : Ix → Carrier) (lub : Carrier) : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
44
- field
45
- is-upperbound : ∀ i → s i ≤ lub
46
- is-least : ∀ y → (∀ i → s i ≤ y) → lub ≤ y
47
-
48
- record Lub {Ix : Set c} (s : Ix → Carrier) : Set (c ⊔ ℓ₁ ⊔ ℓ₂) where
49
- constructor mkLub
50
- field
51
- lub : Carrier
52
- is-upperbound : ∀ i → s i ≤ lub
53
- is-least : ∀ y → (∀ i → s i ≤ y) → lub ≤ y
54
-
55
- record IsDCPO : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
56
- field
57
- ⋁ : ∀ {Ix : Set c}
58
- → (s : Ix → Carrier)
59
- → IsDirectedFamily s
60
- → Carrier
61
- ⋁-isLub : ∀ {Ix : Set c}
62
- → (s : Ix → Carrier)
63
- → (dir : IsDirectedFamily s)
64
- → IsLub s (⋁ s dir)
65
-
66
- module _ {Ix : Set c} {s : Ix → Carrier} {dir : IsDirectedFamily s} where
67
- open IsLub (⋁-isLub s dir)
68
- renaming (is-upperbound to ⋁-≤; is-least to ⋁-least)
69
- public
70
-
71
- record DCPO (c ℓ₁ ℓ₂ : Level) : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
72
- field
73
- poset : Poset c ℓ₁ ℓ₂
74
- DcpoStr : IsDCPO poset
75
-
76
- open Poset poset public
77
- open IsDCPO DcpoStr public
78
-
79
- module _ {c ℓ₁ ℓ₂} (D : DCPO c ℓ₁ ℓ₂) where
80
- private
81
- module D = DCPO D
82
-
83
- uniqueLub : ∀ {Ix} {s : Ix → D.Carrier}
84
- → (x y : D.Carrier) → IsLub D.poset s x → IsLub D.poset s y
85
- → x D.≈ y
86
- uniqueLub x y x-lub y-lub = D.antisym
87
- (IsLub.is-least x-lub y (IsLub.is-upperbound y-lub))
88
- (IsLub.is-least y-lub x (IsLub.is-upperbound x-lub))
89
-
90
- is-lub-cong : ∀ {Ix} {s : Ix → D.Carrier}
91
- → (x y : D.Carrier)
92
- → x D.≈ y
93
- → IsLub D.poset s x → IsLub D.poset s y
94
- is-lub-cong x y x≈y x-lub = record
95
- { is-upperbound = λ i → D.trans (IsLub.is-upperbound x-lub i) (D.reflexive x≈y)
96
- ; is-least = λ z ub → D.trans (D.reflexive (D.Eq.sym x≈y)) (IsLub.is-least x-lub z (λ i → D.trans (ub i) (D.reflexive D.Eq.refl)))
97
- }
98
-
99
-
100
- module _ {c ℓ₁ ℓ₂ : Level} {P : Poset c ℓ₁ ℓ₂} {Q : Poset c ℓ₁ ℓ₂} where
101
-
102
- private
103
- module P = Poset P
104
- module Q = Poset Q
105
-
106
- record IsScottContinuous (f : P.Carrier → Q.Carrier) : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
107
- field
108
- PreserveLub : ∀ {Ix : Set c} {s : Ix → P.Carrier}
109
- → (dir : IsDirectedFamily P s)
110
- → (lub : P.Carrier)
111
- → IsLub P s lub
112
- → IsLub Q (f ∘ s) (f lub)
113
- PreserveEquality : ∀ {x y} → x P.≈ y → f x Q.≈ f y
114
-
115
- dcpo+scott→monotone : (P-dcpo : IsDCPO P)
116
- → (f : P.Carrier → Q.Carrier)
117
- → (scott : IsScottContinuous f)
118
- → IsMonotone P Q f
119
- dcpo+scott→monotone P-dcpo f scott = record
120
- { cong = λ {x} {y} x≈y → IsScottContinuous.PreserveEquality scott x≈y
121
- ; mono = λ {x} {y} x≤y → mono-proof x y x≤y
122
- }
123
- where
124
- mono-proof : ∀ x y → x P.≤ y → f x Q.≤ f y
125
- mono-proof x y x≤y = IsLub.is-upperbound fs-lub (lift true)
126
- where
127
- s : Lift c Bool → P.Carrier
128
- s (lift b) = if b then x else y
129
-
130
- sx≤sfalse : ∀ b → s b P.≤ s (lift false)
131
- sx≤sfalse (lift true) = x≤y
132
- sx≤sfalse (lift false) = P.refl
133
-
134
- s-directed : IsDirectedFamily P s
135
- s-directed = record
136
- { elt = lift true
137
- ; SemiDirected = λ i j → (lift false , sx≤sfalse i , sx≤sfalse j)
138
- }
139
-
140
- s-lub : IsLub P s y
141
- s-lub = record
142
- { is-upperbound = sx≤sfalse
143
- ; is-least = λ z proof → proof (lift false)
144
- }
145
-
146
- fs-lub : IsLub Q (f ∘ s) (f y)
147
- fs-lub = IsScottContinuous.PreserveLub scott s-directed y s-lub
148
-
149
-
150
- monotone∘directed : ∀ {Ix : Set c} {s : Ix → P.Carrier}
151
- → (f : P.Carrier → Q.Carrier)
152
- → IsMonotone P Q f
153
- → IsDirectedFamily P s
154
- → IsDirectedFamily Q (f ∘ s)
155
- monotone∘directed f ismonotone dir = record
156
- { elt = IsDirectedFamily.elt dir
157
- ; SemiDirected = λ i j →
158
- let (k , s[i]≤s[k] , s[j]≤s[k]) = IsDirectedFamily.SemiDirected dir i j
159
- in k , IsOrderHomomorphism.mono ismonotone s[i]≤s[k] , IsOrderHomomorphism.mono ismonotone s[j]≤s[k]
160
- }
161
-
162
- module _ where
163
-
164
- ScottId : ∀ {c ℓ₁ ℓ₂} {P : Poset c ℓ₁ ℓ₂} → IsScottContinuous {P = P} {Q = P} id
165
- ScottId = record
166
- { PreserveLub = λ dir lub z → z
167
- ; PreserveEquality = λ z → z }
168
-
169
- scott-∘ : ∀ {c ℓ₁ ℓ₂} {P Q R : Poset c ℓ₁ ℓ₂}
170
- → (f : Poset.Carrier R → Poset.Carrier Q) (g : Poset.Carrier P → Poset.Carrier R)
171
- → IsScottContinuous {P = R} {Q = Q} f → IsScottContinuous {P = P} {Q = R} g
172
- → IsMonotone R Q f → IsMonotone P R g
173
- → IsScottContinuous {P = P} {Q = Q} (f ∘ g)
174
- scott-∘ f g scottf scottg monof monog = record
175
- { PreserveLub = λ dir lub z → f.PreserveLub
176
- (monotone∘directed g monog dir)
177
- (g lub)
178
- (g.PreserveLub dir lub z)
179
- ; PreserveEquality = λ {x} {y} z →
180
- f.PreserveEquality (g.PreserveEquality z)
181
- }
182
- where
183
- module f = IsScottContinuous scottf
184
- module g = IsScottContinuous scottg
185
-
186
- module _ {c ℓ₁ ℓ₂} (D : DCPO c ℓ₁ ℓ₂) (let module D = DCPO D) where
187
- open DCPO D
188
-
189
- open import Relation.Binary.Reasoning.PartialOrder poset public
190
-
191
- ⋃-pointwise : ∀ {Ix} {s s' : Ix → Carrier}
192
- → {fam : IsDirectedFamily poset s} {fam' : IsDirectedFamily poset s'}
193
- → (∀ ix → s ix ≤ s' ix)
194
- → ⋁ s fam ≤ ⋁ s' fam'
195
- ⋃-pointwise {s = s} {s'} {fam} {fam'} p =
196
- ⋁-least (⋁ s' fam') λ i → trans (p i) (⋁-≤ i)
197
-
198
- module Scott
199
- {c ℓ₁ ℓ₂}
200
- {D E : DCPO c ℓ₁ ℓ₂}
201
- (let module D = DCPO D)
202
- (let module E = DCPO E)
203
- (f : D.Carrier → E.Carrier)
204
- (isScott : IsScottContinuous {P = D.poset} {Q = E.poset} f)
205
- (mono : IsMonotone D.poset E.poset f) where
206
-
207
- open DCPO D
208
- open DCPO E
209
-
210
- pres-⋁
211
- : ∀ {Ix} (s : Ix → D.Carrier) → (dir : IsDirectedFamily D.poset s)
212
- → f (D.⋁ s dir) E.≈ E.⋁ (f ∘ s) (monotone∘directed f mono dir)
213
- pres-⋁ s dir = E.antisym
214
- (IsLub.is-least
215
- (IsScottContinuous.PreserveLub isScott dir (D.⋁ s dir) (D.⋁-isLub s dir))
216
- (E.⋁ (f ∘ s) (monotone∘directed f mono dir))
217
- E.⋁-≤
218
- )
219
- (IsLub.is-least
220
- (E.⋁-isLub (f ∘ s) (monotone∘directed f mono dir))
221
- (f (D.⋁ s dir))
222
- (λ i → IsOrderHomomorphism.mono mono (D.⋁-≤ i))
223
- )
224
-
225
-
226
-
227
- module _ {c ℓ₁ ℓ₂} (D E : DCPO c ℓ₁ ℓ₂) where
228
- private
229
- module D = DCPO D
230
- module E = DCPO E
231
-
232
- to-scott : (f : D.Carrier → E.Carrier) → IsMonotone D.poset E.poset f
233
- → (∀ {Ix} (s : Ix → D.Carrier) (dir : IsDirectedFamily D.poset s) →
234
- IsLub E.poset (f ∘ s) (f (D.⋁ s dir))) → IsScottContinuous {P = D.poset} {Q = E.poset} f
235
- to-scott f mono pres-⋁ = record
236
- { PreserveLub = λ dir lub x → is-lub-cong E (f (D.⋁ _ dir)) (f lub)
237
- (IsOrderHomomorphism.cong mono (uniqueLub D (D.⋁ _ dir) lub (D.⋁-isLub _ dir) x))
238
- (pres-⋁ _ dir)
239
- ; PreserveEquality = IsOrderHomomorphism.cong mono }
35
+
0 commit comments