How can you prove that a formula holds for every natural number, when you can only ever check finitely many cases? Mathematical induction is the answer, and it is the main proof tool in algorithm analysis: it proves sum formulas, recurrence solutions and the correctness of loops and recursive algorithms.
The idea
Intuition
Think of an endless row of dominoes. If (1) the first domino falls, and (2) whenever any domino falls it knocks over the next one, then every domino falls. Induction proves (1) and (2) for a statement about n n n , and concludes the statement for every n n n .
Definition 2.11 · Principle of mathematical induction
Let P ( n ) P(n) P ( n ) be a statement about an integer n n n . If
Base case: P ( n 0 ) P(n_0) P ( n 0 ) is true, and
Inductive step: for every integer k ≥ n 0 k \ge n_0 k ≥ n 0 , if P ( k ) P(k) P ( k ) is true then P ( k + 1 ) P(k+1) P ( k + 1 ) is true,
then P ( n ) P(n) P ( n ) is true for all integers n ≥ n 0 n \ge n_0 n ≥ n 0 . The assumption ”P ( k ) P(k) P ( k ) is true” inside step 2 is called the induction hypothesis .
Writing an induction proof
State P ( n ) P(n) P ( n ) clearly.
Base case. Check P ( n 0 ) P(n_0) P ( n 0 ) by direct calculation (usually n 0 = 1 n_0 = 1 n 0 = 1 or 0 0 0 ).
Induction hypothesis. “Assume P ( k ) P(k) P ( k ) is true for some arbitrary k ≥ n 0 k \ge n_0 k ≥ n 0 .” Write out what that means.
Inductive step. Using the hypothesis, prove P ( k + 1 ) P(k+1) P ( k + 1 ) . Usually: split the ( k + 1 ) (k+1) ( k + 1 ) case into “the k k k case” plus one extra term, replace the k k k case using the hypothesis, and simplify to the required form.
Conclusion. “By induction, P ( n ) P(n) P ( n ) holds for all n ≥ n 0 n \ge n_0 n ≥ n 0 .”
Correction · The induction hypothesis
Study material says: §2.4 describes the induction hypothesis as “the assumption that the statement is true for any value of n where n ≥ 1”.
Correct version: The hypothesis assumes the statement for one arbitrary but fixed value k k k (for example “assume P ( k ) P(k) P ( k ) for some k ≥ 1 k \ge 1 k ≥ 1 ”), and the inductive step uses it to prove P ( k + 1 ) P(k+1) P ( k + 1 ) . We never assume the statement for all values of n n n .
Why: Assuming P ( n ) P(n) P ( n ) for every n n n would be assuming what we want to prove (circular reasoning). Rosen (Discrete Mathematics , §5.1) states the inductive step as ”P ( k ) ⇒ P ( k + 1 ) P(k) \Rightarrow P(k+1) P ( k ) ⇒ P ( k + 1 ) for every k k k ”, with P ( k ) P(k) P ( k ) assumed only inside that implication.
Example 2.12 Sum of the first n positive integers
Goal. Prove P ( n ) P(n) P ( n ) : 1 + 2 + ⋯ + n = n ( n + 1 ) 2 1 + 2 + \dots + n = \dfrac{n(n+1)}{2} 1 + 2 + ⋯ + n = 2 n ( n + 1 ) for all n ≥ 1 n \ge 1 n ≥ 1 .
Base case (n = 1 n = 1 n = 1 ). Left side = 1 = 1 = 1 . Right side = 1 ⋅ 2 2 = 1 = \frac{1 \cdot 2}{2} = 1 = 2 1 ⋅ 2 = 1 . Equal, so P ( 1 ) P(1) P ( 1 ) is true.
Induction hypothesis. Assume for some k ≥ 1 k \ge 1 k ≥ 1 : 1 + 2 + ⋯ + k = k ( k + 1 ) 2 1 + 2 + \dots + k = \dfrac{k(k+1)}{2} 1 + 2 + ⋯ + k = 2 k ( k + 1 ) .
Inductive step. We must show 1 + ⋯ + k + ( k + 1 ) = ( k + 1 ) ( k + 2 ) 2 1 + \dots + k + (k+1) = \dfrac{(k+1)(k+2)}{2} 1 + ⋯ + k + ( k + 1 ) = 2 ( k + 1 ) ( k + 2 ) . Using the hypothesis,
1 + ⋯ + k + ( k + 1 ) = k ( k + 1 ) 2 + ( k + 1 ) = k ( k + 1 ) + 2 ( k + 1 ) 2 = ( k + 1 ) ( k + 2 ) 2 1 + \dots + k + (k+1) = \dfrac{k(k+1)}{2} + (k+1) = \dfrac{k(k+1) + 2(k+1)}{2} = \dfrac{(k+1)(k+2)}{2} 1 + ⋯ + k + ( k + 1 ) = 2 k ( k + 1 ) + ( k + 1 ) = 2 k ( k + 1 ) + 2 ( k + 1 ) = 2 ( k + 1 ) ( k + 2 ) .
Conclusion. P ( k ) ⇒ P ( k + 1 ) P(k) \Rightarrow P(k+1) P ( k ) ⇒ P ( k + 1 ) for every k ≥ 1 k \ge 1 k ≥ 1 , and P ( 1 ) P(1) P ( 1 ) holds, so P ( n ) P(n) P ( n ) holds for all n ≥ 1 n \ge 1 n ≥ 1 .
Result. ∑ i = 1 n i = n ( n + 1 ) 2 \sum_{i=1}^{n} i = \dfrac{n(n+1)}{2} ∑ i = 1 n i = 2 n ( n + 1 ) for every positive integer n n n .
Example 2.13 Sum of squares (Check Your Progress 1, Q1)
Goal. Prove 1 2 + 2 2 + ⋯ + n 2 = n ( n + 1 ) ( 2 n + 1 ) 6 1^2 + 2^2 + \dots + n^2 = \dfrac{n(n+1)(2n+1)}{6} 1 2 + 2 2 + ⋯ + n 2 = 6 n ( n + 1 ) ( 2 n + 1 ) for all n ≥ 1 n \ge 1 n ≥ 1 .
Base case (n = 1 n = 1 n = 1 ). Left = 1 = 1 = 1 ; right = 1 ⋅ 2 ⋅ 3 6 = 1 = \frac{1 \cdot 2 \cdot 3}{6} = 1 = 6 1 ⋅ 2 ⋅ 3 = 1 . True.
Induction hypothesis. Assume 1 2 + ⋯ + k 2 = k ( k + 1 ) ( 2 k + 1 ) 6 1^2 + \dots + k^2 = \dfrac{k(k+1)(2k+1)}{6} 1 2 + ⋯ + k 2 = 6 k ( k + 1 ) ( 2 k + 1 ) for some k ≥ 1 k \ge 1 k ≥ 1 .
Inductive step. 1 2 + ⋯ + k 2 + ( k + 1 ) 2 = k ( k + 1 ) ( 2 k + 1 ) 6 + ( k + 1 ) 2 = ( k + 1 ) [ k ( 2 k + 1 ) + 6 ( k + 1 ) ] 6 = ( k + 1 ) ( 2 k 2 + 7 k + 6 ) 6 1^2 + \dots + k^2 + (k+1)^2 = \dfrac{k(k+1)(2k+1)}{6} + (k+1)^2 = \dfrac{(k+1)\left[k(2k+1) + 6(k+1)\right]}{6} = \dfrac{(k+1)(2k^2 + 7k + 6)}{6} 1 2 + ⋯ + k 2 + ( k + 1 ) 2 = 6 k ( k + 1 ) ( 2 k + 1 ) + ( k + 1 ) 2 = 6 ( k + 1 ) [ k ( 2 k + 1 ) + 6 ( k + 1 ) ] = 6 ( k + 1 ) ( 2 k 2 + 7 k + 6 ) .
Factorise. 2 k 2 + 7 k + 6 = ( k + 2 ) ( 2 k + 3 ) 2k^2 + 7k + 6 = (k+2)(2k+3) 2 k 2 + 7 k + 6 = ( k + 2 ) ( 2 k + 3 ) , so the sum is ( k + 1 ) ( k + 2 ) ( 2 k + 3 ) 6 = ( k + 1 ) ( ( k + 1 ) + 1 ) ( 2 ( k + 1 ) + 1 ) 6 \dfrac{(k+1)(k+2)(2k+3)}{6} = \dfrac{(k+1)\big((k+1)+1\big)\big(2(k+1)+1\big)}{6} 6 ( k + 1 ) ( k + 2 ) ( 2 k + 3 ) = 6 ( k + 1 ) ( ( k + 1 ) + 1 ) ( 2 ( k + 1 ) + 1 ) , which is the formula for n = k + 1 n = k+1 n = k + 1 .
Result. By induction, ∑ i = 1 n i 2 = n ( n + 1 ) ( 2 n + 1 ) 6 \sum_{i=1}^{n} i^2 = \dfrac{n(n+1)(2n+1)}{6} ∑ i = 1 n i 2 = 6 n ( n + 1 ) ( 2 n + 1 ) for all n ≥ 1 n \ge 1 n ≥ 1 .
Example 2.14 Geometric sum (Check Your Progress 1, Q2)
Goal. Prove 2 0 + 2 1 + ⋯ + 2 n = 2 n + 1 − 1 2^0 + 2^1 + \dots + 2^n = 2^{n+1} - 1 2 0 + 2 1 + ⋯ + 2 n = 2 n + 1 − 1 for all integers n ≥ 0 n \ge 0 n ≥ 0 .
Base case (n = 0 n = 0 n = 0 ). Left = 2 0 = 1 = 2^0 = 1 = 2 0 = 1 ; right = 2 1 − 1 = 1 = 2^1 - 1 = 1 = 2 1 − 1 = 1 . True.
Induction hypothesis. Assume 2 0 + ⋯ + 2 k = 2 k + 1 − 1 2^0 + \dots + 2^k = 2^{k+1} - 1 2 0 + ⋯ + 2 k = 2 k + 1 − 1 for some k ≥ 0 k \ge 0 k ≥ 0 .
Inductive step. 2 0 + ⋯ + 2 k + 2 k + 1 = ( 2 k + 1 − 1 ) + 2 k + 1 = 2 ⋅ 2 k + 1 − 1 = 2 k + 2 − 1 2^0 + \dots + 2^k + 2^{k+1} = (2^{k+1} - 1) + 2^{k+1} = 2 \cdot 2^{k+1} - 1 = 2^{k+2} - 1 2 0 + ⋯ + 2 k + 2 k + 1 = ( 2 k + 1 − 1 ) + 2 k + 1 = 2 ⋅ 2 k + 1 − 1 = 2 k + 2 − 1 , which is the formula for n = k + 1 n = k+1 n = k + 1 .
Result. ∑ i = 0 n 2 i = 2 n + 1 − 1 \sum_{i=0}^{n} 2^i = 2^{n+1} - 1 ∑ i = 0 n 2 i = 2 n + 1 − 1 for all n ≥ 0 n \ge 0 n ≥ 0 .
Induction and algorithms
Induction is how we prove algorithms correct. For a loop, we prove a loop invariant — a statement true before every iteration — by induction on the number of iterations. For a recursive algorithm, we assume the recursive calls on smaller inputs are correct (the hypothesis) and show the current call is correct. For example, factorial(n) returns n ⋅ n \cdot n ⋅ factorial(n − 1 n-1 n − 1 ); if factorial(n − 1 n-1 n − 1 ) correctly returns ( n − 1 ) ! (n-1)! ( n − 1 )! , then factorial(n) returns n ⋅ ( n − 1 ) ! = n ! n \cdot (n-1)! = n! n ⋅ ( n − 1 )! = n ! .
Key idea
Induction proves P ( n ) P(n) P ( n ) for all n n n by proving a base case and the implication P ( k ) ⇒ P ( k + 1 ) P(k) \Rightarrow P(k+1) P ( k ) ⇒ P ( k + 1 ) for an arbitrary k k k ; the inductive step must actually use the hypothesis.
Common mistake
Skipping the base case. The step "P ( k ) ⇒ P ( k + 1 ) P(k) \Rightarrow P(k+1) P ( k ) ⇒ P ( k + 1 ) " alone can be true for a false statement: for "n = n + 1 n = n + 1 n = n + 1 ", if k = k + 1 k = k + 1 k = k + 1 then k + 1 = k + 2 k + 1 = k + 2 k + 1 = k + 2 — but the statement is false for every n n n .
Common mistake
Proving P ( k + 1 ) P(k+1) P ( k + 1 ) by starting from the formula for k + 1 k+1 k + 1 and “simplifying both sides” until they match. Start from the left side of P ( k + 1 ) P(k+1) P ( k + 1 ) , split off the last term, and use the hypothesis.
Note
Strong induction assumes P ( n 0 ) , … , P ( k ) P(n_0), \dots, P(k) P ( n 0 ) , … , P ( k ) all hold and proves P ( k + 1 ) P(k+1) P ( k + 1 ) . It is convenient for recurrences such as T ( n ) = 2 T ( n / 2 ) + n T(n) = 2T(n/2) + n T ( n ) = 2 T ( n /2 ) + n , where n / 2 n/2 n /2 is not n − 1 n-1 n − 1 .
TEE Exam note
Induction proofs earn marks for each of the three labelled parts. Write the headings Base case , Induction hypothesis , Inductive step and Conclusion ; in the step, show clearly where the hypothesis is substituted. Check Your Progress 1 (sum of squares, sum of powers of 2) are typical 5–6 mark questions.
Key takeaways
Induction = base case + inductive step P ( k ) ⇒ P ( k + 1 ) P(k) \Rightarrow P(k+1) P ( k ) ⇒ P ( k + 1 ) for arbitrary k k k .
The hypothesis assumes P ( k ) P(k) P ( k ) for one arbitrary k k k , not for all n n n .
Standard results: ∑ i = n ( n + 1 ) 2 \sum i = \frac{n(n+1)}{2} ∑ i = 2 n ( n + 1 ) , ∑ i 2 = n ( n + 1 ) ( 2 n + 1 ) 6 \sum i^2 = \frac{n(n+1)(2n+1)}{6} ∑ i 2 = 6 n ( n + 1 ) ( 2 n + 1 ) , ∑ i = 0 n 2 i = 2 n + 1 − 1 \sum_{i=0}^{n} 2^i = 2^{n+1} - 1 ∑ i = 0 n 2 i = 2 n + 1 − 1 .
Induction proves loop invariants and the correctness of recursive algorithms.
Practice questions Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 1 · multiple choice In an induction proof starting at n = 1 n = 1 n = 1 , which step proves the statement for n = 1 n = 1 n = 1 ?
A The base case B The induction hypothesis C The inductive step D The conclusion
Check answer
Show answer Answer: A. The base case
The base case checks the first value directly. The hypothesis is an assumption, not a proof of anything.
Question 2 · multiple choice What does the induction hypothesis assume?
Check answer
Show answer Answer: C. P ( k ) P(k) P ( k ) is true for some arbitrary k ≥ n 0 k \ge n_0 k ≥ n 0 .
We assume the statement for one arbitrary k and prove it for k + 1. Assuming it for all n would be circular.
Question 3 · multiple choice In the inductive step for ∑ i = 1 n i = n ( n + 1 ) 2 \sum_{i=1}^{n} i = \frac{n(n+1)}{2} ∑ i = 1 n i = 2 n ( n + 1 ) , what is k ( k + 1 ) 2 + ( k + 1 ) \frac{k(k+1)}{2} + (k+1) 2 k ( k + 1 ) + ( k + 1 ) equal to?
Check answer
Show answer Answer: C. ( k + 1 ) ( k + 2 ) 2 \frac{(k+1)(k+2)}{2} 2 ( k + 1 ) ( k + 2 )
Put both over 2: [k(k+1) + 2(k+1)]/2 = (k+1)(k+2)/2.
Question 4 · multiple choice A “proof” shows P ( k ) ⇒ P ( k + 1 ) P(k) \Rightarrow P(k+1) P ( k ) ⇒ P ( k + 1 ) for all k k k but never checks a base case. What can we conclude?
Check answer
Show answer Answer: C. Nothing: without a base case the statement may be false for every n n n .
The chain of implications needs a first true domino. “n = n + 1” satisfies the step but is never true.
Question 5 · multiple choice Check ∑ i = 0 n 2 i = 2 n + 1 − 1 \sum_{i=0}^{n} 2^i = 2^{n+1} - 1 ∑ i = 0 n 2 i = 2 n + 1 − 1 for n = 4 n = 4 n = 4 .
Check answer
Show answer Answer: B. 31 = 31 31 = 31 31 = 31
1 + 2 + 4 + 8 + 16 = 31 and 2⁵ − 1 = 31. 15 = 2⁴ − 1 is the value for n = 3.
Question 6 · short answer
Prove by induction that 1 + 3 + 5 + ⋯ + ( 2 n − 1 ) = n 2 1 + 3 + 5 + \dots + (2n - 1) = n^2 1 + 3 + 5 + ⋯ + ( 2 n − 1 ) = n 2 for all n ≥ 1 n \ge 1 n ≥ 1 .
Show worked answer Base case (n = 1): left = 1, right = 1² = 1, true. Induction hypothesis: assume 1 + 3 + … + (2k − 1) = k² for some k ≥ 1. Inductive step: 1 + 3 + … + (2k − 1) + (2(k + 1) − 1) = k² + (2k + 1) = (k + 1)², which is the statement for n = k + 1. Conclusion: by induction, the sum of the first n odd numbers is n² for all n ≥ 1.