The Yoneda Lemma
The Yoneda lemma computes the natural transformations out of a representable presheaf: they form a set in natural bijection with X(A). The proof fixes a single degree of freedom, the image of the identity arrow, and shows naturality forces everything else.
╌╌╌╌
Fix a locally small category , an object , and a presheaf . The representable presheaf and the arbitrary presheaf are both objects of the functor category , so it makes sense to ask what the maps between them are. The maps are natural transformations, and they form the set . The Yoneda lemma identifies this set exactly.1
The answer is guessable from an informal principle: from a piece of input data there is usually only one output of a given type that can be built. The input here is a pair . One set built from it is the collection of natural transformations . Another is itself, obtained by evaluating at . The principle suggests these are the same set, and they are.
Informally: a natural transformation is an element of . The lemma holds equally in covariant form, with and a covariant ; the statement above uses presheaves to match the Yoneda embedding.
The explicit bijection
The bijection has an explicit form. Given a natural transformation , its component at is a function . Feed it the one canonical element of , the identity , and record the result.
The formula for is forced: lives in , a map gives , and applying it to is the only element of that and produce. The Yoneda lemma asserts that and are mutually inverse bijections, natural in and . The proof does four things: define each map (done above), then check each composite is an identity.
The proof
The map is natural. For a map in , naturality of is the square below, whose top edge is and whose bottom edge is .
Chasing : the top-then-right route gives , and the left-then-bottom route gives . Functoriality makes the two equal, so the square commutes and is a genuine natural transformation.
The composite . Directly,
using .
The composite . Two natural transformations agree iff all components agree, and two functions agree iff they agree on every element, so it suffices to fix and and show . The left side unfolds to
so the claim is . This is exactly what naturality of supplies. Naturality of at the map is the square
evaluated at . The top edge sends to , so the right-then-down route is ; the left-then-down route is ; commutativity equates them. (In the figure the components are labelled .) This establishes the bijection for each fixed and .
The chase records the structural content of the lemma:
Naturality in both variables
The bijection is not merely one bijection per pair ; the whole family is natural. By a standard lemma it is enough to check naturality of one of the two maps, and by another it is enough to check naturality separately in each variable. Take .
- Naturality in . A map induces on transformations and on values, and for , the last step by the identity-arrow computation above. So the naturality square in commutes.
- Naturality in . A map of presheaves induces on transformations and on values, and using componentwise composition in . So the naturality square in commutes.
Both squares commute, so the bijection is natural in , completing the
proof. Naturality distinguishes there exists a bijection
from the bijection is canonical.
Without it, one could iterate the
construction with and manufacture an infinite sequence of presheaves
. The Yoneda lemma says naturally, so the sequence
never leaves .
The covariant form and duality
Replacing by dualizes the lemma. A presheaf on is a covariant functor , and the representable presheaf at becomes the covariant hom-functor , so the dual statement reads
naturally in and . The explicit maps are the same up to reversal: a natural transformation corresponds to , and an element induces the transformation with components for .2 Nothing new needs proving; both forms are used freely, the contravariant one because the Yoneda embedding lands in presheaves, the covariant one because forgetful and hom-set functors are covariant.
| Form | Representable | Statement | Element inducing |
|---|---|---|---|
| Contravariant | |||
| Covariant |
Directed graphs
For a computation where every set can be written down, take directed graphs. A graph is a pair of sets with source and target functions, which is exactly a set-valued functor on a two-object category: let have objects and and two non-identity arrows . A presheaf assigns a set of edges, a set of nodes, and two functions giving each edge its source and target.3
The representable presheaf has
so is the graph with one node and no edges. The Yoneda lemma then says, for any graph ,
a map from the one-node graph into is the same as a node of . This is visibly true: a graph map out of a single node picks a node and nothing else, and the identity-arrow chase is one line, since the only element of to chase is .
The representable works the same way: and , with and sending to and respectively. So is the graph with two nodes and a single edge from one to the other, and Yoneda gives : maps from the single-edge graph into are the edges of . Again this is visible directly, since placing the generic edge into means choosing an edge together with its (determined) endpoints. In both cases the lemma converts a statement about all components of a natural transformation at once into a statement about a single generator.
The one-object case
The lemma's content is visible already for a monoid viewed as a one-object category, where a presheaf is a right -set.4 The unique representable presheaf is the right regular representation: the underlying set of acted on by right multiplication, . Write it . For any right -set and any , there is a unique map of -sets with , namely . So maps correspond bijectively to elements of :
This is the Yoneda lemma for a one-object category, with the abstract made concrete as the underlying set of the -set . A map out of the regular representation is a choice of where to send the generator , and equivariance forces the rest.
Because a map is an element of , taking to be another representable shows that maps of representables are exactly maps of objects, so the Yoneda embedding is full and faithful, and an object is determined by the maps into it.
Footnotes
- Leinster, Basic Category Theory, §4.2 — The Yoneda lemma: statement, the informal
one output per input
heuristic, and the four-part proof by defining and and chasing . ↩ - Barr & Wells, Category Theory for Computing Science, §4.5.6–4.5.8 — the covariant statement: an element induces the natural transformation by , and this assignment is a bijection. ↩
- Barr & Wells, Category Theory for Computing Science, §4.3.10 and §4.5.1 — the set-of-nodes functor on graphs is represented by the one-node graph, and the set-of-arrows functor by the graph with two nodes and one arrow. ↩
- Leinster, Basic Category Theory, §4.2, Exercise 4.2.3 — the Yoneda lemma for one-object categories: the unique representable is the right regular representation, and maps out of it correspond to elements. Barr & Wells, Theorem 4.5.8, states the same correspondence via the formula . ↩
╌╌ END ╌╌