940 likes | 1.08k Views
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.
E N D
Pattern For Induction CPSC 121 Steve Wolfman 2012/08/02 This work is licensed under aCreative 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. “Structural” Insight: a problem of size n breaks down in terms of problems of size __________.
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.
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”.
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.
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.
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.
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.
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”.
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!
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).
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.
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).
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
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 __________.
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”.
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.
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.
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.
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.
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.
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”.
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.
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.”
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.
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).
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.
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.
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
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.
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 __________.
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”.
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.
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.
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,
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.
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.
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”.
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.
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 “”
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.
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).
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.
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.
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
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.