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." This fundamental result is often said to be difficult to conceptualize. In this post, we present a variant of the usual proof and explain in a plain manner 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, let C\mathscr{C} be a small category. A presheaf on C\mathscr{C} is a functor F ⁣:CopSet\mathscr{F} \colon \mathscr{C}^{\rm op} \to \mathbf{Set}. We denote the category of presheaves on C\mathscr{C}, with morphisms being natural transformations of functors, by PSh(C)\mathbf{PSh}(\mathscr{C}).

It is instructive to examine the prototypical case, where C=Open(X)\mathscr{C} = \mathbf{Open}(X) for some topological space XX. Here, the objects of C\mathscr{C} are the open sets of XX and the morphisms are given by the inclusions of open sets. We can view Open(X)\mathbf{Open}(X) as a subcategory of Top\mathbf{Top} by corresponding each inclusion VUV \subseteq U to its associated embedding ιV,U ⁣:VU\iota_{V, U} \colon V \to U. In this setting, a presheaf F\mathscr{F} on XX attaches to each open subset UXU \subseteq X a set of sections F(U)\mathscr{F}(U); furthermore, for each inclusion ιV,U\iota_{V, U}, there is a corresponding restriction map resU,V\operatorname{res}_{U, V} which takes a section in F(U)\mathscr{F}(U) and restricts it to obtain a section in F(V)\mathscr{F}(V). Any presheaf or sheaf on a topological space 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}(\mathscr{F}). Here, sections in F(U)\mathscr{F}(U) correspond to subspaces of Et(F)\operatorname{Et}(\mathscr{F}) which lie over UU, and resV,U(s)\operatorname{res}_{V, U}(s) is just the set-theoretic restriction, which may also be written as the pullback ιV,Us\iota_{V, U}^* s.

In the general case, we can 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, and the set of sections F(U)\mathscr{F}(U) can be thought as representing all the ways the data of UU fits inside of F\mathscr{F}, much like in the étale space point-of-view; this is the viewpoint suggested on the nLab article on presheaves. Given a morphism fHom(V,U)f \in \operatorname{Hom}(V, U), the analog of the restriction map is the morphism F(f) ⁣:F(U)F(V)\mathscr{F}(f) \colon \mathscr{F}(U) \to \mathscr{F}(V). In this article, we will call this map the pullback by ff and denote it by ff^* when the presheaf F\mathscr{F} is understood.

Representable Presheaves

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

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

FU,s(V)={{sV}if VUif V⊈U.\mathscr{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 morphism 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 Hom-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 on VCV \in \mathscr{C} are given by Hom(,U)(V)=Hom(V,U)\operatorname{Hom}(-, U)(V)= \operatorname{Hom}(V, U), and the pullback by 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.

Definition. Let C\mathscr{C} be a category and let UCU \in \mathscr{C} be an object. Define a presheaf on C\mathscr{C} with a distinguished section on UU to be a pair (G,s)(\mathscr{G}, s), where GPSh(C)\mathscr{G} \in \mathbf{PSh}(\mathscr{C}) is a presheaf and sG(U)s \in \mathscr{G}(U). These form a category PSh(C,U)\mathbf{PSh}^{\bullet}(\mathscr{C}, U) where a morphism between objects (G,s)(\mathscr{G}, s) and (H,t)(\mathscr{H}, t) is defined to be a morphism of presheaves GH\mathscr{G} \Rightarrow \mathscr{H} which maps sts \mapsto t.

Proposition. The presheaf Hom(,U)\operatorname{Hom}(-, U) with distinguished section idU\operatorname{id}_U is the initial object of PSh(C,U)\mathbf{PSh}^{\bullet}(\mathscr{C}, U).

Proof. Let F\mathscr{F} be a presheaf with a distinguished section sF(U)s \in \mathscr{F}(U). Then there exists a morphism ϕ ⁣:Hom(,U)F\phi \colon \operatorname{Hom}(-, U) \Rightarrow \mathscr{F} given by ffs=[F(f)](s)f \mapsto f^*s = [\mathscr{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\mathscr{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>> \mathscr{F}(W) \\ @AgAA @. @Vg^*VV @Vg^*VV \\ V @. @.\operatorname{Hom}(V,\, U) @>\phi>> \mathscr{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 ( \mathscr{F}, s).

Conversely, to show uniqueness, suppose that ψ ⁣:(Hom(,U),idU)(F,s)\psi \colon (\operatorname{Hom}(-, U),\, \operatorname{id}_U) \to ( \mathscr{F}, s) is a morphism of presheaves distinguished 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 UU 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 mapping  ⁣:CPSh(C)\text{よ}\colon \mathscr{C} \to \mathbf{PSh}(\mathscr{C}) defines a functor by mapping fHom(V,U)f \in \operatorname{Hom}(V, U) to the underlying morphism (f)\text{よ}(f) of the unique morphism (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, it follows that (fg)=(f)(g)\text{よ}(f \circ g) = \text{よ}(f) \circ \text{よ}(g) (this can also be proved directly, of course).

\blacksquare

Yoneda's Lemma

We now state and prove Yoneda's lemma.

Theorem (Yoneda's lemma). Let C\mathscr{C} be a category. If F\mathscr{F} is a presheaf on C\mathscr{C} and UCU \in \mathscr{C} is an object, then there is an isomorphism of sets

evU,F ⁣:HomPSh(C)(HU,F)F(U);ϕϕU(idU).\mathrm{ev}_{U,\, \mathscr{F}}\colon \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathscr{F}) \xrightarrow{\sim} \mathscr{F}(U); \quad \phi \overset{\mathrm{}}\longmapsto \phi_U(\operatorname{id}_U).

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

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

For fixed F\mathscr{F}, the map UF(U)U \mapsto \mathscr{F}(U) defines a functor taking fff \mapsto f^*, which follows by the definition of a presheaf. Likewise, for fixed UU, the assignment FF(U)\mathscr{F} \mapsto \mathscr{F}(U) defines a functor taking a presheaf morphism to its component at UU, which follows by the definition of the presheaf category. It follows that the map (U,F)F(U)(U, \mathscr{F}) \mapsto \mathscr{F}(U) defines a bifunctor Bpairing\mathscr{B}_{\rm pairing} from the product category.

On the other hand, the Yoneda embedding UHUU \mapsto H_U is a functor, and Hom(,)\operatorname{Hom}(-, -) is a bifunctor, so it follows that (U,F)HomPSh(C)(HU,F)(U, \mathscr{F}) \mapsto \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathscr{F}) also defines a bifunctor Byoneda\mathscr{B}_{\rm yoneda} from the product category.

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, \mathscr{F}), we have

evV,F([Byoneda(f,idF)](ϕ))=evV,F(ϕ(f))=ϕV([(f)]V(idV))=ϕV(f).\mathrm{ev}_{V,\,\mathscr{F}} \Big( \big[\mathscr{B}_{\rm yoneda}(f, \operatorname{id}_{\mathscr{F}})\big] (\phi) \Big) = \mathrm{ev}_{V,\,\mathscr{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}_\mathscr{F})\big] \big(\mathrm{ev}_{U, \,\mathscr{F}} (\phi)\big) = \big[\mathscr{B}_{\rm pairing}(f, \operatorname{id}_\mathscr{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 \mathscr{F} \Rightarrow \mathscr{G}. Then for all presheaf morphisms ϕHomPSh(C)(HU,F)\phi \in \operatorname{Hom}_{\mathbf{PSh}(\mathscr{C})}(H_U, \mathscr{F}), we have

evU,G([Byoneda(idU,ψ)](ϕ))=evU,G(ψϕ)=(ψUϕU)(idU). \mathrm{ev}_{U,\,\mathscr{G}} \Big( \big[\mathscr{B}_{\rm yoneda}(\operatorname{id}_{U}, \psi)\big] (\phi) \Big) = \mathrm{ev}_{U,\,\mathscr{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, \mathscr{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

Intuitively, the Yoneda lemma states that a morphism from a presheaf represented by UU to a general presheaf is completely determined by how it maps the identity section on UU. The naturality condition can be rephrased as such:

  1. In order to "shift back" the source of the evaluation from being at the identity idU\operatorname{id}_U to another section ff, we can either first evaluate at idU\operatorname{id}_U as usual and then pullback to obtain ϕV(f)\phi_V(f), or precompose ϕ\phi with the Yoneda embedding of ff and then evaluate idV\operatorname{id}_V.
  2. In order to "shift forward" the destination of the evaluation from being in F\mathscr{F} to another presheaf G\mathscr{G}, we can evaluate idU\operatorname{id}_U as usual and then apply a component of the morphism FG\mathscr{F} \Rightarrow \mathscr{G}, or compose ϕ\phi with the morphism FG\mathscr{F} \Rightarrow \mathscr{G} and then evaluate at idU\operatorname{id}_U.

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) \xrightarrow{\sim} \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 the underlying objects in C\mathscr{C}. In other words, to understand an object in a category, it suffices to understand the presheaf of morphisms to that object.