Natural Transformation

lean4-proofcategory-theoryvisualization
G(f)αX=αYF(f)G(f) \circ \alpha_X = \alpha_Y \circ F(f)

Statement

Let F,G:CDF, G : \mathcal{C} \to \mathcal{D} be functors. A natural transformation α:FG\alpha : F \Rightarrow G is a family of morphisms αX:F(X)G(X)\alpha_X : F(X) \to G(X) in D\mathcal{D}, one for each object XCX \in \mathcal{C}, such that for every morphism f:XYf : X \to Y in C\mathcal{C} the following square commutes:

G(f)αX=αYF(f)G(f) \circ \alpha_X = \alpha_Y \circ F(f)

This is the naturality condition: the components αX\alpha_X interlock coherently with how FF and GG act on morphisms.

Visualization

Identity natural transformation idF:FF\mathrm{id}_F : F \Rightarrow F on the power-set functor F=P:SetSetF = \mathcal{P} : \mathbf{Set} \to \mathbf{Set}:

  For any f : X → Y and subset S ⊆ X:

        id_{F(X)}
  F(X) ──────────▶ F(X)
    │                │
 F(f)│                │F(f)        F(f)(S) = f[S] = {f(s) | s ∈ S}
    ▼                ▼
  F(Y) ──────────▶ F(Y)
        id_{F(Y)}

  Check: F(f)(id_{F(X)}(S)) = F(f)(S) = id_{F(Y)}(F(f)(S))  ✓

Concrete non-trivial example: α:IdP\alpha : \mathrm{Id} \Rightarrow \mathcal{P} on Set\mathbf{Set}, where αX(x)={x}\alpha_X(x) = \{x\} (singleton embedding):

  X = {a, b},  Y = {1, 2, 3},  f : {a,b} → {1,2,3},  f(a)=1, f(b)=3

  α_X : {a,b} ──▶ P({a,b})          α_Y : {1,2,3} ──▶ P({1,2,3})
        a ↦ {a}                             1 ↦ {1}
        b ↦ {b}                             3 ↦ {3}

  Naturality: P(f)(α_X(a)) = P(f)({a}) = {f(a)} = {1} = α_Y(f(a))  ✓
              P(f)(α_X(b)) = {3} = α_Y(3) = α_Y(f(b))              ✓

Proof Sketch

  1. Identity natural transformation: Define (idF)X=idF(X)(\mathrm{id}_F)_X = \mathrm{id}_{F(X)}. Naturality: F(f)idF(X)=F(f)=idF(Y)F(f)F(f) \circ \mathrm{id}_{F(X)} = F(f) = \mathrm{id}_{F(Y)} \circ F(f).

  2. Vertical composition: Given α:FG\alpha : F \Rightarrow G and β:GH\beta : G \Rightarrow H, define (βα)X=βXαX(\beta \circ \alpha)_X = \beta_X \circ \alpha_X. Naturality follows by composing the two naturality squares.

  3. Horizontal composition (whiskering): For α:FG\alpha : F \Rightarrow G and a functor HH, the whiskered Hα:HFHGH\alpha : HF \Rightarrow HG has components (Hα)X=H(αX)(H\alpha)_X = H(\alpha_X).

  4. Functors and natural transformations form a category: The functor category [C,D][\mathcal{C}, \mathcal{D}] has functors as objects and natural transformations as morphisms.

Connections

Natural transformations are the morphisms in functor categories and are precisely what the Yoneda LemmaYoneda LemmaNat(Hom(X,),F)F(X)\mathrm{Nat}(\mathrm{Hom}(X,-),\, F) \cong F(X)Natural transformations from a representable functor y_X to F biject with elements of F(X)Read more → classifies when one functor is representable. The notion underpins the definition of Adjoint FunctorsAdjoint FunctorsHom(LX,Y)Hom(X,RY)\mathrm{Hom}(LX, Y) \cong \mathrm{Hom}(X, RY)A pair of functors L ⊣ R with a natural bijection Hom(LX, Y) ≅ Hom(X, RY)Read more → (the unit and counit are natural transformations) and appears in the Fundamental Theorem of Galois TheoryFundamental Theorem of Galois Theory{intermediate fields}{subgroups of Gal(K/F)}\{\text{intermediate fields}\} \longleftrightarrow \{\text{subgroups of } \text{Gal}(K/F)\}Bijection between intermediate fields and subgroups of the Galois groupRead more → as the natural isomorphism between Galois groups.

Lean4 Proof

import Mathlib.CategoryTheory.NatTrans

open CategoryTheory

/-- The identity natural transformation exists and its components are identities.
    Mathlib: `NatTrans.id` and `NatTrans.id_app`. -/
theorem nat_trans_id_app {C D : Type*} [Category C] [Category D]
    (F : CD) (X : C) :
    (NatTrans.id F).app X = 𝟙 (F.obj X) :=
  rfl

/-- Naturality square: for any α : F ⟹ G and f : X ⟶ Y,
    G.map f ≫ α.app X = α.app Y ≫ F.map f. -/
theorem nat_trans_naturality {C D : Type*} [Category C] [Category D]
    {F G : CD} (α : FG) {X Y : C} (f : XY) :
    F.map f ≫ α.app Y = α.app XG.map f :=
  α.naturality f