0
|
1 module nat where
|
|
2
|
|
3 -- Monad
|
|
4 -- Category A
|
|
5 -- A = Category
|
|
6 -- Functor T : A -> A
|
|
7 --T(a) = t(a)
|
|
8 --T(f) = tf(f)
|
|
9
|
|
10 open import Category
|
|
11 open import Level
|
|
12 open Functor
|
|
13
|
1
|
14 --T(g f) = T(g) T(f)
|
|
15
|
0
|
16 Lemma1 : {c₁ c₂ l : Level} {A : Category c₁ c₂ l} (T : Functor A A) -> {a b c : Obj A} {g : Hom A b c} { f : Hom A a b }
|
|
17 -> A [ ( FMap T (A [ g o f ] )) ≈ (A [ FMap T g o FMap T f ]) ]
|
|
18 Lemma1 = \t -> IsFunctor.distr ( isFunctor t )
|
|
19
|
|
20 -- F(f)
|
|
21 -- F(a) ----> F(b)
|
|
22 -- | |
|
|
23 -- |t(a) |t(b) G(f)t(a) = t(b)F(f)
|
|
24 -- | |
|
|
25 -- v v
|
|
26 -- G(a) ----> G(b)
|
|
27 -- G(f)
|
|
28
|
|
29 record IsNTrans {c₁ c₂ ℓ c₁′ c₂′ ℓ′ : Level} (D : Category c₁ c₂ ℓ) (C : Category c₁′ c₂′ ℓ′)
|
|
30 ( F G : Functor D C )
|
|
31 (Trans : (A : Obj D) → Hom C (FObj F A) (FObj G A))
|
|
32 : Set (suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁′ ⊔ c₂′ ⊔ ℓ′)) where
|
|
33 field
|
|
34 naturality : {a b : Obj D} {f : Hom D a b}
|
|
35 → C [ C [ ( FMap G f ) o ( Trans a ) ] ≈ C [ (Trans b ) o (FMap F f) ] ]
|
|
36 -- how to write uniquness?
|
|
37 -- uniqness : {d : Obj D}
|
|
38 -- → ∃{e : Trans d} -> ∀{a : Trans d} → C [ e ≈ a ]
|
|
39
|
|
40
|
|
41 record NTrans {c₁ c₂ ℓ c₁′ c₂′ ℓ′ : Level} (domain : Category c₁ c₂ ℓ) (codomain : Category c₁′ c₂′ ℓ′) (F G : Functor domain codomain )
|
|
42 : Set (suc (c₁ ⊔ c₂ ⊔ ℓ ⊔ c₁′ ⊔ c₂′ ⊔ ℓ′)) where
|
|
43 field
|
|
44 Trans : (A : Obj domain) → Hom codomain (FObj F A) (FObj G A)
|
|
45 isNTrans : IsNTrans domain codomain F G Trans
|
|
46
|
|
47 open NTrans
|
1
|
48 Lemma2 : {c₁ c₂ l : Level} {A : Category c₁ c₂ l} {F G : Functor A A}
|
|
49 -> (μ : NTrans A A F G) -> {a b : Obj A} { f : Hom A a b }
|
|
50 -> A [ A [ FMap G f o Trans μ a ] ≈ A [ Trans μ b o FMap F f ] ]
|
0
|
51 Lemma2 = \n -> IsNTrans.naturality ( isNTrans n )
|
|
52
|
|
53 open import Category.Cat
|
|
54
|
|
55 -- η : 1_A -> T
|
|
56 -- μ : TT -> T
|
|
57 -- μ(a)η(T(a)) = a
|
|
58 -- μ(a)T(η(a)) = a
|
|
59 -- μ(a)(μ(T(a))) = μ(a)T(μ(a))
|
|
60
|
1
|
61 record IsMonad {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ)
|
|
62 ( T : Functor A A )
|
|
63 ( η : NTrans A A identityFunctor T )
|
|
64 ( μ : NTrans A A (T ○ T) T)
|
|
65 : Set (suc (c₁ ⊔ c₂ ⊔ ℓ )) where
|
|
66 field
|
|
67 assoc : {a : Obj A} -> A [ A [ Trans μ a o Trans μ ( FObj T a ) ] ≈ A [ Trans μ a o FMap T (Trans μ a) ] ]
|
|
68 -- unity2 : {a : Obj A} -> A [ Trans μ a o (FMap T (Trans η a )) ]
|
|
69 -- unity1 : {a : Obj A} -> A [ Trans μ a o Trans η ( FObj T a ) ]
|
0
|
70
|
1
|
71 record Monad {c₁ c₂ ℓ : Level} (A : Category c₁ c₂ ℓ) (T : Functor A A) (η : NTrans A A identityFunctor T) (μ : NTrans A A (T ○ T) T)
|
|
72 : Set (suc (c₁ ⊔ c₂ ⊔ ℓ )) where
|
|
73 field
|
|
74 isMonad : IsMonad A T η μ
|
0
|
75
|
|
76
|
|
77 -- nat of η
|
|
78
|
|
79
|
|
80 -- g ○ f = μ(c) T(g) f
|
|
81
|
|
82 -- h ○ (g ○ f) = (h ○ g) ○ f
|
|
83
|
|
84 -- η(b) ○ f = f
|
|
85 -- f ○ η(a) = f
|
|
86
|
|
87
|