1 / 94

Pattern For Induction

Pattern For Induction. CPSC 121 Steve Wolfman 2012/08/02. This work is licensed under a Creative Commons Attribution 3.0 Unported License . Starting an Induction Proof. Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n.

yori
Télécharger la présentation

Pattern For Induction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Pattern For Induction CPSC 121 Steve Wolfman 2012/08/02 This work is licensed under aCreative Commons Attribution 3.0 Unported License.

  2. Starting an Induction Proof Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________.

  3. Laying Out the Structure of an Induction Proof Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true.

  4. Starting an Induction Proof Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State the theorem explicitly or circle it if it’s given. It may help to define a function like “Let c(n) = the # of nodes in KST tree Kn”.

  5. Starting an Induction Proof Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State P(n) explicitly, regardless of whether it’s given. You’ll need P(n) over and over! On an exam, you can even use it to write long statements briefly.

  6. Starting an Induction Proof Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State this insight explicitly. It may be right in the problem statement! Say a function is recursive. Then the recursive calls tell you how the problem breaks down. Say a definition is recursive. Then the self-reference tells you how the problem breaks down. Say there’s a summation. Then our self-referential definitions for summations (or products or …) tell you how the problem breaks down.

  7. Laying Out the Structure of an Induction Proof The theorem’s easy. You already wrote it. Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true.

  8. Laying Out the Structure of an Induction Proof Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. The smallest relevant value. Prove the property for this case. For the same value as above.

  9. Laying Out the Structure of an Induction Proof Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. Ask: Does the structural insight break the next value of n down in terms of the existing base case? If not, add it as a base case. Continue until all remaining cases are “handled”.

  10. Laying Out the Structure of an Induction Proof Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. The largest base case. P(i) for every i your structural insight tells you that you need!

  11. Laying Out the Structure of an Induction Proof Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. Restate your structural insight. Then, use the IH to “solve” the subproblems. Finally, build back up to P(n).

  12. Starting an Induction Proof Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State the theorem explicitly or circle it if it’s given. It may help to define a function like “Let c(n) = the # of nodes in KST tree Kn”. State P(n) explicitly, regardless of whether it’s given. You’ll need P(n) over and over! On an exam, you can even use it to write long statements briefly. State this insight explicitly. It may be right in the problem statement! Say a function is recursive. Then the recursive calls tell you how the problem breaks down. Say a definition is recursive. Then the self-reference tells you how the problem breaks down. Say there’s a summation. Then our self-referential definitions for summations (or products or …) tell you how the problem breaks down.

  13. Laying Out the Structure of an Induction Proof The theorem’s easy. You already wrote it. Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. The smallest relevant value. Prove the property for this case. For the same value as above. Ask: Does the structural insight break the next value of n down in terms of the existing base case? If not, add it as a base case. Continue until all remaining cases are “handled”. The largest base case. P(i) for every i your structural insight tells you that you need! Restate your structural insight. Then, use the IH to “solve” the subproblems. Finally, build back up to P(n).

  14. Reminder: Sigma, Pi, Factorial, Powers:All Self-Referential

  15. Examples • K1 is a tree with only a root node. For all integers n  2, Kn is a root node with all previous Ki as subtrees. Prove Kn has 2n-1 nodes. (You may assume .) • Prove for every positive integer n: • Prove that the following algorithm takes no more than multiplications: ;; Integer Natural -> Integer Pow(a,b): if b = 0: return 1 else if b = 1: return a else: let part = Pow(a,) if b is odd: return part*part*a else: return part*part

  16. Example 1

  17. Example 1, Getting Started Problem: K1 is a tree with only a root node. For all integers n  2, Kn is a root node with all previous Ki as subtrees. Prove Kn has 2n-1 nodes. (You may assume .) Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________.

  18. Example 1, Getting Started Problem: K1 is a tree with only a root node. For all integers n  2, Kn is a root node with all previous Ki as subtrees. Prove Kn has 2n-1 nodes. Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State the theorem explicitly or circle it if it’s given. It may help to define a function like “Let c(n) = the # of nodes in KST tree Kn”.

  19. Example 1, Getting Started Problem: K1 is a tree with only a root node. For all integers n  2, Kn is a root node with all previous Ki as subtrees. Prove Kn has 2n-1 nodes. Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State P(n) explicitly, regardless of whether it’s given. You’ll need P(n) over and over! On an exam, you can even use it to write long statements briefly.

  20. Example 1, Getting Started Problem: K1 is a tree with only a root node. For all integers n  2, Kn is a root node with all previous Ki as subtrees. Prove Kn has 2n-1 nodes. Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Scratch work: P(n)  c(Kn) = 2n-1 “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State this insight explicitly. It may be right in the problem statement! Say a definition is recursive. Then the self-reference tells you how the problem breaks down.

  21. Example 1, Getting Started Problem: K1 is a tree with only a root node. For all integers n  2, Kn is a root node with all previous Ki as subtrees. Prove Kn has 2n-1 nodes. Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Scratch work: P(n)  c(Kn) = 2n-1 “Structural” Insight: For all integers n  2, Kn is a root node with all previous Ki as subtrees.

  22. Example 1: Laying out the Structure The theorem’s easy. You already wrote it. Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true.

  23. Example 1: Laying out the Structure Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. The smallest relevant value. (Here: n  1; so, 1.) Prove the property for this case. For the same value as above.

  24. Example 1: Laying out the Structure Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = 1, TODO: prove the property. , c(K1) = 21-1. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. Ask: Does the structural insight break the next value of n (here: 2) down in terms of the existing base case? If not, add it as a base case. Continue until all remaining cases are “handled”.

  25. Example 1: Laying out the Structure Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = 1, TODO: prove the property. , c(K1) = 21-1. IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. NO MORE BCs. 2 breaks down in terms of 1, which is our base case. 3 breaks down in terms of 2 (which we know we can handle) and 1. Everything subsequent breaks down in terms of previous values, which eventually reach 1.

  26. Example 1: Laying out the Structure Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = 1, TODO: prove the property. , c(K1) = 21-1. IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. The largest base case. P(i) for every i your structural insight tells you that you need! Reminder: our structural insight is “For all integers n  2, Kn is a root node with all previous Ki as subtrees.”

  27. Example 1: Laying out the Structure Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = 1, TODO: prove the property. , c(K1) = 21-1. IH: WLOG, let n be an arbitrary integer > 1.Assume c(Ki) = 2i-1 for all “previous i” (that is, all integers 1  i < n). IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. Restate your structural insight. Then, use the IH to “solve” the subproblems.

  28. Example 1: Laying out the Structure Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = 1, TODO: prove the property. , c(K1) = 21-1. IH: WLOG, let n be an arbitrary integer > 1.Assume c(Ki) = 2i-1 for all “previous i” (that is, all integers 1  i < n). IS:Since n > 1, Kn is a root node with all previous Ki as subtrees. By the IH, for each of these subtrees, c(Ki) = 2i-1.  P(n) is true. (Because n is an integer, n > 1 means the same as n  2.) Finally, build back up to P(n).

  29. Example 1: Laying out the Structure Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = 1, TODO: prove the property. , c(K1) = 21-1. IH: WLOG, let n be an arbitrary integer > 1.Assume c(Ki) = 2i-1 for all “previous i” (that is, all integers 1  i < n). IS:Since n > 1, Kn is a root node with all previous Ki as subtrees. By the IH, for each of these subtrees, c(Ki) = 2i-1.  c(Kn) = 2n-1. Finally, build back.

  30. Example 1: Finishing the Proof Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = 1, K1 is defined to contain only 1 node. Therefore, c(K1) = 1. And, 21-1 = 20 = 1. , c(K1) = 21-1. IH: WLOG, let n be an arbitrary integer > 1.Assume c(Ki) = 2i-1 for all “previous i” (that is, all integers 1  i < n). IS:Since n > 1, Kn is a root node with all previous Ki as subtrees. By the IH, for each of these subtrees, c(Ki) = 2i-1.  c(Kn) = 2n-1. Finally, build back.

  31. Example 1: Finishing the Proof Let c(n) = the # of nodes in KST tree Kn. Theorem: c(Kn) = 2n-1 for all integersn  1. Proof: by induction on n. BC: For n = 1, K1 is defined to contain only 1 node. Therefore, c(K1) = 1. And, 21-1 = 20 = 1. , c(K1) = 21-1. IH: WLOG, let n be an arbitrary integer > 1.Assume c(Ki) = 2i-1 for all “previous i” (that is, all integers 1  i < n). IS:Since n > 1, Kn is a root node with all previous Ki as subtrees. By the IH, for each of these subtrees, c(Ki) = 2i-1. Thus: (one root node plus the nodes in the subtrees) By the IH Where j = i – 1. By assumption in the problem statement. QED

  32. Example 1, Other Things to Try Problem: K1 is a tree with only a root node. For all integers n  2, Kn is a root node with all previous Ki as subtrees. Prove Kn has 2n-1 nodes. (You may assume .) • Prove the assumption (by induction!). • Prove the alternate insight “For n  2, Kn is Kn-1 plus an extra subtree that is also Kn-1” (not by induction), then use this insight to prove the theorem instead. • Figure out what the height of Kn is and prove it by induction (with either insight). • Change the definition to “K0 is the empty tree” rather than starting with K1 and change n  2 to n  1. Reprove the theorem.

  33. Example 2

  34. Example 2, Getting Started Problem: Prove for every positive integer n,. Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________.

  35. Example 2, Getting Started Problem: Prove for every positive integer n,. Theorem: some property is true for all integers n  ___. Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State the theorem explicitly or circle it if it’s given. It may help to define a function like “Let c(n) = the # of nodes in KST tree Kn”.

  36. Example 2, Getting Started Problem: Prove for every positive integer n, . Theorem: For every positive integer n, . Scratch work: P(n)  some property on n. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State P(n) explicitly, regardless of whether it’s given. You’ll need P(n) over and over! On an exam, you can even use it to write long statements briefly.

  37. Example 2, Getting Started Problem: Prove for every positive integer n, . Theorem: For every positive integer n, . Scratch work: P(n)  “Structural” Insight: a problem of size n breaks down in terms of problems of size __________. State this insight explicitly. It may be right in the problem statement! Say there’s a summation. Then our self-referential definitions for summations (or products or …) tell you how the problem breaks down.

  38. Reminder: Sigma, Pi, Factorial, Powers:All Self-Referential

  39. Example 2, Getting Started Problem: Prove for every positive integer n, . Theorem: For every positive integer n, . Scratch work: P(n)  “Structural” Insight: For all integers n  2,

  40. Example 2: Laying out the Structure The theorem’s easy. You already wrote it. Theorem: ____________________. Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true.

  41. Example 2: Laying out the Structure Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = ___, , P(___) is true. More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. The smallest relevant value. (Here: n is positive or  1; so, 1.) Prove the property for this case. For the same value as above.

  42. Example 2: Laying out the Structure Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = 1, TODO: prove the property. , . More? IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. Ask: Does the structural insight break the next value of n (here: 2) down in terms of the existing base case? If not, add it as a base case. Continue until all remaining cases are “handled”.

  43. Example 2: Laying out the Structure Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = 1, TODO: prove the property. , . IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. NO MORE BCs. 2 breaks down in terms of 1, which is our base case. 3 breaks down in terms of 2 (which we know we can handle). Everything subsequent breaks down in terms of the previous value, which eventually reaches 1.

  44. Example 2: Laying out the Structure Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = 1, TODO: prove the property. , . IH: WLOG, let n be an arbitrary integer > ____.Assume _________________________________________________________________________________. IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. The largest base case. P(i) for every i your structural insight tells you that you need! Reminder: our structural insight is “”

  45. Example 2: Laying out the Structure Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = 1, TODO: prove the property. , . IH: WLOG, let n be an arbitrary integer > 1.Assume . IS:Since n > ____, ___________________________. By the IH, __________________________________.  P(n) is true. Restate your structural insight. Then, use the IH to “solve” the subproblems.

  46. Example 2: Laying out the Structure Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = 1, TODO: prove the property. , . IH: WLOG, let n be an arbitrary integer > 1.Assume . IS:Since n > 1, . By the IH, .  P(n) is true. (Because n is an integer, n > 1 means the same as n  2.) Finally, build back up to P(n).

  47. Example 2: Laying out the Structure Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = 1, TODO: prove the property. , . IH: WLOG, let n be an arbitrary integer > 1.Assume . IS:Since n > 1, . By the IH, .  . Finally, build back.

  48. Example 2: Finishing the Proof Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = 1, and . , . IH: WLOG, let n be an arbitrary integer > 1.Assume . IS:Since n > 1, . By the IH, .  . Finally, build back. At this point, we did scratch work on both sides of the formula: and until they connected.

  49. Example 2: Finishing the Proof Theorem: For every positive integer n, . Proof: by induction on n. BC: For n = 1, and . , . IH: WLOG, let n be an arbitrary integer > 1.Assume . IS:Since n > 1, . By the IH, . QED

  50. Example 2, Other Things to Try Problem: Prove for every positive integer n,. • Find a formula for . Now, prove the formula correct by induction and, separately, by relating the new formula to the one you analysed in Example 2. • Find a formula for . Prove it correct by induction. (Can’t figure out the formula? Type 1 + 8 + 27 + … into Wolfram Alpha hit enter.) • Change the bounds to 0 to n (rather than 1 to n) and find new formulae/proofs.

More Related