Counting past infinity
"Three" answers two different questions. How many pebbles are in the bowl? Three. Which runner crossed the line after the second? The third. For finite collections the two answers always agree, so we rarely notice that they are different ideas. For infinite collections they come apart.
Line up the natural numbers as usual, , and then line them up again, but with moved to the very end: . How many numbers are there? The same set, so the same number. But the two arrangements have different shapes: in the second there is a last element, standing after infinitely many others. Georg Cantor met such arrangements in the 1870s and 1880s while studying the sets on which a trigonometric series may misbehave: taking limit points of limit points of limit points, he needed to keep counting after all the finite stages — ", , , …" — and he invented the ordinal numbers to do it.
This lesson builds both kinds of infinite number inside ZFC. Ordinals measure the shapes of well-ordered sets; cardinals measure sizes. We prove the basic theorems about both — including the Schröder–Bernstein theorem and Hessenberg's theorem — and meet the question about sizes that ZFC cannot answer, the continuum hypothesis. You should know well-orders and countability and Cantor's diagonal argument.
Shapes of well-orders
A well-order is a linear order in which every non-empty subset has a least element. Every finite linear order is a well-order, and so is ; the integers and the rationals are not. Well-orders are exactly the orders along which we can "count": after any set of positions that is not everything, there is a next position — the least one not yet used.
The pictures already show the two main surprises. Adding a point at the end of changes its shape — has a largest element, does not — but adding a point at the beginning does not: is again "a first point, then a next, then a next, …", which is . So ordinal addition will not be commutative. And yet all four orders have the same size: each is a countable set. Ordinals keep track of shape; cardinals forget everything except size.
Definitions
Definition— order isomorphism, initial segment
Linear orders and are isomorphic if there is a bijection with . The initial segment of a linear order below is .
Definition— ordinal
A set is transitive if every element of is also a subset of (if then ). An ordinal is a transitive set that is well-ordered by — that is, the relation is a strict well-order of . We write for when are ordinals, and for the class of all ordinals.
The von Neumann natural numbers , , are ordinals, and so is . Each ordinal is the set of the ordinals before it: .
Definition— successor and limit ordinals
The successor of an ordinal is . An ordinal is a successor ordinal if it is for some , and a limit ordinal if it is neither nor a successor. The least limit ordinal is .
Definition— comparing sizes
means there is an injection ; means there is a bijection ; and means but not .
Definition— cardinal
A cardinal is an ordinal that is not in bijection with any smaller ordinal. If can be well-ordered, its cardinality is the least ordinal in bijection with , which is a cardinal. The infinite cardinals are listed by the alephs: , is the least cardinal greater than , and for limit . (When the ordinal rather than the size is meant, is also written .)
So , and are three different ordinals but only one cardinal, : the others are in bijection with the smaller ordinal . Every finite ordinal is a cardinal, and every infinite cardinal is a limit ordinal.
The ordinals are well-ordered
Theorem— Lemma 1
Every element of an ordinal is an ordinal.
Proof
Let be an ordinal and . Since is transitive, , so well-orders (a subset of a well-order is well-ordered). To see that is transitive, let . Then and so , by transitivity of . Now are elements of with and ; since is a transitive relation on (it is an order), .
∎
Theorem— Lemma 2
If and are ordinals and , then .
Proof
Let be the -least element of the non-empty set . We show . If , then (transitivity of ) and by the minimality of ; so . Conversely, let . Then and are elements of , which is linearly ordered by : so , or . The middle case is impossible because , and so is the last, since would give by transitivity of . Hence . So , and .
∎
Theorem— Theorem 3 (any two ordinals are comparable)
For ordinals , exactly one of , , holds.
Proof
The set is transitive (an intersection of transitive sets) and well-ordered by (a subset of ), so it is an ordinal. If and , then Lemma 2 gives and , so ; but is irreflexive on , a contradiction. So , that is , and then or by Lemma 2; or and symmetrically or . At most one case holds: together with or with would give (using transitivity of in the second case), contradicting irreflexivity.
∎
Theorem— Theorem 4 (least elements and suprema)
Every non-empty set of ordinals has a least element, which equals , and a least upper bound, namely , which is an ordinal.
Proof
Pick . If no element of is below , then by Theorem 3 is least. Otherwise is a non-empty subset of the well-ordered set and has a least element, which is then least in (anything below it would also be in ). The least element is a subset of every member of (for ordinals, gives by transitivity) and is itself a member, so . For the supremum: is a union of transitive sets, hence transitive; its elements are ordinals by Lemma 1; by Theorem 3 and the first part, is a well-order on it. So is an ordinal. It contains every as a subset, so it is an upper bound (Lemma 2); and if is any upper bound, every is a subset of , so , which by Lemma 2 means .
∎
Theorem— Theorem 5 (Burali-Forti)
There is no set of all ordinals.
Proof
If were the set of all ordinals, it would be transitive (Lemma 1) and well-ordered by (Theorems 3 and 4), hence an ordinal; so , contradicting the irreflexivity of on the ordinal .
∎
Theorem— Theorem 6 (transfinite induction)
Let be a property of ordinals. If, for every ordinal , " for all " implies , then holds for every ordinal . Equivalently: if ; ; and for limit , " for all " implies — then holds for all ordinals.
Proof
If failed, the set would be a non-empty set of ordinals with a least element (Theorem 4). Every satisfies , so the hypothesis gives , a contradiction. The second form follows because every ordinal is , a successor or a limit, and in each case its hypothesis supplies the induction step.
∎
Theorem— Theorem 7 (transfinite recursion)
Let be a class function (given by a formula) defined on all sets. Then there is a unique class function on the ordinals with for every , where is the set .
Proof
(Sketch.) Call a function with domain an ordinal an attempt if for all . By transfinite induction, two attempts agree where both are defined. Again by transfinite induction, for every there is an attempt with domain : at a limit stage, Replacement collects the attempts on the smaller ordinals into a set, and their union is an attempt to which one more value can be added. Define as the value at of any attempt defined there. Uniqueness is one more transfinite induction. (Full details: Enderton 1977, chapter 7; Kunen 1980, chapter I.)
∎
Recursion is how the transfinite is used in practice: the stages of the cumulative hierarchy, ordinal arithmetic, the aleph function and the iterated derived sets of analysis are all defined by it.
Every well-order is an ordinal
Theorem— Lemma 8 (well-orders are rigid)
Let be a well-order and strictly increasing. Then for every .
Proof
Otherwise the set is non-empty; let be its least element. Then , and since is strictly increasing, . So also belongs to the set, and it is smaller than — a contradiction.
∎
Theorem— Corollary 9
(a) A well-order is not isomorphic to any proper initial segment of itself. (b) Between two well-orders there is at most one isomorphism. (c) Distinct ordinals are not isomorphic.
Proof
(a) An isomorphism would be strictly increasing with , contradicting Lemma 8. (b) If are isomorphisms, then and are strictly increasing maps , so and ; applying and gives . (c) If , then is a proper initial segment of , so (a) applies.
∎
Theorem— Theorem 10 (order types)
Every well-ordered set is isomorphic to exactly one ordinal, its order type .
Proof
Uniqueness is Corollary 9(c). For existence, let be the set of such that the initial segment is isomorphic to some ordinal; that ordinal is unique, call it . By Replacement, is a set.
- is closed downwards, and is strictly increasing. If via and , then restricts to an isomorphism , where is an ordinal (Lemma 1); so and .
- is an ordinal. It is a set of ordinals, and it is transitive: if , then for some , and by the previous point. By Theorems 3 and 4, a transitive set of ordinals is an ordinal.
- is an isomorphism, by the first point.
- . Otherwise let be the least element of . Since is closed downwards, , and shows that is isomorphic to the ordinal ; so , a contradiction.
Hence .
∎
The proof needs Replacement, and this is no accident: in Zermelo's system without Replacement one cannot prove that the ordinal exists, although the well-order "two copies of " obviously does.
Ordinal arithmetic
Ordinal arithmetic can be defined in two equivalent ways. By order types: is the type of a copy of followed by a copy of , and is the type of copies of — the set ordered by comparing second coordinates first. Or by transfinite recursion on the second argument:
for limit ordinals . On the natural numbers these are the usual operations.
Example— Order matters
- , but (it has a largest element).
- (" copies of ": is just ), but .
- , whereas .
- , but : the right distributive law fails.
Some laws do survive, each proved by transfinite induction on the last variable: addition and multiplication are associative; the left distributive law holds; and implies , while only holds on the other side ( but ).
Cantor normal form. Every ordinal can be written uniquely as with and positive integers — a "base- expansion". The ordinals have supremum , the least ordinal with ; below the exponents are themselves smaller than , so normal forms can be written out completely. The computation section implements this arithmetic.
Comparing sizes
Theorem— Theorem 11 (Cantor)
For every set , there is no surjection . Hence .
Proof
Let and put . If for some , then , which is impossible. So is not a value of . Since is an injection , we get but not .
∎
Theorem— Theorem 12 (Schröder–Bernstein, provable in ZF)
If and , then .
Proof
Let and be injections. For put
If then , so , and therefore : is monotone.
A fixed point (Knaster–Tarski). Let (the family contains , so the intersection makes sense). For each such , gives ; hence . Then , so is one of the 's and . Thus , which says exactly that
The bijection. Define by for and for ; the second case makes sense because every is for a unique .
- is injective: on it is , on it is , both injective; and a value with lies in , while a value with lies in .
- is surjective: a point is for its preimage ; a point has , so .
∎
The proof uses no choice. The set has a concrete description: follow a point of backwards through , , for as long as possible; consists of the points whose backward chain stops in . The computation section builds this way.
Theorem— Theorem 13 (Hartogs, provable in ZF)
For every set there is an ordinal with no injection . Consequently, for every ordinal there is a cardinal greater than , and the alephs are defined for every ordinal index.
Proof
Every well-order of a subset of is a subset of , so these well-orders form a set (by Separation from ), and by Replacement their order types form a set . If and , then is the type of an initial segment, so : is a transitive set of ordinals, hence an ordinal. An ordinal injects into if and only if it is the order type of a well-order of a subset of , i.e. if and only if it belongs to . Since , the ordinal does not inject into . For the second statement apply this to : the least ordinal that does not inject into is a cardinal greater than .
∎
Theorem— Theorem 14 (Hessenberg)
For every infinite cardinal : , that is, .
Proof
Order by Gödel's ordering: if , or the maxima are equal and precedes lexicographically. This is a well-order (a least element of a non-empty set is found by minimising the maximum first, then lexicographically). We prove the theorem by transfinite induction on infinite cardinals , assuming it for all smaller infinite cardinals.
The initial segment below is contained in , where (since is a limit ordinal). If is finite then is finite; if is infinite then by the induction hypothesis applied to the cardinal . So every proper initial segment of has cardinality less than . Let be its order type. If , then would be the order type of a proper initial segment, which has cardinality — impossible. So , and . The reverse inequality is clear, and Schröder–Bernstein finishes the proof.
∎
Cardinal arithmetic is defined by (disjoint union), and .
Theorem— Corollary 15
If is infinite and , then ; if moreover , then .
Proof
, and ; Schröder–Bernstein turns the chains of inequalities into equalities.
∎
Example— Cardinal computations
- , while the ordinals , , and are all different.
- (from the countability lesson), and : the plane has as many points as the line. Cantor found this in 1877 and wrote to Dedekind, "I see it, but I don't believe it."
- satisfies , so it equals .
The continuum hypothesis. Cantor's theorem gives , so (assuming can be well-ordered, which follows from the axiom of choice). The continuum hypothesis (CH) is the statement : every infinite set of reals is either countable or the same size as . Cantor posed it in 1878, and Hilbert put it first on his list of problems in 1900. Gödel (1938) showed that ZFC does not refute CH, and Cohen (1963) that it does not prove it — if ZFC is consistent, so is ZFC + . By later work of Robert Solovay, can consistently be any cardinal of uncountable cofinality (such as or ), but by a theorem of Julius König (1905) it can never be .
Ordinals and cardinals in Lean
Mathlib defines an ordinal as an isomorphism class of well-orders, and a cardinal as an equivalence class of types under bijection — the "order type" and "size" of the lesson, taken as primitive. The von Neumann picture is recovered inside Mathlib's model of ZFC: ordinals correspond exactly to the transitive sets well-ordered by , which is Theorem 10 in Mathlib's language.
/-- **Every ordinal is represented by exactly one von Neumann ordinal.** Mathlib's ordinals
(isomorphism types of well-orders) are order-isomorphic to the transitive sets well-ordered by
`∈` inside its model of ZFC. This applies `Ordinal.toZFSetIso`. -/
theorem von_neumann_iso : Nonempty (Ordinal.{u} ≃o {x : ZFSet.{u} // x.IsOrdinal}) :=
⟨Ordinal.toZFSetIso⟩The engine of Theorem 10 is the rigidity of well-orders, Lemma 8 and Corollary 9, which we prove exactly as in the lesson — the least counterexample , and its image as a smaller one:
/-- **In a well-order, a strictly increasing map never moves a point down:** `x ≤ f x`.
If not, take the *least* `m` with `f m < m`. Since `f` is strictly increasing, `f (f m) < f m`,
so `f m` is an even smaller counterexample — a contradiction.
(Mathlib: `StrictMono.le_apply`.) -/
theorem le_apply_of_strictMono {α : Type u} [LinearOrder α] [WellFoundedLT α] {f : α → α}
(hf : StrictMono f) (x : α) : x ≤ f x := by
by_contra hx
have hne : ({y | f y < y} : Set α).Nonempty := ⟨x, lt_of_not_ge hx⟩
obtain ⟨m, hm, hmin⟩ := WellFounded.has_min wellFounded_lt {y | f y < y} hne
exact hmin (f m) (hf hm) hm/-- **Two well-orders are isomorphic in at most one way.** If `f, g : α ≃o β`, then
`f⁻¹ ∘ g` and `g⁻¹ ∘ f` are strictly increasing self-maps of `α`, so
`x ≤ f⁻¹ (g x)` and `x ≤ g⁻¹ (f x)`; applying `f` and `g` gives `f x ≤ g x ≤ f x`. -/
theorem orderIso_unique {α : Type u} {β : Type v} [LinearOrder α] [WellFoundedLT α]
[LinearOrder β] (f g : α ≃o β) : f = g := by
ext x
apply le_antisymm
· have h1 := le_apply_of_strictMono (f := fun y => f.symm (g y))
(f.symm.strictMono.comp g.strictMono) x
have h2 := f.monotone h1
simpa using h2
· have h1 := le_apply_of_strictMono (f := fun y => g.symm (f y))
(g.symm.strictMono.comp f.strictMono) x
have h2 := g.monotone h1
simpa using h2/-- **A well-order does not embed into a proper initial segment of itself.** A strictly increasing
`f : α → α` cannot map everything below a point `a`: we would get `f a < a`, contradicting
`le_apply_of_strictMono`. (For instance `ω` is not isomorphic to `{0, 1, …, n - 1}`, and no
ordinal is isomorphic to a smaller one.) -/
theorem no_embedding_into_initial_segment {α : Type u} [LinearOrder α] [WellFoundedLT α]
(a : α) {f : α → α} (hf : StrictMono f) : ¬ ∀ x, f x < a :=
fun h => absurd (h a) (not_lt.mpr (le_apply_of_strictMono hf a))Transfinite induction in its zero / successor / limit form, from strong induction and the trichotomy "zero, successor or limit":
/-- **Transfinite induction.** To prove `P o` for every ordinal it suffices to prove `P 0`, to
pass from `P o` to `P (o + 1)`, and to pass from "`P` holds below a limit `o`" to `P o`.
Proof: strong induction along the well-order of the ordinals (`WellFoundedLT.induction`),
then a case split: every ordinal is `0`, a successor or a limit
(`Ordinal.zero_or_succ_or_isSuccLimit`). -/
theorem transfinite_induction (P : Ordinal.{u} → Prop) (h0 : P 0)
(hsucc : ∀ o, P o → P (Order.succ o))
(hlim : ∀ o, Order.IsSuccLimit o → (∀ o' < o, P o') → P o) (o : Ordinal.{u}) : P o := by
induction o using WellFoundedLT.induction with
| _ o ih =>
rcases Ordinal.zero_or_succ_or_isSuccLimit o with h | ⟨o', rfl⟩ | h
· rw [h]; exact h0
· exact hsucc o' (ih o' (Order.lt_succ o'))
· exact hlim o h ihOrdinal arithmetic is not commutative, while cardinality cannot see the difference between and :
/-- **`1 + ω = ω`**: one extra point *in front* of `0, 1, 2, …` is absorbed.
This applies Mathlib's `Ordinal.one_add_omega0`. -/
theorem one_add_omega : (1 : Ordinal.{u}) + ω = ω :=
Ordinal.one_add_omega0/-- **Ordinal addition is not commutative:** `1 + ω = ω`, but `ω < ω + 1` (an extra point *after*
all the natural numbers is a new largest element), so `1 + ω ≠ ω + 1`. -/
theorem add_not_comm : (1 : Ordinal.{u}) + ω ≠ ω + 1 := by
rw [one_add_omega]
exact ne_of_lt (lt_add_one ω)/-- **Ordinal multiplication is not commutative:** `2 · ω` is `ω` copies of `2`, which is just
`ω` (`Ordinal.natCast_mul_omega0`), while `ω · 2 = ω + ω` (`Ordinal.mul_two`) is two copies of
`ω`, which is larger than `ω`. -/
theorem mul_not_comm : (2 : Ordinal.{u}) * ω ≠ ω * 2 := by
have h2 : (2 : Ordinal.{u}) * ω = ω := Ordinal.natCast_mul_omega0 (n := 2) two_pos
rw [h2, Ordinal.mul_two]
exact ne_of_lt (lt_add_of_pos_right ω Ordinal.omega0_pos)/-- **Same size, different shape:** `ω + 1` is a different ordinal from `ω`, but it has the same
cardinality `ℵ₀`: the cardinality of a sum is the sum of the cardinalities
(`Ordinal.card_add`), and `ℵ₀ + 1 = ℵ₀` (`Cardinal.add_one_eq`). -/
theorem card_omega_add_one : (ω + 1 : Ordinal.{u}).card = ℵ₀ := by
rw [Ordinal.card_add, Ordinal.card_omega0, Ordinal.card_one]
exact Cardinal.add_one_eq le_rflCantor's theorem, by the diagonal set, and its cardinal form from Mathlib:
/-- **Cantor's theorem**, in its sharpest form: no function `f : α → Set α` is surjective.
The diagonal set `D = {x | x ∉ f x}` differs from every `f a` at the point `a`. -/
theorem cantor_no_surjection {α : Type u} (f : α → Set α) : ¬ Function.Surjective f := by
intro hf
obtain ⟨a, ha⟩ := hf {x | x ∉ f x}
have key : a ∈ f a ↔ a ∉ f a := by
constructor
· intro h; rw [ha] at h; exact h
· intro h; rw [ha]; exact h
have hnot : a ∉ f a := fun h => key.mp h h
exact hnot (key.mpr hnot)/-- **Cantor's theorem for cardinals:** `κ < 2^κ` for every cardinal `κ`.
This applies Mathlib's `Cardinal.cantor`. -/
theorem cantor_card (κ : Cardinal.{u}) : κ < 2 ^ κ :=
Cardinal.cantor κThe Schröder–Bernstein theorem, following the Knaster–Tarski proof of Theorem 12 step by step (Mathlib's OrderHom.lfp supplies the fixed point; Lean's Function.invFun plays the role of ). Mathlib's own proof uses the same idea:
/-- **The Schröder–Bernstein theorem**, by the proof in the lesson. Given injections
`f : α → β` and `g : β → α`, the map `F(S) = α \ g[β \ f[S]]` on subsets of `α` is monotone, so
it has a fixed point `S` (Knaster–Tarski: Mathlib's `OrderHom.lfp`). Then `α \ S = g[β \ f[S]]`,
and `h = f` on `S`, `h = g⁻¹` off `S` is a bijection `α → β`. -/
theorem schroeder_bernstein {α : Type u} {β : Type v} {f : α → β} {g : β → α}
(hf : Function.Injective f) (hg : Function.Injective g) :
∃ h : α → β, Function.Bijective h := by
classical
rcases isEmpty_or_nonempty β with hβ | hβ
· -- If `β` is empty, so is `α`, and the empty function is a bijection.
have : IsEmpty α := Function.isEmpty f
exact ⟨f, fun a => isEmptyElim a, fun b => isEmptyElim b⟩
-- The monotone operator `F(S) = α \ g[β \ f[S]]`.
let F : Set α →o Set α :=
{ toFun := fun S => (g '' (f '' S)ᶜ)ᶜ
monotone' := fun S T hST =>
Set.compl_subset_compl.mpr
(Set.image_mono (Set.compl_subset_compl.mpr (Set.image_mono hST))) }
-- Knaster–Tarski: a fixed point `S = F(S)`.
set S : Set α := OrderHom.lfp F with hSdef
have hS : (g '' (f '' S)ᶜ)ᶜ = S := OrderHom.map_lfp F
-- Off `S`, every point is `g y` for some `y` outside `f[S]`.
have hSc : g '' (f '' S)ᶜ = Sᶜ := (compl_compl _).symm.trans (congrArg compl hS)
have off : ∀ a, a ∉ S → ∃ y, y ∉ f '' S ∧ g y = a := by
intro a ha
have : a ∈ g '' (f '' S)ᶜ := by rw [hSc]; exact ha
obtain ⟨y, hy, rfl⟩ := this
exact ⟨y, hy, rfl⟩
-- `g'` undoes `g`.
let g' : α → β := Function.invFun g
have hg' : ∀ y, g' (g y) = y := Function.leftInverse_invFun hg
let h : α → β := fun a => if a ∈ S then f a else g' a
refine ⟨h, ?_, ?_⟩
· -- `h` is injective.
intro a b hab
by_cases ha : a ∈ S <;> by_cases hb : b ∈ S
· simp only [h, ha, hb, ↓reduceIte] at hab
exact hf hab
· simp only [h, ha, hb, ↓reduceIte] at hab
obtain ⟨y, hy, rfl⟩ := off b hb
rw [hg'] at hab
exact absurd ⟨a, ha, hab⟩ hy
· simp only [h, ha, hb, ↓reduceIte] at hab
obtain ⟨y, hy, rfl⟩ := off a ha
rw [hg'] at hab
exact absurd ⟨b, hb, hab.symm⟩ hy
· simp only [h, ha, hb, ↓reduceIte] at hab
obtain ⟨y, -, rfl⟩ := off a ha
obtain ⟨z, -, rfl⟩ := off b hb
rw [hg', hg'] at hab
rw [hab]
· -- `h` is surjective.
intro y
by_cases hy : y ∈ f '' S
· obtain ⟨a, ha, rfl⟩ := hy
exact ⟨a, by simp only [h, ha, ↓reduceIte]⟩
· have hgy : g y ∉ S := by
have : g y ∈ g '' (f '' S)ᶜ := ⟨y, hy, rfl⟩
rw [hSc] at this
exact this
exact ⟨g y, by simp only [h, hgy, ↓reduceIte, hg']⟩/-- The same theorem from Mathlib: `Function.Embedding.schroeder_bernstein`. (Mathlib's proof
uses the same Knaster–Tarski fixed point.) -/
theorem schroeder_bernstein_library {α : Type u} {β : Type v} {f : α → β} {g : β → α}
(hf : Function.Injective f) (hg : Function.Injective g) :
∃ h : α → β, Function.Bijective h :=
Function.Embedding.schroeder_bernstein hf hgHessenberg's theorem is taken from Mathlib, and Corollary 15 is derived from it with the same chain of inequalities as in the lesson:
/-- **Hessenberg's theorem:** `κ · κ = κ` for every infinite cardinal `κ`.
This applies Mathlib's `Cardinal.mul_eq_self`. -/
theorem hessenberg {κ : Cardinal.{u}} (h : ℵ₀ ≤ κ) : κ * κ = κ :=
Cardinal.mul_eq_self h/-- **Infinite sums collapse:** if `κ` is infinite then `κ + λ = max κ λ`. Proof from
Hessenberg: with `μ = max κ λ` (infinite), `μ ≤ κ + λ ≤ μ + μ = 2 · μ ≤ μ · μ = μ`. -/
theorem add_eq_max {κ μ : Cardinal.{u}} (h : ℵ₀ ≤ κ) : κ + μ = max κ μ := by
have hm : ℵ₀ ≤ max κ μ := le_trans h (le_max_left κ μ)
apply le_antisymm
· calc κ + μ ≤ max κ μ + max κ μ := add_le_add (le_max_left κ μ) (le_max_right κ μ)
_ = 2 * max κ μ := (two_mul (max κ μ)).symm
_ ≤ max κ μ * max κ μ :=
mul_le_mul_left (le_trans Cardinal.ofNat_le_aleph0 hm) (max κ μ)
_ = max κ μ := hessenberg hm
· exact max_le le_self_add le_add_selfWhat is and is not formalised. Proved here: rigidity of well-orders and its corollaries, transfinite induction, the non-commutativity examples, , Cantor's theorem, Schröder–Bernstein and Corollary 15. Taken from Mathlib: the correspondence with von Neumann ordinals, , and Hessenberg's theorem. Not formalised: Lemmas 1–2 and Theorems 3–5 for von Neumann ordinals (Mathlib has versions in Mathlib.SetTheory.ZFC.Ordinal), Hartogs' theorem, and anything about the independence of CH. Note also that Lean's logic includes choice, so the delicate "provable in ZF" claims of the lesson are not visible in these proofs (although #print axioms shows that our proof of Cantor's theorem uses no axioms at all).
Computing with infinite numbers
Ordinals below have finite names — their Cantor normal forms — so a computer can do exact arithmetic with them. The first experiment implements addition and multiplication from the recursive definitions, confirms the non-commutativity examples, tests the associative and distributive laws on random triples, and then follows Goodstein sequences: write in "hereditary base ", replace every by , subtract , write the result in hereditary base , replace every by , subtract , and so on. The numbers grow explosively — but replacing the base by turns each term into an ordinal, and these ordinals strictly decrease. Since there is no infinite decreasing sequence of ordinals, every Goodstein sequence reaches (Goodstein, 1944).
"""Ordinal arithmetic below epsilon_0, and Goodstein sequences.
Every ordinal below epsilon_0 has a Cantor normal form
w^e1*c1 + ... + w^ek*ck with e1 > ... > ek (themselves such ordinals) and
positive integer coefficients. We represent these forms as nested tuples and
implement comparison, addition and multiplication exactly, following the
recursive definitions in the lesson. The program shows that addition and
multiplication are not commutative, tests the associative and distributive
laws on random triples (left distributivity holds, right distributivity
fails), and computes Goodstein sequences, whose terms are matched with a
strictly decreasing sequence of ordinals. Evidence: exact symbolic
computation; the random tests are experiments, not proofs.
"""
import random
ZERO = ()
def nat(n):
"""The finite ordinal n."""
if n < 0:
raise ValueError("ordinals are non-negative")
return () if n == 0 else ((ZERO, n),)
ONE = nat(1)
OMEGA = ((ONE, 1),)
def cmp(a, b):
"""Return -1, 0 or 1 as a < b, a = b or a > b (lexicographic on terms)."""
for (ea, ca), (eb, cb) in zip(a, b):
c = cmp(ea, eb)
if c:
return c
if ca != cb:
return -1 if ca < cb else 1
return (len(a) > len(b)) - (len(a) < len(b))
def add(a, b):
"""Ordinal sum a + b: terms of a below the leading exponent of b vanish."""
if not b:
return a
e, c = b[0]
higher = tuple(t for t in a if cmp(t[0], e) > 0)
same = [t for t in a if cmp(t[0], e) == 0]
if same:
return higher + ((e, same[0][1] + c),) + b[1:]
return higher + b
def mul(a, b):
"""Ordinal product a * b, term by term in b (left distributivity)."""
if not a or not b:
return ZERO
lead_e, lead_c = a[0]
result = ZERO
for e, c in b:
if e == ZERO:
term = ((lead_e, lead_c * c),) + a[1:]
else:
term = ((add(lead_e, e), c),)
result = add(result, term)
return result
def fmt(a):
"""Write a Cantor normal form, e.g. w^2*3 + w + 5."""
if not a:
return "0"
parts = []
for e, c in a:
if e == ZERO:
parts.append(str(c))
continue
if e == ONE:
base = "w"
elif (len(e) == 1 and e[0][0] == ZERO) or e == OMEGA:
base = f"w^{fmt(e)}"
else:
base = f"w^({fmt(e)})"
parts.append(base if c == 1 else f"{base}*{c}")
return " + ".join(parts)
def random_ordinal(rng, max_exp=2, max_coeff=3):
"""A random ordinal below w^(max_exp + 1) with small coefficients."""
terms = []
for e in range(max_exp, -1, -1):
c = rng.randint(0, max_coeff)
if c:
terms.append((nat(e), c))
return tuple(terms)
def law_failures(rng, trials, law):
"""Count random triples (a, b, c) for which ``law(a, b, c)`` is False."""
bad = []
for _ in range(trials):
a, b, c = (random_ordinal(rng) for _ in range(3))
if not law(a, b, c):
bad.append((a, b, c))
return bad
def hereditary(n, base):
"""The ordinal obtained from n in hereditary base `base` by base -> w."""
terms, exp = [], 0
while n:
n, digit = divmod(n, base)
if digit:
terms.append((hereditary(exp, base), digit))
exp += 1
return tuple(reversed(terms))
def bump(n, base):
"""Replace the base by base + 1 everywhere in hereditary notation."""
total, exp = 0, 0
while n:
n, digit = divmod(n, base)
if digit:
total += digit * (base + 1) ** bump(exp, base)
exp += 1
return total
def goodstein(n, steps):
"""First terms (base, value) of the Goodstein sequence starting at n."""
out, base = [], 2
for _ in range(steps):
out.append((base, n))
if n == 0:
break
n = bump(n, base) - 1
base += 1
return out
def main():
w = OMEGA
two = nat(2)
print("1. Arithmetic in Cantor normal form (w = omega):")
rows = [
("1 + w", add(ONE, w), "w + 1", add(w, ONE)),
("2 * w", mul(two, w), "w * 2", mul(w, two)),
("(w + 1) * 2", mul(add(w, ONE), two), "2 * (w + 1)", mul(two, add(w, ONE))),
("(1 + 1) * w", mul(add(ONE, ONE), w), "1*w + 1*w", add(w, w)),
]
for left, x, right, y in rows:
print(f" {left} = {fmt(x):<11} {right} = {fmt(y):<11} equal: {x == y}")
rng = random.Random(2024)
laws = [
("(a + b) + c = a + (b + c)",
lambda a, b, c: add(add(a, b), c) == add(a, add(b, c))),
("(ab)c = a(bc)", lambda a, b, c: mul(mul(a, b), c) == mul(a, mul(b, c))),
("a(b + c) = ab + ac",
lambda a, b, c: mul(a, add(b, c)) == add(mul(a, b), mul(a, c))),
("(a + b)c = ac + bc",
lambda a, b, c: mul(add(a, b), c) == add(mul(a, c), mul(b, c))),
("a + b = b + a", lambda a, b, c: add(a, b) == add(b, a)),
]
print("2. 3000 random triples below w^3 for each law:")
examples = []
for name, law in laws:
bad = law_failures(rng, 3000, law)
print(f" {name:<27}{len(bad):>5} failures")
if bad:
examples.append((name, bad[0]))
name, (a, b, c) = examples[0]
print(f" e.g. {name} fails for a = {fmt(a)}, b = {fmt(b)}, c = {fmt(c)}:")
print(f" {fmt(mul(add(a, b), c))} versus {fmt(add(mul(a, c), mul(b, c)))}")
print("3. Goodstein: write n in hereditary base b, change b to b + 1, subtract 1.")
print(" n = 3:", [v for _, v in goodstein(3, 10)])
print(" n = 4: base value ordinal (base -> w)")
seq = goodstein(4, 7)
for base, value in seq:
print(f" {base:>3} {value:>6} {fmt(hereditary(value, base))}")
ords = [hereditary(v, b) for b, v in seq]
falling = all(cmp(x, y) > 0 for x, y in zip(ords, ords[1:]))
print(f" ordinals strictly decreasing: {falling}")
print()
print("Epistemic status: the normal-form arithmetic is exact, and the")
print("non-commutativity examples are genuine counterexamples. The 3000-triple")
print("tests are only experimental evidence for associativity and left")
print("distributivity, which are proved by transfinite induction. Goodstein's")
print("theorem (every sequence reaches 0) follows because ordinals are")
print("well-ordered; n = 4 takes more steps than any computer can follow.")
if __name__ == "__main__":
main()The second experiment builds Schröder–Bernstein bijections by chasing chains: between and , with and , it rediscovers the classical bijection that halves and fixes every other point; and between and it produces an explicit bijection from two injections.
"""The Schroeder-Bernstein bijection, computed by following chains.
Given injections f : A -> B and g : B -> A, follow any a in A backwards:
a = g(b)? b = f(a')? a' = g(b')? ... The backward chain either stops in A
(at a point not of the form g(b)), stops in B (at a point not of the form
f(a)), or never stops. The proof in the lesson sets h(a) = f(a) when the chain
stops in A and h(a) = g^(-1)(a) otherwise; these are exactly the points of the
least fixed point S of the map S -> A minus g[B minus f[S]]. Here we compute h
for two examples: the closed and half-open unit intervals (on rational points,
with exact fractions), where h turns out to be the famous "halve the powers of
1/2" map, and the natural numbers and the integers. Evidence: exact
computation on finitely many points; bijectivity on the whole set is the
theorem.
"""
from fractions import Fraction
def chain_type(a, f_inv, g_inv, limit=200):
"""Follow a in A backwards; return 'A', 'B' (where it stops) or 'endless'."""
seen = set()
x, side = a, "A"
for _ in range(limit):
if (x, side) in seen:
return "endless"
seen.add((x, side))
prev = g_inv(x) if side == "A" else f_inv(x)
if prev is None:
return side
x, side = prev, ("B" if side == "A" else "A")
return "endless"
def sb_map(a, f, f_inv, g_inv):
"""The Schroeder-Bernstein bijection: f on A-stopping chains, else g^-1."""
if chain_type(a, f_inv, g_inv) == "A":
return f(a)
return g_inv(a)
# Example 1: A = [0, 1], B = [0, 1), f(x) = x/2 (into B), g(y) = y (into A).
def f1(x):
return x / 2
def f1_inv(y):
return 2 * y if y <= Fraction(1, 2) else None
def g1_inv(x):
return x if x < 1 else None
# Example 2: A = N, B = Z, f(n) = n, g(z) = 3z (z >= 0), -3z - 1 (z < 0).
def f2(n):
return n
def f2_inv(z):
return z if z >= 0 else None
def g2_inv(n):
if n % 3 == 0:
return n // 3
if n % 3 == 2:
return -(n + 1) // 3
return None
def rational_points(max_den):
"""All fractions p/q in [0, 1] with q <= max_den, sorted."""
pts = {Fraction(p, q) for q in range(1, max_den + 1) for p in range(q + 1)}
return sorted(pts)
def main():
print("Example 1: A = [0, 1], B = [0, 1), f(x) = x/2, g(y) = y.")
for x in [Fraction(1), Fraction(1, 2), Fraction(1, 8), Fraction(3, 4),
Fraction(1, 3), Fraction(0)]:
kind = chain_type(x, f1_inv, g1_inv)
label = "never stops" if kind == "endless" else f"stops in {kind}"
print(f" x = {str(x):>4}: backward chain {label:<11} h(x) = "
f"{sb_map(x, f1, f1_inv, g1_inv)}")
pts = rational_points(30)
images = [sb_map(x, f1, f1_inv, g1_inv) for x in pts]
in_b = all(0 <= y < 1 for y in images)
moved = sorted(x for x, y in zip(pts, images) if y != x)
print(f" {len(pts)} rational points with denominator <= 30:")
print(f" images in [0, 1): {in_b}; injective: "
f"{len(set(images)) == len(images)}")
print(f" points moved: {[str(x) for x in reversed(moved)]}")
print(" h halves 1, 1/2, 1/4, ... and fixes everything else.")
print()
print("Example 2: A = N, B = Z, f(n) = n, g(z) = 3z or -3z - 1.")
h = [sb_map(n, f2, f2_inv, g2_inv) for n in range(3000)]
print(" h(0..14) =", h[:15])
window = set(range(-200, 201))
hit = window <= set(h)
print(f" h injective on 0..2999: {len(set(h)) == len(h)}; "
f"hits every z in -200..200: {hit}")
kinds = [chain_type(n, f2_inv, g2_inv) for n in range(30)]
print(" chains of 0..29 stop in A / B / never:",
[kinds.count(k) for k in ("A", "B", "endless")])
print()
print("Epistemic status: exact arithmetic, checked on finitely many points")
print(f"({len(pts)} rationals; 3000 natural numbers). That h is a bijection of the")
print("whole sets is the Schroeder-Bernstein theorem, proved in the lesson;")
print("the chain classification uses no choice, so the theorem holds in ZF.")
if __name__ == "__main__":
main()Both are exact computations on finitely many objects. The random tests are experimental evidence for laws that are proved by transfinite induction, and the chain-chasing checks injectivity and surjectivity only on finite windows; the theorems are what cover every ordinal and every point.
Explore: the diagonal behind Cantor's theorem
For , a subset of is an infinite sequence of s and s, and Cantor's diagonal set is obtained by flipping the diagonal of any proposed list.
The diagonal machine
Here is a list of infinite 0–1 sequences (we can only show the start). The gold sequence d flips the diagonal.
| s1 | … | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| s2 | … | ||||||||||
| s3 | … | ||||||||||
| s4 | … | ||||||||||
| s5 | … | ||||||||||
| s6 | … | ||||||||||
| d | 1 | 0 | 1 | 0 | 0 | 1 | ? | ? | ? | ? | … |
Point at (or tab to) a row to see where d differs from it. Click any digit to change the list.
Add d to the list and a new d appears that is different again. No list — however long — can contain every sequence.
Edit the list as you like and watch the flipped diagonal escape every row. Then reread the proof of Theorem 11: the set is exactly "flip the diagonal" for an arbitrary set and an arbitrary , with no list and no numbering needed.
Exercises
1. Ordinals and cardinals
Warm-upHumanWhich of these ordinals are equal to ? Select all.
2. Ordinals and cardinals
CoreHumanWrite in the form with a natural number. What is ?
3. Ordinals and cardinals
CoreHumanWrite in the form with a natural number. What is ?
4. Ordinals and cardinals
CoreHumanIn the proof that a strictly increasing on a well-order satisfies , we take the least with . Why does this lead to a contradiction?
5. Ordinals and cardinals
CoreHumanWhich of these statements are provable in ZF, without the axiom of choice? Select all.
6. Ordinals and cardinals
CoreHumanWhat is the cardinality of ?
7. Ordinals and cardinals
CoreFormalWhich Lean statement correctly formalises Cantor's theorem for a type α?
8. Ordinals and cardinals
StretchHumanHere is a faulty argument. “(1) The map together with is a bijection from to . (2) So and have the same cardinality. (3) So and are isomorphic well-orders. (4) Hence by uniqueness of order types.” Which step is wrong?
9. Ordinals and cardinals
StretchComputationalRepresent an ordinal below by its list of coefficients, lowest power first: [c0, c1, ..., ck] stands for (so [3, 0, 2] is , and [] is ), with no trailing zeros. Write ord_add(a, b) computing the ordinal sum . Rule: the terms of below the leading power of are absorbed, the coefficients at the leading power of add up, and the higher terms of remain.
Common misconceptions
Misconception
Confusing ordinal and cardinal arithmetic. and are different ordinals with the same cardinality ; as cardinals, , but as ordinals . Always ask whether a "" adds shapes or sizes.
Misconception
"Every set has an aleph as its cardinality." Without the axiom of choice this fails: in ZF, a set has an aleph as its cardinality exactly when it can be well-ordered, and ZF does not prove that can be well-ordered. With choice, every set is well-orderable and the alephs list all infinite cardinalities.
Misconception
" is a theorem." That is the continuum hypothesis, which ZFC neither proves nor refutes (if ZFC is consistent). What is a theorem is .
Misconception
"Schröder–Bernstein needs the axiom of choice." It does not: the proof above defines the bijection explicitly from and . What does need choice is comparability — that for any two sets or ; Hartogs showed in 1915 that this is equivalent to the axiom of choice.
Misconception
"There is a largest infinity." Cantor's theorem gives for every set, and Hartogs' theorem gives a larger cardinal than any ordinal. Like the ordinals, the cardinals do not form a set.
Many ways of seeing
Topology— Ordinals as spaces
Every ordinal carries the order topology, generated by open intervals, and these spaces are a standard source of counterexamples in point-set topology. An ordinal is compact exactly when it is or a successor, so is a compact Hausdorff space. The space is sequentially compact — every sequence has a convergent subsequence, because a countable set of countable ordinals is bounded below — but not compact: the open sets , , cover it with no finite subcover. In the point lies in the closure of but is the limit of no sequence from it, so sequences cannot describe this topology. Gluing copies of end to end gives the long ray, a connected space in which every point except the initial one has a neighbourhood homeomorphic to an open interval, but which is not metrisable.
Analysis— Where ordinals were born: derived sets
For , let be its set of limit points. Cantor proved in 1870 that a trigonometric series converging to everywhere has all coefficients , and in 1872 that the same holds if convergence is only known off a set with for some finite . To go further he iterated the derivative transfinitely, and — this is where the transfinite ordinals first appeared (1880). The process stabilises: the Cantor–Bendixson theorem says that for every closed there is a countable ordinal with , and is the union of the perfect set and a countable set. In particular every uncountable closed set of reals contains a perfect set and so has cardinality : CH holds for closed sets.
Combinatorics— Goodstein, hydras and unprovability
Goodstein's theorem is a statement about natural numbers — every Goodstein sequence reaches — whose natural proof assigns to each term an ordinal below and uses that these ordinals cannot decrease forever. Laurence Kirby and Jeff Paris (1982) showed that the detour through infinite ordinals is unavoidable in a precise sense: Goodstein's theorem cannot be proved in Peano arithmetic. They gave a second example in the same paper, the hydra game, in which Hercules chops heads off a finite rooted tree that regrows ever more copies; Hercules always wins, but proving it needs transfinite induction up to . Ordinals thus measure the strength needed for finite combinatorial statements.
Algebra— Dimension is a cardinal
All bases of a vector space have the same cardinality, and for infinite dimensions the proof is cardinal arithmetic. If and are bases with infinite, each is a combination of a finite set (its support), and these finite sets must cover , since otherwise a vector of outside them would lie in their span. So by Corollary 15, and by symmetry and Schröder–Bernstein . For example , because a -vector space with a basis of infinite size has exactly elements. A theorem of Paul Erdős and Irving Kaplansky computes the dimension of the dual space of an infinite-dimensional space: , which is always strictly larger than .
Logic— Independence and proof-theoretic strength
To a logician, CH is the paradigm of a statement independent of ZFC: Gödel's constructible universe satisfies it, and Cohen's forcing builds models where it fails (see forcing). Ordinals also measure the strength of theories. Gerhard Gentzen (1936) proved the consistency of Peano arithmetic using transfinite induction up to , and later (1943) showed that PA proves transfinite induction up to each smaller ordinal but not up to itself: is the proof-theoretic ordinal of PA. Larger ordinals calibrate stronger theories (proof theory), and larger cardinals calibrate stronger set theories (large cardinals).
Wonder Trails
History and global context
- Thinkers in many traditions puzzled over infinite collections. Some Jaina texts from India, of the last centuries BCE and the first centuries CE, classify numbers as enumerable, innumerable and infinite and distinguish several kinds of infinity, though not by one-to-one correspondence. Galileo Galilei (Two New Sciences, 1638) observed that the perfect squares can be paired with all the natural numbers and concluded that "equal", "greater" and "less" do not apply to infinite quantities; Bernard Bolzano's Paradoxes of the Infinite (1851) took the comparison of infinite sets further.
- Georg Cantor introduced derived sets (1872), proved that is uncountable (1874) and that and have the same cardinality (1877–78), introduced the transfinite ordinals (1880, systematically in his Grundlagen of 1883), and developed ordinal and cardinal arithmetic and the alephs in his Beiträge (1895–97). He formulated the continuum hypothesis in 1878.
- The Schröder–Bernstein theorem was proved by Richard Dedekind in 1887 (unpublished), stated by Cantor, given a flawed proof by Ernst Schröder (1896) and proved by Felix Bernstein (1897), a student in Cantor's seminar; Émile Borel published Bernstein's proof in 1898. Cesare Burali-Forti published his paradox in 1897.
- Gerhard Hessenberg proved for alephs in 1906; Friedrich Hartogs' theorem dates from 1915; John von Neumann gave the definition of ordinals used today in 1923. Reuben Goodstein's theorem appeared in 1944, and Kirby and Paris proved its unprovability in Peano arithmetic in 1982.
- David Hilbert made the continuum hypothesis the first of his 23 problems (Paris, 1900). Kurt Gödel (1938, published 1940) and Paul Cohen (1963) showed that ZFC neither refutes nor proves it.
Further reading
- Herbert B. Enderton, Elements of Set Theory (1977), chapters 6–8 — cardinals, orderings and ordinals at exactly this level.
- Karel Hrbacek and Thomas Jech, Introduction to Set Theory (third edition, 1999).
- Kenneth Kunen, Set Theory: An Introduction to Independence Proofs (1980), chapter I; and Thomas Jech, Set Theory (third millennium edition, 2003), chapters 2–5.
- Yiannis Moschovakis, Notes on Set Theory (1994; second edition 2006) — fixed points, recursion and well-orders.
- Georg Cantor, Contributions to the Founding of the Theory of Transfinite Numbers, translated by Philip Jourdain (1915) — Cantor's Beiträge in English.
- Joseph W. Dauben, Georg Cantor: His Mathematics and Philosophy of the Infinite (1979) — the history.
- Laurence Kirby and Jeff Paris, "Accessible independence results for Peano arithmetic", Bulletin of the London Mathematical Society (1982).