# Intuition for coends

Let $D$ be a co-complete category and $C$ be a small category. For a functor $F:C^{op}\times C \to D$ one defines the co-end $$\int^{c\in C} F(c,c)$$ as the co-equalizer of $$\coprod_{c\to c'}F(c,c'){\longrightarrow\atop\longrightarrow}\coprod_{c\in C}F(c,c).$$ It is the indexed co-limit $\mbox{colim}_W F$ where the weight is the functor $W:C^{op}\times C \to Set$ given by $Hom(-,-)$.

I have two strongly related questions regarding this definition. First, what's the intuition behind this construction? Can I think of it as a kind of ''fattened'' colimit? Second, why is the integral sign used for this? Can ordinary integration be related to this construction?

-
Funny, the same questions came to me a couple of hours ago. I think the equation $A \otimes_R B = \int^{R} A \otimes B$ is quite illuminating. Also in general, the intuition is perhaps that we gather all $F(c,c)$ together and identify the right $C$-action with the left $C$-action. I doubt that (co)ends have a precise relationship with integrals in measure theory, but there are some formal similarities, such as the representation as weighted sums and Fubini's Theorem. – Martin Brandenburg Oct 18 '11 at 19:19
I am not an expert, but should the first coproduct be indexed $c' \to c$, not $c \to c'$? – ykm Oct 30 '13 at 18:28
From the way it sounds, the tuition for coeds must be lower than intuition for coends. – Włodzimierz Holsztyński Mar 19 '14 at 23:10

Martin's comment is right on the money; in particular, the best way to get a feeling for coends is through the many examples where they appear, such as (generalized) tensor products. But from an abstract point of view, coends can be considered as universal "extranatural transformations", and the ubiquity of coends (and ends) is explained by the ubiquity of such extranatural transformations.

Let me take a specific example before getting into the abstract aspects. Let's consider the example of geometric realization of simplicial sets, as a left adjoint to the singularization functor $S: Top \to Set^{\Delta^{op}}$. Recall that if $Y$ is a space, then $S(Y)$ is the simplicial set $\Delta^{op} \to Set$ whose value at the ordinal $[n]$ (with $n+1$ points) is defined by

$$S(Y)([n]) = \hom_{Top}(\sigma_n, Y)$$

where $\sigma_n$ is the $n$-dimensional affine simplex seen as a topological space. We are interested in constructing a left adjoint $R$ to $S$, so that for any simplicial set $X$, the set of natural transformations

$$X \to S(Y)$$

is in natural bijective correspondence with continuous maps $R(X) \to Y$.

The way to do this is to "bend" a natural transformation

$$X([n]) \to \hom_{Top}(\sigma_n, Y)$$

(a family of maps natural in $[n] \in \Delta$) into another family

$$\phi_n: X([n]) \times \sigma_n \to Y$$

of continuous maps indexed by $n$. This family has a property intimately related to the naturality of the first family; it is called "extranaturality". It means that given any morphism $f: [m] \to [n]$, the composite

$$X([n]) \times \sigma_m \stackrel{X[f] \times id}{\to} X([m]) \times \sigma_m \stackrel{\phi_m}{\to} Y$$

equals the morphism

$$X([n]) \times \sigma_m \stackrel{id \times \sigma_f}{\to} X([n]) \times \sigma_n \stackrel{\phi_n}{\to} Y;$$

this precisely mirrors the naturality of the first family in $n$. Thus, what we are after is an extranatural transformation

$$X([n]) \times \sigma_n \to R(X)$$

with the universal property that given any extranatural transformation $\phi_n$ as above, there exists a unique map $R(X) \to Y$ making the evident triangle commute (for each $n$). This is of course the coend

$$R(X) = \int^n X([n]) \times \sigma_n$$

and the appropriate construction in terms of coproducts and coequalizers that you indicated in your question is exactly what is required to construct the universal extranatural transformation.

This is easily abstracted. Given any functor $F: C^{op} \times C \to D$, one can define what it means for a family of maps $F(c, c) \to d$ (for fixed $d$) to be extranatural in $c$, and the coend is again described as a universal extranatural transformation. In nature, such transformations almost invariably arise by "bending" a natural transformation into an extranatural (also called "dinatural") one. The tensor product mentioned by Martin fits into this pattern: thinking of a left $R$-module map of the form

$$M \to \hom_{Ab}(N, A)$$

($M$ a left $R$-module, $N$ a right $R$-module, $A$ an abelian group; the hom acquires a left $R$-module structure) as a $Ab$-enriched natural transformation between functors of the form $R \to Ab$ (where a ring $R$ is viewed as a one-object $Ab$-enriched category), we can "bend" this map into a map

$$M \otimes N \to A$$

which is extranatural with respect to scalar actions, and the quotient $M \otimes N \to M \otimes_R N$ is the universal such extranatural map. But this only scratches the surface of possibilities for this type of situation.

Finally, I second Martin's remark on the traditional integral notation -- not too much should be made of this, except that weighted colimits are primary examples of coends, and there are interchange isomorphisms which are reminiscent of Fubini theorems; this is touched upon in Categories for the Working Mathematician.

-
This is an excellent answer. I would just like to add that I think the example of the tensor product of modules is a very useful one. I really only started to feel that I understood coends when I started to think of functors as a generalization of modules and coends (or the special case of the "tensor product of functors", at least) as a generalization of tensor product of modules. – Mike Shulman Oct 19 '11 at 0:22
Thanks, Mike. I agree that tensor products, and generalized tensor products, are in some sense the crucial examples to understand. (I mean the tensor product of a "left module" $C \to Set$ with a "right module" $C^{op} \to Set$, where $C$ is a small category, and possibly replacing $Set$ by some other $V$ in which $C$ is enriched.) – Todd Trimble Oct 19 '11 at 0:53

I prefer a somewhat different view of ends and coends, with the intuition stemming more from classical linear algebra and functional analysis. So for me an end is really an integral in a categorical sense.

Let me explain it in more detail. The first fact about ends that show me their power and is basic in enriched category theory is the natural transformation lemma. Basically, $$Nat(F\cdot; G\cdot) = \int_c Hom_C(Fc; Gc)$$ This equations shows that a global natural transformation is as if "summed up" from the local, "differential" transformations on each object. That's exactly what a natural transformation is: a coherent family of morphisms. In this way an end allows us to pass from the local to the global picture, just like a real integral. Let's consider a global section functor for sheaves: $$\Gamma(X; \mathcal{F}) = Nat(\Bbb{Z}, \mathcal{F}) = \int_U Hom_{Ab}(\Bbb{Z}; \mathcal{F}(U)) = \int_{U\in Ouv^{op}} \mathcal{F}(U)$$ Compare it with measure integration, where you have a (non-negative) measure defined for all measurable subsets of $X$ and you can, in principle, define the measure of $X$ analysing its subsets. At least for not-too-bad measure spaces you can find the measure of $X$ as the supremum of the subsets' measures. This can be also viewed as an end, if you consider a functor $M: Ouv \to \Bbb{R}_{+}$, where $\Bbb{R}_{+}$ is a poset category with objects $[0;\infty]$, $f:a\to b \iff a \leqslant b$. However, I don't understand at the moment how can nontrivial general integrals be treated in this conext.

Even more enlightening is the composition of distributors. A good account of distributors is in J. Benabou's article "Distributors at work". Informally, it is like a "generalized functor", the most important property being the existence of right adjoint for any functor considered as a distributor. Kan extensions also emerge miraculously. The name itself hints of this connection. A distributor is to a functor what a distribution is to a function. Formally, a (Set-valued) distibutor $F:A \nrightarrow B$ from category $A$ to category $B$ is a functor $$\hat F: A\times B^{op} \to Set$$ A composition of distributors can be defined via Kan extensions along the Yoneda embedding, or much more neatly as a coend $$G\circ F (a;c) = \int^b \hat G(b; c) \times \hat F(a;b)$$ This clearly reminds of matrix composition law. A simple example of (identity) distributor is the hom-functor in a V-category: $$[a;c] = \int^b [b; c] \otimes [a;b]$$

Clearly we just integrate out the dummy variable and the inner hom is just a change-of-coordinates Jacobian! A special case of these identities is the Yoneda lemma, which I will write as a left Kan extension: $$F(a) = \int^c [c;a] \otimes F(c)$$ and the Kan extension itself: $$\mathrm{Lan}_K(F)(a) = \int^c [K(c);a] \otimes F(c)$$

Clearly it's just a change of integration variables!

Another enlightening example comes from the theory of metric spaces, considered by F.W.Lawvere in "Metric spaces, generalized logic, and closed categories". A metric space is considered as a category enriched over $\Bbb{R}_+$, defined above. The objects are points, hom from a to b is the distance from a to b (the metric need not be symmetric). In this case for $\Bbb{R}_+$-valued functor $F$ it's limit is clearly it's supremum. A limit is an end $$\mathrm{Lim} F = \int_d F(d)$$ where $F$ is considered as a bifunctor constant in its first variable. So $$\sup_{x\in X} F(x) = \int_{x\in X} F(x)$$

A person familiar with tropical geometry and idempotent analysis will instantly recognise this formula as a tropical integral! Simple as it is, it is another exact shot for categorical integration. A Kan extension of $\phi: X \to \Bbb{R}$ along $f:X\to Y$ is $$\mathrm{Ran}_{f} \phi (y) = \sup_x [ \phi(x) - \lambda Y(y, f(x)) ]$$

If not for the nonlinear hom nature, it would be immediately recognisable as a tropical Fourier transform, aka Legendre transform.

Even the common integral itself can be considered as a kind of transfinite tensor product, but the construction is somewhat clumsy and eventually reduces to common measure, so it's not of much use practically but fits nicely in the categorical integration picture. As of yet I do not know any neat way to incorporate common integrals into the categorical framework, like tropical integrals do.

Sorry for a big post, but I just couldn't resist sharing these examples.

-
This is really nice. Welcome to MO. – Spice the Bird Nov 12 '11 at 3:04
Anton Fetisov, If I am not mistaken, you meant $$F(a) = \int ^c [c;a] \otimes F(c)$$ and $$\mathrm{Lan}_K(F)(a) = \int ^c [K(c);a] \otimes F(c) .$$ Right? – Fernando Mar 19 '14 at 22:10
@Fernando, right, thank you! – Anton Fetisov Mar 19 '14 at 22:18