Which phone is best?
A student in Accra is choosing a phone. She cares about two things: price (lower is better) and battery life (longer is better).
| Phone | Price (cedis) | Battery (hours) |
|---|---|---|
| A | 1 200 | 20 |
| B | 1 500 | 30 |
| C | 1 800 | 25 |
| D | 2 400 | 40 |
| E | 1 400 | 18 |
Phone B is better than C in both respects, and A is better than E. But A and B cannot be compared: A is cheaper, B lasts longer. So "is at least as good in both respects as" orders the phones only partially. There is no single best phone; instead there are several that nothing beats — A, B and D — which economists call Pareto optimal, after the Italian economist Vilfredo Pareto, and mathematicians call maximal.
Partial orders are everywhere once you look: train and coach journeys from Osaka to Tokyo compared by fare and travel time (the bullet train is fastest, the overnight coach is cheapest, and neither beats the other), courses and their prerequisites (this curriculum is organised by one), tasks in a building project, versions of a document, subsets ordered by inclusion, whole numbers ordered by divisibility. This lesson gives the precise language for them — and shows how carefully one must use words like "best", "bound" and "least" when not everything can be compared.
Pictures of orders: Hasse diagrams
A finite partial order can be drawn as a Hasse diagram: put larger elements higher up, and draw a line from up to when covers — that is, with nothing strictly in between. All other comparisons are then read off as upward paths: exactly when one can climb from to .
Here are the subsets of ordered by inclusion. The diagram is a cube: at the bottom, the whole set at the top.
And here is divisibility on , with below when . Try tracing upward walks: each one is a chain, a set of pairwise comparable elements. Notice how many elements sit at the top with nothing above them.
Divisibility on {1, …, 12}
Edges join a number to the multiples that cover it. Which numbers have nothing above them?
No walk yet.
8 vertices have odd degree: 1, 3, 7, 11, 4, 6, 9, 8.
So no Euler trail is possible. A trail enters and leaves each vertex in its middle in pairs, so only its two ends can have odd degree, and this graph has 8 such vertices.
Definitions
Definition— preorder, partial order, total order
A relation on a set is a preorder if it is reflexive () and transitive ( and imply ). It is a partial order if moreover it is antisymmetric ( and imply ); then is a partially ordered set, or poset. Elements with or are comparable. A partial order in which every two elements are comparable is a total (or linear) order. We write for " and ".
Definition— chain, antichain, cover
A chain is a subset in which every two elements are comparable; an antichain is one in which no two distinct elements are. covers if and there is no with ; the covering pairs are the edges of the Hasse diagram.
Definition— maximal and greatest elements
An element is maximal if there is no with , and greatest if for every . Minimal and least elements are defined dually.
Definition— upper bounds and suprema
Let . An upper bound of is an element with for all . A least upper bound or supremum of , written or , is an upper bound that is every upper bound. Lower bounds and the greatest lower bound (infimum, or ) are defined dually. Note that is an element of ; it need not belong to .
Definition— lattice, complete lattice
A lattice is a poset in which every pair has a supremum (the join) and an infimum (the meet). A complete lattice is a poset in which every subset, including and infinite ones, has a supremum and an infimum.
Definition— well-order
A well-order is a total order in which every non-empty subset has a least element.
Definition— monotone map
A map between posets is monotone (order-preserving) if implies . A fixed point of is an element with .
Definition— Zorn's lemma
Zorn's lemma: if is a non-empty poset in which every chain has an upper bound in , then has a maximal element. (We state it now and discuss its status below.)
Examples and non-examples
Example— Orders on numbers
- , , and are total orders.
- , divisibility, is a partial order but not a total one ( and are incomparable). Its least element is , which divides everything; its greatest element is , which every number divides.
- On , divisibility is only a preorder: and but . Identifying each integer with its negative (passing to equivalence classes) turns it into a partial order — a general way of making a preorder into a partial order.
- The strict relation is not a partial order in our sense, because it is not reflexive; it is a strict order. Partial orders and strict orders correspond one-to-one via and .
Example— Orders on pairs
On , the product order and is partial: and are incomparable. This is the Pareto order of the motivating example, with prices negated. The lexicographic order — compare first coordinates, and use the second only to break ties, as in a dictionary — is total.
Example— Maximal but not greatest
In the maximal elements are — exactly the numbers with no proper multiple in the set — and there is no greatest element. The least element is . In the phones example, A, B and D are maximal and none is greatest.
Example— Bounds and suprema
- In , every family of subsets has a supremum, its union, and an infimum, its intersection: is a complete lattice.
- In , is the meet of and and is the join; is a lattice (in fact a complete one). But with divisibility is not a lattice: and have no upper bound in the set at all.
- In , the set has supremum , which is not in the set, while is bounded above but has no supremum in (see real numbers).
Maximal elements and suprema
Theorem— Proposition 1 (greatest versus maximal)
In a poset, a greatest element, if it exists, is unique and is the only maximal element. In a total order, an element is maximal if and only if it is greatest.
Proof
If and are greatest, then and , so by antisymmetry. A greatest is maximal: if then also , and antisymmetry gives , contradicting . If is any maximal element, then , and maximality forbids , so . In a total order, let be maximal and arbitrary; and are comparable, and is impossible, so : is greatest.
∎
Theorem— Theorem 2 (finite posets have maximal elements)
Every finite non-empty poset has a maximal element.
Proof
First proof (climbing). Start at any element . If it is not maximal, pick ; if is not maximal, pick , and so on. By transitivity whenever , so the are distinct (if with we would have ). A finite set cannot contain infinitely many distinct elements, so the climb stops — at a maximal element.
Second proof (counting, the one checked in Lean). For each let be its down-set, and choose with as large as possible. If , then by transitivity; by the choice of , , so . As , we get , and antisymmetry gives . So nothing is strictly above .
∎
The first proof makes a sequence of choices, which is harmless for finitely many steps; for infinite posets the climb may go on for ever ( in ), and Zorn's lemma is exactly the principle that rescues it when every chain is bounded.
Theorem— Corollary 3 (linear extensions)
Every partial order on a finite set can be extended to a total order: there is a total order with .
Proof
Induction on the number of elements. The empty poset is totally ordered. Otherwise let be maximal (Theorem 2), totally order extending its partial order (induction hypothesis), and put at the end. Since nothing in is strictly above , no comparison is violated.
∎
This is the mathematics behind topological sorting: listing courses so that every course comes after its prerequisites, or scheduling tasks so that each starts after the tasks it depends on.
Theorem— Proposition 4 (suprema are unique; unions and gcds)
A subset has at most one supremum. In , and ; in , and .
Proof
If and are both suprema, each is an upper bound and each is below every upper bound, so and : .
contains and , and any set containing both contains ; so is the least upper bound. Dually for . In , divides and , and every common divisor of and divides (a consequence of Bézout's identity; see divisibility), so is the greatest lower bound in the divisibility order. Dually, every common multiple is a multiple of .
∎
In any lattice the operations satisfy associative and commutative laws, , and the absorption laws
(For the first: is an upper bound of and of , so , and the reverse inequality always holds.) Conversely, a set with two operations obeying these laws is a lattice, ordered by : lattices can be defined algebraically, as in algebraic structures.
Well-orders
Theorem— Theorem 5 (ℕ is well-ordered)
Every non-empty subset of has a least element.
Proof
Suppose has no least element. We show by strong induction that no lies in . Assume that no lies in . If , then — as is not the least element of — some satisfies , contradicting the assumption. So . Hence .
∎
The well-ordering principle and induction are two faces of the same fact (see proof techniques): induction can also be derived from well-ordering, by considering the least counterexample.
Theorem— Proposition 6 (ℤ and ℚ are not well-ordered)
is not a well-order: itself has no least element. is not a well-order either, and even has no least element.
Proof
For every , . For every positive rational , is a smaller positive rational.
∎
Being well-ordered depends on the order, not just the set: can be well-ordered, for example as (compare by absolute value, negatives first). Cantor's ordinal numbers are the "lengths" of well-orders, continuing the natural numbers into the infinite: Every well-order supports proofs by transfinite induction, the same argument as Theorem 5. Zermelo's well-ordering theorem (1904) says every set can be well-ordered — even — but its proof uses the axiom of choice, and no explicit well-order of can be written down.
Fixed points and Zorn's lemma
Theorem— Theorem 7 (Knaster–Tarski)
Let be a complete lattice and a monotone map. Then has a least fixed point, namely
Proof
Let . For every we have , so by monotonicity. Thus is a lower bound of , and since is the greatest lower bound. Applying , , so , and therefore . Hence . Any fixed point satisfies , so and .
∎
This theorem is how mathematics and computer science define things "inductively". For instance, the set of vertices reachable from a vertex in a graph is the least fixed point of the monotone map on the complete lattice of sets of vertices. In a finite lattice it can also be computed by iterating from the bottom element, , until the sequence stops growing. Knaster–Tarski also gives a slick proof of the Cantor–Schröder–Bernstein theorem (see cardinals).
Zorn's lemma. Theorem 2 guarantees maximal elements in finite posets. In infinite posets they may not exist — has none — and Zorn's lemma gives a sufficient condition: if every chain has an upper bound, a maximal element exists. It is the standard tool for producing "maximal" objects in infinite settings. For example, to find a basis of a vector space , consider the poset of linearly independent subsets of ordered by inclusion; the union of a chain of independent sets is independent and is an upper bound, so Zorn's lemma gives a maximal independent set, which must span (otherwise a vector outside the span could be added). The same pattern gives maximal ideals in rings. Zorn's lemma cannot be proved from the other axioms of set theory (ZF): over ZF it is equivalent to the axiom of choice (see the axiom of choice). In this lesson we use it as a tool, to be justified there.
Orders in Lean and Mathlib
Mathlib's order theory is organised by type classes — Preorder, PartialOrder, LinearOrder, Lattice (with ⊔ and ⊓), CompleteLattice (with sSup and sInf) — and predicates such as IsLUB s a ("a is a least upper bound of s") and IsMax m ("nothing is strictly above m").
Divisibility. Antisymmetry on by the human argument (, , so ); a copy of carrying the divisibility order, built as a genuine PartialOrder instance from the three axioms; and the failure of antisymmetry on .
/-- **Antisymmetry of divisibility on ℕ.** If `a ∣ b` and `b ∣ a` then `a = b`. Write `b = ak` and
`a = bl = a(kl)`. If `a = 0` then `b = 0` too; otherwise cancel `a` to get `kl = 1`, so `k = 1`
and `b = a`. (Reflexivity, `a ∣ a`, and transitivity are immediate.) -/
theorem nat_dvd_antisymm {a b : ℕ} (h₁ : a ∣ b) (h₂ : b ∣ a) : a = b := by
obtain ⟨k, rfl⟩ := h₁
obtain ⟨l, hl⟩ := h₂
rcases Nat.eq_zero_or_pos a with rfl | ha
· simp
· have hkl : k * l = 1 := by
have h : a * 1 = a * (k * l) := by rw [mul_one, ← mul_assoc]; exact hl
exact (Nat.eq_of_mul_eq_mul_left ha h).symm
rw [Nat.eq_one_of_mul_eq_one_right hkl, mul_one]/-- A copy of `ℕ` ordered by divisibility (`a ≤ b` means `a ∣ b`), so that Mathlib's order
library can be used on it. The axioms are `dvd_refl`, `dvd_trans` and `nat_dvd_antisymm`. In this
order `1` is the least element and `0` the greatest (every number divides `0`). -/
def DivNat : Type := ℕ/-- The partial order on `DivNat`. -/
instance DivNat.instPartialOrder : PartialOrder DivNat where
le a b := @Dvd.dvd ℕ _ a b
le_refl a := @dvd_refl ℕ _ a
le_trans a b c := @dvd_trans ℕ _ a b c
le_antisymm a b := @nat_dvd_antisymm a b/-- **On ℤ, divisibility is only a preorder.** `2 ∣ -2` and `-2 ∣ 2`, yet `2 ≠ -2`:
antisymmetry fails because `2` and `-2` are *associates* (they differ by the unit `-1`). -/
theorem int_dvd_not_antisymm : (2 : ℤ) ∣ -2 ∧ (-2 : ℤ) ∣ 2 ∧ (2 : ℤ) ≠ -2 := by
refine ⟨⟨-1, by norm_num⟩, ⟨-1, by norm_num⟩, by norm_num⟩Maximal versus greatest, checked by decide on , and Theorem 2 by the counting proof — the down-set of largest size.
/-- **The maximal elements of `({1, …, 12}, ∣)` are `7, 8, 9, 10, 11, 12`:** exactly the numbers
`m` with no proper multiple in the set. Checked by `decide`. -/
theorem maximal_in_one_to_twelve :
(Finset.Icc 1 12).filter (fun m => ∀ x ∈ Finset.Icc 1 12, m ∣ x → x = m) =
{7, 8, 9, 10, 11, 12} := by
decide/-- **…but there is no greatest element:** no `g ∈ {1, …, 12}` is divisible by every member. With
several maximal elements, none of them can be greatest. -/
theorem no_greatest_in_one_to_twelve :
¬ ∃ g ∈ Finset.Icc 1 12, ∀ x ∈ Finset.Icc 1 12, x ∣ g := by
decide/-- **Every finite non-empty poset has a maximal element.** Choose `m` with the largest number of
elements below it. If `m ≤ x`, everything below `m` is below `x`, so the down-set of `m` is
contained in that of `x`; by the choice of `m` the two down-sets have the same size, hence are
equal. Then `x` (which is below `x`) is below `m`, and antisymmetry gives `x = m`. -/
theorem exists_maximal_of_finite {α : Type*} [PartialOrder α] [Fintype α] [Nonempty α] :
∃ m : α, ∀ x, m ≤ x → x = m := by
classical
obtain ⟨m, hm⟩ := Finite.exists_max (fun y : α => (Finset.univ.filter (· ≤ y)).card)
refine ⟨m, fun x hmx => ?_⟩
have hsub : Finset.univ.filter (· ≤ m) ⊆ Finset.univ.filter (· ≤ x) := by
intro y hy
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hy ⊢
exact le_trans hy hmx
have heq := Finset.eq_of_subset_of_card_le hsub (hm x)
have hx : x ∈ Finset.univ.filter (· ≤ m) := by
rw [heq]
simp
simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hx
exact le_antisymm hx hmxJoins and meets. Unions and intersections are the joins and meets of subsets, the gcd is the meet for divisibility (core Lean's Nat.dvd_gcd_iff), a supremum outside its set, and absorption.
/-- **In `(P(A), ⊆)` the join of two sets is their union:** `s ∪ t` is an upper bound of
`{s, t}`, and any set containing both `s` and `t` contains `s ∪ t`. -/
theorem union_isLUB {A : Type*} (s t : Set A) : IsLUB {s, t} (s ∪ t) := by
constructor
· rintro u (rfl | rfl)
· exact Set.subset_union_left
· exact Set.subset_union_right
· intro u hu
exact Set.union_subset (hu (Set.mem_insert s {t})) (hu (Set.mem_insert_of_mem s rfl))/-- **…and the meet is the intersection**, by the dual argument. So `(P(A), ⊆)` is a lattice. -/
theorem inter_isGLB {A : Type*} (s t : Set A) : IsGLB {s, t} (s ∩ t) := by
constructor
· rintro u (rfl | rfl)
· exact Set.inter_subset_left
· exact Set.inter_subset_right
· intro u hu
exact Set.subset_inter (hu (Set.mem_insert s {t})) (hu (Set.mem_insert_of_mem s rfl))/-- **In `(ℕ, ∣)` the meet of `a` and `b` is `gcd(a, b)`:** `d` divides `gcd(a, b)` exactly when it
divides both. This is core Lean's `Nat.dvd_gcd_iff`. (Dually, the join is `lcm(a, b)`.) -/
theorem gcd_is_meet (a b d : ℕ) : d ∣ Nat.gcd a b ↔ d ∣ a ∧ d ∣ b := Nat.dvd_gcd_iff/-- **A least upper bound need not belong to the set:** in `ℚ`, the set of rationals below `1`
has least upper bound `1`, which is not in the set. Mathlib's `isLUB_Iio`. -/
theorem lub_not_mem : IsLUB (Set.Iio (1 : ℚ)) 1 ∧ (1 : ℚ) ∉ Set.Iio 1 :=
⟨isLUB_Iio, fun h => lt_irrefl (1 : ℚ) h⟩/-- **The absorption law** `a ⊔ (a ⊓ b) = a`, which holds in every lattice: `a` is an upper bound
of `a` and of `a ⊓ b ≤ a`, so the join is at most `a`; and `a ≤ a ⊔ (a ⊓ b)` always. Mathlib's
`sup_inf_self`. Absorption, with associativity and commutativity of `⊔` and `⊓`, characterises
lattices algebraically. -/
theorem absorption {L : Type*} [Lattice L] (a b : L) : a ⊔ (a ⊓ b) = a :=
le_antisymm (sup_le le_rfl inf_le_left) le_sup_leftWell-orders. Theorem 5 by strong induction, exactly as above, and the two non-examples of Proposition 6.
/-- **ℕ is well-ordered: every non-empty set of naturals has a least element.** Suppose `S` has no
least element. By strong induction no `k` lies in `S`: if `k ∈ S`, then since `k` is not least
there is a smaller `n ∈ S`, contradicting the induction hypothesis for `n`. So `S` is empty. -/
theorem nat_wellOrdered (S : Set ℕ) (hS : S.Nonempty) : ∃ m ∈ S, ∀ n ∈ S, m ≤ n := by
by_contra h
have h' : ∀ m ∈ S, ∃ n ∈ S, n < m := by
intro m hm
by_contra hne
exact h ⟨m, hm, fun n hn => not_lt.mp fun hnm => hne ⟨n, hn, hnm⟩⟩
have key : ∀ k, k ∉ S := by
intro k
induction k using Nat.strong_induction_on with
| _ k ih =>
intro hk
obtain ⟨n, hn, hnk⟩ := h' k hk
exact ih n hnk hn
obtain ⟨x, hx⟩ := hS
exact key x hx/-- **ℤ is not well-ordered by `≤`:** the whole of `ℤ` (a non-empty set) has no least element,
since `m - 1 < m` for every `m`. -/
theorem int_not_wellOrdered : ¬ ∃ m : ℤ, ∀ x : ℤ, m ≤ x := by
rintro ⟨m, hm⟩
have := hm (m - 1)
omega/-- **Nor is ℚ, even on the positive part:** the positive rationals have no least element, since
`0 < m/2 < m` whenever `0 < m`. -/
theorem rat_pos_no_least : ¬ ∃ m : ℚ, 0 < m ∧ ∀ q : ℚ, 0 < q → m ≤ q := by
rintro ⟨m, hm, hmin⟩
have := hmin (m / 2) (by linarith)
linarithFixed points and Zorn. Knaster–Tarski in four lines, each matching a sentence of the proof; and Zorn's lemma, which Mathlib proves from the axiom of choice (Lean's Classical.choice).
/-- **Knaster–Tarski: every monotone map on a complete lattice has a least fixed point**, namely
`a = inf {x | f x ≤ x}`. For each such `x`, `a ≤ x` gives `f a ≤ f x ≤ x`, so `f a` is a lower
bound and `f a ≤ a`. Then `f (f a) ≤ f a`, so `f a` belongs to the set and `a ≤ f a`. Any fixed
point `b` belongs to the set, so `a ≤ b`. (Mathlib's version is `OrderHom.lfp`.) -/
theorem knaster_tarski {L : Type*} [CompleteLattice L] (f : L → L) (hf : Monotone f) :
∃ a, f a = a ∧ ∀ b, f b = b → a ≤ b := by
set a := sInf {x | f x ≤ x} with ha
have h1 : f a ≤ a := le_sInf fun x hx => le_trans (hf (sInf_le hx)) hx
have h2 : a ≤ f a := sInf_le (show f (f a) ≤ f a from hf h1)
exact ⟨a, le_antisymm h1 h2, fun b hb => sInf_le (show f b ≤ b from hb.le)⟩/-- **Zorn's lemma:** in a preorder in which every chain has an upper bound, there is a maximal
element (nothing strictly above it). Mathlib's `zorn_le`, proved there from the axiom of choice;
over ZF the two are equivalent (see the lesson on the axiom of choice). -/
theorem zorn {α : Type*} [Preorder α] (h : ∀ c : Set α, IsChain (· ≤ ·) c → BddAbove c) :
∃ m : α, IsMax m :=
zorn_le hNot formalised here: Proposition 1, the linear-extension corollary, the algebraic characterisation of lattices, and the well-ordering theorem (Mathlib: WellOrderingRel), whose proof, like Zorn's lemma, uses choice.
Counting orders, and computing with them
How many partial orders are there on a small set? Every partial order is reflexive, so it suffices to try all choices of the off-diagonal pairs — relations on four elements — and test the axioms. The census shows that total orders and lattices are rare among partial orders, and checks Theorem 2 on every poset with at most four elements. (The number of preorders, , will reappear in the topologist's viewpoint.)
"""How many ways can a small set be ordered? An exhaustive census of posets.
Every partial order on an n-element set is a reflexive relation, so it is
enough to try all 2^(n(n-1)) choices of the off-diagonal pairs. For n <= 4 the
experiment counts the preorders, the partial orders, the total orders and the
lattices among them, and checks on every partial order the lesson's theorem
that a finite non-empty poset has a maximal element - and that "maximal"
and "greatest" really differ. The counts are exact and exhaustive for these
sizes (they agree with the published values: 1, 3, 19, 219 partial orders);
they prove nothing for larger n.
"""
import itertools
import math
def reflexive_relations(n):
"""Yield every reflexive relation on range(n) as a set of pairs."""
off = [(a, b) for a in range(n) for b in range(n) if a != b]
diag = {(a, a) for a in range(n)}
for bits in itertools.product((0, 1), repeat=len(off)):
yield diag | {p for p, bit in zip(off, bits) if bit}
def is_transitive(rel, n):
"""(a, b) and (b, c) in rel imply (a, c) in rel."""
return all((a, c) in rel for (a, b) in rel for c in range(n)
if (b, c) in rel)
def is_antisymmetric(rel):
"""(a, b) and (b, a) in rel imply a = b."""
return all(a == b or (b, a) not in rel for (a, b) in rel)
def is_total(rel, n):
"""Any two elements are comparable."""
return all((a, b) in rel or (b, a) in rel
for a in range(n) for b in range(n))
def maximal_elements(rel, n):
"""Elements with nothing strictly above them."""
return [m for m in range(n)
if not any((m, x) in rel and x != m for x in range(n))]
def greatest_element(rel, n):
"""The element above everything, or None."""
tops = [g for g in range(n) if all((x, g) in rel for x in range(n))]
return tops[0] if tops else None
def join(rel, n, a, b):
"""The least upper bound of a and b, or None if it does not exist."""
ups = [u for u in range(n) if (a, u) in rel and (b, u) in rel]
least = [u for u in ups if all((u, v) in rel for v in ups)]
return least[0] if least else None
def meet(rel, n, a, b):
"""The greatest lower bound of a and b, or None."""
return join({(y, x) for (x, y) in rel}, n, a, b)
def is_lattice(rel, n):
"""Every pair has a join and a meet."""
return all(join(rel, n, a, b) is not None and meet(rel, n, a, b)
is not None for a in range(n) for b in range(n))
def census(n):
"""Counts for all relations on an n-element set."""
c = {"preorders": 0, "partial orders": 0, "total orders": 0,
"lattices": 0, "with greatest": 0, "max ok": True}
for rel in reflexive_relations(n):
if not is_transitive(rel, n):
continue
c["preorders"] += 1
if not is_antisymmetric(rel):
continue
c["partial orders"] += 1
c["total orders"] += is_total(rel, n)
c["lattices"] += is_lattice(rel, n)
c["with greatest"] += greatest_element(rel, n) is not None
c["max ok"] = c["max ok"] and bool(maximal_elements(rel, n))
return c
def main():
print(" n preorders partial total n! lattices with greatest")
every = True
for n in range(1, 5):
c = census(n)
every = every and c["max ok"]
print(f"{n:>2} {c['preorders']:>9} {c['partial orders']:>7}"
f" {c['total orders']:>5} {math.factorial(n):>2}"
f" {c['lattices']:>8} {c['with greatest']:>13}")
print("every partial order (n <= 4) has a maximal element:", every)
v = {(0, 0), (1, 1), (2, 2), (0, 1), (0, 2)}
print("the 'V' shape 0 < 1, 0 < 2: maximal", maximal_elements(v, 3),
"greatest", greatest_element(v, 3), "join(1, 2)", join(v, 3, 1, 2))
print()
print("Epistemic status: an exact, exhaustive count for sets of at most")
print("four elements, agreeing with the known values. It illustrates that")
print("most partial orders are neither total nor lattices, and confirms")
print("the maximal-element theorem for these cases only; the lesson proves")
print("it for every finite poset.")
if __name__ == "__main__":
main()The second experiment computes the Hasse diagram of divisibility on , confirms that the divisors of form a lattice with and as meet and join while does not, and finds the set of vertices reachable in a small graph as a least fixed point — once by iterating from , once as the intersection of all pre-fixed points, as in Theorem 7.
"""Divisibility as an order: Hasse diagrams, lattices and a least fixed point.
The experiment lists the covering pairs of ({1, ..., 12}, |) - the edges of
its Hasse diagram - and its minimal and maximal elements; checks that the
divisors of 60 form a lattice with meet gcd and join lcm, while {1, ..., 12}
is not a lattice; and computes a least fixed point two ways, as the
Knaster-Tarski theorem predicts: by iterating a monotone map on the subsets of
a finite set starting from the empty set, and as the intersection of all
sets S with f(S) contained in S. Exact and exhaustive for these examples.
"""
import itertools
import math
def covers(elements, leq):
"""Pairs (a, b) with a < b and nothing strictly between: Hasse edges."""
return [(a, b) for a in elements for b in elements
if a != b and leq(a, b)
and not any(c not in (a, b) and leq(a, c) and leq(c, b)
for c in elements)]
def divides(a, b):
"""a | b."""
return b % a == 0
def maximal(elements, leq):
"""Elements with no strictly larger element."""
return [m for m in elements
if not any(x != m and leq(m, x) for x in elements)]
def least_upper_bound(elements, leq, a, b):
"""The join of a and b inside `elements`, or None."""
ups = [u for u in elements if leq(a, u) and leq(b, u)]
least = [u for u in ups if all(leq(u, v) for v in ups)]
return least[0] if least else None
def lattice_check(elements, leq):
"""Return the first pair without a join, or None if all joins exist."""
for a, b in itertools.combinations(elements, 2):
if least_upper_bound(elements, leq, a, b) is None:
return a, b
return None
EDGES = {0: {1, 2}, 1: {3}, 2: {3}, 3: {4}, 4: set(), 5: {6}, 6: {5}, 7: {0}}
def step(s, start=0, edges=EDGES):
"""f(S) = {start} together with every successor of S: monotone in S."""
return frozenset({start}) | frozenset(t for v in s for t in edges[v])
def lfp_by_iteration(f):
"""Kleene iteration: empty set, f(empty), f(f(empty)), ... until stable."""
s, rounds = frozenset(), 0
while f(s) != s:
s, rounds = f(s), rounds + 1
return s, rounds
def lfp_by_prefixed_points(f, universe):
"""Intersection of all S with f(S) a subset of S (Knaster-Tarski)."""
result = frozenset(universe)
for r in range(len(universe) + 1):
for s in itertools.combinations(universe, r):
s = frozenset(s)
if f(s) <= s:
result &= s
return result
def main():
nums = list(range(1, 13))
edges = covers(nums, divides)
print(f"Hasse diagram of ({{1..12}}, |): {len(edges)} covering pairs")
print(" " + " ".join(f"{a}-{b}" for a, b in edges[:12]))
print(" " + " ".join(f"{a}-{b}" for a, b in edges[12:]))
print(" minimal:", maximal(nums, lambda a, b: divides(b, a)),
" maximal:", maximal(nums, divides))
print(" pair with no join in {1..12}:", lattice_check(nums, divides))
d60 = [d for d in range(1, 61) if 60 % d == 0]
ok = all(least_upper_bound(d60, divides, a, b) == math.lcm(a, b)
for a in d60 for b in d60)
print(f"divisors of 60 ({len(d60)}): every join exists and is the lcm:", ok)
print(" pair with no join among divisors of 60:",
lattice_check(d60, divides))
print()
fix, rounds = lfp_by_iteration(step)
meet = lfp_by_prefixed_points(step, range(8))
print("reachable from 0 in a graph = least fixed point of S -> {0} u succ(S)")
print(f" iteration from the empty set: {sorted(fix)} after {rounds} rounds")
print(f" meet of all pre-fixed points: {sorted(meet)}")
print(" the two agree:", fix == meet)
print()
print("Epistemic status: exact, exhaustive computations for these finite")
print("examples. They illustrate the definitions and the Knaster-Tarski")
print("theorem, which the lesson proves for every complete lattice.")
if __name__ == "__main__":
main()Both are exhaustive and exact for the finite examples computed. They illustrate the theorems; the proofs above cover all posets and all complete lattices.
Exercises
1. Orders, lattices and well-orders
Warm-upHumanWhich of these relations are partial orders (reflexive, antisymmetric, transitive)? (Choose all that apply.)
2. Orders, lattices and well-orders
Warm-upHumanConsider ordered by divisibility. List all its maximal elements, separated by commas.
3. Orders, lattices and well-orders
Warm-upHumanIn the lattice , what is the join (least upper bound) ?
4. Orders, lattices and well-orders
CoreHumanHow many edges (covering pairs) does the Hasse diagram of have?
5. Orders, lattices and well-orders
CoreHumanTheorem 2 says every finite non-empty poset has a maximal element. Which example shows that the word "finite" cannot simply be dropped?
6. Orders, lattices and well-orders
CoreHumanWhich of these totally ordered sets are well-ordered (every non-empty subset has a least element)? (Choose all that apply.)
7. Orders, lattices and well-orders
CoreFormalWhich Lean statement says correctly that every finite non-empty poset has a maximal element?
8. Orders, lattices and well-orders
StretchHumanKnaster–Tarski: a monotone map on a complete lattice has a fixed point. Which examples show that one of the two hypotheses cannot be dropped? (Choose all that apply.)
9. Orders, lattices and well-orders
StretchComputationalWrite linear_extension(elements, leq) that lists the elements of a finite poset in an order compatible with leq (a function returning True when ): whenever and , must come before . Use the idea of Corollary 3, or repeatedly take a minimal element.
Common misconceptions
Misconception
Treating "maximal" and "greatest" as synonyms. Greatest means above everything; maximal means nothing is above it. They agree in total orders, but a partial order can have many maximal elements and no greatest one: in there are six maximal elements and no greatest. If a greatest element exists, it is the unique maximal element (Proposition 1) — but a unique maximal element need not be greatest in an infinite poset (take together with one extra element that is comparable only with itself: is the only maximal element, yet it is not above ).
Misconception
Assuming every partial order is total. Divisibility, inclusion of sets and the product order on pairs all have incomparable elements. Arguments such as "either or " are valid only after totality has been established.
Misconception
"The least upper bound of a set belongs to the set." It need not: is not in the set, and in the supremum of is . When the supremum does belong to the set, it is the set's greatest element.
Misconception
"A set with a least element is well-ordered." Well-ordering requires that every non-empty subset has a least element. The non-negative rationals have a least element, , but their subset of positive rationals has none.
Misconception
"Zorn's lemma is proved by climbing until you reach the top." Climbing works for finite posets (Theorem 2). For infinite ones the climb must continue transfinitely, choosing an upper bound at every limit stage — infinitely many arbitrary choices, which is exactly what the axiom of choice provides. Without choice, Zorn's lemma cannot be proved.
Many ways of seeing
Topology— Finite topologies are preorders
Every topological space carries a specialisation preorder: when every open set containing also contains (equivalently, lies in the closure of , with the convention that open sets are "up-sets"). For finite spaces the correspondence is perfect: topologies on a finite set are in one-to-one correspondence with preorders on it, the open sets being exactly the up-closed sets, and the space is (points are distinguished by open sets) exactly when the preorder is a partial order. So the census counts topologies too: there are topologies on a three-point set, the same as the number of preorders. Continuous maps between finite spaces are exactly the monotone maps. In the other direction, every total order generates an order topology, and for a dense total order connectedness is equivalent to completeness — the reason is connected and is not (see point-set topology).
Geometry— The Boolean lattice is a cube
The Hasse diagram of is the graph of the -dimensional cube: identify a subset with its indicator vector in , and two subsets are joined when they differ in one coordinate. Rank (the size of a subset) is height in the cube; the meet and join are coordinatewise minimum and maximum. More generally, the faces of a convex polytope — vertices, edges, faces, …, ordered by inclusion — form a lattice, the face lattice, which captures the polytope's combinatorial shape; the face lattice of a cube, for instance, has elements between the empty face and the whole cube. Product orders on are geometric too: the elements above a point form a closed orthant, and the Pareto front of a finite set is its set of maximal points.
Combinatorics— Chains, antichains and Dilworth's theorem
In a finite poset, a chain and an antichain share at most one element, so covering the poset by chains needs at least as many chains as the size of the largest antichain. Dilworth's theorem (1950) says this bound is attained: the minimum number of chains covering a finite poset equals the maximum size of an antichain. Its dual, Mirsky's theorem, says the length of the longest chain equals the minimum number of antichains covering the poset. In , the largest antichain has sets — all subsets of the middle size — which is Sperner's theorem (1928). For , the six maximal elements form an antichain, and the chains , , , , , cover the poset, so six is the answer to both questions (see combinatorics).
Logic— Implication is an order, and induction is a least fixed point
Propositions ordered by implication ( when implies , up to logical equivalence) form a lattice whose meet is "and" and whose join is "or": a Boolean algebra, the algebraic face of propositional logic (see propositional logic). The Knaster–Tarski theorem is the foundation of inductive definitions: the natural numbers, the well-formed formulas of a logic and the theorems of a proof system are each the least set closed under certain rules — the least fixed point of a monotone operator — and proofs by induction over them are proofs that a property defines a pre-fixed point. In computer science, the meaning of a recursive program is the least fixed point of a monotone map on a lattice of partial functions, and static analysers compute least fixed points by exactly the iteration from the bottom element used in the computation section.
Category theory— A preorder is a category with at most one arrow
A preorder is the same thing as a category with at most one morphism between any two objects: put an arrow exactly when ; reflexivity provides identities and transitivity provides composition. Monotone maps are then exactly functors, a supremum is a coproduct, an infimum is a product, a greatest element is a terminal object and a least element an initial object. A pair of monotone maps , with — a Galois connection — is precisely an adjunction between thin categories, and much of category theory can be first learned in this simplified, ordered setting (see categories and adjunctions).
History and global context
- Orders of magnitude and of numbers. Comparisons of size are as old as counting, but the idea of a relation that orders only some pairs emerged in the nineteenth century, in the algebra of logic of George Boole, Charles Sanders Peirce and Ernst Schröder, and in Richard Dedekind's work on ideals: Dedekind's "Dualgruppen" (1897, 1900) are what we now call lattices.
- Well-orders and choice. Georg Cantor introduced well-ordered sets and ordinal numbers in the 1880s and 1890s. Ernst Zermelo proved in 1904 that every set can be well-ordered, using the axiom of choice he made explicit for the purpose. Felix Hausdorff's Grundzüge der Mengenlehre (1914) developed the theory of ordered sets systematically and stated a maximal principle; Kazimierz Kuratowski (1922) and Max Zorn (1935) gave the forms now used as "Zorn's lemma".
- Lattices and fixed points. Garrett Birkhoff's Lattice Theory (1940) established lattices as a field of their own. Bronisław Knaster and Alfred Tarski proved the fixed-point theorem for sets in 1928, and Tarski gave the general lattice version in 1955. Hasse diagrams take their name from Helmut Hasse, who used them in algebraic number theory; Robert Dilworth proved his decomposition theorem in 1950.
- Orders at work. Algorithms for ordering tasks consistently with their dependencies — topological sorting — were developed for project planning and computing in the 1950s and 1960s, and today schedule everything from building projects to software compilation.
Further reading
- B. A. Davey and H. A. Priestley, Introduction to Lattices and Order (1990; 2nd ed. 2002) — the standard introduction, with many pictures.
- Garrett Birkhoff, Lattice Theory (1940; 3rd ed. 1967) — the classic monograph.
- Paul R. Halmos, Naive Set Theory (1960) — short chapters on orders, Zorn's lemma, well-ordering and ordinals.
- Bernd S. W. Schröder, Ordered Sets: An Introduction (2003) — combinatorial order theory, including Dilworth's theorem and fixed points.
- William T. Trotter, Combinatorics and Partially Ordered Sets: Dimension Theory (1992) — for the combinatorial side.