The Yoneda Lemma

Jeffery MensahSeptember 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 ⁣:CopSet\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 ⁣:VU\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 UXU \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);ffι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 UXU \subseteq X are given by continuous maps σ ⁣:UEt(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 HomC(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 fHom(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 ff^* when the presheaf F\mathcal{F} is understood.

Representable Presheaves

Let FPSh(C)\mathcal{F} \in \mathbf{PSh}(\mathscr{C}) be a presheaf and UFU \in \mathcal{F}. Given a section sF(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 UXU \subseteq X and a section sF(U)s \in \mathcal{F}(U) we may construct the subpresheaf FU,s\mathcal{F}_{U, s} given by

FU,s(V)={{sV}if VUif 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 fHom(V,U)f \in \operatorname{Hom}(V, U), we must include the pullback fsf^* 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 VCV \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 fHom(V,W)f \in \operatorname{Hom}(V, W) is given by

f=defHom(,U)(f) ⁣:Hom(W,U)Hom(V,U);fs=defsf.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 UCU \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 sG(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 GH\mathcal{G} \Rightarrow \mathcal{H} which maps sts \mapsto t.

Proposition. The presheaf Hom(,U)\operatorname{Hom}(-, U) with distinguished section idU\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 sF(U)s \in \mathcal{F}(U). Then there exists a morphism ϕ ⁣:Hom(,U)F\phi \colon \operatorname{Hom}(-, U) \Rightarrow \mathcal{F} given by ffs=[F(f)](s)f \mapsto f^*s = [\mathcal{F}(f)] (s). In other words, ϕ\phi maps a section fHom(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 ⁣:VWg \colon V \to W in C\mathscr{C}. Then the diagram

W Hom(W,U)ϕF(W)g ggV 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 fHom(W,U)f \in \operatorname{Hom}(W, U) we have g(fs)=(fg)s=(gf)sg^*(f^*s) = (f \circ g)^*s = (g^* f)^* s. Moreover, the identity idU\operatorname{id}_U is mapped to the distinguished section ss, since idUs=s{\operatorname{id}_U}^* s = s. Hence, ϕ\phi defines a morphism (Hom(,U),idU)(F,s)(\operatorname{Hom}(-, U), \operatorname{id}_U) \to ( \mathcal{F}, s).

Conversely, to show uniqueness, suppose that ψ ⁣:(Hom(,U),idU)(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 fHom(V,U)f \in \operatorname{Hom}(V, U), since

ψV(f)=ψV(fidU)=f(ψU(idU))=fs.\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 fHomC(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 WgVfUW \overset{g}{\to} V \overset{f}{\to} U be a sequence of morphisms. Then

idW ⁣(g)W(g=gidV) ⁣(f)V(gf=fg).\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  ⁣(fg)= ⁣(f) ⁣(g)\!\text{よ}(f \circ g) = \!\text{よ}(f) \circ \!\text{よ}(g).

\blacksquare

Explicitly,  ⁣(f)\!\text{よ}(f) is the pushforward along ff, taking sHom(W,V)s \in \mathrm{Hom}(W, V) and mapping it to fs=fsHom(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 UCU \in \mathscr{C}, then there is an isomorphism of sets

evU,F ⁣:HomPSh(C)(HU,F)F(U);ϕϕU(idU).\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 sF(U)s \in \mathcal{F}(U), there exists a unique morphism ϕ ⁣:HUF\phi \colon H_U \to \mathcal{F} such that ϕU(idU)=s\phi_U(\operatorname{id}_U) = s, since (HU,idU)(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 UF(U)U \mapsto \mathcal{F}(U) is functorial by the definition of a presheaf. Likewise, for fixed UU, the map FF(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 UHUU \mapsto H_U is a functor, and HomPsh(C)(,)\operatorname{Hom}_{\mathbf{Psh}(\mathscr{C})}(-, -) is a bifunctor, which implies that (U,F)HomPSh(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 fHom(V,U)f \in \operatorname{Hom}(V, U). Then for all presheaf morphisms ϕHomPSh(C)(HU,F)\phi \in \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathcal{F}), we have

evV,F([Byoneda(f,idF)](ϕ))=evV,F(ϕ ⁣(f))=ϕV([ ⁣(f)]V(idV))=ϕ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,idF)](evU,F(ϕ))=[Bpairing(f,idF)](ϕU(idU))=fϕU(idU)=ϕ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 ψ ⁣:FG\psi \colon \mathcal{F} \Rightarrow \mathcal{G}. Then for all presheaf morphisms ϕHomPSh(C)(HU,F)\phi \in \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathcal{F}), we have

evU,G([Byoneda(idU,ψ)](ϕ))=evU,G(ψϕ)=(ψUϕU)(idU). \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(idU,ψ)](evU,F(ϕ))=[Bpairing(idU,ψ)](ϕU(idU))=ψU(ϕU(idU)).\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 ⁣:HomPSh(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}.