Documentation

Mathlib.CategoryTheory.Monad.Basic

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)
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)
    Instances For
      Equations
      Equations

      The unit for the monad T.

      Equations
      Instances For

        The multiplication for the monad T.

        Equations
        Instances For

          The counit for the comonad G.

          Equations
          Instances For

            The comultiplication for the comonad G.

            Equations
            Instances For

              A custom simps projection for the functor part of a monad, as a coercion.

              Equations
              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
                    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
                          @[simp]
                          theorem CategoryTheory.Comonad.coassoc_assoc {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] (G : CategoryTheory.Comonad C) (X : C) {Z : C} (h : G.toPrefunctor.obj (G.toPrefunctor.obj (G.toPrefunctor.obj X)) Z) :
                          theorem CategoryTheory.MonadHom.ext_iff {C : Type u₁} :
                          ∀ {inst : CategoryTheory.Category.{v₁, u₁} C} {T₁ T₂ : CategoryTheory.Monad C} (x y : CategoryTheory.MonadHom T₁ T₂), x = y x.app = y.app
                          theorem CategoryTheory.MonadHom.ext {C : Type u₁} :
                          ∀ {inst : CategoryTheory.Category.{v₁, u₁} C} {T₁ T₂ : CategoryTheory.Monad C} (x y : CategoryTheory.MonadHom T₁ T₂), x.app = y.appx = y

                          A morphism of monads is a natural transformation compatible with η and μ.

                          Instances For
                            theorem CategoryTheory.ComonadHom.ext {C : Type u₁} :
                            ∀ {inst : CategoryTheory.Category.{v₁, u₁} C} {M N : CategoryTheory.Comonad C} (x y : CategoryTheory.ComonadHom M N), x.app = y.appx = y

                            A morphism of comonads is a natural transformation compatible with ε and δ.

                            Instances For
                              @[simp]
                              theorem CategoryTheory.MonadHom.app_μ_assoc {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {T₁ : CategoryTheory.Monad C} {T₂ : CategoryTheory.Monad C} (self : CategoryTheory.MonadHom T₁ T₂) (X : C) {Z : C} (h : T₂.toPrefunctor.obj X Z) :
                              CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.μ T₁).app X) (CategoryTheory.CategoryStruct.comp (self.toNatTrans.app X) h) = CategoryTheory.CategoryStruct.comp (T₁.toPrefunctor.map (self.toNatTrans.app X)) (CategoryTheory.CategoryStruct.comp (self.toNatTrans.app (T₂.toPrefunctor.obj X)) (CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.μ T₂).app X) h))
                              @[simp]
                              theorem CategoryTheory.ComonadHom.app_δ_assoc {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {M : CategoryTheory.Comonad C} {N : CategoryTheory.Comonad C} (self : CategoryTheory.ComonadHom M N) (X : C) {Z : C} (h : N.toPrefunctor.obj (N.toPrefunctor.obj X) Z) :
                              CategoryTheory.CategoryStruct.comp (self.toNatTrans.app X) (CategoryTheory.CategoryStruct.comp ((CategoryTheory.Comonad.δ N).app X) h) = CategoryTheory.CategoryStruct.comp ((CategoryTheory.Comonad.δ M).app X) (CategoryTheory.CategoryStruct.comp (self.toNatTrans.app (M.toPrefunctor.obj X)) (CategoryTheory.CategoryStruct.comp (N.toPrefunctor.map (self.toNatTrans.app X)) h))
                              Equations
                              • CategoryTheory.instQuiverMonad = { Hom := CategoryTheory.MonadHom }
                              Equations
                              • CategoryTheory.instQuiverComonad = { Hom := CategoryTheory.ComonadHom }
                              theorem CategoryTheory.MonadHom.ext' {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {T₁ : CategoryTheory.Monad C} {T₂ : CategoryTheory.Monad C} (f : T₁ T₂) (g : T₁ T₂) (h : f.app = g.app) :
                              f = g
                              theorem CategoryTheory.ComonadHom.ext' {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {T₁ : CategoryTheory.Comonad C} {T₂ : CategoryTheory.Comonad C} (f : T₁ T₂) (g : T₁ T₂) (h : f.app = g.app) :
                              f = g
                              Equations
                              • CategoryTheory.instCategoryMonad = CategoryTheory.Category.mk
                              @[simp]
                              @[simp]
                              theorem CategoryTheory.comp_toNatTrans {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {T₁ : CategoryTheory.Comonad C} {T₂ : CategoryTheory.Comonad C} {T₃ : CategoryTheory.Comonad C} (f : T₁ T₂) (g : T₂ T₃) :
                              @[simp]
                              theorem CategoryTheory.MonadIso.mk_inv_toNatTrans {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {M : CategoryTheory.Monad C} {N : CategoryTheory.Monad C} (f : M.toFunctor N.toFunctor) (f_η : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.η M).app X) (f.hom.app X) = (CategoryTheory.Monad.η N).app X) _auto✝) (f_μ : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.μ M).app X) (f.hom.app X) = CategoryTheory.CategoryStruct.comp (CategoryTheory.CategoryStruct.comp (M.toPrefunctor.map (f.hom.app X)) (f.hom.app (N.toPrefunctor.obj X))) ((CategoryTheory.Monad.μ N).app X)) _auto✝) :
                              (CategoryTheory.MonadIso.mk f).inv.toNatTrans = f.inv
                              @[simp]
                              theorem CategoryTheory.MonadIso.mk_hom_toNatTrans {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {M : CategoryTheory.Monad C} {N : CategoryTheory.Monad C} (f : M.toFunctor N.toFunctor) (f_η : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.η M).app X) (f.hom.app X) = (CategoryTheory.Monad.η N).app X) _auto✝) (f_μ : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.μ M).app X) (f.hom.app X) = CategoryTheory.CategoryStruct.comp (CategoryTheory.CategoryStruct.comp (M.toPrefunctor.map (f.hom.app X)) (f.hom.app (N.toPrefunctor.obj X))) ((CategoryTheory.Monad.μ N).app X)) _auto✝) :
                              (CategoryTheory.MonadIso.mk f).hom.toNatTrans = f.hom
                              def CategoryTheory.MonadIso.mk {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {M : CategoryTheory.Monad C} {N : CategoryTheory.Monad C} (f : M.toFunctor N.toFunctor) (f_η : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.η M).app X) (f.hom.app X) = (CategoryTheory.Monad.η N).app X) _auto✝) (f_μ : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.μ M).app X) (f.hom.app X) = CategoryTheory.CategoryStruct.comp (CategoryTheory.CategoryStruct.comp (M.toPrefunctor.map (f.hom.app X)) (f.hom.app (N.toPrefunctor.obj X))) ((CategoryTheory.Monad.μ N).app X)) _auto✝) :
                              M N

                              Construct a monad isomorphism from a natural isomorphism of functors where the forward direction is a monad morphism.

                              Equations
                              Instances For
                                @[simp]
                                theorem CategoryTheory.ComonadIso.mk_inv_toNatTrans {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {M : CategoryTheory.Comonad C} {N : CategoryTheory.Comonad C} (f : M.toFunctor N.toFunctor) (f_ε : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp (f.hom.app X) ((CategoryTheory.Comonad.ε N).app X) = (CategoryTheory.Comonad.ε M).app X) _auto✝) (f_δ : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp (f.hom.app X) ((CategoryTheory.Comonad.δ N).app X) = CategoryTheory.CategoryStruct.comp ((CategoryTheory.Comonad.δ M).app X) (CategoryTheory.CategoryStruct.comp (f.hom.app (M.toPrefunctor.obj X)) (N.toPrefunctor.map (f.hom.app X)))) _auto✝) :
                                (CategoryTheory.ComonadIso.mk f).inv.toNatTrans = f.inv
                                @[simp]
                                theorem CategoryTheory.ComonadIso.mk_hom_toNatTrans {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {M : CategoryTheory.Comonad C} {N : CategoryTheory.Comonad C} (f : M.toFunctor N.toFunctor) (f_ε : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp (f.hom.app X) ((CategoryTheory.Comonad.ε N).app X) = (CategoryTheory.Comonad.ε M).app X) _auto✝) (f_δ : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp (f.hom.app X) ((CategoryTheory.Comonad.δ N).app X) = CategoryTheory.CategoryStruct.comp ((CategoryTheory.Comonad.δ M).app X) (CategoryTheory.CategoryStruct.comp (f.hom.app (M.toPrefunctor.obj X)) (N.toPrefunctor.map (f.hom.app X)))) _auto✝) :
                                (CategoryTheory.ComonadIso.mk f).hom.toNatTrans = f.hom
                                def CategoryTheory.ComonadIso.mk {C : Type u₁} [CategoryTheory.Category.{v₁, u₁} C] {M : CategoryTheory.Comonad C} {N : CategoryTheory.Comonad C} (f : M.toFunctor N.toFunctor) (f_ε : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp (f.hom.app X) ((CategoryTheory.Comonad.ε N).app X) = (CategoryTheory.Comonad.ε M).app X) _auto✝) (f_δ : autoParam (∀ (X : C), CategoryTheory.CategoryStruct.comp (f.hom.app X) ((CategoryTheory.Comonad.δ N).app X) = CategoryTheory.CategoryStruct.comp ((CategoryTheory.Comonad.δ M).app X) (CategoryTheory.CategoryStruct.comp (f.hom.app (M.toPrefunctor.obj X)) (N.toPrefunctor.map (f.hom.app X)))) _auto✝) :
                                M N

                                Construct a comonad isomorphism from a natural isomorphism of functors where the forward direction is a comonad morphism.

                                Equations
                                Instances For
                                  @[simp]
                                  theorem CategoryTheory.monadToFunctor_map (C : Type u₁) [CategoryTheory.Category.{v₁, u₁} C] :
                                  ∀ {X Y : CategoryTheory.Monad C} (f : X Y), (CategoryTheory.monadToFunctor C).toPrefunctor.map f = f.toNatTrans

                                  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
                                    theorem CategoryTheory.monadToFunctor_mapIso_monad_iso_mk (C : Type u₁) [CategoryTheory.Category.{v₁, u₁} C] {M : CategoryTheory.Monad C} {N : CategoryTheory.Monad C} (f : M.toFunctor N.toFunctor) (f_η : ∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.η M).app X) (f.hom.app X) = (CategoryTheory.Monad.η N).app X) (f_μ : ∀ (X : C), CategoryTheory.CategoryStruct.comp ((CategoryTheory.Monad.μ M).app X) (f.hom.app X) = CategoryTheory.CategoryStruct.comp (CategoryTheory.CategoryStruct.comp (M.toPrefunctor.map (f.hom.app X)) (f.hom.app (N.toPrefunctor.obj X))) ((CategoryTheory.Monad.μ N).app X)) :
                                    @[simp]
                                    theorem CategoryTheory.comonadToFunctor_map (C : Type u₁) [CategoryTheory.Category.{v₁, u₁} C] :
                                    ∀ {X Y : CategoryTheory.Comonad C} (f : X Y), (CategoryTheory.comonadToFunctor C).toPrefunctor.map f = f.toNatTrans

                                    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

                                      An isomorphism of monads gives a natural isomorphism of the underlying functors.

                                      Equations
                                      Instances For

                                        An isomorphism of comonads gives a natural isomorphism of the underlying functors.

                                        Equations
                                        Instances For
                                          @[simp]
                                          theorem CategoryTheory.Monad.id_map (C : Type u₁) [CategoryTheory.Category.{v₁, u₁} C] :
                                          ∀ {X Y : C} (f : X Y), (CategoryTheory.Monad.id C).toFunctor.toPrefunctor.map f = f
                                          @[simp]
                                          theorem CategoryTheory.Monad.id_obj (C : Type u₁) [CategoryTheory.Category.{v₁, u₁} C] (X : C) :
                                          (CategoryTheory.Monad.id C).toFunctor.toPrefunctor.obj X = X

                                          The identity monad.

                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            @[simp]
                                            theorem CategoryTheory.Comonad.id_map (C : Type u₁) [CategoryTheory.Category.{v₁, u₁} C] :
                                            ∀ {X Y : C} (f : X Y), (CategoryTheory.Comonad.id C).toFunctor.toPrefunctor.map f = f
                                            @[simp]
                                            theorem CategoryTheory.Comonad.id_obj (C : Type u₁) [CategoryTheory.Category.{v₁, u₁} C] (X : C) :
                                            (CategoryTheory.Comonad.id C).toFunctor.toPrefunctor.obj X = X

                                            The identity comonad.

                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For