## 1 Introduction

Kan extensions are a prominent tool of category theory, to the extent that, already in the preface to the first edition of [21], Mac Lane declared that “all concepts of category theory are Kan extensions”, a claim reinforced more recently in [27, Chapter 1]. However, they are also considered to be a notoriously slippery concept, especially by newcomers to the subject. One of the most powerful pictures that help understanding how they work may be the idea that Kan extensions, especially in their pointwise form, “replace parts of a diagram with their best approximations, either from the right or from the left”. In other words, Kan extensions can be seen as taking limits or colimits of “parts” of a diagram. The scope of this paper is making this intuition mathematically precise.

We make use of the concept of partial evaluation, which was introduced in [9], and which is a way to formalize “partially computed operations” in terms of monads. The standard example is that “$$1+2+3+4$$” may be evaluated to “10”, but also partially evaluated to “$$3+7$$”, whereby parts of the given sum have been replaced by their sums.

Just as monads on sets may be seen as encoding different algebraic structures and operations, here we consider pseudomonads on categories which encode the operation of taking colimits. We are in particular interested in two pseudomonads: the monad of diagrams and the monad of small presheaves (also known as the free (small) cocompletion monad). Both monads are known in the literature, but certainly not presented in sufficient detail as needed for our purposes. To make the paper more accessible, we therefore decided to spell out their definition in full detail, in Sects. 2 and 4.

There is a functor connecting diagrams and presheaves, which we call the image presheaf, and which appears in the literature under the name of connected component functor [23] (at least for the case of small categories). This construction takes a diagram and forms a presheaf that can be considered the “free colimit” of the diagram. We describe the construction in detail in Sect. 3, taking care of the size issues we face when the codomain of diagrams is not small.

The definitions of pseudomonads, pseudoalgebras, and their morphisms are also hard to find in the literature in sufficient detail. For this reason, to avoid any ambiguity, we have given a detailed account of them in Appendix A. Readers who are familiar with these pseudomonads, and with the concepts of pseudomonads in general, may skip these sections, with the exception of Sects. 2.5, 4.6 and Appendix A.3, which contain new results.

Here is what the novel content of this work consists of. First of all, we show that the image presheaf induces a morphism of monads from the monad of diagrams to the monad of small presheaves, which in turn gives a pullback functor between the categories of algebras (we prove the 2-dimensional version of this statement in Appendix A.3). This morphism of monads is not injective in any sense. Indeed, it turns out that diagrams with isomorphic image presheaves have the same colimit, in a very strong sense, analogous to “differing by a confinal functor”. We indeed generalize the theory of confinal functors, and connect it to the theory of absolute colimits – both because we need that in order to prove the subsequent statements, and because it should be interesting for its own sake.

We then turn to the central topic of this paper and study partial evaluations for both monads. We prove that partial evaluations for the monad of diagrams correspond to pointwise left Kan extensions along split opfibrations, by invoking the Grothendieck correspondence between split opfibrations and functors into $${\mathsf {Cat}}$$. For the monad of small presheaves, we show that partial evaluations correspond to pointwise left Kan extensions along arbitrary functors. This result may be summarized in the following way: given small presheaves P and Q on a locally small, small-cocomplete category, Q is a partial colimit of P if and only if they can be written as image presheaves of small diagrams D and $$D'$$, in such a way that $$D'$$ is the left Kan extension of D along some functor. More concisely, Kan extensions are partial colimits, as claimed by the paper’s title.

This result is analogous to, and was motivated by, an analogous result in measure theory involving probability monads, where partial evaluations (or “partial expectations”) correspond exactly to conditional expectations (Theorem 5.13). Indeed, one could say that “if coends are like integrals, then Kan extensions are like conditional expectations”. (See Sect. 5.4 for more on this.)

As usual, when one talks about free cocompletion, one has to be very careful with size issues. This is why some parts of this work, such as the proof of Lemma 5.12, appear to be rather technical. The payoff is that the main theorems of this work will hold for arbitrary (small) colimits in arbitrary (locally small) categories, beyond the trivial case of preorders.

Outline. In Sect. 2 we study the category of diagrams in a given category, and show that the construction gives a pseudomonad on the 2-category of locally small categories. While this construction seems to be known, its details don’t seem to have been spelled out previously. The content of Sect. 2.5, however, seems to be entirely new. We show that cocomplete categories, equipped with a choice of colimit for each diagrams, are pseudoalgebras over this pseudomonad, and that not all pseudoalgebras are of that form.

In Sect. 3 we study the concept of image presheaf, which can be seen as a “free colimit of a diagram”, or as a “colimit blueprint”. We show that having the same image presheaf is a strong and consistent generalization both of the theory of confinal functors (Proposition 3.9), and of the concept of absolute colimit (Proposition 3.13). The main ideas are already known in the literature for the case of small categories. We restate some of them to take care of the size issues we face (since some of our categories are only locally small).

In Sect. 4 we study small presheaves and show that they form a pseudomonad. Again, this is known, but here we spell out the construction in much greater detail than previous accounts have done. This enables us to establish the new result presented in Sect. 4.6: the image presheaf construction forms a morphism of pseudomonads from diagrams to presheaves.

The principal new results of this paper appear in Sect. 5. Theorem 5.5 and Theorem 5.6 state that partial colimits for the monad of diagrams correspond to pointwise left Kan extensions of diagrams along split opfibrations. In Theorem 5.10 we prove that partial colimits for the free cocompletion monad correspond to pointwise left Kan extensions of diagrams along arbitrary functors. Then, in Sect. 5.4, we compare this categorical result to the analogous measure-theoretic fact that partial expectations for probability monads correspond (in some cases) to conditional expectations of random variables. This is in line with the famous analogy between coends and integrals.

Finally, in Appendix A we recall the (known) definition of pseudomonads and pseudoalgebras, and of the categories they form, which we use in the rest of the paper. We also provide a 2-dimensional version of the restriction of scalars construction (Theorem A.7), where a morphism of monads induces a functor between the categories of their algebras in opposite direction. As far as we know, this 2-dimensional version has not appeared in the literature previously.

Categorical setting, notation, and conventions. As it is to be expected when one talks about generic colimits, size issues are relevant. Here are our conventions.

All the categories in this work (except $${\mathsf {CAT}}$$) are assumed locally small. We denote by $${\mathsf {Cat}}$$ the 2-category of small categories, and by $${\mathsf {CAT}}$$ the 2-category of possibly large, locally small categories. Note that $${\mathsf {CAT}}$$ is itself larger than a large category (some authors call it a huge category).

When we say “category”, without specifying the size, we will always implicitly refer to a possibly large, locally small category.

Similarly, by “cocomplete category” we always mean a possibly large, locally small category which admits all small colimits.

## 2 The Monad of Diagrams

In this section we define the monad of diagrams. The first source for it that we are aware of is Guitart’s article [12], but without an explicit construction, and some concepts date back at least to Kock’s PhD thesis [16] (without the higher-dimensional aspects yet). We give in detail all the structure maps, and in Sect. 2.5 we prove that cocomplete categories with a choice of colimits are pseudoalgebras (but not all pseudoalgebras are in this form). The notions of pseudomonad and pseudoalgebra that we use are given in detail in Appendix A.

Note that, differently from some of the literature, we use the following slightly generalized notion of morphism of diagrams (also used in Guitart’s original work [12], and dating back to the origins of category theory [7, Section 23]). Moreover, in order to avoid size issues, we require every diagram to be small.

### Definition 2.1

Let $${\mathsf {C}}$$ be a locally small category.

• We call a diagram in $${\mathsf {C}}$$ a small category $${\mathsf {J}}$$ together with a functor $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$. Throughout this work, all the diagrams will be implicitly assumed to be of this form (i.e. be small).

• Given diagrams $$({\mathsf {J}},D)$$ and $$({\mathsf {J'}},D')$$ in $${\mathsf {C}}$$, we call a morphism of diagrams a functor $$R:{\mathsf {J}}\rightarrow {\mathsf {J'}}$$ together with a natural transformation $$\rho :D\Rightarrow D'\circ R$$, i.e. a diagram in $${\mathsf {CAT}}$$ as the following.

• Given diagrams $$({\mathsf {J}},D)$$ and $$({\mathsf {J'}},D')$$ in D and morphisms of diagrams $$(R,\rho ), (R',\rho '): ({\mathsf {J}},D) \rightarrow ({\mathsf {J'}},D')$$, we call a 2-cell of diagrams a natural transformation $$\alpha :R\Rightarrow R'$$ such that the following 2-cells are equal.

We denote by $${\mathsf {Diag(C)}}$$ the 2-category of diagrams in $${\mathsf {C}}$$, their morphisms, and their 2-cells. (Sometimes we will still denote by $${\mathsf {Diag(C)}}$$ the underlying 1-category.)

Note that the definition of morphism of diagrams is slightly more general than just a natural transformation between parallel functors. This is still compatible with the traditional intuitive picture of “deforming a diagram into another one”, provided that one notices the following. In principle R may be not essentially surjective, so one should visualize the natural transformation $$\rho$$ as “deforming” the figure drawn by D into a subfigure of the one drawn by $$D'$$.

Note moreover that:

• For $${\mathsf {C}}$$ locally small, $${\mathsf {Diag(C)}}$$ is locally small too;

• The forgetful functor $${\mathsf {Diag(C)}}\rightarrow {\mathsf {Cat}}$$ given by the domain is a fibration (via precomposition), and it is an opfibration (via left Kan extensions) if and only if $${\mathsf {C}}$$ is cocomplete (see for example [26, Proposition 2.8]).

In the rest of this section we show that $${\mathsf {C}}\rightsquigarrow {\mathsf {Diag(C)}}$$ is part of a pseudomonad on $${\mathsf {CAT}}$$, and that cocomplete categories with a choice of colimit for each diagram are pseudoalgebras, with the structure map given by such chosen colimits. For the precise definitions of pseudomonads and pseudoalgebras, see Appendix A.

### 2.1 Functoriality

We show that the assignment $${\mathsf {C}}\rightsquigarrow {\mathsf {Diag(C)}}$$ is part of a 2-functor on $${\mathsf {CAT}}$$. First of all, let $${\mathsf {C}}$$ and $${\mathsf {D}}$$ be locally small categories, and let $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ be a functor.

Consider now $${\mathsf {Diag(C)}}$$ and $${\mathsf {Diag(D)}}$$ as 1-categories. There is a (1-)functor $$F_*:{\mathsf {Diag(C)}}\rightarrow {\mathsf {Diag(D)}}$$ induced by F via postcomposition and whiskering, as follows.

Therefore, $${\mathsf {Diag}}$$ is an endofunctor of $${\mathsf {CAT}}$$.

The functor $$F_*:{\mathsf {Diag(C)}}\rightarrow {\mathsf {Diag(D)}}$$ extends to 2-cells giving a 2-functor, but we will not need this in order for $${\mathsf {Diag}}$$ to be a pseudomonad on $${\mathsf {CAT}}$$.

On the other hand, we need to extend $${\mathsf {Diag}}$$ to the 2-cells of $${\mathsf {CAT}}$$. So let $${\mathsf {C}}$$ and $${\mathsf {D}}$$ be locally small categories, let $$F,G:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ be functors, and let $$\alpha :F\Rightarrow G$$ be a natural transformation. We have an induced natural transformation $$\alpha _*:F_*\Rightarrow G_*$$ induced via whiskering, as follows. To each diagram $$({\mathsf {J}},D)$$ in $${\mathsf {C}}$$, we assign the morphism of diagrams $$(\mathrm {id}_{\mathsf {J}}, \alpha D)$$ of $${\mathsf {D}}$$, i.e.

Naturality follows from naturality of $$\alpha$$. This makes $${\mathsf {Diag}}$$ a strict 2-functor $${\mathsf {CAT}}\rightarrow {\mathsf {CAT}}$$.

### 2.2 Unit and Multiplication

#### 2.2.1 The Unit: One-Object Diagrams

The unit of the monad is a map constructing “one-object diagrams”. In detail, let $${\mathsf {C}}$$ be a locally small category. We construct the functor $$\eta _{\mathsf {C}}:{\mathsf {C}}\rightarrow {\mathsf {Diag(C)}}$$ as follows.

For brevity, we will denote $$\eta _{\mathsf {C}}$$ simply by $$\eta$$. This is (strictly) natural in the category $${\mathsf {C}}$$: given a functor $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$, the following diagram commutes strictly.

Indeed, both paths in the diagram give the following assignment,

using the fact that $$F(C)=F\circ C$$ if we view C as a functor $$1\rightarrow {\mathsf {C}}$$, and that analogously Ff is given by whiskering f (seen as a natural transformation) with F.

#### 2.2.2 Diagrams of Diagrams are Lax Cocones

Let’s now turn to the multiplication. We first notice that an object of $${\mathsf {Diag(Diag(C))}}$$ is the same as a lax cocone in $${\mathsf {CAT}}$$ with tip $${\mathsf {C}}$$, where the indexing category and all the categories appearing in the cone except $${\mathsf {C}}$$ are required to be small. Let’s see how. Let $${\mathsf {J}}$$ be a small category. A functor $$D:{\mathsf {J}}\rightarrow {\mathsf {Diag(C)}}$$ assigns to each object J of $${\mathsf {J}}$$ a diagram in $${\mathsf {C}}$$, i.e. a small category $$D_0J$$ together with a functor $$D_1J:D_0J\rightarrow {\mathsf {C}}$$:

and to each morphism $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$ a morphism of diagrams, which amounts to a functor $$D_0j:D_0J\rightarrow D_0J'$$ together with a natural transformation $$D_1j$$ as below:

Moreover, since we want D to be a functor, we need it to preserve identities and composition, i.e. $$D_0$$ needs to be a functor, and $$D_1$$ needs to satisfy the conditions $$D_1(\mathrm {id}_J)=\mathrm {id}_{D_1J}$$ and $$D_1(j'\circ j)=D_1j'D_0j\circ D_1J$$, which are exactly the conditions of lax naturality. In pictures,

In other words, a functor $$D:{\mathsf {J}}\rightarrow {\mathsf {Diag(C)}}$$ consists of a functor $$D_0:{\mathsf {J}}\rightarrow {\mathsf {Cat}}\subseteq {\mathsf {CAT}}$$, together with a lax cocone $$D_1$$ in $${\mathsf {CAT}}$$ under $$D_0$$ with tip $${\mathsf {C}}$$. A lax cocone is a lax natural transformation $$D_1:D_0\Rightarrow \Delta {\mathsf {C}}$$, where $$\Delta {\mathsf {C}}$$ is the constant functor at $${\mathsf {C}}$$. For brevity, we will also write constant functors simply as objects.

#### 2.2.3 The Multiplication: the Grothendieck Construction

Given now $$D=(D_0,D_1)$$ as above, take the Grothendieck construction $$\int \!D_0$$ of $$D_0:{\mathsf {J}}\rightarrow {\mathsf {Cat}}\subseteq {\mathsf {CAT}}$$, which we recall.

• An object of $$\int \!D_0$$ consists of a pair (JX) where J is an object of $${\mathsf {J}}$$ and X is an object of the category $$D_0J$$;

• A morphism $$(J,X)\rightarrow (J',X')$$ of $$\int \!D_0$$ consists of a pair (jf) where $$j:J\rightarrow J'$$ is a morphism of $${\mathsf {J}}$$, and $$f:D_0j(X)\rightarrow X'$$ is a morphism of the category $$D_0J'$$.

The short integral sign does not denote a coend here, it is standard for the Grothendieck construction (we use different sizes to avoid confusion, since both symbols are standard notation). Note that since $${\mathsf {J}}$$ and all the $$D_0J$$ are small, $$\int \!D_0$$ is small too. Its set of objects is given by

\begin{aligned} \coprod _{J\in {\mathsf {J}}} D_0J . \end{aligned}

Moreover:

• For each object J of $${\mathsf {J}}$$, the inclusion maps $$i_J:D_0J\rightarrow \int \!D_0$$ defined by the coproduct above can be canonically made into functors via

We will call the images of the $$i_J$$ the fibers of $$\int \!D_0$$.

• For each morphism $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$, there is a natural transformation

whose component at each object X of $$D_0J$$ is given by

• The $$i_J$$ and $$i_j$$ assemble into a lax cocone $$D_0 \Rightarrow \Delta \int \!D_0$$, i.e. the identity and composition conditions are satisfied.

It is well known that $$\int \!D_0$$ is the oplax colimit of $$D_0$$ in $${\mathsf {Cat}}$$, with the universal lax cocone given by the $$i_J$$. We now show that it is so also in $${\mathsf {CAT}}$$, and we also give a strict version of the universal property.Footnote 1

### Proposition 2.2

Let $$D_0:{\mathsf {J}}\rightarrow {\mathsf {Cat}}\subseteq {\mathsf {CAT}}$$ be a small diagram of small categories. Let $$D_1:D_0\Rightarrow \Delta {\mathsf {C}}$$ be a lax cocone over $$D_0$$ in $${\mathsf {CAT}}$$, with tip $${\mathsf {C}}$$ locally small (but not necessarily small). There is a unique functor $$\int \!D_0\rightarrow {\mathsf {C}}$$ such that

• For all objects J of $${\mathsf {J}}$$, the following triangle commutes (strictly);

• For all morphisms $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$, the following 2-cells coincide.

Denote this functor by $$\mu (D_0,D_1)$$, or more briefly by $$\mu (D)$$. It is a diagram in $${\mathsf {C}}$$. This will give the multiplication of the monad $${\mathsf {Diag}}$$.

### Proof of Proposition 2.2

Since we want the diagram 2.1 to commute strictly, the only possibility to define $$\mu (D)$$ on objects is as follows. For every object J of $${\mathsf {J}}$$, and for every object X of $$D_0J$$,

\begin{aligned} \mu (D) (J,X) {:}{=}D_1J(X) . \end{aligned}

Just as well, for all the morphisms of $$\int \!D_0$$ in the fiber, i.e. in the form $$(\mathrm {id}_J,f)$$ for a morphism $$f:X\rightarrow X'$$ of $$D_0J$$, we are forced to define

\begin{aligned} \mu (D) (\mathrm {id}_J,f) {:}{=}D_1J(f) . \end{aligned}

Moreover, since we want the condition (2.2) to hold, for all morphisms $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$ we have to require that $$\mu (D)$$ on the components of $$i_j$$ has to give the respective component of $$D_1j$$. Explicitly, for each object X of $$D_0J$$,

\begin{aligned} \mu (D) (i_j)_X = \mu (D) (j, \mathrm {id}_{D_0j(X)}) {:}{=}(D_1j)_X . \end{aligned}

The generic morphism $$(j,f):(J,X)\rightarrow (J',X')$$, for $$j:J\rightarrow J'$$ and $$f:D_0j(X)\rightarrow X'$$ can be decomposed as

and so we have determined the action of $$\mu (D)$$ for all morphisms of $$\int \!D_0$$.

Functoriality of this assignment is routine. $$\square$$

#### 2.2.4 Functoriality and Naturality of the Multiplication

We now have to show that the assignment $$(D_0,D_1)\mapsto \mu (D_0,D_1)$$ is functorial, and that it is natural in the category $${\mathsf {C}}$$.

To address functoriality, we need to look at morphisms in $${\mathsf {Diag(Diag(C))}}$$.

Given diagrams $$D:{\mathsf {J}}\rightarrow {\mathsf {Diag(C)}}$$ and $$E:{\mathsf {K}}\rightarrow {\mathsf {Diag(C)}}$$, where $${\mathsf {J}}$$ and $${\mathsf {K}}$$ are small categories, a morphism of diagrams from D to E amounts to a functor $$F:{\mathsf {J}}\rightarrow {\mathsf {K}}$$ together with a natural transformation

Explicitly, D consists of a functor $$D_0:{\mathsf {J}}\rightarrow {\mathsf {Cat}}\subseteq {\mathsf {CAT}}$$ and a lax cocone $$D_1:D_0\Rightarrow \Delta {\mathsf {C}}$$, and E has an analogous form. The natural transformation $$\phi$$ amounts to the following. For each object J of $${\mathsf {J}}$$, we have a morphism of diagrams

and for each morphism $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$, the following diagrams have to commute. First of all, this diagram of functors has to commute strictly.

Moreover, the following composite 2-cells have to coincide, forming a commutative pyramid with 2-cells as lateral faces, whose square base is the commutative square just described above.

Form now the Grothendieck construction of $$E_0$$. We can form a lax cocone over $$D_0$$ with tip $$\int \!E_0$$ as follows.

Note that this is a lax cocone $$D_0\Rightarrow \Delta \int \!E_0$$. By the universal property of the Grothendieck construction as an oplax colimit (Proposition 2.2), there is a unique functor $$\int \!D_0\rightarrow \int \!E_0$$ such that

• for all objects J of $${\mathsf {J}}$$, the following square commutes;

• for all morphisms $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$, the following composite 2-cells coincide.

Denote this functor by $$\mu _0(F,\phi )$$. This gives a triangle

which does not necessarily commute. In order to get a morphism of diagram $$\mu (D)\rightarrow \mu (E)$$ we need to fill the triangle above with a 2-cell which we form as follows. Consider the object (JX) of $$\int \!D_0$$, where J is an object of $${\mathsf {J}}$$ and X is an object of $$D_0J$$. Note that, by the diagram (2.1), $$\mu (D)(J,X)=D_1J(X)$$. Analogously, using the diagram (2.1) for E together with the diagram (2.4),

\begin{aligned} \mu (E)(\mu _0(J,X)) = \mu (E)(J,\phi _0J(X)) = E_1FJ(\phi _0J(X)). \end{aligned}

We now assign to the object (JX) the morphism of $${\mathsf {C}}$$ given by the component of $$\phi _1J$$ at X,

Let’s now show that this assignment is natural. We will again test this first along the fibers, and then on the opcartesian morphisms of $$\int \!D_0$$. So let $$f:X\rightarrow Y$$ be a morphism of $$D_0J$$. The following diagram commutes simply by naturality of $$\phi _1J$$.

Let now $$j:J\rightarrow J'$$ be a morphism of $${\mathsf {J}}$$. We have to prove that the following diagram commutes.

This is however exactly Equation (2.3), written out in components. Therefore we have a natural transformation, which we denote by $$\mu _1(F,\phi )$$, and we get a morphism of diagrams

which makes $$\mu$$ functorial. (The identity and composition conditions follow by uniqueness.) Note that in particular this shows functoriality of the Grothendieck construction not only on strictly commutative triangles of functors (i.e. in $${\mathsf {Cat}}/{\mathsf {C}}$$), but also more in general for lax-commutative triangles.

### Proposition 2.3

The functor $$\mu :{\mathsf {Diag(Diag(C))}}\rightarrow {\mathsf {Diag(C)}}$$ is strictly natural in $${\mathsf {C}}$$.

### Proof

Let $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ be a functor. The induced functor

maps a lax cocone with tip $${\mathsf {C}}$$ to the lax cocone with tip $${\mathsf {D}}$$ obtained simply via postcomposition with F.

In other words, $$F_{**}(D_0,D_1)=(D_0, F\circ D_1)$$. If we take the Grothendieck construction in both cases we get morphisms $$\mu (D):\int \!D_0 \rightarrow {\mathsf {C}}$$ and $$\mu (F_{**}D):\int \!D_0\rightarrow {\mathsf {D}}$$. By uniqueness (Proposition 2.2), necessarily $$\mu (F_**D)=F\circ \mu (D)$$, and therefore $$\mu$$ is strictly natural. $$\square$$

### 2.3 Unitors and Associators

#### 2.3.1 Left Unitor

Let $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ be a diagram. We can apply to it the unit $$\eta _{{\mathsf {Diag(C)}}}:{\mathsf {Diag(C)}}\rightarrow {\mathsf {Diag(Diag(C))}}$$ to form the diagram

corresponding to the following (rather trivial) lax cocone in $${\mathsf {CAT}}$$ with tip C.

We view this as a lax cocone over the diagram $${\mathsf {J}}:{\mathsf {1}}\rightarrow {\mathsf {CAT}}$$ which maps the unique object of $${\mathsf {1}}$$ to $${\mathsf {J}}$$. If we form the Grothendieck construction as prescribed by the multiplication of the monad, we get the category $$\int \!{\mathsf {J}}$$ which is isomorphic to $${\mathsf {J}}$$, explicitly given as follows:

• Objects are pairs $$(\bullet , X)$$, where $$\bullet$$ is the unique object of $${\mathsf {1}}$$ and X is an object of $${\mathsf {J}}$$;

• A morphism $$(\bullet , X)\rightarrow (\bullet , Y)$$ is simply a morphism $$f:X\rightarrow Y$$ of $${\mathsf {J}}$$.

The functor $$\mu (\eta (D))$$ maps then $$(\bullet , X)$$ to DX and $$f:(\bullet , X)\rightarrow (\bullet , Y)$$ to Df in $${\mathsf {C}}$$.

The functor $$\int \!{\mathsf {J}}\rightarrow {\mathsf {J}}$$ given by $$(\bullet , X)\mapsto X$$ is an isomorphism of categories. This defines an isomorphism of diagrams $$\mu _{\mathsf {C}}(\eta _{{\mathsf {Diag(C)}}}(D))\rightarrow D$$, in the category $${\mathsf {Diag(C)}}$$. Denote this isomorphism by $$\ell$$. This is the map that we take as left unitor.

### Proposition 2.4

The map $$\ell$$ induces a modification $$\mu \circ (\eta \,{\mathsf {Diag}}) \Rrightarrow \mathrm {id}$$.

### Proof

Let’s first show that $$\ell$$ is natural in the diagram D. If $$(R,\rho ):({\mathsf {J}},D)\rightarrow ({\mathsf {K}},E)$$ is a morphism of diagrams, it’s easy to see that this diagram commutes strictly,

where $${\tilde{R}}$$ is the functor mapping $$(\bullet , X)$$ to $$(\bullet , RX)$$, and acting similarly on morphisms. This commutative diagram induces an analogous commutative diagram in $${\mathsf {Diag(C)}}$$, so that $$\ell$$ is a natural isomorphism of functors

In order to show that $$\ell$$ is a modification, we have to show that $$\ell$$ is natural in the category $${\mathsf {C}}$$ as well, in the sense that for each functor $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ the following composite 2-cells are equal,

where the squares without a 2-cell commute (by naturality).

Explicitly, we have to check that given a diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$, the following parallel functors coincide.

Note however that $$F_*$$ acts on the codomain of the diagram, by postcomposing with F, while $$\ell$$ acts on the domain of the diagram, mapping $${\mathsf {J}}$$ to its isomorphic copy $$\int \!{\mathsf {J}}$$. Therefore both arrows give the same morphism of diagrams, explicitly the following commutative diagram of $${\mathsf {CAT}}$$,

where $${\tilde{D}}(\bullet , X)=D(X)$$, and the action on morphisms is similarly defined. Therefore $$\ell$$ is a modification. $$\square$$

#### 2.3.2 Right Unitor

Let $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ be a diagram. This time we apply to it the map $$\eta _*:{\mathsf {Diag(C)}}\rightarrow {\mathsf {Diag(Diag(C))}}$$ given by the functor image of $$\eta$$ under $${\mathsf {Diag}}$$. Explicitly, the result is the following lax cocone in $${\mathsf {CAT}}$$, with tip $${\mathsf {C}}$$, indexed by $${\mathsf {J}}$$ via the constant functor $$\Delta {\mathsf {1}}:{\mathsf {J}}\rightarrow {\mathsf {CAT}}$$ at $${\mathsf {1}}$$. In pictures,

If we form the Grothendieck construction, this time we get the category which is again isomorphic to $${\mathsf {J}}$$, explicitly given as follows:

• Objects are pairs $$(X,\bullet )$$, where X is an object of $${\mathsf {J}}$$ and $$\bullet$$ is the unique object of $${\mathsf {1}}$$;

• A morphism $$(X,\bullet )\rightarrow (Y,\bullet )$$ is simply a morphism $$f:X\rightarrow Y$$ of $${\mathsf {J}}$$.

The functor $$\mu (\eta _*(D))$$ maps $$(X,\bullet )$$ to DX and $$f:(X,\bullet )\rightarrow (Y,\bullet )$$ to Df in $${\mathsf {C}}$$.

Analogously to the left unitor case, we have a functor $$\int \!\Delta {\mathsf {1}}\rightarrow {\mathsf {J}}$$ given by $$(X,\bullet )\mapsto X$$ which induces an isomorphism of categories. This defines in turn an isomorphism of diagrams $$\mu (\eta _*(D))\rightarrow D$$, which we denote by $$r^{-1}$$ (and its inverse by r. See Definition A.1 for the convention we are using). The map r is the one that we take as right unitor.

### Proposition 2.5

The map r induces a modification $$\mathrm {id}\Rrightarrow \mu \circ \eta _*$$.

We omit the proof, since it is analogous to the case of $$\ell$$.

#### 2.3.3 Associator

In order to define the associator, we have to look at $${\mathsf {Diag(Diag(Diag(C)))}}$$. So let $$D:{\mathsf {J}}\rightarrow {\mathsf {Diag(Diag(C))}}$$ be a diagram which assigns to each object J of $${\mathsf {J}}$$ a diagram of diagrams $$D_1J:D_0J\rightarrow {\mathsf {Diag(C)}}$$, itself mapping the object K of $$D_0J$$ to the diagram $$(D_1J)_1:(D_1J)_0K\rightarrow {\mathsf {C}}$$, which, in turn, maps an object L of $$(D_1J)_0K$$ to the object $$(D_1J)_1(L)$$ of $${\mathsf {C}}$$. We could depict the situation as follows. For brevity we omit the action on morphisms, which is similarly constructed.

We can now take the Grothendieck construction at two different depths, which we can think of as “joining levels J and K” and “joining levels K and L”. The former way, which is $$\mu (D)\in {\mathsf {Diag(Diag(C))}}$$, gives the following diagram of diagrams (only two levels).

The latter way, which is $$\mu _*D\in {\mathsf {Diag(Diag(C))}}$$, gives instead the following diagram of diagrams, which is in general not isomorphic to the former.

If we apply once again the Grothendieck construction to the two, we do obtain isomorphic diagrams:

and

These are isomorphic as diagrams through the map

and so the following diagram commutes up to isomorphism.

We call this isomorphism the associator, and denote it by a. Again, analogously as for the unitors, we have:

### Proposition 2.6

The associators assemble to a modification $$\mu \circ \mu _* \Rrightarrow \mu \circ \mu$$.

### 2.4 Higher Coherence Laws

The associator and unitors satisfy coherence conditions that are analogous to the ones of monoidal categories (see Definition A.1 for the precise definition). We spell them out in detail for this case.

#### 2.4.1 Unit Condition

Instantiating the unit condition of Definition A.1 in our case, we get the following statement, which reminds us of the unit condition of monoidal categories.

• Consider a diagram of diagrams as follows.

Applying directly the Grothendieck construction we would have a diagram $$(J,K)\mapsto (D_1J)(K)$$. However, we instead want to insert a “bullet” via the unitor, and this can be done in two ways.

• We can either apply the (inverse of the) left unitor $$\ell$$ at depth K, and then take the Grothendieck construction, obtaining the following diagram.

• Alternatively, we can apply the right unitor r at depth J, and again take the Grothendieck construction, obtaining the following isomorphic diagram.

• Now, not only are the two diagrams isomorphic, but the isomorphism relating them is exactly the associator,

which we can view as “rebracketing”.

#### 2.4.2 Pentagon Equation

Instantiating the pentagon condition of Definition A.1 in our case, we get the following statement, which reminds us of the analogous condition for monoidal categories. Consider a four-level diagram, as follows.

There are several ways of obtaining a depth-one diagram via applying the Grothendieck construction three times, and they are related to one another via the associators. In particular, we can apply the Grothendieck construction repeatedly starting from the deepest (rightmost) level,

or we can start from the outermost (leftmost) level.

There are now two ways of obtaining the former from the latter via associators, and they are equal. They are induced by the following rebracketings, which form a commutative pentagon (analogous to the one of monoidal categories).

### 2.5 Cocomplete Categories are Algebras

In this section we prove the following statements.

### Theorem 2.7

Every cocomplete category $${\mathsf {C}}$$ equipped with a choice of colimit for each diagram has the structure of a pseudoalgebra over $${\mathsf {Diag}}$$.

As shown in Sect. 2.5.4, the converse of the theorem does not hold: not all pseudoalgebras are in this form.

A definition of pseudoalgebra over a pseudomonad is given in Appendix A.

#### 2.5.1 Structure Map

Let $${\mathsf {C}}$$ be a cocomplete category. For each diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$, choose a colimit (they are all isomorphic, pick one in each equivalence class). Let’s see why this construction is functorial. A colimit does not just consist of an object of $${\mathsf {C}}$$, but also of the arrows of the colimiting cocone. Denote by c(D) the (chosen) colimit object of D, and by $$h(D):D\Rightarrow c(D)$$ the colimiting cocone. In components, the cocone consists of arrows

for each object J of $${\mathsf {J}}$$. Now consider a morphism of diagrams as follows.

Using $$\rho$$ and the colimit cocone $$h(D'):D'\Rightarrow c(D')$$ we can construct a cocone under D, with tip $$c(D')$$: the one of components

for each J of $${\mathsf {J}}$$. This cocone must then factor uniquely through c(D) by the universal property of c(D) as a colimit:

Denote the resulting map $$c(D)\rightarrow c(D')$$ by $$c(R,\rho )$$. It is the unique map that makes the diagram above commute for each J of $${\mathsf {J}}$$. By uniqueness, this assignment preserves identities and composition, and so c is a functor $${\mathsf {Diag(C)}}\rightarrow {\mathsf {C}}$$. Technically speaking, for each diagram one can choose many possible colimits within the same equivalence class. However, once c(D) and $$c(D')$$ are fixed, the map $$c(D)\rightarrow c(D')$$ is unique. So any choice of such colimit objects gives rise to a functor, and all these functors will be naturally isomorphic, again by uniqueness.

We can say even more: the map $$c:{\mathsf {Diag(C)}}\rightarrow {\mathsf {C}}$$ is even 2-functorial if we view $${\mathsf {Diag(C)}}$$ as a 2-category (as in Definition 2.1), and $${\mathsf {C}}$$ (which is a 1-category) as a locally discrete 2-category. This is made precise by the following lemma.

### Lemma 2.8

Let $${\mathsf {C}}$$ be a cocomplete category and $$c:{\mathsf {Diag(C)}}\rightarrow {\mathsf {C}}$$ a choice of colimit for each diagram. Consider diagrams $$({\mathsf {J}},D)$$ and $$({\mathsf {J'}},D')$$ in $${\mathsf {C}}$$, morphisms of diagrams $$(R,\rho ), (R',\rho '): ({\mathsf {J}},D) \rightarrow ({\mathsf {J'}},D')$$, and suppose there exists a 2-cell of diagrams $$\alpha :(R,\rho )\Rightarrow (R',\rho ')$$. Then $$c(R,\rho ) = c(R',\rho ')$$.

### Proof

Recall that $$\alpha$$ consists of a natural transformation $$\alpha :R\Rightarrow R'$$ such that

This way, for each object J of $${\mathsf {J}}$$, the following diagram commutes,

where $$h(D'):D'\Rightarrow c(D')$$ denotes the colimit cone of $$c(D')$$ under $$D'$$. The maps $$c(R,\rho )$$ and $$c(R',\rho '): c(D)\rightarrow c(D')$$ are both defined as the unique maps making the following diagram commute,

and are therefore equal. $$\square$$

#### 2.5.2 Structure 2-Cells

We now give the structure 2-cells of the pseudoalgebras, namely the unitor and the multiplicator.

### Lemma 2.9

The following diagram commutes up to a canonical natural isomorphism.

We denote the natural isomorphism by $$\iota : c\circ \eta \Rightarrow \mathrm {id}_C$$.

### Proof

Let C be an object of $${\mathsf {C}}$$. The diagram $$\eta (C)$$ is the one-object diagram whose unique node is given by C. A colimit cocone over $$\eta (C)$$ consists of an object $$C'$$ together with a specified isomorphism $$C\rightarrow C'$$. Therefore, for any choice of c, we get canonically an isomorphism $$\iota _C:C\rightarrow c(\eta (C))$$. The maps $$\iota _C$$ assemble to a natural isomorphism $$\iota :c\circ \eta \Rightarrow \mathrm {id}_C$$, since for each $$f:C\rightarrow C'$$ of $${\mathsf {C}}$$ the following diagram commutes,

since the map $$c(\eta (f))$$ is defined (by definition of how c acts on morphisms) as the unique map making the diagram above commute. $$\square$$

### Lemma 2.10

The following diagram commutes up to a canonical natural isomorphism.

Denote the natural isomorphism by $$\gamma : c\circ c_* \Rightarrow c\circ \mu$$.

This statement is known in the literature, see for example [4, Section 40], as well as [26, Theorem 3.2]. Here we present a direct proof. In the proof we can see how the objects in the top right corner of the square are, in some sense, partial colimits of the objects in the bottom left corner. This will be made precise in Sect. 5.

### Proof

Let $$D:{\mathsf {J}}\rightarrow {\mathsf {Diag(C)}}$$. The diagram $$c_*D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ is given by the following postcomposition.

In other words, the nodes of D are diagrams (one for each object of $${\mathsf {J}}$$), and $$c_*$$ replaces them by their (chosen) colimit, obtaining a diagram in $${\mathsf {C}}$$ indexed by $${\mathsf {J}}$$.

Recall that $$\mu$$ is given by the Grothendieck construction, so that $$\mu (D)$$ is a diagram obtained by the union of the diagrams DJ for each J of $${\mathsf {J}}$$, plus additional arrows between those subdiagrams, induced by the morphisms of $${\mathsf {J}}$$. Specifically, for every morphism $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$ and for every $$f:X\rightarrow Y$$ of $$D_0J$$, the following square commutes.

The object $$c(\mu (D))$$ is a colimit of the resulting diagram involving all the j and the f as above. Recall now the universal property of the Grothendieck construction, and in particular diagrams (2.1) and (2.2). For each object J of $${\mathsf {J}}$$, the morphism of diagrams given by the inclusion $$i_J$$ of the fiber over J,

induces a map between their (chosen) colimits $$c(i_J,\mathrm {id}):c(DJ) \rightarrow c(\mu (D))$$. The maps $$c(i_J,\mathrm {id}):c(DJ) \rightarrow c(\mu (D))$$, for each J, assemble to a cocone under $$c_*D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$, with tip $$c(\mu (D))$$, meaning that for each morphism $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$, the following diagram commutes.

Indeed, we can rewrite (2.2) as follows,

which is exactly the condition for a 2-cells of diagrams $$(i_J,\mathrm {id})\Rightarrow (i_{J'}\circ D_0J,D_1j)$$ (see Definition 2.1). By Lemma 2.8, then, $$c(i_J,\mathrm {id})=c(i_{J'}\circ D_0J,D_1j)$$, which means that (2.5) commutes.

As we said, the maps $$c(i_J,\mathrm {id}):c(DJ) \rightarrow c(\mu (D))$$, assemble to a cocone under $$c_*D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$, with tip $$c(\mu (D))$$. Therefore, by the universal property of $$c(c_*D)$$ as a colimit, there exists a unique arrow $$c(c_*D)\rightarrow c(\mu (D))$$, which we denote by $$\gamma _D$$, making the following diagram commute for all J of $${\mathsf {J}}$$,

where the $$h(c_*D)_J$$ denote the arrows of the colimiting cocone. Note that for each object X of $$D_0J$$ we can extend the diagram above to the following commutative diagram,

where $$h(DJ)_X$$ and $$h(\mu (D))_X$$ are the components at X of the colimiting cocones of c(DJ) and $$c(\mu (D))$$.

To show that $$\gamma _D$$ is an isomorphism, we invoke the Yoneda embedding. Let K be any object of $${\mathsf {C}}$$. We want to show that the function

which is natural in K, is a bijection. To this end, we note that by the universal property of colimits, the set on the left is naturally isomorphic (via composing with the components of $$h(\mu (D))$$) to the subset

\begin{aligned} S\; \subseteq \;\prod _{J\in {\mathsf {J}}} \prod _{X\in D_0J} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}\big ( D_1J(X), K \big ) \end{aligned}

whose elements are families of arrows $$(k_{J,X}: D_1J(X) \rightarrow K)$$ such that for each $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$ and each $$f:X\rightarrow Y$$ of $$D_0J$$ the following diagram commutes.

Now, for each J of $${\mathsf {J}}$$, the quantity appearing in S given by

\begin{aligned} S_J \;\subseteq \; \prod _{X\in D_0J} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}\big ( D_1J(X), K \big ) \end{aligned}

and whose elements are arrows $$(k_{J,X}: D_1J(X) \rightarrow K)$$ such that $$f:X\rightarrow Y$$ of $$D_0J$$ the following diagram commutes,

is in natural bijection with

\begin{aligned} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}\big ( c(DJ), K \big ) \end{aligned}

by universal property of the colimit, via composing with the cocones h(DJ). In other words, S is in natural bijection with the subset of

\begin{aligned} S' \;\subseteq \;\prod _{J\in {\mathsf {J}}} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}\big ( c(DJ), K \big ) \end{aligned}

whose elements are arrows $$(k'_{J}: c(DJ) \rightarrow K)$$ such that the following diagram commutes.

The subset $$S'$$, again by the universal property of the colimit, is in bijection (via composing with $$h(c_*D)$$) with $${{\,\mathrm{Hom}\,}}_{\mathsf {C}}\big (c(c_*D), K\big )$$, which is exactly at the right side of (2.7). Since (2.6) commutes, composing with $$\gamma _D$$ has the same effect as applying the bijections given by (the inverse of) composing with $$h(c_*D)$$ and $$h(DJ)_X$$ (all the bijections are invertible), and then composing with $$h(\mu (D))_X$$. Therefore (2.7) is a bijection too. By the Yoneda lemma, then, $$\gamma _D$$ is an isomorphism. $$\square$$

#### 2.5.3 Coherence Laws

In order to prove Theorem 2.7 it remains to be checked that the unit and multiplication coherence conditions of Definition A.4 hold. Intuitively, such coherence conditions hold by the “uniqueness property of maps between colimits”. In other words, not only do objects satisfying the same universal property admit an isomorphism between them, but they admit a unique one compatible with the universal property (in our case, the cocone): while colimit objects of a diagram may have many automorphisms (as objects), colimit cocones over the same diagram form a contractible groupoid.

Let’s see this more explicitly. The unit condition of Definition A.4, instantiated in our case, says the following. Let $${\mathsf {C}}$$ be a cocomplete locally small category, and construct (choose) the functor $$c:{\mathsf {Diag(C)}}\rightarrow {\mathsf {C}}$$ as before. Consider now a diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$. We can apply the map $$\eta _*:{\mathsf {Diag(C)}}\rightarrow {\mathsf {Diag(Diag(C))}}$$ as in Sect. 2.3.2 and obtain the diagram $$\eta _*D:{\mathsf {J}}\rightarrow {\mathsf {Diag(C)}}$$ as follows.

Now we can either

• apply to $$\eta _*D$$ the map $$c_*$$, which replaces each one-object diagram DJ with its chosen colimit c(DJ) (isomorphic to DJ via the unitor $$\iota$$), giving the diagram $$c(D-):{\mathsf {J}}\rightarrow {\mathsf {C}}$$; or

• form the Grothendieck construction and obtain the diagram $$(J,\bullet ) \mapsto DJ$$, with exactly the same image in $${\mathsf {C}}$$ as D, but indexed by a nominally different category, and isomorphic to D via the counit $$\rho$$ .

Both ways give isomorphic diagrams in $${\mathsf {C}}$$, which then have isomorphic colimits. The isomorphism between the colimits can be written a priori in two ways:

• It is the one induced by $$\gamma : c\circ c_* \Rightarrow c\circ \mu$$;

• It is the one induced by the isomorphism of diagrams of components $$\iota :DJ \rightarrow c(DJ)$$ for each object J of $${\mathsf {J}}$$.

The unit condition of pseudoalgebras says that these two isomorphism should be equal. This is indeed the case, by uniqueness of the morphism $$\gamma$$: forming the colimit cocones of D and of $$c(D-)$$, which are isomorphic diagrams via $$\iota$$, we have a unique morphism making the following diagram commute for all J of $${\mathsf {J}}$$,

which can be seen as either the map $$\gamma$$ (by definition), or as the map induced by $$\iota$$, after suitably translating D into $$(J,\bullet ) \mapsto DJ$$ via the right unitor r.

The multiplication condition of Definition A.4, again instantiated in our case, says the following. As in Sect. 2.3.3, let $$D\in {\mathsf {Diag(Diag(Diag(C)))}}$$ be a diagram as follows.

We can now take the colimit progressively, a priori in two ways: first of all, “from the inside out”, that is,

• For each J of $${\mathsf {J}}$$ and K of $$D_0J$$, take the (chosen) colimits of the diagrams $$(D_1J)_1K$$, obtaining the following diagram of diagrams;

• Then, for each J of $${\mathsf {J}}$$, take the (chosen) colimit of the remaining innermost level diagram $$c_*(D_1J)$$, obtaining the following diagram;

• Finally, take the colimit $$c(c_*(c_{**}D))$$ of the diagram just obtained.

Alternatively, we could

• Form the Grothendieck construction of D joining levels J and K, obtaining the following diagram of diagrams;

• Form again the Grothendieck construction, joining level L as well;

• Finally, take the colimit $$c(\mu (\mu (D)))$$ of the resulting diagram.

The colimits constructed this way are isomorphic, a priori, in two different ways, using the maps obtained by $$\gamma$$ in different orders (first inner level, then outer, or vice versa). However, the different ways coincide, since both colimits come equipped with the following cocones,

and there is a unique map making the diagram above commute for all J, K and L.

This finally proves that cocomplete categories are pseudoalgebras of $${\mathsf {Diag}}$$ (Theorem 2.7).

#### 2.5.4 Not All Algebras are of this Form

We now want to show the following statement.

### Proposition 2.11

Not every pseudoalgebra over $${\mathsf {Diag}}$$ is in the form of Theorem 2.7.

We use the following known result [26, Theorem 2.7].

### Theorem 2.12

Let $${\mathsf {C}}$$ be a cocomplete category. Then the category $${\mathsf {Diag(C)}}$$ is cocomplete too. Moreover, the functor $${\mathsf {Diag(C)}}\rightarrow {\mathsf {Cat}}$$ which assigns to each diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ its domain $${\mathsf {J}}$$ preserves colimits.

We are now ready to prove the proposition. We will prove it by showing that for free pseudoalgebras, in the form $$({\mathsf {Diag(C)}},\mu )$$, the map $$\mu$$ is in general not taking colimits of diagrams (of diagrams).

### Proof of Proposition 2.11

Let $${\mathsf {C}}$$ be a cocomplete category with at least two non-isomorphic objects X and Y and a morphism $$f:X\rightarrow Y$$. Consider now the morphism $$\eta (f)$$ of $${\mathsf {Diag(C)}}$$, which can be seen as the morphism of diagrams,

and so, in particular, also as a diagram of diagrams (indexed by the walking arrow $${\mathsf {2}}$$). Denote by $$D:{\mathsf {2}}\rightarrow {\mathsf {Diag(C)}}$$ this diagram of diagrams. We have that $$\mu (D)$$, as given by the Grothendieck construction, is a diagram indexed again by $${\mathsf {2}}$$. Instead, by Theorem 2.12, the colimit of D in $${\mathsf {Diag(C)}}$$ is a diagram whose domain must be the colimit of $$\mathrm {id}:{\mathsf {1}}\rightarrow {\mathsf {1}}$$ in $${\mathsf {Cat}}$$, which is $${\mathsf {1}}$$. In particular, this colimit is not isomorphic to $$\mu (D)$$ .

Therefore, for the free algebra $$({\mathsf {Diag(C)}},\mu )$$, the algebra structure map $$\mu$$ is not in the form of Theorem 2.7. (See the end of Appendix A.2 for why $$({\mathsf {Diag(C)}},\mu )$$ is indeed a pseudoalgebra.) $$\square$$

A structural reason for why not all $${\mathsf {Diag}}$$-algebras arise this way will be given in Sect 4.6.1. Conjecturally, the generic $${\mathsf {Diag}}$$-algebras may be given by taking oplax colimits, instead of strict (in 2-categories rather than categories).

## 3 Image Presheaves

In this section we define the notion of image presheaf of a diagram, which may be interpreted as its “free” or “prototype colimit”. As far as we can tell, it was first introduced by Paré under the name “connected component functor” [23]. This concepts allows to extend and generalize the theory of cofinal functors (which we call confinal, see Sect 3.2), giving conditions for when certain diagrams have isomorphic colimits even after applying a functor to them (Proposition 3.9), and it incorporates absolute colimits as a special case (see Proposition 3.13 and the subsequent discussion).

### 3.1 Diagrams and Presheaves

Given a diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$, we obtain a presheaf $${{\,\mathrm{Im}\,}}{D}$$ on $${\mathsf {C}}$$ canonically, as follows.

### Definition 3.1

The image presheaf of the diagram D, which we denote by $${{\,\mathrm{Im}\,}}D$$, is the colimit of the following composite functor,

where y denotes the Yoneda embedding.

We can view the image as a “free colimit”, the presheaf obtained as the colimit of representables indexed by the diagram D. As usual, by the universal property of colimits this assignment is functorial. The terminology “image” is motivated by a factorization (see Sect 3.2.1), as well as by analogy with random variables (see Sect 5.4).

Equivalently, $${{\,\mathrm{Im}\,}}D$$ is the (pointwise) left Kan extension

\begin{aligned} {{\,\mathrm{Im}\,}}{D} {:}{=}{\mathrm {Lan}}_{D^\mathrm {op}}{1}, \end{aligned}

as in the following diagram,

where $$1:{\mathsf {J}}^\mathrm {op}\rightarrow {\mathsf {Set}}$$ is the constant presheaf at the singleton set 1, and $$\lambda _D$$ denotes the universal 2-cell. This way one could generalize the definition to the case of weighted diagrams, which is however beyond the scope of the present paper.

Concretely, given an object C of $${\mathsf {C}}$$, the set $$({{\,\mathrm{Im}\,}}D) (C)$$ is the set

\begin{aligned} \mathop {{{\,\mathrm{\mathrm{colim}}\,}}}\limits _{J\in {\mathsf {J}}} \big ( {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C,DJ) \big ). \end{aligned}

Its elements are the equivalence classes of arrows of $${\mathsf {C}}$$ of the form $$C\rightarrow DJ$$, for some object J of $${\mathsf {J}}$$, where we identify any two arrows $$f:C\rightarrow DJ$$ and $$f':C\rightarrow DJ'$$ whenever there exists a morphism $$g:J\rightarrow J'$$ of $${\mathsf {J}}$$ such that $$f'=Dg\circ f$$, as in the following diagram.

Functoriality of $${{\,\mathrm{Im}\,}}$$, as a functor $${\mathsf {Diag(C)}}\rightarrow [{\mathsf {C}}^\mathrm {op}, {\mathsf {Set}}]$$, is given by pasting arrows and commutative diagrams.

In general, two arrows $$f:C\rightarrow DJ$$ and $$f':C\rightarrow DJ'$$ are identified if there is a zig-zag of arrows of $${\mathsf {J}}$$ connecting J and $$J'$$, which we write as $$J\leftrightsquigarrow J'$$, such that the following diagram “commutes”.

By convention, we say that a triangle containing a zig-zag as the one above commutes if and only if each arrow in the zig-zag gives a commutative triangle. For later use, we denote by [Jf] the equivalence class in $${{\,\mathrm{Im}\,}}D$$ represented by $$f:C\rightarrow DJ$$.

This description in terms of equivalence classes of arrows can be stated more concisely as follows: the presheaf $${{\,\mathrm{Im}\,}}D$$ applied to the object C is the set of connected components of the comma category C/D. This is how this construction was first introduced (for small categories) in [23, Section 2], where it is called the “connected component functor” or $$\pi _0$$. The equivalence of the two definitions is already proven in [23, Theorem 2.1].

#### 3.1.1 The Category of Elements

Let $$P:{\mathsf {C}}^\mathrm {op}\rightarrow {\mathsf {Set}}$$ be a presheaf. Recall the discrete fibration given by the category of elements

Note that we use again the short integral sign, as we had used for the Grothendieck construction – but here it denotes the category of elements, as we are using the contravariant version. The category $$\int \!^o P$$ is the category where

• Objects consist of pairs (Cx), where C is an object of $${\mathsf {C}}$$ and $$x_C$$ is an element of the set PC.

• A morphism $$(C,x)\rightarrow (C',y)$$ is a morphism $$g:C\rightarrow C'$$ of $${\mathsf {C}}$$ such that the function $$Pg:PC'\rightarrow PC$$ sends $$y\in PC'$$ to $$x\in PC$$.

If C is small (resp. locally small), $$\int \!^o P$$ is small too (resp. locally small). The functor $$\int \!^o P \rightarrow C$$, which is a discrete fibration, maps (Cx) to C and a morphism of $$\int \!^o P$$ to the underlying morphism of C. The category of elements is functorial in the following way. Let $$\alpha :P\rightarrow Q$$ be a morphism of presheaves, i.e. a natural transformation

we can construct a functor $$\int \!^o \alpha :\int \!^o P \rightarrow \int \!^o Q$$ which makes the following diagram commute,

where the morphisms into $${\mathsf {C}}$$ are the canonical discrete fibrations. The functor $$\int \!^o \alpha$$ is constructed as follows.

• It maps the object (Cp), where C is an object of $${\mathsf {C}}$$ and $$p\in PC$$, to the object $$(C,\alpha _C(p))$$. Note that $$\alpha _C(p)\in QC$$;

• It maps the morphism $$(C,Pf(q))\rightarrow (C',q)$$ induced by the morphism $$f:C\rightarrow C'$$ of $${\mathsf {C}}$$ to the morphism $$(C,Qf(\alpha _{C'}(q)))\rightarrow (C', \alpha _{C'}(q))$$ again induced by f. Note that the following naturality diagram commutes.

Consider now a diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$, take its image presheaf $${{\,\mathrm{Im}\,}}D$$ and form its category of elements $$\int \!^o{{\,\mathrm{Im}\,}}D$$. Let’s see what we get explicitly.

• An object of $$\int \!^o{{\,\mathrm{Im}\,}}D$$ consists of an object C of $${\mathsf {C}}$$ together with an equivalence class [Jf] represented by an object J of $${\mathsf {J}}$$ and a morphism $$f:C\rightarrow DJ$$ of $${\mathsf {C}}$$.

• A morphism $$(C,[J,f])\rightarrow (C',[J',f'])$$ consists of a morphism $$g:C\rightarrow C'$$ of $${\mathsf {C}}$$ such that $$({{\,\mathrm{Im}\,}}D)(g)([J',f'])=[J,f]$$. This means that there is a zig-zag of arrows of $${\mathsf {J}}$$ connecting J and $$J'$$, which we write as $$J\leftrightsquigarrow J'$$, such that the following diagram commutes.

### Proposition 3.2

Given a morphism of diagrams

the 2-cell $$\rho$$ factors in the following form,

where the triangle on the right commutes, with the vertical arrow given by $$\int \!^o{{\,\mathrm{Im}\,}}(R,\rho )$$ (recall that both $$\int \!^o$$ and $${{\,\mathrm{Im}\,}}$$ are functorial).

Before the proof, let’s see what the functor $$\int \!^o{{\,\mathrm{Im}\,}}(R,\rho ):\int \!^o {{\,\mathrm{Im}\,}}F\rightarrow \int \!^o {{\,\mathrm{Im}\,}}F'$$ looks like. It maps an object

\begin{aligned} (C,[J,C\xrightarrow {f} FJ]) \end{aligned}

of $$\int \!^o{{\,\mathrm{Im}\,}}F$$ to the object

\begin{aligned} (C,[RJ,C\xrightarrow {f} FJ \xrightarrow {\rho _J} F'RJ]) \end{aligned}

of $$\int \!^o{{\,\mathrm{Im}\,}}F'$$. On morphisms, given $$g:C\rightarrow C'$$ in $${\mathsf {C}}$$ and a zig-zag $$J \leftrightsquigarrow J'$$ in $${\mathsf {J}}$$ making the diagram on the left commute, we get the diagram on the right.

The right-most square commutes by naturality of $$\rho$$ applied to the zig-zag.

### Proof

Let J be an object of $${\mathsf {J}}$$. Let’s give the component of $${\tilde{\rho }}$$ at J explicitly. Note first that

and that

\begin{aligned} {\tilde{F}}'(R(J)) \;=\; (RJ, [F'RJ \xrightarrow {\mathrm {id}} F'RJ]). \end{aligned}

The morphism $${\tilde{\rho }}_J: \int \!^o{{\,\mathrm{Im}\,}}(R,\rho ) ({\tilde{F}} (J)) \rightarrow {\tilde{F}}'(R(J))$$ is then given by the following diagram,

with the zig-zag given by the identity. By construction, whiskering $${\tilde{\rho }}$$ with the forgetful functor to $${\mathsf {C}}$$ we get back $$\rho$$. $$\square$$

### 3.2 Connecting Confinal Functors and Absolute Colimits

As shown in [23, Section 3], the concept of image presheaf allows us to extend a bit the theory of confinal functors,Footnote 2 and unifies it with the theory of absolute colimits. Here we restate some of those ideas, since we have slightly different size conditions. A reference for the standard theory is for example given in [2, Section 2.11] (note that there the term “final functor” is used instead, for limit-invariant functors, rather than colimit-invariant).

### Definition 3.3

A functor $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ is called confinal if for every object D of $${\mathsf {D}}$$, the comma category D/F is non-empty and connected.

Note that, if we view F as a (possibly large) diagram, $${{\,\mathrm{Im}\,}}F(D)$$ for an object D of $${\mathsf {D}}$$ can be seen as the set of connected components of D/F. Therefore F is confinal if and only if $${{\,\mathrm{Im}\,}}F(D)$$ is the terminal presheaf. (See also [23, Corollary 3.4].)

The importance of confinal functors is due to the following well-known statement, which is actually an equivalent characterization of confinality.

### Proposition 3.4

If $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ is confinal, for every functor $$G:{\mathsf {D}}\rightarrow {\mathsf {E}}$$ admitting a colimit, the functor $$G\circ F:{\mathsf {C}}\rightarrow {\mathsf {E}}$$ admits a colimit too, and the map between colimits

\begin{aligned} \mathop {{{\,\mathrm{\mathrm{colim}}\,}}}\limits _{C\in {\mathsf {C}}} G(F(C)) \rightarrow \mathop {{{\,\mathrm{\mathrm{colim}}\,}}}\limits _{D\in {\mathsf {D}}} G(D) \end{aligned}

induced by the following morphism of (possibly large) diagrams

is an isomorphism.

For a proof, see for example the proof of the very similar statement [2, Proposition 2.11.2] (again, note the different conventions there).

#### 3.2.1 Refining the Comprehension Factorization

We would like now to prove the following statement.

### Proposition 3.5

Let $${\mathsf {C}}$$ be (small-)cocomplete. The (large) colimit of the fibration

exists, and it coincides with the (small) colimit of the diagram $$F:{\mathsf {J}}\rightarrow {\mathsf {C}}$$.

This is almost an instance of the following known result, sometimes called the “comprehension factorization schema”.

### Theorem 3.6

[28] There is an orthogonal (EM)-factorization system on $${\mathsf {Cat}}$$, where E are the confinal functors and M are the discrete fibrations.

However, in our case we are not requiring $${\mathsf {C}}$$ to be small, only locally small. Because of this, and because we need the construction explicitly, we give a dedicated proof. We construct a functor $$\tilde{F}:{\mathsf {J}}\rightarrow \int \!^o{{\,\mathrm{Im}\,}}F$$ as follows.

• For each object J of $${\mathsf {J}}$$, define

\begin{aligned} \tilde{F}J \;{:}{=}\; (FJ,[J,\mathrm {id}_{FJ}]), \end{aligned}

i.e. assign to J the equivalence class represented by the identity arrow $$FJ\rightarrow FJ$$ of $${\mathsf {C}}$$.

• For each morphism $$f:J\rightarrow J'$$, take the map $$Ff:FJ\rightarrow FJ'$$. Notice that we have the following commutative diagram,

so that we have a well-defined morphism of $$\int \!^o{{\,\mathrm{Im}\,}}F$$ (the zig-zag is simply given by the morphism f).

### Proposition 3.7

The functor $$\tilde{F}:{\mathsf {J}}\rightarrow \int \!^o{{\,\mathrm{Im}\,}}F$$ is confinal.

This suffices to deduce Proposition 3.5, since the following diagram commutes.

### Proof of Proposition 3.7

We need to show that for every object (C, [Jf]) of $$\int \!^o{{\,\mathrm{Im}\,}}F$$, the comma category $$(C,[J,f])/\tilde{F}$$ is non-empty and connected. This is guaranteed by the way the category $$\int \!^o{{\,\mathrm{Im}\,}}F$$ is constructed, as follows.

First, since $$\tilde{F}J$$ is the equivalence class represented by the identity $$FJ\rightarrow FJ$$, we can consider f as an arrow $$(C,[J,f])\rightarrow \tilde{F}J$$ of $$\int \!^o{{\,\mathrm{Im}\,}}F$$ and, hence, an object of $$(C,[J,f])/\tilde{F}$$, as we have the trivially commuting diagram

with the zig-zag given by the identity. Now, given any other arrow $$f':(C,[J,f])\rightarrow \tilde{F}J'$$ in $$\int \!^o{{\,\mathrm{Im}\,}}F$$, we have $$[J',f']={{\,\mathrm{Im}\,}}F(f')([J',1_{DJ'}])=[J,f]$$. So there is a zig-zag $$J\leftrightsquigarrow J'$$ in $${\mathsf {J}}$$, which actually links $$f'$$ with f in the comma category $$(C,[J,f])/\tilde{F}$$, as required. $$\square$$

#### 3.2.2 Mutually Confinal Diagrams

We will make use of the following well-known fact:

### Lemma 3.8

Consider the functors

where $${\mathsf {A}}$$, $${\mathsf {B}}$$ and $${\mathsf {C}}$$ are locally small categories. If $$G\circ F$$ is confinal and G is fully faithful, then F and G separately are confinal too.

### Proposition 3.9

Let $${\mathsf {C}}$$ be a locally small category. Let $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and $$E:{\mathsf {K}}\rightarrow {\mathsf {C}}$$ be small diagrams. The following conditions are equivalent.

1. (a)

$${{\,\mathrm{Im}\,}}D$$ and $${{\,\mathrm{Im}\,}}E$$ are naturally isomorphic;

2. (b)

for every locally small category $${\mathsf {D}}$$ and every functor $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$, the composite diagram $$F\circ D:{\mathsf {J}}\rightarrow {\mathsf {D}}$$ admits a colimit if and only if $$F\circ E:{\mathsf {K}}\rightarrow {\mathsf {D}}$$ does, and in that case the two colimits are isomorphic;

3. (c)

D and E are connected by a zigzag in $${\mathsf {Cat}}/{\mathsf {C}}$$ such that all the arrows of the underlying zigzag $${\mathsf {J}}\leftrightsquigarrow {\mathsf {K}}$$ in $${\mathsf {Cat}}$$ are confinal functors.

### Definition 3.10

If the diagrams $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and $$E:{\mathsf {K}}\rightarrow {\mathsf {C}}$$ satisfy any (and, hence, all) of the conditions above, we call them mutually confinal.

One should view the property of being mutually confinal as the absolute coincidence of their colimits: existence granted, their colimits remain the same even after applying any other functor.

This idea, minus the size issues, appears already in [23, Theorem 3.2].

### Proof of Proposition 3.9

The statement (c)$$\Rightarrow$$(b) is part of the standard theory of confinal functors (see the references). The statement (b)$$\Rightarrow$$(a) follows from choosing for $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ the Yoneda embedding $$\eta :{\mathsf {C}}\rightarrow {\mathsf {PC}}$$.

The real work is to prove (a)$$\Rightarrow$$(c). To this end, suppose that $$\alpha$$ is an isomorphism $${{\,\mathrm{Im}\,}}D \cong {{\,\mathrm{Im}\,}}E$$. We have an isomorphism between the corresponding categories of elements,

together with functors $$\tilde{D}:{\mathsf {J}}\rightarrow \int \!^o {{\,\mathrm{Im}\,}}D$$ and $$\tilde{E}:{\mathsf {K}}\rightarrow \int \!^o {{\,\mathrm{Im}\,}}E$$ which are confinal by Proposition 3.7. We have the following diagram of confinal functors.

Denote now by $${\mathsf {S}}$$ the full subcategory of $$\int \!^o {{\,\mathrm{Im}\,}}E$$ given by the joint full image of the two functors $$\int \!^o\alpha \circ \tilde{D}$$ and $${\tilde{E}}$$. The situation is depicted in the following commutative diagram.

By construction, S is small, since its cardinality is bounded by the one of the disjoint union of the sets of objects of $${\mathsf {J}}$$ and $${\mathsf {K}}$$, which are small. Moreover, the resulting functors $${\mathsf {J}}\rightarrow {\mathsf {S}}$$ and $${\mathsf {K}}\rightarrow {\mathsf {S}}$$ are confinal by Lemma 3.8. The resulting diagram

gives the desired zigzag (of length 2). $$\square$$

#### 3.2.3 Absolute Colimits

An absolute colimit is a colimit which is preserved by every functor [24]. We can redefine the concept of absolute colimits in terms of mutually confinal functor as follows. As we will see, this is equivalent to the usual definition. Again, these ideas, minus size issues, already appear in [23], see Corollary 3.3 therein and the subsequent discussion.

### Definition 3.11

Let $${\mathsf {C}}$$ be a locally small category, and let $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ be a small diagram. An absolute colimit of D is an object X of $${\mathsf {C}}$$ such that the diagrams $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and $$X:{\mathsf {1}}\rightarrow {\mathsf {C}}$$ are mutually confinal.

The image presheaf of a one-object diagram is the one given by the Yoneda embedding $$y:{\mathsf {C}}\rightarrow [{\mathsf {C}}^\mathrm {op},{\mathsf {Set}}]$$, as the following proposition show.

### Proposition 3.12

For each locally small category $${\mathsf {C}}$$, the following diagram commutes up to natural isomorphism.

### Proof

Using the definition of image in terms of Kan extensions, and recalling that $$\eta (X)$$ is the diagram $$X:{\mathsf {1}}\rightarrow {\mathsf {C}}$$ that picks out the object X, we have that $${{\,\mathrm{Im}\,}}(\eta (X))$$ is given by the following Kan extension,

which is isomorphic to $${{\,\mathrm{Hom}\,}}_{\mathsf {C}}(-,X)$$, i.e. the image of X under the Yoneda embedding. The isomorphism is moreover natural in X, by the universal property of (free) colimits. $$\square$$

Therefore, equivalently, an object X is an absolute colimit of the diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ if and only if $${{\,\mathrm{Im}\,}}D$$ is naturally isomorphic to the representable presheaf $${{\,\mathrm{Hom}\,}}_{\mathsf {C}}(-,X)$$.

If we instance Proposition 3.9 for this case, we get the following statement.

### Proposition 3.13

Let $${\mathsf {C}}$$ be a locally small category. Let $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and be a small diagram, and let X be an object of $${\mathsf {C}}$$. The following conditions are equivalent.

1. (a)

X is an absolute colimit of D (i.e. $${{\,\mathrm{Im}\,}}D \cong {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(-,X)$$ naturally);

2. (b)

for every locally small category $${\mathsf {D}}$$ and every functor $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$, the object F(X) is the colimit in $${\mathsf {D}}$$ of the composite diagram $$F\circ D:{\mathsf {J}}\rightarrow {\mathsf {D}}$$;

3. (c)

$$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and $$X:{\mathsf {1}}\rightarrow {\mathsf {C}}$$ are connected by a zigzag in $${\mathsf {Cat}}/{\mathsf {C}}$$ such that all the arrows of the underlying zigzag $${\mathsf {J}}\leftrightsquigarrow {\mathsf {1}}$$ in $${\mathsf {Cat}}$$ are confinal functors.

Note that condition (b) implies, in particular, that indeed X is a colimit of D (take F to be the identity). Denote the colimit cone by $$h:D\Rightarrow X$$.

We can now rewrite condition (c) in a more elementary way. Recall that in the proof of Proposition 3.9 we had obtained condition (c) from (a) by forming the category of elements of the (common) image presheaf, and taking the joint image of the confinal functors from $${\mathsf {J}}$$ and from $${\mathsf {1}}$$ to this category of elements. The category of elements of the representable presheaf $${{\,\mathrm{Hom}\,}}_{\mathsf {C}}(-,X)$$ is isomorphic to the slice category $${\mathsf {C}}/X$$. We therefore have to take the joint image in $${\mathsf {C}}/X$$ of the two functors at the top of this diagram,

where the functor $${\mathsf {J}}\rightarrow {\mathsf {C}}/X$$ maps an object $$J\in {\mathsf {J}}$$ to the arrow of the colimit cone $$h_J:DJ\rightarrow X$$. Just as in the proof of Proposition 3.9, denote this joint full image by $${\mathsf {S}}$$. Now, the resulting functor $${\mathsf {1}}\rightarrow {\mathsf {S}}$$ is trivially confinal, since it maps the unique object of $${\mathsf {1}}$$ to $$\mathrm {id}_X\in {\mathsf {C}}/X$$. More interestingly, the proof of Proposition 3.9 says that also the resulting functor $${\mathsf {J}}\rightarrow {\mathsf {S}}$$ is confinal. The condition is nontrivial for the only object of $${\mathsf {S}}$$ that does not come from $${\mathsf {J}}$$, which is the one coming from $${\mathsf {1}}$$, namely $$\mathrm {id}_X\in {\mathsf {C}}/X$$. For this object, the confinality condition of the functor $${\mathsf {J}}\rightarrow {\mathsf {S}}$$ says the following:

1. (d)

There exist an object J of $${\mathsf {J}}$$ and an arrow $$f:X\rightarrow DJ$$ of $${\mathsf {C}}$$ such that the following diagram commutes:

and such that moreover, for each object $$J'$$ of $${\mathsf {J}}$$ and arrow $$f':X\rightarrow DJ'$$ making a similar diagram commute, there exists a zigzag $$J \leftrightsquigarrow J'$$ in $${\mathsf {J}}$$ making the following diagram in $${\mathsf {C}}$$ commute.

Intuitively, we can interpret this condition as “the colimit cone eventually has a section, which is in some sense unique”. This is similar to very well-known statements in the literature, see for example Theorems 2.1 and 4.1 in [24]. Therefore we can view our theory of mutually confinal functors as a joint generalization both of confinal functors and of absolute colimits.

## 4 The Monad of Small Presheaves

In this section we study small presheaves, and show that they also form a pseudomonad. Moreover, the image map of the previous section gives a morphism of pseudomonads (also explicitly defined in Appendix A). Again, cocomplete categories are pseudoalgebras of this monad, but this time, every pseudoalgebra is of this form. Indeed, considering the long history of (co)completion theory of categories (see [14, 18] for early contributions), one should view the monad of small presheaves as the “free small-cocompletion monad”. The fact that $${\mathsf {Diag}}$$ admits cocomplete categories as algebras is then to be thought of as an instance of the “restriction of scalars” construction, where algebras of a monad can be pulled back along a morphism of monads, see Appendix A.3.

It is known that small presheaves form a pseudomonad [6]. However, we did not find an explicit construction in the literature, so we give one in the present section. Compared to the pseudomonad of Sect. 2, this one is weaker: the underlying pseudofunctor is not a strict 2-functor. A short review of the relevant basic definitions can be found in Appendix A. The fact that $${{\,\mathrm{Im}\,}}$$ defines a morphism of pseudomonads (Sect. 4.6) seems to be new.

### Definition 4.1

A presheaf is called small if it is (naturally isomorphic to) the image presheaf of a small diagram.

Denote by $${\mathsf {PC}}$$ the full subcategory of $$[{\mathsf {C}}^\mathrm {op},{\mathsf {Set}}]$$ whose objects are small presheaves.

The image presheaf of a (small) diagram is by definition a small presheaf, so that the functor $${{\,\mathrm{Im}\,}}:{\mathsf {Diag(C)}}\rightarrow [{\mathsf {C}}^\mathrm {op},{\mathsf {Set}}]$$ actually lands in $${\mathsf {PC}}$$. We denote the resulting functor $${\mathsf {Diag(C)}}\rightarrow {\mathsf {PC}}$$ again by $${{\,\mathrm{Im}\,}}$$. This will not cause confusion, since from now on we will only consider small presheaves.

Despite the slightly new terminology, this is a known concept, see for example [6]. We recall the following facts.

• A presheaf is small if and only if it can be written as a small colimit of representables [6, Section 2]. Therefore we can think of small presheaves as of forming the free small cocompletion of a category.

• The category $${\mathsf {PC}}$$ of small presheaves on a locally small category $${\mathsf {C}}$$ is itself locally small. This allows us to avoid several size issues when talking about the free cocompletion.

Notice also the following fact.

### Remark 4.2

Let $${\mathsf {C}}$$ be a locally small category, and let $$P:{\mathsf {C}}^\mathrm {op}\rightarrow {\mathsf {Set}}$$ be a small presheaf. Then we know (Proposition 3.7) that there exist a small category $${\mathsf {S}}$$ and a confinal functor $${\tilde{F}}:{\mathsf {S}}\rightarrow \int \!^o P$$. By Lemma 3.8, we can assume that $${\tilde{F}}$$ is fully faithful, or equivalently that it is the inclusion of a full subcategory.

For later use in this section, we recall the following known statement, sometimes called the co-Yoneda lemma (see [15, Section 3.10], as well as [19, Section 2.2]).Footnote 3

### Proposition 4.3

Let $${\mathsf {C}}$$ be a category, and let $$H:{\mathsf {C}}\rightarrow {\mathsf {Set}}$$ be a functor. There is an isomorphism

\begin{aligned} H(C) \;\cong \; \int ^{C'\in {\mathsf {C}}} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C',C) \times H(C') , \end{aligned}

for each object C of $${\mathsf {C}}$$ and natural in C, given by mapping each element $$x\in H(C)$$ to the equivalence class in the coend above the ordered pair $$(\mathrm {id}_C, x)\in {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C,C) \times H(C)$$.

### 4.2 The Pseudofunctor

Given locally small categories $${\mathsf {C}}$$ and $${\mathsf {D}}$$ and a functor $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$, we would like to find an assignment $${\mathsf {PC}}\rightarrow {\mathsf {PD}}$$, which maps small presheaves to small presheaves.

### Definition 4.4

Let $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ be a functor between locally small categories, and let P be a small presheaf on $${\mathsf {C}}$$. The pushforward of P along F is the presheaf on $${\mathsf {D}}$$ given by the following left Kan extension.

We denote the resulting presheaf by $$F_\sharp P$$.

Equivalently, $$F_\sharp P$$ is given by the free colimit of F, weighted by P. By the universal property of (weighted) colimits, it is therefore functorial in F. Note that this definition specifies $$F_\sharp P$$ only up to isomorphism. As usual, the choice of a particular object within its isomorphism class is de facto irrelevant.

Recall the following fact, which says that Kan extension diagrams can be pasted vertically. While the statement is folklore and a consequence of the simple fact that universal arrows [21] compose in an obvious sense, we provide a proof because the explicit isomorphism given in the proof will be of use later.

### Proposition 4.5

Let $${\mathsf {A}}$$, $${\mathsf {B}}$$, $${\mathsf {C}}$$ and $${\mathsf {D}}$$ be categories, and let $$F:{\mathsf {A}}\rightarrow {\mathsf {B}}$$, $$G:{\mathsf {B}}\rightarrow {\mathsf {C}}$$, $$H:{\mathsf {A}}\rightarrow {\mathsf {D}}$$ be functors. The left Kan extensions $${\mathrm {Lan}}_{G}{({\mathrm {Lan}}_{F}{H})}$$ and $${\mathrm {Lan}}_{G\circ F}{H}$$ are naturally isomorphic.

### Proof

By the universal property of $${\mathrm {Lan}}_{F}{H}$$, the natural transformation $$\lambda _{G\circ F}$$ on the right of (4.1) factors uniquely through $$\lambda _F$$, i.e. there exists a unique 2-cell $$\nu :{\mathrm {Lan}}_{F}{H}\Rightarrow {\mathrm {Lan}}_{G\circ F}{H}\circ G$$ such that the following 2-cells are equal.

Moreover, by the universal property of $${\mathrm {Lan}}_{G}{({\mathrm {Lan}}_{F}{H})}$$, the natural transformation $$\nu$$ factors uniquely through $$\lambda _G$$, meaning that there exists a unique natural transformation $$\kappa :{\mathrm {Lan}}_{G}{({\mathrm {Lan}}_{F}{H})}\Rightarrow {\mathrm {Lan}}_{G\circ F}{H}$$ such that the following 2-cells are equal,

where the unlabeled arrow (for reasons of space) denotes $${\mathrm {Lan}}_{G}{({\mathrm {Lan}}_{F}{H})}$$. We now show that $$\kappa$$ is an isomorphism, by providing an inverse. By the universal property of $${\mathrm {Lan}}_{G\circ F}{H}$$, the composite natural transformation on the left of (4.1) factors uniquely through $$\lambda _{G\circ F}$$, meaning that there exists a unique natural transformation $$\delta :{\mathrm {Lan}}_{G\circ F}{H} \Rightarrow {\mathrm {Lan}}_{G}{({\mathrm {Lan}}_{F}{H})}$$ such that the following 2-cells are equal.

where this time the unlabeled arrow denotes $${\mathrm {Lan}}_{G\circ F}{H}$$. By the universal properties of the respective Kan extensions, we then have that $$\kappa \circ \delta$$ has to be the identity natural transformation at $${\mathrm {Lan}}_{G\circ F}{H}$$, and $$\delta \circ \kappa$$ has to be the identity natural transformation at $${\mathrm {Lan}}_{G}{({\mathrm {Lan}}_{F}{H})}$$. $$\square$$

### Corollary 4.6

Pushforwards of small presheaves exist, are given by pointwise left Kan extensions, and are small.

### Remark 4.7

Since we are dealing with pointwise Kan extensions, we can also express this vertical pasting law in terms of coends, where it is an instance of the co-Yoneda lemma (Proposition 4.3). In particular, let $${\mathsf {A}}$$ and $${\mathsf {B}}$$ be locally small categories, let $$F:{\mathsf {A}}\rightarrow {\mathsf {B}}$$ be a functor, and let $$P:{\mathsf {A}}^\mathrm {op}\rightarrow {\mathsf {Set}}$$ be a small presheaf. Then

\begin{aligned} F_\sharp P (B) \cong \int ^{A\in {\mathsf {A}}} P(A) \times {{\,\mathrm{Hom}\,}}_{\mathsf {B}}(B,FA) . \end{aligned}

Let moreover $${\mathsf {C}}$$ be locally small, and $$G:{\mathsf {B}}\rightarrow {\mathsf {C}}$$ be a functor. Then

\begin{aligned} G_\sharp F_\sharp P (C)&\cong \int ^{A\in {\mathsf {A}}}\int ^{B\in {\mathsf {B}}} P(A) \times {{\,\mathrm{Hom}\,}}_{\mathsf {B}}(B,FA) \times {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C,GB) \\&\cong \int ^{A\in {\mathsf {A}}} P(A) \times {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C,GFA) \\&\cong (G\circ F)_\sharp P (C) , \end{aligned}

where the middle isomorphism, which in the proof Proposition 4.5 was denoted by $$\kappa$$, is given by the co-Yoneda lemma.

Now, given $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$, we have a (chosen) mapping $$F_\sharp :{\mathsf {PC}}\rightarrow {\mathsf {PD}}$$. For $${\mathsf {P}}$$ to be a pseudofunctor, we first of all need $$F_\sharp$$ to be a functor. To this end, let $$\alpha :P\rightarrow Q$$ be a natural transformation between small presheaves on $${\mathsf {C}}$$. By the universal property of $$F_\sharp P$$ as a Kan extension, there is a unique 2-cell $$F_\sharp P\Rightarrow F_\sharp Q$$, which we denote by $$F_\sharp \alpha$$, which makes the following 2-cells equal.

This makes $$F_\sharp$$ a functor $${\mathsf {PC}}\rightarrow {\mathsf {PD}}$$, where functoriality holds by uniqueness of the cell $$F_\sharp \alpha$$. Uniqueness of such cell holds once a choice of $$F_\sharp$$ has been made. (One can obtain this 2-cell also using the pointwise characterization of $$F_\sharp$$ as a coend.)

#### 4.2.1 Unitor and Compositor

The left Kan extension of $$P\in {\mathsf {PC}}$$ along the identity functor $$\mathrm {id}:{\mathsf {C}}\rightarrow {\mathsf {C}}$$ is naturally isomorphic to P itself, and this isomorphism is natural in P as well. In other words, $$\mathrm {id}_\sharp : {\mathsf {PC}}\rightarrow {\mathsf {PC}}$$ is naturally isomorphic to $$\mathrm {id}:{\mathsf {PC}}\rightarrow {\mathsf {PC}}$$. Since we are free to choose $$\mathrm {id}_\sharp P$$ within its isomorphism class, we can in particular pick $$\mathrm {id}_\sharp P=P$$, so that the unitor of our pseudofunctor is the identity (one speaks of a normal pseudofunctor).

With composition, the matters are not so simple. By Proposition 4.5, or by Remark 4.7, we know that Kan extensions preserve compositions up to a specified natural isomorphism, which we had denoted by $$\kappa$$. In general we cannot assume that $$\kappa$$ is the identity, we cannot make that choice consistently across the whole category. However, we can show that $$\kappa$$ satisfies all the properties of a compositor, and so it makes $${\mathsf {P}}$$ pseudofunctorial.

As in Remark 4.7, let $${\mathsf {A}}$$, $${\mathsf {B}}$$ and $${\mathsf {C}}$$ be locally small categories, and let $$F:{\mathsf {A}}\rightarrow {\mathsf {B}}$$ and $$G:{\mathsf {B}}\rightarrow {\mathsf {C}}$$ be functors. Let moreover P be a small presheaf on $${\mathsf {A}}$$. The isomorphism $$\kappa : G_\sharp (F_\sharp P) \rightarrow (G\circ F)_\sharp P$$ of $${\mathsf {PC}}$$ given by the co-Yoneda lemma, as in Remark 4.7, is (strictly) natural in P, in F, and in G, by the universal property of coends.

In order to have pseudofunctoriality it remains to be shown that the compositor $$\kappa$$ is associative and unital. Unitality is guaranteed by our choice of unitor (identities), we now prove associativity.

### Proposition 4.8

The following “associativity” diagram commutes for all locally small categories $${\mathsf {A}}$$, $${\mathsf {B}}$$, $${\mathsf {C}}$$ and $${\mathsf {D}}$$ and functors $$F:{\mathsf {A}}\rightarrow {\mathsf {B}}$$, $$G:{\mathsf {B}}\rightarrow {\mathsf {C}}$$ and $$H:{\mathsf {C}}\rightarrow {\mathsf {D}}$$.

One could again invoke the co-Yoneda lemma, but it may be instructive to give a proof by explicitly pasting Kan extensions vertically. For simplicity, we equivalently prove the statement in terms of the inverse $$\kappa ^{-1}$$.

### Proof

Let P be a small presheaf on $${\mathsf {A}}$$. By iterating (4.2), both composite cells

are equal to the following composition.

By the universal property of $$(H\circ G\circ F)_\sharp P$$ as a Kan extension, then, the two composite 2-cells $$(H\circ G\circ F)_\sharp P\Rightarrow H_\sharp G_\sharp F_\sharp P$$ are equal. $$\square$$

This proves that $${\mathsf {P}}$$ is a pseudofunctor $${\mathsf {CAT}}\rightarrow {\mathsf {CAT}}$$.

#### 4.2.2 Naturality of the Image

Consider a functor $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ between locally small categories, and let $$D:{\mathsf {I}}\rightarrow {\mathsf {C}}$$ be a (small) diagram in $${\mathsf {C}}$$. One can either form the image presheaf of D and then push it forward along F, or one can first form the diagram $$F\circ D:{\mathsf {I}}\rightarrow {\mathsf {D}}$$, and then take the image presheaf. As we will see shortly, the result is the same, up to coherent isomorphism.

### Proposition 4.9

The functors $${{\,\mathrm{Im}\,}}:{\mathsf {Diag(C)}}\rightarrow {\mathsf {PC}}$$ form a pseudonatural transformation $${\mathsf {Diag}}\Rightarrow {\mathsf {P}}$$.

### Proof

First of all, for each functor $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ of $${\mathsf {CAT}}$$ we need a natural isomorphism in the following form.

Let now $$D:{\mathsf {I}}\rightarrow {\mathsf {C}}$$ be a small diagram. Using the definition of image in terms of Kan extensions, the two routes of Equation (4.4) are given by the following Kan extensions, respectively,

which we know are naturally isomorphic via the map $$\kappa$$ of Proposition 4.5 and Sect. 4.2.1, which is also natural both in D and in F. The unit and multiplication conditions correspond to the unitality and associativity condition for $$\kappa$$. $$\square$$

### 4.3 Unit and Multiplication

#### 4.3.1 The Unit: the Yoneda Embedding

Let $${\mathsf {C}}$$ be a locally small category. By Proposition 3.12, the Yoneda embedding $$y:{\mathsf {C}}\rightarrow [{\mathsf {C}}^\mathrm {op},{\mathsf {Set}}]$$ lands in $${\mathsf {PC}}$$: representable presheaves are small. We denote again by $$\eta :{\mathsf {C}}\rightarrow {\mathsf {PC}}$$ the functor induced by the Yoneda embedding $$C\mapsto {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(-,C)$$. When this causes confusion because both monads $${\mathsf {Diag}}$$ and $${\mathsf {P}}$$ are present, we will denote the two units by $$\eta ^{{\mathsf {Diag}}}$$ and $$\eta ^{\mathsf {P}}$$.

### Proposition 4.10

The unit $$\eta :{\mathsf {C}}\rightarrow {\mathsf {PC}}$$ is canonically pseudonatural in $${\mathsf {C}}$$.

### Proof

Let $${\mathsf {C}}$$ and $${\mathsf {D}}$$ be locally small, and let $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ be a functor. We have to prove that the following diagram commutes up to coherent isomorphism.

In practice, using the coend description of $$F_\sharp$$ (via Kan extensions), this amounts to a natural isomorphism of presheaves,

\begin{aligned} {{\,\mathrm{Hom}\,}}_{\mathsf {D}}(-, FC) \;\cong \; \int ^{C'\in {\mathsf {C}}} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C',C) \times {{\,\mathrm{Hom}\,}}_{\mathsf {D}}(-, FC') \end{aligned}

which is given by the co-Yoneda lemma (Proposition 4.3), by setting $$H(C)={{\,\mathrm{Hom}\,}}_{D}(-, FC)$$. In particular, the isomorphism is given pointwise, for each object D of $${\mathsf {D}}$$ by mapping $$f:D\rightarrow FC$$ to the equivalence class of $$(\mathrm {id}_C,f)\in {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C,C)\times {{\,\mathrm{Hom}\,}}_{\mathsf {D}}(D,FC)$$. It can be checked that, defined this way, the isomorphism respects identities and composition. $$\square$$

#### 4.3.2 The Multiplication: Free Weighted Colimits

Let’s now turn to the multiplication of the monad. One could define it as the left-adjoint to the unit, since the monad turns out to be lax idempotent (a.k.a. Kock-Zöberlein). Here, instead, we define the multiplication directly.

### Definition 4.11

Let $${\mathsf {C}}$$ be locally small, and let $$\Phi$$ be an object of $${\mathsf {PPC}}$$ (i.e. a small presheaf on small presheaves). We define $$\mu (\Phi )$$ as the object of $${\mathsf {PC}}$$ specified, up to isomorphism, by the following “free weighted colimit”,

\begin{aligned} \mu (\Phi )(C) {:}{=}\int ^{P\in {\mathsf {PC}}} \Phi (P) \times P(C) \end{aligned}

for each object C of $${\mathsf {C}}$$.

### Remark 4.12

By functoriality of colimits, $$\mu (\Phi )$$ is a presheaf $${\mathsf {C}}^\mathrm {op}\rightarrow {\mathsf {Set}}$$. Since PC is in general not small, let’s show why the coend exists. Since $$\Phi$$ is small, there exists a small diagram $$D:{\mathsf {I}}\rightarrow {\mathsf {PC}}$$ such that $${{\,\mathrm{Im}\,}}(D)\cong \Phi$$. In other words,

\begin{aligned} \mu (\Phi )(C) \;\cong \; \int ^{P\in {\mathsf {PC}}} \int ^{I\in {\mathsf {I}}} {{\,\mathrm{Hom}\,}}_{\mathsf {PC}} (P, DI) \times P(C) , \end{aligned}

which by Fubini and by the co-Yoneda lemma (Proposition 4.3) is naturally isomorphic to

\begin{aligned} \int ^{I\in {\mathsf {I}}} DI(C). \end{aligned}

This coend exists, since it is a coend in $${\mathsf {Set}}$$ indexed by a small category, and it gives a small presheaf (since $${\mathsf {PC}}$$ is cocomplete).

Therefore $$\mu$$ is a functor $${\mathsf {PPC}}\rightarrow {\mathsf {PC}}$$ (as usual, defined up to natural isomorphism).

### Proposition 4.13

The functor $$\mu :{\mathsf {PPC}}\rightarrow {\mathsf {PC}}$$ is pseudonatural in the category $${\mathsf {C}}$$.

### Proof

We have to prove that the following diagram commutes up to coherent natural isomorphism.

Given $$\Phi \in PPC$$, the top right path gives the presheaf

\begin{aligned} \int ^{C\in {\mathsf {C}}}\int ^{P\in {\mathsf {PC}}}{{\,\mathrm{Hom}\,}}_{\mathsf {D}}(-, FC) \times \Phi (P) \times P(C) , \end{aligned}

which (by Fubini) is isomorphic to

\begin{aligned} \int ^{P\in {\mathsf {PC}}} \Phi (P) \times F_\sharp P . \end{aligned}
(4.5)

The bottom left path gives the presheaf

\begin{aligned} \int ^{Q\in {\mathsf {PD}}} \int ^{P\in {\mathsf {PC}}} {{\,\mathrm{Hom}\,}}_{\mathsf {PD}}(Q, F_\sharp P) \times \Phi (P) \times Q , \end{aligned}

which by the co-Yoneda lemma (Proposition 4.3) is isomorphic to (4.5). One can check that this isomorphism respects identities and composition. $$\square$$

### 4.4 Unitors, Associators, Coherence

The left unitor

is given as follows. Starting with a presheaf P in $${\mathsf {PC}}$$, we can apply the unit to get the following representable presheaf on $${\mathsf {PC}}$$,

\begin{aligned} {{\,\mathrm{Hom}\,}}_{{\mathsf {PC}}}(-, P) , \end{aligned}

and then, applying the multiplication, we get the following presheaf,

\begin{aligned} \int ^{Q\in {\mathsf {PC}}} {{\,\mathrm{Hom}\,}}_{{\mathsf {PC}}}(Q,P) \times Q(-) \;\cong \; P , \end{aligned}

where the last isomorphism, filling the diagram above, is given by the co-Yoneda lemma (Proposition 4.3), and defines the left unitor $$\ell$$. Naturality in P follows from naturality of the co-Yoneda isomorphism. The modification property for $$\ell$$ against functors $$F:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ is again an instance of the coherence of colimits (uniqueness of the isomorphism), just as in Sect. 2.5.3 and Proposition 4.8, this time for weighted colimits.

The right unitor

is given as follows. Again start with a presheaf P in $${\mathsf {PC}}$$. This time we apply the map $$\eta _\sharp$$, to get the following presheaf.

\begin{aligned} Q\mapsto \int ^{C\in {\mathsf {C}}} PC \times {{\,\mathrm{Hom}\,}}_{{\mathsf {PC}}}(Q, \eta _{\mathsf {C}}(C)) = \int ^{C\in {\mathsf {C}}} PC \times {{\,\mathrm{Hom}\,}}_{{\mathsf {PC}}}(Q, {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(-,C)) \end{aligned}

(Note that we cannot apply the Yoneda lemma to simplify the expression on the right.) We now apply the multiplication again, to obtain

\begin{aligned} X&\mapsto \int ^{Q\in {\mathsf {PC}}} \int ^{C\in {\mathsf {C}}} PC \times {{\,\mathrm{Hom}\,}}_{{\mathsf {PC}}}(Q, {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(-,C)) \times Q(X) \\&\cong \int ^{C\in {\mathsf {C}}} P(C) \times {{\,\mathrm{Hom}\,}}_{C}(X,C) \\&\cong P(X) , \end{aligned}

where both isomorphisms are given again by the co-Yoneda lemma (Proposition 4.3). This gives the right unitor r, and the reason why it’s a modification is analogous to the one for the left unitor $$\ell$$.

The associator

is again an instance of the co-Yoneda lemma (Proposition 4.3). Namely, given $$\Phi \in {\mathsf {PPPC}}$$, the top-right path of the diagram gives the following presheaf

\begin{aligned} C \mapsto \int ^{P\in {\mathsf {PC}}} \int ^{\Psi \in {\mathsf {PPC}}} P(C) \times \Phi (\Psi ) \times {{\,\mathrm{Hom}\,}}_{{\mathsf {PC}}}\left( P , \int ^{Q\in PC} \Psi (Q) \times Q(-) \right) \end{aligned}

while the bottom-left path gives the following,

\begin{aligned} C \mapsto \int ^{\Psi \in {\mathsf {PPC}}} \int ^{Q\in PC} \Phi (\Psi ) \times \Phi (Q) \times Q(C) \end{aligned}

and the two differ by one application of the co-Yoneda lemma (over P). This gives the associator a, which is a modification for reasons analogous to the above.

Again, the higher coherence conditions hold by the uniqueness of isomorphisms given by the universal property, as in Sect. 2.5.3.

### 4.5 Algebras

It is well-known that the pseudoalgebras of the pseudomonad $${\mathsf {P}}$$ are cocomplete categories with a choice of (weighted) colimit, and pseudomorphisms of pseudoalgebras are cocontinuous functors [6]. Differently from the case of $${\mathsf {Diag}}$$, this is a complete characterization. Let’s see in detail how the structure maps look.

Given a small-cocomplete, locally small category $${\mathsf {C}}$$, let $$e:{\mathsf {PC}}\rightarrow {\mathsf {C}}$$ be a choice of weighted colimits, that is,

\begin{aligned} e(P) \;\cong \; \int ^{X\in {\mathsf {C}}} P(X) \otimes X , \end{aligned}
(4.6)

where $$\otimes$$ denotes the copower (also known as tensor, see for example [15, Section 3.7]).

The copower satisfies a (more general) version of the “co-Yoneda lemma” of Proposition 4.3, as follows. See again [15, Section 3.10] for more details.

### Proposition 4.14

Let $${\mathsf {C}}$$ be a category, let $${\mathsf {D}}$$ be a cocomplete category, and let $$H:{\mathsf {C}}\rightarrow {\mathsf {D}}$$ be a functor. There is an isomorphism

\begin{aligned} H(C) \;\cong \; \int ^{C'\in {\mathsf {C}}} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C',C) \otimes H(C') , \end{aligned}

for each object C of $${\mathsf {C}}$$ and natural in C, given by selecting the component of $$\mathrm {id}_C\in {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(C,C)$$ in the copower.

A similar argument as Remark 4.12 shows then that the coend in (4.6) exists. The action of e on morphisms is the one given by the universal property, as usual.

The unitor and multiplicator of the algebras are given as follows. First of all, the unitor

is the canonical isomorphism given by the general co-Yoneda lemma (Proposition 4.14),

\begin{aligned} \int ^{X\in {\mathsf {C}}} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(X,C) \otimes X \;\cong \; X . \end{aligned}

for all $$C\in {\mathsf {C}}$$.

The multiplicator

is also given by the generalized co-Yoneda lemma, as follows,

\begin{aligned}&\;\int ^{Y\in {\mathsf {C}}} \int ^{P\in {\mathsf {PC}}} \Phi (P) \times {{\,\mathrm{Hom}\,}}_{\mathsf {C}}\left( Y, \int ^{X\in C} P(X)\otimes X \right) \otimes Y \\&\cong \; \int ^{P\in {\mathsf {PC}}} \int ^{X\in {\mathsf {C}}} \Phi (P) \times P(X) \otimes X \end{aligned}

for all $$\Phi \in {\mathsf {PPC}}$$. This can be seen as a “generalized Fubini” for coends or weighted colimits, analogous to Lemma 2.10.

Again, the coherence conditions can be seen as a matter of uniqueness of the isomorphism by the universal property of weighted colimits.

### 4.6 The Image is a Morphism of Monads

Here we want to show that the image is a (pseudo)morphism of (pseudo)monads, following Definition A.2. The unit modification u is given by the isomorphism of Proposition 3.12. Again, the fact that this gives a modification comes from the universal property.

The multiplication modification m is in the following form,

where $${{\,\mathrm{Im}\,}}{{\,\mathrm{Im}\,}}$$ is shorthand for the following composite.

(Note that, since the interchange law of pseudonatural transformations holds only up to natural isomorphism, a priori horizontal composition is not uniquely defined, as in a weak bicategory. The choice we make, which will be consistent throughout the document, is motivated by later convenience.)

Explicitly, m is given as follows. Let $$D:{\mathsf {J}}\rightarrow {\mathsf {Diag(C)}}$$ be the following diagram of diagrams.

Then, for every $$C\in {\mathsf {C}}$$, writing images and $$\mu$$ in terms of coends, the two paths of diagram (4.7) are the following objects,

\begin{aligned} \int ^{P\in {\mathsf {PC}}} \int ^{J\in {\mathsf {J}}} {{\,\mathrm{Hom}\,}}_{PC}\left( P, \int ^{K\in D_0J} {{\,\mathrm{Hom}\,}}_{\mathsf {C}} (-, D_1J(K)) \right) \times P(C) \end{aligned}

and

\begin{aligned} \int ^{J\in {\mathsf {J}}} \int ^{K\in D_0(J)} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(X, D_1J(K)) \end{aligned}

and they are again isomorphic by the co-Yoneda lemma (Proposition 4.3), over P. This isomorphism is what we take as the multiplicator m. Again, the fact that it forms a modification follows from uniqueness, and so do the higher coherence conditions of Definition A.2.

#### 4.6.1 The Pullback Functor of Algebras

In algebra, given a ring morphism $$f:R\rightarrow R'$$, every $$R'$$-module is canonically an R-module too, via the map f, and morphisms of $$R'$$-modules are morphisms of R-modules too. The resulting “pullback” functor between the categories of $$R'$$-modules and R-modules is known as the “restriction of scalars” [3, Chapter II], or “Weil restriction” in algebraic geometry [29, Section 1.3]. Not every R-module arises this way if f is not an isomorphism (for example, R itself, seen as an R-module, does not).

More generally, given a morphism of monads $$\lambda : T\rightarrow T'$$, every $$T'$$-algebra is canonically a T-algebra via $$\lambda$$, and morphisms of $$T'$$-algebras are automatically morphisms of T-algebras. This is well known (see, for example, [1, Theorem 3 in Section 3.6]), and the pullback functor is again called “restriction of scalars”, after its instance for the case of rings. Again, not every T-algebra arises this way (if $$\lambda$$ is not an isomorphism), for example, the free algebra $$(TX,\mu )$$, where X is any object, in general does not.

With $${{\,\mathrm{Im}\,}}:{\mathsf {Diag}}\rightarrow {\mathsf {P}}$$ we are witnessing an instance of this phenomenon in higher dimensions: every $${\mathsf {P}}$$-algebra, i.e. a cocomplete category, is also a $${\mathsf {Diag}}$$-algebra, via the map $${{\,\mathrm{Im}\,}}$$, which is a morphism of monads. As we have seen in Sect. 2.5.4, not every $${\mathsf {Diag}}$$-algebra arises this way, for example, in general free algebras do not. The 2-dimensional restriction-of-scalars theorem is given in Appendix A.3 as Theorem A.7.

To see that cocomplete categories as $${\mathsf {Diag}}$$-algebras indeed arise in this way, note that the following diagram commutes up to natural isomorphism for each cocomplete category $${\mathsf {C}}$$ (and any choices of colimits c and coends e).

Indeed, the fact that this diagram commutes is, for the last time, an instance of the general co-Yoneda lemma (Proposition 4.14): given $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$,

\begin{aligned} \int ^{X\in {\mathsf {C}}} \int ^{J\in {\mathsf {J}}} {{\,\mathrm{Hom}\,}}_{\mathsf {C}}(X, DJ) \otimes X \;\cong \;\int ^{J} DJ, \end{aligned}

which is indeed just the colimit of D, given up to isomorphism by c. (Compare this with the analogous “free” case of Remark 4.12.)

## 5 Partial Colimits

We review here the basic ideas of partial evaluations, which are a categorical formalization of the idea of “computing only pieces of an operation”. We will apply this to the operation of colimit encoded by the monads $${\mathsf {Diag}}$$ and $${\mathsf {P}}$$. We will then show that, for both monads, we have a correspondence between Kan extensions and partial evaluations of colimits (Theorems 5.5, 5.6 and 5.10). Intuitively, these results may be interpreted as the fact that “a left Kan extension is a partially computed colimit”. While the statement for the $${\mathsf {Diag}}$$ monad is rather straightforward, the corresponding statement for $${\mathsf {P}}$$ requires quite more work.

### 5.1 Partial Evaluations

Partial evaluations were introduced in [25, Chapter 4] for the case of probability monads, and defined for the general case in [9]. A detailed study of their compositional structure (in general they don’t form a category) is given in [5].

### Definition 5.1

Let $$(T,\mu ,\nu )$$ be a monad on $${\mathsf {Set}}$$, and let (Ae) be a T-algebra. Consider the parallel pair of maps

of which $$e:TA\rightarrow A$$ is the coequalizer. Given elements $$p,q\in TA$$, a partial evaluation from p to q is an element $$r\in TTA$$ such that $$\mu _A(r)=p$$ and $$Te(r)=q$$.

If such a partial evaluation exists, we also say that q is a partial evaluation of p and that p can be partially evaluated to q.

### Example 5.2

Let $$(T,\mu ,\nu )$$ be the free commutative monoid monad. Given a set X, the elements of TX can be thought of as formal sums of elements of X, for example in the form $$x+y+z$$ with $$x,y,z\in X$$. Natural numbers with addition form a commutative monoid, and so $${\mathbb {N}}$$ forms a T-algebra. The formal sum

\begin{aligned} 3 + 4 + 5 + 6 , \end{aligned}

seen as an element of $$T{\mathbb {N}}$$, can be partially evaluated to the formal sum

\begin{aligned} 7 + 11 \end{aligned}

via the element $$[3+4]+[5+6]\in TT{\mathbb {N}}$$. The interpretation is that “we haven’t summed everything together, but only some of the terms”.

An essential property of partial evaluations is that “they don’t change the total result”. This is reflected by the multiplication diagram of the algebra,

which can be seen as saying that evaluating (via the map e) two formal expressions which differ by a partial evaluation, the (total) result of the evaluation is the same. In the example above, both formal sums evaluate to 18.

Let’s also remark that “total evaluations are a special case of partial evaluations”. We refer the interested reader to [9] and [5] for more details and examples. In our case we need a higher-dimensional, weaker analogue of the concept, since we are dealing with pseudomonads on $${\mathsf {CAT}}$$ rather than monads on $${\mathsf {Set}}$$.

### Definition 5.3

Let $$(T,\mu ,\nu )$$ be a pseudomonad on $${\mathsf {CAT}}$$, and let $$({\mathsf {A}},e)$$ be a T-pseudoalgebra. Given objects $$P,Q\in {\mathsf {A}}$$, a partial evaluation from P to Q is an object R of TTA such that $$\mu _{\mathsf {A}}(R)\cong P$$ and $$Te(R)\cong Q$$.

If such a partial evaluation exists, we also say that Q is a partial evaluation of P and that P can be partially evaluated to Q.

### 5.2 Partial Evaluations of Diagrams

We now instance Definition 5.3 for the case of the monad $${\mathsf {Diag}}$$, keeping in mind the following multiplication square, which commutes up to isomorphism.

### Definition 5.4

Let $${\mathsf {C}}$$ be a cocomplete category, and let $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and $$D':{\mathsf {K}}\rightarrow {\mathsf {C}}$$ be small diagrams. A partial evaluation from D to $$D'$$ for the monad $${\mathsf {Diag}}$$ is an object E of $${\mathsf {Diag(Diag(C))}}$$ such that $$\mu (E)\cong D$$ and $$c_*E\cong D'$$. If such an object exists, we also say that $$D'$$ is a partial colimit of D for the monad $${\mathsf {Diag}}$$.

As we see shortly, we now establish an equivalence between partial evaluations of diagrams and left Kan extensions along split opfibrations. There are now two ways of talking about the correspondence. One, which is probably the easiest to state, is as an equivalence of properties.

### Theorem 5.5

Let $${\mathsf {C}}$$ be a cocomplete category, and let $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and $$D':{\mathsf {K}}\rightarrow {\mathsf {C}}$$ be small diagrams. Then $$D'$$ is a partial colimit of D (for the monad $${\mathsf {Diag}}$$) if and only if $$D'$$ can be written as the (pointwise) left Kan extension of D along a split opfibration.

Instead of an equivalence of properties we can also write the result as an equivalence of structures, as follows.

### Theorem 5.6

Let $${\mathsf {C}}$$ be a cocomplete category, and let $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and $$D':{\mathsf {K}}\rightarrow {\mathsf {C}}$$ be small diagrams. There is a bijection between partial evaluations of colimits from D to $$D'$$ and split opfibrations $$F:{\mathsf {J}}\rightarrow {\mathsf {K}}$$ exhibiting $$D'$$ as a (pointwise) left Kan extension of D along F.

In particular, if $${\mathsf {K}}$$ is the terminal category $${\mathsf {1}}$$, the Kan extension is an ordinary colimit. This is an instance of the fact that “total evaluations are a special case of partial evaluations”.

We will prove the latter statement, Theorem 5.6, since it clearly implies the former. We will use the following property of Kan extensions along opfibrations, which can be interpreted as “fiberwise colimits”. The following two statements are well known (see for example the nLab page on Kan extensions).

### Proposition 5.7

Let $$F:{\mathsf {E}}\rightarrow {\mathsf {B}}$$ be an opfibration between small categories. For each object E of $${\mathsf {E}}$$, the inclusion of the fiber $$F^{-1}(E)$$ into the comma category F/E has a left adjoint. Hence, it is a confinal functor.

### Corollary 5.8

Let $$F:{\mathsf {E}}\rightarrow {\mathsf {B}}$$ be an opfibration between small categories, and let $${\mathsf {C}}$$ be cocomplete and locally small. The (pointwise) left Kan extension of a functor $$G:{\mathsf {E}}\rightarrow {\mathsf {C}}$$ along F at B can then be computed by a colimit labeled by the fiber of F at B:

\begin{aligned} {\mathrm {Lan}}_{F}{G}(B) \;\cong \; \mathop {{{\,\mathrm{\mathrm{colim}}\,}}}\limits _{E\in F^{-1}(B)} G(E) . \end{aligned}

We are now ready to prove the theorem. The crucial point of the theorem is the correspondence between split opfibrations and (strict!) functors into $${\mathsf {Cat}}$$.

### Proof of Theorem 5.6

First of all, suppose that we have a partial evaluation from D to $$D'$$. That is, let $$E=(E_0,E_1)$$ be an object of $${\mathsf {Diag(Diag(C))}}$$ such that $$\mu (E)=D$$ and $$c_*E=D'$$. Note that this implies that $$E_0$$ is necessarily indexed by $${\mathsf {K}}$$ (up to isomorphism), it is a functor $${\mathsf {K}}\rightarrow {\mathsf {Cat}}$$. We can now express $$c_*(E)$$ as the left Kan extension of $$\mu (E)$$ along the Grothendieck fibration $$\pi :\int \!E_0\rightarrow {\mathsf {K}}$$. Indeed, using Corollary 5.8, we have that for each object K of $${\mathsf {K}}$$,

\begin{aligned} {\mathrm {Lan}}_{\pi }{\mu (E)} (K) \;&\cong \; \mathop {{{\,\mathrm{\mathrm{colim}}\,}}}\limits _{(K,X)\in \pi ^{-1}(K)} \mu (E)(K,X) \\ \;&=\; \mathop {{{\,\mathrm{\mathrm{colim}}\,}}}\limits _{X\in E_0K} E_1K(X) \\ \;&\cong \; c_*(E)(K) . \end{aligned}

Conversely, let $$F:{\mathsf {J}}\rightarrow {\mathsf {K}}$$ be a split opfibration and suppose that $$D'$$ is the left Kan extension of D along F.

Let now $$E_0:{\mathsf {K}}\rightarrow {\mathsf {Cat}}\subseteq {\mathsf {CAT}}$$ be the functor associated with the opfibration F. Concretely, this is the functor mapping each object K of $${\mathsf {K}}$$ to its preimage $$F^{-1}(K)$$, and each morphism $$k:K\rightarrow K'$$ to the functor $$F^{-1}(K)\rightarrow F^{-1}(K')$$ given by the opcartesian lifts. Define also, for each object K of $${\mathsf {K}}$$, the functor $$E_1K:E_0K\rightarrow {\mathsf {C}}$$ to be given by

For each morphism $$k:K\rightarrow K'$$, define $$E_1j'$$ to be the 2-cell given by the opcartesian lifts in $${\mathsf {J}}$$, whiskered by D. We have that, by construction, $$\mu (E_0,E_1)=D$$. Moreover, by Corollary 5.8, $$D'=c_*(E_0,E_1)$$. $$\square$$

Note also that, in the hypotheses above, D and $$D'$$ must necessarily have isomorphic colimits, either because “Kan extensions can be stacked vertically” (Proposition 4.5), or because of the multiplication square (5.1). A different but related picture is given in [26, Proposition 2.9].

### 5.3 Partial Evaluations of Presheaves

We now give and prove a similar statement for the monad $${\mathsf {P}}$$. Let’s instance Definition 5.3 for the case of the monad $${\mathsf {P}}$$.

### Definition 5.9

Let $${\mathsf {C}}$$ be a cocomplete category, and let P and Q be small presheaves on $${\mathsf {C}}$$. A partial evaluation from P to Q for the monad $${\mathsf {P}}$$ is a presheaf on presheaves $$\Phi$$ in $${\mathsf {PPC}}$$ such that $$\mu (\Phi )\cong P$$ and $$e_\sharp \Phi \cong Q$$. If such an object exists, we also say that Q is a partial colimit of P for the monad $${\mathsf {P}}$$.

This time we establish a correspondence with Kan extensions along any functor, not just along a split opfibration. Moreover, we only have a weak statement, analogous to Theorem 5.5, an equivalence of properties rather than of structures.

### Theorem 5.10

Let $${\mathsf {C}}$$ be a cocomplete category, and let $$P,Q\in {\mathsf {PC}}$$. The following conditions are equivalent.

1. (a)

There exists a small diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ such that $${{\,\mathrm{Im}\,}}D \cong P$$, and a small category $${\mathsf {K}}$$ with a functor $$F:{\mathsf {J}}\rightarrow {\mathsf {K}}$$ such that $${{\,\mathrm{Im}\,}}({\mathrm {Lan}}_{F}{D})\cong Q$$.

2. (b)

There exists a partial evaluation from P to Q for the monad $${\mathsf {P}}$$, i.e. an object $$\Phi \in {\mathsf {PPC}}$$ such that $$\mu (\Phi )\cong P$$ and $$e_\sharp (\Phi ) \cong Q$$.

In other words, Q is a partial colimit of P if and only if it can be written as the image presheaf of the left Kan extension of a diagram with image presheaf P.

Again, if $${\mathsf {K}}$$ is the terminal category $${\mathsf {1}}$$, the Kan extension is an ordinary colimit (“total evaluations are a special case of partial evaluations”).

The proof of the theorem, which can be considered the main result of this paper, requires more work than the analogous statement for $${\mathsf {Diag}}$$, and will have to use two auxiliary lemmas.

### Lemma 5.11

Let $$F:{\mathsf {J}}\rightarrow {\mathsf {K}}$$ be a functor between small categories. There exist a small category $${\mathsf {H}}$$, a confinal functor $$G:{\mathsf {H}}\rightarrow {\mathsf {J}}$$, and a split opfibration $$\pi :{\mathsf {H}}\rightarrow {\mathsf {K}}$$ such that for every locally small category $${\mathsf {C}}$$ and every diagram $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$, the pointwise left Kan extension of $$D \circ G$$ along $$\pi$$ exists if and only if the one of D along F exists, and in that case the two Kan extensions are naturally isomorphic.

We can depict the situation as follows:

Note that the diagram above does not necessarily commute, nor does any of its two subdiagrams.

### Proof of Lemma 5.11

Given an object K of $${\mathsf {K}}$$, the comma category F/K has

• As objects, pairs (Jk) where J is an object of $${\mathsf {J}}$$ and $$k:FJ\rightarrow K$$ is a morphism of $${\mathsf {K}}$$;

• As morphisms, commutative diagrams in the following form,

where $$j:J\rightarrow J'$$ is a morphism of $${\mathsf {J}}$$.

Now define the functor $$F/-:{\mathsf {K}}\rightarrow {\mathsf {Cat}}$$ as follows.

• To each object K of $${\mathsf {K}}$$ assign the comma category F/K;

• To each morphism $$\ell :K\rightarrow K'$$ of $${\mathsf {K}}$$, assign the functor $$F/K\rightarrow F/K'$$ given by post-composition with $$\ell$$.

Choose now as $${\mathsf {H}}$$ the Grothendieck construction $$\int \!F/-$$, and notice that it is small. Up to isomorphism,

• Its objects are triplets (KJk) where K is an object of $${\mathsf {K}}$$, J is an object of $${\mathsf {J}}$$, and $$k:FJ\rightarrow K$$ is a morphism of $${\mathsf {K}}$$;

• Each morphism $$\ell :K\rightarrow K'$$ of $${\mathsf {K}}$$ defines an “opcartesian” morphism $$\ell _*:(K,J,k:FJ\rightarrow K)\rightarrow (K',J,\ell \circ k: FJ\rightarrow K')$$;

• For each object K of $${\mathsf {K}}$$, a morphism $$j:(J,k:FJ\rightarrow K)\rightarrow (J', k':FJ'\rightarrow K)$$ of F/K (i.e. a morphism $$j:J\rightarrow J'$$ of $${\mathsf {J}}$$ with $$k'\circ Fj= k$$) defines a morphism “in the fiber” $$(K,J,k) \rightarrow (K, J', k')$$, which we denote again by j.

• Any other morphism of $${\mathsf {H}}$$ is a composition of two morphisms in the two forms above.

The forgetful functor $$\pi :{\mathsf {H}}\rightarrow {\mathsf {K}}$$ which maps (KJk) to K is a split opfibration. We can also construct the forgetful functor $$G:{\mathsf {H}}\rightarrow {\mathsf {J}}$$ which maps (KJk) to J. This functor is confinal: indeed, let J be an object of $${\mathsf {J}}$$.

• The category J/G is nonempty: it always contains

• The category J/G is connected: let $$(K',J',k':FJ'\rightarrow K')$$ and $$(K'',J'',k'':FJ''\rightarrow K'')$$ be objects of $${\mathsf {H}}$$, and let $$f:J\rightarrow J'$$ and $$g:J\rightarrow J''$$ be morphisms of $${\mathsf {J}}$$. We can then form the following zigzag in $${\mathsf {H}}$$:

Suppose now the pointwise left Kan extension

exists. We claim that $${\mathrm {Lan}}_{\pi }{D\circ G}\cong {\mathrm {Lan}}_{F}{D}$$. To see this, let K be an object of $${\mathsf {K}}$$. Since $$\pi$$ is an opfibration, by Corollary 5.8 we can write $${\mathrm {Lan}}_{\pi }{(D\circ G)}(K)$$ up to isomorphism as the colimit of the following composite functor.

Recall now that $$H = \int \!F/-$$, so that $$\pi ^{-1}(K)\subseteq {\mathsf {H}}$$ is isomorphic to F/K, and the following diagram commutes,

where U is the forgetful functor mapping $$(J,k:FJ\rightarrow K)$$ to just J. Therefore we can rewrite $${\mathrm {Lan}}_{\pi }{(D\circ G)}(K)$$ up to isomorphism as the colimit of this simpler composition,

which gives the pointwise left Kan extension of D along F. $$\square$$

### Lemma 5.12

Let $${\mathsf {C}}$$ be a locally small category. The functor $${{\,\mathrm{Im}\,}}{{\,\mathrm{Im}\,}}:{\mathsf {Diag(Diag(C))}}\rightarrow {\mathsf {PPC}}$$ is essentially surjective on objects.

Recall that the following diagram commutes only up to natural isomorphism,

and that, by convention, we denoted by $${{\,\mathrm{Im}\,}}{{\,\mathrm{Im}\,}}$$ the top-right path.

### Proof of Lemma 5.12

Since $${{\,\mathrm{Im}\,}}$$ is essentially surjective, it suffices to prove that $${\mathsf {Diag}}{{\,\mathrm{Im}\,}}$$ is as well. In other words, we have to prove that every small diagram of small presheaves can be obtained from a diagram of diagrams (by taking the image presheaf of each subdiagram).

Let $${\mathsf {I}}$$ be a small category, and let $$D:{\mathsf {I}}\rightarrow {\mathsf {PC}}$$ be a diagram. Explicitly, for each object I of $${\mathsf {I}}$$ we have a small presheaf $$DI:{\mathsf {C}}^\mathrm {op}\rightarrow {\mathsf {Set}}$$, and for each morphism of $${\mathsf {I}}$$ we have a morphism of presheaves. We can now take the category of elements of each DI, as described in Sect. 3.1.1. For each I of $${\mathsf {I}}$$ we have a discrete fibration $$\pi _I:\int \!^o DI \rightarrow {\mathsf {C}}$$, and for each morphism $$i:I\rightarrow J$$ of $${\mathsf {I}}$$ we have a commutative triangle as follows.

However, the categories $$\int \!^o DI$$ are large in general, and so they do not form the desired diagram of (small) diagrams yet. We then proceed as follows. Since each presheaf DI is small, for each I of $${\mathsf {I}}$$ there exists (Remark 4.2) a small full subcategory $${\mathsf {S}}_I$$ of $$\int \!^o DI$$, such that the inclusion functor is confinal. Denote by $$F_I:{\mathsf {S}}_I\rightarrow {\mathsf {C}}$$ the composition (or restriction)

By construction, $${{\,\mathrm{Im}\,}}(F_i)\cong DI$$. The assignment $$I\mapsto {\mathsf {S}}_I$$ is not functorial in I: for each morphism $$i:I\rightarrow J$$ of $${\mathsf {I}}$$, we get the following commutative diagram.

However, in principle we cannot lift $$\int \!^o Di$$ to get a commutative square, that is, a priori the restriction of $$\int \!^o Di$$ to $${\mathsf {S}}_I$$ does not necessarily land in $${\mathsf {S}}_J$$. We now extend the $${\mathsf {S}}_I$$, as follows.

Let I be an object of $${\mathsf {I}}$$, and consider the slice category $${\mathsf {I}}/I$$, whose objects are pairs (Hh) where H is an object of $${\mathsf {I}}$$, and $$h:H\rightarrow I$$ is an arrow of $${\mathsf {I}}$$. This category is small, since its set of objects is given by

\begin{aligned} \coprod _{H\in \mathrm {Ob}({\mathsf {I}})} {{\,\mathrm{Hom}\,}}_{\mathsf {I}}(H,I) , \end{aligned}

which is a small union of small sets. Now define $${\mathsf {T}}_I$$ to be the full subcategory of $$\int \!^o DI$$ whose set of objects is given by

That is, an object of $$E_I$$ is in the form $$\int \!^o Dh(C,x)$$ for some object $$(C\in {\mathsf {C}},x\in DH(C))$$ in $${\mathsf {S}}_H$$ and some morphism $$h:H\rightarrow I$$ of $${\mathsf {I}}$$. The category $${\mathsf {T}}_I$$ is small, since its set of objects is a small union of small sets. Moreover, since we can pick h to be the identity $$I\rightarrow I$$, the category $${\mathsf {S}}_I$$ is fully embedded into $${\mathsf {T}}_I$$, i.e. we have a commutative diagram of inclusions

which are all confinal by Lemma 3.8. In particular, if we denote by $$E_I: {\mathsf {T}}_I\rightarrow {\mathsf {C}}$$ the composition (or restriction)

we have again that $${{\,\mathrm{Im}\,}}(E_I)\cong DI$$.

This time, the assignment $$I\mapsto {\mathsf {T}}_I$$ is functorial. To see this, let $$i:I\rightarrow J$$ be a morphism of $${\mathsf {I}}$$, and form the following commutative diagram.

We claim that the restriction of $$\int \!^o Di$$ to the subcategory $${\mathsf {T}}_I$$ lands in $${\mathsf {T}}_J$$. Any object of $${\mathsf {T}}_I$$ is of the form $$\int \!^o Dh(C,x)$$ for some (Cx) in $${\mathsf {S}}_H$$ and some $$h:H\rightarrow I$$ of $${\mathsf {I}}$$. We then have

which lies in $${\mathsf {T}}_J$$ since $$i\circ h:H\rightarrow J$$ belongs to the slice category $${\mathsf {I}}/J$$. We can then complete the diagram to a commutative diagram

The assignment $$I\mapsto {\mathsf {T}}_I$$, $$i\mapsto {\mathsf {T}}_i$$ is a functor $${\mathsf {I}}\rightarrow {\mathsf {Cat}}$$, and the corresponding assignment $$I\mapsto ({\mathsf {T}}_I,E_I:{\mathsf {E}}_{\mathsf {I}}\rightarrow {\mathsf {C}})$$ gives a functor $$E:{\mathsf {I}}\rightarrow {\mathsf {Diag(C)}}$$.

This functor $$E:{\mathsf {I}}\rightarrow {\mathsf {Diag(C)}}$$ is the diagram of diagrams that we want. Indeed, $${\mathsf {Diag}}({{\,\mathrm{Im}\,}})(E)$$ is given by the postcomposition with the image

and we know that for each I of $${\mathsf {I}}$$, $${{\,\mathrm{Im}\,}}(E_I) \cong DI$$. To show that $${\mathsf {Diag}}({{\,\mathrm{Im}\,}})(E)\cong D$$, and hence conclude the proof, we have to show that the isomorphism $${{\,\mathrm{Im}\,}}(E_I) \rightarrow DI$$ is natural in I. So let $$i:I\rightarrow J$$ be a morphism of $${\mathsf {I}}$$. We have to show that the following diagram of $${\mathsf {PC}}$$ commutes,

where the isomorphisms are the ones given in Proposition 3.4. Diagram (5.2) commutes since the vertices are the colimits of the functors $$\eta \circ E_i$$, $$\eta \circ E_J$$, $$\eta \circ \pi _I$$ and $$\eta \circ \pi _J$$ obtained by the following commutative diagram of $${\mathsf {CAT}}$$,

and the induced maps between their colimits are the arrows of (5.2). Since the square in (5.3) commutes, (5.2) commutes too (by uniqueness of the induced map). $$\square$$

We are now finally ready to prove the theorem.

### Proof of Theorem 5.10

Since $${{\,\mathrm{Im}\,}}$$ is a morphism of monads, the following diagram commutes up to natural isomorphism.

In particular, this can be interpreted as “$${{\,\mathrm{Im}\,}}$$, as a morphism of monads, preserves partial evaluations”. With this and the previous lemmas in mind, let’s proceed with the proof.

• (a)$$\Rightarrow$$(b): Consider $$D:{\mathsf {J}}\rightarrow {\mathsf {C}}$$ and $$F:{\mathsf {J}}\rightarrow {\mathsf {K}}$$ as in (a). By Lemma 5.11 there exists a diagram $$D:{\mathsf {H}}\rightarrow {\mathsf {C}}$$ together with a confinal functor $$G:{\mathsf {H}}\rightarrow {\mathsf {J}}$$ and an opfibration $$\pi :{\mathsf {H}}\rightarrow {\mathsf {K}}$$ with $${\mathrm {Lan}}_{\pi }{D\circ G}\cong {\mathrm {Lan}}_{F}{D}$$. Since G is confinal, by Proposition 3.9 we have that $${{\,\mathrm{Im}\,}}(D\circ G) \cong {{\,\mathrm{Im}\,}}D \cong P$$. Now, by Theorem 5.5, there exists a diagram of diagrams $$E\in {\mathsf {Diag(Diag(C))}}$$ such that $$\mu (E)\cong D\circ G$$ and $${\mathsf {Diag}}{{\,\mathrm{\mathrm{colim}}\,}}(E)\cong {\mathrm {Lan}}_{\pi }{D\circ G}$$. Chasing diagram (5.4), we see that $${{\,\mathrm{Im}\,}}{{\,\mathrm{Im}\,}}(E)$$ is the desired partial evaluation between $${{\,\mathrm{Im}\,}}(D\circ G) \cong {{\,\mathrm{Im}\,}}D \cong P$$ and $${{\,\mathrm{Im}\,}}({\mathrm {Lan}}_{\pi }{D\circ G})\cong {{\,\mathrm{Im}\,}}({\mathrm {Lan}}_{F}{D})\cong Q$$.

• (b)$$\Rightarrow$$(a): Let $$\Phi$$ be a partial evaluation from P to Q. By Lemma 5.12, $${{\,\mathrm{Im}\,}}{{\,\mathrm{Im}\,}}$$ is essentially surjective on objects, so that there exists $$E\in {\mathsf {Diag(Diag(C))}}$$ with $${{\,\mathrm{Im}\,}}{{\,\mathrm{Im}\,}}(E)\cong \Phi$$. Chasing diagram (5.4), let $$D=\mu (E)$$ and $$D'={\mathsf {Diag}}{{\,\mathrm{\mathrm{colim}}\,}}(E)$$, so that $${{\,\mathrm{Im}\,}}D \cong P$$ and $${{\,\mathrm{Im}\,}}D'\cong Q$$. By Theorem 5.5, $$D'$$ can be written as the pointwise left Kan extension of D along a split opfibration.

$$\square$$

### 5.4 Comparison with Measure Theory

Coends, in particular when they denote weighted colimits, are often considered similar to integrals in analysis, which is why they are normally denoted by an integral sign. The correspondence can roughly be summarized in terms of monads, by saying that the monad $${\mathsf {P}}$$ on $${\mathsf {CAT}}$$ behaves similarly to the Giry monad P on the category of (say) measurable spaces [11], and to other probability and measure monads. In particular,

• Small presheaves on a category are similar to measures on a measurable space;

• Cocomplete categories (categories where one can take colimits) are similar to algebras over probability monads (spaces where one can take integrals or expectation values, such as the real line);

• In a (sufficiently) cocomplete category $${\mathsf {C}}$$, given a small presheaf $$P\in {\mathsf {PC}}$$ the following coend

\begin{aligned} \int ^{X\in {\mathsf {C}}} PX\bigotimes X \end{aligned}

is similar to the following integral of a measure p on, say, real numbers,

\begin{aligned} \int _{{\mathbb {R}}} x\,dp(x) ; \end{aligned}
• As Kleisli morphisms, (small) profunctors are similar to Markov kernels.

An introduction to probability monads, for the interested reader, can be found in [25, Chapter 1] as well as in [9, Section 6].

We now wish to emphasize that Theorem 5.10 adds a further analogy between integrals and coends: just like Kan extensions can be thought of as “partial colimits”, conditional expectations can be thought of as “partial expectations”. In particular, we compare Theorem 5.10 to a similar theorem for a probability monad on the category of metric spaces, the Kantorovich monad (see [8] as well as the more introductory material in [9, Section 6]).

The following statement is known ([9, Theorem 6.13] or [25, Theorem 4.2.14]).

### Theorem 5.13

Let (Ae) be a Banach space (an algebra of the Kantorovich monad). Let $$p,q\in PA$$ be Radon probability measures on A of finite first moment. The following conditions are equivalent:

• There exist probability spaces $$(\Omega ,\mu )$$ and $$(\Omega ',\mu ')$$, random variables $$f:\Omega \rightarrow A$$ and $$g:\Omega '\rightarrow A$$ with image measures p and q respectively, and a measure-preserving map $$m:\Omega \rightarrow \Omega '$$ such that g is the conditional expectation of f along (the pull-back sigma-algebra induced by) m – as in the following not necessarily commutative diagram:

• There is a partial evaluation $$k\in PPA$$ from p to q (for the Kantorovich monad).

The similarity to Theorem 5.10 is evident. One could say intuitively that if coends are analogous to integrals, Kan extensions are analogous to conditional expectations. The former can be interpreted as partial (weighted) colimits, and the latter as partial (weighted) averages. Notice also that the diagram (5.5) does not commute, but the conditional expectation map, just like a Kan extension, can be thought of as the one “making the diagram as close as possible to commuting”.

It has to be noted that, while we proved Theorem 5.10 by invoking an analogous (but simpler and stronger) statement for the monad of diagrams, Theorem 5.13 was proven directly, using measure-theoretic methods. In the statement of the Theorem 5.13 it seems that random variables play somewhat the role that diagrams play in Theorem 5.10 (or at least, of diagrams equipped with weights, analogous to the measures on $$\Omega$$ and $$\Omega '$$). However, currently it is not clear whether random variables, or related structures, may form a monad analogous to $${\mathsf {Diag}}$$, and on which category such a structure could be found.