Strong Induction
In ordinary induction the step from to may use only . Strong induction lets the step use all earlier cases . This fits problems where the next case depends on cases further back: Fibonacci numbers, factorization into primes, and recursive algorithms that split a problem into unequal parts.
The principle
To prove :
- Base case(s): prove (and maybe a few more small cases).
- Inductive step: for every , prove that implies .
Strong induction is not more powerful than ordinary induction (apply ordinary induction to ), but it is often more convenient.
Products of primes, again
Theorem. Every integer is a product of primes.
Proof by strong induction. Assume every with is a product of primes, and consider . If is prime, it is a product of one prime. Otherwise with . By the hypothesis, and are products of primes, hence so is .
Ordinary induction would be awkward here: knowing that factors says nothing about .
Making change
Theorem. Every amount of cents can be paid with 4-cent and 5-cent coins.
Proof. Base cases: , , , . Step: for , the amount can be paid by the hypothesis; add one 4-cent coin.
The step reaches back 4 cases, so it needs 4 base cases. The proof is again an algorithm:
def pay(n):
"""Coins of 4 and 5 adding to n >= 12, following the strong-induction proof."""
base = {12: [4, 4, 4], 13: [4, 4, 5], 14: [4, 5, 5], 15: [5, 5, 5]}
if n in base:
return base[n]
return pay(n - 4) + [4]
for n in [12, 17, 23, 30, 31]:
coins = pay(n)
print(n, "=", " + ".join(map(str, coins)), " check:", sum(coins) == n)
cannot = [n for n in range(1, 12) if not any((n - 5 * k) % 4 == 0 for k in range(n // 5 + 1))]
print("amounts below 12 that cannot be paid:", cannot)12 = 4 + 4 + 4 check: True
17 = 4 + 4 + 5 + 4 check: True
23 = 5 + 5 + 5 + 4 + 4 check: True
30 = 4 + 5 + 5 + 4 + 4 + 4 + 4 check: True
31 = 5 + 5 + 5 + 4 + 4 + 4 + 4 check: True
amounts below 12 that cannot be paid: [1, 2, 3, 6, 7, 11]
11 is the largest amount that cannot be paid (the Frobenius number of 4 and 5 is ).
Fibonacci bounds
The Fibonacci numbers are , , . Each term depends on the two before it, so strong induction is natural.
Theorem. for all .
Proof. Base: , . Step: for , .
A sharper bound with the same method: for , where satisfies . So Fibonacci numbers grow exponentially, which is why the naive recursive fib takes exponential time.
phi = (1 + 5 ** 0.5) / 2
a, b = 0, 1
for n in range(1, 16):
a, b = b, a + b # now a = F_n
if n % 3 == 0:
print(f"n={n:2d} F_n={a:4d} phi^(n-2)={phi ** (n - 2):8.2f} 2^n={2 ** n:6d}")n= 3 F_n= 2 phi^(n-2)= 1.62 2^n= 8
n= 6 F_n= 8 phi^(n-2)= 6.85 2^n= 64
n= 9 F_n= 34 phi^(n-2)= 29.03 2^n= 512
n=12 F_n= 144 phi^(n-2)= 122.99 2^n= 4096
n=15 F_n= 610 phi^(n-2)= 521.00 2^n= 32768
The unstacking game
Split a stack of boxes into two stacks of and boxes and score points; keep splitting until all stacks have one box. Every strategy scores exactly . Strong induction: the first split scores , then the parts score and by the hypothesis (they are smaller than ), and . Exercise 3 checks it by computer.
In software
Divide-and-conquer algorithms (quicksort, merge sort, binary search on unequal halves) recurse on parts of some smaller size, not necessarily . Their correctness proofs use strong induction: assume the algorithm is correct on all smaller inputs.
Exercises
Exercise 1: Stamps of 3 and 7
Prove that every amount can be paid with 3-cent and 7-cent stamps.
Answer
Base cases 12, 13, 14; step: pay (that is, ) and add a 3.
Solution
Base: , , . Step: for , is payable by the hypothesis; add a 3-cent stamp. Three base cases are needed because the step goes back 3. (11 is not payable: and 11 are not multiples of 3.)
Exercise 2: Every positive integer is a sum of distinct powers of 2
Prove it by strong induction.
Answer
Take the largest power ; is a sum of distinct smaller powers.
Solution
Base: . Step: let and . If we are done. Otherwise , so by the hypothesis is a sum of distinct powers of 2, all smaller than (since they sum to less than ). Adding keeps them distinct. This is the existence of binary representation.
Exercise 3: Unstacking (code)
Play the unstacking game for with random splits several times and compare the score with .
Answer
Every run scores 45.
Solution
import random
def play(n, rng):
if n == 1:
return 0
a = rng.randint(1, n - 1)
return a * (n - a) + play(a, rng) + play(n - a, rng)
rng = random.Random(3)
print([play(10, rng) for _ in range(6)], 10 * 9 // 2)[45, 45, 45, 45, 45, 45] 45
Test yourself
What may the inductive step of strong induction assume?
- Only
- Nothing
A strong-induction step for uses . How many base cases are needed?
- 1
- 2
- 4
- None
Is strong induction able to prove things that ordinary induction cannot?
- Yes, always
- No, they are equivalent in power
- Only for primes
- Only for infinite sets