Ends, Coends, and the Calculus of (Co)ends
Anchor (Master): Mac Lane 1998 *Categories for the Working Mathematician* 2e (Springer GTM 5) Ch. IX-X (ends, coends, Kan extensions by (co)ends); Loregian 2021 *(Co)end Calculus* (Cambridge) Ch. 1-5 (the Fubini rule, the (co)Yoneda lemma, weighted (co)limits, Kan extensions, the bar construction); Kelly 1982 *Basic Concepts of Enriched Category Theory* (Cambridge) Ch. 2-3 (ends and weighted limits in the enriched setting); Riehl 2014 *Categorical Homotopy Theory* (Cambridge) Ch. 4, 7 (weighted colimits, the two-sided bar construction, geometric realization as a coend)
Intuition Beginner
Some constructions in mathematics depend on a label in two opposite ways at once: a quantity grows when the label moves forward and shrinks when the same label moves backward. The cleanest example is a comparison between two things tagged by the same name. To compare a measurement at a point with another measurement at that same point, you need the point in both roles: as the source you read from and as the target you write to. A rule that uses one label in both roles is the kind of thing this unit learns to package.
When a family of pieces is glued together compatibly across every label, there are two natural single objects to extract. One is the part that all the pieces agree on no matter how you shuffle the labels: the common core, the most you can say that survives every comparison. The other is the whole formed by piling all the pieces together and then declaring two contributions equal whenever a label-shuffle relates them: the merged total, the least you can collapse to without losing anything.
Think of an average over every way a structure can map to itself. The first object, the common core, is the universal place that maps consistently into all the self-comparisons. The second, the merged total, is the universal place that all the self-comparisons map consistently out of. Both are averages of a family indexed by labels that pull in two directions. The end is the common core; the coend is the merged total.
Visual Beginner
Picture a long row of boxes, one box for each label. Each box holds the value of a rule that reads the label as a source and writes it as a target at the same time. Arrows between labels act on the boxes in two directions: a forward arrow pushes one box ahead, and the same arrow pulls another box back. A compatible family is a choice that respects both pushes and pulls everywhere.
| object | what it collects | universal direction |
|---|---|---|
| the end (common core) | the part every box agrees on | maps consistently into all boxes |
| the coend (merged total) | all boxes piled up, glued by label-shuffles | all boxes map consistently out |
| a natural comparison | one number per box, respecting both directions | named by the end of a hom-rule |
The two nodes outside the row are the answers. The node on top is the most economical source feeding every box compatibly; the node on the bottom is the most economical target collecting every box compatibly. Reading the same row two ways gives the two constructions, and most calculations in this unit move between the top reading and the bottom reading.
Worked example Beginner
Work in a small world with two labels, and , and one forward arrow from to besides the do-nothing arrows. A rule reads a label twice, once forward and once backward, and returns a set. Set the rule to return, at the matched pair , the two-element set ; at , the one-element set ; and across the arrow it sends and both to when pushing forward, while pulling backward sends to .
Step 1. Find the common core, the choices agreeing across . A choice picks one element at and one at . Compatibility across demands that pushing the -choice forward and pulling the -choice backward land on matching answers. Pulling backward gives , so the -choice must be .
Step 2. Read off the common core. Only the pair (choose at , choose at ) survives. The common core is a one-element set: a single compatible choice.
Step 3. Find the merged total. Pile the boxes: from and from , three elements before gluing. The arrow glues to , since pushing forward gives . After gluing, and are one element, and is left alone.
What this tells us: the common core had one element, while the merged total had two. These are the two averages of the same family. The end shrank the family to what everything shares; the coend collapsed the family to its merged whole.
Check your understanding Beginner
Formal definition Intermediate+
Let and be categories and a bifunctor, contravariant in its first variable and covariant in its second. Such an is a profunctor-shaped datum: it reads an object as both a source and a target. The matched diagonal values are the objects this unit averages over [Mac Lane 1998].
Definition (dinatural transformation; wedge; cowedge). A wedge from an object to is a family of arrows , one for each object , such that for every arrow the dinaturality square $$ F(c,f)\circ\omega_c ;=; F(f,c')\circ\omega_{c'} $$ commutes, where acts on the covariant slot and on the contravariant slot. Dually a cowedge from to is a family with for all . A dinatural transformation between two such bifunctors is the evident family making the two-sided hexagon commute; a wedge is the dinatural transformation from a constant bifunctor.
Definition (end; coend). The end is the universal wedge: an object with a wedge such that every wedge factors as through a unique . The coend is the universal cowedge: an object with a cowedge through which every cowedge factors uniquely. The integral-sign notation is due to Yoneda [Yoneda 1960]; the subscript marks the end (a limit) and the superscript the coend (a colimit). The notation introduced here — , , the copower and power of by a set , the cotensor and tensor of an enriched setting, and for the twisted-arrow category — is recorded in _meta/NOTATION.md.
Definition (twisted-arrow category). The twisted-arrow category has objects the arrows of and morphisms the pairs with (an inward factorisation). A bifunctor restricts along the projection , , to a diagram on , and the end and coend are computed as an ordinary limit and colimit of that diagram.
Counterexamples to common slips Intermediate+
An end is not a limit over . The end ranges over the twisted-arrow category, not over ; reading as for some functor of one variable discards the contravariant slot and the dinaturality coherence that ties the two slots together.
Dinaturality is weaker than naturality and does not compose. Dinatural transformations between bifunctors need not compose to a dinatural transformation in general; the wedge case (one side constant) is the safe special case the (co)end packages, which is why ends are defined as universal wedges rather than as limits of a dinaturality 2-category.
The copower is a coproduct, not a product. In the coend the symbol is the -fold coproduct of ; confusing it with the power (a product) swaps a weighted colimit for a weighted limit and reverses every universal arrow.
Key theorem with proof Intermediate+
The keystone of the calculus expresses the set of natural transformations between two functors as an end. It is the bridge from the Yoneda viewpoint of 41.04.02 into the integral notation.
Theorem (natural transformations as an end). Let be functors into a locally small category, and define the bifunctor by . Then there is a bijection, natural in and , $$ \mathrm{Nat}(F,G);\cong;\int_{c\in\mathcal{C}}\mathcal{D}(Fc,Gc), $$ identifying a natural transformation with a universal wedge over the hom-bifunctor [Mac Lane 1998].
Proof. A wedge from the one-point set to is a family of elements , i.e. a family of arrows , one per object . The dinaturality condition for the wedge at an arrow reads $$ \mathcal{D}(Fc,Gf)(\alpha_c);=;\mathcal{D}(Ff,Gc')(\alpha_{c'}), $$ where is post-composition by and is pre-composition by . Spelled out, the left side is and the right side is , so the condition is — exactly the naturality square of . Hence wedges from to are precisely natural transformations .
By the universal property of the end, wedges from to the hom-bifunctor are in bijection with maps , that is, with elements of the end. Composing the two bijections gives , sending to the element it names and back. Naturality in and holds because both sides are computed from the same hom-bifunctor and the bijection is induced by the identity wedge, which is preserved by whiskering.
Bridge. This end formula builds toward the entire (co)end calculus and appears again in 41.06.02, where it is the engine of the Kan-extension formulas. The foundational reason a single wedge encodes a natural transformation is that dinaturality over the hom-bifunctor unwinds to the naturality square, so the integral is the hom-set of the functor category read as a universal cone; this is exactly the end-shaped repackaging of the Yoneda viewpoint of 41.04.02, where natural transformations out of a representable were computed by evaluation at the identity. Putting these together, the ninja-Yoneda density formula and the end form proved here are dual halves of one principle, and the bridge is from "compatible family of arrows" to "single universal object", which generalises the limit-and-colimit machinery of 41.02.01 from one-variable diagrams to bifunctors varying in two opposite directions at once.
Exercises Intermediate+
Advanced results Master
Theorem (ends and coends as twisted-arrow (co)limits). For with small and complete, the end exists and is computed as the limit $$ \int_{c}F(c,c);\cong;\lim\Bigl(\mathrm{TwArr}(\mathcal{C})^{\mathrm{op}}\xrightarrow{\ }\mathcal{C}^{\mathrm{op}}\times\mathcal{C}\xrightarrow{\ F\ }\mathcal{D}\Bigr), $$ and, when is cocomplete, the coend is the colimit of the same composite over . Equivalently the end is the equalizer of the two maps induced by the two slot actions, and the coend is the coequalizer of the dual maps between coproducts. The equalizer presentation is the working computation in and in any category where the relevant products and coproducts are explicit.
Theorem (the (co)Yoneda / ninja-Yoneda lemma). For and ,
$$
Fc;\cong;\int^{d}\mathcal{C}(d,c)\cdot Fd,\qquad
Fc;\cong;\int_{d}\bigl(Fd\bigr)^{\mathcal{C}(c,d)},\qquad
G;\cong;\int^{d}Gd\cdot\mathcal{C}(-,d),
$$
the coend and end forms reducing any (co)representable-weighted (co)limit to evaluation. These identities are the density theorem of 41.04.02 written as rewrite rules: the coend "integrates away" a hom-functor in a slot by setting the bound variable to the free one. The same reduction proves from the Key theorem and extends, with no change of argument, to the enriched setting where is replaced by a closed symmetric monoidal and the copower by the tensor and the power by the cotensor .
Theorem (weighted limits and colimits as (co)ends). Let be a weight and a diagram in a category with the needed (co)powers and (co)limits. The weighted limit and weighted colimit are $$ \lim{}^{W}F;=;\int_{c}\bigl(F c\bigr)^{W c};=;\int_{c}W c\pitchfork Fc,\qquad \mathrm{colim}^{W}F;=;\int^{c}W c\cdot Fc, $$ the end of the cotensor and the coend of the tensor. The conical case is the constant weight : then and , recovering ordinary limits and colimits. The defining adjunction exhibits the weighted colimit as the object representing weighted cocones, the form Kelly takes as primitive in the enriched theory [Kelly 1982].
Theorem (the functor tensor product and the bar construction). For functors and in a cocomplete , the functor tensor product is the coend , a weighted colimit of by . When carries a simplicial or monoidal structure the two-sided bar construction is the simplicial object whose geometric realization is this coend, with -simplices and the coend arising as the realization . The nerve of a small category is the simplicial set with the chains of composable arrows, and its geometric realization is the coend , the canonical example in which a coend over the simplex category glues standard simplices along face and degeneracy maps.
Theorem (geometric realization as a coend). The geometric realization of a simplicial set is the coend $$ |X|;=;\int^{[n]\in\Delta}X_n\cdot\Delta^{n};=;\int^{[n]}X_n\times\Delta^{n}, $$ the tensor of the discrete set with the topological standard simplex , glued by the face and degeneracy identifications encoded in the dinaturality over . By the (co)Yoneda lemma this is the left Kan extension along the Yoneda embedding of the cosimplicial space , so realization is the unique colimit-preserving extension sending the representable to . Singular homology, the singular-set functor, and the realization-nerve adjunction all read off this one coend.
Synthesis. Putting these together, the (co)end calculus is the manipulable face of the density theorem of 41.04.02, and every formula here is the universal cone of 41.02.01 read for a bifunctor varying in two opposite directions. The foundational reason a coend computes geometric realization, the bar construction, and the functor tensor product alike is that each is a weighted colimit , so they differ only in the weight; the (co)Yoneda lemma is exactly the rule that integrates away a representable weight, and this is dual to the end form that names natural transformations. The central insight is that the Fubini theorem makes these integrals associative and commutative in independent variables, so the Kan-extension formula of 41.06.02 is computed by the same moves, which generalises the conical limits and colimits of 41.02.01 to the weighted setting and carries over verbatim to enriched categories with replaced by a monoidal . The bridge is that the entire toolkit — Fubini, (co)Yoneda, weighted (co)limits — exists so that the Kan-extension formulas of the next unit can be written and evaluated as integrals.
Full proof set Master
Proposition 1 (the end is the equalizer of the two slot actions). For with small and complete, is the equalizer of the parallel pair $$ \textstyle\prod_{c}F(c,c);\underset{t}{\overset{s}{\rightrightarrows}};\prod_{f\colon c\to c'}F(c,c'), $$ where has -component and has component .
Proof. A map is a family . Composing with gives, in the slot, ; composing with gives . So holds if and only if for every , which is the dinaturality condition defining a wedge. The equalizer is therefore the universal object through which every wedge factors, i.e. the end. Completeness of provides the two products and the equalizer, so the end exists.
Proposition 2 (natural transformations form an end). For locally small, , naturally in and .
Proof. By Proposition 1 the end is the equalizer in of with and . An element of the equalizer is a family with for all , which is precisely a natural transformation . The assignment is a bijection onto the equalizer, inverse to reading the components back off. Naturality in along acts by whiskering and matches the induced map on equalizers; naturality in is dual.
Proposition 3 (the co-Yoneda lemma). For , the map , , is a bijection.
Proof. As a -coend, , where identifies, for , the element at with at for and . The map is well defined: by functoriality, so it respects . It is surjective: is . It is injective: every class has a representative with , since , and forces because no further relation touches the -fibre. Hence is a bijection, natural in . The dual end form follows by applying this in together with Proposition 2.
Proposition 4 (Fubini for coends). For with cocomplete, .
Proof. The coend is the colimit of restricted along . An arrow of is a pair of arrows, and an inward factorisation splits coordinatewise, so as categories. The colimit of a diagram over a product category is computed as an iterated colimit, , because colimits commute with colimits and both compute the left adjoint to the constant-diagram functor . Reading the inner colimit as the coend in and the outer as the coend in (and the reverse) gives the two iterated coends, each canonically isomorphic to the joint one. The end statement is dual: splits identically and limits commute with limits.
Proposition 5 (weighted colimits as coends, conical case). For and cocomplete, the object represents weighted cocones: , and for this is .
Proof. Using the universal property of the coend and of the copower, , where the first isomorphism is the continuity of carrying a colimit to a limit (a coend to an end), and the second is the copower-power adjunction applied inside the end. By Proposition 2 the right-hand end is , the set of weighted cocones, so the coend represents them. For the copower and the weighted-cocone set becomes the ordinary cocone set, whence by Exercise 5.
Connections Master
The Yoneda lemma, the Yoneda embedding, and density
41.04.02. The prerequisite unit proves the density theorem and previews the co-Yoneda coend without the calculus to manipulate it. This unit supplies that calculus: the ninja-Yoneda identities of Proposition 3 are density written as rewrite rules, and the end form of Proposition 2 is the Yoneda viewpoint — natural transformations computed by evaluation — repackaged as a universal wedge.Limits and colimits as universal cones
41.02.01. Ends are limits and coends are colimits over the twisted-arrow category, so Proposition 1's equalizer presentation specialises the cone machinery of41.02.01to bifunctors. Weighted limits and colimits generalise the conical case proved there: recovers the universal cone, and the weighted form is the colimit re-weighted by a presheaf.Kan extensions
41.06.02. The co-produced unit41.06.02defines the pointwise left and right Kan extensions by the coend and end formulas and , which are exactly the weighted colimit and weighted limit of this unit with the hom-functor as weight. The Fubini theorem and the (co)Yoneda lemma proved here are the moves that evaluate those formulas, so41.06.02is the calculus of this unit applied to extension problems.Monads and their algebras
41.05.01. The two-sided bar construction specialises, for a monad regarded as a one-object enriched category, to the simplicial bar resolution computing monadic (co)limits and the Eilenberg-Moore and Kleisli comparisons; the coend over the simplex category is the resolution that the monadicity machinery of41.05.01uses implicitly.
Historical & philosophical context Master
The integral-sign notation for ends and coends is due to Nobuo Yoneda, who introduced it in his 1960 study of and exact sequences, extending the bijection that bears his name to a calculus of bifunctor-valued limits [Yoneda 1960]. Mac Lane systematised dinatural transformations, ends, coends, and the Fubini theorem in Chapter IX of Categories for the Working Mathematician, where the end is defined as a universal wedge and the coend computation of Kan extensions appears in Chapter X [Mac Lane 1998]. Kelly's Basic Concepts of Enriched Category Theory (1982) recast weighted limits and colimits as ends and coends over an enriching category , taking the weighted form rather than the conical form as primitive, the choice that made the enriched theory uniform [Kelly 1982].
The coend model of geometric realization traces to the simplicial methods of Milnor and Kan and was given its modern form in the two-sided bar construction, with Riehl's Category Theory in Context and Loregian's (Co)end Calculus presenting the integral notation as a working tool for homotopy theory and enriched category theory [Loregian 2021]. The reading of realization as a left Kan extension along the Yoneda embedding, sending each representable simplex to its topological model, is the form that unifies the nerve, the singular-set functor, and the realization-nerve adjunction as instances of one coend.
Bibliography Master
@article{Yoneda1960ends,
author = {Yoneda, Nobuo},
title = {On {Ext} and exact sequences},
journal = {Journal of the Faculty of Science, University of Tokyo, Section I},
volume = {8},
year = {1960},
pages = {507--576}
}
@book{MacLane1998ends,
author = {Mac Lane, Saunders},
title = {Categories for the Working Mathematician},
edition = {2},
publisher = {Springer},
series = {Graduate Texts in Mathematics 5},
year = {1998}
}
@book{Loregian2021,
author = {Loregian, Fosco},
title = {(Co)end Calculus},
publisher = {Cambridge University Press},
series = {London Mathematical Society Lecture Note Series 468},
year = {2021}
}
@book{Kelly1982ends,
author = {Kelly, G. Max},
title = {Basic Concepts of Enriched Category Theory},
publisher = {Cambridge University Press},
series = {London Mathematical Society Lecture Note Series 64},
year = {1982}
}
@book{Riehl2016ends,
author = {Riehl, Emily},
title = {Category Theory in Context},
publisher = {Dover},
year = {2016}
}
@book{Riehl2014,
author = {Riehl, Emily},
title = {Categorical Homotopy Theory},
publisher = {Cambridge University Press},
series = {New Mathematical Monographs 24},
year = {2014}
}