---
title: Limits and Colimits of Presheaves
module: Adjoints, Representables, and Limits Together
moduleNumber: 6
lessonNumber: 2
order: 602
summary: >
  Representables preserve limits, and limits in a functor category are computed
  one object at a time, so a presheaf category is complete and cocomplete with all
  its structure inherited pointwise from Set. The Yoneda embedding then preserves
  limits but not colimits, and the density theorem repairs the colimit side:
  every presheaf is a canonical colimit of representables.
topics: [Adjoints, Representables, and Limits Together]
sources:
  - book: Leinster
    ref: "Ch. 6 — Adjoints, representables and limits; §6.2 Limits and colimits of presheaves"
draft: false
---

A presheaf on $\mathcal{A}$ is a functor $\mathcal{A}^{\mathrm{op}} \to
\mathbf{Set}$, and presheaves on $\mathcal{A}$ form the category
$[\mathcal{A}^{\mathrm{op}}, \mathbf{Set}]$. Limits and colimits in this category
are computed pointwise, so it inherits completeness and cocompleteness from
$\mathbf{Set}$. The
[Yoneda embedding](/category-theory/representables-yoneda/yoneda-consequences)
preserves limits but not colimits, and although a colimit of representables need
not be representable, _every_ presheaf is a colimit of
representables.[^leinster-open]

Hom-functors turn limits into limits.

## Representables preserve limits

Fix a locally small category $\mathcal{A}$ and an object $A$. The
[hom-functor](/category-theory/representables-yoneda/representable-functors)
$\mathcal{A}(A, -) : \mathcal{A} \to \mathbf{Set}$ sends an object $X$ to the set
of maps $A \to X$. For a product, a map into $X \times Y$ is a pair of maps, so
$$
\mathcal{A}(A, X \times Y) \;\cong\; \mathcal{A}(A, X) \times \mathcal{A}(A, Y),
$$
naturally in every argument. The same pattern holds for equalizers: a map into
$\mathrm{Eq}(s, t)$ is a map $f : A \to X$ with $s f = t f$, which is exactly an
element of the equalizer of $\mathcal{A}(A, s)$ and $\mathcal{A}(A, t)$ in
$\mathbf{Set}$. These are two instances of a single statement.[^leinster-621]

> **Lemma (Cones as a limit of hom-sets).** Let $\mathcal{I}$ be small,
> $\mathcal{A}$ locally small, $D : \mathcal{I} \to \mathcal{A}$ a diagram, and
> $A \in \mathcal{A}$. Then
> $$
> \mathrm{Cone}(A, D) \;\cong\; \lim \, \mathcal{A}(A, D)
> \qquad \text{naturally in } A \text{ and } D,
> $$
> where $\mathcal{A}(A, D)$ is the diagram $I \mapsto \mathcal{A}(A, D(I))$ in
> $\mathbf{Set}$.

The lemma is a reading of the explicit limit formula in $\mathbf{Set}$. An
element of $\lim \mathcal{A}(A, D)$ is a compatible family $(f_I)$ with $f_I \in
\mathcal{A}(A, D(I))$ and $\mathcal{A}(A, D u)(f_I) = f_J$ for every $u : I \to
J$. That compatibility is $D(u) \circ f_I = f_J$, which is the cone condition.
Combined with the
[representation of the cone functor](/category-theory/adjoints-limits/limits-via-adjoints),
$\mathrm{Cone}(A, D) \cong \mathcal{A}(A, \lim D)$, the lemma gives the headline.

> **Proposition (Representables preserve limits).** For a locally small
> $\mathcal{A}$ and any $A$, the functor $\mathcal{A}(A, -) : \mathcal{A} \to
> \mathbf{Set}$ preserves limits:
> $$
> \mathcal{A}\bigl(A, \textstyle\lim D\bigr) \;\cong\; \lim \, \mathcal{A}(A, D).
> $$

Dualizing replaces $\mathcal{A}$ by $\mathcal{A}^{\mathrm{op}}$: the
contravariant hom-functor $\mathcal{A}(-, A) : \mathcal{A}^{\mathrm{op}} \to
\mathbf{Set}$ preserves limits, which means it turns colimits in $\mathcal{A}$
into limits in $\mathbf{Set}$,
$$
\mathcal{A}\bigl(\operatorname{colim} D, A\bigr) \;\cong\; \lim \, \mathcal{A}(D, A).
$$
The covariant hom-functor turns limits into limits and the contravariant one
turns colimits into limits; neither produces a colimit. The duality is not
symmetric.

> **Worked example (Representable preserves a product, by count).** In
> $\mathbf{Set}$, the hom-functor $\mathbf{Set}(A, -)$ sends $X \times Y$ to
> $\mathbf{Set}(A, X \times Y)$, and the preservation isomorphism is
> $$
> \mathbf{Set}(A, X \times Y) \;\cong\; \mathbf{Set}(A, X) \times \mathbf{Set}(A, Y),
> $$
> sending $f$ to the pair $(p \circ f, q \circ f)$ of its components. For finite
> sets the cardinalities check out: with $|A| = a$, $|X| = m$, $|Y| = n$,
> $$
> |\mathbf{Set}(A, X \times Y)| = (mn)^a
> \quad\text{and}\quad
> |\mathbf{Set}(A, X)| \cdot |\mathbf{Set}(A, Y)| = m^a n^a,
> $$
> equal because $(mn)^a = m^a n^a$. Taking $A = \{1, 2\}$, $X = \{a, b\}$,
> $Y = \{c, d, e\}$ gives $(2 \cdot 3)^2 = 36 = 2^2 \cdot 3^2$: thirty-six maps
> into the product, thirty-six pairs of maps into the factors.

## Limits in functor categories

Now let $\mathcal{A}$ be small and $\mathcal{S}$ locally small, so
$[\mathcal{A}, \mathcal{S}]$ is again locally small. For each $A \in \mathcal{A}$
the **evaluation** functor $\mathrm{ev}_A : [\mathcal{A}, \mathcal{S}] \to
\mathcal{S}$ sends $X$ to $X(A)$. Given a diagram $D : \mathcal{I} \to
[\mathcal{A}, \mathcal{S}]$ of functors, evaluating at $A$ produces an ordinary
diagram $D(-)(A) : \mathcal{I} \to \mathcal{S}$. The claim is that the limit of
$D$ is computed by taking the limit of each $D(-)(A)$ and reassembling.

> **Theorem (Pointwise limits).** Let $\mathcal{A}$ and $\mathcal{I}$ be small,
> $\mathcal{S}$ locally small, and $D : \mathcal{I} \to [\mathcal{A}, \mathcal{S}]$
> a diagram such that each $D(-)(A)$ has a limit in $\mathcal{S}$. Then $D$ has a
> limit, and a cone on $D$ is a limit cone if and only if evaluating it at every
> $A$ gives a limit cone in $\mathcal{S}$.

In short, **limits in a functor category are computed pointwise**, the
"points" being the objects of $\mathcal{A}$. The proof assembles the pointwise
limits $L(A) = \lim D(-)(A)$ into a functor: a map $f : A \to A'$ induces a map
$L(f) : L(A) \to L(A')$ as the unique factorization from the
[induced-map lemma](/category-theory/adjoints-limits/limits-via-adjoints), the
projections then form a cone $L \Rightarrow D(I)$ in $[\mathcal{A}, \mathcal{S}]$,
and universality is checked one object at a time.[^leinster-625] Colimits are
computed pointwise by the dual argument.

$$
% caption: The pointwise limit: evaluate the diagram of functors at each object
% (here $A$ and $B$), take the limit $L(A)$ in $\mathcal{S}$ with projections
% $p_I$ at $A$ and $q_I$ at $B$, and the maps $L(f)$ assemble the values into the
% limit functor.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
% at A
\node (LA)  at (0,1.5)  {$L(A)$};
\node (DIA) at (2.6,1.5){$D(I)(A)$};
% at B
\node (LA2) at (0,0)    {$L(B)$};
\node (DIA2)at (2.6,0)  {$D(I)(B)$};
\draw[->, acc, thick] (LA) -- (DIA) node[midway, above]{$p_I$};
\draw[->, acc, thick] (LA2) -- (DIA2) node[midway, below]{$q_I$};
\draw[->, black] (LA) -- (LA2) node[midway, left]{$L(f)$};
\draw[->, black] (DIA) -- (DIA2) node[midway, right]{$D(I)(f)$};
\node[black, anchor=west] at (4.1,1.5) {limit at $A$};
\node[black, anchor=west] at (4.1,0)   {limit at $B$};
\end{tikzpicture}
$$

Two consequences:

- **Completeness is inherited.** If $\mathcal{S}$ has all limits (respectively
  colimits) of shape $\mathcal{I}$, so does $[\mathcal{A}, \mathcal{S}]$, and each
  evaluation functor $\mathrm{ev}_A$ preserves them.
- **Presheaf categories are complete and cocomplete.** Since $\mathbf{Set}$ has
  all small limits and colimits, $[\mathcal{A}^{\mathrm{op}}, \mathbf{Set}]$ has
  them too, computed pointwise, for any small $\mathcal{A}$.

A caution attaches to the first point. When $\mathcal{S}$ lacks some limits, the
functor category can still contain a limit of that shape which no evaluation
functor preserves; such limits are not pointwise. The theorem only builds
pointwise limits from limits already present in $\mathcal{S}$.[^leinster-627]

### Limits commute with limits

Pointwise computation gives a clean proof that the order of taking limits does
not matter. For shapes $\mathcal{I}$, $\mathcal{J}$ and a category $\mathcal{S}$
with all limits, a functor $D : \mathcal{I} \times \mathcal{J} \to \mathcal{S}$
can be curried either way, and its three possible limits agree.[^leinster-628]

> **Proposition (Limits commute with limits).** For small $\mathcal{I}$,
> $\mathcal{J}$ and a locally small $\mathcal{S}$ with limits of both shapes, every
> $D : \mathcal{I} \times \mathcal{J} \to \mathcal{S}$ satisfies
> $$
> \lim_{\mathcal{J}} \lim_{\mathcal{I}} D \;\cong\; \lim_{\mathcal{I} \times \mathcal{J}} D
> \;\cong\; \lim_{\mathcal{I}} \lim_{\mathcal{J}} D,
> $$
> and all three exist.

$$
% caption: A limit over a product shape (here both factors discrete on two
% objects): the vertex $L$ projects to every $D_{ij}$, and taking the limit one
% factor at a time gives the same $L$ in either order.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\node[acc] (L) at (0,0) {$L$};
\node (d11) at (-2.6,1.5) {$D_{11}$};
\node (d12) at (2.6,1.5)  {$D_{12}$};
\node (d21) at (-2.6,-1.5){$D_{21}$};
\node (d22) at (2.6,-1.5) {$D_{22}$};
\draw[->, acc, thick] (L) -- (d11);
\draw[->, acc, thick] (L) -- (d12);
\draw[->, acc, thick] (L) -- (d21);
\draw[->, acc, thick] (L) -- (d22);
\draw[->, black] (d11) -- (d12) node[midway, above]{$j$};
\draw[->, black] (d21) -- (d22) node[midway, below]{$j$};
\draw[->, black] (d11) -- (d21) node[midway, left]{$i$};
\draw[->, black] (d12) -- (d22) node[midway, right]{$i$};
\end{tikzpicture}
$$

The proof runs each side through the representation isomorphism until both name a
representing object for $[\mathcal{I} \times \mathcal{J}, \mathcal{S}](\Delta -,
D)$, then invokes uniqueness. By analogy with swapping the order of integration,
the result is sometimes called a Fubini theorem. The analogy is only partial:
colimits commute with colimits, but limits do **not** in general commute with
colimits. Taking $\mathcal{S} = \mathbf{Set}$ with four one-element sets,
$$
(1 + 1) \times (1 + 1) = 4 \neq 2 = (1 \times 1) + (1 \times 1),
$$
so a product of sums differs from the corresponding sum of products.

## The Yoneda embedding and limits

The [Yoneda embedding](/category-theory/representables-yoneda/yoneda-consequences)
$H_{\bullet} : \mathcal{A} \to [\mathcal{A}^{\mathrm{op}}, \mathbf{Set}]$ sends
$A$ to the representable $H_A = \mathcal{A}(-, A)$. Since representables preserve
limits and limits of presheaves are pointwise, the embedding carries limits in
$\mathcal{A}$ to limits in the presheaf category.

> **Corollary (Yoneda preserves limits).** For any small $\mathcal{A}$, the
> Yoneda embedding $H_{\bullet} : \mathcal{A} \to [\mathcal{A}^{\mathrm{op}},
> \mathbf{Set}]$ preserves limits.

Concretely, if $\mathcal{A}$ has binary products then $H_{X \times Y} \cong H_X
\times H_Y$, which evaluated at $A$ is the familiar $\mathcal{A}(A, X \times Y)
\cong \mathcal{A}(A, X) \times \mathcal{A}(A, Y)$. Viewing $\mathcal{A}$ as sitting
inside its presheaf category, the corollary says a limit of representables never
leaves $\mathcal{A}$: it is again representable.

$$
% caption: The Yoneda embedding sends the product cone on $P = X \times Y$ (left,
% with projections $p, q$) to a product cone on $H_P$; evaluating the presheaf
% isomorphism $H_{X \times Y} \cong H_X \times H_Y$ at $A$ recovers the hom-set identity.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\node (P)  at (0,1.3)  {$P$};
\node (X)  at (-1.5,0) {$X$};
\node (Y)  at (1.5,0)  {$Y$};
\draw[->, black] (P) -- (X) node[midway, above left]{$p$};
\draw[->, black] (P) -- (Y) node[midway, above right]{$q$};
\draw[->, acc, very thick] (2.5,0.65) -- (3.9,0.65) node[midway, above, black]{Yoneda};
\begin{scope}[xshift=5.6cm]
  \node (HP) at (0,1.3)  {$H_P$};
  \node (HX) at (-1.6,0) {$H_X$};
  \node (HY) at (1.6,0)  {$H_Y$};
  \draw[->, acc, thick] (HP) -- (HX) node[midway, above left]{$H_p$};
  \draw[->, acc, thick] (HP) -- (HY) node[midway, above right]{$H_q$};
  \node[black, anchor=north] at (0,-0.5) {a product cone};
\end{scope}
\end{tikzpicture}
$$

Colimits are the opposite story. The embedding does **not** preserve them. If
$\mathcal{A}$ has an initial object $0$, then $H_0(0) = \mathcal{A}(0, 0)$ is a
one-element set, whereas the initial presheaf is constant at $\varnothing$. So
$H_0$ is not initial: the embedding sends the initial object of $\mathcal{A}$ to
a non-initial presheaf.[^leinster-6214] The next section addresses this failure:
every presheaf is nonetheless a colimit of representables.

## Every presheaf is a colimit of representables

A canonical construction writes every presheaf as a colimit of representables;
its indexing category is the category of elements.

> **Definition (Category of elements).** For a presheaf $X$ on $\mathcal{A}$, the
> **category of elements** $\mathcal{E}(X)$ has:
>
> - objects: pairs $(A, x)$ with $A \in \mathcal{A}$ and $x \in X(A)$;
> - maps $(A', x') \to (A, x)$: maps $f : A' \to A$ in $\mathcal{A}$ with
>   $(Xf)(x) = x'$.
>
> The **projection** $P : \mathcal{E}(X) \to \mathcal{A}$ sends $(A, x) \mapsto A$
> and $f \mapsto f$.

The objects of $\mathcal{E}(X)$ are the elements of $X$ gathered across all
objects of $\mathcal{A}$; by Yoneda they are just the generalized elements of
$X$ of representable shape. Composing the projection with the Yoneda embedding
gives a diagram of representables indexed by these elements.

$$
% caption: The density diagram: the category of elements projects to $\mathcal{A}$
% by $P$, then embeds into presheaves by Yoneda, and the colimit of the composite
% recovers $X$.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\node (E) at (0,0)   {$\mathcal{E}(X)$};
\node (A) at (3,0)   {$\mathcal{A}$};
\node (PC) at (6.6,0) {$[\mathcal{A}^{\mathrm{op}}$, $\mathbf{Set}]$};
\node[acc] (X) at (6.6,1.8) {$X$};
\draw[->, black] (E) -- (A) node[midway, above]{$P$};
\draw[->, black] (A) -- (PC) node[midway, above]{Yoneda};
\draw[->, acc, thick] (PC) -- (X) node[midway, right]{colim};
\end{tikzpicture}
$$

> **Theorem (Density).** Let $\mathcal{A}$ be small and $X$ a presheaf on
> $\mathcal{A}$. Then $X$ is the colimit of
> $$
> \mathcal{E}(X) \xrightarrow{\;P\;} \mathcal{A} \xrightarrow{\;H_{\bullet}\;}
> [\mathcal{A}^{\mathrm{op}}, \mathbf{Set}],
> $$
> that is, $X \cong \operatorname{colim}(H_{\bullet} \circ P)$.

The proof computes cocones. A cocone on $H_{\bullet} \circ P$ with vertex $Y$ is
a family of natural transformations $H_A \to Y$, one per element $(A, x)$,
compatible across maps of $\mathcal{E}(X)$. By the
[Yoneda lemma](/category-theory/representables-yoneda/yoneda-lemma) each
transformation $H_A \to Y$ is an element of $Y(A)$, and the compatibility
condition turns the family into a single natural transformation $X \to Y$. So
cocones on $H_{\bullet} \circ P$ with vertex $Y$ correspond naturally to maps
$X \to Y$, which is the universal property of the colimit.[^leinster-6217] The
name echoes topology: $\mathcal{A}$ is "dense" in its presheaf category because
every presheaf is a colimit (a limit-of-points, in the topological sense) of
objects of $\mathcal{A}$.

$$
% caption: The density theorem exhibits $X$ as a colimit of representables: one
% representable $H_A$ for each element $x \in X(A)$, glued over the category of
% elements.
\begin{tikzpicture}[>=stealth, font=\footnotesize]
\definecolor{acc}{HTML}{4A6FA5}
\node (H1) at (0,0)   {$H_{A_1}$};
\node (H2) at (1.9,0) {$H_{A_2}$};
\node (H3) at (3.8,0) {$H_{A_3}$};
\node[acc] (X) at (1.9,1.7) {$X$};
\draw[->, acc, thick] (H1) -- (X);
\draw[->, acc, thick] (H2) -- (X);
\draw[->, acc, thick] (H3) -- (X);
\draw[->, black] (H1) to[bend right=18] (H2);
\draw[->, black] (H2) to[bend right=18] (H3);
\node[black, anchor=north] at (1.9,-0.5) {representables over $\mathcal{E}(X)$};
\end{tikzpicture}
$$

> **Worked example (A presheaf as a sum of five representables).** Let
> $\mathcal{A}$ be discrete on two objects $K, L$, so a presheaf is a pair of
> sets and $[\mathcal{A}^{\mathrm{op}}, \mathbf{Set}] \cong \mathbf{Set} \times
> \mathbf{Set}$. The two representables are $H_K \cong (1, \varnothing)$ and
> $H_L \cong (\varnothing, 1)$. A presheaf $X$ with $|X(K)| = 3$ and
> $|X(L)| = 2$ is the sum
> $$
> X \;\cong\; H_K + H_K + H_K + H_L + H_L,
> $$
> five representables indexed by its five elements. The category of elements
> $\mathcal{E}(X)$ is discrete on those five objects, the projection sends three
> to $K$ and two to $L$, and the colimit of the resulting diagram is that sum, as
> the density theorem predicts.

| Presheaf structure | Under the density theorem |
| --- | --- |
| An element $x \in X(A)$ | an object $(A, x)$ of $\mathcal{E}(X)$ |
| A map $f$ with $(Xf)(x) = x'$ | a map $(A', x') \to (A, x)$ in $\mathcal{E}(X)$ |
| The presheaf $X$ | the colimit of $H_{\bullet}$ over $\mathcal{E}(X)$ |
| A map $X \to Y$ | a cocone on $H_{\bullet} \circ P$ with vertex $Y$ |

The density theorem is dual to the Yoneda lemma; the two are the same statement
seen from opposite sides, one about maps out of representables and one about
maps into them. Together they say that a presheaf category is generated by its
representables under colimits, which makes
$[\mathcal{A}^{\mathrm{op}}, \mathbf{Set}]$ the
[free cocompletion](/category-theory/limits-colimits/colimits) of $\mathcal{A}$.

[^leinster-open]: **Leinster**, _Basic Category Theory_, §6.2 opening — the three questions about limits and colimits in functor categories, and the program of answering them through representability.
[^leinster-621]: **Leinster**, _Basic Category Theory_, §6.2, Lemma 6.2.1 and Proposition 6.2.2 — cones are a limit of hom-sets, hence representables preserve limits; the product and equalizer cases are worked as motivation.
[^leinster-625]: **Leinster**, _Basic Category Theory_, §6.2, Theorem 6.2.5 — limits in a functor category are computed pointwise, with the two-part proof assembling the pointwise limits into a functor and checking universality object by object.
[^leinster-627]: **Leinster**, _Basic Category Theory_, §6.2, Corollary 6.2.6 and Warning 6.2.7 — completeness of $[\mathcal{A}, \mathcal{S}]$ inherited from $\mathcal{S}$, and the caveat that non-pointwise limits can appear when $\mathcal{S}$ is incomplete.
[^leinster-628]: **Leinster**, _Basic Category Theory_, §6.2, Proposition 6.2.8 and Warning 6.2.10 — limits commute with limits (the Fubini analogy), and the counterexample showing products need not commute with sums.
[^leinster-6214]: **Leinster**, _Basic Category Theory_, §6.2, Corollary 6.2.12 and Warning 6.2.14 — the Yoneda embedding preserves limits but not colimits, witnessed by the initial object.
[^leinster-6217]: **Leinster**, _Basic Category Theory_, §6.2, Definition 6.2.16 and Theorem 6.2.17 — the category of elements and the density theorem exhibiting every presheaf as a canonical colimit of representables, secretly dual to Yoneda.
