Discrete Mathematics: Proof by Induction and Set Sizes
Today's topics cover proof by induction, set sizes equality, and paying with 3 and 5 cent coins in a discrete math class. Learn about the theorems and techniques used to prove sets are of equal size.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Clicker frequency: CA CSE 20 DISCRETE MATH Prof. Shachar Lovett http://cseweb.ucsd.edu/classes/wi15/cse20-a/
Todays topics Proof by induction: Set sizes equality Paying using 3 and 5 cent coins Section 3.6 in Jenkyns, Stephenson
Set sizes We saw last time the following theorem, useful to prove that two sets have equal size Theorem: let X,Y be finite sets. Assume there is a function ?:? ? which is both one-to-one and onto. Then |X|=|Y|. We will prove it using induction on |X|.
Set sizes Theorem: let X,Y be finite sets. Assume there is a function ?:? ? which is both one-to-one and onto. Then |X|=|Y|. Prove by induction on n=|X|.
Set sizes Theorem: let X,Y be finite sets. Assume there is a function ?:? ? which is both one-to-one and onto. Then |X|=|Y|. Prove by induction on n=|X|. Base case: n=0, so ? = . If Y is not empty, then f is not onto, so we must have Y = and hence |X|=|Y|=0.
Set sizes Theorem: let X,Y be finite sets. Assume there is a function ?:? ? which is both one-to-one and onto. Then |X|=|Y|. Prove by induction on n=|X|. Base case: n=0, so ? = . If Y is not empty, then f is not onto, so we must have Y = and hence |X|=|Y|=0. Inductive step: assume it is true for all sets of size n. Prove it is true when |X|=n+1.
Set sizes Inductive step: let |?| = ? + 1. Choose ? ? and let ? = ? ? ?. Define: ? = ? {? },? = ? {? }. We have ? = ?. We will prove that ? = ? and hence ? = ? + 1. First, we claim that ? ? ,? ? ? . If this is false for some ? ? , then since ? ? ? we must have ? ? ? ? = ? , so ? ? = ? = ? ? which is impossible since f is one-to-one. So, we can define ? :? ? by ? ? = ? ? . It is one-to-one because f is, and is onto because they only element missing is ? ? which is not in ? . Hence we can apply the inductive assumption and conclude that ? = ? and hence ? = ? + 1.
3-cent and 5-cent coins We will prove the following theorem Theorem: For all prices p 8 cents, the price p can be paid using only 5-cent and 3-cent coins 1851-1889 1866-today
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 price p=____. Inductive step: Assume [or Suppose ] that WTS that So the inductive step holds, completing the proof.
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 price p=________. Inductive step: Assume [or Suppose ] that A. 0 cents B. 1 cent C. 2 cents D. 3 cents E. Other/none/more than one WTS that So the inductive step holds, completing the proof.
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 price p=8. Inductive step: Assume [or Suppose ] that WTS that So the inductive step holds, completing the proof.
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 price p=8. Inductive step: Assume [or Suppose ] that A. Theorem is true for p=8. B. Theorem is true for some p>8. C. Theorem is true for some p 8. D. Theorem is true for some p>0. E. Theorem is true for all p>8. WTS that So the inductive step holds, completing the proof.
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 price p=8. Inductive step: Assume [or Suppose ] that theorem is true for some p 8. WTS that So the inductive step holds, completing the proof.
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 price p=8. Inductive step: Assume [or Suppose ] that theorem is true for some p 8. WTS that A. Theorem is true for p=8. B. Theorem is true for some p>8. C. Theorem is true for p+1. D. Theorem is true for p+8. So the inductive step holds, completing the proof.
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 price p=8. Inductive step: Assume [or Suppose ] that theorem is true for some p 8. WTS that theorem is true for price p+1. So the inductive step holds, completing the proof.
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 price p=8. Inductive step: Assume [or Suppose ] that theorem is true for some p 8. WTS that theorem is true for price p+1. ??? So the inductive step holds, completing the proof.
3-cent and 5-cent coins Inductive step: Assume price p 8 can be paid using only 3-cent and 5-cent coins. Need to prove that price p+1 can be paid using only 3-cent and 5- cent coins. Main idea: reduce from price p+1 to price p.
Making change If we have 100 5-cent coins, and 100 3-cent coins (for a total of p = $8.00), how can we modify the number of 5- cent and 3-cent coins so that we can make the p+1 price (p+1 = $8.01)? A. 40 5-cent coins + 200 3-cent coins B. 39 5-cent coins + 202 3-cent coins C. 99 5-cent coins + 102 3-cent coins
Making change If we have 100 5-cent coins, and 100 3-cent coins (for a total of p = $8.00), how can we modify the number of 5- cent and 3-cent coins so that we can make the p+1 price (p+1 = $8.01)? A. 40 5-cent coins + 200 3-cent coins B. 39 5-cent coins + 202 3-cent coins C. 99 5-cent coins + 102 3-cent coins
Turning our modification scheme into a generic algorithm If we have n 5-cent coins, and m 3-cent coins (for a total of p = 5n+3m), how can we modify the number of 5-cent and 3-cent coins so that we can make the p+1 price (p+1 = 5n+3m+1)? A. n+1 5-cent coins + m-2 3-cent coins B. n-1 5-cent coins + m+2 3-cent coins C. n+1 5-cent coins + m+2 3-cent coins D. No generic way
Turning our modification scheme into a generic algorithm If we have n 5-cent coins, and m 3-cent coins (for a total of p = 5n+3m), how can we modify the number of 5-cent and 3-cent coins so that we can make the p+1 price (p+1 = 5n+3m+1)? A. n+1 5-cent coins + m-2 3-cent coins B. n-1 5-cent coins + m+2 3-cent coins C. n+1 5-cent coins + m+2 3-cent coins D. No generic way
What if we dont have any 5-cent coins to subtract?? If we have 0 5-cent coins, and m 3-cent coins (for a total of p = 3m), how can we modify the number of 5-cent and 3-cent coins so that we can make the p+1 price (p+1 = 3m+1)? A. You can t B. You can [explain to your group how]
What if we dont have any 5-cent coins to subtract?? If we have 0 5-cent coins, and m 3-cent coins (for a total of p = 3m), how can we modify the number of 5-cent and 3-cent coins so that we can make the p+1 price (p+1 = 3m+1)? Remove three 3-cent coins, add two 5-cent So: two 5-cent coins, m-3 3-cent points, for a total of 2*5+3*(m-3)=3m+1=p+1
That algorithm relies on being able to subtract three 3-cent coins. What if we don t have that many? (only 1 or 2?) A. Uh-oh, our proof can not work as we ve done it so far B. That could never happen [explain why not] C. That could happen, and we need to make a 3rd (or more) case(s) to handle it
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 p 8. WTS that the theorem holds for p+1. p 8. Assume that p=5n+3m where n,m 0 are integers. We need to show that p+1=5a+3b for integers a,b 0. Partition to cases: Case I: n 1. In this case, p+1=5*(n-1)+3*(m+2). Case II: m 3. In this case, p+1=5*(n+2)+3*(m-3). Case III: n=0 and m 2. Then p=5n+3m 6 which is a contradiction to p 8. So the inductive step holds, completing the proof.
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 x=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
Algorithm pseudo-code PayWithThreeCentsAndFiveCents: Input: price p 8. Output: integers n,m 0 so that p=5n+3m 1. Let x=8, n=1, m=1 (so that x=5n+3m). 2. While x<p: a) x:=x+1 b) If n 1, set n:=n-1, m:=m+2 c) Otherwise, set n:=n+2, m:=m-3 3. Return (n,m)
Algorithm pseudo-code PayWithThreeCentsAndFiveCents: Input: price p 8. Output: integers n,m 0 so that p=5n+3m 1. Let x=8, n=1, m=1 (so that x=5n+3m). 2. While x<p: a) x:=x+1 b) If n 1, set n:=n-1, m:=m+2 c) Otherwise, set n:=n+2, m:=m-3 3. Return (n,m) Invariant: x=5n+3m Invariant: x=5n+3m We proved that n,m 0 in this process always; this is not immediate from the algorithm code
Algorithm run example x=8: n=1, m=1 While x<p: a) b) c) 8= Invariant: x=5n+3m x:=x+1 If n 1, set n:=n-1, m:=m+2 Otherwise, set n:=n+2, m:=m-3 9= 10 = 11= 12 =
Algorithm properties Theorem: Algorithm uses at most two nickels (i.e n 2) Proof: by induction on p Try to prove it yourself first! x=8: n=1, m=1 While x<p: a) b) c) Invariant: x=5n+3m x:=x+1 If n 1, set n:=n-1, m:=m+2 Otherwise, set n:=n+2, m:=m-3
x=8: n=1, m=1 While x<p: a) b) c) Invariant: x=5n+3m Algorithm properties x:=x+1 If n 1, set n:=n-1, m:=m+2 Otherwise, set n:=n+2, m:=m-3 Theorem: Algorithm uses at most two nickels (i.e n 2). Proof: by induction on p Base case: p=8. Algorithm outputs n=m=1. Inductive hypothesis: p=5n+3m where n 2. WTS p+1=5a+3b where a 2. Proof by cases: Case I: n 1. So p+1=5(n-1)+3(m+2) and a=n-1 2. Case II: n=0. So p+1=5*2+3(m-3). a=2. In both cases p+1=5a+3b where a 2. QED
Next class Strong induction Read section 3.6.1 in Jenkyns, Stephenson