Monoidal Category

One of the defining features of is the plurality of monoidal products within it. To represent them we give the definition of a monoidal category which we will instanciate with multiple monoidal product in .

Definition

A monoidal product on a Category is given by:

  • A bifunctor
  • An object
  • Natural Isomorphisms:
    • For associativity
    • For units on the left :
    • For units on the right :
record Monoidal {0 o : Type} (c : Category o) where
  constructor MkMonoidal
 
  mult : Bifunctor c c c
 
  i : o
  alpha : let f1, f2 : (c × (c × c)) ->> c
              f1 = ((idF _) `pair` mult) ⨾⨾ mult
              f2 = assocR ⨾⨾ ((mult `pair` idF _) ⨾⨾ mult)
          in f1 =~= f2

TODO: add diagram

  leftUnitor :
      let 0 leftAppliedMult : c ->> c
          leftAppliedMult = applyL {a = c, b = c, c} i mult
      in leftAppliedMult =~= idF c

TODO: add diagram

  rightUnitor :
      let 0 rightAppliedMult : c ->> c
          rightAppliedMult = applyR i mult
      in rightAppliedMult =~= idF c

Like before, we define a couple of utility functions to more easily manipulate monoidal products. uses the product’s bifunctor to combine objects and uses the same functor to combine morphisms.

() : {auto 0 cat : Category o} -> (mon : Monoidal cat) => o -> o -> o
() a b = mon.mult.mapObj (a && b)
 
public export 0
(-⊗-)  : {auto 0 cat : Category o} -> {0 x, y, a, b : o} -> (mon : Monoidal cat) =>
       x ~> y -> a ~> b -> x  a ~> y  b
(-⊗-) m1 m2 = mon.mult.mapHom (x && a) (y && b) (m1 && m2)

Monoids in a Monoidal Category

Given a monoidal category, we define monoids in that category by leveraging the monoidal structure of the category.

Definition

Given a category and a monoidal product on it. A monoid object with respect to this structure is a triple where:

  • is an object of
  • combines those objects using the monoidal product from
  • a map from the neutral object of the monoidal product from
  • And the following equations hold:
    • The pentagon
    • The left-unit
    • The right-unit

We port this definition in Idris directly by providing a record with all the necessary information, parameterised over the category and its monoidal structure.

record MonoidObject {0 o : Type} {cat : Category o} (mon : Monoidal cat) where
  constructor MkMonObj
  obj : o
  η : mon.i ~> obj
  mult : obj  obj ~> obj
  0 left : let 0 η_id_μ, λ : mon.i  obj ~> obj
               0 topMorphism : mon.i  obj ~> obj  obj
               topMorphism = η -⊗- cat.id obj
               η_id_μ = topMorphism |> mult
               λ = mon.leftUnitor.nat.component obj
            in η_id_μ === λ
  0 right : let 0 id_η_μ, ρ : obj  mon.i  ~> obj
                0 topMorphism : obj  mon.i  ~> obj  obj
                topMorphism = cat.id obj -⊗- η
                id_η_μ = topMorphism |> mult
                ρ  = mon.rightUnitor.nat.component obj
             in id_η_μ === ρ
  0 assoc : let
                0 botLeft : (obj  obj)  obj ~> obj
                botLeft = mult -⊗- cat.id obj |> mult
                0 assoc : ((obj  obj)  obj) ~> obj  (obj  obj)
                assoc = mon.alpha.tan.component (obj && (obj && obj))
                0 topRight : ((obj  obj)  obj) ~> obj
                topRight = assoc |> cat.id obj -⊗- mult |> mult
            in botLeft === topRight