# Yoneda lemma

In mathematics, the Yoneda lemma is a fundamental result in category theory. It is an abstract result on functors of the type morphisms into a fixed object. It is a vast generalisation of Cayley's theorem from group theory (viewing a group as a miniature category with just one object and only isomorphisms). It allows the embedding of any locally small category into a category of functors (contravariant set-valued functors) defined on that category. It also clarifies how the embedded category, of representable functors and their natural transformations, relates to the other objects in the larger functor category. It is an important tool that underlies several modern developments in algebraic geometry and representation theory. It is named after Nobuo Yoneda.

## Generalities

The Yoneda lemma suggests that instead of studying the locally small category ${\mathcal {C}}$, one should study the category of all functors of ${\mathcal {C}}$ into $\mathbf {Set}$ (the category of sets with functions as morphisms). $\mathbf {Set}$ is a category we think we understand well, and a functor of ${\mathcal {C}}$ into $\mathbf {Set}$ can be seen as a "representation" of ${\mathcal {C}}$ in terms of known structures. The original category ${\mathcal {C}}$ is contained in this functor category, but new objects appear in the functor category, which were absent and "hidden" in ${\mathcal {C}}$. Treating these new objects just like the old ones often unifies and simplifies the theory.
This approach is akin to (and in fact generalizes) the common method of studying a ring by investigating the modules over that ring. The ring takes the place of the category ${\mathcal {C}}$, and the category of modules over the ring is a category of functors defined on ${\mathcal {C}}$.

## Formal statement

Yoneda's lemma concerns functors from a fixed category ${\mathcal {C}}$ to a category of sets, $\mathbf {Set}$. If ${\mathcal {C}}$ is a locally small category (i.e. the hom-sets are actual sets and not proper classes), then each object $A$ of ${\mathcal {C}}$ gives rise to a functor to $\mathbf {Set}$ called a hom-functor. This functor is denoted:
    $h_{A}=\mathrm {Hom} (A,-)$.
The (covariant) hom-functor $h_{A}$ sends $X\in {\mathcal {C}}$ to the set of morphisms $\mathrm {Hom} (A,X)$ and sends a morphism $f\colon X\to Y$ (where $Y\in {\mathcal {C}}$) to the morphism $f\circ -$ (composition with $f$ on the left) that sends a morphism $g$ in $\mathrm {Hom} (A,X)$ to the morphism $f\circ g$ in $\mathrm {Hom} (A,Y)$. That is,
    $h_{A}(f)=\mathrm {Hom} (A,f),{\text{ or}}$
    $h_{A}(f)(g)=f\circ g$
Yoneda's lemma says that:
Lemma (Yoneda) — Let $F$ be a functor from a locally small category ${\mathcal {C}}$ to $\mathbf {Set}$. Then for each object $A$ of ${\mathcal {C}}$, the natural transformations $\mathrm {Nat} (h_{A},F)\equiv \mathrm {Hom} (\mathrm {Hom} (A,-),F)$ from $h_{A}$ to $F$ are in one-to-one correspondence with the elements of $F(A)$. That is,
    $\mathrm {Nat} (h_{A},F)\cong F(A).$
Moreover, this isomorphism is natural in $A$ and $F$ when both sides are regarded as functors from ${\mathcal {C}}\times \mathbf {Set} ^{\mathcal {C}}$ to $\mathbf {Set}$.
Here the notation $\mathbf {Set} ^{\mathcal {C}}$ denotes the category of functors from ${\mathcal {C}}$ to $\mathbf {Set}$.
Given a natural transformation $\Phi$ from $h_{A}$ to $F$, the corresponding element of $F(A)$ is $u=\Phi _{A}(\mathrm {id} _{A})$; and given an element $u$ of $F(A)$, the corresponding natural transformation is given by $\Phi _{X}(f)=F(f)(u)$ which assigns to a morphism $f\colon A\to X$ a value of $F(X)$.

### Contravariant version

There is a contravariant version of Yoneda's lemma, which concerns contravariant functors from ${\mathcal {C}}$ to $\mathbf {Set}$. This version involves the contravariant hom-functor
    $h^{A}=\mathrm {Hom} (-,A),$
which sends $X$ to the hom-set $\mathrm {Hom} (X,A)$. Given an arbitrary contravariant functor $G$ from ${\mathcal {C}}$ to $\mathbf {Set}$, Yoneda's lemma asserts that
    $\mathrm {Nat} (h^{A},G)\cong G(A).$

### Naturality

The bijections provided in the (covariant) Yoneda lemma (for each $A$ and $F$) are the components of a natural isomorphism between two certain functors from ${\mathcal {C}}\times \mathbf {Set} ^{\mathcal {C}}$ to $\mathbf {Set}$.$^{:61}$ One of the two functors is the evaluation functor
    $-(-)\colon {\mathcal {C}}\times \mathbf {Set} ^{\mathcal {C}}\to \mathbf {Set}$
    $-(-)\colon (A,F)\mapsto F(A)$
that sends a pair $(f,\Phi )$ of a morphism $f\colon A\to B$ in ${\mathcal {C}}$ and a natural transformation $\Phi \colon F\to G$ to the map
    $\Phi _{B}\circ F(f)=G(f)\circ \Phi _{A}\colon F(A)\to G(B).$
This is enough to determine the other functor since we know what the natural isomorphism is. Under the second functor
    $\operatorname {Nat} (\hom(-,-),-)\colon {\mathcal {C}}\times \operatorname {Set} ^{\mathcal {C}}\to \operatorname {Set} ,$
    $\operatorname {Nat} (\hom(-,-),-)\colon (A,F)\mapsto \operatorname {Nat} (\hom(A,-),F),$
the image of a pair $(f,\Phi )$ is the map
    $\operatorname {Nat} (\hom(f,-),\Phi )=\operatorname {Nat} (\hom(B,-),\Phi )\circ \operatorname {Nat} (\hom(f,-),F)=\operatorname {Nat} (\hom(f,-),G)\circ \operatorname {Nat} (\hom(A,-),\Phi )$
that sends a natural transformation $\Psi \colon \hom(A,-)\to F$ to the natural transformation $\Phi \circ \Psi \circ \hom(f,-)\colon \hom(B,-)\to G$, whose components are
    $(\Phi \circ \Psi \circ \hom(f,-))_{C}(g)=(\Phi \circ \Psi )_{C}(g\circ f)\qquad (g\colon B\to C).$

### Naming conventions

The use of $h_{A}$ for the covariant hom-functor and $h^{A}$ for the contravariant hom-functor is not completely standard. Many texts and articles either use the opposite convention or completely unrelated symbols for these two functors. However, most modern algebraic geometry texts starting with Alexander Grothendieck's foundational EGA use the convention in this article.
The mnemonic "falling into something" can be helpful in remembering that $h_{A}$ is the covariant hom-functor. When the letter $A$ is falling (i.e. a subscript), $h_{A}$ assigns to an object $X$ the morphisms from $A$ into $X$.

### Proof

Since $\Phi$ is a natural transformation, we have the following commutative diagram:
This diagram shows that the natural transformation $\Phi$ is completely determined by $\Phi _{A}(\mathrm {id} _{A})=u$ since for each morphism $f\colon A\to X$ one has
    $\Phi _{X}(f)=(Ff)u.$
Moreover, any element $u\in F(A)$ defines a natural transformation in this way. The proof in the contravariant case is completely analogous.

### The Yoneda embedding

An important special case of Yoneda's lemma is when the functor $F$ from ${\mathcal {C}}$ to $\mathbf {Set}$ is another hom-functor $h_{B}$. In this case, the covariant version of Yoneda's lemma states that
    $\mathrm {Nat} (h_{A},h_{B})\cong \mathrm {Hom} (B,A).$
That is, natural transformations between hom-functors are in one-to-one correspondence with morphisms (in the reverse direction) between the associated objects. Given a morphism $f\colon B\to A$ the associated natural transformation is denoted $\mathrm {Hom} (f,-)$.
Mapping each object $A$ in ${\mathcal {C}}$ to its associated hom-functor $h_{A}=\mathrm {Hom} (A,-)$ and each morphism $f\colon B\to A$ to the corresponding natural transformation $\mathrm {Hom} (f,-)$ determines a contravariant functor $h_{\bullet }$ from ${\mathcal {C}}$ to $\mathbf {Set} ^{\mathcal {C}}$, the functor category of all (covariant) functors from ${\mathcal {C}}$ to $\mathbf {Set}$. One can interpret $h_{\bullet }$ as a covariant functor:
    $h_{\bullet }\colon {\mathcal {C}}^{\text{op}}\to \mathbf {Set} ^{\mathcal {C}}.$
The meaning of Yoneda's lemma in this setting is that the functor $h_{\bullet }$ is fully faithful, and therefore gives an embedding of ${\mathcal {C}}^{\mathrm {op} }$ in the category of functors to $\mathbf {Set}$. The collection of all functors $\{h_{A}|A\in C\}$ is a subcategory of $\mathbf {Set} ^{\mathcal {C}}$. Therefore, Yoneda embedding implies that the category ${\mathcal {C}}^{\mathrm {op} }$ is isomorphic to the category $\{h_{A}|A\in C\}$.
The contravariant version of Yoneda's lemma states that
    $\mathrm {Nat} (h^{A},h^{B})\cong \mathrm {Hom} (A,B).$
Therefore, $h^{\bullet }$ gives rise to a covariant functor from ${\mathcal {C}}$ to the category of contravariant functors to $\mathbf {Set}$:
    $h^{\bullet }\colon {\mathcal {C}}\to \mathbf {Set} ^{{\mathcal {C}}^{\mathrm {op} }}.$
Yoneda's lemma then states that any locally small category ${\mathcal {C}}$ can be embedded in the category of contravariant functors from ${\mathcal {C}}$ to $\mathbf {Set}$ via $h^{\bullet }$. This is called the Yoneda embedding.
The Yoneda embedding is sometimes denoted by よ, the hiragana Yo.

### Representable functor

The Yoneda embedding essentially states that for every (locally small) category, objects in that category can be represented by presheaves, in a full and faithful manner. That is,
    $\mathrm {Nat} (h^{A},P)\cong P(A)$
for a presheaf P. Many common categories are, in fact, categories of pre-sheaves, and on closer inspection, prove to be categories of sheaves, and as such examples are commonly topological in nature, they can be seen to be topoi in general. The Yoneda lemma provides a point of leverage by which the topological structure of a category can be studied and understood.

### In terms of (co)end calculus

Given two categories $\mathbf {C}$ and $\mathbf {D}$ with two functors $F,G:\mathbf {C} \to \mathbf {D}$, natural transformations between them can be written as the following end.
    $\mathrm {Nat} (F,G)=\int _{c\in \mathbf {C} }\mathrm {Hom} _{\mathbf {D} }(Fc,Gc)$
For any functors $K\colon \mathbf {C} ^{op}\to \mathbf {Sets}$ and $H\colon \mathbf {C} \to \mathbf {Sets}$ the following formulas are all formulations of the Yoneda lemma.
    $K\cong \int ^{c\in \mathbf {C} }Kc\times \mathrm {Hom} _{\mathbf {C} }(-,c),\qquad K\cong \int _{c\in \mathbf {C} }(Kc)^{\mathrm {Hom} _{\mathbf {C} }(c,-)},$
    $H\cong \int ^{c\in \mathbf {C} }Hc\times \mathrm {Hom} _{\mathbf {C} }(c,-),\qquad H\cong \int _{c\in \mathbf {C} }(Hc)^{\mathrm {Hom} _{\mathbf {C} }(-,c)}.$

## Preadditive categories, rings and modules

A preadditive category is a category where the morphism sets form abelian groups and the composition of morphisms is bilinear; examples are categories of abelian groups or modules. In a preadditive category, there is both a "multiplication" and an "addition" of morphisms, which is why preadditive categories are viewed as generalizations of rings. Rings are preadditive categories with one object.
The Yoneda lemma remains true for preadditive categories if we choose as our extension the category of additive contravariant functors from the original category into the category of abelian groups; these are functors which are compatible with the addition of morphisms and should be thought of as forming a module category over the original category. The Yoneda lemma then yields the natural procedure to enlarge a preadditive category so that the enlarged version remains preadditive — in fact, the enlarged version is an abelian category, a much more powerful condition. In the case of a ring $R$, the extended category is the category of all right modules over $R$, and the statement of the Yoneda lemma reduces to the well-known isomorphism
    $M\cong \mathrm {Hom} _{R}(R,M)$ for all right modules $M$ over $R$.

## Relationship to Cayley's theorem

As stated above, the Yoneda lemma may be considered as a vast generalization of Cayley's theorem from group theory. To see this, let ${\mathcal {C}}$ be a category with a single object $*$ such that every morphism is an isomorphism (i.e. a groupoid with one object). Then $G=\mathrm {Hom} _{\mathcal {C}}(*,*)$ forms a group under the operation of composition, and any group can be realized as a category in this way.
In this context, a covariant functor ${\mathcal {C}}\to \mathbf {Set}$ consists of a set $X$ and a group homomorphism $G\to \mathrm {Perm} (X)$, where $\mathrm {Perm} (X)$ is the group of permutations of $X$; in other words, $X$ is a G-set. A natural transformation between such functors is the same thing as an equivariant map between $G$-sets: a set function $\alpha \colon X\to Y$ with the property that $\alpha (g\cdot x)=g\cdot \alpha (x)$ for all $g$ in $G$ and $x$ in $X$. (On the left side of this equation, the $\cdot$ denotes the action of $G$ on $X$, and on the right side the action on $Y$.)
Now the covariant hom-functor $\mathrm {Hom} _{\mathcal {C}}(*,-)$ corresponds to the action of $G$ on itself by left-multiplication (the contravariant version corresponds to right-multiplication). The Yoneda lemma with $F=\mathrm {Hom} _{\mathcal {C}}(*,-)$ states that
    $\mathrm {Nat} (\mathrm {Hom} _{\mathcal {C}}(*,-),\mathrm {Hom} _{\mathcal {C}}(*,-))\cong \mathrm {Hom} _{\mathcal {C}}(*,*)$,
that is, the equivariant maps from this $G$-set to itself are in bijection with $G$. But it is easy to see that (1) these maps form a group under composition, which is a subgroup of $\mathrm {Perm} (G)$, and (2) the function which gives the bijection is a group homomorphism. (Going in the reverse direction, it associates to every $g$ in $G$ the equivariant map of right-multiplication by $g$.) Thus $G$ is isomorphic to a subgroup of $\mathrm {Perm} (G)$, which is the statement of Cayley's theorem.

## History

Yoshiki Kinoshita stated in 1996 that the term "Yoneda lemma" was coined by Saunders Mac Lane following an interview he had with Yoneda in the Gare du Nord station.