taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Volume P1 · Proof, induction and invariants

Mathematical induction

Draft. This chapter is written and checked by the tools of the project, and a person has not reviewed it yet. Read it with care.

Read first
Contents
  1. The principle of induction
  2. Stronger claims and recurrences
  3. Induction on other quantities

The principle of induction

Statement

The natural numbers are 0,1,2,…0, 1, 2, \dots, and every natural number is reached from 00 by adding 11 some number of times. Induction uses this fact. A property that holds for 00 and passes from each number to the next holds for all of them.

Theorem P1.4.1 (the principle of induction). Let P(n)P(n) be a statement about the natural number nn. If P(0)P(0) is true, and for every natural number kk the statement P(k)→P(k+1)P(k) \to P(k + 1) is true, then P(n)P(n) is true for every natural number nn.

Lean: Nat.rec is the principle, the tactic induction n with | zero => ... | succ k ih => ... is the way to use it, and Nat.le_induction is the form with a base aa (Lean core and Mathlib).

The principle is an axiom of the natural numbers in most treatments (the axiom of Peano), and Chapter 5 shows that it is equivalent to the well-ordering principle. A proof by induction has three parts.

  1. The statement: say what P(n)P(n) is, in a sentence that does not use the proof.
  2. The base case: prove P(0)P(0), or P(a)P(a) for the first number aa of the claim.
  3. The step: let kk be a natural number (with k≥ak \ge a) and assume P(k)P(k), the induction hypothesis. Prove P(k+1)P(k + 1).

Definition P1.4.2 (the form with a base aa). If P(a)P(a) is true, and P(k)→P(k+1)P(k) \to P(k + 1) for every k≥ak \ge a, then P(n)P(n) is true for every n≥an \ge a. The form with base aa follows from the form with base 00 applied to the statement Q(m)=P(a+m)Q(m) = P(a + m).

Example P1.4.3 (the odd numbers). Claim: for n≥1n \ge 1, 1+3+5+⋯+(2n−1)=n21 + 3 + 5 + \cdots + (2n - 1) = n^2. Base: for n=1n = 1 both sides equal 11. Step: assume 1+3+⋯+(2k−1)=k21 + 3 + \cdots + (2k - 1) = k^2. Then 1+3+⋯+(2k−1)+(2k+1)=k2+2k+1=(k+1)21 + 3 + \cdots + (2k - 1) + (2k + 1) = k^2 + 2k + 1 = (k + 1)^2. This is the claim for k+1k + 1. For n=10n = 10 the sum is 100100.

Example P1.4.4 (the sum of the first nn numbers). Claim: for n≥0n \ge 0, 0+1+2+⋯+n=n(n+1)/20 + 1 + 2 + \cdots + n = n(n + 1)/2. Base: for n=0n = 0 both sides are 00. Step: assume the formula for kk. Then the sum up to k+1k + 1 is k(k+1)/2+(k+1)=(k+1)(k+2)/2k(k + 1)/2 + (k + 1) = (k + 1)(k + 2)/2, which is the formula for k+1k + 1.

Lean: Finset.sum_range_succ is the lemma that peels the last term of a sum over Finset.range; with induction n and simp [Finset.sum_range_succ] it is the usual route to such a formula.

Example P1.4.5 (the geometric sum). Claim: for n≥0n \ge 0 and r≠1r \ne 1, 1+r+r2+⋯+rn=(rn+1−1)/(r−1)1 + r + r^2 + \cdots + r^n = (r^{n+1} - 1)/(r - 1). Base: n=0n = 0 gives 1=(r−1)/(r−1)1 = (r - 1)/(r - 1). Step: the sum up to k+1k + 1 is (rk+1−1)/(r−1)+rk+1=(rk+1−1+rk+2−rk+1)/(r−1)=(rk+2−1)/(r−1)(r^{k+1} - 1)/(r - 1) + r^{k+1} = (r^{k+1} - 1 + r^{k+2} - r^{k+1})/(r - 1) = (r^{k+2} - 1)/(r - 1). For r=2r = 2 and n=9n = 9 the sum is 1023=210−11023 = 2^{10} - 1.

Example P1.4.6 (a divisibility). Claim: for n≥1n \ge 1, 3∣4n−13 \mid 4^n - 1. Base: 4−1=34 - 1 = 3. Step: if 4k−1=3m4^k - 1 = 3m, then 4k+1−1=4⋅4k−1=4(3m+1)−1=12m+3=3(4m+1)4^{k+1} - 1 = 4 \cdot 4^k - 1 = 4(3m + 1) - 1 = 12m + 3 = 3(4m + 1).

Example P1.4.7 (an inequality with a base other than 00). Claim: for n≥5n \ge 5, 2n>n22^n > n^2. Base: 32>2532 > 25. Step: assume 2k>k22^k > k^2 with k≥5k \ge 5. Then 2k+1>2k22^{k+1} > 2k^2, and 2k2≥(k+1)22k^2 \ge (k + 1)^2 since k2≥2k+1k^2 \ge 2k + 1 for k≥3k \ge 3. So 2k+1>(k+1)22^{k+1} > (k + 1)^2. The claim is false for n=2,3,4n = 2, 3, 4 (where 4=44 = 4, 8<98 < 9, 16=1616 = 16), so the base cannot be moved down to 22, and the inequality is true again for n=1n = 1 and n=0n = 0.

Example P1.4.8 (Bernoulli's inequality). Claim: for a real x≥−1x \ge -1 and n≥0n \ge 0, (1+x)n≥1+nx(1 + x)^n \ge 1 + nx. Base: 1≥11 \ge 1. Step: (1+x)k+1=(1+x)(1+x)k≥(1+x)(1+kx)=1+(k+1)x+kx2≥1+(k+1)x(1 + x)^{k+1} = (1 + x)(1 + x)^k \ge (1 + x)(1 + kx) = 1 + (k + 1)x + kx^2 \ge 1 + (k + 1)x. The first inequality multiplies the hypothesis by 1+x≥01 + x \ge 0.

Proof

Proof of the principle from the definition of ℕ\mathbb N. Suppose P(0)P(0) and all P(k)→P(k+1)P(k) \to P(k + 1) hold, and suppose P(n)P(n) fails for some nn. The proof is by the well-ordering principle of Chapter 5: let mm be the least nn with P(n)P(n) false. Then m≠0m \ne 0, so m=k+1m = k + 1 for a natural number kk, and P(k)P(k) is true since k<mk < m. The step gives P(k+1)=P(m)P(k + 1) = P(m), a contradiction. □\square

This proof uses the well-ordering principle, so it is not a proof from nothing. In a development from the axioms, one of the two is an axiom. Both are true, and each follows from the other (Chapter 5, Section 2).

The step of an induction is an implication, and the proof of an implication assumes the hypothesis. The induction hypothesis P(k)P(k) is assumed, not proved, in the step. This is not a circle: the proof of the step is valid for the general kk, and the base case makes it a chain, as a row of dominoes falls when the first one is pushed and each one pushes the next.

Examples

Example P1.4.9 (sum of cubes). Claim: 13+23+⋯+n3=(n(n+1)/2)21^3 + 2^3 + \cdots + n^3 = (n(n + 1)/2)^2 for n≥1n \ge 1. Base: 1=11 = 1. Step: the sum up to k+1k + 1 is (k(k+1)/2)2+(k+1)3=(k+1)2(k2/4+k+1)=(k+1)2(k+2)2/4(k(k + 1)/2)^2 + (k + 1)^3 = (k + 1)^2 (k^2/4 + k + 1) = (k + 1)^2 (k + 2)^2 / 4. The sum of the first nn cubes is the square of the sum of the first nn numbers. For n=3n = 3: 1+8+27=36=621 + 8 + 27 = 36 = 6^2.

Example P1.4.10 (a divisibility by cases of the step). Claim: for n≥1n \ge 1, n3+2nn^3 + 2n is divisible by 33. Base: 33. Step: (k+1)3+2(k+1)=k3+2k+3k2+3k+3(k + 1)^3 + 2(k + 1) = k^3 + 2k + 3k^2 + 3k + 3, which is the sum of the number k3+2kk^3 + 2k and the multiple 3(k2+k+1)3(k^2 + k + 1) of 33. A check of n=1,…,29n = 1, \dots, 29 by a computer finds no failure.

Example P1.4.11 (a recurrence). Let a0=0a_0 = 0 and an+1=2an+1a_{n+1} = 2a_n + 1. Then an=2n−1a_n = 2^n - 1. Base: a0=0=20−1a_0 = 0 = 2^0 - 1. Step: ak+1=2(2k−1)+1=2k+1−1a_{k+1} = 2(2^k - 1) + 1 = 2^{k+1} - 1. The sequence begins 0,1,3,7,15,310, 1, 3, 7, 15, 31.

Pitfalls

An induction proof can fail in four places, and each gives a false proof of a false claim or an incomplete proof of a true one.

A missing base case. Let P(n)P(n) be "n2+n+1n^2 + n + 1 is even". The step is true: (k+1)2+(k+1)+1=(k2+k+1)+2(k+1)(k + 1)^2 + (k + 1) + 1 = (k^2 + k + 1) + 2(k + 1) is even if k2+k+1k^2 + k + 1 is. But P(0)P(0) is false, since 11 is odd, and the claim is false for every nn, since n2+nn^2 + n is even and n2+n+1n^2 + n + 1 is odd. The step alone proves nothing.

A step that fails at the first value. The claim "all horses have the same color" of Chapter 3 has a step that fails from n=1n = 1 to n=2n = 2. The step must hold for every k≥ak \ge a, including the smallest.

A hypothesis that is used for the wrong kk. The step may use P(k)P(k) and not P(k+1)P(k + 1). A proof of P(k+1)P(k + 1) that uses P(k+1)P(k + 1) is a circle.

A claim with an unbound variable. In "n2+nn^2 + n is even for n≥0n \ge 0", the statement P(n)P(n) is about one nn. A claim with two variables, such as "m+n=n+mm + n = n + m for all mm and nn", needs a decision: the induction runs over one of them, and the other is held fixed.

Exercises

  1. [10] Prove by induction that 1+2+⋯+n=n(n+1)/21 + 2 + \cdots + n = n(n + 1)/2 for n≥1n \ge 1, and use it to find 1+2+⋯+1001 + 2 + \cdots + 100.
  2. [10] Prove that 2+4+⋯+2n=n(n+1)2 + 4 + \cdots + 2n = n(n + 1) for n≥1n \ge 1.
  3. [12] Prove that 3∣4n−13 \mid 4^n - 1 for n≥0n \ge 0 and that 5∣6n−15 \mid 6^n - 1 for n≥0n \ge 0.
  4. [12] Prove that 1+2+4+⋯+2n=2n+1−11 + 2 + 4 + \cdots + 2^n = 2^{n+1} - 1 for n≥0n \ge 0, and use it to find the number of nodes in a complete binary tree with 1010 levels (levels 00 to 99).
  5. [14] Prove that 2n≥n+12^n \ge n + 1 for n≥0n \ge 0, and that n!≥2n−1n! \ge 2^{n-1} for n≥1n \ge 1.
  6. [15] Prove that ∑k=1nk⋅2k=(n−1)2n+1+2\sum_{k=1}^n k \cdot 2^k = (n - 1)2^{n+1} + 2 for n≥1n \ge 1.
  7. [M18] Prove that ∑k=1nk(k+1)=n(n+1)(n+2)/3\sum_{k=1}^n k(k + 1) = n(n + 1)(n + 2)/3 for n≥1n \ge 1.
  8. [M20] Prove that 7∣8n−17 \mid 8^n - 1 for n≥0n \ge 0 and that 6∣n3−n6 \mid n^3 - n for n≥0n \ge 0 by induction on nn.
  9. [M20] Prove Bernoulli's inequality (1+x)n≥1+nx(1 + x)^n \ge 1 + nx for real x≥−1x \ge -1 and n≥0n \ge 0, and show that the condition x≥−1x \ge -1 cannot be dropped.
  10. [M24] Find the error in this proof of "3n<2n+103^n < 2^n + 10 for all n≥0n \ge 0": base 30=1<113^0 = 1 < 11; step 3k+1=3⋅3k<3(2k+10)=3⋅2k+303^{k+1} = 3 \cdot 3^k < 3(2^k + 10) = 3 \cdot 2^k + 30, "which is less than 2k+1+102^{k+1} + 10". Find the first nn for which the claim fails.

Lean

The tactic induction n with | zero => _ | succ k ih => _ gives the base goal and the step goal with the hypothesis ih. For a base other than 00, Nat.le_induction gives goals for n = a and for n + 1 with a ≤ n. A sum over Finset.range n obeys Finset.sum_range_succ, which splits off the last term, and simp [Finset.sum_range_succ] followed by ring closes many formulas of this section.

Notes and history

The method is old: it has forms in Pascal's treatise of 1654 on the arithmetic triangle, and in the work of Fermat on the method of descent, and the name mathematical induction is due to De Morgan in the nineteenth century. The axioms of Peano of 1889 take the principle as one of the axioms. TAOCP Section 1.2.1 states the principle and uses it for the first formulas of that section; the step from the formula to its proof is the part this chapter trains, and the next section shows what to do when the formula must first be found.

Stronger claims and recurrences

Statement

The step of an induction must prove P(k+1)P(k + 1) from P(k)P(k) alone. Sometimes P(k)P(k) says too little for this, and the claim cannot be proved as it stands. A remedy that seems wrong at first is to prove more: a stronger claim Q(n)Q(n) with Q(n)→P(n)Q(n) \to P(n) has a stronger hypothesis in the step, and the step may then go through.

Definition P1.4.12 (a stronger claim). A statement Q(n)Q(n) is stronger than P(n)P(n) if Q(n)→P(n)Q(n) \to P(n) for every nn. A proof of Q(n)Q(n) for all nn proves P(n)P(n) for all nn.

Example (the sum of 1/(k(k+1))1/(k(k+1))). Claim P(n)P(n): ∑k=1n1k(k+1)<1\sum_{k=1}^n \frac{1}{k(k+1)} < 1. A step from P(k)P(k) to P(k+1)P(k + 1) would need ∑j=1k+1<1\sum_{j=1}^{k+1} < 1 from ∑j=1k<1\sum_{j=1}^{k} < 1, and the last term 1/((k+1)(k+2))1/((k+1)(k+2)) may take the sum over 11 for all that the hypothesis says. The stronger claim Q(n)Q(n): the sum equals 1−1/(n+1)1 - 1/(n + 1). Base: 1/2=1−1/21/2 = 1 - 1/2. Step: the sum up to k+1k + 1 is 1−1/(k+1)+1/((k+1)(k+2))=1−(k+2−1)/((k+1)(k+2))=1−1/(k+2)1 - 1/(k + 1) + 1/((k + 1)(k + 2)) = 1 - (k + 2 - 1)/((k + 1)(k + 2)) = 1 - 1/(k + 2). Then Q(n)Q(n) gives P(n)P(n), since 1−1/(n+1)<11 - 1/(n + 1) < 1.

Example P1.4.13 (the sum of 1/k21/k^2). Claim P(n)P(n): ∑k=1n1/k2<2\sum_{k=1}^n 1/k^2 < 2. The stronger claim Q(n)Q(n): the sum is at most 2−1/n2 - 1/n. Base: 1≤2−1=11 \le 2 - 1 = 1. Step: ∑j=1k+1≤2−1/k+1/(k+1)2≤2−1/k+1/(k(k+1))=2−1/(k+1)\sum_{j=1}^{k+1} \le 2 - 1/k + 1/(k + 1)^2 \le 2 - 1/k + 1/(k(k + 1)) = 2 - 1/(k + 1), since 1/(k(k+1))=1/k−1/(k+1)1/(k(k+1)) = 1/k - 1/(k + 1). For n=10n = 10 the sum is about 1.54981.5498, below 2−1/10=1.92 - 1/10 = 1.9.

The two examples show a rule of thumb. The hypothesis must carry exactly the information that the step needs, and it is often a statement of how much below the bound the sum is. The right QQ is found by examining what the step lacks, or by computing the first values and guessing the formula.

Definition P1.4.14 (the Fibonacci numbers). The Fibonacci numbers are F0=0F_0 = 0, F1=1F_1 = 1 and Fn+2=Fn+1+FnF_{n+2} = F_{n+1} + F_n for n≥0n \ge 0. The first values are 0,1,1,2,3,5,8,13,21,34,55,89,1440, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.

Lean: Nat.fib with Nat.fib_add_two : fib (n + 2) = fib n + fib (n + 1) (Mathlib).

Definition P1.4.15 (induction with two base cases). If a statement P(n+2)P(n + 2) is derived from P(n)P(n) and P(n+1)P(n + 1), the proof needs the base cases P(0)P(0) and P(1)P(1), and the step: let k≥0k \ge 0, assume P(k)P(k) and P(k+1)P(k + 1), and prove P(k+2)P(k + 2). This is the principle of induction applied to the statement Q(n)=P(n)∧P(n+1)Q(n) = P(n) \wedge P(n + 1).

Example P1.4.16 (a bound for FnF_n). Claim: Fn<2nF_n < 2^n for n≥0n \ge 0. Base cases: F0=0<1F_0 = 0 < 1 and F1=1<2F_1 = 1 < 2. Step: Fk+2=Fk+1+Fk<2k+1+2k<2k+1+2k+1=2k+2F_{k+2} = F_{k+1} + F_k < 2^{k+1} + 2^k < 2^{k+1} + 2^{k+1} = 2^{k+2}. For n=30n = 30: F30=832040F_{30} = 832040, much smaller than 2302^{30}. A better bound is next.

Theorem P1.4.17 (bounds for FnF_n). Let φ=(1+5)/2\varphi = (1 + \sqrt 5)/2, so that φ2=φ+1\varphi^2 = \varphi + 1. Then φn−2≤Fn≤φn−1\varphi^{n-2} \le F_n \le \varphi^{n-1} for n≥1n \ge 1.

Lean: the proof is a statement about Nat.fib and real powers; the key step is the identity φ2=φ+1\varphi^2 = \varphi + 1, which nlinarith or ring_nf reaches after Real.sq_sqrt.

Proof. Base cases n=1n = 1 and n=2n = 2: φ−1≤1≤φ0\varphi^{-1} \le 1 \le \varphi^0, and φ0=1≤F2=1≤φ1\varphi^0 = 1 \le F_2 = 1 \le \varphi^1, true since φ≈1.618\varphi \approx 1.618. Step: let k≥1k \ge 1 and assume both bounds for kk and for k+1k + 1. Then Fk+2=Fk+1+Fk≤φk+φk−1=φk−1(φ+1)=φk−1φ2=φk+1F_{k+2} = F_{k+1} + F_k \le \varphi^k + \varphi^{k-1} = \varphi^{k-1}(\varphi + 1) = \varphi^{k-1} \varphi^2 = \varphi^{k+1}. The lower bound is the same with the inequalities reversed: Fk+2≥φk−1+φk−2=φk−2(φ+1)=φkF_{k+2} \ge \varphi^{k-1} + \varphi^{k-2} = \varphi^{k-2}(\varphi + 1) = \varphi^k. □\square

A two-step recurrence usually needs this double hypothesis. A proof that assumes only P(k+1)P(k + 1) in the step has no information about FkF_k and fails.

Example P1.4.18 (a sum of Fibonacci numbers). Claim: F1+F2+⋯+Fn=Fn+2−1F_1 + F_2 + \cdots + F_n = F_{n+2} - 1 for n≥1n \ge 1. Base: 1=F3−1=2−11 = F_3 - 1 = 2 - 1. Step: the sum up to k+1k + 1 is Fk+2−1+Fk+1=Fk+3−1F_{k+2} - 1 + F_{k+1} = F_{k+3} - 1. For n=10n = 10 the sum is 143=F12−1143 = F_{12} - 1.

Example P1.4.19 (a sum of squares). Claim: F12+⋯+Fn2=FnFn+1F_1^2 + \cdots + F_n^2 = F_n F_{n+1} for n≥1n \ge 1. Base: 1=F1F21 = F_1 F_2. Step: FkFk+1+Fk+12=Fk+1(Fk+Fk+1)=Fk+1Fk+2F_k F_{k+1} + F_{k+1}^2 = F_{k+1}(F_k + F_{k+1}) = F_{k+1} F_{k+2}.

Theorem P1.4.20 (a formula for a recurrence). Let a0=0a_0 = 0, a1=1a_1 = 1, and an+2=3an+1−2ana_{n+2} = 3a_{n+1} - 2a_n. Then an=2n−1a_n = 2^n - 1 for n≥0n \ge 0.

Proof. Base: a0=0=20−1a_0 = 0 = 2^0 - 1 and a1=1=21−1a_1 = 1 = 2^1 - 1. Step: assume ak=2k−1a_k = 2^k - 1 and ak+1=2k+1−1a_{k+1} = 2^{k+1} - 1. Then ak+2=3(2k+1−1)−2(2k−1)=6⋅2k−3−2⋅2k+2=4⋅2k−1=2k+2−1a_{k+2} = 3(2^{k+1} - 1) - 2(2^k - 1) = 6 \cdot 2^k - 3 - 2 \cdot 2^k + 2 = 4 \cdot 2^k - 1 = 2^{k+2} - 1. □\square

Proof

To use a stronger claim, follow these steps. First, write the step as a table: what is known (the hypothesis) and what is to be shown. Second, find what is missing: an inequality with a gap that is lost in the step, or a value of an expression that is not determined. Third, add this to the claim, and prove the new claim from the start with its own base case. The new base case may be harder, and the new step is easier.

The stronger claim often holds for a whole family of quantities, such as the three values F3nF_{3n}, F3n+1F_{3n+1} and F3n+2F_{3n+2} in the last example below, and gives the step the information that it needs.

Examples

Example P1.4.21 (a closed form found by computation). Let b0=1b_0 = 1, b1=3b_1 = 3, bn+2=bn+1+2bnb_{n+2} = b_{n+1} + 2b_n. The values are 1,3,5,11,21,43,85,1711, 3, 5, 11, 21, 43, 85, 171. They are close to 2n+2/32^{n+2}/3: the guess is bn=(2n+2−(−1)n)/3b_n = (2^{n+2} - (-1)^n)/3. Base: b0=(4−1)/3=1b_0 = (4 - 1)/3 = 1 and b1=(8+1)/3=3b_1 = (8 + 1)/3 = 3. Step: bk+2=(2k+3−(−1)k+1+2⋅2k+2−2(−1)k)/3=(2k+3+2k+3+(−1)k−2(−1)k)/3=(2k+4−(−1)k)/3b_{k+2} = (2^{k+3} - (-1)^{k+1} + 2 \cdot 2^{k+2} - 2(-1)^k)/3 = (2^{k+3} + 2^{k+3} + (-1)^k - 2(-1)^k)/3 = (2^{k+4} - (-1)^k)/3, and (−1)k+2=(−1)k(-1)^{k+2} = (-1)^k, so this is the guess for k+2k + 2. A computer check of the first twenty values agrees.

Example P1.4.22 (the identity of Cassini). Claim: Fn+1Fn−1−Fn2=(−1)nF_{n+1} F_{n-1} - F_n^2 = (-1)^n for n≥1n \ge 1. Base: F2F0−F12=−1F_2 F_0 - F_1^2 = -1. Step: Fk+2Fk−Fk+12=(Fk+1+Fk)Fk−Fk+1(Fk+Fk−1)=Fk2−Fk+1Fk−1=−(−1)k=(−1)k+1F_{k+2} F_k - F_{k+1}^2 = (F_{k+1} + F_k) F_k - F_{k+1}(F_k + F_{k-1}) = F_k^2 - F_{k+1} F_{k-1} = -(-1)^k = (-1)^{k+1}. For n=5n = 5: F6F4−F52=8⋅3−25=−1F_6 F_4 - F_5^2 = 8 \cdot 3 - 25 = -1.

Example P1.4.23 (every third Fibonacci number is even). Claim: F3nF_{3n} is even for n≥0n \ge 0. The recurrence relates F3n+3F_{3n+3} to F3n+2F_{3n+2} and F3n+1F_{3n+1}, not to F3nF_{3n}, so the hypothesis "F3nF_{3n} is even" alone does not give the step. The stronger claim Q(n)Q(n): F3nF_{3n} is even, and F3n+1F_{3n+1} and F3n+2F_{3n+2} are odd. Base: 0,1,10, 1, 1. Step: F3n+3=F3n+2+F3n+1F_{3n+3} = F_{3n+2} + F_{3n+1} is odd plus odd, so even; F3n+4=F3n+3+F3n+2F_{3n+4} = F_{3n+3} + F_{3n+2} is even plus odd, so odd; F3n+5=F3n+4+F3n+3F_{3n+5} = F_{3n+4} + F_{3n+3} is odd plus even, so odd. The values F0,F3,…,F12F_0, F_3, \dots, F_{12} are 0,2,8,34,1440, 2, 8, 34, 144.

Exercises

  1. [10] Compute F13F_{13} and F14F_{14}, and check F13F15−F142F_{13} F_{15} - F_{14}^2 against Cassini's identity.
  2. [12] Prove that ∑k=1n1/(k(k+1))=1−1/(n+1)\sum_{k=1}^n 1/(k(k+1)) = 1 - 1/(n+1) for n≥1n \ge 1, and find the value for n=99n = 99.
  3. [14] Prove that ∑k=1nk2=n(n+1)(2n+1)/6\sum_{k=1}^n k^2 = n(n + 1)(2n + 1)/6 for n≥1n \ge 1.
  4. [14] Prove that F1+F3+⋯+F2n−1=F2nF_1 + F_3 + \cdots + F_{2n-1} = F_{2n} for n≥1n \ge 1.
  5. [15] Prove the sharper bound Fn≤(5/3)n−1F_n \le (5/3)^{n-1} for n≥1n \ge 1.
  6. [M18] Let a0=2a_0 = 2, a1=3a_1 = 3 and an+2=3an+1−2ana_{n+2} = 3a_{n+1} - 2a_n. Find ana_n by computing four values and guessing, then prove it.
  7. [M20] Prove Cassini's identity Fn+1Fn−1−Fn2=(−1)nF_{n+1} F_{n-1} - F_n^2 = (-1)^n for n≥1n \ge 1, and use it to show that consecutive Fibonacci numbers have no common divisor larger than 11.
  8. [M20] Prove that Fm+n=FmFn+1+Fm−1FnF_{m+n} = F_m F_{n+1} + F_{m-1} F_n for m≥1m \ge 1 and n≥0n \ge 0, by induction on nn.
  9. [M22] Prove that ∑k=1n1/k2≤2−1/n\sum_{k=1}^n 1/k^2 \le 2 - 1/n for n≥1n \ge 1, and explain why the claim "the sum is less than 22" cannot be proved by induction as it stands.
  10. [M25] Prove that F3nF_{3n} is even for n≥0n \ge 0 with a stronger claim. Prove that Fn+4=3Fn+1+2FnF_{n+4} = 3F_{n+1} + 2F_n, and use it to show that 3∣F4n3 \mid F_{4n} for n≥0n \ge 0.

Lean

Nat.fib is the function, Nat.fib_add_two is the recurrence, and Nat.fib_pos gives positivity. A proof of a statement about Nat.fib by two-step induction can use Nat.twoStepInduction, which gives the two base cases and the double hypothesis. The shape of its arguments has changed between versions of Mathlib, so check it in the version that you use.

Notes and history

The sequence is from the Liber abaci of Leonardo of Pisa (1202), in a problem on rabbits, and the name Fibonacci was given in the nineteenth century. Cassini's identity is from 1680. TAOCP treats the Fibonacci numbers in Section 1.2.8, and the proofs by induction of that section have the form of this one. The bound of the theorem is a step toward the closed form of Section 1.2.8.

Induction on other quantities

Statement

The index of the principle is a natural number, but the natural number need not be an index in the statement. A claim about finite sets can be proved by induction on the number of elements, a claim about boards by induction on the side, and a claim about a loop by induction on the number of passes. The method is the same: choose a size nn that is a natural number, prove the claim for the smallest size, and prove it for size k+1k + 1 from size kk.

Definition P1.4.24 (induction on a size). Let 𝒞\mathcal C be a class of objects, each with a size ∣X∣∈ℕ|X| \in \mathbb N. To prove that every object of 𝒞\mathcal C has a property, prove for each nn the statement P(n)P(n): every object of size nn has the property. The proof by induction on nn has a base case, usually n=0n = 0 or n=1n = 1, and a step that builds an object of size k+1k + 1 from one of size kk, or takes one apart.

A step that takes an object of size k+1k + 1 apart and applies the hypothesis to a smaller piece is correct only if every object of size k+1k + 1 has such a piece. The proof must say why.

Example P1.4.25 (the number of subsets). Claim: a set with nn elements has 2n2^n subsets. Base: the empty set has one subset, itself, and 20=12^0 = 1. Step: let AA have k+1k + 1 elements and choose a∈Aa \in A. The subsets of AA are of two kinds, those that do not contain aa and those that do. The first kind are the subsets of A∖{a}A \setminus \{a\}, which has kk elements, so there are 2k2^k of them. The second kind correspond one-to-one with the first kind: a subset SS that contains aa goes to S∖{a}S \setminus \{a\}. So there are 2k2^k of them too, and 2k+2k=2k+12^k + 2^k = 2^{k+1} in all. For n=5n = 5 a computer count gives 3232.

Lean: Finset.card_powerset : (Finset.powerset s).card = 2 ^ s.card (Mathlib).

Example P1.4.26 (the handshakes). Claim: among nn people, if each two shake hands once, there are n(n−1)/2n(n - 1)/2 handshakes. Base: n=1n = 1 has 0=1⋅0/20 = 1 \cdot 0/2. Step: add a person to a group of kk. The new person shakes hands with each of the kk, so there are kk new handshakes, and k(k−1)/2+k=(k+1)k/2k(k - 1)/2 + k = (k + 1)k/2. For n=10n = 10 the count is 4545, and for n=20n = 20 it is 190190.

Example P1.4.27 (the regions of the plane). Claim: nn lines in the plane, no two parallel and no three through a point, divide the plane into (n2+n+2)/2(n^2 + n + 2)/2 regions. Base: n=0n = 0 gives 11 region. Step: add a line ℓ\ell to kk lines. The line ℓ\ell meets each of the kk lines in a point, and these kk points are different, since no three lines are concurrent. They divide ℓ\ell into k+1k + 1 pieces, and each piece divides a region of the old picture in two. So the number of regions grows by k+1k + 1: (k2+k+2)/2+k+1=(k2+3k+4)/2=((k+1)2+(k+1)+2)/2(k^2 + k + 2)/2 + k + 1 = (k^2 + 3k + 4)/2 = ((k + 1)^2 + (k + 1) + 2)/2. The numbers for n=0,…,5n = 0, \dots, 5 are 1,2,4,7,11,161, 2, 4, 7, 11, 16.

Theorem P1.4.28 (tiling). For every n≥0n \ge 0, a square board of side 2n2^n with one cell removed can be covered without overlap by L-shaped pieces of three cells. The number of pieces is (4n−1)/3(4^n - 1)/3.

Proof. Base: n=0n = 0. The board has one cell, which is removed, and no piece is needed. Step: take a board of side 2k+12^{k+1} with one cell removed. Cut it into four boards of side 2k2^k. One quarter contains the removed cell. Place one L-piece at the center of the board so that it covers one cell of each of the three other quarters, the cell next to the center. Now each quarter is a board of side 2k2^k with one cell removed (the removed cell or the cell of the piece). By the hypothesis each can be tiled. The number of pieces is 4⋅(4k−1)/3+1=(4k+1−1)/34 \cdot (4^k - 1)/3 + 1 = (4^{k+1} - 1)/3. □\square

The counting formula is a check, since 4n−14^n - 1 is divisible by 33 (Section 1). The side 2n2^n cannot be replaced by any side: for the side 33, the board has 88 cells after the removal, which is not a multiple of 33, and for the side 55 the board has 2424 cells, but a computer search finds that only 99 of the 2525 cells give a tileable board.

Definition P1.4.29 (a loop's passes). A pass of a loop is one execution of its body. A claim about the state after kk passes is proved by induction on kk: the base is the state before the first pass, and the step shows that one more pass takes a state with the property to a state with the property.

Example P1.4.30 (the loop for the squares). Consider the loop, with s←0s \gets 0, t←1t \gets 1 at the start, whose body is: s←s+ts \gets s + t; t←t+2t \gets t + 2. Claim: after kk passes, s=k2s = k^2 and t=2k+1t = 2k + 1. Base: k=0k = 0, s=0s = 0, t=1t = 1. Step: if s=k2s = k^2 and t=2k+1t = 2k + 1 before a pass, then after it s=k2+2k+1=(k+1)2s = k^2 + 2k + 1 = (k + 1)^2 and t=2k+3=2(k+1)+1t = 2k + 3 = 2(k + 1) + 1. After 1010 passes s=100s = 100 and t=21t = 21. The loop gives the squares by additions only, and it is the loop form of the first example of Section 1.

Example P1.4.31 (the product by additions). Let a loop start with r←0r \gets 0, j←0j \gets 0, and let its body be r←r+ar \gets r + a; j←j+1j \gets j + 1, repeated while j<bj < b. Claim: after kk passes r=kar = ka and j=kj = k. The proof is the same. When the loop stops, j=bj = b, so r=abr = ab. This is the first instance of the method of invariants of Chapter 8: a statement that holds after every pass, and with the exit test gives the result.

Proof

For an induction on a size, the data of the proof are the class, the size and the decomposition. The decomposition is the step. In the examples above it is: remove an element of a set, remove a person from a group, remove a line, cut a board in four, or take one pass of a loop. A decomposition must be total: every object of size k+1k + 1 must have it. For the lines it is the removal of any line, and the picture of the kk remaining lines still satisfies the assumptions (no two parallel, no three concurrent). For the board it is the cutting in four equal parts, which needs the side to be even.

A mistake in the choice of the class is the usual source of false proofs. A proof for lines that adds a line to a picture of kk lines must be sure that every picture of k+1k + 1 lines can be obtained in this way, and the order in which the lines are added must not matter.

Examples

Example P1.4.32 (a false proof: all points are on one line). Claim: any nn points in the plane lie on one line. Base: n=1n = 1 and n=2n = 2 are true. Step: take k+1k + 1 points, with the hypothesis for kk. The first kk lie on a line ℓ\ell and the last kk lie on a line ℓ′\ell'. The two lines share k−1k - 1 points, so they are equal if k−1≥2k - 1 \ge 2, and all the points are on one line. The error is at k=2k = 2, with three points: the two lines share only one point, so they need not be equal. The proof has a gap at the first step beyond the base n=2n = 2, and the claim is false for three points that are not collinear.

Example P1.4.33 (the colored map). Claim: the regions into which nn lines divide the plane can be colored with two colors so that regions that share a side have different colors. Base: no line, one region. Step: add a line ℓ\ell to a picture that is colored. Reverse all the colors on one side of ℓ\ell. A side that lies on ℓ\ell now separates regions of different colors (they had the same color before, as they were one region), and a side not on ℓ\ell separates two regions on the same side of ℓ\ell, whose colors were different and are still different (both reversed or both kept).

Example P1.4.34 (the sum of the digits). Claim: a number written in base 1010 is congruent to the sum of its digits modulo 99. Take the size to be the number of digits n≥1n \ge 1. Base: a number of one digit is its own digit sum. Step: a number with k+1k + 1 digits has the form 10m+d10m + d with mm of kk digits and dd a digit. Since 10≡1(mod9)10 \equiv 1 \pmod 9, 10m+d≡m+d10m + d \equiv m + d, and mm is congruent to its digit sum. For 20242024: 2+0+2+4=82 + 0 + 2 + 4 = 8 and 2024=9⋅224+82024 = 9 \cdot 224 + 8.

Exercises

  1. [10] Prove by induction on nn that a set with nn elements has 2n2^n subsets, and find the number of subsets of {1,…,8}\{1, \dots, 8\} that have an even number of elements.
  2. [12] Prove that among nn people there are n(n−1)/2n(n - 1)/2 pairs, by induction on nn, and find the number of diagonals of a convex polygon with nn sides, n(n−3)/2n(n - 3)/2.
  3. [14] Run by hand the loop of the example for the squares for 55 passes and give ss and tt after each pass.
  4. [15] A loop starts with x←1x \gets 1 and does x←2xx \gets 2x in each pass. Prove that after kk passes x=2kx = 2^k. Change the body to x←x+xx \gets x + x and prove again.
  5. [15] Prove that nn lines in general position divide the plane into (n2+n+2)/2(n^2 + n + 2)/2 regions, and find the greatest number of regions for 2020 lines.
  6. [M18] Prove that the number of integers of nn digits in base 1010 (the first digit not 00) is 9⋅10n−19 \cdot 10^{n-1} for n≥1n \ge 1, by induction on nn.
  7. [M20] Prove that every number of nn digits in base 1010 is congruent modulo 99 to its digit sum. Use it to show that 9∣1234567899 \mid 123456789, and to find the remainder of 220=10485762^{20} = 1048576 modulo 99.
  8. [M22] Prove that a knockout tournament of n≥1n \ge 1 players ends with exactly n−1n - 1 matches, by induction on nn (each match removes one player).
  9. [M24] Show that the tiling theorem does not hold for a board with one cell removed of side 33 or 66, by counting cells. Describe the placement of the five pieces that tile a board of side 44 with one corner cell removed.
  10. [M25] Find the error in the following proof that every set of nn people have the same age: base n=1n = 1; step: remove one person, apply the hypothesis; remove another person, apply it; the two groups of kk share people, so all have the same age. At which kk does the step fail?

Lean

For a claim about a finite set, Finset.induction_on is the principle on the number of elements: it gives the case of the empty set and the case of insert a s with a ∉ s. The statement Finset.card_powerset gives the number of subsets, and Finset.card_insert_of_not_mem gives the size of an insertion (the name has changed to Finset.card_insert_of_notMem in recent versions; check which one your version has). The tiling theorem is a statement that the project does not formalize.

Notes and history

The count of regions of the plane by lines is the first case of a family of results in the geometry of arrangements, and the tiling by L-pieces of a board with one cell removed is due to Golomb (1954), who used the problem to show how a proof by induction can give a construction. The false proof that all people have the same age is a variant of the horses of Chapter 3. Chapter 8 returns to the induction on the number of passes of a loop, which is the form that TAOCP Section 1.2.1 uses for its proofs of algorithms.

Induction is the method of proof for a statement about every natural number. It is the one method that a reader of Section 1.2.1 of TAOCP must have under control, because that section, and most of Chapter 1 of Volume 1 after it, proves its formulas by this method.

Section 1 states the principle in its forms for a base 00, a base 11 and a general base, gives the pattern of an induction proof (statement, base, step), and works the first examples: sums, divisibility and inequalities. It ends with the usual errors. Section 2 treats the case where the claim as stated is too weak for the step and must be made stronger, with the Fibonacci numbers as the main example, and the proof of a formula for a recurrence. Section 3 treats induction on a quantity other than an index: the size of a finite set, the size of a board, the number of lines, and the number of passes of a loop.

The chapter assumes Chapters 1 to 3. The spine texts are Velleman, How to Prove It, Chapter 6, and Lehman, Leighton and Meyer, Mathematics for Computer Science, Chapter 6. Chapter 5 goes on to strong induction and well ordering, and Chapter 8 turns the method of a loop's passes of Section 3 into the method of invariants.

The source of this page. Something is wrong? Report it.