Tidy up
This commit is contained in:
parent
0cebe1e866
commit
485703c85e
|
@ -7,6 +7,7 @@ open import Data.Product
|
|||
|
||||
open import Cubical
|
||||
open import Cubical.NType.Properties using (lemPropF ; lemSig)
|
||||
open import Cubical.GradLemma using (gradLemma)
|
||||
|
||||
open import Cat.Category
|
||||
open import Cat.Category.Functor as F
|
||||
|
@ -357,6 +358,7 @@ module Kleisli {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where
|
|||
isMonad : IsMonad raw
|
||||
open IsMonad isMonad public
|
||||
|
||||
private
|
||||
module _ (raw : RawMonad) where
|
||||
open RawMonad raw
|
||||
propIsIdentity : isProp IsIdentity
|
||||
|
@ -376,6 +378,7 @@ module Kleisli {ℓa ℓb : Level} (ℂ : Category ℓa ℓb) where
|
|||
= propIsNatural raw (isNatural x) (isNatural y) i
|
||||
IsMonad.isDistributive (propIsMonad raw x y i)
|
||||
= propIsDistributive raw (isDistributive x) (isDistributive y) i
|
||||
|
||||
module _ {m n : Monad} (eq : Monad.raw m ≡ Monad.raw n) where
|
||||
private
|
||||
eqIsMonad : (λ i → IsMonad (eq i)) [ Monad.isMonad m ≡ Monad.isMonad n ]
|
||||
|
@ -417,28 +420,25 @@ module _ {ℓa ℓb : Level} {ℂ : Category ℓa ℓb} where
|
|||
Kleisli.Monad.isMonad (forth m) = forthIsMonad (M.Monad.isMonad m)
|
||||
|
||||
module _ (m : K.Monad) where
|
||||
private
|
||||
open K.Monad m
|
||||
module MR = M.RawMonad
|
||||
module MI = M.IsMonad
|
||||
|
||||
backRaw : M.RawMonad
|
||||
MR.R backRaw = R
|
||||
MR.pureNT backRaw = pureNT
|
||||
MR.joinNT backRaw = joinNT
|
||||
M.RawMonad.R backRaw = R
|
||||
M.RawMonad.pureNT backRaw = pureNT
|
||||
M.RawMonad.joinNT backRaw = joinNT
|
||||
|
||||
private
|
||||
open MR backRaw
|
||||
module R = Functor (MR.R backRaw)
|
||||
open M.RawMonad backRaw
|
||||
module R = Functor (M.RawMonad.R backRaw)
|
||||
|
||||
backIsMonad : M.IsMonad backRaw
|
||||
MI.isAssociative backIsMonad {X} = begin
|
||||
M.IsMonad.isAssociative backIsMonad {X} = begin
|
||||
joinT X ∘ R.func→ (joinT X) ≡⟨⟩
|
||||
join ∘ fmap (joinT X) ≡⟨⟩
|
||||
join ∘ fmap join ≡⟨ isNaturalForeign ⟩
|
||||
join ∘ join ≡⟨⟩
|
||||
joinT X ∘ joinT (R.func* X) ∎
|
||||
MI.isInverse backIsMonad {X} = inv-l , inv-r
|
||||
M.IsMonad.isInverse backIsMonad {X} = inv-l , inv-r
|
||||
where
|
||||
inv-l = begin
|
||||
joinT X ∘ pureT (R.func* X) ≡⟨⟩
|
||||
|
@ -453,23 +453,21 @@ module _ {ℓa ℓb : Level} {ℂ : Category ℓa ℓb} where
|
|||
Monoidal.Monad.raw (back m) = backRaw m
|
||||
Monoidal.Monad.isMonad (back m) = backIsMonad m
|
||||
|
||||
-- I believe all the proofs here should be `refl`.
|
||||
module _ (m : K.Monad) where
|
||||
open K.Monad m
|
||||
-- open K.RawMonad (K.Monad.raw m)
|
||||
bindEq : ∀ {X Y}
|
||||
→ K.RawMonad.bind (forthRaw (backRaw m)) {X} {Y}
|
||||
≡ K.RawMonad.bind (K.Monad.raw m)
|
||||
bindEq {X} {Y} = begin
|
||||
K.RawMonad.bind (forthRaw (backRaw m)) ≡⟨⟩
|
||||
(λ f → joinT Y ∘ func→ R f) ≡⟨⟩
|
||||
(λ f → join ∘ fmap f) ≡⟨⟩
|
||||
(λ f → bind (f >>> pure) >>> bind 𝟙) ≡⟨ funExt lem ⟩
|
||||
(λ f → bind f) ≡⟨⟩
|
||||
bind ∎
|
||||
where
|
||||
joinT = proj₁ joinNT
|
||||
lem : (f : Arrow X (omap Y)) → bind (f >>> pure) >>> bind 𝟙 ≡ bind f
|
||||
lem : (f : Arrow X (omap Y))
|
||||
→ bind (f >>> pure) >>> bind 𝟙
|
||||
≡ bind f
|
||||
lem f = begin
|
||||
bind (f >>> pure) >>> bind 𝟙
|
||||
≡⟨ isDistributive _ _ ⟩
|
||||
|
@ -481,13 +479,9 @@ module _ {ℓa ℓb : Level} {ℂ : Category ℓa ℓb} where
|
|||
≡⟨ cong bind (proj₂ ℂ.isIdentity) ⟩
|
||||
bind f ∎
|
||||
|
||||
_&_ : ∀ {ℓa ℓb} {A : Set ℓa} {B : Set ℓb} → A → (A → B) → B
|
||||
x & f = f x
|
||||
|
||||
forthRawEq : forthRaw (backRaw m) ≡ K.Monad.raw m
|
||||
K.RawMonad.omap (forthRawEq _) = omap
|
||||
K.RawMonad.pure (forthRawEq _) = pure
|
||||
-- stuck
|
||||
K.RawMonad.bind (forthRawEq i) = bindEq i
|
||||
|
||||
fortheq : (m : K.Monad) → forth (back m) ≡ m
|
||||
|
@ -550,7 +544,6 @@ module _ {ℓa ℓb : Level} {ℂ : Category ℓa ℓb} where
|
|||
backeq : (m : M.Monad) → back (forth m) ≡ m
|
||||
backeq m = M.Monad≡ (backRawEq m)
|
||||
|
||||
open import Cubical.GradLemma
|
||||
eqv : isEquiv M.Monad K.Monad forth
|
||||
eqv = gradLemma forth back fortheq backeq
|
||||
|
||||
|
|
Loading…
Reference in a new issue