-
Notifications
You must be signed in to change notification settings - Fork 2
/
Lawvere.agda
142 lines (130 loc) · 4.7 KB
/
Lawvere.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
module Lawvere where
open import Library
open import Data.Sum
open import Categories
open import Categories.Sets
open import Categories.Initial
open import Categories.PushOuts
open import Categories.Products hiding (_×_)
open import Categories.CoProducts
open import Categories.Terminal
open import Functors
open import Functors.Fin
record Lawvere {a}{b} : Set (lsuc (a ⊔ b)) where
constructor lawvere
field T : Cat {a}{b}
L : Fun (Nats Op) T
L0 : Term T (Fun.OMap L zero)
LP : ∀ m n → Prod T (Fun.OMap L m) (Fun.OMap L n)
-- it's not the identity, it switches some implicit in fid and fcomp I think
FunOp : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}} →
Fun C D → Fun (C Op) (D Op)
FunOp (functor OMap HMap fid fcomp) = functor OMap HMap fid fcomp
LSet : Lawvere
LSet = lawvere
(Sets Op)
(FunOp FinF)
(term (λ ()) (ext λ ()))
λ m n → prod
(Fin m ⊎ Fin n)
inj₁
inj₂
[_,_]′
refl
refl
λ p q → ext (λ{ (inj₁ a) -> fcong a p; (inj₂ b) -> fcong b q})
open import RMonads
open import RMonads.RKleisli
open import RMonads.RKleisli.Functors
lem : RMonad FinF → Lawvere {lzero}{lzero}
lem M = lawvere
(Kl M Op)
(FunOp (RKlL M) )
(term (λ ()) (ext λ ()))
λ m n → prod
(m + n)
(η ∘ extend)
(η ∘ lift m)
(case m)
(ext λ i → trans (fcong (extend i) law2) (lem1 m _ _ i))
(ext λ i → trans (fcong (lift m i) law2) (lem2 m _ _ i))
λ {o} {f} {g} {h} p q → ext (lem3
m
f
g
h
(trans (ext λ i → sym (fcong (extend i) law2)) p)
(trans (ext λ i → sym (fcong (lift m i) law2)) q))
where open RMonad M
lem-1 : Lawvere {lzero}{lzero} → RMonad FinF
lem-1 LT = rmonad
(λ n → Cat.Hom (Lawvere.T LT) (Fun.OMap (Lawvere.L LT) 1) (Fun.OMap (Lawvere.L LT) n))
{!!}
{!!}
{!!}
{!!}
{!!}
open import Categories.Products
record Model {a}{b}{c}{d} (Law : Lawvere {a}{b}) : Set (lsuc (a ⊔ b ⊔ c ⊔ d))
where
open Lawvere Law
field C : Cat {c}{d}
F : Fun T C
F0 : Term C (Fun.OMap F (Fun.OMap L zero))
FP : ∀ m n → Prod C (Fun.OMap F (Fun.OMap L m))
(Fun.OMap F (Fun.OMap L n))
open import RMonads.REM
open import RMonads.CatofRAdj.InitRAdj
open import RMonads.CatofRAdj.TermRAdjObj
open import RMonads.REM.Functors
model : (T : RMonad FinF) → Model (lem T)
model T = record {
C = EM T Op ;
F = FunOp (K' T (EMObj T));
F0 = term (λ{alg} → ralgmorph (RAlg.astr alg {0} (λ ()))
(λ {n}{f} →
sym $ RAlg.alaw2 alg {n}{zero}{f}{λ ()} ))
(λ{alg}{f} → RAlgMorphEq T (ext (λ t → trans
(trans (cong (λ f₁ → RAlg.astr alg f₁ t) (ext (λ ())))
(sym (fcong t (RAlgMorph.ahom f {0}{RMonad.η T}))))
(cong (RAlgMorph.amor f) (fcong t (RMonad.law1 T))))));
FP = λ m n → prod
(Fun.OMap (REML FinF T) (m + n) )
(Fun.HMap (REML FinF T) extend)
(Fun.HMap (REML FinF T) (lift m))
(λ{alg} f g → ralgmorph
(RAlg.astr alg
(case m (RAlgMorph.amor f ∘ RMonad.η T)
(RAlgMorph.amor g ∘ RMonad.η T)))
(sym (RAlg.alaw2 alg)))
(λ {alg}{f}{g} → RAlgMorphEq T (trans
(sym (RAlg.alaw2 alg))
(trans (cong (RAlg.astr alg)
(ext λ i → trans (fcong (extend i) (sym (RAlg.alaw1 alg)))
(lem1 m _ _ i)))
(trans (sym (RAlgMorph.ahom f))
(ext λ i → cong (RAlgMorph.amor f)
(fcong i (RMonad.law1 T)))))))
(λ {alg}{f}{g} → RAlgMorphEq T (trans
(sym (RAlg.alaw2 alg))
(trans (cong (RAlg.astr alg)
(ext λ i → trans (fcong (lift m i) (sym (RAlg.alaw1 alg)))
(lem2 m _ _ i)))
(trans (sym (RAlgMorph.ahom g))
(ext λ i → cong (RAlgMorph.amor g)
(fcong i (RMonad.law1 T)))))))
λ{alg}{f}{g}{h} p q → RAlgMorphEq T (trans
(trans (ext λ i → cong (RAlgMorph.amor h)
(sym (fcong i (RMonad.law1 T))))
(RAlgMorph.ahom h))
(cong (RAlg.astr alg) (ext (lem3
m
(RAlgMorph.amor f ∘ RMonad.η T)
(RAlgMorph.amor g ∘ RMonad.η T)
(RAlgMorph.amor h ∘ RMonad.η T)
(ext λ i → trans
(cong (RAlgMorph.amor h) (sym (fcong i (RMonad.law2 T))))
(fcong (RMonad.η T i) (cong RAlgMorph.amor p)))
(ext λ i → trans
(cong (RAlgMorph.amor h) (sym (fcong i (RMonad.law2 T))))
(fcong (RMonad.η T i) (cong RAlgMorph.amor q)))))))}