First steps into a larger world of monads

Until now, we have taken the definition of monad to be:

• A category $\mathcal{C}$.
• An endofunctor $\mathbb{T} : \mathcal{C} \rightarrow \mathcal{C}$.
• A unit natural transformation $\eta : \mathsf{Id} \Rightarrow \mathbb{T}$.
• A multiplication natural transformation $\mu : \mathbb{T}^2 \Rightarrow \mathbb{T}$.

satisfying some compatibility equations. In this post, we will take a first step in generalising this definition to include a much broader range of mathematical objects. Our original definition arises as a special case, and interesting new examples come into view.

Generalising to 2-categories

A 2-category is an abstraction of the fundamental mathematical structure of categories, functors and natural transformation. Note that some more modern accounts refer to these as strict 2-categories, reserving the term 2-category for a more general notion, although this terminology is still not in consistent use. We shall occasionally use the adjective strict for emphasis.

A (strict) 2-category has three key building blocks:

1. 0-cells, which we shall denote $\mathcal{C}, \mathcal{D}, \ldots$.
2. Between any pair of 0-cells $\mathcal{C}, \mathcal{D}$, there is a collection of 1-cells of type $\mathcal{C} \rightarrow \mathcal{D}$. We shall denote 1-cells as $F,G,\ldots$. For any 0-cell $\mathcal{C}$, there is a distinguished identity 1-cell $\mathsf{Id}_{\mathcal{C}} : \mathcal{C} \rightarrow \mathcal{C}$.
3. Between any pair of 1-cells $F, G : \mathcal{C} \rightarrow \mathcal{D}$ of the same type, there is a collection of 2-cells of type $F \Rightarrow G$. We shall denote 2-cells as $\alpha, \beta, \ldots$. For any 1-cell $F$, there is a distinguished identity 2-cell $\mathsf{id}_{F} : F \Rightarrow F$.

These components can be composed in various ways:

• For any pair of 1-cells $F : \mathcal{A} \rightarrow \mathcal{B}$ and $G : \mathcal{B} \rightarrow \mathcal{C}$, there is a composite 1-cell $G \circ F : \mathcal{A} \rightarrow \mathcal{C}$.
• For 1-cells, $F,G : \mathcal{A} \rightarrow \mathcal{B}$ and $H, K : \mathcal{B} \rightarrow \mathcal{C}$, and 2-cells $\alpha : F \Rightarrow G$ and $\beta : H \Rightarrow K$ there is a horizontal composite natural transformation $\beta \circ \alpha : H \circ F \Rightarrow K \circ G$.
• For any triple of 1-cells $F,G,H : \mathcal{A} \rightarrow \mathcal{B}$, and 2-cells $\alpha : F \Rightarrow G$ and $\beta : G \Rightarrow H$, there is a vertical composite natural transformation $\beta \cdot \alpha$.

These composition operations satisfy various unitality, assocativity and other compatibility equations, such that the collections of 1-cells, and the 2-cells between them form categories, and horizontal composition is a bifunctor. The details are readily available elsewhere, so I shall avoid spelling out the full formal definition.

Example: Categories, functors and natural transformations form a 2-category $\mathbf{Cat}$, and in fact this is the motivating example. Strictly speaking we should say small categories, functors and natural transformations to avoid Russell’s paradox like problems. As usual we shall not dwell on such size issues.

Example: There is a 2-category $\mathbf{Rel}$ with:

1. 0-cells sets.
2. 1-cells of type $A \rightarrow B$ relations $R \subseteq A \times B$.
3. There is a 2-cells $R \Rightarrow S$ if $R \subseteq S$.

The identity 1-cells are the usual notion of identity relation:

$\mathsf{Id}(a_1,a_2) \Leftrightarrow (a_1 = a_2)$

This sort of 2-category is termed thin as there is at most one 2-cell between a pair of 1-cells. That is, the collections of 1-cells, and 2-cells between them form preorders.

With the definition of 2-category in place, the generalisation of the notion of monad is pretty routine. We simply replace category, functor and natural transformation with 0-cell, 1-cell and 2-cell in our original definition.

A monad in a 2-category 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} \Rightarrow \mathbb{T}$.
4. A multiplication 2-cell $\mu : \mathbb{T}^2 \Rightarrow \mathbb{T}$.

This data must satisfy the following three equations:

$\mu \cdot (\eta \circ \mathsf{Id}_{\mathbb{T}}) = \mathsf{Id}_{\mathbb{T}} \qquad \mu \cdot (\mathsf{Id}_{\mathbb{T}} \circ \eta) = \mathsf{Id}_{\mathbb{T}} \qquad \mu \cdot (\mu \circ \mathsf{Id}_{\mathbb{T}}) = \mu \cdot (\mathsf{id}_{\mathbb{T}} \circ \mu)$

We recover our original notion of monad as a special case.

Example: Monads in the 2-category $\mathbf{Cat}$ are exactly our original notion of monads.

We can also now talk about further examples, that would not even have made sense before.

Example: A monad on a set $A$ in the 2-category $\mathbf{Rel}$ is a relation $R : A \rightarrow A$ such that:

1. $\mathsf{Id} \subseteq R$.
2. $R \circ R \subseteq R$.

Unpacking this into a pointwise definition, this is a relation $R$ such that:

1. For all $a \in A$, $R(a,a)$.
2. If $R(a_1,a_2)$ and $R(a_2,a_3)$ then $R(a_1,a_3)$.

That is, a monad on $A$ in $\mathbf{Rel}$ is a preorder on $A$.

A variation on the previous example yields a classical observation of Lawvere, in a monadic guise.

Example: Let $\mathbb{R}^{\infty}$ denote the positive real numbers, extended with a maximal element $\infty$. We can extend addition and multiplication to $\mathbb{R}^{\infty}$ by setting:

$x + \infty = \infty = \infty + x \qquad\text{and}\qquad x \times \infty = \infty =\infty \times x$

There is a 2-category $\mathbf{Rel}_{\mathcal{L}}$ with:

1. 0-cells sets.
2. 1-cells of type $A \rightarrow B$ are functions $R : A \times B \rightarrow \mathbb{R}^{\infty}$. We think of these as positive real valued relations, with $R(a,b)$ giving a distance between $a$ and $b$.
3. There is a 2-cell $R \Rightarrow S$ if for all $a,b$, $R(a,b) \geq S(a,b)$. Note the direction of ordering here.

As this 2-category is thin, it only remains to specify the identity and composition of 1-cells. The identity 1-cells generalise the identity relations we saw in the earlier example:

$\mathsf{Id}(a,a) = \begin{cases} 0, &\text{if \begin{math}a_1 = a_2\end{math}} \\ \infty, &\text{otherwise} \end{cases}$

In terms of distances, an element $a$ is zero distance from itself, and infinitely far away from everything else.

For the composition of $R : A \rightarrow B$ and $S : B \rightarrow C$, again we generalise composition of relations from the previous example:

$(S \circ R)(a,c) = \bigwedge_{b \in B} R(a,b) + R(b,c)$

In terms of our distance based intuition, if $R$ gives distances between $A$ and $B$, and $S$ gives distances between $B$ and $C$, then $(S \circ R)(a,c)$ gives the shortest distance between $a$ and $c$ travelling in two steps:

1. Firstly moving from $a$ to some element $b \in B$ using the distances specified by $R$.
2. Secondly, moving from the chosen element $b \in B$ to $c$ using the distances specified by $S$.

Now we have specified our setting, we can consider what the monads are. A monad on a set $A$ in $\mathbf{Rel}_{\mathcal{L}}$ consists of a function $D : A \times A \rightarrow \mathbb{R}^{\infty}$ such that there are 2-cells:

1. $\mathsf{Id} \Rightarrow D$
2. $D \circ D \Rightarrow D$

It will help to expand these to pointwise definitions, and make the ordering between elements explicit. We find that:

1. $D(a,a) = 0$
2. $D(a_1,a_2) \leq \bigwedge_{a \in A} D(a_1, a) + D(a, a_2)$. This is equivalent to requiring for all $a_1, a_2, a$ that the triangle inequality $D(a_1, a_2) \leq D(a_1,a) + D(a, a_2)$ holds.

So the monads in $\mathbf{Rel}_{\mathcal{L}}$ are generalised metric spaces in which we permit the following extra flexibility:

1. Non equal points may be at zero distance from each other.
2. Distances are not necessarily symmetric, that is we may have $D(a,b) \neq D(b,a)$.

The 2-category of the previous example was built by considering relations over generalised truth values. Varying this idea yields many other interesting examples.

Our final example is a natural generalisation of $\mathbf{Cat}$.

Example: We encountered enriched categories briefly when discussing strong monads. For a monoidal category $\mathcal{V}$, there are $\mathcal{V}$-categories, $\mathcal{V}$-functors and $\mathcal{V}$-natural transformations. These form a 2-category $\mathcal{V}-\mathbf{Cat}$, and the monads in this 2-category yield exactly the definition of $\mathcal{V}$-monad that is considered in enriched category theory. This sort of example is encouraging evidence for the usefulness of the abstract definition of monad, in that it recovers mathematical construction considered in settings beyond ordinary category theory.

Conclusion

We have taken a first step in generalising the definition of monad to the setting of (strict) 2-categories. This allowed us to rediscover some interesting new examples, such as preorders and generalised metric spaces being monads. Unfortunately, some natural examples we would like to cover are still out of reach as the strict 2-categorical setting is too rigid. To get our hands on many further examples, we shall take a second step, and generalise the definition of monad to bicategories in a later post.