Monads #
We construct the categories of monads and comonads, and their forgetful functors to endofunctors.
(Note that these are the category theorist's monads, not the programmers monads.
For the translation, see the file CategoryTheory.Monad.Types
.)
For the fact that monads are "just" monoids in the category of endofunctors, see the file
CategoryTheory.Monad.EquivMon
.
The data of a monad on C consists of an endofunctor T together with natural transformations η : 𝟭 C ⟶ T and μ : T ⋙ T ⟶ T satisfying three equations:
- T μ_X ≫ μ_X = μ_(TX) ≫ μ_X (associativity)
- η_(TX) ≫ μ_X = 1_X (left unit)
- Tη_X ≫ μ_X = 1_X (right unit)
- obj : C → C
- map_id : ∀ (X : C), self.map (CategoryTheory.CategoryStruct.id X) = CategoryTheory.CategoryStruct.id (self.obj X)
- map_comp : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), self.map (CategoryTheory.CategoryStruct.comp f g) = CategoryTheory.CategoryStruct.comp (self.map f) (self.map g)
- η : CategoryTheory.Functor.id C ⟶ self.toFunctor
The unit for the monad.
- μ : self.comp self.toFunctor ⟶ self.toFunctor
The multiplication for the monad.
- assoc : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.map (self.μ.app X)) (self.μ.app X) = CategoryTheory.CategoryStruct.comp (self.μ.app (self.obj X)) (self.μ.app X)
- left_unit : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.η.app (self.obj X)) (self.μ.app X) = CategoryTheory.CategoryStruct.id ((CategoryTheory.Functor.id C).obj (self.obj X))
- right_unit : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.map (self.η.app X)) (self.μ.app X) = CategoryTheory.CategoryStruct.id (self.obj ((CategoryTheory.Functor.id C).obj X))
Instances For
The data of a comonad on C consists of an endofunctor G together with natural transformations ε : G ⟶ 𝟭 C and δ : G ⟶ G ⋙ G satisfying three equations:
- δ_X ≫ G δ_X = δ_X ≫ δ_(GX) (coassociativity)
- δ_X ≫ ε_(GX) = 1_X (left counit)
- δ_X ≫ G ε_X = 1_X (right counit)
- obj : C → C
- map_id : ∀ (X : C), self.map (CategoryTheory.CategoryStruct.id X) = CategoryTheory.CategoryStruct.id (self.obj X)
- map_comp : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), self.map (CategoryTheory.CategoryStruct.comp f g) = CategoryTheory.CategoryStruct.comp (self.map f) (self.map g)
- ε : self.toFunctor ⟶ CategoryTheory.Functor.id C
The counit for the comonad.
- δ : self.toFunctor ⟶ self.comp self.toFunctor
The comultiplication for the comonad.
- coassoc : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.δ.app X) (self.map (self.δ.app X)) = CategoryTheory.CategoryStruct.comp (self.δ.app X) (self.δ.app (self.obj X))
- left_counit : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.δ.app X) (self.ε.app (self.obj X)) = CategoryTheory.CategoryStruct.id (self.obj X)
- right_counit : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.δ.app X) (self.map (self.ε.app X)) = CategoryTheory.CategoryStruct.id (self.obj X)
Instances For
Equations
- CategoryTheory.coeMonad = { coe := fun (T : CategoryTheory.Monad C) => T.toFunctor }
Equations
- CategoryTheory.coeComonad = { coe := fun (G : CategoryTheory.Comonad C) => G.toFunctor }
A morphism of monads is a natural transformation compatible with η and μ.
- naturality : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), CategoryTheory.CategoryStruct.comp (T₁.map f) (self.app Y) = CategoryTheory.CategoryStruct.comp (self.app X) (T₂.map f)
- app_η : ∀ (X : C), CategoryTheory.CategoryStruct.comp (T₁.η.app X) (self.app X) = T₂.η.app X
- app_μ : ∀ (X : C), CategoryTheory.CategoryStruct.comp (T₁.μ.app X) (self.app X) = CategoryTheory.CategoryStruct.comp (CategoryTheory.CategoryStruct.comp (T₁.map (self.app X)) (self.app (T₂.obj X))) (T₂.μ.app X)
Instances For
A morphism of comonads is a natural transformation compatible with ε and δ.
- naturality : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), CategoryTheory.CategoryStruct.comp (M.map f) (self.app Y) = CategoryTheory.CategoryStruct.comp (self.app X) (N.map f)
- app_ε : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.app X) (N.ε.app X) = M.ε.app X
- app_δ : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.app X) (N.δ.app X) = CategoryTheory.CategoryStruct.comp (M.δ.app X) (CategoryTheory.CategoryStruct.comp (self.app (M.obj X)) (N.map (self.app X)))
Instances For
Equations
- CategoryTheory.instQuiverMonad = { Hom := CategoryTheory.MonadHom }
Equations
- CategoryTheory.instQuiverComonad = { Hom := CategoryTheory.ComonadHom }
Equations
- CategoryTheory.instCategoryMonad = CategoryTheory.Category.mk ⋯ ⋯ ⋯
Equations
- CategoryTheory.instCategoryComonad = CategoryTheory.Category.mk ⋯ ⋯ ⋯
Equations
- CategoryTheory.instInhabitedMonadHom = { default := CategoryTheory.CategoryStruct.id T }
Equations
- CategoryTheory.instInhabitedComonadHom = { default := CategoryTheory.CategoryStruct.id G }
Construct a monad isomorphism from a natural isomorphism of functors where the forward direction is a monad morphism.
Equations
- CategoryTheory.MonadIso.mk f f_η f_μ = { hom := { toNatTrans := f.hom, app_η := f_η, app_μ := f_μ }, inv := { toNatTrans := f.inv, app_η := ⋯, app_μ := ⋯ }, hom_inv_id := ⋯, inv_hom_id := ⋯ }
Instances For
Construct a comonad isomorphism from a natural isomorphism of functors where the forward direction is a comonad morphism.
Equations
- CategoryTheory.ComonadIso.mk f f_ε f_δ = { hom := { toNatTrans := f.hom, app_ε := f_ε, app_δ := f_δ }, inv := { toNatTrans := f.inv, app_ε := ⋯, app_δ := ⋯ }, hom_inv_id := ⋯, inv_hom_id := ⋯ }
Instances For
The forgetful functor from the category of monads to the category of endofunctors.
Equations
- CategoryTheory.monadToFunctor C = { obj := fun (T : CategoryTheory.Monad C) => T.toFunctor, map := fun {X Y : CategoryTheory.Monad C} (f : X ⟶ Y) => f.toNatTrans, map_id := ⋯, map_comp := ⋯ }
Instances For
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
The forgetful functor from the category of comonads to the category of endofunctors.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- ⋯ = ⋯
Equations
- ⋯ = ⋯
An isomorphism of monads gives a natural isomorphism of the underlying functors.
Equations
- CategoryTheory.MonadIso.toNatIso h = (CategoryTheory.monadToFunctor C).mapIso h
Instances For
An isomorphism of comonads gives a natural isomorphism of the underlying functors.
Equations
- CategoryTheory.ComonadIso.toNatIso h = (CategoryTheory.comonadToFunctor C).mapIso h
Instances For
The identity monad.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- CategoryTheory.Monad.instInhabited C = { default := CategoryTheory.Monad.id C }
The identity comonad.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- CategoryTheory.Comonad.instInhabited C = { default := CategoryTheory.Comonad.id C }
Transport a monad structure on a functor along an isomorphism of functors.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Transport a comonad structure on a functor along an isomorphism of functors.
Equations
- One or more equations did not get rendered due to their size.