Professional Documents
Culture Documents
Discrete Structures Cấu Trúc Rời Rạc: TS Nguyễn Thị Huỳnh Trâm
Discrete Structures Cấu Trúc Rời Rạc: TS Nguyễn Thị Huỳnh Trâm
STRUCTURES
Cấu Trúc Rời Rạc
(~p → r) (q→ r) (p → q) → r
(~p → r) (q → r)
( p r ) (~ q r) (if – then law)
( p ~ q ) r (distributive law)
~(~p q ) r (De Morgan)
~( p → q ) r (if – then law)
( p → q ) → r (if – then law)
Trichotomy (Tam phân): exactly one of the following is true: a < b, or b <a, or a = b
PROPERTIES OF THE REAL NUMBERS
Appendix A of Epp’s textbook for all the properties.
PROPERTIES OF THE REAL NUMBERS
PROPERTIES OF THE REAL NUMBERS
PROPERTIES OF THE REAL NUMBERS
PROPERTIES OF THE REAL NUMBERS
PROPERTIES OF THE REAL NUMBERS
PROPERTIES OF THE REAL NUMBERS
PROPERTIES OF THE REAL NUMBERS
What is Proof
A proof is a concise, polished argument explaining the validity of a statement to a
skeptic (người nghi ngờ) (usually, you).
• Concise (ngắn gọn) means there are no irrelevant details. It also means to use
few words.
• Polished (đánh bóng) means it should be the final draft, i.e. you need to revise it
to make it understandable, like writing an essay.
• Argument (tranh luận) means every step should follow logically from all previous
steps.
• A proof is not an attempt to determine whether or not something is true. That is
your scratch work. You should be convinced the statement is true before you write
your proof.
Lượng từ Khi nào đúng Khi nào sai
x P(x) P(x) đúng với mọi x Có một giá trị x để P (x) là sai
x P(x) Có một x sao cho P (x) là đúng P(x) sai với mọi x
That is, there exists an integer x such that x > 2 and x2 - 5x + 6 > 0.
Proof: 1. Note that 1000 ∈ Z and 1000 > 2.
2. Also, 10002 - 5(1000) + 6 = 995006 > 0
• In the proof, there is no need to explain how 1000 was obtained. You just need to show
that 1000 has the said properties. Of course, many integers satisfy the same properties (as
you can easily verify), and any one of these will suffice for the proof.
• This style of proof - where you explicitly find the value with the correct properties - is called
a proof by construction. It is the most direct way to prove that something exists.
Lượng từ Khi nào đúng Khi nào sai
x P(x) P(x) đúng với mọi x Có một giá trị x để P (x) là sai
x P(x) Có một x sao cho P (x) là đúng P(x) sai với mọi x
Existence Proof 2
Prove that there exist irrational numbers p and q such pq is rational.
𝑎
Recall that a number x is rational if it can be written as a ratio of two integers: x = ,
𝑏
• Doing a proof is like solving a jigsaw puzzle. No two jigsaws are alike; no two proofs
are alike.
• Sometimes you solve large chunks quickly; other times you get stuck. You don’t have
to solve from top to bottom.
• Some strategies are useful eg. fixing the border of the puzzle first. Likewise, there
are useful strategies for proofs
If-then statements
Many statements to be proven take the form: if P then Q
One strategy is to use a direct proof:
1) Assume P is true, then combine this with other known facts F and theorems T to
conclude that Q must be true.
2) Think of P as the starting point, and Q the destination.
The other known facts F and theorems T make up the route that go from P to Q.
Each step of the route must be logically connected.
In your draft, you can work forwards from P, or backwards from Q, but be careful
never to assume Q to be true.
In your final, polished proof, you must argue only forwards, not backwards
NUMBER THEORY
Definition 1.1.1 (Colorful)
An integer n is said to be colorful if there exists some integer k such that n = 3k:
This terminology colorful is non-standard; used only in this class.
Questions:
• Is 1353 colorful?
• What about (208 - 201)?
• 0?
NUMBER THEORY
Definition 1.1.1 (Colorful)
An integer n is said to be colorful if there exists some integer k such that n = 3k:
This terminology colorful is non-standard; used only in this class.
Questions:
• Is 1353 colorful?
• What about (208 - 201)?
• 0?
• Yes, 1353 is colorful because 1353 = 3 × 451.
• No, because 208 - 201 = 7, and there is no integer k such that 7 = 3k.
• Yes, 0 is colorful because 0 = 3 × 0
Prove that: if x, y are colorful integers, then so is x + 2y
Identify P and Q to be: P : x, y are colorful integers
Q : x + 2y is colorful
We can immediately write down the start and end of the proof, as follows:
Draft proof: Assume P is true, then combine this with
1. Assume that x; y are colorful integers. other known facts F and theorems T to
2. … conclude that Q must be true.
3. And thus x + 2y is colorful. Think of P as the starting point, and Q the
The next logical thing is to
destination.
use the definition of colorful.
Prove that: if x; y are colorful integers, then so is x + 2y
Identify P and Q to be: P : x, y are colorful integers
Q : x + 2y is colorful
We can immediately write down the start and end of the proof, as follows:
Draft proof:
1. Assume that x; y are colorful integers.
2. Then by definition of colorful, ∃a, b ∈ Z such that x = 3a and y = 3b
3… -The other known facts F
4. So ∃c ∈ Z such that x + 2y = 3c. and theorems T make up the
5. And thus x + 2y is colorful, by definition of colorful route that go from P to Q.
-Each step of the route must
be logically connected.
Draft proof:
1. Assume that x; y are colorful integers.
2. Then by definition of colorful, ∃a, b ∈ Z such that x = 3a and y = 3b
3…
4. So ∃c ∈ Z such that x + 2y = 3c.
5. And thus x + 2y is colorful, by definition of colorful
This means we need to connect c to a and b. Obviously, we should try writing (x + 2y) in
terms of a; b:
x + 2y = 3a + 2(3b) by substitution In your draft, you can
= 3a + (2 · 3)b by associativity
work forwards from P, or
= 3a + (3 · 2)b by commutativity
= 3a + 3(2b) by associativity backwards from Q, but
= 3(a + 2b) by distributivity
be careful never to
Aha! It is clear what c should be now. So here’s our final proof
assume Q to be true.
Prove that: if x; y are colorful integers, then so is x + 2y
Proof.
1. Assume that x; y are colorful integers.
2. Then by definition of colorful, ∃a, b ∈ Z such that x = 3a and y = 3b
3. Now, x + 2y = 3a + 2(3b) by substitution
4. = 3a + 3(2b) by commutativity and associativity
5. = 3(a + 2b) by distributivity
6. Let c = a + 2b. Note that a + 2b ∈ Z because integers are closed under addition and
multiplication.
Closure (Đóng): integers are closed
7. So ∃c ∈ Z such that x + 2y = 3c.
under addition and multiplication i.e
8. And thus x + 2y is colorful, by definition of colorful. ∀𝑥, 𝑦 ∈ 𝑍, 𝑥 + 𝑦 ∈ 𝑍 and xy ∈ 𝑍
In your final, polished proof, you must argue only forwards, not backwards
DIVISIBILITY
Definition 1.3.1 (Divisibility)
That is, when dealing with positive integers, a divisor of a number cannot be larger
than the number.
Note that the theorem is silent for the case b = 0, because 0 is not positive.
When doing proofs, it is often helpful to keep track of what we are given and what
our goals are. Since the statement to be proven is an if-then statement, we can
quickly write the P as our givens and the Q as our goal.
DIVISIBILITY
From the definition of a | b, we know that b = ak for some integer k. We may add this to
our givens.
• So we now have one equality in our givens, but our goal involves an inequality.
How do we achieve this?
• Intuitively, the equality says that if a needs to be multiplied by something to get b,
then b must be larger than a. But this requires k to be positive. Fortunately, rule T25
of Appendix A (Epp) assures this.
DIVISIBILITY
• So what we want is to argue that since ak = b and k is positive, we may “drop" k to get
a ≤ b. Although this is intuitively true, none of the rules in Appendix A (Epp) justifies this
argument. We need another approach.
• Since k is a positive integer, we have the inequality 1 ≤ k for “free", which we can add to
our givens. We can now invoke rule T20 to multiply both sides of this inequality by a
(which is positive), to get a ≤ ak. The right hand side is now b, which is our goal. Hence
our proof:
DIVISIBILITY
Line 1: if instead we
had said: Take positive
integers a; b; c, then
the proof would still be
valid until Line 6.
But in Line 7, we
would not be able to
generalize to all
integers, because our
proof thus far was
valid only for positive
integers.
For-all statements
Likewise, we cannot
assume a ≤ b or b ≤ c
or a ≤ c, since
this is an unnecessary
restriction
For-all statements
Another common
mistake is to say, in
Line 3: b = ar and
c = br. This forces b
and c to be the same
multiple, which
again restricts our
proof.
For-all statements
Remarks:
• To prove the statement directly, you would have to start by assuming x2 is irrational.
That is, x2 ≠ a/b for all integer a and nonzero integer b.
The unequality ≠ makes it difficult to continue. What form can you let x2 take? Irrationality
is defined by the absence, rather than the presence, of a form. If you cannot write down
a form for x2, then you cannot manipulate it to get a form for x. The proof cannot proceed
• By using the contrapositive, you instead deal with rationals, rather than irrationals. You
can thus exploit the form of rationals in your proof.
• Thus, whenever you encounter an if-then statement involving the absence of a form,
you should consider proving by contraposition instead
Proof by Contradiction
Remarks:
• To prove a statement S by contradiction, you first assume that ∼ S is true. Based on
this, you use known facts and theorems to arrive at a contradiction. Since every step of
your argument thus far is logically correct, the problem must lie in your assumption.
Thus, you conclude that ∼ S is false, and hence S is true.
• A formal definition of contradiction will be given in the chapter on logic; for now, it
suffices to say that a contradiction is something that is logically impossible. For example,
at the start of your proof, you may assume (or deduce) that x ≥ 5. Then later you deduce
that x < 5. These two facts are clearly contradictory.
• In a proof by contradiction, the contradictory facts need not be directly related to S. As
long as you contradict any known thing in mathematics, eg. 1 = 0, your proof has
succeeded.
It is difficult to use a direct proof because irrationality is the absence of a form.
On the other hand, proving by contradiction begins by assuming that 2 is rational,
thereby allowing us to exploit the form of a rational number.
The resulting proof is a mathematical classic.
Proof by contradiction
1. Assume that 2 is rational.
2. Then by definition of rationals, there exists integers m, n, with n ≠ 0, such that
2 = m/n.
3. Further, we may assume that m/n is reduced to lowest terms, ie. the only common
factor of m, n is 1.
4. From Line 2, m2 = 2n2, by basic algebra.
5. So m2 is even, by definition of even, and because n2 is an integer by the closure
property.
6. => m is even, by Proposition 4.6.4 (Epp)
7. => Ǝ k ∈ Z ∋ m = 2k, by definition of even.
8. Subtituting into Line 4: (2k)2 = 2n2.
9. => 2.k2 = n2, by basic algebra.
10. So n2 is even, by definition of even, and because k2 is an integer by the
closure property.
11. => n is even by Proposition 4.6.4 (Epp).
12. But this means 2 is a common factor of m, n, contradicting Line 3.
13. Hence 2 must be irrational.
Proof. [Proof by contradiction]
1. Suppose 7 is colorful.
2. Then, by definition of colorful, 7 = 3k for some integer k.
3. => 6 = 3k - 1, by basic algebra.
4. => 1 = 3(k - 2), by basic algebra.
5. Since k - 2 is an integer by the closure property, the above means that 3 |1, by
definition of divisibility.
6. Then by Theorem 4.3.1 (Epp), this means 3 ≤ 1.
7. Clearly, this is absurd, so the Proposition is true.
Remarks:
• It is wrong to say: “7 is not colorful” because 7:3 = 2:333…, which is not an integer."
There is no concept of division in Number Theory.
Moreover, the definition of colorful does not use division, but instead uses the existence
of an integer.
• It is also wrong to say: I cannot find an integer k such 7 = 3k, therefore 7 is not colorful.“
If you cannot find it, it doesn’t mean no such integer exists.
• The irrefutable way to prove the non-existence of something is to show that if it exists,
then it will lead to an absurd conclusion.
This is the essence of a proof by contradiction
Proofs
• Construction: find the value with the correct properties (Ǝ 𝑡𝑟𝑢𝑒 ∀(𝑓𝑎𝑙𝑠𝑒))
• If-then statements: assume P is true, then combine this with other known facts F and
theorems T to conclude that Q must be true.
Proof.
1. For any a, b, c ∈ Z:
2. If a | b and a | c:
3. Let k ∈ Z such that b = ak. (by definition of divisibility)
4. Let m ∈ Z such that c = am. (by definition of divisibility)
5. For any x, y ∈ Z:
6. bx + cy = (ak)x + (am)y = a(kx + my). (by basic algebra)
7. Note that kx + my ∈ Z. (by closure of addition and multiplication
over integers)
8. Thus a | bx + cy. (by definition of divisibility)
Primes
Primes
Note that this property does not hold for composites, e.g. 4 | 8 but 4 ≠ 8.
Primes
Primes
Primes
That is, every positive integer greater than 1 can be uniquely factorized into a product of
prime numbers.
This is also called The Fundamental Theorem of Arithmetic.
It is standard practice to sort the primes from smallest to largest.
Examples: 24 = 2 × 2 × 2 × 3 = 23 · 3.
90 = 2 × 3 × 3 × 5 = 2 · 32 · 5
Primes
Primes
1. Suppose you encode m; n by inserting a 0 between their decimal representations,
e.g. 1234 and 768 gets encoded to 12340768
Clearly, this won’t work if m or n contains 0.
2. Suppose you try s = m + n. This doesn’t work either. Why?
3. Next, you try s = 1000m + n. Will this work?
4. Clearly, s = mn also doesn’t work.
5. Luckily, you remember CS1231, so you try s = 2m3n.
This works because the prime factorization of s guarantees that we can get back m
and n uniquely!
Question: how would you handle negative m and n?
Python code for encode and decode
def encode(m, n): def isEven(x):
return 2**m * 3**n # x is even if its remainder is 0
def decode(s): # when divided by 2
# Repeatedly divide s by 2, and count return x % 2 == 0
number of times def isColorful(x):
# this can be done. Do the same for 3. # x is colorful if its remainder is 0
# when divided by 3
m=0 return x % 3 == 0
while isEven(s):
s=s/2
m=m+1
n=0
while isColorful(s):
s=s/3
n=n+1
return m,n
Primality test
Primality test
Of course, one way to check if a number n is prime is to see if n can be found in a list, L,
of primes.
To generate L, an ancient method called the Sieve of Eratosthenes may be used:
1. Start by listing all integers greater than 1. Call this list C. Also, let L be an empty list.
2. Take the first number p = 2 in C, and add it to L. This is the first prime.
3. In C, cross out all multiples of p.
4. Let p be the next uncrossed number in C. This is the next prime. Add it to L, and
repeat from Step 3
Well Ordering Principle
B = {𝐱 ∈ Z |x is a multiple of 3}.
• There is no lower bound. To see this, suppose not; suppose the lower bound is some
integer c. Then one of c – 1, c – 2, c - 3 must be divisible by 3.
But all of them are less than c, contradicting the fact that c is a lower bound.
C = {𝐱 ∈ Z | x2 ≤ 100x}.
• If x2 ≤ 100x then x(x - 100) ≤ 0, by basic algebra. Thus C is the set of integers x such
that 0 ≤ x ≤ 100. Thus any integer m ≤ 0 is a lower bound
Well Ordering Principle
Examples: Does each set below have a least element? If so, what is it? If not, explain
why there is no violation of the Well Ordering Principle.
• The set of all positive real numbers.
• The set of all non-negative integers n such that n2 < n.
• The set of all non-negative integers of the form 46 - 7k, where k is any integer
Well Ordering Principle
• The set of all positive real numbers.
There is no least (smallest) positive real number. To see this, suppose x ∈ R+, then x/2
∈ R+ and x=2 < x. There is no violation of the Well Ordering Principle because the
principle concerns only sets of integers, not real numbers.
• The set of all non-negative integers n such that n2 < n.
This set is empty! Thus there is no least element, and no violation of the Well Ordering
Principle.
• The set of all non-negative integers of the form 46 - 7k, where k is any integer
14. But r - b < r, contradicting the fact the r is the least element.
This algorithm computes the quotient and remainder for non-negative integer a and
positive integer b.
The key idea is to repeatedly subtract b from a until the result is less than b, and to
count the number of subtractions
Representation of Integers
The Quotient-Remainder Theorem provides the basis for writing an integer n as a
sequence of digits in a base b.
For example, our usual way of writing the number
n = 3 · 102 + 3 · 101 + 4·100 is: 334. This is in decimal (base 10) because it uses powers
of 10. The same number n could be represented using a different base.
More generally, given any positive integer n and base b, we may repeatedly apply the
n = bq0 + r0 334 = 10 x 33 + 4
Quotient-Remainder Theorem to get:
q0 = bq1 + r1 33 = 10 x 3 + 3
q1 = bq2 + r2 3 = 10 x 0 + 3
...
qm-1 = bqm + rm
n = bq0 + r0 334 = 10 x 33 + 4
q0 = bq1 + r1 33 = 10 x 3 + 3
q1 = bq2 + r2 3 = 10 x 0 + 3
... n = 3 · 102 + 3 · 101 + 4·100
qm-1 = bqm + rm
n = rmbm + rm-1bm-1 + : : : + r1b + r0
• Each remainder ri is one of the integers 0,1,..,b - 1, and the process stops when qm = 0.
• By eliminating the quotients qi, we get: n = rmbm + rm-1bm-1 + : : : + r1b + r0
which may be written more compactly as: n = σ𝑚 𝑟
𝑖=0 𝑖 𝑏 𝑖
• In turn, we may write n more compactly in base b as a sequence of the digits ri.
That is: n = (rmrm-1 … r1r0)b
This positional notation is convenient. When b = 10 we usually omit it, which gives us
our usual decimal representation for integers
Example: Express (109)10 in base 2.
Answer: Dividing repeatedly by 2 we obtain:
109 = 2 × 54 + 1 n = bq0 + r0
54 = 2 × 27 + 0 q0 = bq1 + r1
27 = 2 × 13 + 1 q1 = bq2 + r2
13 = 2 × 6 + 1 ...
qm-1 = bqm + rm
6=2×3+0
3=2×1+1
1=2×0+1
Hence, by reading the remainders from bottom up, (109)10 = (1101101)2.
The greatest common divisor is also called the highest common factor.
Proof:
1. Let D = {all common divisors of a, b}.
2. Clearly, 1 ∈ D, and D ⊆ Z.
3. By assumption, one of a, b is non-zero. Let it be a, since gcd(a, b) = gcd(b, a) by its
definition, so we can swap the numbers to make a the non-zero number.
4. Also, |a| is an upper bound for D, since no common divisor of a, b can be larger than
this.
5. Thus by Well Ordering 2, there exists a greatest element d in D.
6. By Proposition 4.3.4, d is unique
Euclid’s algorithm
In practice, computing the gcd by prime factorization is too slow, especially when the
numbers are large. Luckily, an efficient algorithm was given by Euclid way back in the
year 300BC. n = bq0 + r0
q0 = bq1 + r1
The key idea to find gcd(a, b) is based on two facts:
q1 = bq2 + r2
(i) gcd(a, 0) = a.
...
(ii) gcd(a, b) = gcd(b, r), where r is the remainder of a=b. qm-1 = bqm + rm
Line (i) was explained in the previous slide. n = rmbm + rm-1bm-1 + : : : + r1b + r0
For Line (ii), note that since a = bq + r, then any common divisor c of a, b must divide r
by Theorem 4.1.1 (r is a linear combination of a, b.)
Also, any common divisor of b; r must divide a for the same reason. So (a; b) and (b; r)
have the same set of common divisors, and thus their gcd’s must be equal
Let’s trace Euclid’s algorithm to calculate gcd(330; 156)
gcd(330; 156)
330 = 156 × 2 + 18 gcd(156; 18)
156 = 18 × 8 + 12 gcd(18; 12)
18 = 12 × 1 + 6 gcd(12; 6)
12 = 6 × 2 + 0 gcd(6; 0)
Thus gcd (330, 156)=6
6 = 18 - 12 × 1 = 18 + 12 × (-1)
= 18 + (156 - 18 × 8) × (-1) = 156 × (-1) + 18 × 9
= 156 × (-1) + (330 - 156 × 2) × 9 = 330 × 9 + 156 × (-19)
Thus 6 = 330 · 9 + 156 · (-19).
The above procedure is called the Extended Euclidean Algorithm, for obvious reasons.
Non-uniqueness of B´ezout’s Identity
There are multiple solutions x, y to the equation ax + by = d.
Once a solution pair (x, y) is found, additional pairs may be generated by
𝑘𝑏 𝑘𝑎
x+ ,𝑦 − , where k is any integer.
𝑑 𝑑
𝑘𝑏 𝑘𝑎 𝑘𝑎𝑏 𝑘𝑎𝑏
Proof sketch: a x + +𝑏 𝑦− = ax + + 𝑏𝑦 − =𝑑
𝑑 𝑑 𝑑 𝑑
2)
3) Hãy đổ đúng 1 lít nước sông vào một cái máng lớn trên ruộng. Chỉ có hai can để múc nước từ
sông: một can chứa đầy được đúng 13 lít, can còn lại 11 lít.
Theorem 4.2.3: If p is a prime and x1, x2,…, xn are any integers such that: p | x1x2 … xn
then p | xi, for some i (1 ≤ i ≤ n).
Proof:
(by Induction)
1. Let P(n) = ( (p | x1x2…xn) → (p | xi for some i ∈ [1; n]) )
2. (Consider the base case n = 1)
3. Clearly, P(1) is true.
4. For any k ∈ Z+: (Inductive step:)
5. Assume P(k) is true.
6. That is, (p | x1x2 …xk) → (p | xi for some i ∈ [1; k]).
7. (Consider the case k + 1:)
8. Suppose p | x1x2 : : : xk+1
Theorem 4.2.3: If p is a prime and x1, x2,…, xn are any integers such that: p | x1x2 … xn
then p | xi, for some i (1 ≤ i ≤ n).
To prove “P iff Q", we need to prove “if P then Q" and “if Q then P"
1. (Forward direction: “if P then Q")
2. For any positive integers a, b:
3. Suppose a | b:
4. Then b = ak for some integer k, by definition of divisibility.
5. Then gcd(a, b)=gcd(a, ak)= a because a is the largest common divisor.
6. (Backward direction: “if Q then P")
7. For any positive integers a, b:
8. Suppose gcd(a,b)=a:
9. Then a is a common divisor of a, b, by definition of gcd.
10. Thus, a | b.
Prove that if a, b are integers, not both zero, and d =gcd(a, b), then a=d and b=d are
integers with no common divisor that is greater than 1
Least Common Multiple
Definition 4.6.1 (Least Common Multiple)
For any non-zero integers a; b, their least common multiple, denoted lcm(a, b), is the
positive integer m such that:
(i) a | m and b | m,
(ii) for all positive integers c, if a | c and b | c, then m ≤ c.
The lcm of a, b exists because the Well Ordering Principle guarantees the existence of
the least element on the set of common multiples of a, b.
Examples: Find
• lcm(12; 18)
• lcm(22 · 3 · 5; 23 · 32)
• lcm(2800; 6125)
Examples: Find
• lcm(12; 18) • lcm(22 · 3 · 5; 23 · 32) • lcm(2800; 6125)
q0 = bq1 + r1
q1 = bq2 + r2
...
qm-1 = bqm + rm
n = rmbm + rm-1bm-1 + : : : + r1b + r0
Definition 4.5.1 (Greatest Common Divisor)
Let a and b be integers, not both zero. The greatest common divisor of a and b, denoted
gcd(a; b), is the integer d satisfying:
(i) d | a and d | b.
(ii) ∀𝑐 ∈ 𝑍 , if c | a and c| b then c ≤ d.
Euclid’s algorithm
The key idea to find gcd(a, b) is based on two facts:
(i) gcd(a, 0) = a.
(ii) gcd(a, b) = gcd(b, r), where r is the remainder of a=b.
Non-uniqueness of B´ezout’s Identity
There are multiple solutions x, y to the equation ax + by = d.
Once a solution pair (x, y) is found, additional pairs may be generated by
𝑘𝑏 𝑘𝑎
x+ ,𝑦 − , where k is any integer.
𝑑 𝑑
𝑘𝑏 𝑘𝑎 𝑘𝑎𝑏 𝑘𝑎𝑏
Proof sketch: a x + +𝑏 𝑦− = ax + + 𝑏𝑦 − =𝑑
𝑑 𝑑 𝑑 𝑑
Proposition 4.5.5
For any integers a, b, not both zero, if c is a common divisor of a and b, then c | gcd(a, b).
Prove that for all positive integers a, b, a | b if, and only if, gcd(a, b) = a
Prove that if a, b are integers, not both zero, and d =gcd(a, b), then a=d and b=d are
integers with no common divisor that is greater than 1
Definition 4.5.1 (Greatest Common Divisor)
Let a and b be integers, not both zero. The greatest common divisor of a and b, denoted
gcd(a; b), is the integer d satisfying:
(i) d | a and d | b.
(ii) ∀𝑐 ∈ 𝑍 , if c | a and c| b then c ≤ d.
Prove that for all positive integers a and b, gcd(a, b)| lcm(a; b)
Definition 4.7.1 (Congruence modulo)
Let m and n be integers, and let d be a positive integer. We say that m is congruent to n
modulo d, and write: m ≡ n (mod d)
if, and only if, d | (m - n)
Symbolically: m ≡ n (mod d) ↔ d | (m - n)
Examples: Determine which of the following is true and which is false.
• 12 ≡ 7 (mod 5)
• 6 ≡ -8 (mod 4)
• 3 ≡ 3 (mod 7)
• ∀𝑎, 𝑏 ∈ 𝑍, not both zero, a ≡ b (mod gcd(a, b))
Examples: Determine which of the following is true and which is false.
• 12 ≡ 7 (mod 5)
• 6 ≡ -8 (mod 4)
• 3 ≡ 3 (mod 7)
• ∀𝑎, 𝑏 ∈ 𝑍, not both zero, a ≡ b (mod gcd(a, b))
Answer:
• True. Clearly, 5 | (12 - 7).
• False. Because 4 ł (6 - (-8)).
• False. Since 7 ł (3 - 3).
• True. Let d = gcd(a; b). Then d | (a - b) because d | a and d | b.
Theorem 8.4.1 (Epp): Modular Equivalences
Let a; b, and n be any integers and suppose n > 1.
The following statements are all equivalent:
1. n | (a - b)
2. a ≡ b (mod n)
3. a = b + kn for some integer k
4. a and b have the same (non-negative) remainder when divided by n
5. a mod n = b mod n
Example:
Clearly, 3 × 1 ≡ 3 × 5 (mod 6).
But, 1 5 (mod 6).
When “cancelling" a on both sides of Equation ab=ac, we are really multiplying with the
multiplicative inverse of a. By definition, the multiplicative inverse is a number b such that
ab = 1. Thus we need a suitable inverse that works with modulo arithmetic.
Note that multiplicative inverses are not unique, since if s is such an inverse, then so is
(s + kn) for any integer k (Why?)
Proof sketch
Since a and n are coprime, Theorem 4.7.3 guarantees the existence of a multiplicative
inverse a-1.
Multiply both sides of ab ≡ ac (mod n) with a-1 gives the desired answer.
Quiz: In T7 of Appendix A (Epp) (Cancellation Law for integers), it is explicitly stated
that a ≠ 0. Yet the above theorem doesn’t seem to require this. Why not?
Example:
Solve the equation 5x + 13y = 75 for integers x, y.
1. Re-write: 5x = 75 - 13y.
2. Then 5x ≡ 75 (mod 13), by Theorem 8.4.1 (Epp).
3. Re-write: 5x ≡ 5 · 15 (mod 13).
4. Note that 5 and 13 are coprime.
5. Thus, x ≡ 15 (mod 13), by Theorem 8.4.9 (Epp).
6. Thus, x ≡ 2 (mod 13), because 15 mod 13 = 2.
7. So x = 2 is a solution.
8. Substituting back into the equation: 5(2) + 13y = 75.
9. And thus y = 5.
Other solutions include: (x; y) = (15, 0), (-11, 10), (28, -5).
Definition 4.7.1 (Congruence modulo)
Let m and n be integers, and let d be a positive integer. We say that m is congruent to n
modulo d, and write: m ≡ n (mod d)
if, and only if, d | (m - n)
Symbolically: m ≡ n (mod d) ↔ d | (m - n)