module Cat.Monoidal.Diagram.Comonoid where

Comonoids in a monoidal categoryπŸ”—

A comonoid in a monoidal category is the dual concept of a monoid, similarly consisting of diagrams in centred around an object the comonoid itself.

Instead of a unit we have a β€œcounit” map and β€œcomultiplication” map The intuition is that describes a way to destroy data and describes a way to duplicate data. Again, these maps should be compatible with the unitors and associator of the underlying monoidal category:

  record Comonoid-on (M : C.Ob) : Type β„“ where
    no-eta-equality
    field
      Ξ΅ : C.Hom M C.Unit
      Ξ” : C.Hom M (M C.βŠ— M)

      Ξ”-counitl : (Ξ΅ C.β—€ _) C.∘ Ξ” ≑ C.Ξ»β†’ _
      Ξ”-counitr : (_ C.β–Ά Ξ΅) C.∘ Ξ” ≑ C.ρ→ _
      Ξ”-coassoc : (_ C.β–Ά Ξ”) C.∘ Ξ” ≑ C.Ξ±β†’ _ C.∘ (Ξ” C.β—€ _) C.∘ Ξ”

The category Comon(C)πŸ”—

Just as with monoids, the comonoid objects in can be made into a category, which we define here as a category displayed over

This means constructing a predicate on maps expressing the condition of being a comonoid homomorphism, which is dual to is-monoid-hom.

  record
    is-comonoid-hom {m n} (f : C.Hom m n)
     (mo : Comonoid-on Cᡐ m) (no : Comonoid-on Cᡐ n) : Type β„“ where

    private
      module m = Comonoid-on mo
      module n = Comonoid-on no

    field
      pres-Ξ΅ : n.Ξ΅ C.∘ f ≑ m.Ξ΅
      pres-Ξ” : n.Ξ” C.∘ f ≑ (f C.βŠ—β‚ f) C.∘ m.Ξ”

Again, we see that being a comonoid homomorphism is a pair of propositions and thus is itself a proposition, greatly simplifying the construction of the displayed category.

  Comon[_] : Displayed C β„“ β„“
  Comon[_] = with-thin-display record where
    Ob[_] = Comonoid-on Cᡐ
    Hom[_] = is-comonoid-hom

    id' = record where
      pres-Ξ΅ = C.idr _
      pres-Ξ” = C.idr _ βˆ™ C.introl C.βŠ—.F-id

    _∘'_ {x = x} {y} {z} {f} {g} fh gh = record where
      pres-Ξ΅ = C.pulll (fh .pres-Ξ΅) βˆ™ gh .pres-Ξ΅
      pres-Ξ” =
        z .Comonoid-on.Ξ” C.∘ f C.∘ g                    β‰‘βŸ¨ C.extendl (fh .pres-Ξ”) βŸ©β‰‘
        (f C.βŠ—β‚ f) C.∘ y .Comonoid-on.Ξ” C.∘ g           β‰‘βŸ¨ (C.refl⟩∘⟨ gh .pres-Ξ”) βŸ©β‰‘
        (f C.βŠ—β‚ f) C.∘ (g C.βŠ—β‚ g) C.∘ x .Comonoid-on.Ξ”  β‰‘Λ˜βŸ¨ C.pushl (C.βŠ—.F-∘ _ _) βŸ©β‰‘Λ˜
        (f C.∘ g C.βŠ—β‚ f C.∘ g) C.∘ x .Comonoid-on.Ξ”     ∎