The Yoneda Lemma

Jeffery Mensah • September 30, 2024∼1750 words

The Yoneda lemma, according to Ravil Vakil in Foundations of Algebraic Geometry, is an "important exercise you should do once in your life." In this post, we give a slight variant of the usual proof and explain the idea behind the lemma.

Presheaves

In category theory, a presheaf is a mild generalization of the usual geometric notion of a presheaf. Instead of attaching data to each open set of a topological space, we attach data to each object in a category. More precisely, a presheaf on a category C\mathscr{C} is a functor F ⁣:Cop→Set\mathcal{F} \colon \mathscr{C}^{\rm op} \to \mathbf{Set}. Morphisms between presheaves are defined to be natural transformations of these functors. Together, these form the category of presheaves on C\mathscr{C}, denoted by PSh(C)\mathbf{PSh}(\mathscr{C}).

Example. For a topological space XX, let C=Open(X)\mathscr{C} = \mathbf{Open}(X) be the category of open subsets of XX, whose morphisms are inclusions ιV,U ⁣:V↪U\iota_{V, U} \colon V \hookrightarrow U of open sets. A typical example of a presheaf on this category is the presheaf of continuous real-valued functions, denoted by F=C0(−,R)\mathcal{F} = \mathrm{C}^0(-, \mathbb{R}).

This presheaf attaches to each open subset U⊆XU \subseteq X a set of sections F(U)=C0(U,R)\mathcal{F}(U) = \mathrm{C}^0(U, \mathbb{R}), visualized as graphs lying over UU. For each inclusion ιV,U\iota_{V, U}, we define a restriction map which takes a section over UU and restricts it to VV. Specifically, we define

F(ιV,U)=ιV,U∗ ⁣:F(U)→F(V);f↦f∘ιV,U.\mathcal{F}(\iota_{V, U}) = \iota_{V, U}^* \colon \mathcal{F}(U) \to \mathcal{F}(V); \quad \quad f \mapsto f \circ \iota_{V, U}.

In fact, any presheaf or sheaf on Open(X)\mathbf{Open}(X) can be interpreted as arising from the sheaf of continuous sections to a larger space sitting above XX, known as the étale space, Et⁡(F)\operatorname{Et}(\mathcal{F}). The étale space comes with a natural projection π ⁣:Et⁡(F)→X\pi \colon \operatorname{Et}(\mathcal{F}) \to X, and sections over U⊆XU \subseteq X are given by continuous maps σ ⁣:U→Et⁡(F)\sigma \colon U \to \operatorname{Et}(\mathcal{F}) such that π∘σ=idU\pi \circ \sigma = \mathrm{id}_U.

In the above example, HomOpen(X)(V ⁣,U)\mathrm{Hom}_{\mathbf{Open}(X)}(V\!, U) has at most one morphism, determining whether or not VV is contained in UU. Using this as intuition for a general category C\mathscr{C}, we similarly think of Hom⁡C(V,U)\operatorname{Hom}_{\mathscr{C}}(V, U) as comprising all of the ways in which the structure of VV can "fit inside" the structure of UU.

Given a presheaf F\mathcal{F} on C\mathscr{C}, we think of each section over UU as a way of fitting the data of UU inside of F\mathcal{F}, much like in the étale space viewpoint. Then for f∈Hom⁡(V,U)f \in \operatorname{Hom}(V, U), the map F(f) ⁣:F(U)→F(V)\mathcal{F}(f) \colon \mathcal{F}(U) \to \mathcal{F}(V) takes each occurrence of UU in F\mathcal{F} and "restricts" it to obtain a suboccurrence of VV in F\mathcal{F} (this is also the intuition suggested in nLab article on presheaves).

In this article, we will call the map F(f)\mathcal{F}(f) the pullback by ff and denote it by f∗f^* when the presheaf F\mathcal{F} is understood.

Representable Presheaves

Let F∈PSh(C)\mathcal{F} \in \mathbf{PSh}(\mathscr{C}) be a presheaf and U∈FU \in \mathcal{F}. Given a section s∈F(U)s \in \mathcal{F}(U), what is the minimal subpresheaf containing ss? To construct this, we intuitively must "throw away" or "cut out" all sections of F\mathcal{F} which don't fit inside ss.

Example. Let XX be a topological space and F\mathcal{F} be a presheaf on XX. Given an open set U⊆XU \subseteq X and a section s∈F(U)s \in \mathcal{F}(U) we may construct the subpresheaf FU,s\mathcal{F}_{U, s} given by

FU,s(V)={{s∣V}if V⊆U∅if V⊈U.\mathcal{F}_{U, s}(V) = \begin{cases} \{s|_{V}\} &\text{if } V \subseteq U \\ \varnothing &\text{if } V \not\subseteq U \\ \end{cases}.

This subpresheaf consists of all the restrictions of ss, and nothing more.

In general, for every f∈Hom⁡(V,U)f \in \operatorname{Hom}(V, U), we must include the pullback f∗sf^* s as a section of the minimal subpresheaf. To formalize this notion, consider the functor Hom⁡(−,U)\operatorname{Hom}(-, U), which may be interpreted as the presheaf of morphisms to U\hspace{0.5pt}U. By definition, the sections of this presheaf over an object V∈CV \in \mathscr{C} are given by Hom⁡(−,U)(V)=Hom⁡(V,U)\operatorname{Hom}(-, U)(V)= \operatorname{Hom}(V, U), and the pullback along a morphism f∈Hom⁡(V,W)f \in \operatorname{Hom}(V, W) is given by

f∗=defHom⁡(−,U)(f) ⁣:Hom⁡(W,U)→Hom⁡(V,U);f∗s=defs∘f.f^* \overset{\mathrm{def}}{=} \operatorname{Hom}(-, U)(f) \colon \operatorname{Hom}(W, U) \to \operatorname{Hom}(V, U); \quad\quad f^*s \overset{\mathrm{def}}{=} s \circ f.

Given U∈CU \in \mathscr{C}, let us call a pair (G,s)(\mathcal{G}, s), where G\mathcal{G} is a presheaf on C\mathscr{C} and s∈G(U)s \in \mathcal{G}(U) a presheaf on C\mathscr{C} with a distinguished section on  U\,U. These form a category PSh∙(C,U)\mathbf{PSh}_{\bullet}(\mathscr{C}, U) where a morphism between objects (G,s)(\mathcal{G}, s) and (H,t)(\mathcal{H}, t) is defined to be a morphism of presheaves G⇒H\mathcal{G} \Rightarrow \mathcal{H} which maps s↦ts \mapsto t.

Proposition. The presheaf Hom⁡(−,U)\operatorname{Hom}(-, U) with distinguished section id⁡U\operatorname{id}_U is an initial object of PSh∙(C,U)\mathbf{PSh}_{\bullet}(\mathscr{C}, U).

Proof. Let F\mathcal{F} be a presheaf with a distinguished section s∈F(U)s \in \mathcal{F}(U). Then there exists a morphism ϕ ⁣:Hom⁡(−,U)⇒F\phi \colon \operatorname{Hom}(-, U) \Rightarrow \mathcal{F} given by f↦f∗s=[F(f)](s)f \mapsto f^*s = [\mathcal{F}(f)] (s). In other words, ϕ\phi maps a section f∈Hom⁡(V,U)f \in \operatorname{Hom}(V, U) to the pullback of the distinguished section ss, which is a once again section over VV (but in F\mathcal{F}). To check that this defines a morphism of presheaves, consider a morphism g ⁣:V→Wg \colon V \to W in C\mathscr{C}. Then the diagram

W Hom⁡(W, U)→ϕF(W)g↑ g∗↓g∗↓V Hom⁡(V, U)→ϕF(V)\begin{CD} W @. @. \operatorname{Hom}(W,\, U) @>\phi>> \mathcal{F}(W) \\ @AgAA @. @Vg^*VV @Vg^*VV \\ V @. @.\operatorname{Hom}(V,\, U) @>\phi>> \mathcal{F}(V) \end{CD}

commutes, since for all f∈Hom⁡(W,U)f \in \operatorname{Hom}(W, U) we have g∗(f∗s)=(f∘g)∗s=(g∗f)∗sg^*(f^*s) = (f \circ g)^*s = (g^* f)^* s. Moreover, the identity id⁡U\operatorname{id}_U is mapped to the distinguished section ss, since id⁡U∗s=s{\operatorname{id}_U}^* s = s. Hence, ϕ\phi defines a morphism (Hom⁡(−,U),id⁡U)→(F,s)(\operatorname{Hom}(-, U), \operatorname{id}_U) \to ( \mathcal{F}, s).

Conversely, to show uniqueness, suppose that ψ ⁣:(Hom⁡(−,U), id⁡U)→(F,s)\psi \colon (\operatorname{Hom}(-, U),\, \operatorname{id}_U) \to ( \mathcal{F}, s) is a morphism of presheaves with distinguished sections on UU. Then ψV(f)\psi_V(f) is automatically determined for all sections f∈Hom⁡(V,U)f \in \operatorname{Hom}(V, U), since

ψV(f)=ψV(f∗id⁡U)=f∗(ψU(id⁡U))=f∗s.\psi_V(f) = \psi_V(f^*\operatorname{id}_U) = f^*\big(\psi_U(\operatorname{id}_U)\big) = f^*s.

■\blacksquare

We call the initial object Hom⁡(−,U)\operatorname{Hom}(-, U) of PSh∙(C,U)\mathbf{PSh}_{\bullet}(\mathscr{C}, U) the presheaf represented by  U\,U and denote it by HUH_U. In a sense, this is the "least specific" presheaf on C\mathscr{C} which contains a section over UU. The map taking an object to the presheaf it represents is known as the Yoneda embedding, which we denote by  ⁣よ\!\text{よ}.

Proposition. The Yoneda embedding defines a functor as follows: given f∈HomC(V,U)f \in \mathrm{Hom}_{\mathscr{C}}(V, U) define  ⁣よ(f)\!\text{よ}(f) to be the underlying map of the unique map (HV,idV)→(HU,f)(H_V, \mathrm{id}_V) \to (H_U, f) in PSh∙(C,V)\mathbf{PSh}_\bullet(\mathscr{C}, V).

Proof. Let W→gV→fUW \overset{g}{\to} V \overset{f}{\to} U be a sequence of morphisms. Then

idW⟼ ⁣よ(g)W(g=g∗id⁡V)⟼ ⁣よ(f)V(g∗f=f∘g).\mathrm{id}_W \overset{\!\text{よ}(g)_W}{\longmapsto} (g = g^*\operatorname{id}_V) \overset{\!\text{よ}(f)_V}{\longmapsto} (g^*f = f \circ g).

By uniqueness of maps from initial objects, it follows that  ⁣よ(f∘g)= ⁣よ(f)∘ ⁣よ(g)\!\text{よ}(f \circ g) = \!\text{よ}(f) \circ \!\text{よ}(g).

■\blacksquare

Explicitly,  ⁣よ(f)\!\text{よ}(f) is the pushforward along ff, taking s∈Hom(W,V)s \in \mathrm{Hom}(W, V) and mapping it to f∗s=f∘s∈Hom(W,U)f_*s = f \circ s \in \mathrm{Hom}(W, U). Indeed, the pushforward commutes with pullbacks, making it into a morphism of presheaves mapping the identity section over VV to ff; by definition, this must be the Yoneda embedding.

The Yoneda Lemma

We now state and prove the Yoneda lemma.

Theorem (Yoneda lemma). Let C\mathscr{C} be a category. If F\mathcal{F} is a presheaf on C\mathscr{C} and U∈CU \in \mathscr{C}, then there is an isomorphism of sets

evU, F ⁣:Hom⁡PSh(C)(HU,F)→≅F(U);ϕ⟼ϕU(id⁡U).\mathrm{ev}_{U,\, \mathcal{F}}\colon \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathcal{F}) \xrightarrow{\cong} \mathcal{F}(U); \quad \phi \overset{\mathrm{}}\longmapsto \phi_U(\operatorname{id}_U).

Moreover, this a natural isomorphism of bifunctors Cop×PSh(C)→Set\mathscr{C}^{\rm op} \times \mathbf{PSh}(\mathscr{C}) \to \mathbf{Set}.

Proof. For any section s∈F(U)s \in \mathcal{F}(U), there exists a unique morphism ϕ ⁣:HU→F\phi \colon H_U \to \mathcal{F} such that ϕU(id⁡U)=s\phi_U(\operatorname{id}_U) = s, since (HU,id⁡U)(H_U, \operatorname{id}_U) is initial in PSh∙(C,U)\mathbf{PSh}_{\bullet}(\mathscr{C}, U). It follows that the evaluation map evU, F\mathrm{ev}_{U,\, \mathcal{F}} is a bijection.

For fixed F\mathcal{F}, the map U↦F(U)U \mapsto \mathcal{F}(U) is functorial by the definition of a presheaf. Likewise, for fixed UU, the map F↦F(U)\mathcal{F} \mapsto \mathcal{F}(U) is functorial by the definition of the presheaf category. Thus, (U,F)↦F(U)(U, \mathcal{F}) \mapsto \mathcal{F}(U) defines a bifunctor Bpairing\mathscr{B}_{\rm pairing}.

On the other hand, the Yoneda embedding U↦HUU \mapsto H_U is a functor, and Hom⁡Psh(C)(−,−)\operatorname{Hom}_{\mathbf{Psh}(\mathscr{C})}(-, -) is a bifunctor, which implies that (U,F)↦Hom⁡PSh(C)(HU,F)(U, \mathcal{F}) \mapsto \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathcal{F}) also defines a bifunctor Byoneda\mathscr{B}_{\rm yoneda}.

It remains to show that the two bifunctors are naturally isomorphic. For this, it suffices to check that they are natural on each factor. So, let f∈Hom⁡(V,U)f \in \operatorname{Hom}(V, U). Then for all presheaf morphisms ϕ∈Hom⁡PSh(C)(HU,F)\phi \in \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathcal{F}), we have

evV, F([Byoneda(f,id⁡F)](ϕ))=evV, F(ϕ∘ ⁣よ(f))=ϕV([ ⁣よ(f)]V(id⁡V))=ϕV(f).\mathrm{ev}_{V,\,\mathcal{F}} \Big( \big[\mathscr{B}_{\rm yoneda}(f, \operatorname{id}_{\mathcal{F}})\big] (\phi) \Big) = \mathrm{ev}_{V,\,\mathcal{F}}\big(\phi \circ \!\text{よ}(f)\big) = \phi_V\Big([\!\text{よ}(f)]_V (\operatorname{id}_V)\Big) = \phi_V(f).

At the same time, we have

[Bpairing(f,id⁡F)](evU, F(ϕ))=[Bpairing(f,id⁡F)](ϕU(id⁡U))=f∗ϕU(id⁡U)=ϕV(f).\big[\mathscr{B}_{\rm pairing}(f, \operatorname{id}_\mathcal{F})\big] \big(\mathrm{ev}_{U, \,\mathcal{F}} (\phi)\big) = \big[\mathscr{B}_{\rm pairing}(f, \operatorname{id}_\mathcal{F})\big] \big(\phi_U(\operatorname{id}_U)\big) = f^*\phi_U(\operatorname{id}_U) = \phi_V(f).

Therefore, the bifunctor isomorphism is natural in the first factor. For the second factor, consider a presheaf morphism ψ ⁣:F⇒G\psi \colon \mathcal{F} \Rightarrow \mathcal{G}. Then for all presheaf morphisms ϕ∈Hom⁡PSh(C)(HU,F)\phi \in \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathcal{F}), we have

evU, G([Byoneda(id⁡U,ψ)](ϕ))=evU, G(ψ∘ϕ)=(ψU∘ϕU)(id⁡U). \mathrm{ev}_{U,\,\mathcal{G}} \Big( \big[\mathscr{B}_{\rm yoneda}(\operatorname{id}_{U}, \psi)\big] (\phi) \Big) = \mathrm{ev}_{U,\,\mathcal{G}} \big(\psi \circ \phi) = \big(\psi_U \circ \phi_U\big)(\operatorname{id}_U) .

At the same time, we have

[Bpairing(id⁡U,ψ)](evU,F(ϕ))=[Bpairing(id⁡U,ψ)](ϕU(id⁡U))=ψU(ϕU(id⁡U)).\big[\mathscr{B}_{\rm pairing}(\operatorname{id}_U, \psi)\big] \big(\mathrm{ev}_{U, \mathcal{F}} (\phi)\big) = \big[\mathscr{B}_{\rm pairing}(\operatorname{id}_U, \psi)\big] \big(\phi_U(\operatorname{id}_U)\big) = \psi_U(\phi_U(\operatorname{id}_U)) .

Therefore, the bifunctor isomorphism is also natural in the second factor. It follows that the evaluation bifunctor ev\mathrm{ev} is natural, which concludes the argument.

■\blacksquare

The Yoneda Embedding

The Yoneda lemma implies that there is an isomorphism

evU, V ⁣:Hom⁡PSh(C)(HU,HV)⟶≅Hom⁡(U,V)\mathrm{ev}_{U,\, V}\colon \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, H_V) \overset{\cong}{\longrightarrow} \operatorname{Hom}(U, V)

which implies that the Yoneda embedding functor is fully faithful. In particular, an isomorphism of representable presheaves in PSh(C)\mathbf{PSh}(\mathscr{C}) must be induced by an isomorphism of their representing objects in C\mathscr{C}. This can expressed as the following principle, whose importance cannot be understated:

To understand an object XX in a category C\mathscr{C}, it suffices to understand how XX relates to every other object in C\mathscr{C}.