22
CS322 Week 4 - Monday

Week 4 - Monday. What did we talk about last time? Rational numbers

Embed Size (px)

Citation preview

Page 1: Week 4 - Monday.  What did we talk about last time?  Rational numbers

CS322Week 4 - Monday

Page 2: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Last time

What did we talk about last time? Rational numbers

Page 3: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Questions?

Page 4: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Logical warmup An epidemic has struck the Island of Knights and Knaves

Sick Knights always lie Sick Knaves always tell the truth Healthy Knights and Knaves are unchanged

During the epidemic, a Nintendo Wii was stolen There are only three possible suspects: Jacob, Karl, and Louie They are good friends and know which one actually stole the Wii Here is part of the trial's transcript:

Judge (to Jacob): What do you know about the theft? Jacob: The thief is a Knave Judge: Is he healthy or sick? Jacob: He is healthy Judge( to Karl): What do you know about Jacob? Karl: Jacob is a Knave. Judge: Healthy or sick? Karl: Jacob is sick.

The judge thought a while and then asked Louie if he was the thief. Based on his yes or no answer, the judge decided who stole the Wii.

Who was the thief?

Page 5: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Divisibility

Page 6: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Definition of divisibility If n and d are integers, then n is divisible by d if

and only if n = dk for some integer k Or, more formally: For n, d Z,

n is divisible by d k Z n = dk We also say:

n is a multiple of d d is a factor of n d is a divisor of n d divides n

We use the notation d | n to mean "d divides n"

Page 7: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Examples

Is 37 divisible by 3? Is -7 a factor of 7? Does 6 | 256? Is 0 a multiple of 45?

Page 8: Week 4 - Monday.  What did we talk about last time?  Rational numbers

More on divisors

If a,b Z and a | b, is a ≤ b? Not necessarily!

But, if a,b Z+ and a | b, then a ≤ b

Which integers divide 1? If a,b Z, is 3a + 3b divisible by 3? If k,m Z, is 10km divisible by 5?

Page 9: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Transitivity of divisibility

Prove that for all integers a, b, and c, if a | b and b | c, then a | c

Steps: Rewrite the claim in formal notation Write Proof: State your premises Justify every line you infer from the

premises Write QED after you have demonstrated

the conclusion

Page 10: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Prove or disprove:

For all integers a and b, if a | b and b | a, then a = b

How could we change this statement so that it is true?

Then, how could we prove it?

Page 11: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Unique factorization theorem For any integer n > 1, there exist a

positive integer k, distinct prime numbers p1, p2, …, pk, and positive integers e1, e2, …, ek such that

And any other expression of n as a product of prime numbers is identical to this except, perhaps, for the order in which the factors are written

kek

eee ppppn ...321321

Page 12: Week 4 - Monday.  What did we talk about last time?  Rational numbers

An application of the unique factorization theorem Let m be an integer such that

8∙7 ∙6 ∙5 ∙4 ∙3 ∙2 ∙m = 17∙16 ∙15 ∙14 ∙13 ∙12 ∙11 ∙10

Does 17 | m? Leave aside for the moment that we

could actually compute m

Page 13: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Quotient Remainder Theorem and Proof by Cases

Page 14: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Proof by cases If you have a premise consisting of clauses

that are ANDed together, you can split them up Each clause can be used in your proof

What if clauses are ORed together? You don't know for sure that they're all true In this situation, you use a proof by cases Assume each of the individual possibilities is

true separately If the proof works out in all possible cases, it

still holds

Page 15: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Proof by cases formatting For a direct proof using cases, follow the

same format that you normally would When you reach your cases, number

them clearly Show that you have proved the

conclusion for each case Finally, after your cases, state that, since

you have shown the conclusion is true for all possible cases, the conclusion must be true in general

Page 16: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Quotient-remainder theorem For any integer n and any positive integer d,

there exist unique integers q and r such that n = dq + r and 0 ≤ r < d

This is a fancy way of saying that you can divide an integer by another integer and get a unique quotient and remainder

We will use div to mean integer division (exactly like / in Java )

We will use mod to mean integer mod (exactly like % in Java)

What are q and r when n = 54 and d = 4?

Page 17: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Even and odd As another way of looking at our earlier

definition of even and odd, we can apply the quotient-remainder theorem with the divisor 2

Thus, for any integer n n = 2q + r and 0 ≤ r < 2

But, the only possible values of r are 0 and 1 So, for any integer n, exactly one of the

following cases must hold: n = 2q + 0 n = 2q + 1

We call even or oddness parity

Page 18: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Consecutive integers have opposite parity Prove that, given any two

consecutive integers, one is even and the other is odd

Hint Divide into two cases: The smaller of the two integers is even The smaller of the two integers is odd

Page 19: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Another proof by cases

Theorem: for all integers n, 3n2 + n + 14 is even

How could we prove this using cases?

Be careful with formatting

Page 20: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Upcoming

Page 21: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Next time…

Indirect proof Classic results:

Irrationality of the square root of 2 Infinitude of primes

Page 22: Week 4 - Monday.  What did we talk about last time?  Rational numbers

Reminders

Exam 1 is next Monday Review is Friday

Read sections 4.6 and 4.7