module Cat.Bi.Diagram.Monad where
open _=>_ hiding (η)
open Functor
module _ {o ℓ ℓ'} (B : Prebicategory o ℓ ℓ') where
private module B = Prebicategory B
Monads in a bicategory🔗
Recall that a monad on a category consists of a functor and natural transformations While the words “functor” and “natural transformation” are specific to the setup where 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
field
: a B.↦ a
M : (M B.⊗ M) B.⇒ M
μ : B.id 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 we abstract all of that away into the setup of the bicategory All we need is that the multiplication be compatible with the associator and the unit must be appropriately compatible with the left and right unitors
: μ B.∘ (M B.▶ μ) ≡ μ B.∘ (μ B.◀ M) B.∘ B.α← M M M
μ-assoc : μ B.∘ (M B.▶ η) ≡ B.ρ← M
μ-unitr : μ B.∘ (η B.◀ M) ≡ B.λ← M μ-unitl
We can draw these compatibility conditions as pretty commutative 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 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-on
open Monad
private module C = Cr C
: Monad (Cat _ _) C → Cat.Monad C
Bicat-monad→monad = _ , monad' where
Bicat-monad→monad monad module M = Monad monad
: Cat.Monad-on M.M
monad' .unit = M.η
monad' .mult = M.μ
monad' .μ-unitr {x} =
monad' (M.μ ._=>_.η x C.∘_) (C.intror refl)
ap .μ-unitr ηₚ x
∙ M.μ-unitl {x} =
monad' (M.μ ._=>_.η x C.∘_) (C.introl (M.M .Functor.F-id))
ap .μ-unitl ηₚ x
∙ M.μ-assoc {x} =
monad' (M.μ ._=>_.η x C.∘_) (C.intror refl)
ap .μ-assoc ηₚ x
∙∙ M(M.μ ._=>_.η x C.∘_) (C.elimr refl ∙ C.eliml (M.M .Functor.F-id))
∙∙ ap
: Cat.Monad C → Monad (Cat _ _) C
Monad→bicat-monad (M , monad) = monad' where
Monad→bicat-monad module M = Cat.Monad-on (monad)
: Monad (Cat _ _) C
monad' .Monad.M = M
monad' .μ = M.mult
monad' .η = M.unit
monad' .μ-assoc = ext λ _ →
monad' (M.μ _ C.∘_) (C.elimr refl)
ap .μ-assoc
∙∙ M(M.μ _ C.∘_) (C.introl (M.M-id) ∙ C.intror refl)
∙∙ ap .μ-unitr = ext λ _ →
monad' (M.μ _ C.∘_) (C.elimr refl)
ap .μ-unitr
∙ M.μ-unitl = ext λ _ →
monad' (M.μ _ C.∘_) (C.eliml M.M-id)
ap .μ-unitl ∙ M
module _ {o ℓ ℓ'} (B : Prebicategory o ℓ ℓ') where
private
open module B = Prebicategory B
Monads as lax functors🔗
Suppose that we have a lax functor from the terminal bicategory to Then identifies a single object as well as a morphism given by The composition operation is a natural transformation i.e. a natural transformation Finally, the unitor gives Altogether, this is exactly the same data as an object and a monad in on
: Σ[ a ∈ B.Ob ] Monad B a → Lax-functor ⊤Bicat B
monad→lax-functor (a , monad) = P where
monad→lax-functor open Monad monad
open Lax-functor
: Lax-functor ⊤Bicat B
P .P₀ _ = a
P .P₁ = !Const M
P .compositor ._=>_.η _ = μ
P .compositor .is-natural _ _ _ = B.Hom.elimr (B.compose .F-id) ∙ sym (B.Hom.idl _)
P .unitor = η
P .hexagon _ _ _ =
P .id ∘ μ ∘ (μ ◀ M) ≡⟨ Hom.pulll (Hom.idl _) ⟩
Hom(μ ◀ M) ≡⟨ Hom.intror $ ap (λ nt → nt ._=>_.η (M , M , M)) associator.invr ⟩
μ ∘ (μ ∘ μ ◀ M) ∘ (α← M M M ∘ α→ M M M) ≡⟨ cat! (Hom a a) ⟩
(μ ∘ μ ◀ M ∘ α← M M M) ∘ α→ M M M ≡˘⟨ Hom.pulll μ-assoc ⟩
(M ▶ μ) ∘ (α→ M M M) ∎
μ ∘ .right-unit _ = Hom.id ∘ μ ∘ M ▶ η ≡⟨ Hom.idl _ ∙ μ-unitr ⟩ ρ← M ∎
P .left-unit _ = Hom.id ∘ μ ∘ (η ◀ M) ≡⟨ Hom.idl _ ∙ μ-unitl ⟩ λ← M ∎
P
: Lax-functor ⊤Bicat B → Σ[ a ∈ B.Ob ] Monad B a
lax-functor→monad = (a , record { monad }) where
lax-functor→monad P open Lax-functor P
: B.Ob
a = P₀ tt
a
module monad where
= P₁.F₀ _
M = γ→ _ _
μ = unitor
η =
μ-assoc (Hom.intror $ ap (λ nt → nt ._=>_.η (M , M , M)) associator.invl) ⟩
μ ∘ M ▶ μ ≡⟨ (μ ∘ M ▶ μ) ∘ (α→ M M M ∘ α← M M M) ≡⟨ cat! (Hom a a) ⟩
(μ ∘ M ▶ μ ∘ α→ M M M) ∘ α← M M M ≡˘⟨ hexagon _ _ _ Hom.⟩∘⟨refl ⟩
(P₁.F₁ _ ∘ μ ∘ μ ◀ M) ∘ α← M M M ≡⟨ ( P₁.F-id Hom.⟩∘⟨refl) Hom.⟩∘⟨refl ⟩
(Hom.id ∘ μ ∘ μ ◀ M) ∘ α← M M M ≡⟨ cat! (Hom a a) ⟩
μ ∘ μ ◀ M ∘ α← M M M ∎= P₁.introl refl ∙ right-unit _
μ-unitr = P₁.introl refl ∙ left-unit _ μ-unitl