TExcelTAD
Home › Discrete Mathematics › The Well Ordering Principle

The Well Ordering Principle

The Well Ordering Principle (WOP) says:

Every non-empty set of non-negative integers has a smallest element.

It sounds obvious, and it is: but it is also a powerful proof tool, closely related to induction. It fails for other number sets. The integers Z\mathbb{Z} have no smallest element, and neither do the positive rationals: for any q>0q > 0, q/2q/2 is smaller.

The template: a smallest counterexample

To prove P(n)P(n) for all n∈Nn \in \mathbb{N}:

  1. Suppose, for contradiction, that the set C={n∈N∣¬P(n)}C = \{n \in \mathbb{N} \mid \neg P(n)\} of counterexamples is non-empty.
  2. By the WOP, CC has a smallest element mm.
  3. Use mm to find a smaller counterexample (or show P(m)P(m) holds anyway). Contradiction.
  4. So CC is empty and P(n)P(n) holds for all nn.

Theorem. For all n≥0n \ge 0: 0+1+2+⋯+n=n(n+1)20 + 1 + 2 + \cdots + n = \frac{n(n + 1)}{2}.

Proof. Suppose some nn fails, and let mm be the smallest failure. m≠0m \ne 0, because the formula holds at 0 (both sides are 0). So m−1≥0m - 1 \ge 0, and m−1m - 1 is not a failure by minimality:

0+1+⋯+(m−1)=(m−1)m20 + 1 + \cdots + (m - 1) = \frac{(m - 1)m}{2}

Add mm to both sides: the right side becomes (m−1)m2+m=m(m+1)2\frac{(m - 1)m}{2} + m = \frac{m(m + 1)}{2}, so the formula holds at mm after all. Contradiction. ■\blacksquare

Lowest terms exist

The proof that 2\sqrt{2} is irrational assumed a fraction can be written in lowest terms. WOP justifies it: among all ways of writing ab\frac{a}{b} with positive denominator, the set of denominators is a non-empty set of positive integers, so it has a smallest member b0b_0. If a0b0\frac{a_0}{b_0} were not in lowest terms, dividing both by a common factor d>1d > 1 would give a smaller denominator. Python's Fraction always stores this minimal form.

python · try it yourself
from fractions import Fraction
from math import gcd

a, b = 84, 120
g = gcd(a, b)
print(f"{a}/{b} -> {a // g}/{b // g}  (divided by gcd {g})")
print("Fraction stores:", Fraction(a, b))
84/120 -> 7/10  (divided by gcd 12)
Fraction stores: 7/10

Every integer greater than 1 is a product of primes

Theorem. Every integer n≥2n \ge 2 is a product of one or more primes.

Proof. Let CC be the set of integers ≥2\ge 2 that are not products of primes, and suppose CC is non-empty. Its smallest element mm is not prime (a prime is a product of one prime). So m=abm = ab with 2≤a,b<m2 \le a, b < m. Since a,b<ma, b < m, they are not in CC: each is a product of primes. Then m=abm = ab is a product of primes too. Contradiction. ■\blacksquare

The proof contains an algorithm: keep splitting a composite number into two smaller factors until only primes remain. Termination is guaranteed because the numbers keep getting smaller, and you cannot go down forever in N\mathbb{N}.

python · try it yourself
def split(n):
    """Factor n by repeatedly splitting off the smallest divisor."""
    for d in range(2, int(n ** 0.5) + 1):
        if n % d == 0:
            return split(d) + split(n // d)
    return [n]   # no divisor found: n is prime

for n in [12, 97, 360, 1001, 2 ** 10 - 1]:
    print(n, "=", " * ".join(map(str, split(n))))
12 = 2 * 2 * 3
97 = 97
360 = 2 * 2 * 2 * 3 * 3 * 5
1001 = 7 * 11 * 13
1023 = 3 * 11 * 31

Termination arguments

The same idea proves that loops and recursions stop. If every step of a process decreases a non-negative integer (a variant or measure), the process cannot run forever: otherwise the set of values it visits would have no smallest element. Euclid's algorithm terminates because the second argument strictly decreases; the recursive split above terminates because nn decreases.

Exercises

Exercise 1: A sum formula by WOP

Use the smallest-counterexample template to prove 1+3+5+⋯+(2n−1)=n21 + 3 + 5 + \cdots + (2n - 1) = n^2 for all n≥1n \ge 1.

Answer

If mm is the smallest failure, m>1m > 1, the formula holds for m−1m - 1, and adding 2m−12m - 1 gives (m−1)2+2m−1=m2(m - 1)^2 + 2m - 1 = m^2: contradiction.

Solution

At n=1n = 1 both sides equal 1, so the smallest failure mm satisfies m≥2m \ge 2. By minimality, 1+3+⋯+(2m−3)=(m−1)21 + 3 + \cdots + (2m - 3) = (m - 1)^2. Adding the next odd number:

(m−1)2+(2m−1)=m2−2m+1+2m−1=m2(m - 1)^2 + (2m - 1) = m^2 - 2m + 1 + 2m - 1 = m^2

So mm is not a failure. Contradiction: there is no failure. ■\blacksquare

Exercise 2: Where WOP fails

Show that the set {x∈Q∣x>0}\{x \in \mathbb{Q} \mid x > 0\} has no smallest element.

Answer

For any positive rational xx, x/2x/2 is a smaller positive rational.

Solution

Suppose xx were the smallest. x/2x/2 is rational, positive, and x/2<xx/2 < x. Contradiction. So WOP is special to sets of non-negative integers (and sets that look like them).

Exercise 3: Postage with 3 and 5 (code + proof idea)

Check in Python that every amount from 8 to 100 cents can be paid with 3-cent and 5-cent stamps. Then explain with WOP why it works for all n≥8n \ge 8.

Answer

The check passes. If m≥11m \ge 11 were the smallest failure, m−3≥8m - 3 \ge 8 works, and one more 3-cent stamp pays mm.

Solution
python · try it yourself
def payable(n):
    return any((n - 5 * f) % 3 == 0 for f in range(n // 5 + 1))

print(all(payable(n) for n in range(8, 101)))
print("not payable below 8:", [n for n in range(1, 8) if not payable(n)])
True
not payable below 8: [1, 2, 4, 7]

8, 9 and 10 work directly (3+53 + 5, 3+3+33 + 3 + 3, 5+55 + 5). Let mm be the smallest failure ≥8\ge 8; then m≥11m \ge 11, so m−3≥8m - 3 \ge 8 is payable by minimality, and adding a 3-cent stamp pays mm. Contradiction. ■\blacksquare

Test yourself

Which set has a smallest element?

  1. Z\mathbb{Z}
  2. the positive rationals
  3. {n∈N∣n2>50}\{n \in \mathbb{N} \mid n^2 > 50\}
  4. the negative integers

In a WOP proof, after picking the smallest counterexample mm, what do you usually show?

  1. That mm is prime
  2. That a smaller counterexample exists or that mm is not a counterexample
  3. That m=0m = 0
  4. That mm is even

Why does a loop that strictly decreases a non-negative integer each iteration terminate?

  1. Because computers are finite
  2. Because an infinite strictly decreasing sequence of natural numbers would have no smallest element
  3. Because of floating point
  4. It might not terminate