Yoneda's Lemma in Excruciating Detail

27 July 2018

Yoneda’s lemma is not hard, say I, having spent an embarrassing amount of time formalising it in Agda. It’s really just following the types. However, the types are complex and Awodey goes over the details a little too quickly for my taste, so I feel validated in processing my trauma by writing a blog post, millennial style.

I assume familiarity with products, exponentials, naturality and the representable functors. The next section contains very brief discussions of these topics, to serve as a reference and to fix the notation (which is mostly Awodey’s, but I deviate in a few places). Afterwards, we’ll dive into the proof.

1 Prerequisites

1.1 Notation

Categories use boldfaced letters. I write \(A ∈ \mathbf{C}\) for “A is an object of \(\mathbf{C}\)” and \(f : A → B ∈ \mathbf{C}\) for “\(f\) is an arrow from \(A\) to \(B\) in \(\mathbf{C}\)”.

I like to put type information all over the place, so for example \(f = g : A → B\) means that \(f : A → B\), \(g : A → B\) and \(f = g\). \(f \;(x ∈ S)\) is the function \(f\) applied to \(x\), noting that \(x ∈ S\).

You may want to verify that the above are valid definitions of functors/natural transformations.

Using \(\mathrm{Curry}\), we can also define a function that transposes a bifunctor in its second argument, rather than the first: \[\begin{eqnarray}
&& \mathrm{Curry}₂ \;F : \mathbf{C}→ \mathbf{B}⇒ \mathbf{D}\\
&& \mathrm{Curry}₂ \;F := \mathrm{Curry}\;(F ∘ \mathrm{Swap})
\end{eqnarray}\]

2 Proof

2.1 Theorem Statement

When I formalised the proof, one of the main difficulties was an imprecise understanding of the actual theorem statement, so let’s get that out of the way first. As a nice side effect, we’ll discover a more succinct formulation of the theorem than what I’ve seen elsewhere.

The way the theorem is usually presented goes something like this: For an arbitrary category \(\mathbf{C}\), an object \(C ∈ \mathbf{C}\) and a functor \(F : \mathbf{C}^{\mathrm{op}} → \mathbf{Sets}\),

We have a family of isomorphisms

\[ i_{C,F} : \mathrm{Hom}(y \;C, F) ≅ F \;C \]

Recall that \(y : \mathbf{C}→ \mathbf{C}^{\mathrm{op}} ⇒ \mathbf{Sets}\), so \(y \;C : \mathbf{C}^{\mathrm{op}} → \mathbf{Sets}\). The \(\mathrm{Hom}\) is the set of natural transformations between \(y \;C\) and \(F\).

\(i\) is natural in \(C\). This means that if we hold \(F\) steady and let \(C\) vary, we get a natural transformation. More formally: The function

\[ i_{∙,F} : \mathrm{Hom}(y \;∙, F) → F \;∙ \]

is a natural transformation for all \(F\).

\(i\) is natural in \(F\), meaning that we can also let \(F\) vary while holding \(C\) steady:

\[ i_{C,∙} : \mathrm{Hom}(y \;C, ∙) → ∙ \;C \]

is a natural transformation for all \(C\).

I have two problems with this formulation. The first: When we say that \(i_{C,∙}\) is a natural transformation, then \(\mathrm{Hom}(y \;∙, F)\) must be a functor. But is it? After all, not just any old function is a functor.

This also brings us closer to addressing my second problem: Why are there two seemingly unrelated naturality conditions in the theorem statement? The answer, perhaps unsurprisingly, is that they are not unrelated: Yoneda’s lemma in fact talks about a single natural isomorphism.

To see why, consider that a natural transformation between bifunctors essentially consists of two natural transformations where we hold the first and second argument, respectively, steady. This looks much like the situation we’re in here: \(\mathrm{Hom}(y \;∙, ∙)\) is certainly a bifunctor. And the strange-looking “\(∙ \;∙\)” is the application bifunctor\(\mathrm{Ap}: (\mathbf{C}^{\mathrm{op}} ⇒ \mathbf{Sets}) × \mathbf{C}^{\mathrm{op}} → \mathbf{Sets}\). The lemma then simply states,

Now we can simplify the terms on both sides of the equation. They denote functions from \(\mathrm{Hom}(y \;C, F)\) to \(G \;D\), so we apply them to some natural transformation \(ι : y \;C → F\). On the left-hand side:

The equation holds, so \(i\) is indeed natural. Naturality of \(j = i^{-1}\) already follows from this, and so we have a natural iso.

I won’t bother with any formalities regarding small and large categories. The reliance on these crude notions – compared to a proper tower of universes – strikes me as a weakness of the usual presentation of category theory, though I have to admit it mostly does the job.↩

If you have a comment, please mail it to
<my forename>@<my surname>.de and I'll be happy to add it
to the post.
Contact |
Site proudly generated by
Hakyll