-
Notifications
You must be signed in to change notification settings - Fork 1
/
Soundness.agda
399 lines (357 loc) · 13.1 KB
/
Soundness.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
{-# OPTIONS --type-in-type #-}
open import Categories
open import PartialMaps.Stable
module Soundness (X : Cat) (M : StableSys X) where
open import Utilities
open import Restriction.Cat
open import PartialMaps.Cat X M
open Cat X
open import Categories.Pullbacks X
open StableSys M
open import Categories.Pullbacks.PastingLemmas X
open import Categories.Isos X
restSpan : ∀{A B} → Span A B → Span A A
restSpan (span A' mhom fhom m∈) = span A' mhom mhom m∈
~congRestSpan : ∀{A B}{mf m'f' : Span A B} → mf ~Span~ m'f' →
restSpan mf ~Span~ restSpan m'f'
~congRestSpan (spaneq s i q r) = spaneq s i q q
qrestSpan : ∀{A B} → QSpan A B → QSpan A A
qrestSpan = lift _ (abs ∘ restSpan) (sound ∘ ~congRestSpan)
R1Span : ∀{A B}{mf : Span A B} → compSpan mf (restSpan mf) ~Span~ mf
R1Span {mf = span _ m f m∈} =
let p , _ = pul∈sys m m∈
pullback (square _ h _ scom) _ = p
in spaneq h
(pullbackIso (monicPullback (mono∈sys m∈)) p)
refl
(cong (comp f) (mono∈sys m∈ scom))
R2Span : ∀{A B C}{mf : Span A B}{m'f' : Span A C} →
compSpan (restSpan mf) (restSpan m'f') ~Span~ compSpan (restSpan m'f') (restSpan mf)
R2Span {mf = span _ m f m∈} {span _ m' f' m'∈} =
let p , _ = pul∈sys m' m∈
pullback sq _ = symPullback p
square _ h k scom = sq
p' , _ = pul∈sys m m'∈
pullback sq' uniqPul' = p'
square _ h' k' scom' = sq'
sqmap u leftTr rightTr , _ = uniqPul' sq
in spaneq u
(pullbackIso p' (symPullback p))
(proof
comp (comp m h') u
≅⟨ ass ⟩
comp m (comp h' u)
≅⟨ cong (comp m) leftTr ⟩
comp m h
≅⟨ scom ⟩
comp m' k
∎)
(proof
comp (comp m' k') u
≅⟨ ass ⟩
comp m' (comp k' u)
≅⟨ cong (comp m') rightTr ⟩
comp m' k
≅⟨ sym scom ⟩
comp m h
∎)
R3Span : ∀{A B C}{mf : Span A B}{m'f' : Span A C} →
compSpan (restSpan m'f') (restSpan mf) ~Span~ restSpan (compSpan m'f' (restSpan mf))
R3Span {mf = span _ m f m∈} {span _ m' f' m'∈} =
let pullback (square _ h k scom) _ , _ = pul∈sys m m'∈
in spaneq
iden
idIso
idr
(proof
comp (comp m h) iden
≅⟨ idr ⟩
comp m h
≅⟨ scom ⟩
comp m' k
∎)
R4Span : ∀{A B C}{mf : Span A B}{m'f' : Span B C} →
compSpan (restSpan m'f') mf ~Span~ compSpan mf (restSpan (compSpan m'f' mf))
R4Span {mf = span _ m f m∈} {span _ m' f' m'∈} =
let pullback (square _ h k scom) uniqPul , _ = pul∈sys f m'∈
p'' = pasting1 (monicPullback (mono∈sys m∈)) (trivialPullback h)
pullback sq'' _ = p''
p' , _ = pul∈sys (comp m h) m∈
pullback sq' uniqPul' = p'
square _ h' k' scom' = sq'
sqmap u leftTr rightTr , _ = uniqPul' sq''
in spaneq
u
(pullbackIso p' p'')
(proof
comp (comp (comp m h) h') u
≅⟨ ass ⟩
comp (comp m h) (comp h' u)
≅⟨ cong (comp (comp m h)) leftTr ⟩
comp (comp m h) iden
≅⟨ idr ⟩
comp m h
∎)
(proof
comp (comp f k') u
≅⟨ ass ⟩
comp f (comp k' u)
≅⟨ cong (comp f) rightTr ⟩
comp f (comp iden h)
≅⟨ cong (comp f) idl ⟩
comp f h
≅⟨ scom ⟩
comp m' k
∎)
liftbetaRest : ∀{A B}{mf : Span A B} →
qrestSpan (abs mf) ≅ abs (restSpan mf)
liftbetaRest = liftbeta _ (abs ∘ restSpan) (sound ∘ ~congRestSpan) _
qR1Span : ∀{A B}{x : QSpan A B} → qcompSpan x (qrestSpan x) ≅ x
qR1Span =
lift (λ z → qcompSpan z (qrestSpan z) ≅ z)
(λ mf →
proof
qcompSpan (abs mf) (qrestSpan (abs mf))
≅⟨ cong (qcompSpan (abs mf)) liftbetaRest ⟩
qcompSpan (abs mf) (abs (restSpan mf))
≅⟨ liftbetaComp ⟩
abs (compSpan mf (restSpan mf))
≅⟨ sound R1Span ⟩
abs mf
∎)
(fixtypes ∘ sound)
_
qR2Span : ∀{A B C}{f : QSpan A B}{g : QSpan A C} →
qcompSpan (qrestSpan g) (qrestSpan f) ≅
qcompSpan (qrestSpan f) (qrestSpan g)
qR2Span =
lift₂ (λ x y → qcompSpan (qrestSpan x) (qrestSpan y) ≅
qcompSpan (qrestSpan y) (qrestSpan x))
(λ mf ng →
proof
qcompSpan (qrestSpan (abs mf)) (qrestSpan (abs ng))
≅⟨ cong₂ qcompSpan liftbetaRest liftbetaRest ⟩
qcompSpan (abs (restSpan mf)) (abs (restSpan ng))
≅⟨ liftbetaComp ⟩
abs (compSpan (restSpan mf) (restSpan ng))
≅⟨ sound (R2Span {mf = mf}{ng}) ⟩
abs (compSpan (restSpan ng) (restSpan mf))
≅⟨ sym liftbetaComp ⟩
qcompSpan (abs (restSpan ng)) (abs (restSpan mf))
≅⟨ sym (cong₂ qcompSpan liftbetaRest liftbetaRest) ⟩
qcompSpan (qrestSpan (abs ng)) (qrestSpan (abs mf))
∎)
(λ p r → fixtypes (cong₂ (λ x y → qcompSpan (qrestSpan x) (qrestSpan y))
(sound r) (sound p)))
_ _
qR3Span : ∀{A B C}{f : QSpan A B}{g : QSpan A C} →
qcompSpan (qrestSpan g) (qrestSpan f) ≅
qrestSpan (qcompSpan g (qrestSpan f))
qR3Span =
lift₂ (λ x y → qcompSpan (qrestSpan x) (qrestSpan y) ≅
qrestSpan (qcompSpan x (qrestSpan y)))
(λ mf ng →
proof
qcompSpan (qrestSpan (abs mf)) (qrestSpan (abs ng))
≅⟨ cong₂ qcompSpan liftbetaRest liftbetaRest ⟩
qcompSpan (abs (restSpan mf)) (abs (restSpan ng))
≅⟨ liftbetaComp ⟩
abs (compSpan (restSpan mf) (restSpan ng))
≅⟨ sound (R3Span {mf = ng}{mf}) ⟩
abs (restSpan (compSpan mf (restSpan ng)))
≅⟨ sym liftbetaRest ⟩
qrestSpan (abs (compSpan mf (restSpan ng)))
≅⟨ cong qrestSpan (sym liftbetaComp) ⟩
qrestSpan (qcompSpan (abs mf) (abs (restSpan ng)))
≅⟨ cong (qrestSpan ∘ qcompSpan (abs mf)) (sym liftbetaRest) ⟩
qrestSpan (qcompSpan (abs mf) (qrestSpan (abs ng)))
∎)
(λ p r → fixtypes (cong₂ (λ x y → qrestSpan (qcompSpan x (qrestSpan y)))
(sound p) (sound r)))
_ _
qR4Span : ∀{A B C}{f : QSpan A B}{g : QSpan B C} →
qcompSpan (qrestSpan g) f ≅ qcompSpan f (qrestSpan (qcompSpan g f))
qR4Span =
lift₂ (λ x y → qcompSpan (qrestSpan x) y ≅
qcompSpan y (qrestSpan (qcompSpan x y)))
(λ mf ng →
proof
qcompSpan (qrestSpan (abs mf)) (abs ng)
≅⟨ cong (λ z → qcompSpan z (abs ng)) liftbetaRest ⟩
qcompSpan (abs (restSpan mf)) (abs ng)
≅⟨ liftbetaComp ⟩
abs (compSpan (restSpan mf) ng)
≅⟨ sound (R4Span {mf = ng}{mf}) ⟩
abs (compSpan ng (restSpan (compSpan mf ng)))
≅⟨ sym liftbetaComp ⟩
qcompSpan (abs ng) (abs (restSpan (compSpan mf ng)))
≅⟨ cong (qcompSpan (abs ng)) (sym liftbetaRest) ⟩
qcompSpan (abs ng) (qrestSpan (abs (compSpan mf ng)))
≅⟨ cong (qcompSpan (abs ng) ∘ qrestSpan) (sym liftbetaComp) ⟩
qcompSpan (abs ng) (qrestSpan (qcompSpan (abs mf) (abs ng)))
∎)
(λ p r → fixtypes (cong₂ (λ x y → qcompSpan y (qrestSpan (qcompSpan x y)))
(sound p) (sound r)))
_ _
RestPar : RestCat
RestPar = record {
cat = Par;
rest = qrestSpan;
R1 = qR1Span;
R2 = qR2Span;
R3 = qR3Span;
R4 = qR4Span}
{-
-- every restriction in Par splits
open import Categories.Idems Par
open Categories.Isos X
open Lemmata RestPar
qrestSpanIdem : ∀{A B}(f : QSpan A B) → Idem
qrestSpanIdem f = record { E = _; e = qrestSpan f; law = lemii}
sectionSpan : ∀{A B}(f : Span A B) → Span (Span.A' f) A
sectionSpan f =
let open Span f
in record { A' = A'; mhom = iden; fhom = mhom; m∈ = iso idiso }
retractionSpan : ∀{A B}(f : Span A B) → Span A (Span.A' f)
retractionSpan f =
let open Span f
in record { A' = A'; mhom = mhom; fhom = iden; m∈ = m∈ }
{-
qrestSpanSplit : ∀{A B}(f : QSpan A B) → Split (qrestSpanIdem f)
qrestSpanSplit =
lift (Split ∘ qrestSpanIdem)
(λ mf → let open Span mf in record {
B = A' ;
s = abs (sectionSpan mf) ;
r = abs (retractionSpan mf) ;
law1 = {!!} ;
law2 = {!!} })
(λ x → {!split≅ !})
-}
{-
restSpanSplit : ∀{A B}(f : Span A B) → Split (restSpanIdem (abs f))
restSpanSplit {A}{B} f =
let open Span f
in record {
B = A';
s = abs (qs f);
r = abs (qr f);
law1 =
let open Pullback (proj₁ (pul (iden {A'}) (iso idiso)))
open Square sq
myp : Pullback (iden {A'}) (iden {A'})
myp = trivialpul (iden {A'})
lem : h ≅ k
lem = proof
h
≅⟨ sym idl ⟩
comp iden h
≅⟨ scom ⟩
comp iden k
≅⟨ idl ⟩
k
∎
lem' : compSpan (qs f) (qr f) ~Span~ restSpan f
lem' = spaneq (PMap.mor (fst (Pullback.prop myp sq)))
(pullbackiso myp (proj₁ (pul (iden {A'}) (iso idiso))))
refl
(proof
comp mhom h
≅⟨ cong (comp mhom) lem ⟩
comp mhom k
∎)
in proof
qcomp (abs (qs f)) (abs (qr f))
≅⟨ qcompabsabs ⟩
abs (compSpan (qs f) (qr f))
≅⟨ sound _ _ lem' ⟩
abs (restSpan f)
≅⟨ sym liftbetaRest ⟩
qrestSpan (abs f)
∎;
law2 =
let open Pullback (proj₁ (pul mhom m∈))
open Square sq
myp : Pullback mhom mhom
myp = monic→pullback (mon m∈)
lem : compSpan (qr f) (qs f) ~Span~ idSpan
lem = spaneq (PMap.mor (fst (Pullback.prop myp sq)))
(pullbackiso myp (proj₁ (pul mhom m∈)))
refl
(proof
comp iden h
≅⟨ idl ⟩
h
≅⟨ mon m∈ scom ⟩
k
≅⟨ sym idl ⟩
comp iden k
∎)
in proof
qcomp (abs (qr f)) (abs (qs f))
≅⟨ qcompabsabs ⟩
abs (compSpan (qr f) (qs f))
≅⟨ sound _ _ lem ⟩
abs idSpan
∎}
{-
restSpanIdem : ∀{A B}(f : Span A B) → Idem
restSpanIdem {A}{B} f = record {
E = A;
e = abs (restSpan f);
law = sound _ _ (~trans (~cong (liftbeta _) (liftbeta _)) R1p)}
restSpanSplit : ∀{A B}(f : Span A B) → Split (restSpanIdem f)
restSpanSplit {A}{B} f = let open Span f
in record {
B = A';
s = abs (record {A' = A'; mhom = iden; fhom = mhom; m∈ = iso idiso });
r = abs (record { A' = A'; mhom = mhom; fhom = iden; m∈ = m∈ });
law1 = let open Pullback (proj₁ (pul (iden {A'}) (iso idiso)))
open Square sq
myp : Pullback (iden {A'}) (iden {A'})
myp = trivialpul (iden {A'})
lem : h ≅ k
lem = proof
h
≅⟨ sym idl ⟩
comp iden h
≅⟨ scom ⟩
comp iden k
≅⟨ idl ⟩
k
∎
in sound
_
_
(~trans (~cong (liftbeta _) (liftbeta _))
(spaneq (PMap.mor (fst (Pullback.prop myp sq)))
(pullbackiso myp (proj₁ (pul (iden {A'}) (iso idiso))))
refl
(proof
comp mhom h
≅⟨ cong (comp mhom) lem ⟩
comp mhom k
∎)));
law2 = let open Pullback (proj₁ (pul mhom m∈))
open Square sq
myp : Pullback mhom mhom
myp = monic→pullback (mon m∈)
in sound
_
_
(~trans (~cong (liftbeta _) (liftbeta _))
(spaneq (PMap.mor (fst (Pullback.prop myp sq)))
(pullbackiso myp (proj₁ (pul mhom m∈)))
refl
(proof
comp iden h
≅⟨ idl ⟩
h
≅⟨ mon m∈ scom ⟩
k
≅⟨ sym idl ⟩
comp iden k
∎)))}
-}
-}
-}