Lecture18 – Strong induction
Download
Report
Transcript Lecture18 – Strong induction
Peer Instruction in Discrete
Mathematics by Cynthia Leeis licensed
under a Creative Commons AttributionNonCommercial-ShareAlike 4.0
International License.
Based on a work
at http://peerinstruction4cs.org.
Permissions beyond the scope of this
license may be available
at http://peerinstruction4cs.org.
CSE 20 –
Discrete
Mathematics
Dr. Cynthia Bailey Lee
Dr. Shachar Lovett
2
Today’s Topics:
1.
2.
3.
Quick wrap-up of Monday’s coin example
Strong vs regular induction
Strong induction examples:
Divisibility by a prime
Recursion sequence: product of fractions
3
Thm: For all prices p >= 8 cents, the price p can be paid using
only 5-cent and 3-cent coins.
Proof (by mathematical induction):
Basis step: Show the theorem holds for p=8 (by example, e.g. p=3+5)
Inductive step:
Assume [or “Suppose”] that the theorem holds for some p8.
WTS that the theorem holds for p+1.
p8.
Assume that p=5n+3m where n,m0 are integers.
We need to show that p+1=5a+3b for integers a,b0.
Partition to cases:
Case I: n1. In this case, p+1=5*(n-1)+3*(m+2).
Case II: m3. In this case, p+1=5*(n+2)+3*(m-3).
Case III: n=0 and m2. Then p=5n+3m6 which is a
contradiction to p8.
So the inductive step holds, completing the proof.
4
We created an algorithm!
Our
proof actually allows us to
algorithmically find a way to pay p using
3-cent and 5-cent coins
Algorithm
for price p:
start with 8=3+5
For x=8...p, in each step adjust the number
of coins according to the modification rules
we’ve constructed to maintain price x
5
Algorithm pseudo-code
PayWithThreeCentsAndFiveCents:
Input: price p8.
Output: integers n,m0 so that p=5n+3m
1.
2.
Let x=8, n=1, m=1 (so that x=5n+3m).
While x<p:
a)
b)
c)
3.
x:=x+1
If n1, set n:=n-1, m:=m+2
Otherwise, set n:=n+2, m:=m-3
Return (n,m)
6
Algorithm pseudo-code
PayWithThreeCentsAndFiveCents:
Input: price p8.
Output: integers n,m0 so that p=5n+3m
1.
Let x=8, n=1, m=1 (so that x=5n+3m).
2.
While x<p:
a)
b)
c)
3.
x:=x+1
If n1, set n:=n-1, m:=m+2
Otherwise, set n:=n+2, m:=m-3
Return (n,m)
Invariant: x=5n+3m
Invariant: x=5n+3m
We proved that n,m0 in this process
always; this is not immediate from
the algorithm code
7
Algorithm run example
x=8: n=1, m=1
While x<p:
Invariant: x=5n+3m
a) x:=x+1
b) If n1, set n:=n-1, m:=m+2
c) Otherwise, set n:=n+2, m:=m-3
8=
9=
10
=
11=
12
=
8
Algorithm properties
Theorem:
Algorithm uses at most two nickels
(i.e n2)
Proof:
by induction on p
Try to prove it yourself first!
x=8: n=1, m=1
While x<p:
Invariant: x=5n+3m
a) x:=x+1
b) If n1, set n:=n-1, m:=m+2
c) Otherwise, set n:=n+2, m:=m-3
9
x=8: n=1, m=1
While x<p:
Invariant: x=5n+3m
a) x:=x+1
b) If n1, set n:=n-1, m:=m+2
c) Otherwise, set n:=n+2, m:=m-3
Algorithm properties
Theorem: Algorithm uses at most two nickels (i.e n2).
Proof: by induction on p
Base case: p=8. Algorithm outputs n=m=1.
Inductive hypothesis: p=5n+3m where n2.
WTS p+1=5a+3b where a2.
Proof by cases:
Case I: n1. So p+1=5(n-1)+3(m+2) and a=n-12.
Case II: n=0. So p+1=5*2+3(m-3). a=2.
In both cases p+1=5a+3b where a2. QED
10
2. Strong induction
examples
DIVISIBILITY BY A PRIME
11
Strong vs regular induction
Prove:
n1 P(n)
Base case: P(1)
Regular induction: P(n)P(n+1)
P(1)
Strong
P(2)
P(3)
…
P(n)
P(n+1)
…
induction: (P(1)…P(n))P(n+1)
Can use more assumptions to prove P(n+1)
P(1)
P(2)
P(3)
…
P(n)
P(n+1)
…
12
Example for the power of
strong induction
Theorem: For all prices p >= 8 cents, the price p
can be paid using only 5-cent and 3-cent coins
Proof:
Base case: 8=3+5, 9=3+3+3, 10=5+5
Assume it holds for all prices 1..p-1, prove for price
p when p11
Proof: since p-38 we can use the inductive
hypothesis for p-3. To get price p simply add
another 3-cent coin.
Much easier than standard induction!
13
3. Strong induction
examples
DIVISIBILITY BY A PRIME
14
Definitions and properties for
this proof
Definitions:
Prime or Composite exclusivity:
All integers greater than 1 are either prime or
composite (exclusive or—can’t be both).
Definition of divisible:
n is prime if a, b : n ab a 1 b 1
n is composite if n=ab for some 1<a,b<n
n is divisible by d iff n = dk for some integer k.
2 is prime (you may assume this; it also follows from
the definition).
15
Definitions and properties for
this proof (cont.)
Goes
without saying at this point:
The set of Integers is closed under
addition and multiplication
Use algebra as needed
16
Thm: For all integers n greater than 1, n is divisible by a prime
number.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n = ________.
Inductive step:
Assume [or “Suppose”] that
WTS that
So the inductive step holds, completing the proof.
17
Thm: For all integers n greater than 1, n is divisible by a prime
number.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n = ________.
Inductive step:
Assume [or “Suppose”] that
WTS that
A.
B.
C.
D.
E.
So the inductive step holds, completing the proof.
0
1
2
3
Other/none/more
than one
18
Thm: For all integers n greater than 1, n is divisible by a prime
number.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n = 2.
Inductive step:
Assume [or “Suppose”] that
WTS that
A. For some integer n>1, n is
divisible by a prime number.
B. For some integer n>1, k is
divisible by a prime number, for
all integers k where 2kn.
C. Other/none/more than one
So the inductive step holds, completing the proof.
19
Thm: For all integers n greater than 1, n is divisible by a prime
number.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n = 2.
Inductive step:
Assume [or “Suppose”] that
For some integer n>1, k is divisible by a prime number, for all integers k where
2kn.
WTS that
A. n+1 is divisible by a prime
number.
B. k+1 is divisible by a prime
number.
C. Other/none/more than one
So the inductive step holds, completing the proof.
20
Thm: For all integers n greater than 1, n is divisible by a prime
number.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n=2.
Inductive step:
Assume that for some n2, all integers 2kn are divisible by a prime.
WTS that n+1 is divisible by a prime.
Proof by cases:
Case 1: n+1 is prime. n+1 divides itself so we are done.
Case 2: n+1 is composite. Then n+1=ab with 1<a,b<n+1. By the
induction hypothesis, since an there exists a prime p which
divides a. So p|a and a|n+1. We’ve already seen that this
implies that p|n+1 (in exam – give full details!)
So the inductive step holds, completing the proof.
21
2. Strong induction
examples
RECURSION SEQUENCE: PRODUCT OF FRACTIONS
22
Definitions and properties for
this proof
Product
less than one:
Algebra,
etc., as usual
Definition of the sequence:
d1 = 9/10
d2 = 10/11
dk = (dk-1)(dk-2) for all integers k3
23
Thm: For all integers n>0, 0<dn<1.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n = ________.
Inductive step:
Assume [or “Suppose”] that
WTS that
So the inductive step holds, completing the proof.
Definition of the sequence:
d1 = 9/10
d2 = 10/11
dk = (dk-1)(dk-2) for all integers k3
24
Thm: For all integers n>0, 0<dn<1.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n = ________.
Inductive step:
Assume [or “Suppose”] that
WTS that
So the inductive step holds, completing the proof.
A.
B.
C.
D.
E.
0
1
2
3
Other/none/more
than one
Definition of the sequence:
d1 = 9/10
d2 = 10/11
dk = (dk-1)(dk-2) for all integers k3
25
Thm: For all integers n>0, 0<dn<1.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n = 1,2.
Inductive step:
Assume [or “Suppose”] that
WTS that
A. For some int n>2, 0<dn<1.
B. For some int n>2, 0<dk<1, for all
integers k where 3kn.
C. Other/none/more than one
So the inductive step holds, completing the proof.
Definition of the sequence:
d1 = 9/10
d2 = 10/11
dk = (dk-1)(dk-2) for all integers k3
26
Thm: For all integers n>0, 0<dn<1.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n = ________.
Inductive step:
Assume [or “Suppose”] that
theorem holds for n2
WTS that
A. For some int n>0, 0<dn<1.
B. For some int n>1, 0<dk<1, for all
integers k where 1kn.
C. 0<dn+1<1
D. Other/none/more than one
So the inductive step holds, completing the proof.
Definition of the sequence:
d1 = 9/10
d2 = 10/11
dk = (dk-1)(dk-2) for all integers k3
27
Thm: For all integers n>0, 0<dn<1.
Proof (by strong mathematical induction):
Basis step: Show the theorem holds for n=1,2.
Inductive step:
Assume [or “Suppose”] that for some int n3, the theorem holds for all int k,
nk 3. (i.e. 0<dk<1 for all k between 3 and n, inclusive)
WTS that 0<dn+1<1.
By definition, dn+1=dn dn-1.
By the inductive hypothesis, 0<dn-1<1 and 0<dn<1.
Hence, 0<dn+1<1.
So the inductive step holds, completing the proof.
28
3. Fibonacci numbers
Verifying a solution
29
Fibonacci numbers
1,1,2,3,5,8,13,21,…
Rule:
F1=1, F2=1, Fn=Fn-2+Fn-1.
Question:
can we derive an expression for the
n-th term?
n
YES!
1 1 5
1 1 5
Fn
2
2
5
5
n
30
Fibonacci numbers
Rule:
F1=1, F2=1, Fn=Fn-2+Fn-1.
We will prove an upper bound:
1 5
Fn r , r
2
n
Proof
by strong induction.
Base case:
A. n=1
B.
C.
D.
E.
n=2
n=1 and n=2
n=1 and n=2 and n=3
Other
31
Fibonacci numbers
Rule:
F1=1, F2=1, Fn=Fn-2+Fn-1.
We will prove an upper bound:
1 5
Fn r , r
2
n
Proof
by strong induction.
Base case: n=1, n=2. Verify by direct
calculation
F1 1 r
F2 1 r 2
32
Fibonacci numbers
Rule:
F1=1, F2=1, Fn=Fn-2+Fn-1.
Theorem:
Base
Fn r n , r
1 5
2
cases: n=1,n=2
Inductive
step: show…
A.
B.
C.
D.
E.
Fn=Fn-1+Fn-2
FnFn-1+Fn-2
Fn=rn
Fn rn
Other
33
Fibonacci numbers
Inductive
What
step: need to show Fn r n, , r 12 5
can we use?
Definition of Fn: Fn Fn2 Fn1
Inductive hypothesis: Fn 1 r n 1 , Fn 2 r n 2
That
is, we need to show that
r n2 r n1 r n
34
Fibonacci numbers
Finishing
the inductive step.
n2
Need to show: r
r n1 r n
Simplifying,
need to show: 1 r r
2
of r 12 5 actually satisfied 1 r r 2
(this is why we chose it!)
Choice
QED
35
Fibonacci numbers - recap
Recursive
definition of a sequence
Base case: verify for n=1, n-2
Inductive step:
Formulated what needed to be shown as
an algebraic inequality, using the definition
of Fn and the inductive hypothesis
Simplified algebraic inequality
Proved the simplified version