Formatting

This commit is contained in:
Frederik Hanghøj Iversen 2018-02-26 20:23:31 +01:00
parent a0944d69b1
commit 5b5d21f777

View file

@ -24,14 +24,14 @@ module Monoidal {a b : Level} ( : Category a b) where
-- R ~ m
R : Functor
-- η ~ pure
ηNat : NaturalTransformation F.identity R
ηNatTrans : NaturalTransformation F.identity R
-- μ ~ join
μNat : NaturalTransformation F[ R R ] R
μNatTrans : NaturalTransformation F[ R R ] R
η : Transformation F.identity R
η = proj₁ ηNat
η = proj₁ ηNatTrans
μ : Transformation F[ R R ] R
μ = proj₁ μNat
μ = proj₁ μNatTrans
private
module R = Functor R
@ -122,17 +122,17 @@ module Kleisli {a b : Level} ( : Category a b) where
isIdentity : IsIdentity
isNatural : IsNatural
isDistributive : IsDistributive
-- | Map fusion is admissable.
fusion : Fusion
fusion {g = g} {f} = begin
fmap (g f) ≡⟨⟩
-- f >=> g = >>= g ∘ f
bind ((f >>> g) >>> pure) ≡⟨ cong bind isAssociative
bind (f >>> (g >>> pure)) ≡⟨ cong (λ φ bind (f >>> φ)) (sym (isNatural _))
bind (f >>> (pure >>> (bind (g >>> pure)))) ≡⟨⟩
bind (f >>> (pure >>> fmap g)) ≡⟨⟩
bind ((fmap g pure) f) ≡⟨ cong bind (sym isAssociative)
bind
(fmap g (pure f)) ≡⟨ sym lem
bind (fmap g (pure f)) ≡⟨ sym lem
bind (pure g) bind (pure f) ≡⟨⟩
fmap g fmap f
where
@ -155,7 +155,9 @@ module Kleisli {a b : Level} ( : Category a b) where
res : (λ i IsMonad (eq i)) [ Monad.isMonad m Monad.isMonad n ]
res = {!!}
-- Problem 2.3
-- | The monoidal- and kleisli presentation of monads are equivalent.
--
-- This is problem 2.3 in [voe].
module _ {a b : Level} { : Category a b} where
private
open Category using (Object ; Arrow ; 𝟙 ; _∘_)
@ -187,7 +189,7 @@ module _ {a b : Level} { : Category a b} where
private
open M.IsMonad m
open K.RawMonad (forthRaw raw)
module Kis = K.IsMonad
module R = Functor R
isIdentity : IsIdentity
isIdentity {X} = begin
@ -196,7 +198,6 @@ module _ {a b : Level} { : Category a b} where
μ X func→ R (η X) ≡⟨ proj₂ isInverse
𝟙
module R = Functor R
isNatural : IsNatural
isNatural {X} {Y} f = begin
bind f pure ≡⟨⟩
@ -211,7 +212,7 @@ module _ {a b : Level} { : Category a b} where
open NaturalTransformation
module = Category
ηN : Natural F.identity R η
ηN = proj₂ ηNat
ηN = proj₂ ηNatTrans
isDistributive : IsDistributive
isDistributive {X} {Y} {Z} g f = begin
@ -243,16 +244,17 @@ module _ {a b : Level} { : Category a b} where
{a : Arrow D E} {b : Arrow C D} {c : Arrow B C} {d : Arrow A B}
a (b c d) a b c d
comm = {!!}
μN = proj₂ μNat
μN = proj₂ μNatTrans
lemmm : μ Z R.func→ (μ Z) μ Z μ (R.func* Z)
lemmm = isAssociative
lem4 : μ (R.func* Z) RR.func→ g R.func→ g μ Y
lem4 = μN g
module KI = K.IsMonad
forthIsMonad : K.IsMonad (forthRaw raw)
Kis.isIdentity forthIsMonad = isIdentity
Kis.isNatural forthIsMonad = isNatural
Kis.isDistributive forthIsMonad = isDistributive
KI.isIdentity forthIsMonad = isIdentity
KI.isNatural forthIsMonad = isNatural
KI.isDistributive forthIsMonad = isDistributive
forth : M.Monad K.Monad
Kleisli.Monad.raw (forth m) = forthRaw (M.Monad.raw m)
@ -262,7 +264,6 @@ module _ {a b : Level} { : Category a b} where
private
module = Category
open K.Monad m
module Mraw = M.RawMonad
open NaturalTransformation
rawR : RawFunctor
@ -274,6 +275,7 @@ module _ {a b : Level} { : Category a b} where
bind (pure 𝟙) ≡⟨ cong bind (proj₁ .isIdentity)
bind pure ≡⟨ isIdentity
𝟙
IsFunctor.isDistributive isFunctorR {f = f} {g} = begin
bind (pure (g f)) ≡⟨⟩
fmap (g f) ≡⟨ fusion
@ -284,19 +286,20 @@ module _ {a b : Level} { : Category a b} where
Functor.raw R = rawR
Functor.isFunctor R = isFunctorR
R2 : Functor
R2 = F[ R R ]
R² : Functor
R² = F[ R R ]
ηNat : NaturalTransformation F.identity R
ηNat = {!!}
ηNatTrans : NaturalTransformation F.identity R
ηNatTrans = {!!}
μNat : NaturalTransformation R2 R
μNat = {!!}
μNatTrans : NaturalTransformation R² R
μNatTrans = {!!}
module MR = M.RawMonad
backRaw : M.RawMonad
Mraw.R backRaw = R
Mraw.ηNat backRaw = ηNat
Mraw.μNat backRaw = μNat
MR.R backRaw = R
MR.ηNatTrans backRaw = ηNatTrans
MR.μNatTrans backRaw = μNatTrans
module _ (m : K.Monad) where
open K.Monad m
@ -327,8 +330,8 @@ module _ {a b : Level} { : Category a b} where
backRawEq : backRaw (forth m) M.Monad.raw m
-- stuck
M.RawMonad.R (backRawEq i) = {!!}
M.RawMonad.ηNat (backRawEq i) = {!!}
M.RawMonad.μNat (backRawEq i) = {!!}
M.RawMonad.ηNatTrans (backRawEq i) = {!!}
M.RawMonad.μNatTrans (backRawEq i) = {!!}
backeq : (m : M.Monad) back (forth m) m
backeq m = M.Monad≡ (backRawEq m)