induction

cse 311: foundations of computing
Spring 2015
Lecture 15: Induction
prove: for all ๐‘› > 0, ๐‘Ž is odd โ†’ ๐‘Ž๐‘› is odd
Let ๐‘› > 0 be arbitrary.
Suppose that ๐‘Ž is odd. We know that if ๐‘Ž, ๐‘ are odd,
then ๐‘Ž๐‘ is also odd.
So:
โ‹ฏโ‹…
๐‘Ž โ‹… ๐‘Ž โ‹… ๐‘Ž โ‹… โ‹ฏ โ‹… ๐‘Ž = ๐‘Ž๐‘›
[๐‘› times]
Those โ€œโ‹ฏโ€s are a problem! Weโ€™re trying to say โ€œwe can use
the same argument over and overโ€ฆโ€
Weโ€™ll come back to this.
mathematical induction
Method for proving statements about all integers โ‰ฅ 0
โ€“ A new logical inference rule!
โ€ข It only applies over the natural numbers
โ€ข The idea is to use the special structure of the naturals to
prove things more easily
โ€“ Particularly useful for reasoning about programs!
for(int i=0; i < n; n++) { โ€ฆ }
โ€ข Show P(i) holds after i times through the loop
public int f(int x) {
if (x == 0) { return 0; }
else { return f(xโ€“1)+1; }}
โ€ข f(x) = x for all values of x โ‰ฅ 0 naturally shown by induction.
induction is a rule of inference
Domain: Natural Numbers
๐‘ƒ(0)
๏€ข ๐‘˜ (๐‘ƒ(๐‘˜) โ†’ ๐‘ƒ(๐‘˜ + 1))
๏œ ๏€ข ๐‘› ๐‘ƒ(๐‘›)
using the induction rule in a formal proof
๐‘ƒ(0)
๏€ข ๐‘˜ (๐‘ƒ(๐‘˜) โ†’ ๐‘ƒ(๐‘˜ + 1))
๏œ ๏€ข ๐‘› ๐‘ƒ(๐‘›)
1. Prove P(0)
2. Let k be an arbitrary integer โ‰ฅ 0
3. Assume that P(k) is true
4. ...
5. Prove P(k+1) is true
6. P(k) ๏‚ฎ P(k+1)
Direct Proof Rule
7. ๏€ข k (P(k) ๏‚ฎ P(k+1))
Intro ๏€ข from 2-6
8. ๏€ข n P(n)
Induction Rule 1&7
format of an induction proof
๐‘ƒ(0)
๏€ข ๐‘˜ (๐‘ƒ(๐‘˜) โ†’ ๐‘ƒ(๐‘˜ + 1))
๏œ ๏€ข ๐‘› ๐‘ƒ(๐‘›)
Base Case
1. Prove P(0)
2. Let k be an arbitrary integer โ‰ฅ 0
Inductive Hypothesis
3. Assume that P(k) is true
4. ...
Inductive Step
5. Prove P(k+1) is true
6. P(k) ๏‚ฎ P(k+1)
Direct Proof Rule
7. ๏€ข k (P(k) ๏‚ฎ P(k+1))
Intro ๏€ข from 2-6
8. ๏€ข n P(n)
Induction Rule 1&7
Conclusion
1 + 2 + 4 + 8 + โ‹ฏ+ 2n
โ€ข
โ€ข
โ€ข
โ€ข
โ€ข
1
1+2
1+2+4
1+2+4+8
1 + 2 + 4 + 8 + 16
=1
=3
=7
= 15
= 31
Can we describe the pattern?
1 + 2 + 4 + โ‹ฏ + 2n = 2n+1 โ€“ 1
proving 1 + 2 + 4 + โ‹ฏ + 2n = 2n+1 โ€“ 1
โ€ข We could try proving it normallyโ€ฆ
โ€“ We want to show that 1 + 2 + 4 + โ‹ฏ + 2n = 2n+1.
โ€“ So, what do we do now? We can sort of explain the pattern,
but thatโ€™s not a proofโ€ฆ
โ€ข We could prove it for n=1, n=2, n=3, โ€ฆ
(individually), but that would literally take foreverโ€ฆ
inductive proof in five easy steps
Proof:
1. โ€œWe will show that P(n) is true for every n โ‰ฅ 0 by induction.โ€
2. โ€œBase Case:โ€ Prove P(0)
3. โ€œInductive Hypothesis:โ€
Assume P(k) is true for some arbitrary integer k โ‰ฅ 0โ€
4. โ€œInductive Step:โ€ Want to prove that P(k+1) is true:
Use the goal to figure out what you need.
Make sure you are using I.H. and point out where you are using it.
(Donโ€™t assume P(k+1) !)
5. โ€œConclusion: Result follows by induction.โ€
proving 1 + 2 + โ€ฆ + 2n = 2n+1 โ€“ 1
proving 1 + 2 + โ€ฆ + 2n = 2n+1 โ€“ 1
1. Let P(n) be โ€œ1 + 2 + โ€ฆ + 2n = 2n+1 โ€“ 1โ€. We will show P(n) is true for all
natural numbers by induction.
2. Base Case (n=0): 20 = 1 = 2 โ€“ 1 = 20+1 โ€“ 1
3. Induction Hypothesis: Suppose that P(k) is true for some
arbitrary k โ‰ฅ 0.
4. Induction Step:
Goal: Show P(k+1), i.e. show 1 + 2 + โ€ฆ + 2k + 2k+1 = 2k+2 โ€“ 1
1 + 2 + โ€ฆ + 2k = 2k+1 โ€“ 1 by IH
Adding 2k+1 to both sides, we get:
1 + 2 + โ€ฆ + 2k + 2k+1 = 2k+1 + 2k+1 โ€“ 1
Note that 2k+1 + 2k+1 = 2(2k+1) = 2k+2.
So, we have 1 + 2 + โ€ฆ + 2k + 2k+1 = 2k+2 โ€“ 1, which is
exactly P(k+1).
5. Thus P(k) is true for all k โˆˆโ„•, by induction.
another example of a pattern
โ€ข
โ€ข
โ€ข
โ€ข
โ€ข
โ€ข
20
22
24
26
28
โ‹ฏ
โˆ’
โˆ’
โˆ’
โˆ’
โˆ’
1
1
1
1
1
=
=
=
=
=
1 โˆ’ 1 = 0 = 3โ‹…0
4 โˆ’ 1 = 3 = 3โ‹…1
16 โˆ’ 1 = 15 = 3 โ‹… 5
64 โˆ’ 1 = 63 = 3 โ‹… 21
256 โˆ’ 1 = 255 = 3 โ‹… 85
prove: 3 โˆฃ 22๐‘› โˆ’ 1 for all ๐‘› โ‰ฅ 0
For all ๐‘› โ‰ฅ 1: 1 + 2 + โ‹ฏ + ๐‘› =
๐‘›
๐‘–=1 ๐‘–
=
๐‘› ๐‘›+1
2
checkerboard tiling
Prove that a 2n ๏‚ด 2n checkerboard with one square removed
can be tiled with:
checkerboard tiling
Prove that a 2n ๏‚ด 2n checkerboard with one square removed
can be tiled with:
prove: ๐‘›๐‘› โ‰ฅ ๐‘›! for all ๐‘› โ‰ฅ 1