Yoneda's Lemma

Euripides

Every man is like the company he is wont to keep.

One of the most consistent philosophies throughout all of category theory is "It's all about the arrows." This is built into the very core of the theory, in that you don't even really need objects to define a category: they are in one-to-one correspondence with the identity arrows!

At a metaphorical level, an arrow f:c→c′ in a category C can be thought of some information that each of c and c′ "see" about the other. So for a fixed object c, the collection of all arrows from c is the total information about the category C available to the object c; or dually, the set of all arrows to a fixed object c′ is all information available in the category C about the object c′. From this point of view, what more information could there be about a given object? Nothing. The category is all there is, and in the category the only data are the arrows.

But how does one formalize this idea?


The original inspiration: universal properties

First revisit our pantheon of objects with universal properties. Looking over these examples, a clear pattern emerges. In each case was have an object c in a category C that is characterized by a "universal property," which can always be expressed in the form of a bijection

Ο„d:HomC(c,d)β†’βˆΌF(d)

that is "natural in d", where F:Cβ†’Set is some functor. This naturality, often stated but not articulated, is the formal embodiment of the idea that the bijection Ο„d is defined "in the same way" for every d∈C, or at least "in a compatible way." What that means precisely is that for every arrow f:d1β†’d2 in C we have a commutative diagram

This is exactly the diagram for a natural transformation.

Examples

For illustration, we recall some specific examples of universal properties.

Coequalizers of set maps

Suppose X and Y are sets. Their disjoint union XβŠ”Y is the set characterized by the universal property that set maps f:XβŠ”Yβ†’Z are in natural bijection with pairs of set maps g:Xβ†’Z, h:Yβ†’Z. To put this into the above context, let F:Setβ†’Set be the functor that assigns:

Ο„Z:HomSet(XβŠ”Y,Z)β†’βˆΌF(Z)

Quotients by normal subgroups

Let N be a normal subgroup of a group G. The quotient group G/N, together with its projection morphism Ο€:Gβ†’G/N defined by g↦g+N, satisfies a universal property. Let F:Grpβ†’Set be the functor that assigns to each group H the set of group morphisms f:Gβ†’H such that N≀ker⁑(f). Then there is a natural bijection

Ο•H:HomGrp(G/N,H)β†’βˆΌF(H).

Under this bijection, each group morphism g:G/Nβ†’H is sent to the group morphism gβˆ˜Ο€:Gβ†’H.

Direct sums of abelian groups

If A and B are abelian groups, their direct sum is the abelian group AβŠ•B. As a set, it consists of all pairs of formal sums a+b with a∈A and b∈B. The operation is defined "component-wise": (a+b)+(aβ€²+bβ€²)=(a+aβ€²)+(b+bβ€²). (Although not common, one could reasonably argue that a different notation should be used for the formal sum symbol, such as aβŠ•b.) One can verify that AβŠ•B is an abelian group, and that it comes equipped with two injective group morphisms i1:Aβ†’AβŠ•B and i2:Bβ†’AβŠ•B. Moreover, there is a natural bijection between group morphisms from AβŠ•B and pairs of groups morphisms Aβ†’C, Bβ†’C:

Ο•C:HomAb(AβŠ•B,C)β†’βˆΌ{(g1,g2)∣g1∈HomAb(A,C),g2∈HomAb(B,C)}

Under this bijection, each group morphism f:AβŠ•Bβ†’C is sent to the pair of group morphisms f∘i1:Aβ†’C, f∘i2:Bβ†’C.

Free R-modules

Let R be a ring and U:R-Modβ†’Set be the usual forgetful functor. The free module construction takes each set A and produces an R-module F(A). The function which sends each a∈A to the same element a∈F(A) regarded as a formal R-linear sum of elements of A is an arrow j:Aβ†’U(F(A)). For any other R-module M, each function f:Aβ†’U(M) can be extended uniquely to a module morphism h:F(A)β†’M with f=U(h)∘j.

In the current context, let G:R-Mod→Set be the functor that assigns to each R-module M the collection of set maps f:A→U(M); i.e., G(M)=HomSet(A,U(M)). Then there is a natural bijection

Ο•N:HomR-Mod(F(A),M)β†’βˆΌG(M).

From objects to (hom) functors

We first notice that in every universal property, we are always characterizing morphisms from an object (or dually, to an object) in terms of a "natural" bijection with some other info. To make this functorial, consider the following:

Definition of hom functor

For each object c in a given category C, we can define a functor Hc:C→Set as follows:

  • For each object d∈C, we let Hc(d)=HomC(c,d).
  • For each arrow f:dβ†’dβ€², we let Hc(f):Hc(d)β†’Hc(dβ€²) be the set map that takes each morphism g:cβ†’d to the morphism f∘g:cβ†’dβ€².

It is also common to write HomC(c,βˆ’) for Hc, but when doing so we will then also write fβˆ˜βˆ’ for Hc(f), rather than the awkward looking HomC(c,f).

We should verify that Hc is indeed a functor.

First note that for each identity arrow 1d in C we have Hc(1d):Hc(d)β†’Hc(d) is the set map that send each arrow g:cβ†’d to the arrow 1d∘g:cβ†’d; since C is a category, we certainly have 1d∘g=g and so Hc(1d) is the identity map on Hc(d).

Next, for a pair of composable arrows f1:d1β†’d2 and f2:d2β†’d3, we have

Hc(f2∘f1)=(f2∘f1)βˆ˜βˆ’=f2∘(f1βˆ˜βˆ’)=Hc(f2)∘Hc(f1).

More formally, for each object g∈Hc(d1) (i.e., arrow g:cβ†’d1), we have

Hc(f2∘f1)(g)=(f2∘f1)∘g,

while

(Hc(f2)∘Hc(f1))(g)=f2∘(f1∘g).

By the associativity of composition in C these two are equal.

From the category C to the functor category SetC

For each object c∈C we have defined a functor Hc:Cβ†’Set, which is an object of the functor category SetC. Have we actually defined a functor H:Cβ†’SetC? To answer that, we need to specify what H should do to arrows.

To that end, suppose h:cβ†’cβ€² is an arrow in C. Each arrow from Hc to Hcβ€² in SetC is a natural transformation Ο„:Hcβ‡’Hcβ€². This is the data of a family of arrows Ο„d:Hc(d)β†’Hcβ€²(d), one for each object d∈D, satisfying the usual naturality condition. So let's consider the sets Hc(d)=HomC(c,d) and Hcβ€²(d)=HomC(cβ€²,d).

Given an element f∈Hc(d) (i.e., an arrow f:cβ†’d), it's not exactly clear how we can use the arrow h:cβ†’cβ€² to produce an arrow cβ€²β†’d, i.e., an element of Hcβ€²(d)).

However, there is an obvious way to take an element fβ€²βˆˆHcβ€²(d) (i.e., an arrow fβ€²:cβ€²β†’d) and use the arrow h:cβ†’cβ€² to produce an arrow cβ†’d, namely by pre-composing with h:cβ†’cβ€².

This defines a set map Ο„d:Hcβ€²(d)β†’Hc(d), which (we hope) defines a natural transformation Ο„:Hcβ€²β‡’Hc. However, this natural transformation is going "the wrong way." In the classical parlance, we would be describing a so-called contravariant functor from C to SetC. This language has generally (but not entirely) fallen out of favor and been replaced by the use of the opposite category construction.[1] In other words, we can use our construction above to define a (covariant) functor[2]

H:Cop→SetC.

Note that the category Cop has the same objects as the category C, and each arrow in Cop from an object c to an object c′ corresponds to an arrow f:c′→c in C. Because of this, and in an effort to avoid confusion, we often denote arrows in Cop by fop:c→c′, where the corresponding arrow in C is f:c′→c.

The hom functor

For a given category C, we have defined a functor H:Cop→SetC as follows:

  • For each object c∈Cop (which is the same as an object c∈C), we have H(c)=Hc=HomC(c,βˆ’).
  • For each arrow hop:cβ†’cβ€² in Cop (which corresponds to an arrow h:cβ€²β†’c in C), the natural transformation H(hop):Hcβ‡’Hcβ€² is defined by "pre-composition with h," i.e., for each d∈C the set map H(hop)d:Hc(d)β†’Hcβ€²(d) is given by sending each arrow f:cβ†’d to the arrow f∘h:cβ€²β†’d.

Note that the naturality of our supposedly natural transformation follows from the associativity of arrow composition. To see this, suppose g:d1β†’d2 is an arrow in C and consider the diagram below:

Starting from the top-left, suppose f∈Hc(d1), i.e., we have an arrow f:cβ†’d1. Going over and down yields the arrow g∘(f∘h):cβ€²β†’d2, while going down and then over yields the arrow (g∘f)∘h:cβ€²β†’d2. By associativity of arrow composition in C, these two arrows are equal.


Was this a good idea?

If we hadn't been inspired by the myriad constructions objects with universal properties, this wouldn't seem like a great way to understand objects in a given category C. Arbitrary functors F:Cβ†’Set can presumably be very complicated and difficult to comprehend, and so the category SetC of all such functors is huge and mysterious, at least in comparison with the original category C. It would seem impossible that useful knowledge about an object c∈C could be gained from studying the corresponding functor Hc∈SetC.

Following the general principle of "knowing an object by knowing the maps from it"[3], we should first examine what we can say about arrows from Hc to other objects F∈SetC. In other words, we should examine natural transformation Hcβ‡’F.

And here we at last come to it, the great lemma of category theory:

Yoneda's Lemma

Suppose c is an object of a category C and F:Cβ†’Set is a functor. Then there is a bijection between the set of natural transformation Hcβ‡’F and the set F(c), given by sending each natural transformation Ο„:Hcβ‡’F to the element Ο„c(1c)∈F(c).

In other words, there is a bijection

y:HomSetC(Hc,F)β†’βˆΌF(c).

We can upgrade this bijection to a full-on natural isomorphism between two functors, but for now let's examine the proof of this lemma.

First suppose Ο„:Hcβ‡’F is a natural transformation. This means that for every object d∈C we have a set map Ο„d:Hc(d)β†’F(d). In particular, by taking d=c we have a set map Ο„c:Hc(c)β†’F(c). The domain of this set map is HomC(c,c) which contains (by the axioms of C being category!) a unique identity arrow