Elements as arrows
Here are five ways of saying the same kind of thing.
- An element of a set is the same as a function from a one-point set.
- An element of a group is the same as a group homomorphism : send to .
- A subset is the same as a function : send the points of to and the others to .
- A solution of in a commutative ring — say in , or in — is the same as a ring homomorphism .
- An open set of a topological space is the same as a continuous map from to the two-point Sierpiński space.
In each case a construction — elements, subsets, solutions, open sets — turns out to be nothing but the arrows into or out of one fixed object: , , , a quotient of a polynomial ring, the Sierpiński space. Such an is called representable, and the fixed object is its representing object.
This is more than a curiosity. If "is" , then everything about is encoded in the single object : to construct is to solve a whole family of problems at once. Products, free groups, quotients, tensor products, limits and the parameter spaces ("moduli spaces") of algebraic geometry are all defined this way. This lesson builds on natural transformations, since "is the same as" will mean "is naturally isomorphic to", and it prepares for the Yoneda lemma.
Probing with a test object
Think of an object as a measuring device. For any object , the set records all the ways can be "placed inside" — its -shaped elements. A map moves -shaped elements of to -shaped elements of by composition. So every object gives a functor .
Now start from the other end: you have a functor , some construction of "things in ". Is there a single test object whose -shaped elements are exactly the -things, compatibly with all maps? If so, there must be one special -thing living on itself: the one corresponding to . Call it . Every other -thing is then obtained by pushing along exactly one arrow . That special element is a universal element, and the main theorem of this lesson says that representations and universal elements are the same thing.
In the group example, and : every element of every group is the image of under exactly one homomorphism . In the subset example (where arrows go into the test object), and : every subset of every set is the preimage of under exactly one function.
Definitions
Throughout, is locally small: each is a set. Composition is written (" after ").
Definition— hom functors
For an object of :
- the covariant hom functor sends to and to post-composition ;
- the contravariant hom functor sends to and to pre-composition .
Definition— representable functor
A functor is representable if there is an object and a natural isomorphism . A functor is representable if there is an object and a natural isomorphism . The pair is a representation and a representing object.
Some authors (and Mathlib) call the covariant case corepresentable and keep representable for the contravariant one; always check which variance is meant.
Definition— universal element
A universal element of is a pair with such that for every object and every there is a unique arrow with .
For contravariant , a universal element is with such that for every and there is a unique with .
Examples and non-examples
Example— Elements of sets
The identity functor is represented by a one-point set with universal element : an element is the image of under exactly one function, . The functor is represented by a two-element set (a pair is a function from ), and by an -element set.
Example— Underlying sets of algebraic structures
- is represented by with universal element (proved in the next section).
- : also . : the monoid with .
- (rings with ): the polynomial ring with universal element — for each there is exactly one ring homomorphism with , evaluation at .
- : the one-dimensional space with universal element . : the one-point space.
- on groups: the free group with universal element .
Example— Subsets and the two-element set
The contravariant power-set functor sends to its set of subsets and to the preimage map . It is represented by with universal element : for each there is exactly one function with , the characteristic function . Naturality is the identity .
Example— Open sets and the Sierpiński space
Let with open sets , , . The functor , sending a space to its set of open subsets and a continuous map to preimage, is represented by : the function is continuous exactly when is open. The same object with the universal element (a closed set of ) represents the functor of closed subsets. One object can represent different functors; the universal element is part of the data.
Example— Solutions of equations
On commutative rings, the functor is represented by with universal element the pair of cosets : a homomorphism is determined by the images of , which can be any solution in . Likewise (units) is represented by , and on groups is represented by .
Example— Non-examples
- The covariant power-set functor , with (direct image), is not representable (Proposition 5 below), although its contravariant cousin is.
- The constant functor with value a two-element set is not representable, for the same reason.
- , sending to the set of equivalence relations on (pulled back along maps), is not representable: if then , but forces , while .
The main theorems
Theorem— Theorem 1 (representations are universal elements)
Let and let be an object.
- If is a natural isomorphism, then is a universal element, and for every .
- If is a universal element, then defines a natural isomorphism .
- These two constructions are mutually inverse: representations of by correspond bijectively to universal elements .
Proof
(1) Let . Naturality of along says . Apply both sides to : since , we get . Each is a bijection, so for every there is exactly one with , that is, with . So is universal.
(2) Each , , is a bijection: that is precisely the "exists unique" in the definition of a universal element. Naturality: for and , functoriality of gives .
(3) Starting from , part (1) shows that the isomorphism built in (2) from is , i.e. itself. Starting from , the isomorphism of (2) sends to .
∎
The dual statement, for contravariant functors and universal elements with arrows into , follows by applying Theorem 1 to . The argument in (1) — "a natural transformation out of is determined by where it sends " — is the heart of the Yoneda lemma, which removes the word "isomorphism".
Theorem— Theorem 2 (uniqueness up to unique isomorphism)
If and are universal elements of , then there is exactly one arrow with , and it is an isomorphism. In particular any two representing objects of are isomorphic.
Proof
Universality of gives a unique with ; universality of gives a unique with . Then
Both and send to , so by the uniqueness clause for (with , ) they are equal. Symmetrically . So is an isomorphism, and it is the only arrow sending to .
∎
The isomorphism is unique once the universal elements are fixed. An object can carry several universal elements: and both represent , and the unique isomorphism between them is .
Theorem— Theorem 3 (groups and subsets)
- is a universal element of , so naturally in , by .
- is a universal element of , so naturally in .
Proof
(1) Let be a group and . The map is a homomorphism , because for all integers , and . If is any homomorphism with , then , and , so by induction upwards and downwards from , for every . Hence is the unique homomorphism with . By Theorem 1 the bijections are natural: for , .
(2) Given , a function satisfies exactly when for and otherwise. So exists and is unique; apply (the dual of) Theorem 1.
∎
Theorem— Theorem 4 (universal properties are representability)
- Products. Objects have a product if and only if is a universal element of (contravariant). Dually, coproducts represent .
- Free groups. For a set , the free group is a universal element of : every map extends uniquely to a homomorphism . Presentations generalise this: represents .
- Quotients. For , is a universal element of . For an equivalence relation on a set , represents .
- Limits. A diagram has a limit if and only if the functor is representable; a limit is a universal element (a universal cone).
Proof
In each case, write out the definition of a universal element and compare it with the defining universal property — they are word for word the same. For (1): a universal element is such that for every and every pair there is a unique with , because the functor acts on by precomposition in both coordinates. That is the definition of a product. For (3) with groups: kills , and the factorisation theorem says every with factors as for exactly one ; since the functor acts by post-composition, this is universality of . Items (2) and (4) are the same unwinding. Theorem 2 then gives, for free, that products, free groups, quotients and limits are unique up to a unique isomorphism compatible with the structure maps.
∎
Theorem— Proposition 5 (a necessary condition)
If is representable, then has exactly one element. If is representable by , then has exactly one element and for finite . Consequently the covariant power-set functor is not representable.
Proof
From any set there is exactly one function , so is a one-element set. Into any there is exactly one function from , and there are functions from an -element set. For the covariant power set, has two elements.
∎
A more conceptual necessary condition: a covariant representable functor preserves all limits (maps into a limit are compatible families of maps into the diagram), and dually a contravariant one turns colimits into limits. Freyd's representability criterion, a corollary of his adjoint functor theorem, gives a converse: if is complete and locally small, a functor is representable if and only if it preserves small limits and satisfies a "solution set" condition (Mac Lane, Categories for the Working Mathematician, Chapter V). We do not prove it here.
Representable functors in Lean
In Mathlib, F.RepresentableBy Y (for F : Cᵒᵖ ⥤ Type) is a natural bijection (X ⟶ Y) ≃ F(X), and F.CorepresentableBy X (for covariant F : C ⥤ Type) is a natural bijection (X ⟶ Y) ≃ F(Y). Morphisms in the category of types are functions wrapped as ↾f.
The power-set functor and Bool. The functor is defined with preimages, and the representation sends a characteristic function χ : X → Bool to {x | χ x = true}. Naturality holds by rfl: the preimage of under is . The inverse needs to decide x ∈ S, which uses classical logic — a hint of the logician's viewpoint below.
/-- The **contravariant power-set functor** `𝒫 : Setᵒᵖ ⥤ Set`. It sends a set `X` to the set
of its subsets, and a function `f : Y → X` to the preimage map `S ↦ f⁻¹(S)`, which goes from
subsets of `X` to subsets of `Y` — backwards, hence `Typeᵒᵖ`. -/
def powerset : Typeᵒᵖ ⥤ Type where
obj X := Set X.unop
map f := ↾fun S => (f.unop : _ → _) ⁻¹' S/-- **The power-set functor is represented by the two-element set `Bool`.** Subsets `S ⊆ X`
correspond to characteristic functions `χ : X → Bool` (`S = {x | χ x = true}`), and the
correspondence is natural: the characteristic function of `f⁻¹(S)` is `χ_S ∘ f`.
Building `χ_S` from `S` needs to decide `x ∈ S`, which uses classical logic. -/
theorem powerset_representable : Nonempty (powerset.RepresentableBy Bool) :=
⟨{ homEquiv := fun {X} =>
{ toFun := fun χ => {x | χ x = true}
invFun := fun (S : Set X) => ↾fun x => @decide (x ∈ S) (Classical.propDecidable _)
left_inv := fun χ => by
ext x
simp
right_inv := fun (S : Set X) => by
apply Set.ext
intro x
simp }
homEquiv_comp := fun _ _ => rfl }⟩Groups and . First the induction from Theorem 3, then the bijection and its naturality. (Mathlib writes the integers as a multiplicative group Multiplicative ℤ.) Finally Mathlib's own statement for its category GrpCat, built on Joël Riou's natural isomorphism GrpCat.coyonedaObjIsoForget.
/-- A group homomorphism `φ : ℤ → G` is determined by `g = φ(1)`: it must send `n` to `gⁿ`.
(In Mathlib the integers *as a multiplicative group* are `Multiplicative ℤ`, and `ofAdd n` is
`n` seen there.) Proof by induction over the integers: `φ(n + 1) = φ(n) φ(1)` and
`φ(n − 1) = φ(n) φ(1)⁻¹`. -/
theorem int_hom_eq_zpow (φ : Multiplicative ℤ →* G) (n : ℤ) :
φ (Multiplicative.ofAdd n) = φ (Multiplicative.ofAdd 1) ^ n := by
induction n using Int.induction_on with
| zero => simp
| succ k ih =>
calc φ (Multiplicative.ofAdd ((k : ℤ) + 1))
= φ (Multiplicative.ofAdd (k : ℤ) * Multiplicative.ofAdd 1) := rfl
_ = φ (Multiplicative.ofAdd (k : ℤ)) * φ (Multiplicative.ofAdd 1) := φ.map_mul _ _
_ = φ (Multiplicative.ofAdd 1) ^ (k : ℤ) * φ (Multiplicative.ofAdd 1) := by rw [ih]
_ = φ (Multiplicative.ofAdd 1) ^ ((k : ℤ) + 1) := (zpow_add_one _ _).symm
| pred k ih =>
calc φ (Multiplicative.ofAdd (-(k : ℤ) - 1))
= φ (Multiplicative.ofAdd (-(k : ℤ)) * (Multiplicative.ofAdd 1)⁻¹) := rfl
_ = φ (Multiplicative.ofAdd (-(k : ℤ))) * (φ (Multiplicative.ofAdd 1))⁻¹ := by
rw [φ.map_mul, φ.map_inv]
_ = φ (Multiplicative.ofAdd 1) ^ (-(k : ℤ)) * (φ (Multiplicative.ofAdd 1))⁻¹ := by rw [ih]
_ = φ (Multiplicative.ofAdd 1) ^ (-(k : ℤ) - 1) := (zpow_sub_one _ _).symm/-- **`Hom(ℤ, G) ≃ G`**: evaluating at `1` is a bijection from group homomorphisms `ℤ → G` to
elements of `G`; the inverse sends `g` to `n ↦ gⁿ` (Mathlib's `zpowersHom`). Injectivity is
`int_hom_eq_zpow`. The pair `(ℤ, 1)` is a universal element of the forgetful functor. -/
def intHomEquiv : (Multiplicative ℤ →* G) ≃ G where
toFun φ := φ (Multiplicative.ofAdd 1)
invFun g := zpowersHom G g
left_inv φ := by
refine MonoidHom.ext fun n => ?_
have h := int_hom_eq_zpow φ (Multiplicative.toAdd n)
rw [ofAdd_toAdd] at h
simp [h]
right_inv g := by simp/-- The bijection `Hom(ℤ, G) ≃ G` is **natural in `G`**: composing with a homomorphism
`f : G → H` on the left corresponds to applying `f` to the element. This is what makes it a
natural isomorphism `Hom(ℤ, −) ≅ U` with the forgetful functor `U`, not just a family of
bijections. -/
theorem int_hom_equiv_natural (f : G →* H) (φ : Multiplicative ℤ →* G) :
intHomEquiv (f.comp φ) = f (intHomEquiv φ) :=
rfl/-- **The forgetful functor `Grp ⥤ Set` is corepresentable**, in Mathlib's category `GrpCat`
of groups. This applies Mathlib's instance `GrpCat.forget_isCorepresentable`, built from the
natural isomorphism `GrpCat.coyonedaObjIsoForget : Hom(ℤ, −) ≅ forget` (with `ℤ` lifted to
the right universe). -/
theorem forget_grp_corepresentable : (forget GrpCat.{u}).IsCorepresentable :=
inferInstanceUniversal elements: Theorems 1 and 2 in full generality. The definition, both directions of Theorem 1, the bijection between them, and the uniqueness theorem. The proof of universal_unique follows the human proof line by line: build and , then compare with the identity using the uniqueness clause.
/-- An element `x ∈ F(A)` of a functor `F : C ⥤ Set` is **universal** if every element of
every `F(B)` is obtained from `x` along exactly one arrow: for all `B` and `y ∈ F(B)` there is
a unique `f : A ⟶ B` with `F(f)(x) = y`. Example: `1 ∈ U(ℤ)` for the forgetful functor on
groups. -/
def IsUniversal {A : C} (x : F.obj A) : Prop :=
∀ (B : C) (y : F.obj B), ∃! f : A ⟶ B, F.map f x = y/-- **A representation gives a universal element**: if `e : Hom(A, −) ≅ F`, then
`x = e(id_A)` is universal. Given `y ∈ F(B)`, the arrow is `e⁻¹(y)`; it works because
`F(f)(e(id_A)) = e(id_A ≫ f) = e(f)` by naturality, and it is unique because `e` is
injective. -/
theorem universal_of_corepresentable {A : C} (e : F.CorepresentableBy A) :
IsUniversal F (e.homEquiv (𝟙 A)) := by
intro B y
refine ⟨e.homEquiv.symm y, ?_, ?_⟩
· show F.map (e.homEquiv.symm y) (e.homEquiv (𝟙 A)) = y
rw [← e.homEquiv_comp, Category.id_comp, Equiv.apply_symm_apply]
· intro f hf
rw [← hf, ← e.homEquiv_comp, Category.id_comp, Equiv.symm_apply_apply]/-- **A universal element gives a representation**: if `x ∈ F(A)` is universal, then
`f ↦ F(f)(x)` is a natural bijection `Hom(A, B) ≃ F(B)`. Bijectivity is exactly the
"exists unique" in the definition; naturality is functoriality of `F`. -/
noncomputable def corepresentableOfUniversal {A : C} {x : F.obj A} (h : IsUniversal F x) :
F.CorepresentableBy A where
homEquiv {B} := Equiv.ofBijective (fun f : A ⟶ B => F.map f x)
⟨fun _ g hfg => (h B (F.map g x)).unique hfg rfl,
fun y => (h B y).exists⟩
homEquiv_comp g f := Functor.map_comp_apply F f g x/-- **Representations of `F` by `A` correspond exactly to universal elements of `F(A)`.**
The two constructions above are mutually inverse: a representation is determined by where it
sends `id_A` (Mathlib's `CorepresentableBy.ext`), and `F(id_A)(x) = x`. -/
theorem corepresentable_equiv_universal {A : C} :
Nonempty (F.CorepresentableBy A ≃ {x : F.obj A // IsUniversal F x}) :=
⟨{ toFun := fun e => ⟨e.homEquiv (𝟙 A), universal_of_corepresentable e⟩
invFun := fun x => corepresentableOfUniversal x.2
left_inv := fun e => by
apply Functor.CorepresentableBy.ext
exact Functor.map_id_apply F A _
right_inv := fun x => by
apply Subtype.ext
exact Functor.map_id_apply F A _ }⟩/-- **Universal elements are unique up to unique isomorphism.** If `(A, x)` and `(A', x')`
are both universal for `F`, there is an isomorphism `e : A ≅ A'` with `F(e)(x) = x'`, and it is
the *only* arrow `A ⟶ A'` sending `x` to `x'`.
Proof: universality gives `f : A ⟶ A'` with `F(f)(x) = x'` and `g : A' ⟶ A` with
`F(g)(x') = x`. Then `g ∘ f` and `id_A` both send `x` to `x`, so they are equal by the
uniqueness clause for `(A, x)`; likewise `f ∘ g = id_{A'}`. -/
theorem universal_unique {A A' : C} {x : F.obj A} {x' : F.obj A'}
(h : IsUniversal F x) (h' : IsUniversal F x') :
∃ e : A ≅ A', F.map e.hom x = x' ∧ ∀ f : A ⟶ A', F.map f x = x' → f = e.hom := by
obtain ⟨f, hf, hf_uniq⟩ := h A' x'
obtain ⟨g, hg, -⟩ := h' A x
have hgf : f ≫ g = 𝟙 A := by
apply (h A x).unique
· rw [Functor.map_comp_apply, hf, hg]
· rw [Functor.map_id_apply]
have hfg : g ≫ f = 𝟙 A' := by
apply (h' A' x').unique
· rw [Functor.map_comp_apply, hg, hf]
· rw [Functor.map_id_apply]
exact ⟨⟨f, g, hgf, hfg⟩, hf, fun f' hf' => hf_uniq f' hf'⟩Not every functor is representable (Proposition 5). A corepresentable functor on types has at most one element over the one-point type, and so the covariant power-set functor has no corepresentation at all — IsEmpty of the type of corepresentations.
/-- **A necessary condition.** If a functor `F : Set ⥤ Set` is corepresentable, then `F` of a
one-point set has at most one element — because there is exactly one map from any set to a
point. So a functor whose value at the point has two distinct elements cannot be
corepresentable: not every functor to `Set` is representable. -/
theorem subsingleton_of_corepresentable {F : Type ⥤ Type} {A : Type}
(e : F.CorepresentableBy A) : Subsingleton (F.obj PUnit) := by
constructor
intro y y'
rw [← e.homEquiv.apply_symm_apply y, ← e.homEquiv.apply_symm_apply y']
congr 1
ext a/-- The **covariant power-set functor**: a set goes to its set of subsets, and `f : X → Y` to
the direct-image map `S ↦ f(S)`. Same objects as `powerset`, arrows the other way. -/
def imagePowerset : Type ⥤ Type where
obj X := Set X
map f := ↾fun S => (f : _ → _) '' S
map_id X := by
ext S
simp
map_comp f g := by
ext S
simp [Set.image_image]/-- **The covariant power-set functor is not corepresentable** (while the contravariant one is
represented by `Bool`). Its value at a point, `Set PUnit = {∅, {⋆}}`, has two elements, which
`subsingleton_of_corepresentable` forbids. -/
theorem image_powerset_not_corepresentable (A : Type) :
IsEmpty (imagePowerset.CorepresentableBy A) := by
constructor
intro e
have hsub := subsingleton_of_corepresentable e
have h : (∅ : Set PUnit) = Set.univ := hsub.elim _ _
have hmem : PUnit.unit ∈ (∅ : Set PUnit) := by
rw [h]
exact Set.mem_univ _
exact hmemUniversal properties as representations (Theorem 4). Products and quotients of types are proved here; free monoids and limits apply Mathlib (FreeMonoid.lift, IsLimit.ofRepresentableBy).
/-- The functor `X ↦ Hom(X, A) × Hom(X, B)` (pairs of maps out of `X`), contravariant in `X`:
a map `f : Y → X` turns a pair `(p, q)` into `(p ∘ f, q ∘ f)`. -/
def pairsOfMaps (A B : Type) : Typeᵒᵖ ⥤ Type where
obj X := (X.unop → A) × (X.unop → B)
map f := ↾fun pq => (pq.1 ∘ f.unop, pq.2 ∘ f.unop)/-- **The product represents pairs of maps**: `Hom(X, A × B) ≃ Hom(X, A) × Hom(X, B)`,
naturally in `X`, by `h ↦ (π₁ ∘ h, π₂ ∘ h)` with inverse `(p, q) ↦ ⟨p, q⟩`. This is exactly the
universal property of the product, read as a representation. -/
theorem product_represents (A B : Type) : Nonempty ((pairsOfMaps A B).RepresentableBy (A × B)) :=
⟨{ homEquiv :=
{ toFun := fun h => (Prod.fst ∘ h, Prod.snd ∘ h)
invFun := fun pq => ↾fun x => (pq.1 x, pq.2 x)
left_inv := fun _ => rfl
right_inv := fun _ => rfl }
homEquiv_comp := fun _ _ => rfl }⟩/-- For an equivalence relation `s` on `X`, the covariant functor sending `Y` to the maps
`X → Y` that are constant on equivalence classes (`a ≈ b → f a = f b`). -/
def respectingMaps {X : Type} (s : Setoid X) : Type ⥤ Type where
obj Y := {f : X → Y // ∀ a b, a ≈ b → f a = f b}
map g := ↾fun f => ⟨(g : _ → _) ∘ f.1, fun a b hab => by simp [f.2 a b hab]⟩/-- **The quotient corepresents maps that respect the relation**:
`Hom(X ⧸ ~, Y) ≃ {f : X → Y | a ~ b → f a = f b}`, naturally in `Y`, by composing with the
quotient map. Surjectivity is `Quotient.lift` ("a respecting map factors through the
quotient") and injectivity holds because every element of `X ⧸ ~` is a class `[a]`. -/
theorem quotient_corepresents {X : Type} (s : Setoid X) :
Nonempty ((respectingMaps s).CorepresentableBy (Quotient s)) :=
⟨{ homEquiv :=
{ toFun := fun h => ⟨(h : _ → _) ∘ Quotient.mk s, fun a b hab => by
simp [Quotient.sound hab]⟩
invFun := fun f => ↾Quotient.lift f.1 f.2
left_inv := fun h => by
ext q
induction q using Quotient.ind
rfl
right_inv := fun _ => rfl }
homEquiv_comp := fun _ _ => rfl }⟩/-- **The free monoid represents "maps of the generators"**: every function `f : α → M` into a
monoid extends to exactly one monoid homomorphism `FreeMonoid α → M` (words are sent to
products). This applies Mathlib's `FreeMonoid.lift` and `FreeMonoid.hom_eq`; it says that
`(FreeMonoid α, of)` is a universal element of `M ↦ (α → M)`. -/
theorem free_monoid_universal {α M : Type*} [Monoid M] (f : α → M) :
∃! φ : FreeMonoid α →* M, ∀ a, φ (FreeMonoid.of a) = f a :=
⟨FreeMonoid.lift f, fun a => FreeMonoid.lift_eval_of f a,
fun ψ hψ => FreeMonoid.hom_eq fun a => by rw [hψ a, FreeMonoid.lift_eval_of]⟩/-- **Limits are representing objects.** For a diagram `K : J ⥤ C`, a representation of the
functor `X ↦ {cones over K with apex X}` by an object `L` makes the cone corresponding to `id_L`
a limit cone. This applies Mathlib's `IsLimit.ofRepresentableBy`. -/
theorem limit_of_representable {J C : Type*} [Category J] [Category C] {K : J ⥤ C} {L : C}
(h : K.cones.RepresentableBy L) :
Nonempty (Limits.IsLimit (Limits.IsLimit.OfNatIso.limitCone h)) :=
⟨Limits.IsLimit.ofRepresentableBy h⟩What is and is not formalised. Theorems 1 and 2 are proved independently for every locally small category and every functor to types. Theorem 3 is proved independently (with Mathlib's category-level statement cited alongside), Theorem 4 is proved for products and quotients in Type and cited from Mathlib for free monoids and limits, and Proposition 5 is proved for functors on Type. The open-set, ring and free-group examples and Freyd's criterion are not formalised in this module.
Counting arrows
Representability makes counting predictions: if is represented by , then the number of homomorphisms must equal the number of elements of with . The experiment checks this by brute force — trying every function — and also checks naturality of subsets versus characteristic functions for all maps between small sets, and applies the counting test of Proposition 5 to some functors on finite sets.
"""Representable functors in finite examples: checking and counting.
Three exact, exhaustive checks on small finite sets and groups.
(1) Subsets are characteristic functions: for all sets X, Y with at most 3
elements and all maps f : Y -> X, the characteristic function of f^-1(S) is
chi_S composed with f (naturality of P(X) = Hom(X, 2)).
(2) Homomorphisms out of a presented group are solutions of its relations: we
count all homomorphisms Z/n -> S3 and V4 -> S3 by brute force over every
function and compare with the number of elements g with g^n = 1, and of
commuting pairs of involutions.
(3) A counting test: a representable functor on finite sets has |F(n)| = n^a
(covariant) or a^n (contravariant). Sequences that fit no such formula
belong to functors that cannot be representable.
"""
import itertools
def maps(dom, cod):
"""All functions dom -> cod, as tuples indexed by dom = range(len)."""
return list(itertools.product(range(cod), repeat=dom))
def subsets(n):
"""All subsets of range(n), as frozensets."""
return [frozenset(c) for k in range(n + 1)
for c in itertools.combinations(range(n), k)]
def chi(s, n):
"""The characteristic function of s ⊆ range(n), as a tuple of 0/1."""
return tuple(1 if x in s else 0 for x in range(n))
def preimage(f, s):
"""f^-1(s) for f given as a tuple."""
return frozenset(y for y, fy in enumerate(f) if fy in s)
def powerset_naturality(max_size=3):
"""Check chi(f^-1(S)) = chi(S) ∘ f for all f : Y -> X, S ⊆ X; return the
number of checks and the number of failures."""
checks = failures = 0
for n in range(max_size + 1):
for m in range(max_size + 1):
for f in maps(m, n):
for s in subsets(n):
checks += 1
lhs = chi(preimage(f, s), m)
rhs = tuple(chi(s, n)[f[y]] for y in range(m))
failures += lhs != rhs
return checks, failures
# Groups as (elements, multiplication function, identity).
def symmetric_group_3():
"""S3 as permutations of (0, 1, 2); (p*q)(i) = p(q(i))."""
elems = list(itertools.permutations(range(3)))
return elems, (lambda p, q: tuple(p[q[i]] for i in range(3))), (0, 1, 2)
def cyclic_group(n):
"""Z/n under addition."""
return list(range(n)), (lambda a, b: (a + b) % n), 0
def klein_four():
"""V4 = Z/2 x Z/2."""
elems = [(a, b) for a in range(2) for b in range(2)]
return elems, (lambda x, y: ((x[0] + y[0]) % 2, (x[1] + y[1]) % 2)), (0, 0)
def count_homs(source, target):
"""Brute force: how many of the functions source -> target respect
multiplication? (Such functions automatically preserve 1 and inverses.)"""
s_el, s_mul, _ = source
t_el, t_mul, _ = target
count = 0
for images in itertools.product(t_el, repeat=len(s_el)):
h = dict(zip(s_el, images))
if all(h[s_mul(a, b)] == t_mul(h[a], h[b]) for a in s_el for b in s_el):
count += 1
return count
def power(g, n, mul, one):
"""g^n in a group."""
result = one
for _ in range(n):
result = mul(result, g)
return result
def nth_roots_of_one(n, group):
"""Number of g with g^n = 1: the size of Hom(Z/n, G) by representability."""
elems, mul, one = group
return sum(power(g, n, mul, one) == one for g in elems)
def commuting_involution_pairs(group):
"""Pairs (x, y) with x^2 = y^2 = 1 and xy = yx: Hom(V4, G)."""
elems, mul, one = group
return sum(mul(x, x) == one and mul(y, y) == one and mul(x, y) == mul(y, x)
for x in elems for y in elems)
def fits_covariant(seq):
"""Return a with seq[n] == n**a for all n (0**0 = 1), or None."""
for a in range(len(seq) + 3):
if all(s == n ** a for n, s in enumerate(seq)):
return a
return None
def fits_contravariant(seq):
"""Return a with seq[n] == a**n for all n, or None."""
if len(seq) < 2:
return None
a = seq[1]
return a if all(s == a ** n for n, s in enumerate(seq)) else None
def bell(n):
"""Number of equivalence relations on an n-element set."""
row, total = [1], 1
for _ in range(n):
new = [row[-1]]
for x in row:
new.append(new[-1] + x)
row, total = new, new[0]
return total if n else 1
def main():
checks, failures = powerset_naturality(3)
print("1. Subsets versus maps to {0, 1}: chi(f^-1 S) = chi(S) ∘ f")
print(f" all f : Y -> X, S ⊆ X with |X|, |Y| <= 3: {checks} checks,"
f" {failures} failures")
print()
s3 = symmetric_group_3()
print("2. Homomorphisms into S3: brute force versus the relations")
for n in range(1, 5):
print(f" |Hom(Z/{n}, S3)| = {count_homs(cyclic_group(n), s3):<3}"
f" #{{g in S3 : g^{n} = 1}} = {nth_roots_of_one(n, s3)}")
print(f" |Hom(V4, S3)| = {count_homs(klein_four(), s3):<3}"
f" #{{(x, y) : x^2 = y^2 = 1, xy = yx}} = "
f"{commuting_involution_pairs(s3)}")
print()
print("3. Counting test on sets of size n = 0..5 (representable => fits)")
rows = [
("contravariant X -> P(X), preimage", [2 ** n for n in range(6)], "contra"),
("contravariant X -> equivalence relations",
[bell(n) for n in range(6)], "contra"),
("covariant X -> X × X", [n * n for n in range(6)], "co"),
("covariant X -> P(X), direct image", [2 ** n for n in range(6)], "co"),
("covariant X -> X ⊔ X", [2 * n for n in range(6)], "co"),
]
for label, seq, kind in rows:
a = fits_contravariant(seq) if kind == "contra" else fits_covariant(seq)
verdict = f"fits with |A| = {a}" if a is not None else "fits no |A|"
print(f" {label:<42} {verdict}")
print(f" sizes {seq}")
print()
print("Epistemic status: exhaustive, exact checks in these finite cases. "
"Part 2\nconfirms Hom(Z/n, G) = {g : g^n = 1} for G = S3 only. In "
"part 3 a\nsequence that fits proves nothing by itself (naturality "
"is also needed),\nbut one that fits no formula proves that the "
"functor is not representable.")
if __name__ == "__main__":
main()What to notice: is for , exactly the number of solutions of in (the identity, three transpositions, two 3-cycles). The Klein four-group gives homomorphisms, one for each commuting pair of elements of order dividing . In part 3, a functor whose sizes fit no formula or cannot be representable; a sequence that does fit (like for subsets) is consistent with representability but does not prove it — naturality matters too. This is exhaustive evidence for finitely many cases, not a proof.
Explore: the product as a representing object
The product represents the functor "pairs of maps into and ". In the widget, choose maps and ; then try to build a map with and . Notice that you have no freedom at all: each is forced to be . That forced, unique choice is what "the pair is a universal element" means.
The product, by its maps
Choose maps f : Z → A and g : Z → B. Then try to build a map h : Z → A × B that projects back to f and g.
f : Z → A
g : Z → B
⟨f, g⟩ : Z → A × B
p ↦ (red, 2) q ↦ (blue, 2) r ↦ (red, 3)
Your turn: choose h(p), h(q), h(r) by clicking cells.
| A × B | 1 | 2 | 3 |
|---|---|---|---|
| red | |||
| blue |
Exercises
1. Representable functors
Warm-upHumanWhich pair is a universal element of the forgetful functor from abelian groups to sets?
2. Representable functors
CoreHumanThe group represents the functor sending a group to the set of commuting pairs . How many group homomorphisms are there?
3. Representable functors
CoreHumanHow many different natural isomorphisms are there, where is the forgetful functor?
4. Representable functors
CoreHumanWhich pairs with are universal elements of the contravariant power-set functor (acting by preimage)? Choose all that apply.
5. Representable functors
CoreHumanIn the proof of Theorem 2 we have with and with . Why is ?
6. Representable functors
CoreHumanWhich of these functors is not representable?
7. Representable functors
StretchHumanLet send a space to its set of closed subsets (a continuous map acts by preimage). Which pair represents ? Here is the Sierpiński space with open sets .
8. Representable functors
CoreFormalIn the lesson's Lean file, imagePowerset : Type ⥤ Type is the covariant power-set functor (direct images). Which Lean statement says that it is not representable, i.e. that no type represents it?
9. Representable functors
CoreComputationalSince represents , the number of homomorphisms equals the number of with . Write hom_count(n, m) computing this number (for ). Then compare your answers with .
Common misconceptions
Misconception
"Every functor to is representable." Far from it. The covariant power-set functor, the constant two-element functor and the equivalence-relation functor are not, by simple counting (Proposition 5). Representability is a strong condition: a covariant representable functor preserves every limit that exists.
Misconception
Confusing covariant and contravariant representability. is covariant (arrows out of ); is contravariant (arrows into ). Subsets are represented contravariantly by — a subset of is a map , and maps act by preimage. The same objects with direct images form a covariant functor that is not representable at all. Before asking "what represents ?", check which way acts on arrows.
Misconception
"The representing object is unique, so the representation is unique." The object is unique up to isomorphism, but a representation also includes the natural isomorphism, equivalently the universal element. represents in exactly two ways, with universal elements and (Exercise). What is unique is the isomorphism between two representations once their universal elements are fixed (Theorem 2).
Misconception
"Representable means equal to a hom functor." It means naturally isomorphic to one. is a set of subsets, not literally a set of functions; the content of the statement is the natural bijection . (In Lean, where Set X is defined as X → Prop, the power set happens to be represented by Prop on the nose.)
Misconception
"A generator is a universal element." Universality is relative to the functor. The element is a universal element of the functor , but not of the forgetful functor : there is no homomorphism sending to , so the "exists" half fails. And a set with fails to represent the identity functor through any of its elements because the "unique" half fails: many functions send a given point to .
Viewpoints
Algebra— Presentations, free objects and tensor products
To the algebraist, representability is the reason presentations work. The group is defined to represent the functor "-tuples of elements satisfying ". So represents -th roots of , and represents commuting pairs. Counting gives real theorems: the number of commuting pairs in a finite group is , where is the number of conjugacy classes (for : ). For modules over a commutative ring , the tensor product is the representing object of — its universal element is — and this, not a choice of construction, is what one uses in practice. See groups.
Geometry— The functor of points and moduli spaces
Grothendieck's algebraic geometry turns the motivation upside down. A geometric object is studied through its functor of points , the solutions of its equations with coordinates in each commutative ring : the circle has the rational points (Pythagorean triples), points over , over , and so on, all at once. An affine scheme is precisely a representable functor on commutative rings, represented by its coordinate ring. A moduli problem asks for a space whose points classify some objects: the Grassmannian scheme represents the functor whose value on is the set of rank- direct summands of (over a field : the -dimensional subspaces of ). Some natural moduli functors are not representable — the functor of elliptic curves up to isomorphism fails because elliptic curves have automorphisms such as — which leads to coarse moduli spaces (the -line) and to stacks. See algebraic geometry.
Topology— Classifying spaces and Brown representability
In topology, representing objects are classifying spaces. The Sierpiński space represents open sets, as above. Much deeper: on the homotopy category of pointed connected CW complexes, E. H. Brown's representability theorem (1962) says that every contravariant functor to sets that turns wedge sums into products and satisfies a Mayer–Vietoris condition is representable. Applied to singular cohomology it gives Eilenberg–MacLane spaces with
(homotopy classes of maps) for CW complexes ; for instance is the circle and is . Similarly, isomorphism classes of real vector bundles of rank over a paracompact space correspond to , so characteristic classes are cohomology classes of the classifying space. See algebraic topology.
Computation— Representable containers and memoisation
A functional programmer meets representable functors as containers. A container type F a is representable if F a ≅ (K → a) naturally in a for some index type K: pairs (a, a) with K = Bool, vectors of length with K = Fin n, infinite streams with K = ℕ. Lists are not: at the empty type there is one list (the empty one), which forces K to be empty, yet there are infinitely many lists of booleans — Proposition 5 in disguise. The isomorphism is the basis of memoisation: a function ℕ → a can be stored as the lazy stream of its values and looked up instead of recomputed.
Logic— Truth values as a representing object
The object representing "subsets" is an object of truth values: for sets, the Sierpiński space for open sets. In Lean, Set X is defined to be X → Prop, so the power-set functor is represented by Prop definitionally, and representing it by Bool instead needs classical logic, because turning a proposition into a boolean requires deciding it. In an elementary topos the representing object of subobjects is the subobject classifier , and its internal logic is in general intuitionistic, not two-valued; see elementary topoi. Informally, the Sierpiński space fits this picture too: its "truth values" behave like observable properties, confirmed as soon as evidence is seen but never certified false by any finite observation.
Wonder Trail
The universal property of the product, explored from first principles with finite sets: exactly the statement that is a universal element.
Wonder Trail · Optional · never gradedThe product, by its mapsCan you describe the set of pairs without ever looking inside it — only by how functions go into it?Follow the trailHistory and global context
- Universal mapping problems were formulated by Pierre Samuel in "On universal mappings and free topological groups" (Bulletin of the AMS, 1948), and systematised by Bourbaki in the chapter on structures of Théorie des ensembles (1957).
- Daniel Kan introduced adjoint functors in 1958; universal elements and adjunctions are two faces of the same idea.
- Alexander Grothendieck made representable functors the backbone of algebraic geometry in his Séminaire Bourbaki lectures of 1959–62 (collected as Fondements de la géométrie algébrique), constructing Hilbert and Picard schemes as representing objects and asking of each moduli problem whether its functor is representable.
- In topology, Samuel Eilenberg and Saunders Mac Lane constructed the spaces in the 1940s and 50s, and Edgar H. Brown Jr. proved his representability theorem in "Cohomology theories" (Annals of Mathematics, 1962).
- The Sierpiński space is named after the Polish mathematician Wacław Sierpiński. Nobuo Yoneda's lemma (1954), the subject of the next lesson, is the general principle behind Theorem 1.
Further reading
- Emily Riehl, Category Theory in Context (2016), Chapter 2 — representable functors, universal properties and the Yoneda lemma, with many examples.
- Tom Leinster, Basic Category Theory (2014), Chapter 4 — a gentle account of representables.
- Saunders Mac Lane, Categories for the Working Mathematician (1971; 2nd edition 1998), Chapters III and V — universal arrows, representability and Freyd's adjoint functor theorem.
- David Eisenbud and Joe Harris, The Geometry of Schemes (2000), Chapter VI — schemes as functors of points and representability.
- Allen Hatcher, Algebraic Topology (2002), Section 4.E — the Brown representability theorem.
- John Milnor and James Stasheff, Characteristic Classes (1974) — Grassmannians as classifying spaces for vector bundles.