RMIT University; Taylor's College1 Lecture 6 To apply the Principle of Mathematical Induction To solve the Towers of Hanoi puzzle To define a recurrence relation
RMIT University; Taylor's College2 Mathematical Induction Suppose we have a mathematical proposition, P(n), about some integers n. We want to know if P(n) is true for every integer n, from a starting point onwards.
RMIT University; Taylor's College3 Mathematical Induction Example: Prove that n! > 2 n is true for all in positive integer n Is this sometimes true, never true, always true after a certain point, or what? Check some values: n!2n2n n = 011 n = 112 n = 224 n = 368 n = n = At this stage, n! seems to be streaking ahead of 2 n at a great rate. How could we prove n! > 2 n ? The idea is to use Proof by Induction.
RMIT University; Taylor's College4 Proof by Induction: 3 Steps 1.Base step: With a starting point n 0, Verify that P(n 0 ) is true. 2.Inductive step: Assume that P(k) is true, prove that P(k + 1) is also true. 3.Conclusion: Declare that P(n) is true for every integer n ≥ n 0
RMIT University; Taylor's College5 Example: Prove by induction that n! > 2 n for all n ≥ 4.
6 Conclusion: n! > 2 n for all n ≥ 4.
7
8
RMIT University; Taylor's College9
10 The Towers of Hanoi We need to move all n discs to Pole 3. But we can only move 1 disc at a time, and a disc must never be placed on a smaller disc. Theorem: This can be solved for all n ≥ 1 Proof: We can use proof by induction
RMIT University; Taylor's College11 The Towers of Hanoi: Proof Base step Suppose we have 1 disc. Pick it up and put it on Pole 3 Inductive step Suppose we can move (k – 1) discs (*) We want to show we can move k discs. Given k discs, leave the big one at the bottom. Move the other (k – 1) to Pole 2 instead of Pole 3. (We know this can be done, by the inductive hypothesis (*)) Move the big disc to Pole 3. Move the other stack from Pole 2 to Pole 3 (Again, we know this can be done, by (*).) We’ve moved the stack of k discs! Conclusion For all n, the problem can be solved.
RMIT University; Taylor's College12 The Towers of Hanoi How many moves (1 disc at a time) are needed to get the stack of n discs from Pole 1 to Pole 3? Let this number be f n. So f 1 = 1. (That is, if we only have 1 disc then a single move takes it to Pole 3.) Let’s look at the inductive proof that the puzzle can always be solved. When n = k, f k moves are needed. So what happens when n = k + 1? The number of moves needed is f k+1, but this can be expressed in terms of f k. It takes f k moves to get the top k discs to Pole 2, then 1 move to get the bottom disc to Pole 3, and then f k moves to get the stack of k discs from Pole 2 and put it on top of the biggest disc which is now on Pole 3.
RMIT University; Taylor's College13 The Towers of Hanoi So f k+1 = f k f k, i.e. f k + 1 = 2f k + 1 This equation is an example of a recurrence relation, where each value of a function can be determined from previous values (assuming that we know some initial values). Using n instead of k, we have f n+1 = 2f n + 1 with initial condition f 1 = 1.
RMIT University; Taylor's College14 The Towers of Hanoi We can then construct the following partial table. nfnfn f 2 = 2f = =3 f 3 = 2f = = 7
RMIT University; Taylor's College15 The Towers of Hanoi But suppose we want to know how many moves are needed to shift 100 discs. We would need to compute all the values from f 7 up to f 99, and then use f 100 = 2f to get the value of f 100. Clearly it would be better if we had a formula for f n which only depended on n, rather than on earlier values of the function. Such a formula is called a solution to the recurrence relation. We won’t give a general method for solving recurrence relations, but rather we’ll look at how to obtain a solution for this particular example.
RMIT University; Taylor's College16 The Towers of Hanoi Do the values in the second column of the table look familiar? If not, let’s add 1 to every value and also put in some more rows fnfn f n n Now it should be clear that the new last column consists of all the powers of 2 with positive exponent. Specifically, f n + 1 = 2 n. Subtracting 1 from both sides gives f n = 2 n – 1. It can be formally proved that this formula gives the correct answer. (We omit the details.)
RMIT University; Taylor's College17 The Towers of Hanoi Our reasoning here is an example of inductive reasoning, where we study enough examples to be able to hypothesize a general result. Note that f 100 = – 1, which is a rather big number! 2 64 – 1 = 18, 446, 744, 073, 709, 551, 615 moves!