Download Chapter 3: Elementary Number Theory And Methods of Proof

Document related concepts

Large numbers wikipedia , lookup

List of first-order theories wikipedia , lookup

List of prime numbers wikipedia , lookup

Abuse of notation wikipedia , lookup

Infinitesimal wikipedia , lookup

List of important publications in mathematics wikipedia , lookup

Vincent's theorem wikipedia , lookup

Georg Cantor's first set theory article wikipedia , lookup

Rounding wikipedia , lookup

Quadratic reciprocity wikipedia , lookup

Four color theorem wikipedia , lookup

Wiles's proof of Fermat's Last Theorem wikipedia , lookup

Mathematical proof wikipedia , lookup

Addition wikipedia , lookup

Theorem wikipedia , lookup

Factorization wikipedia , lookup

Elementary mathematics wikipedia , lookup

Fundamental theorem of algebra wikipedia , lookup

Collatz conjecture wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Transcript
Chapter 3: Elementary Number Theory And
Methods of Proof
January 27, 2008
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 Cases
and 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
• In this Chapter, we will investigate some properties of the
set of integers Z and the set of rational numbers (quotients
of integers) Q
• At the same time, we will try to apply some of the methods
for proving statements which we have learned in Chapters
1 and 2.
• We will start by giving some basic definitions of number
theory which will be used repeatedly in the rest of this
chapter.
Definition
An 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 integer
plus 1.
n is even ⇔ ∃ an integer k such that n = 2k
n is odd ⇔ ∃ an integer k such that n = 2k + 1
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 integer
0=2·0
(d) For any integers m, n, the integer 4m3 n2 is even, since
4m3 n2 = 2(2m3 n2 )
(e) For any two integers m and n, the integer 6m + 4n2 + 5 is
odd, since
6m + 4n2 + 5 = 2(3m + 2n2 + 2) + 1
Definition
An integer n is prime if, and only if, n > 1 and for all positive
integers 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 or
m=1
n is composite ⇔ ∃ positive integers k , m such that n = k · m
and k 6= 1, m 6= 1
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 one
such 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 existential
statement are called constructive proofs of existence
Examples
(a) Prove the following: ∃ an even integer n that can be written
in 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 + 7
10 = 5 + 5
(b) Since 14m + 26n2 = 2(7m + 13n2 ), we can take
k = 7m + 13n2
• Proofs of existential statements can also be
nonconstructive. In that case, we show only that an x
satisfying P(x) must exist without actually exhibiting it or
giving a “recipe” (algorithm) as to how to find it.
• Also, a nonconstructive proof can also be done by
contradiction: we assume that such an x ∈ D does not
exist and show that this assumption leads to something
obviously false.
Disproving Universal Statements by
Counterexample
• Suppose we want to disprove a universal statement of the
form
∀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 an
existential statement, is true and, as we have seen, that
amounts to finding an example of x ∈ D for which P(x) is
true and Q(x) is false.
• This is the method of disproof by counterexample
Example
Disprove the following statement by giving a counterexample
For all integers m and n, if 2m + n is odd, then m and n are
both odd.
Solution To disprove the statement, we need to find integers m
and 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 m
and n are odd.
Counterexample: Let m = 2 and n = 1, then 2m + n = 5
which is odd, but not both m and n are odd integers.
Proving a Universal Statement
• Most of mathematical theorems are universal statements
and 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 the
method of exhaustion; i.e. by listing all elements of D and
checking, one by one, that the universal statement is true
for all of them.
Example
Use the method of exhaustion to prove the following statement:
For each integer n such that 1 ≤ n ≤ 10, n2 − n + 11 is a prime
number.
Solution:
12 − 1 + 11 = 11
32 − 3 + 11 = 17
52 − 5 + 11 = 31
72 − 7 + 11 = 53
92 − 9 + 11 = 83
22 − 2 + 11 = 13
42 − 4 + 11 = 23
62 − 6 + 11 = 41
82 − 8 + 11 = 67
102 − 10 + 11 = 101
So, the statement has been proved by method of exhaustion.
• More often than not, we have to prove a universal
statement when the domain is infinite (e.g., the set of all
integers, or real numbers). In that case, the method of
exhaustion will not work.
• The most powerful method for proving a universal
statement is he method of generalizing from the generic
particular.
Method of generalizing From the Generic Particular: To show
that every element of a domain satisfies a certain property,
suppose x is a particular, but arbitrarily chosen element of
the domain, and show that x satisfies the required property.
Example
You 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.
Add 5.
Multiply by 4.
Subtract 6.
Divide by 2.
Subtract twice the original number.
x
x +5
4x + 20
4x + 14
2x + 7
7
• If the method of generalizing from the generic particular is
applied 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).
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 but
arbitrarily chosen element of D which satisfies the
hypothesis P(x).
3
Show that the conclusion Q(x) is true by using definitions,
previously proved facts, basic algebraic laws, and rules of
logical inference from Chapters 1 and 2.
Example
Prove that the sum of two even integers is even.
Solution: We start by expressing what is to be proved as a
universal 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 but
arbitrarily chosen integers, which are both even.
By definition, that means that we can write m and n in a
particular way:
m = 2r , for some integer r
n = 2s, for some integer s
(We have to use two different letters r and s, since they may be
distinct integers, and we should not assume otherwise.)
Our goal is to show that m + n is even. This will be the case, if
we 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 sum
r + s, which shows that m + n is even.
Theorem
The sum of any two even integers is even.
Proof.
Suppose m and n are [particular but arbitrarily chosen] even
integers. [We must have that m + n is even] By definition of
even, 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 of
two integers. Therefore,
m + n = 2k where k is an integer
It follows, by definition, that m + n is even [What is precisely
what we wanted to show.]
Guidelines for writing Proofs
1
2
3
4
5
6
Copy the statement of the theorem that you want to prove
before writing out the actual proof.
Clearly mark the beginning of the proof with “Proof:”
label all the variables that you will be using, explain what
kind of objects they represent, by saying e.g. “suppose x is
a positive real number...”, “let m be an even integer...”
Use complete sentences; avoid using mathematical
symbols only since the proof becomes difficult to follow. A
readable proof balances the use of the plain language and
mathematical symbols well.
Justify each step in your proof by either appealing to a
hypothesis, definition, or whatever else you are allowed to
use. This also helps you catch errors in your reasoning.
Use words such as “therefore”, “so”, “hence”, etc, to make
clear what conclusion you are drawing from previous steps
of the proof.
Common Mistakes
1
2
3
4
5
6
Proof by example: a universal statement cannot be
proved by giving an example. What works for a particular
choice of values of variables may not work for some other
choices.
Incorrect variable use: don’t use the same variable name
twice for two different variables. [As explained earlier, in
our proof we could not assume that m = 2r , n = 2r , since
m and n need not be equal.]
Jumping to a conclusion: do not make unwarranted
assumptions (even if they may be true)
Begging the question: do not assume the result, whether
explicitly, or implicitly.
Misuse of the word if : do not use if if you mean since or
because
Arguing from false premises: do not assume something
which is not true; as we know, false statement implies both
true and false statements.
Disproving an Existential Statement
• In order to disprove an existential statement, we need to
prove its negation, which is a universal statement.
Example
Prove 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.
Claim
The statement “There exists an integer n such that 6n2 + 27 is
prime.” 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 a
product of two integers greater than 1. Therefore,
6n2 + 27 is not prime, for all integers n.
Divisibility
Definition
If 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, or
that 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
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.
• The divisibility of integers was defined in terms of an
existential statement
d|n ⇔ ∃k ∈ Z such that n = dk
• To state what it means for an integer not to be divisible by
another integer, we use the negation, which is a universal
statement:
∀k , d ∈ Z,
d -n⇔
n
d
is not an integer.
Example
It is not the case that 7|73, since
73
7
is not an integer.
Example
Prove 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 three
particular 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 a
with some integer.
Since a|b,
b = ar , for some integer r
Also, since b|c, we have that
c = bs, for some integer s
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 of
divisibility, that means that
a|c
which is what we wanted to prove.
Theorem
(Transitivity of Divisibility) For all integers a, b, and c, if a
divides b and b divides c, then a divides c.
Proof.
Suppose a, b, and c are integers such that a divides b and b
divides 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. Then
c = ak
and a divides c by definition of divisibility.
Theorem
(Divisibility by a Prime) Any integer n > 1 is divisible by a prime
number.
Proof Suppose n is an integer that is greater than 1. If n is
prime, then n is divisible by a prime number (itself), and we are
done. If n is not prime, then
n = r0 s0
where r0 and s0 are integers such that
1 < r0 , s0 < n
By definition of divisibility,
r0 |n
If r0 is a prime number, then r0 is a prime that divides n and we
are done. If r0 is not prime, then we can write it as
r0 = r1 s1
where 1 < r1 , s1 < r0 . Again,
r1 |r0
If r1 , then r1 is a prime number that divides r0 and therefore it
divides n, so we are done in that case. If r1 is not prime, then it
factors as
r1 = r2 s2
where 1 < r2 , s2 < r1 .
If r2 is prime, then we are done, since r2 divides r1 and r1
divides n, etc.
We can continue in this way, factoring successive factors of n.
In that way, we get a strictly decreasing sequence of positive
integers 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 a
prime number which divides n.
Counterexamples and Divisibility
Properties
Example
Is 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 a
counterexample.
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.
The Unique Factorization Theorem
• One of the most important theorems in the basic number
theory is the unique factorization theorem for integers,
which is also known as the fundamental theorem of
arithmetic.
• 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.
Theorem
(Unique Factorization Theorem; Fundamental Theorem of
Arithmetic) Given any integer n > 1, there exists a positive
integer k , distinct prime numbers p1 , p2 ,. . . , pk , and positive
integers e1 , e2 , . . . , ek such that
n = p1e1 p2e2 p3e3 . . . pkek ,
and any other way of writing n as a product of prime numbers is
identical to this one except, perhaps, for the order in which the
factors are written.
Definition
Given an integer n > 1, the standard factored form of n is
n = p1e1 p2e2 p3e3 . . . pkek ,
where k is a positive integers, p1 , p2 , . . . , pk are prime numbers
and e1 , e2 , . . . ek are positive integers.
Example
Write 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 .
Example
Suppose 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-hand
side of the equation, it must be a prime factor of the left-hand
side (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
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 objects
each with, possibly, a left-over pile which may contain
fewer than 3 objects (0, 1, or 2).
∗∗∗
∗∗∗
∗∗∗
∗∗∗
• We can write that in the following way:
17 = 5 · 3 + 2
∗∗∗
∗∗
Theorem
(The Quotient-Remainder Theorem) Given any integer n and a
positive 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 when
we apply the theorem to a negative n, we have to take that into
account.
Examples
Apply the Quotient-Remainder Theorem to the following pairs
of 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
div and mod Functions
Definition
Given a non-negative integer n and a positive integer d
n div d =
n mod d =
the integer quotient q when n is divided by 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.
Most of standard programming languages (C++, Java, Pascal,
etc) have built-in functions that compute mod and div given a
non-negative integer n and a positive integer d. For example, in
C++, these functions are called / and %.
Example
Compute 62 div 7 and 62 mod 7.
Solution: Since
62 = 8 · 7 + 6,
we have
62 div 7 = 8,
62 mod 7 = 6
Example
Suppose today is Wednesday and you know that neither this
year nor the next year are leap years. What day of the week will
it 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 day
of the week the number
3 + 342 = 345
will correspond to.
To do that, we look for the remainder 345 gives when divided by
7:
345 mod 7 = 2
So, in 342 days it will be Tuesday.
Representations of Integers
• We have seen that, given any integer n and any positive
integer 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:
0≤r <2
n = 2q + r ,
which is the same as
n = 2q + 0
or
n = 2q + 1
• This proves what we already know: every integer is either
even or odd. This is called the parity property.
Theorem
Any two consecutive integers have opposite parity.
Proof. Suppose that we have chosen two arbitrary consecutive
integers. Call them n and n + 1.
We know, by the parity property, that either n is even or n is
odd. [We will break the proof into two cases, based on these
two 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 proves
the theorem.
Case 2 (n is odd): Here, n = 2k + 1, for some integer k . By
substitution,
n + 1 = (2k + 1) + 1 = 2k + 2 = 2(k + 1)
Since k + 1 is an integer, by definition, n + 1 will be an even
integer. So, the statement of the theorem is true in this case.
Therefore, regardless of which case occurs for n, whether it is
even or odd, the theorem is true.
Example
Show 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-Remainder
Theorem 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 has
one of the four forms
n = 4q,
n = 4q + 1,
for some integer q.
n = 4q + 2,
n = 4q + 3
Example
Prove 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 is
odd, we can write it as
n = 2k + 1, for some k
Then,
n2 = (2k + 1)2 = 4k 2 + 4k + 1
We want to show that we can find an integer m such that
4k 2 + 4k + 1 = 8m + 1 ⇒ 4k 2 + 4k = 8m ⇒ k 2 + k = 2m
But, it may be difficult to show that k 2 + k has to be even... We
will try a different approach.
Theorem
The square of any odd integer has the form 8m + 1 for some
integer m.
Proof. Suppose n is an arbitrary odd integer. By the
Quotient-Remainder Theorem, n can be written in one of the
four forms
4q, 4q + 1, 4q + 2, 4q + 3
for some integer q. Since n is odd, it cannot have either of the
forms 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)
= 16q 2 + 8q + 1
= 8(2q 2 + q) + 1
here, we can take m = 2q 2 + q, which proves the statement of
the theorem:
n2 = 8m + 1
Case 2 (n = 4q + 3): Since n = 4q + 3,
n2 = (4q + 3)2 (substitution)
= 16q 2 + 24q + 9
= 16q 2 + 24q + 8 + 1
= 8(2q 2 + 3q + 1) + 1
Therefore, the statement of the theorem has been proved in
this case, as well.
We have proved that, for any odd integer n,
n2 = 8m + 1
for some integer m.
Floor and Ceiling Functions
Definition
Given any real number x, the floor of x, denoted bxc, is defined
as:
bxc = the unique integer n such that n ≤ x < n + 1.
I.e.
bxc = n ⇔ n ≤ x < n + 1
Definition
Given any real number x, the ceiling of x, denoted dxe, is
defined as:
dxe = the unique integer n such that n − 1 < x ≤ n.
I.e.
dxe = n ⇔ n − 1 < x ≤ n
Examples
(a)
b17/4c = 4,
d17/4e = 5
(b)
b3c = 3,
d3e = 3
(c)
b−32/5c = −7,
d−32/5e = −6
Example
Boxes, each capable of holding 36 units, are used to ship a
product from the manufacturer to a wholesaler. Express the
number of boxes that would be required to ship n units of the
product using either the floor or the ceiling notation. Which one
is more appropriate?
Solution: We need either
bn/36c + 1
or
dn/36e
boxes.
Obviously, the ceiling notation is more convenient here.
Example
If n is an integer, what are
bnc
and
Solution:
bnc = n,
1
bn + c?
2
1
bn + c = n
2
Example
Is the following statement true or false?
For all real numbers x and y , bx + y c = bxc + by c.
Solution: This statement is false. We will try to find a
counterexample that will disprove it.
Statement: ∀x ∈ R ∀y ∈ R bx + y c = bxc + by c
Counterexample: let x = 0.5, y = 0.5. then
bx + y c = b0.5 + 0.5c = b1c = 1
bxc + by c = b0.5c + b0.5c = 0 + 0 = 0
Similarly, one can find a counterexample which shows that
dx − y e 6= dxe − dy e
(Exercise.)
Theorem
For all real numbers x and all integers m, bx + mc = bxc + m.
Proof.
Suppose a real number x and an integer m are given. Suppose
bxc = 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
Theorem
For any integer n,
n
b c=
2
n
2,
n−1
2 ,
if n is even
if n is odd
Proof. Suppose n is an arbitrary integer. We will break the
proof into two cases, depending on the parity of n.
Case 1 (n is odd): Then, n = 2k + 1, for some integer k . Then,
2k + 1
2k
1
1
n
c=b
+ c = bk + c = k
b c=b
2
2
2
2
2
The right-hand side will be
n−1
(2k + 1) − 1
=
=k
2
2
. Therefore,
for this case.
n
n
b c=
2
2
Case 2 (n is even): Since n = 2k , for some integer k :
n
2k
b c = b c = bk c = k
2
2
and the right-hand side is
n
2k
=
=k
2
2
This proves the statement of the theorem in this case.
• The Quotient-Remainder Theorem can be expressed in
terms of the floor function:
n = dq + r ,
0≤r <d
• We will show that
n
q = b c,
d
n
r = n − db c
d
or:
n
n div d = b c,
d
n
n mod d = n − db c.
d
Theorem
If n is a non-negative integer and d is a positive integer, and if
q = 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 positive
integer, and q = bn/dc, r = n − dbn/dc.
n
n
dq + r = db c + (n − db c) = n.
d
d
So, we only need to show that 0 ≤ r < d. But, q = bn/dc, so by
definition of the floor function:
q≤
n
<q+1
d
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,
n
r = n − db c = n − dq,
d
so
0≤r <d
(by substitution)
Method of Proof by Contradiction
1
Suppose that the statement you want to prove is false. In
other words, assume that the negation of the statement to
be proved is true.
2
Show that this assumption logically leads to a
contradiction.
3
Conclude that the assumption that the original statement
that we want to prove is true.
Example
Prove by contradiction that there is no greatest integer.
Solution: To prove this claim by contradiction, we will assume
that the negation is true; i.e. that there exists a greatest integer.
Theorem
There is no greatest integer.
Proof.
Suppose that the there is a greatest integer, call it N. Consider
the number M = N + 1. This number is an integer, being a sum
of two integers. However,
M>N
which contradicts our assumption that N is the largest integer.
Therefore, our assumption is false and we have proved that
there is no largest integer.
Theorem
There is no integer that is both even and odd.
Proof. We will prove this statement by contradiction. Suppose
that there is an integer, call it n which is both even and odd. By
definition,
n = 2m, for some integer m
n = 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.
However, we have shown that
m−k =
1
2
which is a contradiction.
Therefore, no integer can be both even and odd.
• Recall that we have defined the set of all rational numbers
Q as the set of all real numbers that can be represented as
quotients of integers.
• For example, every integer is a rational number, since
n=
n
1
as well as a multitude of other real numbers
1
( 12 , − 73 , 0.1 = 10
, etc)
• We add, subtract, and multiply the rational numbers in the
usual way:
a
c
ad − bc
a c
ac
− =
,
· =
b d
bd
b d
bd
√
• There are real numbers ( 2, π, e, etc) which cannot be
written as quotients of integers. We call such numbers
irrational.
a
c
ad + bc
+ =
,
b d
bd
Theorem
The sum of any rational number and any irrational number is
irrational.
Proof Suppose this is not the case. Let r be a rational number
and s an irrational number such that r + s is a rational number.
Since r is rational,
a
r=
b
for some integers a and b. Then
r +s =
a
c
+s =
b
d
for some integers c and d (we are assuming that r + s is
rational).
Then,
c
a
bc − ad
− =
d
b
bd
but that would mean that s is rational (both bc − ad and bd are
integers!), which is a contradiction.
By contradiction, we have shown that the sum of a rational and
an irrational number must be irrational.
s=
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)).
Claim
For all integers n, if n2 is even, then n is even.
Proof.
We will prove this by contraposition. Suppose n is an odd
integer.
n = 2k + 1,
for some k ∈ Z
By substitution,
n2 = (2k + 1)2 = 4k 2 + 4k + 1 = 2(2k 2 + 2k ) + 1
Since 2k 2 + 2k is an integer,
n2 = 2 · (integer) + 1
which shows that n2 is an odd integer.
• This claim can also be proved differently, by contradiction.
Claim
For all integers n, if n2 is even, then n is even.
Proof. We will assume that the claim is false; i.e. that its
negation 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.
Since n is odd,
n = 2k + 1,
for some k ∈ Z
Then,
n2 = (2k + 1)2 = 4k 2 + 4k + 1 = 2(2k 2 + 2k ) + 1
Since 2k 2 + 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.
Theorem
√
2 is an irrational number.
Proof. We√will prove this by contradiction.
Suppose 2 is a rational number:
√
2=
m
n
where m and n are integers. We can also assume that m and n
have no common factors; i.e. that the fraction has been
reduced as much as possible.
By squaring both sides:
2=
m2
n2
which is equivalent to
m2 = 2n2 .
By definition, this means that m2 is an even integer. By the
previous claim, m must be an even integer, too. Therefore,
m = 2k ,
for some k ∈ Z
By substitution,
m2 = (2k )2 = 4k 2 = 2n2 .
If we divide this equality by 2, we get
n2 = 2k 2
So, n2 is even, and by the previous claim, n is also even.
Therefore, both m and n are even integers, which contradicts
our assumption
that m and n have no common factors.
√
Thus, 2 is an irrational number.
Greatest Common Divisor
Definition
Suppose a and b are both non-zero integers. the greatest
common divisor of a and b, denoted gcd(a, b) is the integer d
which 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)
Examples
(a) gcd(4, 5) = 1
(b) gcd(3, 6) = 3
(c) gcd(12, 15) = 3
(d) gcd(374, 110) =? Since
374 = 2 · 11 · 17
110 = 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 gcd
then to try to factor both numbers into prime factors.
Lemma
If r is a positive integer, then gcd(r , 0) = r .
Proof.
Suppose r is a positive integer. Since r divides both itself and
0, it is a common divisor of both numbers. What we need to
show is that r is the greatest such divisor.
If k is an integer larger than r , then it cannot divide r , so it
cannot be a common divisor of both r and 0 either.
Therefore,
gcd(r , 0) = r
Lemma
If 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
Since m − k is an integer, by definition of divisibility:
d |b−a
Lemma
If a and b are any integers with b 6= 0 and q and r are
non-negative integers such that
a = bq + r
then
gcd(a, b) = gcd(b, r )
Proof. Let a and b be two integers with b 6= 0 and q and r
non-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.
By the previous lemma,
d | a − bq = r
Thus, d divides both b and r , so it is their common divisor. We
now 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 ).
Theorem
For 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 )
The Euclidean Algorithm for Finding
gcd(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).
}
• Note that this algorithm is recursive; a recursive algorithm
is one that calls itself during its execution.
Example
Trace the execution of the above algorithm in finding
gcd(124, 3120).
Solution:
a = 124
a = 124
a = 20
a=4
b
b
b
b
= 3120
= 20
=4
=0
3120 mod 124 = 20
124 mod 20 = 4
20 mod 4 = 0
return gcd(124, 20)
return gcd(20, 4)
return gcd(4, 0)
return 4