Exercise Sheet 7
Transcription
Exercise Sheet 7
COMP11120: Solutions for Sheet 7 Solution 73. We give answers to both parts of the question. (a) The definition of the natural numbers remains the same, although one would probably call the number that’s known to exist 1 (but it’s only a name!). If we implement that we get: Base case N. There is a natural number 1. Step case N. For each natural number n there is a natural number Sn, the successor of n. (b) The definition of addition changes as follows: Base case +. m + 1 = Sm and Step case +. m + Sn = S(m + n). Solution 74. We cover each statement. (a) The statement 0 + n = n, for all n ∈ N, is proved in the text above. The statement m + 0 = m for all m ∈ N, is an immediate consequence of base case +. (b) We note that m + 1 = m + S0 def 1 = S(m + 0) step case + = Sm base case + . In the text it is shown that + is commutative so 1 + m = m + 1 = Sm follows. Proving this directly is not too hard, though—provided we remember property (∗): 1 + m = S0 + m def 1 = 0 + Sm property (∗) = S(0 + m) step case + = Sm Part (a). (c) We wish to show that (k + m) + n = k + (m + n) for all natural numbers k, m and n. This becomes the induction hypothesis in the proof below. Base case N. (k + m) + 0 = k + m = k + (m + 0) base case + base case + . Step case N. (k + m) + Sn = S((k + m) + n) step case + = S(k + (m + n)) induction hypothesis = k + S(m + n) step case + = k + (m + Sn) step case + . This concludes the proof. 49 Solution 75. We prove each statement. (a) The required statement is that for all natural numbers m we have m · S0 = m = S0 · m. It’s sufficient to prove one of these once we have (b) (assuming we don’t require (a) to establish (b)), but in the interest of giving more example proofs we show both cases here. Base case N. m · S0 = m · 0 + m step case · =0+m base case · =m 0 unit for + . Step case N. Sm · S0 = Sm · 0 + Sm step case · = 0 + Sm base case · = Sm 0 unit for + . Note that we did not need the induction hypothesis for this proof! So in fact we could have written this proof without a case distinction, merely as m · S0 = m · 0 + m step case · =0+m base case · =m 0 unit for + . But note that we did use a non-trivial property of addition. So what about the other equality? Base case N. S0 · 0 = 0 by base case ·. Step case N. S0 · Sm = S0 · m + S0 step case · = m + S0 induction hypothesis = Sm Exercise (b). (b) Before we can prove the required statement we need an extra property.34 Compare the proof in the text of commutativity of addition to see where the parallels lie. This new property plays the same role as property (*) did in the proof of commutativity of addition. Sm · n = m · n + n. (†) To show this property we have to establish first35 that for all m ∈ N we have 0 · m = 0. This is its own induction proof. 34 35 Try to prove the statement by induction without such a stepping stone to see why. This property is used twice below—if you don’t do it first you have to give the proof twice. 50 Base case N. 0 · 0 = 0 by base case ·. Step case N. 0 · Sm = 0 · m + 0 step case · =0+0 induction hypothesis =0 0 unit for + Next we show property (†). Base case N. Sm · 0 = 0 base case · =0+0 0 unit for + =m·0+0 base case · . Step case N. Sm · Sn = Sm · n + Sm step case · = (m · n + n) + Sm induction hypothesis = m · n + Sm + n assoc and comm of + . = m · n + m + Sn property (*) = mSn + Sn step case · We are equipped now to show commutativity of multiplication. Base case N. m·0=0 =0·m base case · 0 · m = 0. Step case N. m · Sn = m · n + m step case · =n·m+m induction hypothesis = Sn · m Property (†). Solution 76. We give the definition for d. Base case d. d0 = 0 Step case d. d(Sn) = SSdn. We prove the desired equality. Base case N. d0 = 0 base case d = SS0 · 0 base case · . Step case N. d(Sn) = SSdn step case d = SSdn + 0 base case + = Sdn + S0 property (∗) = dn + SS0 property (∗) = SS0 · n + SS0 induction hypothesis = SS0 · Sn step case · . 51 Solution 77. We begin with the required definition. Base case ˆ. m0 = S0. Base case ˆ. mSn = mn · m. Now for the given equality. Base case N. mk+0 = mk 0 unit for + = mk · S0 0 k =m ·m 1 unit for · base case ˆ. Step case N. mk+Sl = mS(k+l) k+l =m step case + ·m k step case ˆ l induction hypothesis k l associativity of · k Sl = (m · m ) · m = m · (m · m) step case ˆ. =m ·m I appreciate that we have used associativity of multiplication here, which is not established in a previous exercise. Sorry about that. Solution 78. The definition is not all that different. Again we need to recurse over both arguments, but we can cover the case where m = 0 in one go. Base case f≤ . f≤ (0, n) = 1. Step case f≤ :m, 0. f≤ (Sm, 0) = 0. Step case f≤ :m, n. f≤ (Sm, Sn) = f≤ (m, n). Solution 79. We prove each statement. (a) Base case N. 0 −˙ 0 = 0 by base case −. ˙ Step case N. 0 −˙ Sn = P (0 −˙ n) step case −˙ = P0 induction hypothesis =0 base case P. (b) Note that we don’t need a proof by induction in this case. We may conclude that P (Sn) = n from the step case of P . Nonetheless the following induction proof is still valid (it just contains an unnecessary base case): Base case N. P (S0) = 0 by base case P . Step case N. P (Sn) = n by step case P . (c) Base case N. P (Sn −˙ 0) = P (Sn) = n by base case −˙ and (b). 52 Step case N. P (Sn −˙ Sm) = P (P (Sn −˙ m)) (d) Base case N. step case −˙ = P (n −˙ m) induction hypothesis = (n −˙ Sm) step case −˙ . 0 −˙ 0 = 0 by base case −. ˙ Step case N. Sn −˙ Sn = P (Sn −˙ n) step case −˙ = n −˙ n (c) =0 induction hypothesis. and indeed the reason for adding statement (c) to this exercise was to give you a stepping stone to proving (d). (e) We begin by giving an alternative definition of mod as suggested. This is as follows. The base case remains as it is, but the step case becomes: Sn mod m = S(n mod m) · (S0 −˙ f= (S(n mod m), m)). This takes care of the two cases from the original definition: • If S(n mod m) = m then f= (S(n mod m), m)) = S0 = 1 and so the expression in the bracket will evaluate to S0 −˙ S0 = 0 by (d). The definition of · then ensures that the whole expression evaluates to 0 as required. • If S(n mod m) �= m then f= (S(n mod m), m)) = 0 and so the expression in ˙ and since the bracket will evaluate to S0 −˙ 0 = S0 = 1 by the definition of −, 1 is the unit for · (see Exercise for a proof) the whole expression evaluates to S(n mod m) as required by the original definition of mod. Using this new definition we now give the proof of the statement asked for. 0 mod S0 = 0 by base case mod. Base case N. Step case N. Sn mod S0 = S(n mod S0) · (S0 −˙ f= (S(n mod S0), S0)) new step case mod = S0 · (S0 −˙ f= (S0, S0)) induction hypothesis = S0 · (S0 −˙ f= (0, 0)) step case f= : m, n = S0 · (S0 −˙ S0) base case f= = S0 · P (S0 −˙ 0) step case −˙ = S0 · P S0 base case −˙ = S0 · 0 part (b) =0 base case · . We could have invoked previous exercises for the last few steps, but it doesn’t add much to the proof to do them again. Solution 80. Here is the required definition. Base case M2 . 0 ∈ M2 . Step case M2 . n ∈ M2 implies 2 + n ∈ M2 . 53 Solution 81. We prove each statement. �0 (a) Base case N . i=0 r = r0 = 1 = i r1 − 1 r−1 by base case � . Step case N . n+1 X ri = i=0 ri + rn+1 step case P i=0 = = = �0 (b) Base case N . n X i=0 i(i rn+1 − 1 + rn+1 r−1 rn+1 + rn+2 − rn−1 − 1 r−1 rn+2 − 1 r−1 + 1) = 0 · 1 = 0 = lations in N. 0·1·2 6 induction hypothesis calcs for fractions calcs in R. by base case � and calcu- Step case N . n+1 X i(i + 1) = i=0 i(i + 1) + (n + 1)(n + 2) = = = �0 i=0 i 2 n(n + 1)(n + 2) + (n + 1)(n + 2) 3 n(n + 1)(n + 2) + 3(n + 1)(n + 2) 3 (n + 3)(n + 1)(n + 2) 3 (n + 1)(n + 2)(n + 3) 3 = 02 = 0 = in N. Step case N . n+1 X i2 = i=0 P n � 0·1·2 6 induction hypothesis calcs for fractions calcs in N mult commutative for N. by base case i2 + (n + 1)2 � and calculations step case P i=0 = = = = = = = (d) Base case N . step case i=0 = (c) Base case N . n X �0 1 n(n + 1)(2n + 1) + (n + 1)2 6 n(n + 1)(2n + 1) + 6(n + 1)2 6 (n + 1)(n(2n + 1) + 6n + 6) 6 (n + 1)(2n2 + n + 6n + 6) 6 (n + 1)(2n2 + 7n + 6) 6 (n + 1)(n + 2)(2n + 3) 6 (n + 1)(n + 2)(2(n + 1) + 1) 6 1 1 1 = 0 = = 1 = = 2 1 1 calculations for fractions. i=0 2i 54 induction hypothesis calcs for fractions calcs in N calcs in N calcs in N calcs in N. calcs in N. 21 − 1 20 by base case � and Step case N . n+1 X i=0 1 2i = n X 1 2i i=0 = = = = (e) Base case N . �0 i=0 0!0 + 1 2n+1 step case 1 2n+1 − 1 + n+1 2n 2 (2n+1 − 1)2 + 1 2n+1 n+2 2 −2+1 2n+1 2n+2 − 1 2n+1 P induction hypothesis calcs for fractions calcs in N calcs in N. = 0!0 = 0 by base case � and calculations in N. Step case N . n+1 X i=0 i!i = n X i!i + (n + 1)!(n + 1) base case P i=0 = (n + 1)! − 1 + (n + 1)!(n + 1) induction hypothesis = (n + 1)!(1 + n + 1) − 1 calcs in N = (n + 1)!(n + 2) − 1 calcs in N = (n + 2)! − 1. step case !. Solution 82. We prove each statement. (a) We carry out calculations to sample the given function. n fn 0 0 1 2 2 4 3 6 4 8 This gives rise to the assumption that f n = 2n. We prove this by induction. Base case f . f 0 = 0 = 2 · 0. Step case f . f (n + 1) = f n + 2 step case f = 2n + 2 induction hypothesis = 2(n + 1) calcs in N. (b) Again we calculate a few values. n fn 0 1 1 1 2 2 3 6 4 24 This gives rise to the assumption that f n = n!. Base case f . f 0 = 1 = 0!. Step case f . f (n + 1) = (n + 1)f n definition f = (n + 1)n! induction hypothesis = (n + 1)! calculations in N. 55 (c) Once more we calculate a few values. n fn 0 2 1 4 2 16 3 256 4 65536 Clearly there are powers of two involved, so we rewrite our table to reflect that. n fn 2? 0 2 21 1 4 22 2 16 24 3 256 28 4 65536 216 n This gives rise to the assumption that f n = 22 . Base case f . 0 f 0 = 2 = 21 = 22 . Step case f . f (n + 1) = (f n)2 definition f 2n = (2 )2 induction hypothesis =2 2n ·2 calculations for powers. =2 2n+1 calculations in N. (d) Calculating a few values we get the following. n fn 0 0 1 3 2 6 3 9 4 12 This suggests that f n = 3n is an alternative way of describing the same function. We prove that this is correct. Base case f :0. f 0 = 0 = 3 · 0. Base case f :1. f 1 = 3 = 1 · 3. Step case f . f (n + 2) = 2f (n + 1) − f n definition f = 2 · 3(n + 1) − 3n induction hypothesis = 6n + 6 − 3n calcs in N = 3n + 6 calcs in N = 2(n + 2) calcs in N. (e) Calculating a few values gives the following. n fn 0 1 1 1 2 1 3 1 4 1 This suggests that our function is actually a constant one, and we show that f n = 1 for all n ∈ N. Base case f :0. f 0 = 1. Base case f :1. f 1 = 1. Step case f . f (n + 2) = 2f (n + 1) − f n =2·1−1 = 1. 56 definition of f induction hypothesis (f) Once again we calculate the first few values n fn 0 1 1 2 2 4 3 8 4 16 This suggests that we should prove f n = 2n . Base case f :0. f 0 = 1 = 20 . Base case f :1. f 1 = 2 = 21 . Step case f . f (n + 2) = f (n + 1) + 2f n definition f = 2n+1 + 2 · 2n =2 n+1 induction hypothesis n+1 +2 calcs in N = 2 · 2n+1 calcs in N n+2 calcs in N. =2 (g) We proceed as before. n fn 0 1 1 3 2 9 3 27 4 81 This suggests f n = 3n . Base case f :0. f 0 = 1 = 30 . Base case f :1. f 1 = 3 = 31 . Step case f . f (n + 2) = 2f (n + 1) + 3f n = 2 · 3n+1 + 3 · 3n n+1 =2·3 n+1 calcs in N n+1 calcs in N n+1 =3·3 =3 . This case is quite similar to the previous one. 57 induction hypothesis +3 = (2 + 1)3 n+2 definition f calcs in N