Bicategories, monoids, internal and enriched categories

Last time, we introduced a more general definition of monads, in the setting of (strict) 2-categories. Unfortunately this strictness is often a bit too rigid to incorporate natural mathematical objects, and this is certainly true for monad theory. This time, we will push our definition of monads beyond this strict setting, into the wider world of bicategories.

Generalising to Bicategories

A bicategory \mathbf{C} consists of:

  1. A collection of 0-cells A,B,\ldots
  2. Between every pair of 0-cells A,B, a category \mathbf{C}(A,B). The objects of these categories are termed 1-cells, and the morphisms 2-cells. Composition of 2-cells is called vertical composition.
  3. For every triple of 0-cells, A,B,C a bifunctor \circ : \mathbf{C}(B,C) \times \mathbf{C}(A,B) \rightarrow \mathbf{C}(A,B), referred to as horizontal composition. For every 0-cell A, there are identity 1-cells \mathsf{Id}_A in \mathbf{C}(A,A).

Horizontal composition is associative and unital up to isomorphism. That is, there are natural isomorphisms:

  1. A left unitor \lambda : \mathsf{Id} \circ (-) \Rightarrow (-).
  2. A right unitor \rho : (-) \circ \mathsf{Id} \Rightarrow (-).
  3. An associator \alpha : (-) \circ ((-) \circ (-)) \Rightarrow ((-) \circ (-)) \circ (-), between the two different orders in which we can apply horizontal composition twice.

As you might expect, this structure is subject to some coherence equations, entirely analogous to those for a monoidal category.

Example: A (strict) 2-category is a bicategory in which the unitors and associators are identities, so horizontal composition is unital and associative on the nose.

Example: A monoidal category is “the same thing” as a bicategory with one 0-cell. This is often phrased as “A monoidal category is a one object bicategory”.

Considering one direction in more detail, in a bicategory \mathbf{C} with one 1-cell A consists of a single category \mathbf{C}(A,A). We also have:

  1. A horizontal composition bifunctor \mathbf{C}(A,A) \times \mathbf{C}(A,A) \rightarrow \mathbf{C}(A,A). We consider this to be the tensor product of our monoidal category.
  2. The identity 1-cell \mathsf{Id}_A will serve as the monoidal unit.

The coherence axioms for a bicategory is this simple case are exactly those of a monoidal category. Going in the other direction is similar.

We also introduce a couple of more complex bicategories that will be important in subsequent examples.

Example: A span of type X \rightarrow Y in a category \mathcal{C} is a pair of \mathcal{C}-morphisms of the form:

X \xleftarrow{f} A \xrightarrow{g} Y.

If \mathcal{C} has pullbacks, we can form the composite of a span X \xleftarrow{f} A \xrightarrow{g} Y with a span Y \xleftarrow{h} B \xrightarrow{k} Z as:

X \xleftarrow{f \circ \pi_1} A \times_{Y} B \xrightarrow{g \circ \pi_2} Z

where \pi_1, \pi_2 are the two projection maps given by forming the pullback of g along h.

Given two spans X \xleftarrow{f_1} A_1 \xrightarrow{g_1} Y and X \xleftarrow{f_2} A_2 \xrightarrow{g_2} Y a morphism of spans between them is a \mathcal{C}-morphism h : A_1 \rightarrow A_2 such that:

f_2 \circ h = f_1 \quad\text{and}\quad g_2 \circ h = g_1

In fact, for a category \mathcal{C} with pullbacks, there is a bicategory \mathbf{Span}(\mathcal{C}) with:

  1. 0-cells the objects of \mathcal{C}.
  2. \mathbf{Span}(\mathcal{C})(X,Y) consists of all spans of type X \rightarrow Y, and span morphisms between them.
  3. The universal property of pullbacks means composition of spans extends to a bifunctor, which we take to be our horizontal composition.

We are skimming over a size issue here. Readers with the necessary background may want to consider how such questions might creep in to the definition above.

Example: Let \mathcal{V} be a monoidal category with coproducts. For sets A,B, we can consider \mathcal{V}-valued matrices of type A \rightarrow B to be functions:

M : A \times B \rightarrow \mathsf{obj}(\mathcal{V})

Given a pair of matrices M : A \rightarrow B and N : B \rightarrow C, we can form their composite as follows:

(N \circ M)(a,c) = \coprod_{b \in B} M(a,b) \otimes N(b,c)

Given a pair of matrices M_1, M_2 : A \rightarrow B, a morphism of matrices is a family of \mathcal{V} morphisms:

f_{a,b} : M_1(a,b) \rightarrow M_2(a,b)

This data can be combined into a bicategory \mathbf{Mat}(\mathcal{V}) with:

  1. 0-cells sets.
  2. The category \mathbf{Mat}(\mathcal{V}(A,B) consists of matrices of type A \rightarrow B and morphisms between then.
  3. Horizontal composition is given by composition of matrices, as described above.

The two previous examples are typical for bicategories, in that horizontal composition involves either limits or colimits. In such cases, if we form iterated horizontal composites in different orders, the universal properties involved will ensure they agree up to isomorphism. Insisting that composites formed in different orders agree on the nose would lead to unrealistic requirements on our choice of (co)limits, so the bicategorical rather than strict 2-categorical setting is more natural.

Now we’ve seen a few different bicategories, it’s time to get back to our main motivation, monads. A monad in a bicategory \mathbf{C} consists of:

  1. A 0-cell \mathcal{C}.
  2. A 1-cell \mathbb{T} : \mathcal{C} \rightarrow \mathcal{C}.
  3. A unit 2-cell \eta: \mathsf{Id}_{\mathcal{C}} \Rightarrow \mathbb{T}.
  4. A multiplication 2-cell \mu: \mathbb{T} \circ \mathbb{T} \Rightarrow \mathbb{T}.

As before, our notation is suggestive of that for “ordinary” monads on categories. Notice the data above is no different to that which we encountered in the strict 2-categorical setting. Things get more interesting when we consider the coherence equations that need to hold, as now we must account for the fact that horizontal composition is not unital or associative on the nose, but only up to isomorphism. The required equations are:

  1. \mu \cdot (\eta \circ \mathsf{id}_{\mathbb{T}}) = \lambda.
  2. \mu \cdot (\mathsf{id}_{\mathbb{T}} \circ \eta) = \rho.
  3. \mu \cdot (\mu \circ \mathsf{id}_{\mathbb{T}}) = \mu \cdot (\mathsf{id}_{\mathbb{T}} \circ \mu) \cdot \alpha.

Firstly, we see that this really does generalise our previous definition.

Example: As we would expect, a monad in a 2-category is a special case of a monad in a bicategory. The unitors and associators are identities, and the equations above collapse to those of the 2-categorical case.

We also find a fun simple source of monads that would not have made sense before:

Example: We can view any monoidal category \mathcal{V} as a one object bicategory. A monoid in \mathcal{V} is the same thing as a monad in this one object bicategory. For example, every group or monoid can be seen as a monad. There is a certain symmetry here:

  1. In a bicategory \mathbf{C}, every monad on \mathcal{A} is a monoid in the monoidal category \mathbf{C}(\mathcal{A},\mathcal{A}).
  2. A monoid in a monoidal category is a monad in the corresponding one object bicategory.

We now move on to some more interesting examples, which really highlight the benefits afforded by the more liberal bicategorical definition.

Example: A (small) category consists of a set of objects O and a set of morphisms M. There are two functions giving the source and target of a given morphism, forming a span:

O \xleftarrow{s} M \xrightarrow{t} O

The identities induce a morphism from the identity span to this span. If we form the pullback of s along t, the object M \times_O M consists of all composable pairs of morphisms, and there is a span morphism from the resulting span to the one defined above, given by the function maps composable pairs to their composite.

Given a category \mathcal{C} with pullbacks, we can define an internal category in \mathcal{C} to consists of the analogous structure. A (small) category is then an internal category in \mathsf{Set}.

The key observation for our purposes is that an internal category in \mathcal{C} is the same thing as a monad in \mathbf{Span}(\mathcal{C}). The monad unit and multiplication correspond to the identities and composition respectively. The rest is “just” an exercise in unravelling definitions.

Example: For a monoidal category \mathcal{V} with coproducts, a \mathcal{V}-enriched category \mathcal{A} consists of:

  1. A set of objects O.
  2. For each pair of objects o_1, o_2 a hom-object in \mathcal{V}. We can view this as a \mathcal{V}-valued matrix A : O \rightarrow O.
  3. Morphisms j_o : \mathcal{I} \rightarrow A(o,o) picking out the identities. These form a morphism of matrices from the identity matrix to A.
  4. Composition morphisms m_{o_1, o_2, o_3} : A(o_2,o_3) \otimes A(o_1,o_2) \rightarrow A(o_1, o_3), which via the universal property of coproducts induce a morphism \coprod_{o_2 \in O} A(o_1, o_2) \otimes A(o_2, o_3) \rightarrow A(o_1,o_3). Together, these form a morphism of matrices of type A \circ A \rightarrow A.

A more careful unpacking of the definitions following these intuitions shows that a \mathcal{V}-category is the same thing as a monad in \mathbf{Mat}(\mathcal{V}).

As a special case of this construction, the Booleans can be considered as a thin two object monoidal category \mathcal{B}. The category \mathbf{Mat}(\mathcal{B}) is equivalent to the bicategory of relations \mathbf{Rel} we encountered last time. The Boolean enriched categories are then exactly preorders.


By considering a further generalisation of the notion of monad to the weak setting of bicategories, many new interesting examples become possible. The examples of internal and enriched categories are well-known, and provide the intuitions for other, more elaborate constructions.

A categorically minded reader should be asking themselves the following question. We have identified internal and enriched categories as monads in certain bicategories, what about the morphisms between them? Do internal and enriched functors correspond to an obvious notion of morphism between these monads? The answer to this question is a bit more subtle than one might hope. We may return to this point in a later post.

More background on bicategories, and the monads corresponding to internal and enriched categories can be found in Lack’s “A 2-Categories Companion”, which is highly recommended reading.

3 thoughts on “Bicategories, monoids, internal and enriched categories”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: