Concrete examples of 2-categories

In order to understand $2$-categories, you really have to understand the prototype $\mathsf{Cat}$ of small categories. Objects are categories, morphisms are functors, and $2$-morphisms are natural transformations. Another prototype, which is closely related to that, is the $2$-category $\mathsf{Top}$ (which is actually an $(\infty,1)$-category). Objects are topological spaces, morphisms are continuous maps, and $2$-morphisms are homotopies between continuous maps (as Omar remarks, one has to be careful here to get associativity of $2$-morphisms; there are various solutions). Many basics about $2$-categories are adapted (starting with the notation, for example "$2$-cells" instead of $2$-morphisms) to these prototypes.

There are many interesting subcategories of $\mathsf{Cat}$ or variations thereof. The category of monoids $\mathsf{Mon}$ is a a full subcategory of $\mathrm{Cat}$, consisting of categories with just one object. An object is a monoid, a morphisms is a homomorphism of monoids, and a $2$-morphism between homomorphisms $f,g : M \to N$ is some element $n \in N$ such that $f(m) n = n g(m)$ for all $m \in M$. If $M,N$ are groups, this means that $f,g$ are conjugated to each other. So this comes close to your example, but I don't think that a single group may be regarded as a $2$-category.

Something similar happens for the category $\mathsf{Ring}$ of rings: Although usually considered as a $1$-category, it is actually a $2$-category when we regard it as a full subcategory of the category if linear categories (namely those with just one object). The description of $2$-morphisms is as above.

Rings categorify to cocomplete tensor categories, which also constitute a $2$-category (morphisms: cocontinuous tensor functors, $2$-morphisms: tensor natural transformations). The $2$-category of (algebraic) stacks is another important example. It is related because to every stack $\mathcal{X}$ one can associate a cocomplete tensor category $\mathrm{Qcoh}(\mathcal{X})$ of quasi-coherent sheaves, and it turns out that $\mathrm{Qcoh}(-)$ is fully faithful in many situations (see here).

As you can see, most examples are optained by variations of $\mathsf{Cat}$. Apart from that:

Every $1$-category can be regarded as a $2$-category by introducing only identities as $2$-morphisms. And a $2$-category with just one object is just a monoidal category, and there are plenty examples of them. So similar to the point of view "category = monoid with many objects" we have "$2$-category = monoidal category with many objects".

Finally, another very basic example of a $2$-category is the category of spans: Objects are sets (or objects from another nice category), a morphism from $A$ to $B$ is a set $C$ together with maps $A \leftarrow C \rightarrow B$. These are composed via pullbacks. And a $2$-morphism from a span $A \leftarrow C \rightarrow B$ to another span $A \leftarrow C' \rightarrow B$ is a morphism $C \to C'$ such that the obvious "diamond" diagram commutes. Actually you have to take isomorphism-classes of spans so that associativity is satisfied.


Taking the perspective that a group is a category with one object where the morphisms are the symmetries of the object, you should then be able to construct a 2-category by saying that the 2-morphisms are the inner automorphisms of the group.

I don't think this works. More precisely, I don't see a natural candidate for horizontal composition.

I wrote this blog post partially as an introduction to 2-categories. I give a few examples, but not too many, so here are examples (some taken from the post and some not):

  • Various subcategories of $\text{Cat}$. For example, $\text{Mon}$ (monoids) or $\text{Pos}$ (posets).
  • For any topological space $X$, there is a 2-category $\Pi_2(X)$, the fundamental 2-groupoid of $X$, whose objects are the points of $X$, whose morphisms are the continuous paths in $X$, and whose 2-morphisms are the homotopy classes of homotopies between paths in $X$.
  • Just as a category with one object is a monoid, a 2-category with one object is a (strict) monoidal category $(M, \otimes)$. Important examples include any category with products as well as the category of representations of a group, Lie algebra, bialgebra...
  • For any monoidal category $V$, various subcategories of $V\text{-Cat}$. For example, if $V = \text{Ab}$, then one can take the 2-category of rings (closely analogous to the case of monoids).
  • (An appropriate skeleton of) the bicategory of bimodules. This construction generalizes considerably.

I sometimes talk about "the" 2-category of logical propositions. The morphisms are proofs of one proposition from another, and the 2-morphisms are ways of turning one proof into another (I do not have a precise idea of what this ought to mean).


Omar's construction using central elements is a special case of something I describe in this post here. $\newcommand{\id}{\textrm{id}}$

In Cartan and Eilenberg there are several instances of squares which "anticommute", that is, we have $h \circ f = - k \circ g$ instead of $h \circ f = k \circ g$. I was wondering if we could make this into an instance of a square commuting "up to a specified 2-morphism" and it turned out the answer was yes.

Let $\mathbb{C}$ be a (small) category. We attach to every parallel pair of 1-morphisms $f, g : X \to Y$ the set of all natural transformations $\alpha : \id_\mathbb{C} \Rightarrow \id_\mathbb{C}$ such that $g = \alpha_Y \circ f$. The vertical composition is obvious, and if we have another parallel pair $h, k : Y \to Z$ and a 2-morphism $\beta : h \Rightarrow k$, the horizontal composition of $\alpha$ and $\beta$ is just $\beta \circ \alpha$, since $k \circ g = (\beta_Z \circ h) \circ (\alpha_Y \circ f) = (\beta_Z \circ \alpha_Z) \circ (h \circ f)$, by naturality of $\alpha$. This yields a (strict) 2-category structure on $\mathbb{C}$. Note that we have to remember which natural transformation is needed to make the triangle commute in order to have a well-defined horizontal composition.

In the specific case of $\mathbb{C} = R\text{-Mod}$, the set (class?) of natural transformations $\id_\mathbb{C} \Rightarrow \id_\mathbb{C}$ include the scalar action of $R$, so in particular the anticommutative squares of Cartan and Eilenberg can be regarded as a square commuting up to a 2-morphism.


$\newcommand{\profto}{\nrightarrow}$ My current favourite example of a bicategory (i.e. a weak 2-category) is the bicategory $\mathfrak{Span}$ of spans of sets. The objects are sets, and the 1-morphisms $M : A \profto B$ are arbitrary pairs of maps $(s : M \to A, t : M \to B)$. Composition is given by fibre products: if $N : B \profto C$ is another span, then their composite $N \circ M : A \profto C$ is given by $M \times_B N$ and the obvious projections down to $A$ and $C$. A 2-morphism between spans is just an ordinary map of sets that commutes with the structural maps.

Why is $\mathfrak{Span}$ interesting? Because a monad in $\mathfrak{Span}$ is the exactly the same thing as a (small) 1-category! (I think the "natural" notion of homomorphism that arises this way is that of a profunctor rather than a functor, but that should be considered a feature rather than a bug.)


One easy way to "strictify" $\mathfrak{Span}$ is to look at a certain more familiar subcategory: the 2-category $\mathfrak{Rel}$, whose objects are sets and whose 1-morphisms are relations. (The composition of relations is the usual one: if $R : A \profto B$ and $S : B \profto C$ are relations, then $c \mathrel{(S \circ R)} a$ if and only if the is some $b$ such that $c \mathrel{S} b$ and $b \mathrel{R} a$.) A 2-morphism between two relations is just the inclusion of the underlying graphs.

Morally, $\mathfrak{Rel}$ is the 0-dimensional analogue of the bicategory $\mathfrak{Prof}$ of categories and profunctors, and it is a way of "enlarging" the ordinary 1-category $\textbf{Set}$. We have the following remarkable fact: a relation $F : A \profto B$ has a right adjoint if and only if $F$ is a functional relation. So not only is $\textbf{Set}$ faithfully embedded in $\mathfrak{Rel}$, we also have a way of recognising when a morphism comes from $\textbf{Set}$!


Finally, some unsolicited advice: 2-category theory is impenetrable even if you are familiar with ordinary category theory. I firmly believe that one must have an excellent grasp of ordinary category theory before moving on to the higher-dimensional stuff. Just as ordinary category theory depends heavily on our intuitions about $\textbf{Set}$ as a 1-category, 2-category theory depends heavily on our intuitions about $\mathfrak{Cat}$ as a 2-category – and that intuition can only be built by studying 1-categories.