The same construction, everywhere
The Cartesian product of sets, the direct product of groups, the product of topological spaces, the greatest common divisor of two numbers and the logical "and" of two statements look like five unrelated constructions. So do their partners: the disjoint union of sets, the free product of groups, the direct sum of abelian groups, the least common multiple and the logical "or".
They are not unrelated. Each of the first five is the answer to one question, asked in five different categories: what is the most economical object that maps to both and ? Each of the second five answers the mirror-image question: what is the most economical object that both and map to? The answers are called the product and the coproduct. When the pair is replaced by no objects at all, the same questions produce terminal and initial objects.
This lesson defines these notions by their universal properties, proves that the definitions pin the objects down up to a unique isomorphism, and then computes them — sometimes with surprising answers. The coproduct of two copies of in the category of groups is a non-abelian group whose geometry is a tree; the coproduct of and in commutative rings is the zero ring; and two fields usually have no product at all.
Generalised elements and the best possible pair
In , an element of is the same thing as a pair (an element of , an element of ). Category theory has no elements in general, but it has a replacement: a morphism is a generalised element of "of shape " (in , a map is an ordinary element). The product is then defined so that the slogan stays true for generalised elements:
The projections turn a morphism into a pair; the universal property says that this is a bijection, for every . Existence of the inverse says is big enough to hold every pair; uniqueness says it has nothing superfluous. The experiment below shows both conditions failing for wrong candidates: is too big (two morphisms for each pair), and alone is too small (some pairs have none).
The coproduct reverses every arrow: morphisms out of correspond to pairs of morphisms out of and out of — to define a map on , you define it on each piece separately. That is case analysis, and it is exactly how one defines a function on a disjoint union.
Definitions
Throughout, is a category and composition is written .
Definition— terminal and initial objects
An object is terminal if for every object there is exactly one morphism . An object is initial if for every object there is exactly one morphism . An object that is both initial and terminal is a zero object.
Definition— product
A product of objects and is an object with morphisms and (the projections) such that for every object and every pair of morphisms , there is a unique morphism with and . We write and .
More generally, a product of a family is an object with projections such that every family factors as for a unique . For the condition says: for every there is a unique . A terminal object is an empty product.
Definition— opposite category and coproduct
The opposite category has the same objects and a morphism for each , with composition reversed. A coproduct of and in is a product of and in . Unpacked: an object with morphisms , (the injections) such that for every pair , there is a unique with and . An initial object is an empty coproduct.
Definition— cones over a pair
A cone over the pair is an object with morphisms , . A morphism of cones is a morphism with and . Cones and their morphisms form a category .
A tour of products and coproducts
| Category | terminal | initial | ||
|---|---|---|---|---|
| any one-point set | pairs | disjoint union | ||
| trivial group | trivial group | direct product | free product | |
| , | direct sum | the same | ||
| (unital) | zero ring | free product of rings | ||
| zero ring | tensor product | |||
| one-point space | product topology | disjoint union topology | ||
| poset | greatest element | least element | meet | join |
| none | none | usually none | usually none |
Example— Sets
with the coordinate projections is a product: given , the map works, and any with , has both coordinates determined. The disjoint union is a coproduct: , , and this is forced. (The plain union is not a coproduct when : for , the maps and constant at a different point cannot both be extended.) The empty set is initial (the empty function is the unique map ) and every one-point set is terminal. The empty set is not terminal: there is no map .
Example— Groups: the free product
The direct product with componentwise multiplication is a product in , as in — the induced map is a homomorphism. The coproduct is the free product : its elements are reduced words with letters alternately from and , multiplied by concatenation followed by cancellation. Given and , the map sends a word to the product of the images of its letters in ; it is the only homomorphism extending and , because the letters generate . (That reduced words multiply associatively is the normal form theorem for free products; see the reading list.) For example is the free group on two generators, and is the infinite dihedral group.
Example— Abelian groups: product and coproduct coincide
In the direct sum is a product (as in ) and a coproduct with injections , : given and , the map is a homomorphism because is abelian, and it is the only one extending and since . The same holds in and . For infinitely many factors the two notions separate: is the product, while the coproduct is the subgroup of sequences with finitely many non-zero terms.
Example— Rings
In the category of rings with identity (and homomorphisms preserving ), is initial: the only homomorphism is . The zero ring is terminal. They differ, so there is no zero object. In commutative rings the coproduct of and is , with and ; for instance , while , because .
Example— Posets: meets and joins
A poset is a category with exactly one morphism when and none otherwise. All equations between morphisms hold automatically, so a product of and is just an element with , , and such that , imply : a greatest lower bound (meet). Dually the coproduct is the least upper bound (join). In , ordered by divisibility, the product of and is and the coproduct is . In the power set they are intersection and union. In the four-element poset under divisibility, and have two minimal upper bounds and no least one, so they have no coproduct:
Example— Topological spaces
The product of spaces and is with the product topology, generated by the boxes : it is the coarsest topology making continuous, and a map is continuous exactly when and are, since . The coproduct is the disjoint union with the topology in which a set is open when its intersection with each piece is open. The one-point space is terminal, the empty space is initial.
Example— Non-existence: fields
In the category of fields (with ring homomorphisms, which are automatically injective), and have no product: a product would come with homomorphisms and , forcing to have characteristic and characteristic at once. They have no coproduct either (a field receiving maps from both would again have two characteristics), and the category of fields has neither an initial nor a terminal object (a terminal field would receive a map from fields of every characteristic). Universal properties characterise objects; whether such an object exists is a separate question.
Theorems and proofs
Theorem— Theorem 1 (products are unique up to unique isomorphism)
Let and both be products of and . Then there is exactly one morphism with and , and it is an isomorphism.
Proof
First a lemma: if satisfy and , then . Indeed both are morphisms whose composites with the projections are the pair , and by the uniqueness clause there is only one such morphism.
By the universal property of applied to the pair there is a unique with ; this is the uniqueness claim. Symmetrically there is with . Then
so by the lemma, and likewise .
∎
The proof never looked inside or — no elements, no construction. That is why it applies verbatim in every category, and why we may speak of the product : any two choices are related by one canonical isomorphism, compatible with all the structure we care about. The same argument shows that terminal (and initial) objects are unique up to unique isomorphism: if are terminal, the unique maps compose to an endomorphism of , which must be since has only one.
Theorem— Theorem 2 (a product is a terminal cone)
A cone over is a product of and if and only if it is a terminal object of the category .
Proof
A morphism of cones is precisely a morphism with and . "Exactly one such for every cone " is the universal property of the product on the one hand and the definition of a terminal object of on the other.
∎
So Theorem 1 is a special case of the uniqueness of terminal objects. This pattern — a universal object is a terminal (or initial) object in a cleverly chosen category — is the backbone of limits and colimits.
Theorem— Theorem 3 (duality)
A coproduct in is a product in , and an initial object of is a terminal object of . Consequently every theorem about products and terminal objects that holds in all categories yields a theorem about coproducts and initial objects: in particular, coproducts and initial objects are unique up to unique isomorphism.
Proof
A morphism in is a morphism in , and composition is reversed. Translating the universal property of a product of and in , with projections , word for word gives the universal property of a coproduct in with injections . Theorem 1, applied in the category , then gives uniqueness of coproducts in .
∎
Theorem— Theorem 4 (the coproduct of groups is not the product)
The free product is not abelian; in particular it is not isomorphic to .
Proof
Let and be the generators of the two copies of , i.e. , . In the symmetric group take the transpositions and ; there are homomorphisms with and . By the universal property of the coproduct there is a homomorphism with and . If , then . But and . Hence .
∎
The proof used nothing about reduced words — only the universal property and one non-abelian group to map into. In , by contrast, the coproduct of and is : the same two objects have different coproducts in different categories. Coproducts depend on the ambient category, which is the content of the misconception "coproducts look like products".
Theorem— Theorem 5 (products and coproducts in posets)
In a poset regarded as a category, and have a product if and only if they have a greatest lower bound, and then the product is ; dually for coproducts and least upper bounds. A least element is an initial object and a greatest element is a terminal object.
Proof
As in the example: all diagrams commute in a poset, so the universal property of a product reduces to ", , and every common lower bound is ", which is the definition of a greatest lower bound. Conversely, a product is a lower bound, and applying the universal property to the cone gives , so by antisymmetry. Least and greatest elements are empty joins and meets.
∎
Theorem— Theorem 6 (the product topology is forced)
Let be topological spaces. The product topology on — generated by the sets , open — makes it a product in . The box topology (generated by all , open) in general does not: for , , the diagonal map , , has continuous components but is not continuous for the box topology.
Proof
A map is continuous for the product topology iff the preimages of the generating sets are open, i.e. iff every is continuous. So the continuous maps correspond exactly to families of continuous maps , which is the universal property (the underlying function is forced, as in ). For the box topology, is open and is not open in . Since is continuous for the product topology (each ), the box topology on is strictly finer and fails the existence half of the universal property.
∎
Products and coproducts in Lean
We state the universal property by hand, in an arbitrary Mathlib category. Mathlib composes in diagrammatic order, so is written h ≫ π₁.
/-- **The universal property of a product.** Projections `π₁ : P ⟶ A` and `π₂ : P ⟶ B` make `P`
a product of `A` and `B` when every pair `f : X ⟶ A`, `g : X ⟶ B` factors through `P` by exactly
one morphism `lift f g : X ⟶ P`. Mathlib composes in diagrammatic order: `h ≫ π₁` means
"first `h`, then `π₁`", i.e. `π₁ ∘ h`. -/
structure IsBinaryProduct {A B P : C} (π₁ : P ⟶ A) (π₂ : P ⟶ B) where
/-- The induced morphism `⟨f, g⟩ : X ⟶ P`. -/
lift : ∀ {X : C}, (X ⟶ A) → (X ⟶ B) → (X ⟶ P)
/-- `π₁ ∘ ⟨f, g⟩ = f`. -/
lift_fst : ∀ {X : C} (f : X ⟶ A) (g : X ⟶ B), lift f g ≫ π₁ = f
/-- `π₂ ∘ ⟨f, g⟩ = g`. -/
lift_snd : ∀ {X : C} (f : X ⟶ A) (g : X ⟶ B), lift f g ≫ π₂ = g
/-- Uniqueness: any `h` with `π₁ ∘ h = f` and `π₂ ∘ h = g` is `⟨f, g⟩`. -/
uniq : ∀ {X : C} (f : X ⟶ A) (g : X ⟶ B) (h : X ⟶ P), h ≫ π₁ = f → h ≫ π₂ = g → h = lift f gTheorem 1, exactly as proved above: the lemma (hom_ext), the comparison isomorphism, and its uniqueness.
/-- **Morphisms into a product are determined by their components.** If `h` and `k` agree after
both projections, both equal `lift (h ≫ π₁) (h ≫ π₂)` by the uniqueness clause. -/
theorem hom_ext (hP : IsBinaryProduct π₁ π₂) {X : C} {h k : X ⟶ P} (h₁ : h ≫ π₁ = k ≫ π₁)
(h₂ : h ≫ π₂ = k ≫ π₂) : h = k := by
rw [hP.uniq _ _ h rfl rfl, hP.uniq _ _ k h₁.symm h₂.symm]/-- **Two products are isomorphic.** The comparison maps are `⟨π₁, π₂⟩ : P ⟶ Q` and
`⟨ρ₁, ρ₂⟩ : Q ⟶ P`. Each composite commutes with the projections, so by `hom_ext` it is the
identity — the proof in the lesson, verbatim. -/
def iso (hP : IsBinaryProduct π₁ π₂) (hQ : IsBinaryProduct ρ₁ ρ₂) : P ≅ Q where
hom := hQ.lift π₁ π₂
inv := hP.lift ρ₁ ρ₂
hom_inv_id := hP.hom_ext (by rw [Category.assoc, hP.lift_fst, hQ.lift_fst, Category.id_comp])
(by rw [Category.assoc, hP.lift_snd, hQ.lift_snd, Category.id_comp])
inv_hom_id := hQ.hom_ext (by rw [Category.assoc, hQ.lift_fst, hP.lift_fst, Category.id_comp])
(by rw [Category.assoc, hQ.lift_snd, hP.lift_snd, Category.id_comp])/-- **…by a unique isomorphism compatible with the projections.** Any isomorphism `i : P ≅ Q`
with `ρ₁ ∘ i = π₁` and `ρ₂ ∘ i = π₂` is the comparison isomorphism `iso hP hQ`: its forward map
satisfies the defining equations of `lift π₁ π₂`, so uniqueness in `Q`'s universal property
identifies them (and an isomorphism is determined by its forward map). -/
theorem iso_unique (hP : IsBinaryProduct π₁ π₂) (hQ : IsBinaryProduct ρ₁ ρ₂) (i : P ≅ Q)
(h₁ : i.hom ≫ ρ₁ = π₁) (h₂ : i.hom ≫ ρ₂ = π₂) : i = iso hP hQ := by
ext
exact hQ.uniq π₁ π₂ i.hom h₁ h₂Mathlib's own products (A ⨯ B, prod.lift) satisfy our definition, and Mathlib proves Theorem 2 for all limits:
/-- **Mathlib's products satisfy our universal property.** When `A` and `B` have a (chosen)
product `A ⨯ B` in Mathlib, its projections `prod.fst`, `prod.snd` form an `IsBinaryProduct`;
the induced map is Mathlib's `prod.lift`, and uniqueness is `prod.hom_ext`. -/
noncomputable def ofHasBinaryProduct (A B : C) [HasBinaryProduct A B] :
IsBinaryProduct (prod.fst : A ⨯ B ⟶ A) prod.snd where
lift f g := prod.lift f g
lift_fst f g := prod.lift_fst f g
lift_snd f g := prod.lift_snd f g
uniq f g h h₁ h₂ := prod.hom_ext (by rw [h₁, prod.lift_fst]) (by rw [h₂, prod.lift_snd])/-- **A product is a terminal cone.** A cone over the pair `(A, B)` is an object with two maps to
`A` and `B` (a `BinaryFan`); cones and their morphisms form a category, and a cone is a limit —
here, a product — exactly when it is a terminal object of that category. This applies Mathlib's
`Cone.isLimitEquivIsTerminal`. -/
theorem product_is_terminal_cone {A B : C} (c : BinaryFan A B) :
Nonempty (IsLimit c) ↔ Nonempty (IsTerminal c) :=
⟨fun ⟨h⟩ => ⟨Cone.isLimitEquivIsTerminal c h⟩,
fun ⟨h⟩ => ⟨(Cone.isLimitEquivIsTerminal c).symm h⟩⟩Coproducts are defined as products in the opposite category (Theorem 3 becomes a definition), and then unpacked:
/-- **A coproduct in `C` is a product in `Cᵒᵖ`.** Injections `ι₁ : A ⟶ S`, `ι₂ : B ⟶ S` make
`S` a coproduct of `A` and `B` when the reversed arrows `ι₁.op : op S ⟶ op A`,
`ι₂.op : op S ⟶ op B` make `op S` a product of `op A` and `op B` in the opposite category.
This *is* the definition — duality is built in. -/
abbrev IsBinaryCoproduct {A B S : C} (ι₁ : A ⟶ S) (ι₂ : B ⟶ S) : Type _ :=
IsBinaryProduct ι₁.op ι₂.op/-- **Unpacking the dual definition: copairing.** Maps `f : A ⟶ Y` and `g : B ⟶ Y` in `C` are
maps `op Y ⟶ op A` and `op Y ⟶ op B` in `Cᵒᵖ`; the product property gives `op Y ⟶ op S`, i.e. a
map `[f, g] : S ⟶ Y` in `C`. -/
def desc (hS : IsBinaryCoproduct ι₁ ι₂) {Y : C} (f : A ⟶ Y) (g : B ⟶ Y) : S ⟶ Y :=
(hS.lift f.op g.op).unop/-- **The copairing restricts correctly:** `[f, g] ∘ ι₁ = f` and `[f, g] ∘ ι₂ = g`. These are the
product equations in `Cᵒᵖ`, read backwards (`unop` of `lift f.op g.op ≫ ι₁.op = f.op`). -/
theorem inl_desc (hS : IsBinaryCoproduct ι₁ ι₂) {Y : C} (f : A ⟶ Y) (g : B ⟶ Y) :
ι₁ ≫ hS.desc f g = f ∧ ι₂ ≫ hS.desc f g = g :=
⟨congrArg Quiver.Hom.unop (hS.lift_fst f.op g.op),
congrArg Quiver.Hom.unop (hS.lift_snd f.op g.op)⟩/-- **…and uniquely:** any `h : S ⟶ Y` with `h ∘ ι₁ = f` and `h ∘ ι₂ = g` is `[f, g]`. This is
the uniqueness clause in `Cᵒᵖ`, applied to `h.op`. -/
theorem desc_unique (hS : IsBinaryCoproduct ι₁ ι₂) {Y : C} (f : A ⟶ Y) (g : B ⟶ Y) (h : S ⟶ Y)
(h₁ : ι₁ ≫ h = f) (h₂ : ι₂ ≫ h = g) : h = hS.desc f g :=
congrArg Quiver.Hom.unop
(hS.uniq f.op g.op h.op (congrArg Quiver.Hom.op h₁) (congrArg Quiver.Hom.op h₂))/-- **Terminal objects are unique up to unique isomorphism.** If `T` and `T'` are terminal, the
unique maps `T ⟶ T'` and `T' ⟶ T` compose to endomorphisms of a terminal object, which must be
identities because a terminal object has only one endomorphism. (Mathlib: `IsTerminal.uniqueUpToIso`.)
Dually for initial objects. -/
theorem terminal_unique {T T' : C} (hT : IsTerminal T) (hT' : IsTerminal T') :
∃ i : T ≅ T', ∀ j : T ≅ T', j = i :=
⟨⟨hT'.from T, hT.from T', hT.hom_ext _ _, hT'.hom_ext _ _⟩,
fun _ => Iso.ext (hT'.hom_ext _ _)⟩In the category of types — Lean's counterpart of — pairs form a product and the sum type A ⊕ B a coproduct; one-element and empty types are terminal and initial.
/-- **In the category of types, the product is the type of pairs.** Given `f : X → A` and
`g : X → B`, the unique map `X → A × B` compatible with the projections is
`x ↦ (f x, g x)`: any compatible `h` has first and second coordinates `f x` and `g x`. -/
def typesProduct (A B : Type u) :
IsBinaryProduct (C := Type u) (↾(Prod.fst : A × B → A)) (↾(Prod.snd : A × B → B)) where
lift f g := ↾fun x => (f x, g x)
lift_fst _ _ := rfl
lift_snd _ _ := rfl
uniq f g h h₁ h₂ := by
-- `ext` reduces to the two coordinates of `h x`.
ext x
· simpa using ConcreteCategory.congr_hom h₁ x
· simpa using ConcreteCategory.congr_hom h₂ x/-- **In the category of types, the coproduct is the disjoint union** `A ⊕ B`, with the
injections `Sum.inl`, `Sum.inr`. Following the definition, we exhibit a product in `(Type u)ᵒᵖ`:
the induced map is "case analysis" `Sum.elim f g`, and it is unique because a function on
`A ⊕ B` is determined by its values on the two summands. -/
def typesCoproduct (A B : Type u) :
IsBinaryCoproduct (C := Type u) (↾(Sum.inl : A → A ⊕ B)) (↾(Sum.inr : B → A ⊕ B)) where
lift f g := (↾(Sum.elim f.unop g.unop)).op
lift_fst _ _ := rfl
lift_snd _ _ := rfl
uniq f g h h₁ h₂ := by
apply Quiver.Hom.unop_inj
ext x
rcases x with a | b
· exact ConcreteCategory.congr_hom (congrArg Quiver.Hom.unop h₁) a
· exact ConcreteCategory.congr_hom (congrArg Quiver.Hom.unop h₂) b/-- **In the category of types, a one-element type is terminal and the empty type is initial.**
Every type has exactly one map to `PUnit` and exactly one map from `PEmpty`. These are Mathlib's
`Types.isTerminalPUnit` and `Types.isInitialPEmpty`. -/
theorem types_terminal_initial :
Nonempty (IsTerminal (PUnit : Type u)) ∧ Nonempty (IsInitial (PEmpty : Type u)) :=
⟨⟨Types.isTerminalPUnit⟩, ⟨Types.isInitialPEmpty⟩⟩Theorem 5, for posets with meets and joins:
/-- **In a poset regarded as a category, the product is the meet.** There is a morphism `x ⟶ y`
exactly when `x ≤ y`, and then only one, so the equations in the universal property are
automatic; what remains is existence: `x ≤ a` and `x ≤ b` imply `x ≤ a ⊓ b`. -/
def infIsProduct [SemilatticeInf α] (a b : α) :
IsBinaryProduct (homOfLE (inf_le_left : a ⊓ b ≤ a)) (homOfLE inf_le_right) where
lift f g := homOfLE (le_inf (leOfHom f) (leOfHom g))
lift_fst _ _ := Subsingleton.elim _ _
lift_snd _ _ := Subsingleton.elim _ _
uniq _ _ _ _ _ := Subsingleton.elim _ _/-- **Conversely, every product in a poset is the meet.** If `p` (with `p ≤ a`, `p ≤ b`) is a
product of `a` and `b`, then `p ≤ a ⊓ b` because `a ⊓ b` is a lower bound, and `a ⊓ b ≤ p` by
the universal property applied to the cone `a ⊓ b`. Antisymmetry gives `p = a ⊓ b`. So a pair
with no greatest lower bound has no product. -/
theorem product_eq_inf [SemilatticeInf α] {a b p : α} {π₁ : p ⟶ a} {π₂ : p ⟶ b}
(hp : IsBinaryProduct π₁ π₂) : p = a ⊓ b :=
le_antisymm (le_inf (leOfHom π₁) (leOfHom π₂))
(leOfHom (hp.lift (homOfLE inf_le_left) (homOfLE inf_le_right)))/-- **Dually, the coproduct in a poset is the join** `a ⊔ b`: in the opposite poset, `a ⊔ b` is
the meet. -/
def supIsCoproduct [SemilatticeSup α] (a b : α) :
IsBinaryCoproduct (homOfLE (le_sup_left : a ≤ a ⊔ b)) (homOfLE le_sup_right) where
lift f g := (homOfLE (sup_le (leOfHom f.unop) (leOfHom g.unop))).op
lift_fst _ _ := Subsingleton.elim _ _
lift_snd _ _ := Subsingleton.elim _ _
uniq _ _ _ _ _ := Subsingleton.elim _ _Initial and terminal objects in algebra, from Mathlib:
/-- **`ℤ` is initial among commutative rings**: for every commutative ring `R` there is exactly one
ring homomorphism `ℤ → R`, namely `n ↦ n · 1`. This is Mathlib's `CommRingCat.zIsInitial`
(uniqueness is `RingHom.ext_int`). -/
theorem int_initial : Nonempty (IsInitial (CommRingCat.of ℤ)) :=
⟨CommRingCat.zIsInitial⟩/-- **The trivial group is both initial and terminal in `Grp`** (a *zero object*): from any group
there is one homomorphism to it, and to any group there is one homomorphism from it (sending the
identity to the identity). This applies Mathlib's `GrpCat.isZero_of_subsingleton`. -/
theorem trivial_group_zero : IsZero (GrpCat.of PUnit) :=
GrpCat.isZero_of_subsingleton _And Theorem 4. Lean finds the contradiction in by evaluating both permutations (decide), after the universal property (Monoid.Coprod.lift) has transported the hypothetical equation to .
/-- **`ℤ ∗ ℤ` is not commutative.** In `Grp`, the coproduct of `ℤ` with itself is the free product
`ℤ ∗ ℤ` (Mathlib's `Monoid.Coprod`, written multiplicatively). Let `x` and `y` be the generators of
the two copies. By the universal property there is a homomorphism `φ : ℤ ∗ ℤ → S₃` sending `x` to
the transposition `(0 1)` and `y` to `(1 2)`. If `x y = y x`, then `φ` would make these two
transpositions commute, and they do not (checked by `decide`). Contrast `prod_comm`. -/
theorem free_product_not_comm :
∃ x y : Multiplicative ℤ ∗ Multiplicative ℤ, x * y ≠ y * x := by
refine ⟨Monoid.Coprod.inl (Multiplicative.ofAdd 1), Monoid.Coprod.inr (Multiplicative.ofAdd 1),
fun h => ?_⟩
-- The homomorphism given by the universal property of the coproduct.
let φ := Monoid.Coprod.lift (zpowersHom (Equiv.Perm (Fin 3)) (Equiv.swap 0 1))
(zpowersHom (Equiv.Perm (Fin 3)) (Equiv.swap 1 2))
have hφ := congrArg φ h
simp only [φ, map_mul, Monoid.Coprod.lift_apply_inl, Monoid.Coprod.lift_apply_inr,
zpowersHom_apply, toAdd_ofAdd, zpow_one] at hφ
exact absurd hφ (by decide)/-- **`ℤ × ℤ` is commutative**: the product of two abelian groups is abelian, componentwise. So the
product and the coproduct of `ℤ` with itself in `Grp` are genuinely different groups. -/
theorem prod_comm (x y : Multiplicative ℤ × Multiplicative ℤ) : x * y = y * x :=
Prod.ext (mul_comm x.1 y.1) (mul_comm x.2 y.2)Not formalised here: the description of free products by reduced words (Mathlib has it as Monoid.CoprodI.Word), coproducts of commutative rings as tensor products, and Theorem 6.
Experiment: testing universal properties by brute force
For finite sets the universal property is a finite statement, so a computer can check it: for every pair , it counts the morphisms with and . The count must be exactly every time. In a finite poset, products and coproducts can be found by searching for greatest lower and least upper bounds — or found not to exist.
"""Testing universal properties by brute force, in finite sets and finite posets.
Part 1 counts, for every pair of maps f : X -> A and g : X -> B between small
finite sets, the maps h : X -> P with p1 o h = f and p2 o h = g, for three
candidate products P. Only the cartesian product gives exactly one h every
time: a bigger set breaks uniqueness, a smaller one breaks existence.
Part 2 searches finite posets (ordered by divisibility) for greatest lower
bounds and least upper bounds - the products and coproducts of the poset
regarded as a category - and finds pairs that have none.
"""
from itertools import product
from math import gcd
def maps(dom, cod):
"""All functions dom -> cod, as dicts."""
return [dict(zip(dom, values)) for values in product(cod, repeat=len(dom))]
def factorisations(X, P, p1, p2, f, g):
"""Number of h : X -> P with p1(h(x)) = f(x) and p2(h(x)) = g(x) for all x."""
return sum(1 for h in maps(X, P)
if all(p1[h[x]] == f[x] and p2[h[x]] == g[x] for x in X))
def candidates(A, B):
"""Three would-be products of A and B: (name, P, p1, p2)."""
pairs = list(product(A, B))
triples = list(product(A, B, (0, 1)))
return [
("A x B", pairs, {p: p[0] for p in pairs}, {p: p[1] for p in pairs}),
("A x B x {0,1}", triples, {t: t[0] for t in triples},
{t: t[1] for t in triples}),
("A, p2 constant", list(A), {a: a for a in A}, {a: B[0] for a in A}),
]
def count_profile(A, B, X, cand):
"""The set of factorisation counts over all pairs (f, g) for one candidate."""
_, P, p1, p2 = cand
return {factorisations(X, P, p1, p2, f, g)
for f in maps(X, A) for g in maps(X, B)}
def divides(a, b):
"""The divisibility order: a <= b iff a divides b."""
return b % a == 0
def glb(elements, leq, a, b):
"""Greatest lower bound of a and b in a finite poset, or None."""
lower = [x for x in elements if leq(x, a) and leq(x, b)]
best = [x for x in lower if all(leq(y, x) for y in lower)]
return best[0] if best else None
def lub(elements, leq, a, b):
"""Least upper bound (the dual notion), or None."""
return glb(elements, lambda x, y: leq(y, x), a, b)
def main():
A, B = (0, 1), ("a", "b", "c")
print("Part 1: number of h : X -> P with p1 o h = f, p2 o h = g")
print(" (all pairs f : X -> A, g : X -> B; |A| = 2, |B| = 3)")
for cand in candidates(A, B):
row = []
for n in range(3):
row.append(sorted(count_profile(A, B, tuple(range(n)), cand)))
print(f" P = {cand[0]:<15} |X| = 0, 1, 2: {row}")
print(" Exactly one h every time only for A x B.")
divs = [d for d in range(1, 61) if 60 % d == 0]
ok = all(glb(divs, divides, a, b) == gcd(a, b)
and lub(divs, divides, a, b) == a * b // gcd(a, b)
for a in divs for b in divs)
print()
print(f"Part 2: divisors of 60 ({len(divs)} elements) under divisibility:")
print(f" product = gcd and coproduct = lcm for all {len(divs) ** 2} pairs: "
f"{ok}")
small = [2, 3, 12, 18]
for a, b in [(2, 3), (12, 18), (2, 12)]:
print(f" in {small}: product of {a}, {b} = "
f"{glb(small, divides, a, b)}, coproduct = "
f"{lub(small, divides, a, b)}")
print(" 2, 3: no lower bound, two minimal upper bounds 12, 18; 12, 18 dually.")
print()
print("Epistemic status: exhaustive checks of finitely many maps and pairs.")
print("They illustrate the definitions; that A x B is a product of any two")
print("sets, and that products in a poset are meets, are proved in the lesson.")
if __name__ == "__main__":
main()Explore: one pair, one map
Choose maps and between small finite sets, then try to build with and . Notice that at each point you have no freedom at all: must be the pair . That absence of choice is the uniqueness clause.
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. Products, coproducts, initial and terminal objects
Warm-upHumanIn , which statement is correct?
2. Products, coproducts, initial and terminal objects
CoreHumanWhich of these categories have a zero object (an object that is both initial and terminal)? Select all that apply.
3. Products, coproducts, initial and terminal objects
Warm-upHumanRegard the positive integers, ordered by divisibility ( iff ), as a category. What is the coproduct of and ?
4. Products, coproducts, initial and terminal objects
CoreHumanIn , let , and . How many morphisms are there? (Use the universal property rather than listing them.)
5. Products, coproducts, initial and terminal objects
CoreHumanIn the proof that two products and of and are isomorphic, we have and with and . Why is ?
6. Products, coproducts, initial and terminal objects
StretchHumanWhat is the coproduct of and in the category of commutative rings with identity?
7. Products, coproducts, initial and terminal objects
StretchHumanWhich statements are true? Select all that apply.
8. Products, coproducts, initial and terminal objects
CoreFormalMathlib writes h ≫ π₁ for (first h, then π₁). Which Lean field correctly expresses the uniqueness clause of the universal property of a product with projections π₁ : P ⟶ A, π₂ : P ⟶ B?
9. Products, coproducts, initial and terminal objects
CoreComputationalWrite glb(elements, leq, a, b) returning the product of a and b in a finite poset — the greatest lower bound — or None if it does not exist. Here elements is a list and leq(x, y) decides .
Common misconceptions
Misconception
"Coproducts look like products." In the two look different but at least familiar; in the coproduct is a non-abelian group, utterly unlike (Theorem 4). In the coproduct is a tensor product, and is the zero ring. In the finite products and coproducts coincide. There is no general recipe "coproduct = something like a sum": you must compute it from the universal property in the category at hand.
Misconception
"Every category has products." Many do not. A poset has a product of and only when exists ( under divisibility lacks several); the category of fields has no product of and ; the category of finite sets has all finite products but not, for example, a product of countably many copies of (its points would correspond to the uncountably many sequences). A universal property characterises an object — existence must be proved separately.
Misconception
"The union is the coproduct of sets." Only for disjoint sets. In general the coproduct needs the two sets to be made disjoint first (), otherwise a map on cannot be defined independently on and on .
Misconception
"The product is defined as the set of pairs." In the set of pairs is a product, but so is any set in bijection with it with the matching projections, and in other categories there may be no "pairs" at all (posets, ). The definition is the universal property; the set of pairs is one construction satisfying it.
Viewpoints
Topology— Tychonoff, wedges and van Kampen
The universal property forces the product topology (Theorem 6), and with it a deep theorem: Tychonoff's theorem says that any product of compact spaces is compact — a statement about the categorical product that is equivalent to the axiom of choice (Kelley, 1950). The box topology, which looks more natural to beginners, fails the universal property and is not compact even for (where it is discrete and infinite).
In pointed spaces the coproduct is the wedge (the disjoint union with base points identified), and the fundamental group turns it into the coproduct of groups: by the Seifert–van Kampen theorem, for path-connected spaces whose base points are deformation retracts of open neighbourhoods (for example CW complexes with a vertex as base point), . So the figure eight has fundamental group , while the torus has — and indeed always. Products go to products and (nice) coproducts to coproducts. See the fundamental group.
Geometry— A grid and a tree
Draw the Cayley graph of a group with respect to generators : a vertex for each element, an edge from to and to . For it is the square grid in the plane — flat geometry, where closes every unit square. For it is the infinite 4-valent tree: since no non-trivial reduced word equals the identity, there are no cycles at all, and the number of elements at distance from the identity is , growing exponentially, like the area of a disc in the hyperbolic plane. Geometric group theory takes such pictures seriously: free groups are the basic examples of hyperbolic groups, and a group acting freely on a tree is free (Serre's theory of groups acting on trees). The product and the coproduct of the same two groups live in different geometries.
Algebra— Biproducts, tensor products and the infinite
In , and , finite products and coproducts coincide: carries both structures, and , , . Such an object is a biproduct, and categories where all finite biproducts exist and hom-sets are abelian groups are the additive categories underlying homological algebra (see abelian categories). Infinite products and coproducts differ: , and for a vector space this is why the dual of a space with a countably infinite basis is so much larger than the space. In commutative rings, the coproduct explains why tensor products are inevitable: the polynomial ring is the coproduct , and a pair of ring maps out of and is a ring map out of .
Logic— And, or, true, false
Order propositions by entailment: when . In this preorder the product of and is (it entails both, and anything entailing both entails it), the coproduct is , the terminal object is and the initial object is ("ex falso quodlibet" is the statement that is initial). Remembering which proof witnesses an entailment upgrades the preorder to a category whose morphisms are proofs; then the universal properties are the introduction and elimination rules of natural deduction: a proof of from is a pair of proofs, and -elimination is the copairing — proof by cases. This is one face of the Curry–Howard correspondence (see categorical logic).
Computation— Algebraic data types
In a typed programming language, the product of types and is the type of pairs or records, with projections fst and snd; the coproduct is the sum type (tagged union, Either A B, or Lean's A ⊕ B), whose universal property is pattern matching: to define a function on A ⊕ B, give one branch for inl a and one for inr b. The unit type is terminal and the empty type initial. Counting confirms the names: for finite types and , and type isomorphisms such as are laws of arithmetic one level up. See the λ-calculus.
Wonder Trails
History and global context
- Products of sets are named after René Descartes, whose coordinates (1637) identify points of the plane with pairs of numbers. A purely set-theoretic definition of the ordered pair came much later: Norbert Wiener (1914) and Kazimierz Kuratowski (1921), whose is the one in use today.
- Andrey Tychonoff introduced the product topology around 1930 and proved the compactness theorem that bears his name; John Kelley showed in 1950 that Tychonoff's theorem is equivalent to the axiom of choice.
- Free products of groups grew out of combinatorial group theory: Otto Schreier studied amalgamated free products (1927), and Alexander Kurosh proved his subgroup theorem for free products (1934).
- Pierre Samuel (1948) formulated "universal mapping problems", and Saunders Mac Lane's "Duality for groups" (1950) characterised direct and free products by arrows alone and observed that the two are dual — the first appearance of products and coproducts as categorical notions. The modern names and the general theory of limits followed in the 1950s.
Further reading
- Tom Leinster, Basic Category Theory (2014), Sections 5.1–5.2 — products, coproducts and their duality with many examples.
- Emily Riehl, Category Theory in Context (2016), Chapter 3.
- Steve Awodey, Category Theory (2nd edition, 2010), Chapters 2 and 3 — products, then duality and coproducts.
- Paolo Aluffi, Algebra: Chapter 0 (2009), Chapters I–II — universal properties in , and , including free products.
- James Munkres, Topology (2nd edition, 2000), Section 19 — product versus box topology.
- Roger Lyndon and Paul Schupp, Combinatorial Group Theory (1977), Chapter IV — free products and the normal form theorem.