View
0
Download
0
Category
Preview:
Citation preview
Extensible Networking Platform 11 - CSE 240 – Logic and Discrete Mathematics
Announcements
• Homework 3 was due this morning
• Exam 1 is in one week! – Proofs– Logical equivalence– Sets– Basic induction
• On Wednesday we will review for the exam
• Read Section 3.2 (Growth of Functions), 5.4-5.5 (Recursive Algorithms and Program correctness) by Wednesday
Extensible Networking Platform 22 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Famous Identities
Identity
Domination
Idempotent
A Ç U = AA U Æ = A
A U U = UA ÇÆ = Æ
A U A = AA Ç A = A
Extensible Networking Platform 33 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Famous Identities
• Excluded Middle
• Uniqueness
• Double complement
A U A = U
A Ç A = Æ
A = A
Extensible Networking Platform 44 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Famous Identities
• Commutativity
• Associativity
• Distributivity
A U B =
(A U B) U C =
A Ç B =B U A B Ç A
(A Ç B) Ç C =
A U (B U C)
A Ç (B Ç C)
A U (B Ç C) =
A Ç (B U C) =
(A U B) Ç (A U C)
(A Ç B) U (A Ç C)
Extensible Networking Platform 55 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Famous Identities
• DeMorgan�s I
• DeMorgan�s II
A B
Hand waving is good for
intuition, but we aim for a more formal proof.
(A U B) = A Ç B
(A Ç B) = A U B
Extensible Networking Platform 66 - CSE 240 – Logic and Discrete Mathematics
Set Theory – 4 Ways to prove identities
• Show that A Í B and that B Ê A.
• Use a membership table.
• Use previously proven identities.
• Use logical equivalences to prove equivalent set definitions.
Like truth tables
Like º
Not hard, a little tedious
Extensible Networking Platform 77 - CSE 240 – Logic and Discrete Mathematics
Set Theory – 4 Ways to prove identities
Prove that
1. (Í) (x Î A U B) ® (x Ï A U B) ®
(x Ï A and x Ï B) ® (x Î A Ç B)
2.( ) (x Î A Ç B) ® (x Ï A and x Ï B)
® (x Ï A U B) ® (x Î A U B)
(A U B) = A Ç B
⊇
Extensible Networking Platform 88 - CSE 240 – Logic and Discrete Mathematics
Set Theory – 4 Ways to prove identities
Prove that using a membership table.
0 : x is not in the specified set1 : otherwise
(A U B) = A Ç B
A B A B A Ç B A U B A U B
1 1 0 0 0 1 01 0 0 1 0 1 00 1 1 0 0 1 00 0 1 1 1 0 1
Haven’t we seen this before?
Extensible Networking Platform 99 - CSE 240 – Logic and Discrete Mathematics
Set Theory – 4 Ways to prove identities
Prove that using logically equivalent set definitions.
(A U B) = A Ç B
(A U B) = {x : ¬(x Î A v x Î B)}
= {x : ¬(x Î A) Ù ¬(x Î B)}
= A Ç B
= {x : (x Î A) Ù (x Î B)}
Extensible Networking Platform 1010 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Generalized Union
€
Ai
i=1
n
= A1∪ A2∪…∪ An
Ex. Let U = N, and define:
€
Ai = {x : ∃k > 1, x = ki,k ∈ Ν}
A1 = {2,3,4,…}A2 = {4,6,8,…}A3 = {6,9,12,…}
Extensible Networking Platform 1111 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Generalized Union
€
Ai
i=1
n
= A1∪ A2∪…∪ An
Ex. Let U = N, and define:
€
Ai = {x : ∃k > 1, x = ki,k ∈ Ν}
Then
€
Ai
i= 2
∞
= ?a) Primesb) Compositesc) Æd) Ne) I have no clue.
primes
Extensible Networking Platform 1212 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Generalized Intersection
€
Ai
i=1
n
= A1∩ A2∩…∩ An
Ex. Let U = N, and define:
€
Ai = {x : ∃k, x = ki,k ∈ Ν}
A1 = {1,2,3,4,…}A2 = {2,4,6,…}A3 = {3,6,9,…}
Extensible Networking Platform 1313 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Generalized Intersection
€
Ai
i=1
n
= A1∩ A2∩…∩ An
Ex. Let U = N, and define:
€
Ai = {x : ∃k, x = ki,k ∈ Ν}
Then
€
Ai
i=1
n
= ? Multiples of LCM(1,…,n)
Extensible Networking Platform 1414 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Inclusion/Exclusion
Example:How many people are wearing a watch?How many people are wearing sneakers?
How many people are wearing a watch OR sneakers?
AB|A È B| = |A| + |B| - |A Ç B|
Extensible Networking Platform 1515 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Inclusion/Exclusion
Example:There are 83 cs majors.40 are taking cs240.31 are taking cs101.22 are taking both.
How many are taking neither?
83 - (40 + 31 - 22) = 34
4031
Extensible Networking Platform 1616 - CSE 240 – Logic and Discrete Mathematics
Set Theory - Generalized Inclusion/Exclusion
Suppose we have:
And I want to know |A U B U C|
A B
C
|A U B U C| = |A| + |B| + |C|
+ |A Ç B Ç C| - |A Ç B| - |A Ç C| - |B Ç C|
Extensible Networking Platform 1717 - CSE 240 – Logic and Discrete Mathematics
Review: Mathematical Induction
Use induction to prove that the sum of the first n odd integers is n2.
Prove a base case (n=1)
Base case (n=1): the sum of the first 1 odd integer is 12. Yes, 1 = 12. Prove P(k)®P(k+1)
Assume P(k): the sum of the first k odd ints is k2. 1 + 3 + … + (2k - 1) = k2
Prove that 1 + 3 + … + (2k - 1) + (2k + 1) = (k+1)2
Inductive hypothesis
1 + 3 + … + (2k-1) + (2k+1) = k2 + (2k + 1) By inductive hypothesis
= (k+1)2By arithmetic
Extensible Networking Platform 1818 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - a cool example
Deficient TilingA 2n x 2n sized grid is deficient if all but
one cell is tiled.
2n
2n
Extensible Networking Platform 1919 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - a cool example
• We want to show that all 2n x 2n sized deficient grids can be tiled with tiles, called triominoes, shaped like:
Extensible Networking Platform 2020 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - a cool example
• Is it true for all 21 x 21 grids?
Yes!
Extensible Networking Platform 2121 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - a cool example
Inductive Hypothesis:We can tile any 2k x 2k deficient board
using our fancy designer tiles.
Use this to prove:We can tile any 2k+1 x 2k+1 deficient
board using our fancy designer tiles.
Extensible Networking Platform 2222 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - a cool example
2k
2k 2k
2k
2k+1
OK!! (by IH)
?
?
?
Extensible Networking Platform 2323 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - a cool example
2k
2k 2k
2k
2k+1
OK!! (by IH)
OK!! (by IH)
OK!! (by IH)
OK!! (by IH)
Extensible Networking Platform 2424 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - a cool example
Extensible Networking Platform 2525 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - a cool example
Extensible Networking Platform 2626 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - why does it work?
Definition:A set S is �well-ordered� if every non-empty
subset of S has a least element.
Given (we take as an axiom): the set of natural numbers (N) is well-ordered.
Is the set of integers (Z) well ordered?No.
{ x Î Z : x < 0 } has no least element.
Extensible Networking Platform 2727 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - why does it work?
Is the set of non-negative reals (R) well ordered?
No. { x Î R : x > 1 } has no
least element.
Extensible Networking Platform 2828 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - why does it work?
Proof of Mathematical Induction:
We prove that (P(0) Ù ("k P(k) ® P(k+1))) ® ("n P(n))
Proof by contradiction.Assume1. P(0)2. "k P(k) ® P(k+1)3. ¬"n P(n) $n ¬P(n)
Extensible Networking Platform 2929 - CSE 240 – Logic and Discrete Mathematics
Mathematical Induction - why does it work?
Assume1. P(0)2. "n P(n) ® P(n+1)3. ¬"n P(n) $n ¬P(n)
Let S = { n : ¬P(n) } Since N is well ordered, S has a least element. Call it k.
What do we know?-P(k) is false because it’s in S.-k ¹ 0 because P(0) is true.-P(k-1) is true because P(k) is the least element in S.
But by (2), P(k-1) ® P(k). ContradictsP(k-1) true, P(k) false.
Done.
Extensible Networking Platform 3030 - CSE 240 – Logic and Discrete Mathematics
Strong Mathematical Induction
IfP(0) and"n³0 (P(0) Ù P(1) Ù … Ù P(n)) ® P(n+1)
Then"n³0 P(n) In our proofs, to show P(k+1), our inductive
hypothesis assumes that ALL of P(0), P(1), … P(k) are true, so we can use ANY
of them to make the inference.
Extensible Networking Platform 3131 - CSE 240 – Logic and Discrete Mathematics
Game with Matches
• Two players take turns removing any number of matches from one of two piles of matches. The player who removes the last match wins
• Show that if two piles contain the same number of matches initially, then the second player is guaranteed a win
Extensible Networking Platform 3232 - CSE 240 – Logic and Discrete Mathematics
Strategy for Second Player• Let P(n) denote the statement �the second player wins
when they are initially n matches in each pile�
• Basis step: P(1) is true, because only 1 match in each pile, first player must remove one match from one pile. Second player removes other match and wins
• Inductive step: suppose P(j) is True for all j 1<=j <= k.
• Prove that P(k+1) is true, that is the second player wins when each piles contains k+1 matches
Extensible Networking Platform 3333 - CSE 240 – Logic and Discrete Mathematics
Strategy for Second Player
• Suppose that the first player removes r matches from one pile, leaving k+1 –r matches there
• By removing the same number of matches from the other pile the second player creates the situation of two piles with k+1-r matches in each. Apply the inductive hypothesis and the second player wins each time.
How is this different than
regular induction?
Extensible Networking Platform 3434 - CSE 240 – Logic and Discrete Mathematics
Postage Stamp Example
• Prove that every amount of postage of 12 cents or more can be formed using just 4-cent and 5-cent stamps
• P(n) : Postage of n cents can be formed using 4-cent and 5-cent stamps
• All n >= 12, P(n) is true
Extensible Networking Platform 3535 - CSE 240 – Logic and Discrete Mathematics
Postage Stamp Proof• Base Case: n = 12, n = 13, n = 14, n = 15
– We can form postage of 12 cents using 3, 4-cent stamps– We can form postage of 13 cents using 2, 4- cent stamps and 1
5-cent stamp– We can form postage of 14 cents using 1, 4-cent stamp and 2 5-
cent stamps– We can form postage of 15 cents using 3, 5-cent stamps
• Induction Step– Let n >= 15– Assume P(k) is true for 12 <= k <= n, that is postage of k cents
can be formed with 4-cent and 5-cent stamps (Inductive Hypothesis)
– Prove P(n+1)– To form postage of n +1 cents, use the stamps that form
postage of n-3 cents (from I.H) with a 4-cent stamp
Why doesthis work?
Extensible Networking Platform 3636 - CSE 240 – Logic and Discrete Mathematics
Recursive Definitions
We completely understand the function f(n) = n!, right?
As a reminder, here�s the definition:n! = 1 · 2 · 3 · … · (n-1) · n, n ³ 1
Inductive (Recursive) Definition
But equivalently, we could define it like this:
Recursive Case
Base Case îíì
=³-•
= 0 n if 1
1n if )!1(! nnn
Extensible Networking Platform 3737 - CSE 240 – Logic and Discrete Mathematics
Recursive Definitions
Another VERY common example:
Fibonacci Numbers
Recursive Case
Base Cases
ïî
ïí
ì
>-+-==
=1 if )2()1(1 if 10 if 0
)(nnfnfnn
nf
Is there a non-recursive definition for the Fibonacci
Numbers?
€
f (n) =15
1+ 52
"
# $
%
& '
n
−1− 52
"
# $
%
& '
n)
* + +
,
- . .
Recommended