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.toPrefunctor.map (CategoryTheory.CategoryStruct.id X) = CategoryTheory.CategoryStruct.id (self.toPrefunctor.obj X)
- map_comp : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), self.toPrefunctor.map (CategoryTheory.CategoryStruct.comp f g) = CategoryTheory.CategoryStruct.comp (self.toPrefunctor.map f) (self.toPrefunctor.map g)
- η' : CategoryTheory.Functor.id C ⟶ self.toFunctor
- μ' : CategoryTheory.Functor.comp self.toFunctor self.toFunctor ⟶ self.toFunctor
- assoc' : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.toPrefunctor.map (self.μ'.app X)) (self.μ'.app X) = CategoryTheory.CategoryStruct.comp (self.μ'.app (self.toPrefunctor.obj X)) (self.μ'.app X)
- left_unit' : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.η'.app (self.toPrefunctor.obj X)) (self.μ'.app X) = CategoryTheory.CategoryStruct.id ((CategoryTheory.Functor.id C).toPrefunctor.obj (self.toPrefunctor.obj X))
- right_unit' : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.toPrefunctor.map (self.η'.app X)) (self.μ'.app X) = CategoryTheory.CategoryStruct.id (self.toPrefunctor.obj ((CategoryTheory.Functor.id C).toPrefunctor.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.toPrefunctor.map (CategoryTheory.CategoryStruct.id X) = CategoryTheory.CategoryStruct.id (self.toPrefunctor.obj X)
- map_comp : ∀ {X Y Z : C} (f : X ⟶ Y) (g : Y ⟶ Z), self.toPrefunctor.map (CategoryTheory.CategoryStruct.comp f g) = CategoryTheory.CategoryStruct.comp (self.toPrefunctor.map f) (self.toPrefunctor.map g)
- ε' : self.toFunctor ⟶ CategoryTheory.Functor.id C
- δ' : self.toFunctor ⟶ CategoryTheory.Functor.comp self.toFunctor self.toFunctor
- coassoc' : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.δ'.app X) (self.toPrefunctor.map (self.δ'.app X)) = CategoryTheory.CategoryStruct.comp (self.δ'.app X) (self.δ'.app (self.toPrefunctor.obj X))
- left_counit' : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.δ'.app X) (self.ε'.app (self.toPrefunctor.obj X)) = CategoryTheory.CategoryStruct.id (self.toPrefunctor.obj X)
- right_counit' : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.δ'.app X) (self.toPrefunctor.map (self.ε'.app X)) = CategoryTheory.CategoryStruct.id (self.toPrefunctor.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 }
The unit for the monad T
.
Equations
- CategoryTheory.Monad.η T = T.η'
Instances For
The multiplication for the monad T
.
Equations
- CategoryTheory.Monad.μ T = T.μ'
Instances For
The counit for the comonad G
.
Equations
- CategoryTheory.Comonad.ε G = G.ε'
Instances For
The comultiplication for the comonad G
.
Equations
- CategoryTheory.Comonad.δ G = G.δ'
Instances For
A custom simps projection for the functor part of a monad, as a coercion.
Equations
- CategoryTheory.Monad.Simps.coe T = T.toFunctor
Instances For
A custom simps projection for the unit of a monad, in simp normal form.
Equations
Instances For
A custom simps projection for the multiplication of a monad, in simp normal form.
Equations
Instances For
A custom simps projection for the functor part of a comonad, as a coercion.
Equations
- CategoryTheory.Comonad.Simps.coe G = G.toFunctor
Instances For
A custom simps projection for the counit of a comonad, in simp normal form.
Equations
Instances For
A custom simps projection for the comultiplication of a comonad, in simp normal form.
Equations
Instances For
A morphism of monads is a natural transformation compatible with η and μ.
- app : (X : C) → T₁.toPrefunctor.obj X ⟶ T₂.toPrefunctor.obj X
- naturality : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), CategoryTheory.CategoryStruct.comp (T₁.toPrefunctor.map f) (self.toNatTrans.app Y) = CategoryTheory.CategoryStruct.comp (self.toNatTrans.app X) (T₂.toPrefunctor.map f)
- app_η : ∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.η T₁).app X) (self.toNatTrans.app X) = (CategoryTheory.Monad.η T₂).app X
- app_μ : ∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.μ T₁).app X) (self.toNatTrans.app X) = CategoryTheory.CategoryStruct.comp (CategoryTheory.CategoryStruct.comp (T₁.toPrefunctor.map (self.toNatTrans.app X)) (self.toNatTrans.app (T₂.toPrefunctor.obj X))) ((CategoryTheory.Monad.μ T₂).app X)
Instances For
A morphism of comonads is a natural transformation compatible with ε and δ.
- app : (X : C) → M.toPrefunctor.obj X ⟶ N.toPrefunctor.obj X
- naturality : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), CategoryTheory.CategoryStruct.comp (M.toPrefunctor.map f) (self.toNatTrans.app Y) = CategoryTheory.CategoryStruct.comp (self.toNatTrans.app X) (N.toPrefunctor.map f)
- app_ε : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.toNatTrans.app X) ((CategoryTheory.Comonad.ε N).app X) = (CategoryTheory.Comonad.ε M).app X
- app_δ : ∀ (X : C), CategoryTheory.CategoryStruct.comp (self.toNatTrans.app X) ((CategoryTheory.Comonad.δ N).app X) = CategoryTheory.CategoryStruct.comp ((CategoryTheory.Comonad.δ M).app X) (CategoryTheory.CategoryStruct.comp (self.toNatTrans.app (M.toPrefunctor.obj X)) (N.toPrefunctor.map (self.toNatTrans.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
Instances For
Construct a comonad isomorphism from a natural isomorphism of functors where the forward direction is a comonad morphism.
Equations
Instances For
The forgetful functor from the category of monads to the category of endofunctors.
Equations
- One or more equations did not get rendered due to their size.
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
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.instInhabitedMonad 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.instInhabitedComonad C = { default := CategoryTheory.Comonad.id C }