module Cat.Bi.Diagram.Monad  where

Monads in a bicategoryπŸ”—

Recall that a monad on a category C\mathcal{C} consists of a functor M:Cβ†’CM : \mathcal{C} \to \mathcal{C} and natural transformations ΞΌ:MMβ‡’M\mu : MM \Rightarrow M, Ξ·:Idβ‡’M\eta : \mathrm{Id} \Rightarrow M. While the words β€œfunctor” and β€œnatural transformation” are specific to the setup where C\mathcal{C} is a category, if we replace those with β€œ1-cell” and β€œ2-cell”, then the definition works in any bicategory!

  record Monad (a : B.Ob) : Type (β„“ βŠ” β„“β€²) where
      M : a B.↦ a
      ΞΌ : (M B.βŠ— M) B.β‡’ M
      Ξ· : B.β‡’ M

The setup is, in a sense, a lot more organic when phrased in an arbitrary bicategory: Rather than dealing with the specificities of natural transformations and the category C\mathcal{C}, we abstract all of that away into the setup of the bicategory B\mathbf{B}. All we need is that the multiplication μ\mu be compatible with the associator α\alpha, and the unit η\eta must be appropriately compatible with the left and right unitors λ,ρ\lambda, \rho.

      ΞΌ-assoc : ΞΌ B.∘ (M B.β–Ά ΞΌ) ≑ ΞΌ B.∘ (ΞΌ B.β—€ M) B.∘ B.α← M M M
      ΞΌ-unitr : ΞΌ B.∘ (M B.β–Ά Ξ·) ≑ B.ρ← M
      ΞΌ-unitl : ΞΌ B.∘ (Ξ· B.β—€ M) ≑ B.λ← M

We can draw these compatibility conditions as pretty commputative diagrams. The commutative altar (on top) indicates associativity of multiplication, or more abstractly, compatibility of the multiplication with the associator. The commutative upside-down triangle indicates mutual compatibility of the multiplication and unit with the unitors.

In CatπŸ”—

To prove that this is an actual generalisation of the 1-categorical notion, we push some symbols around and prove that a monad in the bicategory Cat\mathbf{Cat} is the same thing as a monad on some category. Things are set up so that this is almost definitional, but the compatibility paths have to be adjusted slightly. Check it out below:

module _ {o β„“} {C : Precategory o β„“} where
  open Cat.Monad
  open Monad
  private module C = Cr C

  Bicat-monad→monad : Monad (Cat _ _) C → Cat.Monad C
  Bicat-monad→monad monad = monad′ where
    private module M = Monad monad

    monadβ€² : Cat.Monad C
    monadβ€² .M = M.M
    monadβ€² .unit = M.Ξ·
    monadβ€² .mult = M.ΞΌ
    monadβ€² .left-ident {x} =
        ap (M.μ .η x C.∘_) (C.intror refl)
      βˆ™ M.ΞΌ-unitr Ξ·β‚š x
    monadβ€² .right-ident {x} =
        ap (M.μ .η x C.∘_) (C.introl (M.M .Functor.F-id))
      βˆ™ M.ΞΌ-unitl Ξ·β‚š x
    monadβ€² .mult-assoc {x} =
        ap (M.μ .η x C.∘_) (C.intror refl)
     Β·Β· M.ΞΌ-assoc Ξ·β‚š x
     Β·Β· ap (M.ΞΌ .Ξ· x C.∘_) (C.elimr refl βˆ™ C.eliml (M.M .Functor.F-id))

  Monad→bicat-monad : Cat.Monad C → Monad (Cat _ _) C
  Monad→bicat-monad monad = monad′ where
    private module M = Cat.Monad monad

    monadβ€² : Monad (Cat _ _) C
    monadβ€² .M = M.M
    monadβ€² .ΞΌ = M.mult
    monadβ€² .Ξ· = M.unit
    monadβ€² .ΞΌ-assoc = Nat-path Ξ» _ β†’
        ap (M.mult .η _ C.∘_) (C.elimr refl)
     Β·Β· M.mult-assoc
     Β·Β· ap (M.mult .Ξ· _ C.∘_) (C.introl (M.M .Functor.F-id) βˆ™ C.intror refl)
    monadβ€² .ΞΌ-unitr = Nat-path Ξ» _ β†’
        ap (M.mult .η _ C.∘_) (C.elimr refl)
      βˆ™ M.left-ident
    monadβ€² .ΞΌ-unitl = Nat-path Ξ» _ β†’
        ap (M.mult .η _ C.∘_) (C.eliml (M.M .Functor.F-id))
      βˆ™ M.right-ident