17
1 - CSE 240 – Logic and Discrete Mathematics Announcements Homework 2 Due Homework 3 Posted Due next Monday Quiz 2 on Wednesday Read Section 2.1 (Sets), 2.2 (Set Operations) and 5.1 (Mathematical Induction) Exam 1 in two weeks Monday, February 19 th 2 - CSE 240 – Logic and Discrete Mathematics Two ways of proving $x P(x). Either build one, or show one can be built. Two examples, both involving n! For the examples, think of n! as a list of factors. Constructive Non-constructive Existence Proofs

cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 11 - CSE 240 – Logic and Discrete Mathematics

Announcements

• Homework 2 Due

• Homework 3 Posted– Due next Monday

• Quiz 2 on Wednesday

• Read Section 2.1 (Sets), 2.2 (Set Operations) and 5.1 (Mathematical Induction)

• Exam 1 in two weeks– Monday, February 19th

Extensible Networking Platform 22 - CSE 240 – Logic and Discrete Mathematics

Two ways of proving $x P(x).

Either build one, or show one can be built.

Two examples, both involving n!

For the examples, think of n! as a list of factors.

Constructive Non-constructive

Existence Proofs

Page 2: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 33 - CSE 240 – Logic and Discrete Mathematics

Example: Prove that for all positive integers n, there exist n consecutive composite integers.

"n (positive integers), $x so that x, x+1, x+2, … , x+n-1 are all composite.

Proof: Let n be an arbitrary integer.

x = (n + 1)! + 2

Composite = not prime

(n + 1)! + 2 is divisible by 2, \ composite.

(n + 1)! + 3 is divisible by 3, \ composite.

(n + 1)! + (n + 1) is divisible by n + 1, \ composite.

CONSTRUCTIVE

Quantifiers: Existence Proofs

Extensible Networking Platform 44 - CSE 240 – Logic and Discrete Mathematics

Example: Prove that for all integers n, there exists a prime p so that p > n.

"n (integer), $p so that p is prime, and p > n.

Proof: Let n be an arbitrary integer, and consider n! + 1. If (n! + 1) is prime, we are done since (n! + 1) > n. But what if (n! + 1) is composite?

If (n! + 1) is composite then it has a prime factorization, p1p2…pn = (n! + 1)Consider the smallest pi, how small can it be?

Infinitely many primes!

Quantifiers: Existence Proofs

Page 3: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 55 - CSE 240 – Logic and Discrete Mathematics

"n (integers), $p so that p is prime, and p > n.

Proof: Let n be an arbitrary integer, and consider n! + 1. If (n! + 1) is prime, we are done since(n! + 1) > n. But what if (n! + 1) is composite?

If (n! + 1) is composite then it has a prime factorization, p1p2…pn = (n! + 1)

NON-CONSTRUCTIVE

Consider the smallest pi, and call it p. How small can it be?

Can it be 2?Can it be 3?Can it be 4?Can it be n?So, p > n, and we are done. BUT WE DON�T

KNOW WHAT p IS!!!

Quantifiers: Existence Proofs

Extensible Networking Platform 66 - CSE 240 – Logic and Discrete Mathematics

Another Example - Largest Prime Number

Prove by contradiction: There is no largest prime number; that is, there are infinitely many prime numbers.

Proof:Suppose the given conclusion is false; that is, there is a largest prime number

p. So the prime numbers we have are 2,3,5,...,p; assume there are k such primes, p1,p2,..,and pk.

Let x denote the product of all of these prime numbers plus one: x=(2 * 3 * 5... * p)+1. Clearly, x>p.

When x is divided by each of the primes 2,3,5,...,p. we get 1 as the remainder. So x is not divisible by any of the primes. Hence either x must be a prime, or if x is composite then it is divisible by a prime q != p. In either case, there are more than k primes.

But this contradicts the assumption that there are k primes, so our assumption is false. In other words, there is no largest prime number.

From Discrete Mathematics with Applications, by Thomas Koshy

Page 4: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 77 - CSE 240 – Logic and Discrete Mathematics

Existence Proofs• Proof of theorems of the form • Constructive existence proof:

– Find an explicit value of c, for which P(c) is true.– Then is true by Existential Generalization

(EG).

Example: Show that there is a positive integer that can be written as the sum of cubes of positive integers in two different ways:Proof: 1729issuchanumbersince

1729=103 +93 =123 +13

Extensible Networking Platform 88 - CSE 240 – Logic and Discrete Mathematics

Counterexamples

• Recall • To establish that is true (or is

false) find a c such that ¬P(c) is true or P(c) is false. • In this case c is called a counterexample to the

assertion .

Example: “Every positive integer is the sum of the squares of 3 integers.” The integer 7 is a counterexample. So the claim is false.

Page 5: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 99 - CSE 240 – Logic and Discrete Mathematics

Uniqueness Proofs• Some theorems assert the existence of a unique element with a

particular property, $!x P(x). The two parts of a uniqueness proof are

– Existence: We show that an element x with the property exists.– Uniqueness: We show that if y≠x,theny doesnothavetheproperty.

Example: Show that if a and b are real numbers and a ≠0, then there is a unique real number r such that ar + b = 0.

Solution:– Existence: The real number r = −b/a is a solution of ar + b = 0 because

a(−b/a) + b = −b + b =0.– Uniqueness: Suppose that s is a real number such that as + b = 0. Then ar + b = as + b, where r = −b/a. Subtracting b from both

sides and dividing by a shows that r = s.

Extensible Networking Platform 1010 - CSE 240 – Logic and Discrete Mathematics

Proof Strategies for proving p→q

• Choose a method– First try a direct method of proof

– If this does not work, try an indirect method (e.g., try to prove the contrapositive)

• For whichever method you are trying, choose a strategy– First try forward reasoning. Start with the axioms and known

theorems and construct a sequence of steps that end in the conclusion. Start with p and prove q, or start with ¬q and prove ¬p.

– If this doesn’t work, try backward reasoning. When trying to prove q, find a statement r that we can prove with the property p →q.

Page 6: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 1111 - CSE 240 – Logic and Discrete Mathematics

Backward Reasoning Example: Suppose that two people play a game taking turns removing, 1, 2, or 3stones

at a time from a pile that begins with 15 stones. The person who removes the last stone wins the game. Show that the first player can win the game no matter what the second player does.

Proof: Let n be the last step of the game.Step n: Player1 can win if the pile contains 1,2, or 3 stones. Step n-1: Player2 will have to leave such a pile if the pile that he/she is faced with has 4

stones. Step n-2: Player1 can leave 4 stones when there are 5,6, or 7 stones left at the beginning

of his/her turn. Step n-3: Player2 must leave such a pile, if there are 8 stones . Step n-4: Player1has to have a pile with 9,10, or 11 stones to ensure that there are 8 left. Step n-5: Player2 needs to be faced with 12 stones to be forced to leave 9,10, or 11. Step n-6: Player1can leave 12 stones by removing 3 stones.

Now reasoning forward, the first player can ensure a win by removing 3 stones and leaving 12.

Extensible Networking Platform 1212 - CSE 240 – Logic and Discrete Mathematics

Proof and Disproof: Tilings

Example 1: Can we tile the standard checkerboard using dominos?

Solution: Yes! One example provides a constructive existence proof.

The Standard Checkerboard

Two Dominoes

One Possible Solution

Page 7: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 1313 - CSE 240 – Logic and Discrete Mathematics

TilingsExample 2: Can we tile a checkerboard obtained by removing one of the four corner squares of a standard checkerboard?

Solution: • Our checkerboard has 64−1 = 63 squares. • Since each domino has two squares, a board with a

tiling must have an even number of squares.• The number 63 is not even. • We have a contradiction.

Extensible Networking Platform 1414 - CSE 240 – Logic and Discrete Mathematics

Tilings

Example 3: Can we tile a board obtained by removing both the upper left and the lower right squares of a standard checkerboard?

Nonstandard Checkerboard

Dominoes

Page 8: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 1515 - CSE 240 – Logic and Discrete Mathematics

TilingsSolution?:

• There are 62 squares in this board. • To tile it we need 31dominos. • Key fact: Each domino covers one black and one

white square. • Therefore the tiling covers 31 black squares and 31

white squares.• Our board has either 30 black squares and 32

white squares or 32 black squares and 30 white squares.

• Contradiction!

Extensible Networking Platform 1616 - CSE 240 – Logic and Discrete Mathematics

The Role of Open Problems

• Unsolved problems have motivated much work in mathematics. Fermat’s Last Theorem was conjectured more than 300 years ago. It has only recently been finally solved.

Fermat’s Last Theorem: The equation xn + yn = znhas no solutions in integers x, y, and z, with xyz≠0whenever n is an integer with n > 2.

A proof was found by Andrew Wiles in the 1990shttps://www.youtube.com/watch?v=6ymTZEeTjI8

Page 9: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 1717 - CSE 240 – Logic and Discrete Mathematics

An Open Problem• The 3x + 1 Conjecture: Let T be the transformation

that sends an even integer x to x/2and an odd integer x to 3x + 1. For all positive integers x, when we repeatedly apply the transformation T, we will eventually reach the integer 1.

For example, starting with x = 13:

T(13) = 3∙13+1=40,T(40) = 40/2=20,T(20) = 20/2=10,T(10) = 10/2=5,T(5) = 3∙5+1=16,T(16) = 16/2=8,T(8) = 8/2=4,T(4) = 4/2=2,T(2) = 2/2=1

The conjecture has been verified using computers up to 5.6 · 1013

Extensible Networking Platform 1818 - CSE 240 – Logic and Discrete Mathematics

Additional Proof Methods

• Later we will see many other proof methods:– Mathematical induction, which is a useful method

for proving statements of the form "n P(n), where the domain consists of all positive integers.

– Structural induction, which can be used to prove such results about recursively defined sets.

– Cantor diagonalization is used to prove results about the size of infinite sets.

– Combinatorial proofs use counting arguments.

Page 10: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 1919 - CSE 240 – Logic and Discrete Mathematics

To prove a proposition p, assume not p and show a contradiction. (Prove that the sky is blue…Assume that the sky is not blue )

Suppose the proposition is of the form a ® b, and recall that a ® b º ¬a v b º ¬(a Ù ¬b). So assuming the opposite is to assume a Ù ¬b.

• For a conditional, we assume a and prove ¬b• If I study hard, then I will earn an A

– Assume I study hard and I will Not earn an A

Proof Techniques - proof by contradiction

Extensible Networking Platform 2020 - CSE 240 – Logic and Discrete Mathematics

One More Example

• Show that at least 3 of any 25 days chosen must fall in the same month of the year

Page 11: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 2121 - CSE 240 – Logic and Discrete Mathematics

One More Example

• Show that at least 3 of any 25 days chosen must fall in the same month of the year

• Proof by contradiction– Suppose ¬ p

• There are at most 2 days of any 25 days chosen that must fall in the same month of the year

• Because there are 12 months in a year and 2 days could be chosen per month, we have a maximum of 24 days that could be selected. This contradicts choosing from 25 days. Therefore p

Extensible Networking Platform 2222 - CSE 240 – Logic and Discrete Mathematics

Quick Background on Set Theory

A set is an unordered collection of elements.

Some examples:

{1, 2, 3} is the set containing �1� and �2� and �3.�{1, 1, 2, 3, 3} = {1, 2, 3} since repetition is irrelevant.{1, 2, 3} = {3, 2, 1} since sets are unordered.{1, 2, 3, …} is a way we denote an infinite set (in this case, the

natural numbers).Æ = {} is the empty set, or the set containing no elements.

Note: Æ ¹ {Æ}

Page 12: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 2323 - CSE 240 – Logic and Discrete Mathematics

Set Theory - Definitions and notation

x Î S means �x is an element of set S.�x Ï S means �x is not an element of set S.�

A Í B means �A is a subset of B.�

Venn Diagram

or, �B contains A.�or, �every element of A is also in B.�or, "x ((x Î A) ® (x Î B)).

A

B

Extensible Networking Platform 2424 - CSE 240 – Logic and Discrete Mathematics

Set Theory - Cardinality

If S is finite, then the cardinality of S, |S|, is the number of distinct elements in S.

If S = {1,2,3}, |S| = 3If S = {3,3,3,3,3},

If S = Æ,

If S = { 1, {1}, {1,{1}} },

|S| = 1

|S| = 0

|S| = 3

If S = {0,1,2,3,…}, |S| is infinity. (more on this later)

Page 13: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 2525 - CSE 240 – Logic and Discrete Mathematics

Set Theory - Power sets

If S is a set, then the power set of S is 2S = { x : x Í S }.

If S = {a},

aka P(S)

If S = {a,b},

If S = Æ,

If S = {Æ,{Æ}},

We say, “P(S) is the set of all subsets of

S.”

P(S) = 2S = {Æ, {a}}.

2S = {Æ, {a}, {b}, {a,b}}.

2S = {Æ}.

2S = {Æ, {Æ}, {{Æ}}, {Æ,{Æ}}}.

Fact: if S is finite, |P(S)| = 2|S|. (if |S| = n, |P(S)| = 2n)

Extensible Networking Platform 2626 - CSE 240 – Logic and Discrete Mathematics

Set Theory - Operators

The union of two sets A and B is:A È B = { x : x Î A v x Î B}

If A = {Charlie, Lucy, Linus}, and B = {Lucy, Desi}, then

A È B = {Charlie, Lucy, Linus, Desi}

AB

Page 14: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 2727 - CSE 240 – Logic and Discrete Mathematics

On to Mathematical Induction

One rule: Due to peer pressure, if the person �before�you likes Lucky Charms, then you like Lucky Charms.

• Person 1 likes Lucky Charms.

• What can we conclude?Everyone likes Lucky Charms!

• Suppose we want to prove everyone likes Fruit Loops• Need to show two things:

Suggests a proof technique

• Person 1 likes Fruit Loops (FL(1))

• If person k likes Fruit Loops, then person k+1 does too. (FL(k) ® FL(k+1))

"n FL(n)

Extensible Networking Platform 2828 - CSE 240 – Logic and Discrete Mathematics

Mathematical Induction

• Suppose we want to prove everyone likes Fruit Loops• Need to show two things:

• Person 1 likes Fruit Loops (FL(1))

• If person k likes Fruit Loops, then person k+1 does too. (FL(k) ® FL(k+1))

"n FL(n)

• First part is a simple proposition we call the base case.

• Second part is a conditional. Start by assuming FL(k), and show that FL(k+1) follows.

True by “peer pressure”

Page 15: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 2929 - CSE 240 – Logic and Discrete Mathematics

Mathematical Induction

Use induction to prove that the sum of the first n positive 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 3030 - CSE 240 – Logic and Discrete Mathematics

Mathematical Induction

Prove that 1×1! + 2×2! + … + n×n! = (n+1)! - 1, "n

Base case (n=1): 1×1! = (1+1)! - 1?Yes, 1×1! = 1, 2! - 1 = 1

Assume P(k): 1×1! + 2×2! + … + k×k! = (k+1)! - 1Prove that 1×1! + … + k×k! + (k+1)(k+1)! = (k+2)! - 1 Inductive

hypothesis1×1! + … + k×k! + (k+1)(k+1)! = (k+1)! - 1 + (k+1)(k+1)!

= (k+1)! ((k+1) + 1) - 1= (k+1)!(k+2) - 1= (k+2)! - 1

= (k+1)(k+1)! + (k+1)! - 1

Page 16: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 3131 - CSE 240 – Logic and Discrete Mathematics

Mathematical Induction

Prove that if a set S has |S| = n, then |P(S)| = 2n

• Base case (n=0): S=ø, P(S) = {ø} and |P(S)| = 1 = 20

• Assume P(k): If |S| = k, then |P(S)| = 2k

• Prove that if |S�| = k+1, then |P(S�)| = 2k+1

Inductive hypothesis

• S� = S U {a} for some S Ì S� with |S| = k, and a Î S�.

• Partition the power set of S� into the sets containing a and those not.

• We count these sets separately.

Extensible Networking Platform 3232 - CSE 240 – Logic and Discrete Mathematics

Mathematical Induction

• Assume P(k): If |S| = k, then |P(S)| = 2k

• Prove that if |S�| = k+1, then |P(S�)| = 2k+1

• S� = S U {a} for some S Ì S� with |S| = k, and a Î S�.

• Partition the power set of S� into the sets containing a and those not.

• P(S�) = {X : a Î X} U {X : a Ï X}

• P(S�) = {X : a Î X} U P(S)

Since these are all the subsets of elements in S.

Subsets containing a are made by taking any set from P(S), and

inserting an a.

Page 17: cse240 lecture6 2-4-19webtodd/cse240/cse240_lecture6_2-4-19.pdf · Step n: Player1can win if the pile contains 1,2, or 3stones. Step n-1: Player2will have to leave such a pile if

Extensible Networking Platform 3333 - CSE 240 – Logic and Discrete Mathematics

Mathematical Induction

• Assume P(k): If |S| = k, then |P(S)| = 2k

• Prove that if |S�| = k+1, then |P(S�)| = 2k+1

• S� = S U {a} for some S Ì S� with |S| = k, and a Î S�.

• P(S�) = {X : a Î X} U {X : a Ï X}

• P(S�) = {X : a Î X} U P(S)Subsets containing a are made by

taking any set from P(S), and inserting an a.

So |{X : a Î X}| = |P(S)|

• |P(S�)| = |{X : a Î X}| + |P(S)|

= 2 |P(S)|

= 2×2k = 2k+1