-
Notifications
You must be signed in to change notification settings - Fork 0
/
Eliminators-L-bar.agda
321 lines (279 loc) · 16 KB
/
Eliminators-L-bar.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
{-# OPTIONS --cubical --safe #-}
open import Level using (Level; _⊔_; Lift; lift) renaming (suc to ℓ-suc)
open import Function using (id; _∘_; _$_)
open import Data.Nat using (ℕ; suc) renaming (_≤_ to _≤ᴺ_)
open import Data.Unit using (⊤; tt)
open import Data.Empty renaming (⊥ to 𝟎)
open import Data.Product using (Σ; ∃-syntax; _×_; _,_; proj₁; proj₂)
open import CubicalIdentity using (_≡_; refl; sym; cong; cong-app; transport; trans; subst; subst2
; subst-const; →-≡; subst≡→[]≡)
open CubicalIdentity.≡-Reasoning
open import Sets
open import PartialOrder
open import Monoid
open import MonoidModule
--*
{-
This module defines the inductive-inductive data type L̅ on which the duration monad L̅ will be built.
-
The definition makes use of higher inductive types as in Homotopy Type Theory,
which is a feature of Cubical Agda.
-}
--*
module Eliminators-L-bar {ℓ ℓ′ : Level} {M : Monoid} (OM : O-Monoid {ℓ} {ℓ′} M) where
module Def-L̅ (A : Set (ℓ ⊔ ℓ′)) where
open O-Monoid OM renaming (PO to PO-≤)
data L̅ : Set (ℓ ⊔ ℓ′)
data _⊑_ : L̅ → L̅ → Set (ℓ ⊔ ℓ′)
PO-⊑ : PartialOrder L̅
_▶_ : 𝕄 → DirSeq PO-⊑ → DirSeq PO-⊑
_▷-⊥ : DirSeq PO-≤ → DirSeq PO-⊑
infix 4 _⊑_
private
variable
a b : 𝕄
x y z : L̅
s : DirSeq PO-⊑
t : DirSeq PO-≤
data L̅ where
_▷_ : 𝕄 → L̅ → L̅
⊥ : L̅
⨆ : (DirSeq PO-⊑) → L̅
η : A → L̅
⊑-antisym : x ⊑ y → y ⊑ x → x ≡ y
data _⊑_ where
⊑-refl : x ⊑ x
⊑-trans : x ⊑ y → y ⊑ z → x ⊑ z
▷-sum⃗ : a ▷ (b ▷ x) ⊑ (a + b) ▷ x
▷-sum⃖ : (a + b) ▷ x ⊑ a ▷ (b ▷ x)
▷-neutrˡ⃗ : 𝟘 ▷ x ⊑ x
▷-neutrˡ⃖ : x ⊑ 𝟘 ▷ x
⊥⊑x : ⊥ ⊑ x
▷-monoʳ : x ⊑ y → a ▷ x ⊑ a ▷ y
▷⊥-mono : a ≤ b → a ▷ ⊥ ⊑ b ▷ ⊥
⨆-ub : ∀ (n : ℕ) → s ⟨ n ⟩ ⊑ ⨆ s
⨆-lub : (∀ (n : ℕ) → s ⟨ n ⟩ ⊑ x) → ⨆ s ⊑ x
▷-contʳ⃖ : a ▷ (⨆ s) ⊑ ⨆ (a ▶ s)
-- ▷-contʳ⃗ follows by ⨆-lub and ▷-monoʳ (s. L̅-COMM)
▷⊥-cont⃖ : ∀ (⋁t : Lub PO-≤ (DirSeq.seq t)) → (Lub.ub ⋁t) ▷ ⊥ ⊑ ⨆ (t ▷-⊥)
-- ▷⊥-cont⃗ follows by ⨆-lub and ▷⊥-mono (s. L̅-CCOMM)
⊑-prop : IsProp (x ⊑ y)
PO-⊑ =
record
{ _≤_ = _⊑_
; ≤-refl = ⊑-refl
; ≤-antisym = ⊑-antisym
; ≤-trans = ⊑-trans
; ≤-prop = ⊑-prop
}
a ▶ s = DirSeq-mono s (a ▷_ ↑ ▷-monoʳ)
(seq ⇗ dir) ▷-⊥ = -- DirSeq-mono (seq ⇗ dir) (_▷ ⊥ ↑ ▷⊥-mono) -- morally the same, module level issues
(_▷ ⊥) ∘ seq ⇗ λ n m →
(proj₁ $ dir n m) , (▷⊥-mono $ proj₁ $ proj₂ $ dir n m) , (▷⊥-mono $ proj₂ $ proj₂ $ dir n m)
open PartialOrder.PartialOrder PO-⊑ using () renaming (A-set to L̅-Set)
record Arguments {ℓ-L̅ ℓ-⊑ : Level} : Set (ℓ ⊔ ℓ′ ⊔ ℓ-suc (ℓ-L̅ ⊔ ℓ-⊑)) where
field
P-L̅ : L̅ → Set ℓ-L̅
P-⊑ : P-L̅ x → P-L̅ y → x ⊑ y → Set ℓ-⊑
P-Dir : DirSeq PO-⊑ → Set (ℓ-L̅ ⊔ ℓ-⊑)
P-Dir s = Σ (∀ (n : ℕ) → P-L̅ (DirSeq.seq s n))
(λ p → (∀ (n m : ℕ) → P-⊑ (p n) (p (proj₁ (DirSeq.dir s n m))) (proj₁ (proj₂ (DirSeq.dir s n m)))
× P-⊑ (p m) (p (proj₁ (DirSeq.dir s n m))) (proj₂ (proj₂ (DirSeq.dir s n m)))))
field
P-▷ : ∀ (a : 𝕄) → P-L̅ x → P-L̅ (a ▷ x)
P-⊥ : P-L̅ ⊥
P-⨆ : P-Dir s → P-L̅ (⨆ s)
P-η : ∀ (x : A) → P-L̅ (η x)
P-⊑-antisym : ∀ {x⊑y : x ⊑ y} {y⊑x : y ⊑ x} (px : P-L̅ x) (py : P-L̅ y)
→ P-⊑ px py x⊑y → P-⊑ py px y⊑x →
subst P-L̅ (⊑-antisym x⊑y y⊑x) px ≡ py
P-⊑-refl : ∀ (p : P-L̅ x) → P-⊑ p p ⊑-refl
P-⊑-trans : ∀ {x⊑y : x ⊑ y} {y⊑z : y ⊑ z} (px : P-L̅ x) (py : P-L̅ y) (pz : P-L̅ z) →
P-⊑ px py x⊑y → P-⊑ py pz y⊑z → P-⊑ px pz (⊑-trans x⊑y y⊑z)
P-▷-sum⃗ : ∀ (px : P-L̅ x) → P-⊑ (P-▷ a (P-▷ b px)) (P-▷ (a + b) px) ▷-sum⃗
P-▷-sum⃖ : ∀ (px : P-L̅ x) → P-⊑ (P-▷ (a + b) px) (P-▷ a (P-▷ b px)) ▷-sum⃖
P-▷-neutrˡ⃗ : ∀ (px : P-L̅ x) → P-⊑ (P-▷ 𝟘 px) px ▷-neutrˡ⃗
P-▷-neutrˡ⃖ : ∀ (px : P-L̅ x) → P-⊑ px (P-▷ 𝟘 px) ▷-neutrˡ⃖
P-⊥⊑x : ∀ (p : P-L̅ x) → P-⊑ P-⊥ p ⊥⊑x
P-▷-monoʳ : ∀ {x⊑y : x ⊑ y} (px : P-L̅ x) (py : P-L̅ y) → P-⊑ px py x⊑y → P-⊑ (P-▷ a px) (P-▷ a py) (▷-monoʳ x⊑y)
P-▷⊥-mono : ∀ {a≤b : a ≤ b} → P-⊑ (P-▷ a P-⊥) (P-▷ b P-⊥) (▷⊥-mono a≤b)
P-⨆-ub : ∀ (ps : P-Dir s) (n : ℕ) → P-⊑ (proj₁ ps n) (P-⨆ {s} ps) (⨆-ub n)
P-⨆-lub : ∀ {ub : ∀ (n : ℕ) → s ⟨ n ⟩ ⊑ x} (ps : P-Dir s) (px : P-L̅ x) →
(∀ (n : ℕ) → P-⊑ (proj₁ ps n) px (ub n)) →
P-⊑ (P-⨆ {s} ps) px (⨆-lub ub)
P-▷-contʳ⃖ : ∀ (ps : P-Dir s) → P-⊑ (P-▷ a (P-⨆ {s} ps))
(P-⨆ ((λ n → P-▷ a ((proj₁ ps) n))
, λ n m → (P-▷-monoʳ (proj₁ ps n) (proj₁ ps (proj₁ (DirSeq.dir s n m)))
(proj₁ ((proj₂ ps) n m) ))
, (P-▷-monoʳ (proj₁ ps m) (proj₁ ps (proj₁ (DirSeq.dir s n m)))
(proj₂ ((proj₂ ps) n m) ))))
▷-contʳ⃖
P-▷⊥-cont⃖ : ∀ (⋁t : Lub PO-≤ (DirSeq.seq t)) → P-⊑ (P-▷ (Lub.ub ⋁t) P-⊥)
(P-⨆ {t ▷-⊥} ((λ n → P-▷ (t ⟨ n ⟩) P-⊥)
, λ n m → P-▷⊥-mono , P-▷⊥-mono))
(▷⊥-cont⃖ ⋁t)
P-⊑-prop : ∀ {x⊑y : x ⊑ y} (px : P-L̅ x) (py : P-L̅ y) → IsProp (P-⊑ px py x⊑y)
record Eliminators {ℓ-L̅ ℓ-⊑ : Level} (args : Arguments {ℓ-L̅} {ℓ-⊑}) : Set (ℓ ⊔ ℓ′ ⊔ ℓ-L̅ ⊔ ℓ-⊑) where
open Arguments args
field
L̅-rec : ∀ (x : L̅) → P-L̅ x
⊑-rec : ∀ (x⊑y : x ⊑ y) → P-⊑ (L̅-rec x) (L̅-rec y) x⊑y
Dir-rec : ∀ (s : DirSeq PO-⊑) → P-Dir s
Dir-rec = λ { (seq ⇗ dir) → ( (λ n → L̅-rec (seq n))
, (λ n m → ⊑-rec (proj₁ (proj₂ (dir n m))) ,
⊑-rec (proj₂ (proj₂ (dir n m)))) ) }
field
L̅-rec-▷ : L̅-rec (a ▷ x) ≡ P-▷ a (L̅-rec x)
L̅-rec-⊥ : L̅-rec ⊥ ≡ P-⊥
L̅-rec-⨆ : L̅-rec (⨆ s) ≡ P-⨆ (Dir-rec s)
L̅-rec-η : ∀ {x : A} → L̅-rec (η x) ≡ P-η x
L̅-Elim : ∀ {ℓ-L̅ ℓ-⊑ : Level} (args : Arguments {ℓ-L̅} {ℓ-⊑}) → Eliminators args
L̅-Elim args = record
{ L̅-rec = L̅-rec
; ⊑-rec = ⊑-rec
; L̅-rec-▷ = refl
; L̅-rec-⊥ = refl
; L̅-rec-⨆ = refl
; L̅-rec-η = refl
}
where
open Arguments args
L̅-rec : ∀ (x : L̅) → P-L̅ x
⊑-rec : ∀ {x y : L̅} (x⊑y : x ⊑ y) → P-⊑ (L̅-rec x) (L̅-rec y) x⊑y
Dir-rec : (s : DirSeq PO-⊑) → P-Dir s
Dir-rec = λ { (seq ⇗ dir) → ( (λ n → L̅-rec (seq n))
, ((λ n m → ⊑-rec (proj₁ (proj₂ (dir n m))) ,
⊑-rec (proj₂ (proj₂ (dir n m)))) ) ) }
L̅-rec (a ▷ x) = P-▷ a (L̅-rec x)
L̅-rec ⊥ = P-⊥
L̅-rec (⨆ s) = P-⨆ (Dir-rec s)
L̅-rec (η x) = P-η x
L̅-rec (⊑-antisym {x} {y} x⊑y y⊑x i) = subst≡→[]≡ {P = P-L̅} (P-⊑-antisym (L̅-rec x) (L̅-rec y)
(⊑-rec x⊑y) (⊑-rec y⊑x)) i
⊑-rec (⊑-refl {x}) = P-⊑-refl (L̅-rec x)
⊑-rec (⊑-trans {x} {y} {z} x⊑y y⊑z) = P-⊑-trans (L̅-rec x) (L̅-rec y) (L̅-rec z)
(⊑-rec x⊑y) (⊑-rec y⊑z)
⊑-rec (▷-sum⃗ {a} {b} {x}) = P-▷-sum⃗ (L̅-rec x)
⊑-rec (▷-sum⃖ {a} {b} {x}) = P-▷-sum⃖ (L̅-rec x)
⊑-rec (▷-neutrˡ⃗ {x}) = P-▷-neutrˡ⃗ (L̅-rec x)
⊑-rec (▷-neutrˡ⃖ {x}) = P-▷-neutrˡ⃖ (L̅-rec x)
⊑-rec (⊥⊑x {x}) = P-⊥⊑x (L̅-rec x)
⊑-rec (▷-monoʳ {x} {y} x⊑y) = P-▷-monoʳ (L̅-rec x) (L̅-rec y) (⊑-rec x⊑y)
⊑-rec (▷⊥-mono a≤b) = P-▷⊥-mono
⊑-rec (⨆-ub {seq ⇗ dir} n) = P-⨆-ub seq dir (Dir-rec (seq ⇗ dir)) n
⊑-rec (⨆-lub {seq ⇗ dir} {x} ub) = P-⨆-lub seq dir (Dir-rec (seq ⇗ dir))
(L̅-rec x) (λ n → ⊑-rec (ub n))
⊑-rec (▷-contʳ⃖ {a} {s}) = P-▷-contʳ⃖ (Dir-rec s)
⊑-rec (▷⊥-cont⃖ {seq ⇗ dir} ⋁t) = P-▷⊥-cont⃖ seq dir ⋁t
⊑-rec (⊑-prop {x} {y} p q i) = subst≡→[]≡ {P = P-⊑ (L̅-rec x) (L̅-rec y)} {p = ⊑-rec p} {q = ⊑-rec q}
{x≡y = ⊑-prop p q} (P-⊑-prop (L̅-rec x) (L̅-rec y) _ _) i
L̅-MM : M-Module M
L̅-MM =
record
{ 𝔼 = L̅
; _▷_ = _▷_
; ▷-sum = ⊑-antisym ▷-sum⃗ ▷-sum⃖
; ▷-neutrˡ = ⊑-antisym ▷-neutrˡ⃗ ▷-neutrˡ⃖
}
L̅-OMM : Ordered-M-Module {ℓ′-⊑ = ℓ ⊔ ℓ′} OM L̅-MM
L̅-OMM =
record
{ ⊥ = ⊥
; PO-⊑ = PO-⊑
; ⊥⊑x = ⊥⊑x
; ▷-monoʳ = ▷-monoʳ
; ▷⊥-mono = ▷⊥-mono
}
L̅-COMM : Complete-OM-Module OM L̅-OMM
L̅-COMM =
record
{ ⨆ = ⨆
; ⨆-ub = ⨆-ub
; ⨆-lub = ⨆-lub
; ▷-contʳ = ⊑-antisym (⨆-lub (λ n → ▷-monoʳ (⨆-ub n)))
▷-contʳ⃖
}
L̅-CCOMM : C-Complete-OM-Module L̅-COMM
L̅-CCOMM = record { ▷⊥-cont = λ ⋁t → ⊑-antisym (⨆-lub (λ n → ▷⊥-mono (Lub.is-ub ⋁t n)))
(▷⊥-cont⃖ ⋁t) }
L̅-COMMo : C-Complete-OM-Module-over A OM L̅-CCOMM
L̅-COMMo =
record { η = η }
private
variable
MM′ : M-Module M
OMM′ : Ordered-M-Module OM MM′
COMM′ : Complete-OM-Module OM OMM′
CCOMM′ : C-Complete-OM-Module COMM′
L̅-Initial : ∀ {ℓ-to ℓ-⊑-to : Level} → Initial-C-Complete-OM-Module-over ℓ-to ℓ-⊑-to L̅-COMMo
L̅-Initial =
record
{ H = λ CCOMMo′ → record
{ COMMM = record
{ fun = h CCOMMo′
; f-⊑ = h-⊑ CCOMMo′
; f-⊥ = refl
; f-▷ = refl
; f-⨆ = refl
}
; f-η = refl }
; uniq = λ {_} {_} {_} {_} {CCOMMo′} G → →-≡ (λ x → sym (gx≡hx CCOMMo′ G x))
}
where
module _ (CCOMMo′ : C-Complete-OM-Module-over A OM {COMM = COMM′} CCOMM′) where
open C-Complete-OM-Module-over CCOMMo′ using (𝔼; 𝔼-set)
renaming (_▷_ to _▷′_; ⊥ to ⊥′; _⊑_ to _⊑′_; ⨆ to ⨆′; η to η′
; ▷-sum to ▷′-sum; ▷-neutrˡ to ▷′-neutrˡ; ⊑-antisym to ⊑′-antisym; ▷-contʳ to ▷′-contʳ; ▷⊥-cont to ▷′⊥′-cont
; ⊑-refl to ⊑′-refl; ⊑-trans to ⊑′-trans; ⊥⊑x to ⊥′⊑′x; ▷-monoʳ to ▷′-monoʳ; ▷⊥-mono to ▷′⊥′-mono
; ⨆-ub to ⨆′-ub; ⨆-lub to ⨆′-lub; ⊑-prop to ⊑′-prop; DirSeq-≡ to DirSeq-≡′)
h-args : Arguments
h-args = record
{ P-L̅ = λ x → 𝔼
; P-⊑ = λ hx hy p → hx ⊑′ hy
; P-▷ = λ a hx → a ▷′ hx
; P-⊥ = ⊥′
; P-⨆ = λ { {seq ⇗ dir} (h-seq , h-dir) → ⨆′ (h-seq ⇗ λ n m → (proj₁ (dir n m)) , h-dir n m)}
; P-η = λ x → η′ x
; P-⊑-antisym = λ {x} {y} {x⊑y} {y⊑x} hx hy hx⊑′hy hy⊑′hx
→ trans (subst-const (⊑-antisym x⊑y y⊑x)) (⊑′-antisym hx⊑′hy hy⊑′hx)
; P-⊑-refl = λ hx → ⊑′-refl
; P-⊑-trans = λ hx hy hz hx⊑′hy hy⊑′hz → ⊑′-trans hx⊑′hy hy⊑′hz
; P-▷-sum⃗ = λ {_} {a} {b} hx → subst (λ y → a ▷′ (b ▷′ hx) ⊑′ y) ▷′-sum ⊑′-refl
; P-▷-sum⃖ = λ {_} {a} {b} hx → subst (λ y → y ⊑′ a ▷′ (b ▷′ hx)) ▷′-sum ⊑′-refl
; P-▷-neutrˡ⃗ = λ hx → subst (λ y → 𝟘 ▷′ hx ⊑′ y) ▷′-neutrˡ ⊑′-refl
; P-▷-neutrˡ⃖ = λ hx → subst (λ y → y ⊑′ 𝟘 ▷′ hx) ▷′-neutrˡ ⊑′-refl
; P-⊥⊑x = λ hx → ⊥′⊑′x
; P-▷-monoʳ = λ hx hy hx⊑′hy → ▷′-monoʳ hx⊑′hy
; P-▷⊥-mono = λ {a} {b} {a≤b} → ▷′⊥′-mono a≤b
; P-⨆-ub = λ seq Dir hs n → ⨆′-ub n
; P-⨆-lub = λ seq Dir hs hx h-ub → ⨆′-lub h-ub
; P-▷-contʳ⃖ = λ { {seq ⇗ dir} {a} (h-seq , h-dir)
→ subst (λ y → a ▷′ ⨆′ (h-seq ⇗ (λ n m → proj₁ (dir n m) , h-dir n m)) ⊑′ y)
(sym ▷′-contʳ) ⊑′-refl }
; P-▷⊥-cont⃖ = λ seq dir ⋁t → subst (λ y → Lub.ub ⋁t ▷′ ⊥′ ⊑′ y)
(sym (▷′⊥′-cont ⋁t)) ⊑′-refl
; P-⊑-prop = λ hx hy hp hq → ⊑′-prop hp hq
}
h-elims : Eliminators h-args
h-elims = L̅-Elim h-args
open Eliminators h-elims using () renaming (L̅-rec to h; ⊑-rec to h-⊑) public
module _ (G : C-Complete-OM-Module-Morphism-over L̅-COMMo CCOMMo′) where
open Complete-OM-Module-Morphism-over G renaming (fun to g; f-⊑ to g-⊑; f-⊥ to g-⊥; f-▷ to g-▷; f-⨆ to g-⨆; f-η to g-η)
gx≡hx-args : Arguments
gx≡hx-args = record
{ P-L̅ = λ x → g x ≡ h x
; P-⊑ = λ _ _ _ → ⊤
; P-▷ = λ a gx≡hx → trans g-▷ (cong (a ▷′_) gx≡hx)
; P-⊥ = g-⊥
; P-⨆ = λ { (p-seq , p-Dir) → trans g-⨆ (DirSeq-≡′ (→-≡ (λ n → p-seq n))) }
; P-η = λ x → cong-app g-η x
; P-⊑-antisym = λ gx≡hx gy≡hy _ _ → 𝔼-set _ _
-- the missing cases for P-⊑ can be inferred by the type checker
; P-⊑-prop = λ { _ _ tt tt → refl }
}
gx≡hx-elims : Eliminators gx≡hx-args
gx≡hx-elims = L̅-Elim gx≡hx-args
open Eliminators gx≡hx-elims using () renaming (L̅-rec to gx≡hx) public
open Def-L̅
L̅*-COMMo : ∀ {A B : Set (ℓ ⊔ ℓ′)} (f : A → L̅ B) → C-Complete-OM-Module-over A OM (L̅-CCOMM B)
L̅*-COMMo f = record { η = f }