153
$\begingroup$

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?

$\endgroup$
5
  • 4
    $\begingroup$ Representables are projective? $\endgroup$ Commented Feb 4, 2014 at 21:39
  • 5
    $\begingroup$ @FernandoMuro — Excuse me, but what do you mean with that comment? $\endgroup$
    – jmc
    Commented Feb 5, 2014 at 8:06
  • 14
    $\begingroup$ @jmc I mean that Yoneda's lemma can be interpreted as saying that representables in the functor category are projective objects. I like this interpretation! $\endgroup$ Commented Feb 5, 2014 at 8:12
  • 3
    $\begingroup$ @FernandoMuro — I see! Thanks; I didn't know that yet. I would however like to see (in an answer?) why you think it is the “philosophical” meaning of the Yoneda lemma. $\endgroup$
    – jmc
    Commented Feb 5, 2014 at 8:28
  • 8
    $\begingroup$ I think Neon Genesis evangelion explains it nicely $\endgroup$
    – Brian
    Commented Sep 6, 2022 at 10:48

12 Answers 12

105
$\begingroup$

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.

$\endgroup$
7
  • 29
    $\begingroup$ 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. $\endgroup$ Commented Oct 29, 2009 at 2:08
  • 4
    $\begingroup$ Good point. By the way, a gentle introduction by John Baez on what "free cocompletion" means is here: ncatlab.org/nlab/show/free+cocompletion $\endgroup$ Commented Oct 29, 2009 at 2:14
  • 1
    $\begingroup$ 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). $\endgroup$ Commented Feb 13, 2010 at 20:50
  • 5
    $\begingroup$ @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 ncatlab.org/nlab/show/… $\endgroup$ Commented Feb 16, 2012 at 10:29
  • 2
    $\begingroup$ @HansStricker: The nLab article on "Space and Quantity" (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. $\endgroup$
    – Vectornaut
    Commented Feb 10, 2013 at 21:45
163
$\begingroup$

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.

$\endgroup$
9
  • 146
    $\begingroup$ To me, this is a beautiful explanation of particle physics in the familiar terms of Yoneda's lemma! $\endgroup$ Commented Oct 29, 2009 at 9:31
  • 4
    $\begingroup$ 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: golem.ph.utexas.edu/string/archives/000677.html $\endgroup$ Commented Oct 29, 2009 at 9:53
  • 26
    $\begingroup$ 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. $\endgroup$ Commented Nov 1, 2009 at 15:51
  • 3
    $\begingroup$ 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? $\endgroup$ Commented Feb 13, 2010 at 18:41
  • 10
    $\begingroup$ @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". $\endgroup$ Commented Feb 14, 2010 at 18:16
43
$\begingroup$

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.

$\endgroup$
3
  • 3
    $\begingroup$ Neat! And under this analogy, representable functors (with representing object s) are just models that are freely generated by a single element (of sort s). To me, at least, this clears things up a lot. $\endgroup$ Commented Feb 13, 2010 at 20:55
  • 3
    $\begingroup$ This algebraic perspective is articulated in Vaugh Pratt's The Yoneda Lemma without Category Theory. $\endgroup$ Commented Feb 6, 2016 at 3:29
  • $\begingroup$ The general view of category theory you present, most notably the " equalities between (composites of) morphisms being the laws of the theory" part, has been helpful to me, thank you! $\endgroup$
    – user56097
    Commented Oct 21, 2023 at 9:33
41
$\begingroup$

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.”

$\endgroup$
2
  • 5
    $\begingroup$ I wonder if people should introduce themselves as "I am [name], up to unique isomorphism"? 😄 $\endgroup$
    – LSpice
    Commented Oct 7, 2022 at 15:15
  • 2
    $\begingroup$ Tell me who your Hom-ies are and I'll tell you who you are $\endgroup$ Commented Aug 13 at 21:45
34
$\begingroup$

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.

$\endgroup$
2
  • 3
    $\begingroup$ Nice interpretation! $\endgroup$ Commented Feb 18, 2011 at 19:05
  • 2
    $\begingroup$ This interpretation is very close to what Leinster proposes in his book Basic Category Theory. $\endgroup$
    – user57432
    Commented Oct 2, 2019 at 5:50
31
$\begingroup$

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

$\endgroup$
5
  • $\begingroup$ 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? $\endgroup$
    – Max M
    Commented Nov 2, 2009 at 1:34
  • 5
    $\begingroup$ This refers to the "co-Yoneda lemma", which says that every presheaf is a colimit of representable presheaves: ncatlab.org/nlab/show/co-Yoneda+lemma $\endgroup$ Commented Nov 17, 2009 at 17:04
  • 1
    $\begingroup$ 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: maths.gla.ac.uk/~tl/msci . Don't take the analogy with prime factorization too seriously. $\endgroup$ Commented Nov 18, 2009 at 1:26
  • $\begingroup$ @Tom: Do you know some applications of Yoneda lemma to combinatorics? $\endgroup$
    – Yannic
    Commented Apr 19, 2012 at 7:16
  • $\begingroup$ 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. $\endgroup$ Commented Apr 19, 2012 at 13:45
20
$\begingroup$

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.

$\endgroup$
19
$\begingroup$

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.

$\endgroup$
17
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ Why do you say "G-structured bundle" instead of G-principal bundle? $\endgroup$ Commented Oct 29, 2009 at 7:39
  • 1
    $\begingroup$ It could be a vector bundle with transition functions in G. $\endgroup$ Commented Oct 30, 2009 at 0:42
7
$\begingroup$

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$.

$\endgroup$
6
$\begingroup$

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}$.

$\endgroup$
4
$\begingroup$

$\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.

$\endgroup$
2
  • 1
    $\begingroup$ 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.) $\endgroup$ Commented Feb 11, 2013 at 20:26
  • $\begingroup$ Thank you for your comment. I've used it to clarify and expand this answer- does it make more sense now? $\endgroup$ Commented Feb 12, 2013 at 8:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .