# Simple show cases for the Yoneda lemma

I've been given a very simple motivating and instructive show case for the Yoneda lemma:

Given the category of graphs and a graph object $G$, seen as a quadruple $(V_G,\ E_G,\ S_G:E\rightarrow V,\ T_G:E \rightarrow V)$.

Consider $K_1$ and $K_2$, the one-vertex and the one-edge graph and the two morphisms $\sigma$ and $\tau$ from $K_1$ to $K_2$.

Now consider the graph $H$ with

• $V_H = Hom(K_1,G)$
• $E_H = Hom(K_2,G)$
• $S_H(e) = e \circ \sigma: K_1 \rightarrow G$ for $e \in E_H$
• $T_H(e) = e \circ \tau: K_1 \rightarrow G$ for $e \in E_H$

It can be easily seen that $H$ is isomorphic to $G$.

I have learned that a) the category of graphs is a presheaf category and that b) $K_1$, $K_2$ are precisely the representable functors.

Now I am looking for other simple motivating and instructive show cases.

By the way: Shouldn't such an show case be added to the Wikipedia entry on Yoneda's lemma?

• I'm not totally sure what you mean by "example." Do you want examples of presheaf categories or examples of "natural" representable functors or what? Commented Jan 15, 2010 at 12:45
• I mean "show cases" of the fact that the morphisms of an object determine its "inner structure" up to isomorphism. Commented Jan 15, 2010 at 13:27
• @HansStricker what do you mean by $K_1$ and $K_2$ are the representable functors? Commented May 21, 2014 at 13:25
• The thing that convinced me of the usefulness of Yoneda's lemma is the theory of affine group schemes (a.k.a. affine algebraic groups) -- essentially, Yoneda's lemma shows that studying an affine group scheme (roughly speaking, studying the independent-of-$A$ properties in things like $\mathrm{GL}_n(A)$, $\mathrm{O}_n(A)$ etc. for all $k$-algebras $A$, where $k$ is a fixed field) is equivalent to studying its coordinate Hopf algebra (which is a single object per affine group per $k$). This is, obviously, close to the functional-programming examples, with functoriality replacing polymorphy. Commented May 22, 2014 at 6:07

If you program in a pure functional programming language like Haskell then the Yoneda lemma tells you that for any functor $F$, the types $F a$ and $\forall b . (a \rightarrow b) \rightarrow F b$ are isomorphic. (Restricting attention to computable total functions.) This really is a non-trivial statement and quite surprising when you first see it. Unfortunately it's tricky to explain without some CS backround.

Nonetheless I'll risk failure and try to explain a specific example when $F$ is the 'list' functor, assuming a little computing knowledge:

Fix a type $a$. Suppose you have a (polymorphic) Haskell function $f$ that for any type $b$ maps functions $g\colon a\rightarrow b$ into a list of elements of type $b$. Then $f$ is equal to a function that applies $g$ elementwise to some fixed list of elements of $a$. It's a powerful result. Just knowing the type of the function $f$ is enough to deduce significant detail about what it does. It can reduce the amount of work required to prove the correctness of programs.

The crucial thing that makes this work is that Haskell uses "parametric polymorphism". If you write a function that is polymorphic it's impossible to use specific knowledge about the type, you have to write your function generically to work with all possible types.

• I would rephrase this in layman's terms as "any function $X\to Y$ is uniquely determined by its pointwise action on elements of $X$, whatever $X$ and $Y$ mean". You know, the basic "a function is a rule which maps each element of $X$ to some element of $Y$". Something that is definitely true in naive set theory but fails miserably in most categories and is problematic in axiomatic set theory. Now the trick is that if you generalize your notion of "element" from a morphism $pt \to X$ to a general $\Gamma \to X$, then the naive definition of function becomes correct - by Yoneda's lemma! Commented May 21, 2014 at 23:34
• @AntonFetisov That is a brilliant way to motivate Yoneda! Well-done :-) Commented Oct 20, 2018 at 23:26

Determine all natural transformations (mod-$2$ cohomology operations) $H^n(-,\mathbb{Z}/2) \to H^m(-,\mathbb{Z}/2)$: We have $H^n(-,\mathbb{Z}/2) = [-, K(\mathbb{Z}/2,n)]$ by Brown representability. By Yoneda, we get $[K(\mathbb{Z},m), K(\mathbb{Z},n)] = H^n(K(\mathbb{Z}/2,m),\mathbb{Z}/2)$. So the mod-$2$ Steenrod algebra is the cohomology ring of the Eilenberg-MacLane spaces.

• I know that "simple" is a relative notion and this example may be simple for you, but - alas - it's not for me. Commented Jan 15, 2010 at 8:20
• You can tell me what you don't understand and we'll help you.
– user19475
Commented Jan 15, 2010 at 15:56
• Even if not simple, this is a very good example. It's one of few examples where Yoneda's lemma allows you to understand something that would be much more difficult to understand without it. The details will be in any book about "Cohomology Operations", for example the one by Mosher and Tanguchi. Commented Jan 15, 2010 at 17:54
• Mosher and Tangora.
– user19475
Commented Sep 5, 2016 at 8:48

Well, here's a standard example of morphisms determining an object up to isomorphism: if $A$ is a finitely-generated integral $\mathbb{C}$-algebra, then the morphisms $A \to \mathbb{C}$ are precisely the maximal ideals $\text{MaxSpec } A$, which (by the Nullstellensatz) determine $A$ up to isomorphism.

• Is it the case, that (one of) the interesting question(s) is always, WHICH morphisms and compositions do suffice to determine an object upto isomorphism? (And sometimes it's just the sheer number of immediate in- and out-arrows, isn't it?) Commented Jan 15, 2010 at 16:29
• It's certainly of interest to determine, in a category, which "test objects" suffice to determine the identity of an object A given Hom(A, T) for each test object T. For certain categories finitely many or even one test object suffices. Commented Jan 15, 2010 at 16:46

One of my favourite facts of this type is that in the category of simplicial sets, maps from the standard $n$-simplex to any simplicial set $S$ correspond to the $n$-simplices of $S$. Obviously this is not a surprising result, but I find it particularly nice that it comes out of Yoneda.

• As far as I understand, it's possible to develop a lot of basic properties of homology from this one fact. In particular, you can prove that baricentric subdivision is chain homotopic to the identity on the one simplex, and this will imply that it doesn't affect homology on any simplicial complex. From this, you can get such facts as equivalence of singular and simplicial homology, homotopy invariance of homology, and I think other things I forgot. The exact details of the argument evade me, though. Does anybody remember it clearly? Commented Jan 15, 2010 at 17:51

Not so much a showcase maybe but rather a connection to an algebraist's intuition. A particular case of Yoneda is that a monoid $M$ acting on itself (by (say) left multiplication) is a free $M$-set on one generator, $\hom_M(M,X)\approx X$ naturally in $X$.

This can be in fact of course extended to the full Yoneda lemma - viewing set-valued functors on a category $\mathcal C$ as algebras for a multi-sorted equational theory (objects of $\mathcal C$ for sorts, unary operations only), Yoneda lemma becomes the statement that representables are single-generator free algebras.

• Where would be a good place for me to read more about these perspectives? I'm particularly interested in the last remark about representables and free algebras. Commented Oct 10, 2023 at 1:05

Consider the contravariant functor $\mathcal{P}_G(-):Top \longrightarrow Set$ that sends a space $X$ to the set of isomorphism classes of principal $G$-bundles over $X$. Denote by $BG$ the base space of the universal bundle.

A characteristic class can either be seen as
-A natural transformation $\mathcal{P}_G(-) \longrightarrow H^*(-)$
-An element of $H^*(BG)$.

Indeed, the Yoneda lemma gives a bijection $H^*(BG) \cong Nat([-,BG],H^* (-))$. But by definition of the universal bundle, $[-,BG]$ is equivalent to $\mathcal{P}_G(-)$.

The most simple (= trivial) example is, that in the category of sets Hom(1,$A$) is isomorphic (= equipollent) to $A$ (with 1 the singleton).

The second-most simple example will probably be in the category of 2-block-partions (sets + 1 unary relation).

The third-most simple example is assumably the one given above (sets + 1 binary relation).