snick Outline snack • Prereqs and Learning Goals • Problems and Discussion CPSC 121: Models of Computation – Introductions 2016W2 – Odd Numbers – Horse Colours Revisiting Induction – CS Induction: Duplicate Detection, Binary Search, MergeSort Steve Wolfman, based on work by – More examples Patrice Belleville and others • Next Lecture Notes 1 2 Learning Goals: Pre-Class Learning Goals: In-Class By the start of class, you should be able to: By the end of this unit, you should be able to: – Given a theorem to prove and the insight into – Formally prove properties of the non-negative integers (or a subset like integers larger than 3) how to break the problem down in terms of that have appropriate self-referential structure — smaller problems , write out the skeleton of an including both equalities and inequalities — using inductive proof including: the base case(s) either weak or strong induction as needed. that need to be proven, the induction – Critique formal inductive proofs to determine hypothesis, and the inductive step that needs whether they are valid and where the error(s) lie if to be proven. they are invalid. 3 4 Worked Problem: Outline How Many Introductions? • Prereqs and Learning Goals Problem: n people would like to introduce • Problems and Discussion themselves to each other. How many introductions does it take? – Introductions For 2 people? – Odd Numbers For 3 people? – Horse Colours For 4 people? – CS Induction: Duplicate Detection, Binary Search, MergeSort For 5 people? – More examples … • Next Lecture Notes For n people? Sound familiar? Let’s prove it. 5 6 1
Worked Problem: Worked Problem: How Many Introductions? Self-referential structure? It’s usually good to name things! Def’n : When two people meet each other, that Let’s let I(n) be the number of introductions required for counts as two intros. a group of n people… Let’s do a few steps concretely to find insight… My turn! I(1) ? 0 introductions. For 1 person? Given I(k-1) , what’s I(k) ? a. I(k-1) + 1 b. I(k-1) * (k-1) Given the number for 1 , for 2 ? c. I(k-1) + 2(k – 1) d. I(k-1) + 2k Given the number for 2 , for 3 ? e. None of these 8 7 Once we have this, we’re ready for our pattern! A Pattern for Induction A Pattern for Induction 1. Identify the recursive structure in the problem. 1. Identify the recursive structure in the problem. I(k) 2. Circle each recursive appearance of the 2. Circle each recursive appearance of the structure inside its definition. structure inside its definition. I(k-1) 3. Divide the cases into: those without recursive 3. Divide the cases into: those without recursive appearances (“base cases”) and those with appearances (“base cases”) and those with “0” base case, (“recursive” or “inductive” cases) (“recursive” or “inductive” cases) “> 0” inductive case 4. Write a predicate P( a ) describing what you 4. Write a predicate P( a ) describing what you I(k) = k(k-1) want to say about the structure. want to say about the structure. 5. Write your theorem a ?,P( a ) 5. Write your theorem a ?,P( a ) 6. Complete the proof template. 6. Complete the proof template. 9 10 If the recursive structure is parameterized by P( k ) ≡ [fill in predicate definition] P( k ) ≡ I(k) = k(k-1) something, we use that thing inside P( ? ). Theorem: For all [recursive structure] a , P( a ) holds. Theorem: For all natural numbers k , P( k ) holds. Proof by structural induction: Proof by structural induction: Base case: We know I(0) = 0. 0(0-1) = 0(-1) = 0, as expected. Base case: [For each non-recursive case, prove the theorem holds for that case. End by showing your theorem true for the base case structure!] Inductive Step: Inductive Step: [For each recursive case…] Consider an arbitrary non-zero natural number k . Consider an arbitrary [recursive case structure] a . Induction Hypothesis: Assume the theorem holds for k -1; that is, I(k-1) = Induction Hypothesis: Assume the theorem holds for [each recursive (k-1)((k-1)-1). appearance of the structure in this case]. We now show the theorem holds for k . That is, I(k) = k(k-1). We now show the theorem holds for a . [And then do so! You should: I(k) = I(k-1) + 2(k-1) by definition 1) END by showing that your theorem holds for a . = (k-1)((k-1)-1) + 2(k-1) by the IH USE the “Induction Hypothesis” assumption(s) you made. 2) = (k-1)(k-2) + 2k – 2 3) NEVER take a recursive appearance and use the recursive definition to = k^2 – 3k + 2 + 2k – 2 break it down further, like this BAD example: “each subtree is a binary = k^2 – k tree that can have subtrees and so on until we reach an empty tree.”] = k(k-1) as expected It helps to write out what you want to prove rather than just “show the theorem holds for a ”. 11 12 QED (Even though neither one is strictly necessary.) 2
Historical Problem : Outline Sum of Odd Numbers • Prereqs and Learning Goals Problem: What is the sum of the first n odd • Induction as a Formal Argument Form numbers? • Problems and Discussion – Introductions First, find the pattern. Then, prove it’s correct. – Odd Numbers – Horse Colours The first 1 odd number? – CS Induction: Duplicate Detection, Binary Search, The first 2 odd numbers? MergeSort – More examples The first 3 odd numbers? • Next Lecture Notes The first n odd numbers? Historical note: Francesco Maurolico made the first 13 14 recorded use of induction in 1575 to prove this theorem! Sum of Odd Numbers: Sum of Odd Numbers: Recursive Structure Recursive Structure Problem: Prove that the sum of the first n Problem: Prove that the sum of the first n odd numbers is n 2 . odd numbers is n 2 . The sum of the first n odd numbers is the How can we break the sum of the first, second, …, n th odd number up in terms of sum of the first n-1 odd numbers plus the n th odd number. a simpler sum of odd numbers? (See our recursive formulation of from the last slides!) 15 16 P( k ) ≡ [fill in predicate definition] A Pattern for Induction Theorem: For all [recursive structure] a , P( a ) holds. Proof by structural induction: 1. Identify the recursive structure in the problem. Base case: [For each non-recursive case, prove the theorem holds for that case. End by showing your theorem true for the base case structure!] 2. Circle each recursive appearance of the Inductive Step: [For each recursive case…] structure inside its definition. Consider an arbitrary [recursive case structure] a . 3. Divide the cases into: those without recursive Induction Hypothesis: Assume the theorem holds for [each recursive appearances (“base cases”) and those with appearance of the structure in this case]. (“recursive” or “inductive” cases) We now show the theorem holds for a . [And then do so! You should: 1) END by showing that your theorem holds for a . 4. Write a predicate P( a ) describing what you USE the “Induction Hypothesis” assumption(s) you made. 2) want to say about the structure. 3) NEVER take a recursive appearance and use the recursive definition to break it down further, like this BAD example: “each subtree is a binary 5. Write your theorem a ?,P( a ) tree that can have subtrees and so on until we reach an empty tree.”] 6. Complete the proof template. It helps to write out what you want to prove rather than just “show the theorem holds for a ”. 17 18 (Even though neither one is strictly necessary.) 3
Historical Problem : Historical Problem : Sum of Odd Numbers Sum of Odd Numbers Theorem: For all positive integers n, the sum of the first n odd natural numbers is n 2 . Base Case: Establish for n=1. The sum of the “first 1 odd natural numbers” is 1, which equals 1 2 . (by the IH) Induction Hypothesis: Assume... ? Inductive Step: To prove... ? 19 20 Outline Problem : Proof Critique • Prereqs and Learning Goals Theorem : All horses are the same colour. • Induction as a Formal Argument Form See handout. • Problems and Discussion – Introductions – Odd Numbers Problem : Critique the proof. – Horse Colours – CS Induction: Duplicate Detection, Binary Search, MergeSort – More examples • Next Lecture Notes 21 22 Problem : Proof Critique Problem : Proof Critique Theorem : All horses are the same colour. Theorem : All horses are the same colour. See handout. See handout. Proof critique: Is the proof valid? a. Yes, because each step follows irrefutably Proof critique: Can the proof be fixed? from the previous steps. b. Yes, because the premises are false. c. Yes, but not for the reasons listed here. d. No, because the inductive step fails for n=2. e. No, but not for the reasons listed here. Ask yourself this question if you see a flaw in a proof… 23 24 especially if it’s in your proof! 4
Recommend
More recommend