Until now, we have taken the definition of monad to be:
- A category .
- An endofunctor .
- A unit natural transformation .
- A multiplication natural transformation .
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:
- 0-cells, which we shall denote .
- Between any pair of 0-cells , there is a collection of 1-cells of type . We shall denote 1-cells as . For any 0-cell , there is a distinguished identity 1-cell .
- Between any pair of 1-cells of the same type, there is a collection of 2-cells of type . We shall denote 2-cells as . For any 1-cell , there is a distinguished identity 2-cell .
These components can be composed in various ways:
- For any pair of 1-cells and , there is a composite 1-cell .
- For 1-cells, and , and 2-cells and there is a horizontal composite natural transformation .
- For any triple of 1-cells , and 2-cells and , there is a vertical composite natural transformation .
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 , 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 with:
- 0-cells sets.
- 1-cells of type relations .
- There is a 2-cells if .
The identity 1-cells are the usual notion of identity relation:
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:
- A 0-cell
- A 1-cell .
- A unit 2-cell .
- A multiplication 2-cell .
This data must satisfy the following three equations:
We recover our original notion of monad as a special case.
Example: Monads in the 2-category 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 in the 2-category is a relation such that:
Unpacking this into a pointwise definition, this is a relation such that:
- For all , .
- If and then .
That is, a monad on in is a preorder on .
A variation on the previous example yields a classical observation of Lawvere, in a monadic guise.
Example: Let denote the positive real numbers, extended with a maximal element . We can extend addition and multiplication to by setting:
There is a 2-category with:
- 0-cells sets.
- 1-cells of type are functions . We think of these as positive real valued relations, with giving a distance between and .
- There is a 2-cell if for all , . 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:
In terms of distances, an element is zero distance from itself, and infinitely far away from everything else.
For the composition of and , again we generalise composition of relations from the previous example:
In terms of our distance based intuition, if gives distances between and , and gives distances between and , then gives the shortest distance between and travelling in two steps:
- Firstly moving from to some element using the distances specified by .
- Secondly, moving from the chosen element to using the distances specified by .
Now we have specified our setting, we can consider what the monads are. A monad on a set in consists of a function such that there are 2-cells:
It will help to expand these to pointwise definitions, and make the ordering between elements explicit. We find that:
- . This is equivalent to requiring for all that the triangle inequality holds.
So the monads in are generalised metric spaces in which we permit the following extra flexibility:
- Non equal points may be at zero distance from each other.
- Distances are not necessarily symmetric, that is we may have .
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 .
Example: We encountered enriched categories briefly when discussing strong monads. For a monoidal category , there are -categories, -functors and -natural transformations. These form a 2-category , and the monads in this 2-category yield exactly the definition of -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.
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.
5 thoughts on “First steps into a larger world of monads”