Yoneda Lemma

The Yoneda lemma is a result in category theory.

Statement

Let $\mathcal{C}$ be a locally small category, and let $F$ be a functor from $F$ to Set, the category of sets. Let $h_A$ denote the functor $\mathcal{C} \to \mathbf{Set}$ that sends every object $B \in \mathcal{C}$ to $\text{Hom}(A,B)$ and that takes the arrow $f: B \to C$ to the function $h_A f : \text{Hom}(A,B) \to \text{Hom}(A,C)$ given by $\alpha \mapsto f \circ \alpha$. In other words, $h_A$ is the hom functor $\text{Hom}(A,-)$. Then there exists a bijection between the set of natural transformations from $h_A$ to $F$ and the set $F(A)$. In symbols, $$\text{Nat}(h_A, F) \cong F(A) .$$

Proof

Let $\phi : h_A \stackrel{\bullet}{\to} F$ be a natural transformation. Then for each object $B$ of $\mathcal{C}$, $\phi$ gives us an arrow $\phi_B : h_A(B) \to F(B)$ in the category Set, i.e., a function $\phi_B: \text{Hom}(A,B) \to F(B)$, such that the diagram $$\begin{array}{ccc} h_A(A) & \!\stackrel{\phi_A}{\longrightarrow}\! & F(A) \\ \downarrow h_A f && \downarrow Ff \\ h_A(B) & \! \stackrel{\phi_B}{\longrightarrow}\! & F(B) \end{array}$$ commutes for any arrow $f : A \to B$ in $\mathcal{C}$. In particular, we have $$(\phi_B h_A f)(\text{Id}_A) = (Ff \phi_A) ( \text{Id}_A) .$$ But $h_A f$ is the map $\alpha \mapsto f \circ \alpha$ from $\text{Hom}(A,A)$ to $\text{Hom}(A,B)$. We thus have $$\phi_B (f) = \phi_B (f \circ \text{Id}_A) = Ff (\phi_A \text{Id}_A) .$$ Thus for every object $B$ of $\mathcal{C}$, the morphism $\phi_B$ is uniquely determined by the element $\phi_A \text{Id}_A$. Thus the map $\phi \mapsto \phi_A \text{Id}_A$ is an injection from $\text{Nat}(h_A, F)$ to $F(A)$.

It thus remains to be shown that for any $x \in F(A)$, the maps $$\phi_B : f \mapsto F f x$$ for every object $B$ of $\mathcal{C}$ define a natural transformation. But this is true, as for any objects $B$ and $C$ of $\mathcal{C}$, any morphism $f : B \to C$ of $\mathcal{C}$, and any element $\alpha$ of $h_A(B) = \text{Hom}(A,B)$, we have $$\phi_C h_A f (\alpha) = \phi_C f \alpha = F (f \alpha) x = (F f )(F\alpha) x = (F f) \phi_B (\alpha) ,$$ since $F$ is a functor. Thus the diagram $$\begin{array}{ccc} h_A(B) & \!\stackrel{\phi_B}{\longrightarrow}\! & F(B) \\ \downarrow h_A f && \downarrow F f \\ h_A (C) & \!\stackrel{\phi_C}{\longrightarrow}\! & F(C) \end{array}$$ commutes, so $\phi$ is a natural transformation, as desired.

Therefore the map $\phi \mapsto \phi_A \text{Id}_A$ is a bijection between $\text{Nat}(h_A, F)$ and $F(A)$, as desired. $\blacksquare$

Dual Statement

If we replace the category $\mathcal{C}$ with its opposite category $\mathcal{C}^{\text{op}}$, then we get the following result: if $F$ is a contravariant functor from $\mathcal{C}$ to Set, then $$\text{Nat} \bigl( \text{Hom}( - ,A), F \bigr) \cong F(A)$$ for every object $A$ of $\mathcal{C}$. This dual statement is also sometimes known as the Yoneda lemma.