Actions of categories

In my last post I explained how categories can be seen as algebraic structures in the bicategory of spans, namely as monads. This is already a neat fact in itself, and, as I explained there, allows to see various flavours of categories in the same light.

Today I want to show you something else that falls out of this cats-are-monads idea, namely that cats can act.

When you consider a category as a monad in \bf Span(Set), then you can ask what is an algebra of said monad. The notion of algebra of a monad is mostly known for when the monad is in \bf Cat, but it makes sense in every bicategory. The only difference is, these are called modules rather than algebras:

Definition. Let \cal K be a bicategory, and B: \cal K be an object equipped with an endomorphism T:B \to B. Then a left module [0] of T on a morphism f:A \to B is a 2-cell \alpha :Tf \Rightarrow f (called the action):

It does look like an algebra of a monad in the usual sense, doesn’t it? In fact if \cal K= \bf Cat and f:1 \to B is a functor, which thus picks an object b in B, then \alpha : Tf \Rightarrow f corresponds exactly to a familiar map Tb \to b in B [1].

When T is a not just an endomorphism, but a monad, then an action of (T, \eta, \mu) is an action of T plus two compatibility axioms:

which are stating that \alpha respects multiplication and unit of the monad, not unlike what algebras of monads in \bf Cat do.

Now we are ready to instantiate this definition in \bf Span(Set): what is the action of a category \mathcal{X}, given as a monad (X \xleftarrow{s} M \xrightarrow{t} X,\ i,\ {;})?

Well, it’s a span Y \xleftarrow{f} S \xrightarrow{g} X, together with a map of spans:

which, using the notation s:y \leadsto x to denote an element s \in S such that f(s)=y and g(s)=x, and the notation m:x \to y for morphisms in \cal X we introduced last time, can be written as:

\alpha (y \overset{s}\leadsto x, x \overset{m}\to x') : y \leadsto x'.

This action is akin to the scalar multiplication of a module over a ring (indeed, both are instances of the general concept of ‘module’), except for the extra checks on which squiggly arrows in S can be multiplied by which morphisms of \cal X: if they match on their boundary, then it’s fine, and a morphism m acts by ‘extension’ on s. In practice, one can reason very well by just forgetting about these checks and assuming that whenever you write \alpha(s, m) =: sm, s and m are indeed ‘composable’.

With this notational convention, the laws that make \alpha a module over the monad \cal X are pretty pedestrian:

s1 = s, \quad (sm)n = s(mn)

where mn := m ; n.

What is then (Y \xleftarrow{f} S \xrightarrow{g} X, \alpha) in category-land? It is ‘half’ of a profunctor, i.e. a profunctor from the discrete category \Delta Y to \cal X. That’s why I’ve been denoting the elements of S as if they were heteromorphisms. We get full profunctors if we consider bimodules between two categories, seen as monads in \bf Span(Set).

Definition: A bimodule between monads (S, \eta', \mu') on A and (T, \eta, \mu) on B is a 1-cell f:A \to B together with a left T-action \alpha and a right T-action \beta which commute with each other:

For the case of \bf Span(Set), a right action of a monad {\cal Y} = (Y \xleftarrow{s'} N \xrightarrow{t'} X,\ i', \ {;}') on a span Y \xleftarrow{f} S \xrightarrow{g} X looks exactly like a left action except morphisms of a category act on the left (!):

\beta (y' \overset{n}\to y, y \overset{s}\leadsto x) : y' \leadsto x

and we denote this again as juxtaposition (e.g. the above defines ns).

Then a bimodule is a span such that

(ns)m = n(sm) = nsm.

This makes the data of a bimodule that of a profunctor between the categories \cal Y and \cal X corresponding to the monads acting on the left and right. The profunctors S: \cal Y \nrightarrow X is defined as S(y,x) = \{y \leadsto x\}, and its bifunctoriality corresponds precisely to the structure and laws of the bimodule we defined it from!

This should clarify why some people call profunctors bimodules: because they are!

I really like this ‘algebraic’ perspective on profunctors, because it allows one to make categories do things on other things. Elements of a profunctor are often considered morphisms too, just straddling categories. But it is useful to consider them to be ‘objects’ in their own right, on which morphisms of two categories can act either covariantly or contravariantly. This distinction between ‘scalar’ morphisms and ‘object’ morphisms, is as useful as the distinction between scalars and vectors in linear algebra, and I hope to make my point clearer in further posts.


  1. There’s a terminological issue here when talking about ‘left and right modules’, since there’s a problem with that when it comes to denoting composition. Left and right in ‘left/right module’ refers to the traditional, non-diagrammatic composition. Hence when we draw diagrams it looks off. In this post I’ll focus on modules in \bf Span(Set) where the two notions are basically the same, but in general they are not: in categories, left modules for a monad are algebras in the classical sense, while right modules are free algebras!

  2. The fact that everything interesting about the algebras of an endofunctor in \bf Cat is captured by restricting to those morphisms into A with domain either the walking object 1 or the walking arrow \downarrow (try it: actions on a functor {\downarrow} \to A correspond to morphisms of algebras in the usual sense) is due to the fact \bf Cat is accessible, i.e. everything is a colimit of those two objects. In fact what is a category but a (small) bunch of objects together with a (small) bunch of arrows between them? This is a fact akin to ‘sets are bunch of elements’, and why you only need to look at morphisms 1 \to X to know everything about a set X.