150

The Yoneda Lemma is a simple result of category theory, and its proof is very straightforward.

Yet I feel like I do not truly understand what it is about; I have seen a few comments here mentioning how it has deeper implications into how to think about representable functors.

What are some examples of this? How should one think of the Yoneda Lemma?

Mike Pierce
  • 1,149

12 Answers12

157

In his Algebraic Geometry class a few years back, Ravi Vakil explained Yoneda's lemma like this: You work at a particle accelerator. You want to understand some particle. All you can do are throw other particles at it and see what happens. If you understand how your mystery particle responds to all possible test particles at all possible test energies, then you know everything there is to know about your mystery particle.

  • 144
    To me, this is a beautiful explanation of particle physics in the familiar terms of Yoneda's lemma! – Thanos D. Papaïoannou Oct 29 '09 at 09:31
  • 3
    It is, indeed, to some extent also good explanation of some string theoretic thinking is suggesting: that whatever space is, you find out by testing it by throwing worldsheets of strings into it.

    One can make this Yoneda-way of thinking about string theory sigma-models pretty precise in cases.

    One rarely sees string theorists talk this way, of course. One exception is Eric Sharpe, who promoted that point of view here: http://golem.ph.utexas.edu/string/archives/000677.html

    – Urs Schreiber Oct 29 '09 at 09:53
  • 1
    One does not need to get into any fancy string theory to see this idea. Fundamental groups and homotopy groups are already a manifestation of this idea! Indeed I think Manin once suggested that we can view Gromov-Witten invariants as an algebro-geometric analogue of fundamental group... – Kevin H. Lin Oct 29 '09 at 14:20
  • Could you tell more about this idea of Manin? – Ilya Nikokoshev Nov 01 '09 at 11:40
  • 26
    A lower-level manifestation of the same idea: a locally integrable function on an open domain is determined by the knowledge of the values of the integrals against test functions. – Gian Maria Dall'Ara Nov 01 '09 at 15:51
  • 3
    I think this is a good idea, but in fact the Yoneda lemma says just the opposite, doesn't it? It allows you to identify your particle A with hom(A,_) . So what you are seeing are not the particles that "hit" your particle A, but what A "hits". Am I wrong? – Agustí Roig Feb 13 '10 at 18:41
  • 10
    @Agusti: There are, of course, two Yoneda lemmas. One says you can recover A from hom(A,-) and the other says you can recover it from hom(-,A). The latter is covariant in A, so makes a better statement. But, yes, from the hom(A,-) perspective, I'd say "you can know your particle by looking at its emissions". – Theo Johnson-Freyd Feb 14 '10 at 18:16
  • 2
    But one also has to use the mystery particle itself to test it (essentially, this is the proof of the Yoneda lemma). Although your story sound similar to distribution theory -- in that case you only need much nicer objects (smooth functions with compact support) to test a distribution. – Jochen Wengenroth Jun 18 '21 at 09:48
  • 2
    @JochenWengenroth A priori, yes. Better make a bunch of them! OTOH, if your category is, say, locally presentable, then it is enough to test your mystery particle against all particles below some energy scale. – Theo Johnson-Freyd Jun 19 '21 at 13:45
103

One way to look at it is this:

for $C$ a category, one wants to look at presheaves on $C$ as being "generalized objects modeled on $C$" in the sense that these are objects that have a sensible rule for how to map objects of $C$ into them. You can "probe" them by test objects in $C$.

For that interpretation to be consistent, it must be true that some $X$ in $C$ regarded as just an object of $C$ or regarded as a generalized object is the same thing. Otherwise it is inconsistent to say that presheaves on $C$ are generalized objects on $C$.

The Yoneda lemma ensures precisely that this is the case.

I wrote up a more detailed expository version of this story at motivation for sheaves, cohomology and higher stacks.

LSpice
  • 11,423
Urs Schreiber
  • 19,564
  • 29
    More specifically, the category of presheaves on C is the free cocomplete category on C. This fact is probably about as fundamental as Yoneda's lemma. So the Yoneda lemma is a kind of categorification of the fact that the map from a set to the free commutative monoid on that set is an injection. – Reid Barton Oct 29 '09 at 02:08
  • 4
    Good point. By the way, a gentle introduction by John Baez on what "free cocompletion" means is here: http://ncatlab.org/nlab/show/free+cocompletion – Urs Schreiber Oct 29 '09 at 02:14
  • 1
    So, for example (if I understand what you're getting at), sometimes you want to add "Pro-objects" and "Ind-objects" to your favorite category C which lacks limits over (co-)filtered systems, and you can do this by identifying C with its image under the Yoneda embedding (which implicitly uses Yoneda's Lemma). – John Goodrick Feb 13 '10 at 20:50
  • @Urs: There's so much "dark mumbling" in your answer I'd really like to understand better. Where can I learn more about "generalized objects modeled on C", "objects that have a sensible rule for how to map objects of C into them", "probe them by test objects" - maybe in one coherent and concise text? – Hans-Peter Stricker Oct 31 '11 at 19:01
  • 5
    @Hans, the precise statement that you are looking for is simply the Yoneda lemma. Those words are meant to highlight its "philosophical meaning", as requested. Those "objects modeled on C" are precisely presheaves on C. Their "set of probes" by some X in C is the value of the presheaf on X. Plenty of further technical details are linked to at http://ncatlab.org/nlab/show/motivation+for+sheaves%2C+cohomology+and+higher+stacks – Urs Schreiber Feb 16 '12 at 10:29
  • 2
    @HansStricker: The nLab article on "Space and Quantity" (http://ncatlab.org/nlab/show/space+and+quantity) is my favorite exposition of these ideas. The "Details" section talks a little about the role of the Yoneda lemma. – Vectornaut Feb 10 '13 at 21:45
  • 1
    It seems that it's hard to avoid (Set) when talking about Yoneda lemma. Even in the enriched case, say V-enriched case, V should contains Set essentially in order to prove Yoneda lemma. Is it true that (Set) is universal once Yoneda lemma is imposed to be true, in any sense? – Student Jun 06 '20 at 00:55
39

If you have basic experience with abstract algebra, the ideas in the Yoneda lemma should be quite familiar and even intuitive; the apparent difficulty is only in recognizing them in this new presentation.

You can think of "category" as meaning the same thing as "algebraic theory in a multisorted language with only unary functions"—the objects of the category being the sorts of the language, the morphisms being the definable functions, and the equalities between (composites of) morphisms being the laws of the theory. From this perspective, a functor from $C$ to $\mathrm{Set}$ is simply a model of the theory corresponding to $C$, and natural transformations of such functors are homomorphisms of models. The Yoneda lemma then is about free models. Specifically, it says that for every sort $s$, the "term model" of terms with a single variable, of sort $s$ (equivalently definable functions with domain $s$) is the free model on a single generator of sort $s$. It may be unfamiliar when expressed as "$\mathrm{Nat}(\mathrm{Hom}(s, {-}), M) \cong M(s)$ naturally in $M$", but that is indeed all this categorical expression is saying

The so-called co-Yoneda lemma mentioned in the other comments also has a nice interpretation from this perspective, amounting to the demonstration that every model can be specified by generators and relations.

I wouldn't say this is The One Right Way to think about the Yoneda lemma, because it's useful to view it from many different perspectives, but this is certainly One Right Way to think about the Yoneda lemma.

Mike Pierce
  • 1,149
37

When explaining the Yoneda lemma, I always like to use the Dutch saying

Tell me who your friends are, and I will tell you who you are.

I think this is a pretty good approximation of the “philosophical” meaning of the Yoneda lemma. A more precise statement would be “tell me how you relate to everything else, and I will tell you who you are (up to unique isomorphism)”.

This is really close to the particle accelerator analogy mentioned by Theo Johnson-Freyd (https://mathoverflow.net/a/3223/21815). Nevertheless, I just wanted to share the slogan.


Edit: I just realised that I did not actually mention any motivation for the slogan. Here it is.

The whole point of the Yoneda lemma is that an object $x$ in a category $C$ is fully determined by the functor $\textrm{Hom}(\_, x)$. [Equivalently and dually, one can also take $\textrm{Hom}(x, \_)$.] This is useful in a lot of different settings. For example in algebraic geometry it often happens that one has a particularly easy description of $\textrm{Hom}(\_, x)$, while describing $x$ directly may be a lot harder [e.g., when $x$ is a group scheme].

Obviously, the slogan means to interpret $\textrm{Hom}(y,x)$ as how $y$ relates to $x$. And if you tell me $\textrm{Hom}(y,x)$ for all $y$ [in a functorial manner!] then I can tell you what $x$ is. Hence: “tell me who your friends are, and I will tell you who you are.”

jmc
  • 5,434
  • 4
    I wonder if people should introduce themselves as "I am [name], up to unique isomorphism"? – LSpice Oct 07 '22 at 15:15
32

Barr and Wells (Toposes, Triples, and Theories, 84) talks about arrows as a general kind of elements. In $\mathbf{Set}$, arrows from $\{\ast\}\to A$ are the usual elements of $A$, and arrows from bigger sets $X\to A$ are the $X$-elements of $A$, or elements of $A$ parameterised in $X$. Of course the latter makes sense in any category, so we can use this language to state the Yoneda lemma as:

The $\mathsf{Hom}(-,A)$-elements of $F$ are just the usual elements of $FA$.

I find this to be, at least, a useful mnemonic, but also justifies the intuition that an object "is" its collection of probes.

Qi Zhu
  • 425
Aleks Kissinger
  • 1,862
  • 15
  • 22
31

Lazily, I'll just point to some notes on this question: What's the Yoneda Lemma all about?

Tom Leinster
  • 27,167
  • Could you explain the last statement on page 8? (Any functor C^op \mapsto Set can be built out of representables Hom(-,A) in very roughly the same way that any number is built as a product of primes). Should I make it a separate question? – Max M Nov 02 '09 at 01:34
  • 5
    This refers to the "co-Yoneda lemma", which says that every presheaf is a colimit of representable presheaves: http://ncatlab.org/nlab/show/co-Yoneda+lemma – Urs Schreiber Nov 17 '09 at 17:04
  • 1
    Max M, sorry, I only just saw your question. Urs is right: I was referring to the fact that every presheaf is a colimit, in a canonical way, of representable presheaves. I'd call it that the 'Density formula'. Another reference is Theorem 5.1.16 of these notes: http://www.maths.gla.ac.uk/~tl/msci . Don't take the analogy with prime factorization too seriously. – Tom Leinster Nov 18 '09 at 01:26
  • @Tom: Do you know some applications of Yoneda lemma to combinatorics? – Yannic Apr 19 '12 at 07:16
  • Not off the top of my head. The only thing I can think of is that Joyal's theory of species is a categorical approach to enumerative combinatorics, and is almost certain to involve the Yoneda lemma in its development. – Tom Leinster Apr 19 '12 at 13:45
19

A good and frequent use of the Yoneda lemma is internalization: If e.g. I have monoid valued representable contravariant functor Hom(-,A):C-->Set, then the representing object A must be a monoid object in C. This is because the structure morphism Hom(-,A)xHom(-,A)=Hom(-,AxA)-->Hom(-,A) is a natural transformation and thus, by Yoneda comes from a morphism AxA-->A inside C, same for the other structure morphisms and the commuting diagrams.

The same goes through for other algebraic (or limit) structures and also for covariant Hom-functors which, if they are algebra-valued are represented by an coalgebra-object. An excellent example for the latter is the fact that affine algebraic groups are represented by Hopf algebras.

Peter Arndt
  • 12,033
19

If you don't mind thinking of category theory in terms of functional programming there is an interpretation at A Neighborhood of Infinity - Reverse Engineering Machines with the Yoneda Lemma. Fix a type A and a functor F. If you have a machine that can give you back an object of type FB every time you give it a function of type A->B, can you reverse engineer fully what the machine is doing? Essentially the machine must contain an element of FA and you can recover that FA from how it responds to your functions. This is very similar to Theo's physical perspective.

LSpice
  • 11,423
Dan Piponi
  • 8,086
16

Another way to think about the Yoneda lemma is in terms of universal things. Consider, for instance, the existence of classifying spaces for bundles. The statement is that for any suitable group G, there is a space BG such that for any nice enough space X, homotopy classes of maps X → BG are in natural bijection with isomorphism classes of G-structured bundles over X. In categorical terms, that means there is a natural isomorphism between the functors

X ↦ {G-structured bundles over X}

and

X ↦ [X,BG]

The Yoneda lemma implies that this natural isomorphism is uniquely determined by a specific G-structured bundle over BG. That is, the existence of a "classifying space" BG with the above property implies the existence of a universal bundle EG → BG such that every bundle over any space X is the pullback of the universal one along a map X → BG, unique up to homotopy.

The search for representing objects, and hence for universal data, lies at the heart of a lot of modern algebraic topology, algebraic geometry, and even category theory.

Mike Shulman
  • 65,064
7

This perspective seems to be absent so far, even though this is a very old question.

To properly credit the source for this idea, the perspective seems to be taken for granted in MacLane and Moerdijk's Sheaves in Geometry and Logic, which was where I was introduced to it.

The observation is the following: Categories are generalizations of monoids, and functors are the correct analog of representations.

The analogy:

This goes as follows. If $M$ is a monoid, we can define a one object category, which I'll also denote by $M$ which has a single object $*$ and $M(*,*)=M$ with the composition coming from the multiplication in the monoid.

Then if $M=G$ is a group for example, then a functor $F$ from $G$ to $\newcommand\Set{\mathbf{Set}}\Set$ is a choice of set $X=F(*)$ together with mappings $F(g):X\to X$ for all morphisms $g\in G$. If we write $g\cdot x$ for $F(g)(x)$, then the equation $F(g)\circ F(h) = F(gh)$ becomes $g\cdot (h\cdot x) = (gh)\cdot x$ for all $x\in X$, $g,h\in G$. This is exactly what it means for $X$ to be a $G$-set.

A natural transformation between two functors $F,F' : G\to \Set$ is a map $\phi : F(*)\to F'(*)$ such that $g\cdot \phi(x) = \phi(g\cdot x)$ for all $g\in G$ and $x\in X$. So morphisms of functors are $G$-equivariant maps, as they should be.

Replacing the category of sets with any category you care to think about gives the expected notion of $G$-representation in that category.

Back to categories and functors

In this perspective, a covariant functor $\newcommand\C{\mathcal{C}}F:\C\to \Set$ is a choice of set $F(c)$ for all objects $c\in\C$ and a function $F(f) : F(c)\to F(d)$ for each morphism $f:c\to d$ in $\C$. Subject to the requirement that $F(fg) = F(f)F(g)$ when $f$ and $g$ are composable arrows.

We can think about this as a family of sets $X_c$ for all $c\in \C$ such that for $f:c\to d$, and $x\in X_c$, $f_*x\in X_d$ and $g_*f_*x=(gf)_*x$ when $g$ and $f$ are composable.

A natural transformation between two representations $X_c$, $Y_c$ is a family of maps $\phi_c:X_c\to Y_c$ such that $\phi(f_*x)=f_*\phi(x)$ whenever this makes sense.

Now the Yoneda lemma becomes the following observation. The functor $\C(a,-)$ is "freely generated" as a $\C$-representation by $1_a$. What I mean by this is that a natural transformation $\C(a,-)\to F-$ is determined by the image of $1_a$ and there are no restrictions on the choice of image (except that of course it must lie in $Fa$). This is because for any morphism $f$, we have $$\phi(f)=\phi(f_*1_a)=f_*\phi(1_a).$$

The contravariant version is identical, except now we think of functors as right $\C$-representations because contravariance becomes the rule $x|_f |_g = x|_{fg}$, where $|_f$ denotes the action of $f$ on $x$ when this makes sense.

This philosophical perspective is related to Sridhar Ramesh's answer, based on what I can see, but I'm not really familiar with the algebraic theory perspective, and I think this is a bit more of an elementary algebraic viewpoint.

The point here is that you should think of Yoneda functors $\C(a,-)$ or $\C(-,a)$ as the free objects in a single variable supported at an object $a$.

jgon
  • 101
6

Here is an example on representable functors. Yoneda's lemma gives down-to-earth, morpshim oriented interpretation of representable functors, and vice versa.

I will explain this with an example.

In a category $\mathscr{C}$, the product of $A$ and $B$ is the pair of object $A\times B$ in $\mathscr{C}$ and a fixed natural isomorphism $$ \sigma \colon \mathrm{Hom}(-,A\times B)\to \mathrm{Hom}(-,A)\times \mathrm{Hom}(-,B). $$

This definition of products only uses terminology of functors. By applying Yoneda's lemma, we arrive at a morphism oriented definiton of products. Yoneda's lemma says that there is a bijection $$ \Psi \colon \mathrm{Hom}\left( \mathrm{Hom}(-,A\times B),\mathrm{Hom}(-,A)\times \mathrm{Hom}(-,B)\right) \to \mathrm{Hom}(A\times B,A)\times \mathrm{Hom}(A\times B,B). $$ In particular, we apply this to $\sigma$ and denote $$ \Psi(\sigma)=\sigma(A\times B)(\mathrm{id}_{A\times B})=(\pi^{A}\colon A\times B\to A,\pi^{B}\colon A\times B\to B). $$ Next, by applying the inverse of $\Psi$, we compute $$ \sigma(X)=\Psi^{-1}\left( \Psi(\sigma)\right)(X):\mathrm{Hom}(X,A\times B)\to \mathrm{Hom}(X,A)\times \mathrm{Hom}(X,B) $$ $$ f\colon X\to A\times B\mapsto (\pi^{A}\circ f,\pi^{B}\circ f). $$ Since $\sigma$ is a natural isomorphism, $\sigma(X)$ is a bijection. This bijectivity is the usual definition of product based on morphisms (universality):

For any pair of morphisms $f^{A}\colon X\to A$ and $f^{B}\colon X\to B$, there exists a unique morphism $f\colon X\to A\times B$ with $\pi^{A}\circ f=f^{A}$ and $\pi^{B}\circ f=f^{B}$.

I think the Philosophy behind Yoneda's lemma is that, it connects the world of functors (and natural transformations) $\mathfrak{Set}^{\mathscr{C}^{\mathrm{op}}}$ and the world of morphisms $\mathscr{C}$.

Kai
  • 31
4

$\DeclareMathOperator\hom{hom}\DeclareMathOperator\Hom{Hom}\newcommand\op{^\text{op}}\newcommand\set{\mathrm{set}}$You might also want to think about the Yoneda Lemma as a statement about functors.

A locally small category $\mathcal{C}$ is embedded by the $\hom$ functor in the category $\Hom(\mathcal{C}\op,\set)$. This is called the Yoneda embedding. Thus, the $\hom$ functor is fully faithful (this itself is a corollary of the Yoneda lemma), but is not an equivalence of categories, because it isn't essentially surjective. In other words, not every functor $F$ from $\mathcal{C}\op$ to $\set$ is representable— for example, the empty functor which maps each object in $\mathcal{C}$ to the empty set, is never representable. The problem is that the Yoneda embedding does not commute with colimits. But the Yoneda lemma tells you that every functor $F\in \Hom(\mathcal{C}\op,\set)$ becomes representable when extended appropriately. In other words, every functor $F$ from $\mathcal{C}\op$ to $\set$ extends to a functor from $\left(\Hom(\mathcal{C}\op,\set)\right)\op$ to $\set$ (this is a special case of the Yoneda extension) which does commute with colimits, and is representable.

So one “philosophical interpretation” of the Yoneda lemma is the following:

Every functor $F$ from $\mathcal{C}\op$ to $\set$ can be extended to a representable functor from $\left(\Hom(\mathcal{C}\op,\set)\right)\op$ to $\set$.

One reference for this point of view is Mathew - The Dold–Kan correspondence.

LSpice
  • 11,423
  • 1
    Not only is it not essentially surjective in general, it's never essentially surjective, because the functor $C^{op} \to Set$ that is constantly empty cannot be isomorphic to a representable. (I must confess: I don't understand what you are trying to say in your answer.) – Todd Trimble Feb 11 '13 at 20:26
  • Thank you for your comment. I've used it to clarify and expand this answer- does it make more sense now? – Daniel Moskovich Feb 12 '13 at 08:39