The Unapologetic Mathematician

Mathematics for the interested outsider

What does Yoneda’s Lemma mean?

As I promised, today I’ll try to explain what Yoneda’s Lemma really does for us.

First off, let’s think about functions of two variables. To be very explicit, think of the function f:\mathbb{N}\times\mathbb{N}\rightarrow\mathbb{N} defined by f(x,y)=xy. We can turn this into a function of one variable that returns another function. Specifically, if we write \mathbb{N}^\mathbb{N} for the set of functions from the natural numbers to themselves, we can write \overline{f}:\mathbb{N}\rightarrow\mathbb{N}^\mathbb{N}, where \left[\overline{f}(x)\right](y)=xy. That is, \overline{f}(3) is the function that sends y to 3y. This method of “Currying” (named for Haskell Curry) a function should be familiar if you’ve worked with functional programming languages like LISP, ML, or Haskell. There’s really a lot to be said about it in general, and I’ll get back to exploring it in more depth another time.

Anyhow, a similar statement goes for functors of more than one variable. Since such functors are “functorial in each variable”, we can stick an object into all but one slot and be left with a functor of the last slot. The thing is, this assignment is itself functorial.

Let’s focus on a functor F:\mathcal{A}\times\mathcal{B}\rightarrow\mathcal{C}. Then for any object A\in\mathcal{A} we have a functor \overline{F}(A)=F(A,\underline{\hphantom{X}}):\mathcal{B}\rightarrow\mathcal{C}. Now when we change the object A by applying a morphism \alpha:A_1\rightarrow A_2 we get a natural transformation \overline{F}(\alpha):\overline{F}(A_1)\rightarrow\overline{F}(A_2). It should have components \overline{F}(\alpha)_B:F(A_1,B)\rightarrow F(A_2,B). The clear choice is \overline{F}(\alpha)_B=F(\alpha,1_B), and indeed this is natural since the morphisms from \mathcal{A} commute with those from \mathcal{B}.

Now, strictly speaking this \overline{F} may not be a functor since we only know that \mathcal{C}^\mathcal{B} is a category when at least one of \mathcal{B} and \mathcal{C} is small, but the general idea should be clear.

Now to the situation at hand: we know that any category \mathcal{C} comes equipped with a functor \hom_\mathcal{C}:\mathcal{C}^\mathrm{op}\times\mathcal{C}\rightarrow\mathbf{Set}. We apply this Currying operation on each slot to get two “functors” \mathbf{y}:\mathcal{C}\rightarrow\mathbf{Set}^{\mathcal{C}^\mathrm{op}} and \mathbf{y'}:\mathcal{C}^\mathrm{op}\rightarrow\mathbf{Set}^\mathcal{C}. Of course, the targets are only sure to be categories when \mathcal{C} (and thus \mathcal{C}^\mathrm{op} as well) is small, but we’ll gloss over that point. What the Yoneda Lemma says is that these functors are fully faithful!

To see this, notice that \mathbf{y'} sends an object A\in\mathcal{C}^\mathrm{op} to the covariant functor h_A=\hom_\mathcal{C}(A,\underline{\hphantom{X}}), while \mathbf{y} sends an object A\in\mathcal{C} to the contravariant functor h'_A=\hom(\underline{\hphantom{X}},A). Since the objects of \mathcal{C} and \mathcal{C}^\mathrm{op} are the same, I hope that using A for both won’t be too confusing.

Now let’s take the statement of the (covariant) Yoneda Lemma and apply it to the functor h_B for some object B\in\mathcal{C}. It says that \mathrm{Nat}(h_A,h_B)\cong h_B(A)=\hom_\mathcal{C}(B,A)=\hom_{\mathcal{C}^\mathrm{op}}(A,B). But notice that \mathrm{Nat}(h_A,h_B) is \hom_{\mathbf{Set}^\mathcal{C}}(h_A,h_B) — the set of morphisms from h_A to h_B in the functor category \mathbf{Set}^\mathcal{C}. Now since \mathbf{y'} is a functor from \mathcal{C}^\mathrm{op} to \mathbf{Set}^\mathcal{C}, it acts on the hom sets, sending \hom_{\mathcal{C}^\mathrm{op}}(A,B) to \hom_{\mathbf{Set}^\mathcal{C}}(\mathbf{y'}(A),\mathbf{y'}(B)). And the Yoneda Lemma tells us that this is a bijection — the functor \mathbf{y'} is fully faithful!

And the same argument goes through for \mathbf{y}. Now we apply the contravariant Yoneda Lemma to see that \hom_{\mathbf{Set}^{\mathcal{C}^\mathrm{op}}}(\mathbf{y}(A),\mathbf{y}(B))=\mathrm{Nat}(h'_A,h'_B)\cong h'_B(A)=\hom_\mathcal{C}(A,B). The functor \mathbf{y} induces a bijection on each hom set, so it’s fully faithful too!

Now remember what the point of fully faithful functors is: they’re all about full subcategories. This means that any (small) category \mathcal{C} can be seen as a full subcategory of \mathbf{Set}^{\mathcal{C}^\mathrm{op}}. And full subcategories are nice because they just restrict the objects we’re interested in without throwing out any morphisms between those objects. So, the objects of any category can be seen as a special kind of contravariant \mathbf{Set}-valued functor on that category.

And now: which contravariant \mathbf{Set}-valued functors on a category \mathcal{C} are so special that they constitute objects of \mathcal{C} under this embedding? Well, as usual in category theory we’re interested in things up to isomorphism, so we should ask, “What contravariant set-valued functors are (naturally) isomorphic to one in the image of \mathbf{y}?”

These are just the representable functors.

The representable, contravariant, \mathbf{Set}-valued functors on a category \mathcal{C} constitute a full subcategory of all contravariant \mathbf{Set}-valued functors on \mathcal{C}, which is equivalent to the category \mathcal{C} itself.

And that’s why Yoneda’s Lemma is so amazing.

June 7, 2007 - Posted by | Category theory


  1. Shouldn’t the requirement in par 4 by that $\mathcal C$ and therefore $\mathcal C^{\bf op}$ be locally small? (c.f. the ‘size worries’ paragraph Tom Leinster’s The Yoneda Lemma: What’s it All About.

    How much trouble do reasonably adequate math grad students have with this thing? I’ve read it described as ‘the hardest trivial thing in mathematics’, which makes me feel better about having so much trouble with it. This and its predecessor post are however a very helpful presentation, perhaps due to having a ‘clean plot line’ without a lot of extraneous stuff

    Comment by MathOutsider | October 2, 2007 | Reply

  2. The lack of a preview or edit comment feature on wordpress is really getting to me, here’s an attempt to fix the link:

    The Yoneda Lemma: What’s it All About
    . Well might as well try to get the latex right too, for once: \mathcal C^{\mathrm op}

    Comment by MathOutsider | October 2, 2007 | Reply

  3. what does Sub-categories mean!!!!!!

    Comment by michelle | October 9, 2007 | Reply

  4. michelle: I mentioned that in my post on full and faithful functors.

    Comment by John Armstrong | October 9, 2007 | Reply

  5. MathOutsider: The average graduate student in algebra, algebraic topology, or algebraic geometry can understand the content of the Yoneda Lemma. To them, it is a generalization of Cayley’s theory for groups and the fact that a left R-module M is isomorphic to Hom(R, M) (viewed as an R-module).

    On the other hand, unless the study is able to take a course that specifically covers category theory, they are unlikely to be taught the Yoneda Lemma in any particular course.

    Comment by Marceau | November 10, 2007 | Reply

  6. Marceau, I’m not so sure that’s the case. Maybe I would have said that back when I was in graduate school, but as I’ve seen more and more graduate students I really have to revise that “average” statement. Particularly the applied mathematics students who don’t really have as thorough a background in algebra would have a huge problem with understanding Yoneda without an explicit explanation.

    Comment by John Armstrong | November 10, 2007 | Reply

  7. \mathrm{Nat}(h_A,h_B)$ – I guess this is a latex error…

    Comment by gvaerg | December 28, 2010 | Reply

    • No, I just left off the “$latex” opening. good catch.

      Comment by John Armstrong | December 28, 2010 | Reply

  8. “we only know that \mathcal{C}^\mathcal{B} is a functor”

    Shouldn’t this be “is a category”?

    Comment by gvaerg | February 19, 2011 | Reply

  9. I’ve probably missed something obvious, but I can’t see why we have that y is fully faithfull follows from the fact that there _exists_ a natural isomorphism between Hom(A, B) and Hom(y A, y B), why does this say anything about how y acts on Hom(A, B)?

    Comment by noteventime | May 17, 2011 | Reply

    • The point is that \mathbf{y}‘s action on the hom spaces actually is the natural isomorphism. It’s not just that the two are naturally isomorphic, but that the isomorphism is given in this particular way.

      Comment by John Armstrong | May 17, 2011 | Reply

      • So the fact doesn’t follow from the statement of the Yoneda lemma so much as the specific isomorphism in this particular proof?

        If this is the case I find the presentation given here, and in most other places, somewhat strange, since they seem to imply that the fact follows from the statement of the Yoneda lemma (which I’ve never seen stating isomorphism explicitly).

        The introductory chapter of “Introduction to higher order categorical logic” is the only place I’ve seen this made explicit.

        Comment by noteventime | May 18, 2011 | Reply

        • Yes, the traditional statement just asserts existence, but the proof is very explicit. You have a point that some people may be confused (evidently you have been) but that’s part of why I go into the meaning and highlight the upshot of the proof.

          Comment by John Armstrong | May 18, 2011 | Reply

  10. […] Unapologetic mathematician […]

    Pingback by Le lemme de Yoneda et l’opération spirituelle | L'horreur islamique | May 5, 2013 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: