The Yoneda Lemma

You are what you relate to: representable functors and presheaves

The Yoneda Lemma

"You are what you relate to." The Yoneda Lemma says that an object is completely determined by the collection of all morphisms into (or out of) it. It is the single most important result in category theory, and once you understand it, you see it everywhere.

You Are What You Relate To

Can you identify a mystery object just by knowing how it maps to other objects? Click each object below to reveal the hom-set Hom(?, X). Once all hom-sets are revealed, the mystery object's identity is uniquely determined — this is the essence of the Yoneda philosophy.

Fingerprint: 0/3 hom-sets revealed
?Mystery ObjectAclick to revealBclick to revealCclick to reveal

Key insight: An object is completely determined by its hom-sets — that is, by how it relates to every other object. Two objects with identical "relationship fingerprints" must be isomorphic. This is the philosophical core of the Yoneda Lemma.

Yoneda Embedding

The Yoneda embedding y : C → [Cᵒᵖ, Set] sends each object A to its representable presheaf Hom(A, −). This embedding is full and faithful, meaning it perfectly preserves all morphism information.

Category CfgABCyYonedaEmbedding

Key insight: The Yoneda embedding is full (every natural transformation between representable presheaves comes from a morphism) and faithful (different morphisms give different natural transformations). This means every category embeds into a functor category.

Yoneda Lemma: Step by Step

The Yoneda Lemma states: Nat(Hom(A,−), F) ≅ F(A), naturally in both A and F. Walk through the proof in both directions using the concrete example below.

Step 1 of 5

Setup

We have a functor F and the representable presheaf Hom(A, -). We want to show that natural transformations Nat(Hom(A,-), F) correspond bijectively to elements of F(A).

Hom(A, −)Functor FHom(1,1){id₁}Hom(1,2){f}Hom(1,3){g∘f}F(1){a, b}F(2){x, y, z}F(3){p}alpha_1alpha_2alpha_3
Nat(Hom(A, −), F) F(A)
naturally in A and F

Key insight: A natural transformation out of a representable functor is completely determined by a single value — its action on the identity morphism. Naturality forces all other components. The element alpha_A(id_A) ∈ F(A) is the "DNA" that uniquely encodes the entire natural transformation.

Presheaf Visualizer

A presheaf on a category C is a functor P : Cᵒᵖ → Set. It assigns a set (a "fiber") to each object, and a restriction map to each morphism — going in the opposite direction. Think of it as a "fiber bundle" over the category.

Fibers (sets assigned to each object)P(A) = {a1, a2, a3}a1a2a3P(B) = {b1, b2}b1b2P(C) = {c1}c1Base Category CABCfgg∘f

Functoriality Check

P(g∘f)(c1) = a1
P(f) ∘ P(g)(c1) = P(f)(b1) = a1 Consistent!
P(g∘f) = P(f) ∘ P(g) — contravariant composition reverses order

Key insight: A presheaf is a "generalized object" that records a family of sets indexed by the category, with restriction maps going backwards (contravariant). The representable presheaves Hom(−, A) are the "basic building blocks" from which all presheaves are built.

Key Takeaways

  • Identity from Relations — An object is completely determined by all morphisms to/from it.
  • Yoneda Embedding — y : C → [Cᵒᵖ, Set] is full and faithful, embedding C into its presheaf category.
  • The Lemma — Nat(Hom(A,−), F) ≅ F(A): natural transformations from a representable correspond to elements.
  • Presheaves — Functors Cᵒᵖ → Set generalize the notion of "varying sets over a category."