Bridging Sina Hazratpour’s 2023 standalone formalization in
github.com/sinhp/CovariantYonedaLean4 (CovYoneda/src/yoneda.lean) with
Mathlib’s CategoryTheory.Yoneda on an interactive spatial proof canvas.
Let F, G : C → D be functors. A natural transformation α : F ⇒ G assigns to each object X ∈ C a component αX : F(X) → G(X) such that for every f : X → Y:
Highlight either path around the naturality square to inspect how components intertwine with functorial transport:
Click highlighted symbols (⥤, ⟶, ≫, naturality, Hom) to inspect their elaborated types in the Infoview:
-- Standalone definitions from sinhp/CovariantYonedaLean4 (2023) -- (Replace lines below with verbatim lines from CovYoneda/src/yoneda.lean if desired) structure Category (Obj : Type u) where Hom : Obj → Obj → Type v id : ∀ X, Hom X X comp : ∀ {X Y Z}, Hom X Y → Hom Y Z → Hom X Z structure NatTrans (F G : C ⥤ D) where app : ∀ X : C, F.obj X ⟶ G.obj X naturality : ∀ {X Y : C} (f : X ⟶ Y), F.map f ≫ app Y = app X ≫ G.map f def Hom (A : C) : C ⥤ Type v where obj X := A ⟶ X map f g := g ≫ f
C ⥤ D : Type (max u₁ u₂ v₁ v₂)
obj : C → D, a morphism map map : (X ⟶ Y) → (obj X ⟶ obj Y),
and functoriality axioms map_id and map_comp.
CovYoneda/src/yoneda.lean and Mathlib.
Set X = A and evaluate naturality at f : A → Y applied to the universal element idA ∈ HomC(A, A):
Start at the universal element id_A in the top-left corner; every morphism f : A → Y is the image of id_A under post-composition.
Click any tactic line below to step through the live Lean 4 proof state and goal turnstile (⊢):
-- Standalone Yoneda equivalence (sinhp/CovariantYonedaLean4, 2023) -- (Paste verbatim lines from CovYoneda/src/yoneda.lean here if customizing) def yoneda_fwd (α : NatTrans (Hom A) F) : F.obj A := α.app A (𝟙 A) def yoneda_bwd (u : F.obj A) : NatTrans (Hom A) F := { app := fun _ f => F.map f u, naturality := fun g => by funext f; exact F.map_comp f g u } theorem yoneda_left_inv (α : NatTrans (Hom A) F) : yoneda_bwd (yoneda_fwd α) = α := by apply NatTrans.ext; funext Y f have h := congrFun (α.naturality f) (𝟙 A) rw [Category.id_comp] at h exact h.symm
C : Type u
inst : Category C
A : C
F : C ⥤ Type v
α : NatTrans (Hom A) F
Y : C
f : A ⟶ Y
⊢ F.map f (α.app A (𝟙 A)) = α.app Y f
Instantiating F := HomC(B, −) in Theorem II.1 yields a canonical bijection between morphisms in C and natural transformations between representable functors:
Hence the contravariant Yoneda embedding よ : Cop ⥤ (C ⥤ Type) is fully faithful: two objects A, B ∈ C are isomorphic if and only if their representable functors are naturally isomorphic.
def fullyFaithfulCoyoneda : (coyoneda (C := C)).FullyFaithful where preimage {X Y} α := (yonedaEquiv X.unop (coyoneda.obj Y)).toFun α map_preimage α := (yonedaEquiv _ _).right_inv α preimage_map f := by simp [yonedaEquiv]
CovariantYonedaLean4 (top)
through the nested Yoneda Lemma subslips (bottom-left) to Corollary III.1 (bottom-right). Click any card to zoom back in.