chapter 3: elementary number theory and methods of proofmth314/w08/slides/chapter3.pdf · • we...

87
Chapter 3: Elementary Number Theory And Methods of Proof January 27, 2008

Upload: others

Post on 26-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Chapter 3: Elementary Number Theory AndMethods of Proof

January 27, 2008

Page 2: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Outline

1 3.1 Direct Proof and Counterexample I: Introduction

2 3.3 Direct Proof and Counterexample III: Divisibility

3 3.4 Direct Proof and Counterexample IV: Division into Casesand the Quotient-Remainder Theorem

4 3.5 Direct Proof and Counterexample V: Floor and Ceiling

5 3.6 Indirect Argument: Contradiction and Contraposition

6 3.8 The Euclidean Algorithm

Page 3: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• In this Chapter, we will investigate some properties of theset of integers Z and the set of rational numbers (quotientsof integers) Q

• At the same time, we will try to apply some of the methodsfor proving statements which we have learned in Chapters1 and 2.

Page 4: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• We will start by giving some basic definitions of numbertheory which will be used repeatedly in the rest of thischapter.

DefinitionAn integer is even if, and only if, n is two times some integer.An integer n is odd if, and only if, it is two times some integerplus 1.

n is even ⇔ ∃ an integer k such that n = 2kn is odd ⇔ ∃ an integer k such that n = 2k + 1

Page 5: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Examples

(a) 34 is an even integer

34 = 2 · 17

(b) -157 is an odd integer

−157 = 2 · (−79) + 1

(c) 0 is an even integer0 = 2 · 0

(d) For any integers m, n, the integer 4m3n2 is even, since

4m3n2 = 2(2m3n2)

(e) For any two integers m and n, the integer 6m + 4n2 + 5 isodd, since

6m + 4n2 + 5 = 2(3m + 2n2 + 2) + 1

Page 6: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

DefinitionAn integer n is prime if, and only if, n > 1 and for all positiveintegers k and m, if

n = k ·m

then k = 1 or m = 1. An integer n is composite if, and only if,n > 1 and,

n = k ·m

for some k 6= 1 and m 6= 1.

n is prime ⇔ ∀ positive integers k , m, if n = k ·m → k = 1 orm = 1

n is composite ⇔ ∃ positive integers k , m such that n = k ·mand k 6= 1, m 6= 1

Page 7: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Proving Existential Statements

• Suppose we are given a statement of the form

∃x ∈ D such that P(x)

• Remember that this statement is true if, and only if,

P(x) is true for at least one x ∈ D

• So, in order to prove this statement, we need to find onesuch x ∈ D which will make P(x) true.

• Another way to prove such a statement is to give a method(algorithm) for finding such an x .

• Both these methods for proving the truth of an existentialstatement are called constructive proofs of existence

Page 8: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Examples

(a) Prove the following: ∃ an even integer n that can be writtenin two ways as a sum of two prime numbers.

(b) Suppose m and n are two integers. Prove the following: ∃an integer k such that 14m + 26n2 = 2k

Solution:(a) Let n = 10, then

10 = 3 + 710 = 5 + 5

(b) Since 14m + 26n2 = 2(7m + 13n2), we can take

k = 7m + 13n2

Page 9: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• Proofs of existential statements can also benonconstructive. In that case, we show only that an xsatisfying P(x) must exist without actually exhibiting it orgiving a “recipe” (algorithm) as to how to find it.

• Also, a nonconstructive proof can also be done bycontradiction: we assume that such an x ∈ D does notexist and show that this assumption leads to somethingobviously false.

Page 10: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Disproving Universal Statements byCounterexample

• Suppose we want to disprove a universal statement of theform

∀x ∈ D, if P(x) then Q(x)

• To do this, we look at the negation of this statement

∃x ∈ D such that P(x) and not Q(x)

• Therefore, we have to show that the negation, which is anexistential statement, is true and, as we have seen, thatamounts to finding an example of x ∈ D for which P(x) istrue and Q(x) is false.

• This is the method of disproof by counterexample

Page 11: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleDisprove the following statement by giving a counterexample

For all integers m and n, if 2m + n is odd, then m and n areboth odd.

Solution To disprove the statement, we need to find integers mand n such that 2m + n is odd, and not both m and n are odd.Statement: ∀ integers m and n, if 2m + n is odd, then both mand n are odd.Counterexample: Let m = 2 and n = 1, then 2m + n = 5which is odd, but not both m and n are odd integers.

Page 12: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Proving a Universal Statement

• Most of mathematical theorems are universal statementsand are generally in the form

∀x ∈ D, if P(x) then Q(x)

• If D is a finite set, we can prove such a statement by themethod of exhaustion; i.e. by listing all elements of D andchecking, one by one, that the universal statement is truefor all of them.

Page 13: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleUse the method of exhaustion to prove the following statement:

For each integer n such that 1 ≤ n ≤ 10, n2 − n + 11 is a primenumber.

Solution:

12 − 1 + 11 = 11 22 − 2 + 11 = 1332 − 3 + 11 = 17 42 − 4 + 11 = 2352 − 5 + 11 = 31 62 − 6 + 11 = 4172 − 7 + 11 = 53 82 − 8 + 11 = 6792 − 9 + 11 = 83 102 − 10 + 11 = 101

So, the statement has been proved by method of exhaustion.

Page 14: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• More often than not, we have to prove a universalstatement when the domain is infinite (e.g., the set of allintegers, or real numbers). In that case, the method ofexhaustion will not work.

• The most powerful method for proving a universalstatement is he method of generalizing from the genericparticular.

Method of generalizing From the Generic Particular: To showthat every element of a domain satisfies a certain property,suppose x is a particular, but arbitrarily chosen element ofthe domain, and show that x satisfies the required property.

Page 15: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleYou ask a person to pick any number, add 5, multiply by 4,subtract 6, divide by 2, and subtract twice the original number.Then you tell them that the final result is 7. Why does this “trick”work?Solution: Let x be the number that the other person has picked.So, x will be a particular, but arbitrarily chosen integer.

Pick a number. xAdd 5. x + 5Multiply by 4. 4x + 20Subtract 6. 4x + 14Divide by 2. 2x + 7Subtract twice the original number. 7

Page 16: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• If the method of generalizing from the generic particular isapplied to a universal sentence

∀x ∈ D, if P(x) then Q(x)

we get the method of direct proof.• We pick a particular but arbitrary x ∈ D such that P(x) is

true and try to show that x also satisfies Q(x).

Page 17: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Method of Direct Proof

1 Express the statement to be proved as

∀x ∈ D, if P(x) then Q(x)

2 Start the proof by assuming that x is a particular butarbitrarily chosen element of D which satisfies thehypothesis P(x).

3 Show that the conclusion Q(x) is true by using definitions,previously proved facts, basic algebraic laws, and rules oflogical inference from Chapters 1 and 2.

Page 18: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleProve that the sum of two even integers is even.Solution: We start by expressing what is to be proved as auniversal statement:

∀ integers m and n, if m and n are even, then m + n is even.

We start the proof by assuming that m and n are particular butarbitrarily chosen integers, which are both even.By definition, that means that we can write m and n in aparticular way:

m = 2r , for some integer rn = 2s, for some integer s

(We have to use two different letters r and s, since they may bedistinct integers, and we should not assume otherwise.)

Page 19: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Our goal is to show that m + n is even. This will be the case, ifwe can show that m + n is two times some integer.

m + n = 2r + 2s = 2(r + s)

Finally, since r and s are integers themselves, so is their sumr + s, which shows that m + n is even.

Page 20: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremThe sum of any two even integers is even.

Proof.Suppose m and n are [particular but arbitrarily chosen] evenintegers. [We must have that m + n is even] By definition ofeven, m = 2r and n = 2s, for some integers r and s. Then

m + n = 2r + 2s (by substitution)= 2(r + s) (by factoring out 2)

Let k = r + s. Note that k is an integer because it is a sum oftwo integers. Therefore,

m + n = 2k where k is an integer

It follows, by definition, that m + n is even [What is preciselywhat we wanted to show.]

Page 21: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Guidelines for writing Proofs1 Copy the statement of the theorem that you want to prove

before writing out the actual proof.2 Clearly mark the beginning of the proof with “Proof:”3 label all the variables that you will be using, explain what

kind of objects they represent, by saying e.g. “suppose x isa positive real number...”, “let m be an even integer...”

4 Use complete sentences; avoid using mathematicalsymbols only since the proof becomes difficult to follow. Areadable proof balances the use of the plain language andmathematical symbols well.

5 Justify each step in your proof by either appealing to ahypothesis, definition, or whatever else you are allowed touse. This also helps you catch errors in your reasoning.

6 Use words such as “therefore”, “so”, “hence”, etc, to makeclear what conclusion you are drawing from previous stepsof the proof.

Page 22: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Common Mistakes1 Proof by example: a universal statement cannot be

proved by giving an example. What works for a particularchoice of values of variables may not work for some otherchoices.

2 Incorrect variable use: don’t use the same variable nametwice for two different variables. [As explained earlier, inour proof we could not assume that m = 2r , n = 2r , sincem and n need not be equal.]

3 Jumping to a conclusion: do not make unwarrantedassumptions (even if they may be true)

4 Begging the question: do not assume the result, whetherexplicitly, or implicitly.

5 Misuse of the word if : do not use if if you mean since orbecause

6 Arguing from false premises: do not assume somethingwhich is not true; as we know, false statement implies bothtrue and false statements.

Page 23: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Disproving an Existential Statement

• In order to disprove an existential statement, we need toprove its negation, which is a universal statement.

ExampleProve that the following statement is false:

There exists an integer n such that 6n2 + 27 is prime.

Solution: We need to prove that the negation

For all integers n, 6n2 + 27 is not prime.

Page 24: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ClaimThe statement “There exists an integer n such that 6n2 + 27 isprime.” is false.

Proof.Suppose n is any integer. We can factor 6n2 + 27 as

6n2 + 27 = 3(2n2 + 9)

Clearly, 2n2 + 9 is an integer and 2n2 + 9 > 1. Therefore,6n2 + 27 is a positive integer greater than 1, and it factors into aproduct of two integers greater than 1. Therefore,

6n2 + 27 is not prime, for all integers n.

Page 25: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Divisibility

DefinitionIf n and d are integers, then

n is divisible by d if, and only if, n = dk , for some integer k .

We also say that n is a multiple of d , or that d is a factor of n, orthat d is a divisor of n, etc.We use the notation d |n to indicate that d divides n.If n and d 6= 0 are integers,

d |n ⇔ ∃k ∈ Z such that n = dk

Page 26: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Examples

(a) 12 divides −156 since

−156 = 12 · (−13)

(b) any integer d divides 0, since

0 = d · 0

(c) the only divisors of 1 are 1 and −1(d) if a and b are any integers, then 12a + 54b − 6 is divisible

by 6, since

12a + 54b − 6 = 6(2a + 9b − 1)

and 2a + 9b − 1 is an integer.

Page 27: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• The divisibility of integers was defined in terms of anexistential statement

d |n ⇔ ∃k ∈ Z such that n = dk

• To state what it means for an integer not to be divisible byanother integer, we use the negation, which is a universalstatement:

∀k , d ∈ Z, d - n ⇔ nd is not an integer.

ExampleIt is not the case that 7|73, since 73

7 is not an integer.

Page 28: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleProve that for all integers a, b, and c, if a|b and b|c, then a|c.Solution: We start by assuming that a, b, and c are threeparticular but arbitrarily chosen integers such that

a|b and b|c

We want to show that a|c, which means that c is a product of awith some integer.Since a|b,

b = ar , for some integer r

Also, since b|c, we have that

c = bs, for some integer s

Page 29: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Then,

c = bs, (by an earlier equation)= (ar)s, (by an earlier equation)= a(rs), (by associativity of multiplication)

Since r and s are integers, so is their product. By definition ofdivisibility, that means that

a|c

which is what we wanted to prove.

Page 30: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Theorem(Transitivity of Divisibility) For all integers a, b, and c, if adivides b and b divides c, then a divides c.

Proof.Suppose a, b, and c are integers such that a divides b and bdivides c. By definition of divisibility,

b = ar and c = bs

for some integers r and s.By substitution,

c = bs= (ar)s= a(rs) (by associativity)

Let k = rs. Thenc = ak

and a divides c by definition of divisibility.

Page 31: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Theorem(Divisibility by a Prime) Any integer n > 1 is divisible by a primenumber.Proof Suppose n is an integer that is greater than 1. If n isprime, then n is divisible by a prime number (itself), and we aredone. If n is not prime, then

n = r0s0

where r0 and s0 are integers such that

1 < r0, s0 < n

By definition of divisibility,

r0|n

Page 32: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

If r0 is a prime number, then r0 is a prime that divides n and weare done. If r0 is not prime, then we can write it as

r0 = r1s1

where 1 < r1, s1 < r0. Again,

r1|r0

If r1, then r1 is a prime number that divides r0 and therefore itdivides n, so we are done in that case. If r1 is not prime, then itfactors as

r1 = r2s2

where 1 < r2, s2 < r1.If r2 is prime, then we are done, since r2 divides r1 and r1divides n, etc.

Page 33: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

We can continue in this way, factoring successive factors of n.In that way, we get a strictly decreasing sequence of positiveintegers between 1 and n:

n > r0 > r1 > r2 > . . . > rk−1 > rk > 1

and each ri in this sequence divides n.Since this cannot go on forever, eventually, rk will become aprime number which divides n.

Page 34: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Counterexamples and DivisibilityProperties

ExampleIs the following statement true?

For all integers a, b, and c, if a|bc then a|b or a|c.

Solution: We will show that this statement is false by finding acounterexample.Statement: For all integers a, b, and c, if a|bc then a|b or a|c.Counterexample: Let a = 6, b = 2, and c = 3. Then

a|bc since 6|2 · 3 but a - b and a - c

(since 6 - 2 and 6 - 3).Therefore, the statement is false.

Page 35: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

The Unique Factorization Theorem

• One of the most important theorems in the basic numbertheory is the unique factorization theorem for integers,which is also known as the fundamental theorem ofarithmetic.

• This theorem was proved by Gauss in 1801.• What the theorem is saying is that every positive integer

greater than 1 can be factored into a product of primes in,essentially, a unique way; e.g

36 = 2 · 2 · 3 · 3 = 2 · 3 · 2 · 3 = 2 · 3 · 3 · 2= 3 · 3 · 2 · 2 = 3 · 2 · 2 · 3 = 3 · 2 · 3 · 2

However, all these factorizations are basically the same;they only differ in the ordering of the prime factors.

Page 36: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Theorem(Unique Factorization Theorem; Fundamental Theorem ofArithmetic) Given any integer n > 1, there exists a positiveinteger k, distinct prime numbers p1, p2,. . . , pk , and positiveintegers e1, e2, . . . , ek such that

n = pe11 pe2

2 pe33 . . . pek

k ,

and any other way of writing n as a product of prime numbers isidentical to this one except, perhaps, for the order in which thefactors are written.

DefinitionGiven an integer n > 1, the standard factored form of n is

n = pe11 pe2

2 pe33 . . . pek

k ,

where k is a positive integers, p1, p2, . . . , pk are prime numbersand e1, e2, . . . ek are positive integers.

Page 37: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleWrite 3675 in standard form.Solution:

3675 = 5 · 735= 5 · 5 · 147= 5 · 5 · 3 · 49= 5 · 5 · 3 · 7 · 7

So, the standard form of 3675 is

3675 = 31 · 52 · 72.

Page 38: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleSuppose m is an integer such that

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

Does 17|m?Solution: Since 17 is one of the prime factors on the right-handside of the equation, it must be a prime factor of the left-handside (by the Unique Factorization Theorem)Since it is not a prime number of any of the factors 8,7,6,. . . , 2,it must be a prime factor of m.Therefore,

17|m

Page 39: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

The Quotient-Remainder Theorem

• Suppose we want to divide 17 by 3.• We can visualize that in the following way: given 17

objects, we need to partition them into groups of 3 objectseach with, possibly, a left-over pile which may containfewer than 3 objects (0, 1, or 2).

∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗ ∗∗

• We can write that in the following way:

17 = 5 · 3 + 2

Page 40: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Theorem(The Quotient-Remainder Theorem) Given any integer n and apositive integer d, there exist unique integers q and r such that

n = dq + r and 0 ≤ r < d

Notice that, since r is a non-negative integer, dq ≤ n, so whenwe apply the theorem to a negative n, we have to take that intoaccount.

Page 41: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExamplesApply the Quotient-Remainder Theorem to the following pairsof integers:(a) n = 62, d = 7

62 = 7 · 8 + 6, q = 8, r = 6

(b) n = −62, d = 7

−62 = 7 · (−9) + 1, q = −9, r = 1

(c) n = 62, d = 75

62 = 75 · 0 + 62, q = 0, r = 62

Page 42: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

div and mod Functions

DefinitionGiven a non-negative integer n and a positive integer d

n div d = the integer quotient q when n is divided by dn mod d = the integer remainder r when n is divided by d

In other words,

n div d = q and n mod d = r ⇔ n = dq + r

where q and r are integers and 0 ≤ r < d .

Page 43: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Most of standard programming languages (C++, Java, Pascal,etc) have built-in functions that compute mod and div given anon-negative integer n and a positive integer d . For example, inC++, these functions are called / and %.

ExampleCompute 62 div 7 and 62 mod 7.Solution: Since

62 = 8 · 7 + 6,

we have62 div 7 = 8, 62 mod 7 = 6

Page 44: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleSuppose today is Wednesday and you know that neither thisyear nor the next year are leap years. What day of the week willit be in 342 days time?Solution: Suppose we label the days of the week as follows:0-Sunday, 1-Monday, 2-Tuesday, . . . , 6-Saturday.Given that today is Wednesday, we have to determine what dayof the week the number

3 + 342 = 345

will correspond to.To do that, we look for the remainder 345 gives when divided by7:

345 mod 7 = 2

So, in 342 days it will be Tuesday.

Page 45: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Representations of Integers

• We have seen that, given any integer n and any positiveinteger d , we can represent n as

n = dq + r

for some integer q and some 0 ≤ r < d• For d = 2, we have the following:

n = 2q + r , 0 ≤ r < 2

which is the same as

n = 2q + 0 or n = 2q + 1

• This proves what we already know: every integer is eithereven or odd. This is called the parity property.

Page 46: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremAny two consecutive integers have opposite parity.Proof. Suppose that we have chosen two arbitrary consecutiveintegers. Call them n and n + 1.We know, by the parity property, that either n is even or n isodd. [We will break the proof into two cases, based on thesetwo possibilities]Case 1 (n is even): Then, n = 2k , for some integer k . Then,

n + 1 = 2k + 1

and, by definition, that means that n + 1 is odd, which provesthe theorem.

Page 47: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Case 2 (n is odd): Here, n = 2k + 1, for some integer k . Bysubstitution,

n + 1 = (2k + 1) + 1 = 2k + 2 = 2(k + 1)

Since k + 1 is an integer, by definition, n + 1 will be an eveninteger. So, the statement of the theorem is true in this case.Therefore, regardless of which case occurs for n, whether it iseven or odd, the theorem is true.

Page 48: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleShow that every integer can be written in one of the four forms

n = 4q, n = 4q + 1, n = 4q + 2, n = 4q + 3

for some integer q.Solution: Given any n, we apply the Quotient-RemainderTheorem to n and d = 4:

n = 4q + r , 0 ≤ r < 4

By listing all possibilities for r (r = 0, 1, 2, 3), we see that n hasone of the four forms

n = 4q, n = 4q + 1, n = 4q + 2, n = 4q + 3

for some integer q.

Page 49: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleProve that the square of any odd integer has the form 8m + 1,for some integer m.Solution: We need to show the following:

∀ odd integers n ∃ integer m such that n2 = 8m + 1

We can start by choosing an arbitrary odd integer n. Since n isodd, we can write it as

n = 2k + 1, for some k

Then,n2 = (2k + 1)2 = 4k2 + 4k + 1

We want to show that we can find an integer m such that

4k2 + 4k + 1 = 8m + 1 ⇒ 4k2 + 4k = 8m ⇒ k2 + k = 2m

But, it may be difficult to show that k2 + k has to be even... Wewill try a different approach.

Page 50: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremThe square of any odd integer has the form 8m + 1 for someinteger m.Proof. Suppose n is an arbitrary odd integer. By theQuotient-Remainder Theorem, n can be written in one of thefour forms

4q, 4q + 1, 4q + 2, 4q + 3

for some integer q. Since n is odd, it cannot have either of theforms 4q or 4q + 2 (since they are both even). Therefore,

n = 4q + 1 or n = 4q + 3

Case 1 (n = 4q + 1): In this case

n2 = (4q + 1)2 (substitution)

= 16q2 + 8q + 1

= 8(2q2 + q) + 1

here, we can take m = 2q2 + q, which proves the statement ofthe theorem:

n2 = 8m + 1

Page 51: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Case 2 (n = 4q + 3): Since n = 4q + 3,

n2 = (4q + 3)2 (substitution)

= 16q2 + 24q + 9

= 16q2 + 24q + 8 + 1

= 8(2q2 + 3q + 1) + 1

Therefore, the statement of the theorem has been proved inthis case, as well.We have proved that, for any odd integer n,

n2 = 8m + 1

for some integer m. �

Page 52: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Floor and Ceiling Functions

DefinitionGiven any real number x , the floor of x , denoted bxc, is definedas:

bxc = the unique integer n such that n ≤ x < n + 1.

I.e.bxc = n ⇔ n ≤ x < n + 1

Page 53: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

DefinitionGiven any real number x , the ceiling of x , denoted dxe, isdefined as:

dxe = the unique integer n such that n − 1 < x ≤ n.

I.e.dxe = n ⇔ n − 1 < x ≤ n

Page 54: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Examples

(a)b17/4c = 4, d17/4e = 5

(b)b3c = 3, d3e = 3

(c)b−32/5c = −7, d−32/5e = −6

Page 55: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleBoxes, each capable of holding 36 units, are used to ship aproduct from the manufacturer to a wholesaler. Express thenumber of boxes that would be required to ship n units of theproduct using either the floor or the ceiling notation. Which oneis more appropriate?Solution: We need either

bn/36c+ 1

ordn/36e

boxes.Obviously, the ceiling notation is more convenient here.

Page 56: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleIf n is an integer, what are

bnc and bn +12c?

Solution:bnc = n, bn +

12c = n

Page 57: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleIs the following statement true or false?

For all real numbers x and y , bx + yc = bxc+ byc.

Solution: This statement is false. We will try to find acounterexample that will disprove it.Statement: ∀x ∈ R ∀y ∈ R bx + yc = bxc+ bycCounterexample: let x = 0.5, y = 0.5. then

bx + yc = b0.5 + 0.5c = b1c = 1bxc+ byc = b0.5c+ b0.5c = 0 + 0 = 0

Page 58: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Similarly, one can find a counterexample which shows that

dx − ye 6= dxe − dye

(Exercise.)

Page 59: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremFor all real numbers x and all integers m, bx + mc = bxc+ m.

Proof.Suppose a real number x and an integer m are given. Supposebxc = n, which means

n ≤ x < n + 1

Add m to all sides of this inequality:

n + m ≤ x + m < n + m + 1

Since n + m is an integer, by definition of the floor function:

bx + mc = n + m

which is the same as

bx + mc = bxc+ m

Page 60: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremFor any integer n,

bn2c =

{ n2 , if n is evenn−1

2 , if n is odd

Proof. Suppose n is an arbitrary integer. We will break theproof into two cases, depending on the parity of n.Case 1 (n is odd): Then, n = 2k + 1, for some integer k . Then,

bn2c = b2k + 1

2c = b2k

2+

12c = bk +

12c = k

The right-hand side will be

n − 12

=(2k + 1)− 1

2= k

. Therefore,bn

2c =

n2

for this case.

Page 61: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Case 2 (n is even): Since n = 2k , for some integer k :

bn2c = b2k

2c = bkc = k

and the right-hand side is

n2

=2k2

= k

This proves the statement of the theorem in this case.�

Page 62: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• The Quotient-Remainder Theorem can be expressed interms of the floor function:

n = dq + r , 0 ≤ r < d

• We will show that

q = bndc, r = n − dbn

dc

or:

n div d = bndc, n mod d = n − dbn

dc.

Page 63: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremIf n is a non-negative integer and d is a positive integer, and ifq = bn/dc and r = n − dbn/dc, then

n = dq + r , 0 ≤ r < d

Proof. Suppose n is a non-negative integer, d is a positiveinteger, and q = bn/dc, r = n − dbn/dc.

dq + r = dbndc+ (n − dbn

dc) = n.

So, we only need to show that 0 ≤ r < d . But, q = bn/dc, so bydefinition of the floor function:

q ≤ nd

< q + 1

Page 64: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Then,dq ≤ n < (q + 1)d = dq + d

(we multiplied the inequalities by d).Therefore, after we subtract dq from all sides:

0 ≤ n − dq < d

But,r = n − dbn

dc = n − dq,

so0 ≤ r < d (by substitution)

Page 65: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Method of Proof by Contradiction

1 Suppose that the statement you want to prove is false. Inother words, assume that the negation of the statement tobe proved is true.

2 Show that this assumption logically leads to acontradiction.

3 Conclude that the assumption that the original statementthat we want to prove is true.

Page 66: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ExampleProve by contradiction that there is no greatest integer.Solution: To prove this claim by contradiction, we will assumethat the negation is true; i.e. that there exists a greatest integer.

TheoremThere is no greatest integer.

Proof.Suppose that the there is a greatest integer, call it N. Considerthe number M = N + 1. This number is an integer, being a sumof two integers. However,

M > N

which contradicts our assumption that N is the largest integer.Therefore, our assumption is false and we have proved thatthere is no largest integer.

Page 67: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremThere is no integer that is both even and odd.Proof. We will prove this statement by contradiction. Supposethat there is an integer, call it n which is both even and odd. Bydefinition,

n = 2m, for some integer mn = 2k + 1, for some integer k

Then,

2m = 2k + 1 ⇒ 2m − 2k = 1 ⇒ 2(m − k) = 1

Since m and k are integers, m − k must be an integer.

Page 68: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

However, we have shown that

m − k =12

which is a contradiction.Therefore, no integer can be both even and odd.

Page 69: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• Recall that we have defined the set of all rational numbersQ as the set of all real numbers that can be represented asquotients of integers.

• For example, every integer is a rational number, since

n =n1

as well as a multitude of other real numbers(1

2 ,−73 , 0.1 = 1

10 , etc)• We add, subtract, and multiply the rational numbers in the

usual way:

ab

+cd

=ad + bc

bd,

ab− c

d=

ad − bcbd

,ab· c

d=

acbd

• There are real numbers (√

2, π, e, etc) which cannot bewritten as quotients of integers. We call such numbersirrational.

Page 70: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremThe sum of any rational number and any irrational number isirrational.Proof Suppose this is not the case. Let r be a rational numberand s an irrational number such that r + s is a rational number.Since r is rational,

r =ab

for some integers a and b. Then

r + s =ab

+ s =cd

for some integers c and d (we are assuming that r + s isrational).

Page 71: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Then,

s =cd− a

b=

bc − adbd

but that would mean that s is rational (both bc − ad and bd areintegers!), which is a contradiction.By contradiction, we have shown that the sum of a rational andan irrational number must be irrational.

Page 72: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Argument by Contraposition

1 Express the statement to be proved as

∀x ∈ D, if P(x) then Q(x)

2 Rewrite this statement as

∀x ∈ D, if ∼ Q(x) then ∼ P(x)

3 Prove this contrapositive statement using a direct proof.(Suppose x is an arbitrarily chosen generic element of D,assume ∼ Q(x) and try to derive ∼ P(x)).

Page 73: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

ClaimFor all integers n, if n2 is even, then n is even.

Proof.We will prove this by contraposition. Suppose n is an oddinteger.

n = 2k + 1, for some k ∈ Z

By substitution,

n2 = (2k + 1)2 = 4k2 + 4k + 1 = 2(2k2 + 2k) + 1

Since 2k2 + 2k is an integer,

n2 = 2 · (integer) + 1

which shows that n2 is an odd integer.

Page 74: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• This claim can also be proved differently, by contradiction.

ClaimFor all integers n, if n2 is even, then n is even.Proof. We will assume that the claim is false; i.e. that itsnegation is true:

There exists an integer n such that n2 is even and n is odd.

So assume n is an odd integer whose square is even.

Page 75: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Since n is odd,

n = 2k + 1, for some k ∈ Z

Then,

n2 = (2k + 1)2 = 4k2 + 4k + 1 = 2(2k2 + 2k) + 1

Since 2k2 + 2k is an integer, by definition, n2 is an odd integer.This is a contradiction, since we have assumed that n2 is even.Therefore, if n2 is even, then so is n.

Page 76: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Theorem√2 is an irrational number.

Proof. We will prove this by contradiction.Suppose

√2 is a rational number:

√2 =

mn

where m and n are integers. We can also assume that m and nhave no common factors; i.e. that the fraction has beenreduced as much as possible.By squaring both sides:

2 =m2

n2

which is equivalent tom2 = 2n2.

Page 77: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

By definition, this means that m2 is an even integer. By theprevious claim, m must be an even integer, too. Therefore,

m = 2k , for some k ∈ Z

By substitution,

m2 = (2k)2 = 4k2 = 2n2.

If we divide this equality by 2, we get

n2 = 2k2

So, n2 is even, and by the previous claim, n is also even.Therefore, both m and n are even integers, which contradictsour assumption that m and n have no common factors.Thus,

√2 is an irrational number.

Page 78: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Greatest Common Divisor

DefinitionSuppose a and b are both non-zero integers. the greatestcommon divisor of a and b, denoted gcd(a, b) is the integer dwhich has the following properties:

1 d is a common divisor of a and b:

(d | a) ∧ (d | b)

2 Any other common divisor c of a and b is not larger than d :

∀c ∈ Z (c | a ∧ c | b → c ≤ d)

Page 79: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Examples

(a) gcd(4, 5) = 1(b) gcd(3, 6) = 3(c) gcd(12, 15) = 3(d) gcd(374, 110) =? Since

374 = 2 · 11 · 17110 = 2 · 5 · 11

gcd(3714, 110) = 2 · 11 = 22(e) gcd(3743323, 11012456) =???

We will try to find a more efficient way of finding this gcdthen to try to factor both numbers into prime factors.

Page 80: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

LemmaIf r is a positive integer, then gcd(r , 0) = r .

Proof.Suppose r is a positive integer. Since r divides both itself and0, it is a common divisor of both numbers. What we need toshow is that r is the greatest such divisor.If k is an integer larger than r , then it cannot divide r , so itcannot be a common divisor of both r and 0 either.Therefore,

gcd(r , 0) = r

Page 81: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

LemmaIf an integer d divides two integers a and b, then d | b − a.Proof. We are trying to prove:

∀a, b, d ∈ Z, (d | a ∧ d | b → d | b − a)

Let a, b, and d be integers such that

d | a and d | b

Since d | a and d | b, then there are integers k and m such that

a = kd , b = md

Then, by substitution,

b − a = md − kd = (m − k)d

Page 82: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

Since m − k is an integer, by definition of divisibility:

d | b − a

Page 83: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

LemmaIf a and b are any integers with b 6= 0 and q and r arenon-negative integers such that

a = bq + r

thengcd(a, b) = gcd(b, r)

Proof. Let a and b be two integers with b 6= 0 and q and rnon-negative integers such that

a = bq + r .

Let d = gcd(a, b). We will try to show that

d = gcd(b, r)

as well.Since d is the g.c.d. of a and b, d divides both a and b, and,therefore, a and bq.

Page 84: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

By the previous lemma,

d | a − bq = r

Thus, d divides both b and r , so it is their common divisor. Wenow need to show that it is the largest such integer.Suppose c is some common divisor of b and r . Then,

c | b ∧ c | r ⇒ c | (bq + r) = a

and c will be a common divisor of a and b.Since d is assumed to be gcd(a, b), we must have

c ≤ d .

So,d = gcd(b, r).

Page 85: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

TheoremFor all integers m and n, where m 6= 0,

gcd(m, n) = gcd(m, n mod m)

Proof.Suppose m and n are integers, such that m 6= 0 and

n = mq + r

Then,n mod m = r

and we have already shown that

gcd(m, n) = gcd(m, r)

Page 86: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

The Euclidean Algorithm for Findinggcd(a, b)

int gcd(a, b) {If a = b = 0, (no gcd) return ERROR.If a = b return a.If a = 0 return b.If b = 0 return a.If a > b return gcd(b, a mod b).Else return gcd(a, b mod a).

}

Page 87: Chapter 3: Elementary Number Theory And Methods of Proofmth314/W08/Slides/Chapter3.pdf · • We will start by giving some basic definitions of number theory which will be used repeatedly

• Note that this algorithm is recursive; a recursive algorithmis one that calls itself during its execution.

ExampleTrace the execution of the above algorithm in findinggcd(124, 3120).Solution:

a = 124 b = 3120 3120 mod 124 = 20 return gcd(124, 20)a = 124 b = 20 124 mod 20 = 4 return gcd(20, 4)a = 20 b = 4 20 mod 4 = 0 return gcd(4, 0)a = 4 b = 0 return 4