=========================================================================== CSC 236 Sample Solutions for Week 2 Tutorial Fall 2007 =========================================================================== Dear student, Keep in mind that I plan tutorials to give *you* a chance to practice solving problems and getting immediate feedback on your ideas. I do not intend tutorials to present more fully worked-out examples -- that's what I do in the lectures. If you feel that this is not working well, please let me know. But I think that it would be a loss to have tutorials simply be more lecturing, rather than giving you a chance to explore and try things out and find out if your understanding is at the right level. Also, besides office hours, tutorials are the one time when you should plan to get all of your questions answered -- that means that you should expect the TA's to ask you often if you understand what's going on, and that you should tell them when you don't! (I try to do that in lectures as well, but given the class size and the pacing of the course material, it's not always possible to get the same level of interaction.) In the solution for the first question, I've indicated all of the places where I suggested to the TAs that they ask you for input. They may not have asked each of those questions, and they may not have followed exactly the line of reasoning that I outlined, because I told them to go along with your suggestions. But they should have ended up covering most of the main points. So these sample solutions are more to give you a chance to see it again all at once, including any bits that the TAs may not have gotten to (because of time or because they went in a different direction to explore someone's suggestion). The sample solutions to the second question do not contain all of these explicit suggestions, but I told the TAs to follow the same format and regularly ask you for input. Also, I told them not to worry if they didn't get to it -- it was more important to make sure that you understood the first problem rather than try to cover both of them faster. Now, on to the sample solutions themselves... A. Prove that it is possible to make every amount of postage of at least 18c using only 4c and 7c stamps. Follow the detailed format given in lecture -- in particular, define P(n) precisely. Q: What's the first step? 0. Define P(n) precisely. Q: What does does it mean to "make an amount of postage of n cents using only 4c and 7c stamps"? How do we express it precisely? A: -] a in N, -] b in N, 4a + 7b = n Q: Now, what should P(n) be? A: P(n): n >= 18 -> -] a in N, -] b in N, 4a + 7b = n. A: P(n): -] a in N, -] b in N, 4a + 7b = n, except we prove \-/ n >= 18, P(n) instead of \-/ n in N, P(n). A: P(n): -] a in N, -] b in N, 4a + 7b = n + 18. Each of these will require slightly different proof formats, but the content will be the same (and the differences slight, as we'll see below). We'll pick the first one to do, because it allows us to review important aspects of working with implications. Q: What's the next step? 1. Base Case: Prove P(0). Q: What's P(0) again? A: 0 >= 18 -> -] a in N, -] b in N, 4a + 7b = 0. Q: How do we prove this? A: This is vacuously true (i.e., 0 >= 18 is false). Recall that when A is false, A -> B is true, and this is called "vacuously true" because it tells us nothing about the truth of B. Q: What's the next step? 2. Inductive Hypothesis (IH): Q: What should this be? A: Let n in N and suppose P(n), i.e., n >= 18 -> -] a in N, -] b in N, 4a + 7b = n. Q: What's the next step? 3. Inductive Step: Prove P(n+1), i.e., n+1 >= 18 -> -] a' in N, -] b' in N, 4a' + 4b' = n+1 (using a', b' to avoid possible confusion with the variables in the IH). Q: How do we prove this? A: It's an implication, so start with: Suppose n+1 >= 18. Q: Can we use the IH directly? A: No: n+1 >= 18 means n >= 17, which doesn't match. Q: How can we work around this? A: Break up the inductive step into cases: n+1 = 18 (which we'll have to prove directly) and n+1 > 18 (where we'll be able to use the IH). Consider the following cases: either n+1 = 18 or n+1 > 18. Q: If n+1 = 18, how do we prove P(n+1)? Case 1: If n+1 = 18, then n+1 = 18 = 4 + 14 = 4*1 + 7*2, so P(n+1) holds by picking a' = 1, b' = 2. Q: If n+1 > 18, how do we prove P(n+1)? Case 2: If n+1 > 18, then n >= 18 and the IH allows us to conclude -] a in N, -] b in N, 4a + 7b = n. Hence, n+1 = 4a + 7b + 1. Q: What next? A: We need a bit of a trick! Consider the following cases: either b > 0 or b = 0. Q: Now, can you figure out how to prove the case b > 0? Sub-case a: If b > 0, then n+1 = 4a + 7b + 1 = 4a + 7(b-1) + 7 + 1 = 4a + 7(b-1) + 8 = 4(a+2) + 7(b-1) so P(n+1) holds by picking a' = a+2, b' = b-1. Q: Now, can you figure out how to prove the case b = 0? Sub-case b: If b = 0, then n+1 = 4a + 1. Since n >= 18, this means 4a >= 18, which implies a >= 5 (since a in N). Then, n+1 = 4a + 1 = 4(a-5) + 20 + 1 = 4(a-5) + 7*3 so P(n+1) holds by picking a' = a-5, b' = 3. In every sub-case, P(n+1) holds. In every case, P(n+1) holds. Q: At this point, what have we proved exactly? A: \-/ n in N, P(n) -> P(n+1) (just completed) and P(0) (earlier). Q: What do we want to prove again? A: \-/ n in N, P(n). Q: How do we get there? A: *Apply* the principle of simple induction. Q: What's the next step? 4. Conclusion: By induction, \-/ n in N, P(n), i.e., \-/ n in N, n >= 18 -> -] a in N, -] b in N, 4a + 7b = n, i.e., it is possible to make every amount of postage of 18c or more using only 4c and 7c stamps. Now, look back over the proof. Q: Notice anything about Case 1 and Case 2 in the proof of our inductive step? A: They look an awful lot like the base case and inductive step in some other proof by induction. That's because they are! If we used the second definition of P(n) and used a "modified" version of induction with a base case of n = 18 and an IH that started with "let n in N and n >= 18", we would get exactly Case 1 as our base case and Case 2 as our inductive step. And we would conclude exactly the same thing in the end. Q: What about the last definition of P(n)? A: It would look almost exactly like the proof using the second definition, except with "n+18" instead of "n" on the left-hand side of the equations. B. What is the value of SUM_{0 <= i <= n} 2^i? Make a conjecture and prove it, using the format given in lecture. Exploration: Look at values of the sum and see if there is a pattern. n = 0: SUM = 1 n = 1: SUM = 3 n = 2: SUM = 7 n = 3: SUM = 15 n = 4: SUM = 31 n = 5: SUM = 63 Q: What's a reasonable conjecture? A: SUM_{0 <= i <= n} 2^i = 2^{n+1} - 1. 0. Define P(n): SUM_{0 <= i <= n} 2^i = 2^{n+1} - 1. (Note: no quantifier!) 1. Base Case: Prove P(0), i.e., SUM_{0 <= i <= 0} 2^i = 2^{0+1} - 1. SUM_{0 <= i <= 0} 2^i = 2^0 = 1 = 2-1 = 2^1 - 1 Hence, P(0) holds. 2. Inductive Hypothesis (IH): Let n in N and suppose P(n), i.e., SUM_{0 <= i <= n} 2^i = 2^{n+1} - 1. 3. Inductive Step: Prove P(n+1), i.e., SUM_{0 <= i <= n+1} 2^i = 2^{(n+1)+1} - 1. SUM_{0 <= i <= n+1} 2^i = SUM_{0 <= i <= n} 2^i + 2^{n+1} (by the IH) = 2^{n+1} - 1 + 2^{n+1} = 2*2^{n+1} - 1 = 2^{n+2} - 1 Hence, P(n+1) holds. 4. Conclusion: By induction, \-/ n in N, P(n), i.e., SUM_{0 <= i <= n} 2^i = 2^{n+1} - 1 for all n in N.