Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
6 views

Topic 2 Lecture Notes (Gardiner)

Uploaded by

tonyho2003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Topic 2 Lecture Notes (Gardiner)

Uploaded by

tonyho2003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

MATH1081 – Discrete Mathematics

Topic 2 – Number theory and relations


Lecture 2.01 – Divisibility and greatest common divisors

Lecturer: Dr Sean Gardiner – sean.gardiner@unsw.edu.au


Introduction to number theory and relations
Number theory is primarily concerned with the study of integers and subsets
of the integers. So for this topic we will mostly be working with:
• The integers Z = {... , −3, −2, −1, 0, 1, 2, 3, ... }.
• The positive integers Z+ = {1, 2, 3, ... }.
• The natural numbers N = {0, 1, 2, 3, ... }.

For these and all other number sets we have encountered (Q, R, C), if we
add or multiply any two elements from one of the sets, we attain another
element from that set. But for the operation of division, the integers and its
subsets are distinguished by the fact that this property does not hold –
dividing one integer by another non-zero integer does not guarantee an
integer result.
Number theory is one of the most fundamental branches of Mathematics,
and is still relevant in the modern era especially considering its applications
to cryptography.
Towards the end of this topic, we will also address the topic of mathematical
relations, which is a natural generalisation of what we have already learned
about functions, and provides more structure to our understanding of
divisibility and modular arithmetic.
MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 1/10
Divisibility
Definition. Given two integers a and b, we say a divides b if we can write
b = ak for some integer k. We might also say:
• a is a divisor of b,
• a is a factor of b,
• b is divisible by a, or
• b is a multiple of a.
Notation. The expression a | b is read as “a divides b” and is equivalent to
writing b = ak for some integer k. The expression a ∤ b is read as “a does
not divide b”, and means that b ̸= ak for any integer k.
Example. Decide whether the following statements are true or false.
• 3 | 15 is true since 15 = 3 × 5 and 5 ∈ Z.
• 15 | 3 is false since 3 = 15 × 1
5 but 1
5 ̸∈ Z.
• 3 | 3 is true since 3 = 3 × 1 and 1 ∈ Z.
• −5 | 15 is true since 15 = (−5) × (−3) and −3 ∈ Z.
• 0 | 3 is false since there is no integer k such that 3 = 0 × k.
• 3 | 0 is true since 0 = 3 × 0 and 0 ∈ Z.
• 0 | 0 is true since 0 = 0 × 1 (for example) and 1 ∈ Z.
MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 2/10
Divisibility properties
The divisibility relation has many useful properties. Some of the most
important are the following.
Lemma. For all integers a, we have a | a.
Proof. Since a = a × 1 and 1 ∈ Z, we have by definition that a | a.
Lemma. For all integers a, b, c, if a | b and b | c, then a | c.
Proof. Since a | b, we have b = ak for some k ∈ Z, and since b | c, we
have c = bl for some l ∈ Z. So c = (ak)l = a(kl) where kl ∈ Z, so a | c.
Lemma. For all integers a, b, c, if a | b and a | c, then a | bx + cy for any
x, y ∈ Z.
Proof. Since a | b, we have b = ak for some k ∈ Z, and since a | c, we have
c = al for some l ∈ Z. So bx + cy = (ak)x + (al)y = a(kx + ly ) where
kx + ly ∈ Z, so a | bx + cy .

We can deduce other useful facts from the above properties. For example,
setting c = 0 in the third lemma shows that if a | b then a | bm for any
integer m. Combining this with the first lemma shows that a | am for any
integer m.
MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 3/10
Prime numbers
Definition. A prime number (or just a prime) is any p ∈ N such that p > 1
and the only positive divisors of p are 1 and p.
The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, ... .
Definition. A composite number is any natural number that is not 0, 1, or
a prime number.
The first few composite numbers are 4, 6, 8, 9, 10, 12, ... .
Theorem. There are infinitely many prime numbers.
Proof. See Angell: Slide 3.53 (or Gardiner: Lecture 3.07, Example 5).
To determine if a natural number n is prime, a standard approach is to√
check whether it is divisible by all known primes less than or equal to n.
(See Problem Set 3, Question 25.)
For example, 1009 is prime
√ because it is not divisible by any of the primes
less than or equal to ⌊ 1009⌋ = 31.

MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 4/10
Fundamental Theorem of Arithmetic
Theorem. (Fundamental Theorem of Arithmetic)
Every natural number greater than 1 has a unique prime factorisation. That
is, given any positive integer n > 1, it can be written uniquely in the form

n = p1α1 p2α2 p3α3 · · · pkαk ,

where each p1 , p2 , ... , pk is a prime number, p1 < p2 < p3 < · · · < pk , and
α1 , α2 , ... , αk ∈ Z+ for some k ∈ Z+ .
Proof. See Angell: Slide 3.76 (or Gardiner: Lecture 3.08, Example 4).
For example, the prime factorisation of 12 is 22 × 3.
Example. Find the prime factorisations for each of the integers from 21
to 25.
• 21 = 3 × 7.
• 22 = 2 × 11.
• 23 = 23.
• 24 = 23 × 3.
• 25 = 52 .
MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 5/10
Common divisors
Definition. A common divisor of two integers a and b is any integer d such
that both d | a and d | b.
Example. Which of the following are common divisors of 12 and 18?
• 1 is a common divisor of 12 and 18 because 1 | 12 and 1 | 18.
• −6 is a common divisor of 12 and 18 because −6 | 12 and −6 | 18.
• 9 is not a common divisor of 12 and 18 because 9 | 18 but 9 ∤ 12.

Definition. Two integers a and b are coprime or relatively prime if and only
if their only common divisors are 1 and −1. Equivalently, two integers are
coprime if and only if their only positive common divisor is 1.
Example. Which of the following pairs of numbers are coprime?
• 2 and 3 are coprime because 1 is their only positive common divisor.
• 9 and −10 are coprime because 1 is their only positive common divisor.
• 12 and 18 are not coprime because they have positive common divisors
other than 1, for example 2, 3, or 6.
• 0 and 1 are coprime because 1 is their only positive common divisor.

MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 6/10
Greatest common divisors
Definition. The greatest common divisor (GCD) of two integers a and b
(when a and b are not both 0), denoted gcd(a, b), is the natural number
d ∈ N such that
• both d | a and d | b, and
• for all c ∈ N, if c | a and c | b, then c ≤ d.

For example, gcd(3, 5) = 1 and gcd(12, 18) = 6.


If the prime factorisations of a and b are known, then gcd(a, b) can easily be
found by taking the product of the lower powers of each prime factor. For
example, gcd(108, 72) = gcd(22 × 33 , 23 × 32 ) = 22 × 32 = 36.
Example. Find gcd(23 × 32 × 7, 22 × 3 × 5).
Solution. We have gcd(23 × 32 × 7, 22 × 3 × 5) = 22 × 31 × 50 × 70 = 12.
Alternate definition. The greatest common divisor gcd(a, b) of two
integers a and b is the natural number d ∈ N such that
• both d | a and d | b, and
• for all c ∈ N, if c | a and c | b, then c | d.
With this definition, the value of gcd(0, 0) is well-defined and equals 0.
MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 7/10
Properties of the GCD
Some useful properties of the GCD are given below. Suppose a, b, c, q are
integers.
• Property 1. gcd(a, 1) = 1.
• Property 2. gcd(a, 0) = |a|.
• Property 3. gcd(a, gcd(b, c)) = gcd(gcd(a, b), c).
• Property 4. gcd(ac, bc) = |c| gcd(a, b).
• Property 5. If a | bc and gcd(a, b) = 1, then a | c.
• Property 6. If a = qb + c, then gcd(a, b) = gcd(b, c).
Proof. Since a = qb + c and gcd(b, c) is a common divisor of b and c, it
must also be a divisor of a (by the third lemma on slide 3). So
gcd(b, c) ≤ gcd(a, b), since gcd(a, b) is the greatest common divisor of a
and b.
Similarly, since c = a − qb and gcd(a, b) is a common divisor of a and b,
it must also be a divisor of c. So gcd(a, b) ≤ gcd(b, c), since gcd(b, c) is
the greatest common divisor of b and c.
Combining both these inequations, we deduce that gcd(a, b) = gcd(b, c).
MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 8/10
Least common multiples
Definition. The least common multiple (LCM) of two non-zero integers a
and b, denoted lcm(a, b), is the positive integer d ∈ Z+ such that
• both a | d and b | d, and
• for all c ∈ Z+ , if a | c and b | c, then d ≤ c.
For example, lcm(3, 5) = 15, and lcm(4, 6) = 12.
If the prime factorisations of a and b are known, then lcm(a, b) can easily be
found by taking the product of the higher powers of each prime factor. For
example, lcm(108, 72) = lcm(22 × 33 , 23 × 32 ) = 23 × 33 = 216.
Example. Find lcm(23 × 32 × 7, 22 × 3 × 5).
Solution. We have lcm(23 × 32 × 7, 22 × 3 × 5) = 23 × 32 × 51 × 71 = 2520.
Fact. For any positive integers a and b, we have gcd(a, b) lcm(a, b) = ab.
Alternate definition. The least common multiple lcm(a, b) of two integers
a and b is the natural number d ∈ N such that
• both a | d and b | d, and
• for all c ∈ N, if a | c and b | c, then d | c.
With this definition, lcm(a, b) is well-defined even when a or b is 0.
MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 9/10
Case study: Natural numbers as sets
(Remember that “case studies” are additional content and not examinable.)
In the early 1920s, Ernst Zermelo and Abraham Fraenkel set out to describe
set theory entirely axiomatically, meaning they wanted to rigorously
define/prove all aspects of set theory using only a minimal list of assumed
axioms (fundamental truths). Their motivation was to build up a system
that avoided the construction paradoxes like Russell’s paradox. The resulting
so-called Zermelo-Fraenkel set theory is still used as the standard model for
axiomatic set theory today.
Soon thereafter, at the age of 19, mathematician and computer scientist
John von Neumann described a way of defining the natural numbers in the
context of ZF set theory. The system defines the number 0 as being
represented by the empty set, and for each positive integer n, the number
n + 1 is defined by n + 1 := n ∪ {n}. This construction allows the number n
to be represented by the set with cardinality n.
0 := {} = {}
1 := {0} = {{}}
2 := {0,1} = {{},{{}}}
3 := {0,1,2} = {{},{{}},{{},{{}}}}.
MATH1081 Topic 2 – Number theory and relations Lecture 2.01 – Divisibility and greatest common divisors 10/10
MATH1081 – Discrete Mathematics
Topic 2 – Number theory and relations
Lecture 2.02 – The Euclidean algorithm

Lecturer: Dr Sean Gardiner – sean.gardiner@unsw.edu.au


The Division Theorem
Theorem. (Division Theorem)
For any integers a and b with b ̸= 0, there exist unique integers q and r
such that both
a = qb + r and 0 ≤ r < |b|.
We call q the quotient and r the remainder when a is divided by b.
Proof. See Angell: Slide 3.37 (or Gardiner: Lecture 3.04, Example 4).
Example. What is the quotient and remainder when...
• 30 is divided by 7?
Here q = 4 and r = 2, since 30 = 4 × 7 + 2 and 0 ≤ 2 < 7.
• 30 is divided by 6?
Here q = 5 and r = 0, since 30 = 5 × 6 + 0 and 0 ≤ 0 < 6.
• 30 is divided by −4?
Here q = −7 and r = 2, since 30 = (−7) × (−4) + 2 and 0 ≤ 2 < | − 4|.
• −30 is divided by 4?
Here q = −8 and r = 2, since −30 = (−8) × 4 + 2 and 0 ≤ 2 < 4.
MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 1/10
The Euclidean algorithm
The Euclidean algorithm is a process that, given two integers a and b ̸= 0 as
inputs, efficiently finds gcd(a, b). The algorithm makes use of the Division
Theorem, finding quotients and remainders iteratively in the following way:

a = q0 × b + r0 where q0 , r0 ∈ Z and |b| > r0 ≥ 0,


b = q1 × r0 + r1 where q1 , r1 ∈ Z and r0 > r1 ≥ 0,
r0 = q2 × r1 + r2 where q2 , r2 ∈ Z and r1 > r2 ≥ 0,
r1 = q3 × r2 + r3 where q3 , r3 ∈ Z and r2 > r3 ≥ 0,
.. ..
. .
rn−2 = qn × rn−1 + rn where qn , rn ∈ Z and rn−1 > rn ≥ 0,
rn−1 = qn+1 × rn + 0 where qn+1 ∈ Z and rn > 0.

The process terminates immediately after the nth step, when the remainder
is first found to be zero. The remainder at the nth step is then the GCD of
a and b. That is,
gcd(a, b) = rn .

MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 2/10
Example – Euclidean algorithm
Example. Use the Euclidean algorithm to find gcd(403, 286).
Solution. We have
403 = 1 × 286 + 117,
286 = 2 × 117 + 52,
117 = 2 × 52 + 13,
52 = 4 × 13 + 0.

So gcd(403, 286) = 13.


Example. Use the Euclidean algorithm to find gcd(283, 193).
Solution. We have
283 = 1 × 193 + 90,
193 = 2 × 90 + 13,
90 = 6 × 13 + 12,
13 = 1 × 12 + 1,
12 = 12 × 1 + 0.

So gcd(283, 193) = 1. (That is, 283 and 193 are coprime.)


MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 3/10
The Euclidean algorithm – proof
Theorem. For any integer inputs a and b ̸= 0, the Euclidean algorithm
always outputs gcd(a, b).
Proof. To prove this is true, we need to show that the process always
terminates, and always returns the GCD.
As a reminder, the first few steps of the Euclidean algorithm for a and b are:
a = q0 × b + r0 where q0 , r0 ∈ N and |b| > r0 ≥ 0,
b = q1 × r0 + r1 where q1 , r1 ∈ N and r0 > r1 ≥ 0,
r0 = q2 × r1 + r2 where q2 , r2 ∈ N and r1 > r2 ≥ 0 ...
Notice that the process must eventually terminate, since we have
|b| > r0 > r1 > · · · ≥ 0, so the remainders are strictly decreasing, and must
eventually reach zero after at most |b| steps.
Notice also that gcd(a, b) = gcd(b, r0 ), by Property 6 from Lecture 2.01.
Similarly, gcd(b, r0 ) = gcd(r0 , r1 ), and so on. So in particular, if the
algorithm terminates after n steps (so the remainder rn+1 = 0), we have that
gcd(a, b) = gcd(b, r0 ) = gcd(r0 , r1 ) = · · · = gcd(rn−1 , rn ) = gcd(rn , 0).
Recall also that gcd(rn , 0) = rn , so the output of the Euclidean algorithm
really is gcd(a, b).
MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 4/10
Euclidean algorithm in reverse
Recall the Euclidean algorithm applied to 286 and 403 as follows:
403 = 1 × 286 + 117, 1
286 = 2 × 117 + 52, 2
117 = 2 × 52 + 13, 3
52 = 4 × 13 + 0.
Notice that working backwards from the penultimate line, it should be
possible to make careful substitutions so that we can eventually express
gcd(403, 286) as an integer linear combination of 403 and 286:
13 = 117 − 2 × 52 (from 3 )
= 117 − 2 × (286 − 2 × 117) (substituting from 2 )
= 5 × 117 − 2 × 286 (collecting terms)
= 5 × (403 − 286) − 2 × 286 (substituting from 1 )
= 5 × 403 − 7 × 286 (collecting terms).

So we can write gcd(403, 286) in the form 403x + 286y for integers x and y ,
where specifically x = 5 and y = −7.
MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 5/10
Bézout’s identity
The method we just saw can be generalised for any pair of integers.
Theorem. (Bézout’s identity)
Given any integers a and b, there exist integers x and y such that
gcd(a, b) = ax + by .
Values for x and y can be found by applying the Euclidean algorithm to a
and b and then working backwards, like in the previous example.
Note that the solution pair (x, y ) is not unique. For example, we saw
gcd(403, 286) = 13 = 5 × 403 + (−7) × 286, but it is also true that
gcd(403, 286) = 13 = (−17) × 403 + 24 × 286.
Notice that Bézout’s identity cannot be used in reverse. However, the
following weaker statement is true.
Theorem. Given d = ax + by for some integers a, b, x, y , we have that
gcd(a, b) | d.
Proof. By definition, gcd(a, b) | a and gcd(a, b) | b. So gcd(a, b) must be a
divisor of any integer linear combination of a and b, by a previous result
about divisibility.
MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 6/10
Example – Bézout’s identity
Example. Find integers x and y such that gcd(283, 193) = 283x + 193y .
Solution. The Euclidean algorithm applied to 283 and 193 gives:
283 = 1 × 193 + 90,
193 = 2 × 90 + 13,
90 = 6 × 13 + 12,
13 = 1 × 12 + 1,
12 = 12 × 1 + 0.
Working backwards from the penultimate line, we get:
1 = 13 − 12
= 13 − (90 − 6 × 13)
= 7 × 13 − 90
= 7 × (193 − 2 × 90) − 90
= 7 × 193 − 15 × 90
= 7 × 193 − 15 × (283 − 193)
= 22 × 193 − 15 × 283.
So gcd(283, 193) = 1 = 22 × 193 − 15 × 283, that is, x = −15 and y = 22.
MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 7/10
Solving linear equations for integers
Theorem. Given integers a, b, and c, there exist integers x and y such that
ax + by = c if and only if gcd(a, b) | c.
Proof. First suppose ax + by = c for some integers x and y . Since
gcd(a, b) is a divisor of both a and b, we must have that
gcd(a, b) | (ax + by ) for all integers x, y . So gcd(a, b) | c.
Next suppose gcd(a, b) | c. Then c = gcd(a, b)k for some integer k. By
Bézout’s identity, we know there exist integers x ′ and y ′ such that
gcd(a, b) = ax ′ + by ′ . Multiplying through by k then gives
c = a(kx ′ ) + b(ky ′ ) where x = kx ′ and y = ky ′ are integers.
Corollary. Suppose we are given integers a, b, and c, and wish to solve
ax + by = c for integers x and y .
• If gcd(a, b) ∤ c, then there are no integer solutions.
• If gcd(a, b) | c, then we can find integer solutions as follows:
◦ Find integers x ′ and y ′ satisfying ax ′ + by ′ = gcd(a, b) by applying
the Euclidean algorithm to a and b and working backwards.
c ′
◦ Writing d = gcd(a, b), we have that x = dx and y = dc y ′ are integer
solutions to ax + by = c.
MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 8/10
Example – Solving linear equations for integers
Example. Find integers x and y such that 289x + 119y = 13.
Solution. The Euclidean algorithm applied to 289 and 119 gives:
289 = 2 × 119 + 51,
119 = 2 × 51 + 17,
51 = 3 × 17 + 0.
So gcd(289, 119) = 17, which does not divide 13. Thus there are no integer
solutions to 289x + 119y = 13.
Example. Find integers x and y such that 289x + 119y = 34.
Solution. In this case, gcd(289, 119) = 17 is a divisor of 34, so there do
exist integer solutions.
Working backwards from the penultimate line of the Euclidean algorithm:
17 = 119 − 2 × 51
= 119 − 2(289 − 2 × 119)
= 5 × 119 − 2 × 289.
So an integer solution to 17 = 289x ′ + 119y ′ is x ′ = −2 and y ′ = 5.
Thus an integer solution to 34 = 289x + 119y is x = −4 and y = 10.
MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 9/10
Using Bézout’s identity in proofs
When proving statements involving GCDs, it can often be useful to use
Bézout’s identity. That is, if we are given that gcd(a, b) = c, then we can
use the fact that c = ax + by for some x, y ∈ Z.
For example, consider the following applications:
Theorem. Suppose a, b, and c are integers with a | bc and gcd(a, b) = 1.
Then a | c.
Proof. Since a | bc, we may write bc = ak for some integer k.
Since gcd(a, b) = 1, by Bézout’s identity there exist integers x and y such
that 1 = ax + by . Multiplying this through by c gives

c = acx + bcy = acx + aky = a(cx + ky ).

Since ck + ky is an integer, we can conclude that a | c.


Exercise. Suppose a and b are integers and p is a prime number. Prove
that if p | ab, then p | a or p | b.
Proof. (See Problem Set 3, Question 28.)
This property of prime numbers is actually the way prime elements are
generally defined.
MATH1081 Topic 2 – Number theory and relations Lecture 2.02 – The Euclidean algorithm 10/10
MATH1081 – Discrete Mathematics
Topic 2 – Number theory and relations
Lecture 2.03 – Modular arithmetic

Lecturer: Dr Sean Gardiner – sean.gardiner@unsw.edu.au


The mod operator
Recall the Division Theorem states that for any integers a and b with b ̸= 0,
there exist unique integers q and r such that both
a = qb + r and 0 ≤ r < |b|.
In many situations, we are particularly interested in the remainder r .
Notation. The modulo operator mod returns the canonical remainder when
one integer is divided by another. We write a mod b, read as “a modulo b”,
to mean the (smallest non-negative) remainder when a is divided by b. That
is, given integers a and b with b ̸= 0, we have a mod b = r where
0 ≤ r < |b| and a = qb + r for some q, r ∈ Z.
Example. Find the following values:
• 19 mod 4 = 3.
• −11 mod 5 = 4.
• 333 mod 3 = 0.
Notice that a mod b = 0 if and only if b | a.
In most computer programming languages, the mod operator is represented
by the character %. However, this symbol is never used for this purpose in
mathematical texts.
MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 1/9
Modular congruence
We saw that 19 mod 4 = 3, and of course there are infinitely many integers
x such that x mod 4 = 3. We can think of all such numbers as having
something in common, and say they belong to the same equivalence class.
Instead of writing (for example) 19 mod 4 = 47 mod 4, we can use a special
congruence notation 19 ≡ 47 (mod 4).
Notation. Given integers a and b and a positive integer m, we say that a
and b are congruent modulo m and write a ≡ b (mod m) to mean that
a mod m = b mod m.
The following are all equivalent statements:
• a ≡ b (mod m).
• a mod m = b mod m.
• a and b have the same remainder when divided by m.
• a = b + mk for some integer k.
• m | (a − b).

Challenge. Prove the above statements are equivalent.

MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 2/9
Properties of modular arithmetic
Suppose a, b, c, d ∈ Z and m ∈ Z+ . Below are several useful properties of
modular arithmetic:
• If a ≡ b (mod m), and k ∈ Z+ satisfies k | m, then a ≡ b (mod k).
• If a ≡ b (mod m) and c ≡ d (mod m), then a + c ≡ b + d (mod m).
• If a ≡ b (mod m), then a + k ≡ b + k (mod m) for all k ∈ Z.
• If a ≡ b (mod m) and c ≡ d (mod m), then ac ≡ bd (mod m).
• If a ≡ b (mod m), then ak ≡ bk (mod m) for all k ∈ Z.
• If a ≡ b (mod m), then ak ≡ bk (mod mk) for all k ∈ Z+ .
• If ak ≡ bk (mod mk) for some k ∈ Z+ , then a ≡ b (mod m).
(If there is a divisor common to both sides of the congruence and the
modulus, we can “divide” all terms through by that common divisor.)
• If ak ≡ bk (mod m) for some k ∈ Z, and gcd(m, k) = 1, then
a ≡ b (mod m).
(If there is a divisor common to both sides of the congruence and it is
coprime with the modulus, we can “divide” both sides of the congruence
through by that common divisor.)
• If a ≡ b (mod m), then ak ≡ b k (mod m) for all k ∈ Z+ .
MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 3/9
Properties of modular arithmetic – Proofs
Proofs are provided for two of these properties...
Theorem. If a ≡ b (mod m) and c ≡ d (mod m), then ac ≡ bd (mod m).
Proof. Since a ≡ b (mod m), we know that a = b + mk for some integer k,
and since c ≡ d (mod m), we know c = d + ml for some integer l. So
ac = (b + mk)(d + ml) = bd + mbl + mdk + m2 kl = bd + m(bl + dk + mkl)
where bl + dk + mkl ∈ Z. Thus ac ≡ bd (mod m).
Theorem. If ak ≡ bk (mod m) for some k ∈ Z, and gcd(m, k) = 1, then
a ≡ b (mod m).
Proof. Since ak ≡ bk (mod m), we know that m | (ak − bk), so
m | k(a − b). By the GCD Property 5 from Lecture 2.01, since
gcd(m, k) = 1, we must have that m | (a − b), which is equivalent to saying
a ≡ b (mod m).
Challenge. Using similar approaches, prove that the other properties hold.
Similar problems appear in Problem Set 2, Questions 6 and 8.

MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 4/9
Problem-solving with modular arithmetic
Having established these properties of modular arithmetic, we now have a
useful set of tools for solving problems that involve divisibility or remainders.
Example. Prove that a natural number is divisible by 3 if and only if its
digit sum is divisible by 3.
Solution. Let n be any natural number with k + 1 digits d0 , d1 , d2 , ... , dk
from right to left, so that

n = 100 d0 + 101 d1 + 102 d2 + · · · + 10k dk

where each di is an integer between 0 and 9 inclusive. Then working modulo


3, since 10 mod 3 = 1, we have

n = 100 d0 + 101 d1 + 102 d2 + · · · + 10k dk


≡ 10 d0 + 11 d1 + 12 d2 + · · · + 1k dk (mod 3)
≡ d0 + d1 + d2 + · · · + dk (mod 3).

Thus n has the same residue modulo 3 as its digit sum. So in particular,
n mod 3 = 0 if and only if n’s digit sum is congruent to 0 modulo 3,
meaning n is divisible by 3 if and only if its digit sum is divisible by 3.
MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 5/9
Reducing powers modulo m
Finding large powers of the form ak modulo m can be difficult, since while
we are allowed to reduce a modulo m, we cannot reduce the power k in the
same way. However, it is always possible to simplify the expression by finding
small powers of a that reduce to smaller values modulo m, helping to
decrease the value of ak in steps. Typically, we look for a small power of a
that is close to 0 (ideally 1 or −1) modulo m.
Example. Find 71001 mod 12.
Solution. Checking small powers of 7, we first find that 72 ≡ 49 ≡ 1
(mod 12). So we have
500
71001 ≡ 72 × 71 ≡ 1500 × 7 ≡ 7 (mod 12),
meaning 71001 mod 12 = 7.
Example. Find 121001 mod 7.
Solution. First we can note that 121001 ≡ (−2)1001 (mod 7). Checking
small powers of 2, we find that (−2)3 = −8 ≡ −1 (mod 7), so
333
(−2)1001 ≡ (−2)3 × (−2)2 ≡ (−1)333 × 4 ≡ −4 ≡ 3 (mod 7).
Thus 121001 mod 7 = 3.
MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 6/9
Reducing powers modulo m – Example 2
Example. Find 51001 mod 93.
Solution. In order to check small powers of 5 here, it can be useful to use a
table. Working modulo 93, we have:

n 1 2 3 4 5 6 ...
5n 5 25 32 −26 −37 1 ...

Notice that to find each entry in this table, we only needed to multiply the
previous entry by 5 and reduce the result modulo 93. To keep the
multiplications manageable, we can always choose to use the reduced value
that is closest to 0. For example, to find 54 modulo 93, we did the following:

54 = 53 × 5 ≡ 32 × 5 ≡ 160 ≡ 67 ≡ −26 (mod 93).

Seeing that 56 ≡ 1 (mod 93), we can deduce that


166
51001 ≡ 56 × 55 ≡ 1166 × (−37) ≡ −37 ≡ 56 (mod 93).

That is, 51001 mod 93 = 56.

MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 7/9
Reducing powers modulo m – Example 3
Example. Find 3103 mod 15.
Solution. We can again check small powers of 3 here, working modulo 15:

n 1 2 3 4 5 ...
3n 3 9 12 6 3 ...

In this case, we can see we will never encounter a power of 3 that gives 1
modulo 15. But we can also see that the powers of 3 modulo 15 repeat with
period 4. So 3 ≡ 35 ≡ 39 ≡ 313 ≡ · · · ≡ 3101 (mod 15), and thus

3103 ≡ 3101 × 32 ≡ 3 × 9 ≡ 27 ≡ 12 (mod 15).

Alternate solution. We can divide both the value and its modulus by the
common factor of 3 and first find 3102 mod 5. In this case, we can notice
that 32 = 9 ≡ −1 (mod 5), so

3102 ≡ (32 )51 ≡ (−1)51 ≡ −1 ≡ 4 (mod 5).

So 3102 ≡ 4 (mod 5), and we can now multiply both sides of the congruence
and the modulus through by 3 to find 3103 ≡ 12 (mod 15).
MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 8/9
Fermat’s Little Theorem
A useful theorem for simplifying powers in prime moduli is Fermat’s Little
Theorem:
Theorem. (Fermat’s Little Theorem)
For any prime p and any integer a such that p ∤ a, we have
ap−1 ≡ 1 (mod p).
Proof. (See MATH2400 – Finite Mathematics!)
Note that p − 1 is not necessarily the smallest non-negative power of a that
is 1 modulo p.
Example. Find the following values.
• 99100 mod 101.
Solution. Since 101 is prime, by FLT, a100 ≡ 1 (mod 101) for all integers
a where 101 ∤ a. So in this case we must have 99100 mod 101 = 1.
• 99909 mod 101.
Solution. We just showed that 99100 mod 101 = 1, so
99909 = (99100 )9 × 999 ≡ 1 × (−2)9 ≡ −512 ≡ 94 (mod 101).
MATH1081 Topic 2 – Number theory and relations Lecture 2.03 – Modular arithmetic 9/9
MATH1081 – Discrete Mathematics
Topic 2 – Number theory and relations
Lecture 2.04 – Solving linear modular congruences

Lecturer: Dr Sean Gardiner – sean.gardiner@unsw.edu.au


Linear congruences
Definition. A linear congruence is an expression of the form ax ≡ c (mod m)
for given integers a, c, and m. Note that this expression only makes sense if
the unknown x is also an integer.
A linear congruence can have no solutions or infinitely many solutions, which
can be expressed together as values in certain moduli. We shall investigate
this in more detail on the next slides.
Notice that the linear equation ax + my = c, when considered modulo m,
becomes the linear congruence

ax + my ≡ c (mod m),
ax + 0y ≡ c (mod m),
ax ≡ c (mod m).

In fact, the solutions to ax ≡ c (mod m) are precisely the integer x-values


that solve ax + my = c for integers x and y . So what we have learned
about solving integer linear equations will also have applications when
solving linear congruences.

MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 1/10
Linear congruences – Checking all multiples
Example. Find all solutions to the linear congruence 6x ≡ 4 (mod 7).
Solution. Checking the multiples of 6 while working modulo 7, we have:
x 0 1 2 3 4 5 6
6x 0 6 5 4 3 2 1
So the only solution is x ≡ 3 (mod 7).
Example. Find all solutions to the linear congruence 6x ≡ 4 (mod 8).
Solution. Checking the multiples of 6 while working modulo 8, we have:
x 0 1 2 3 4 5 6 7
6x 0 6 4 2 0 6 4 2
So the only solutions are x ≡ 2 (mod 8) and x ≡ 6 (mod 8).
Equivalently, the only solution is x ≡ 2 (mod 4).
Example. Find all solutions to the linear congruence 6x ≡ 4 (mod 9).
Solution. Checking the multiples of 6 while working modulo 9, we have:
x 0 1 2 3 4 5 6 7 8
6x 0 6 3 0 6 3 0 6 3
So there are no solutions to 6x ≡ 4 (mod 9).
MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 2/10
Linear congruences – Using rules of modular arithmetic
Example. Find all solutions to the linear congruence 6x ≡ 4 (mod 7).
Solution. We have
6x ≡ 4 (mod 7),
−x ≡ 4 (mod 7),
x ≡ −4 (mod 7),
x ≡3 (mod 7).

Example. Find all solutions to the linear congruence 6x ≡ 4 (mod 8).


Solution. We have
6x ≡ 4 (mod 8),
3x ≡ 2 (mod 4) (since 2 | 8),
3x ≡ 6 (mod 4),
x ≡2 (mod 4) (since gcd(3, 4) = 1).

Example. Find all solutions to the linear congruence 6x ≡ 4 (mod 9).


Solution. We must have 6x = 4 + 9k for some integer k. But this means
4 = 6x − 9k = 3(2x − 3k) where 2x − 3k ∈ Z, which cannot ever be true
since 3 ∤ 4. So there are no solutions.
MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 3/10
Solving linear congruences
To solve the general linear congruence ax ≡ c (mod m), first consider
simplifying the problem using the standard rules of modular arithmetic.
If the coefficient and/or modulus are too large for this to be practical, we
can always follow the below method, inspired by the method of finding
integer solutions to ax + my = c:
• Find d = gcd(a, m). If d ∤ c, there is no solution.
• If d | c, then solutions exist, and there are exactly d solutions in the
original modulus m. To find these solutions:
◦ Find integers x ′ and y ′ satisfying ax ′ + my ′ = d by applying the
Euclidean algorithm to a and m and working backwards.
c ′ m
◦ The general solution is then x ≡ dx (mod d ).
◦ If d > 1 and we wish to find all d solutions in the original modulus m,
take the solution dc x ′ and repeatedly add m
d to it until there are d
different solutions. That is,
x ≡ dc x ′ + m
dk (mod m)
for each k ∈ {0, 1, 2, ... , d − 1}.
MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 4/10
Solving linear congruences – Example 1
Example. Solve 29x ≡ 11 (mod 101).
Solution. First apply the Euclidean algorithm to the coefficient 29 and the
modulus 101. We have
101 = 3 × 29 + 14,
29 = 2 × 14 + 1,
14 = 14 × 1 + 0.
So gcd(29, 101) = 1. Since 1 | 11, there are solutions to the congruence,
and there should be exactly 1 solution modulo 101.
Working backwards, we find
1 = 29 − 2 × 14
= 29 − 2(101 − 3 × 29)
= 7 × 29 − 2 × 101.
So an integer solution to 29x ′ + 101y ′ = 1 is x ′ = 7 and y ′ = −2.
Since the right-hand side of the congruence is 11, we need to multiply this
answer for x ′ by 11 101
1 = 11 (and the modulus remains as 1 = 101).
So the general solution is x ≡ 11 × 7 ≡ 77 (mod 101).
MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 5/10
Solving linear congruences – Example 2
Example. Solve 119x ≡ 27 (mod 252).
Solution. First apply the Euclidean algorithm to the coefficient 119 and the
modulus 252. We have
252 = 2 × 119 + 14,
119 = 8 × 14 + 7,
14 = 2 × 7 + 0.

So gcd(119, 252) = 7. Since 7 ∤ 27, there cannot be any solutions to this


congruence.
To justify this conclusion, notice that we are trying to solve the equation
119x = 27 + 252k for some integer k. But this can be rearranged to give
27 = 119x − 252k = 7(17x − 36k) where 17x − 36k ∈ Z, which cannot be
true since 7 ∤ 27. So there are no solutions.

MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 6/10
Solving linear congruences – Example 3
Example. Solve 130x ≡ 125 (mod 245).
Solution. First apply the Euclidean algorithm to the coefficient 130 and the
modulus 245. We have
245 = 1 × 130 + 115,
130 = 1 × 115 + 15,
115 = 7 × 15 + 10,
15 = 1 × 10 + 5,
10 = 2 × 5 + 0.
So gcd(130, 245) = 5. Since 5 | 125, there are solutions to the congruence,
and there should be exactly 5 solutions modulo 245.
Working backwards, we eventually find 5 = 17 × 130 − 9 × 245. So an
integer solution to 130x ′ + 245y ′ = 5 is x ′ = 17 and y ′ = −9.
Since the right-hand side of the congruence is 125, we need to multiply this
answer for x ′ by 125 245
5 = 25 and reduce the answer modulo 5 = 49.
So the general solution is x ≡ 17 × 25 ≡ 33 (mod 49), or in the original
modulus, by adding 49 repeatedly to our answer, we have
x ≡ 33, 82, 131, 180, or 229 (mod 245).
MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 7/10
Solving linear congruences – Example 3
Example. Solve 130x ≡ 125 (mod 245).
Alternative approach. Observing that gcd(130, 245) = 5 and that 5 | 125,
we first divide everything through by 5 to get the equivalent congruence
26x ≡ 25 (mod 49). Applying the Euclidean algorithm to 26 and 49 gives:
49 = 1 × 26 + 23,
26 = 1 × 23 + 3,
23 = 7 × 3 + 2,
3 = 1 × 2 + 1,
2 = 2 × 1 + 0.

Working backwards, we eventually find 1 = 17 × 26 − 9 × 49.


Multiplying this equation through by 25 gives the equation
25 = 425 × 26 − 225 × 49. Considering this equation modulo 49 shows that
25 ≡ 425 × 26 ≡ 33 × 26 (mod 49).
So the general solution is x ≡ 33 (mod 49), or in the original modulus, we
have x ≡ 33, 82, 131, 180, or 229 (mod 245).

MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 8/10
Solving linear congruences – Example 3
Example. Solve 130x ≡ 125 (mod 245).
Alternative solution. We have

130x ≡ 125 (mod 245),


26x ≡ 25 (mod 49) (since 5 | 245),
75x ≡ 25 (mod 49),
3x ≡ 1 (mod 49) (since gcd(25, 49) = 1),
3x ≡ −48 (mod 49),
x ≡ −16 (mod 49) (since gcd(3, 49) = 1),
x ≡ 33 (mod 49).

So the general solution is x ≡ 33 (mod 49), or in the original modulus, we


have x ≡ 33, 82, 131, 180, or 229 (mod 245).
Note that this method is much more efficient, but is reliant on finding useful
substitutions and is not guaranteed to work efficiently in general.

MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 9/10
Multiplicative inverses
Definition. The (multiplicative) inverse of an integer x modulo m (if it
exists) is the integer y for which 0 ≤ y < m and xy ≡ 1 (mod m).
Notation. If it exists, we write the inverse of x modulo m as x −1 mod m.
For example, the multiplicative inverse of 3 modulo 7 is 5, since
3 × 5 = 15 ≡ 1 (mod 7). So 3−1 ≡ 5 (mod 7). Similarly, we can find:
x 0 1 2 3 4 5 6
x −1 mod 7 none 1 4 5 2 3 6
Example. Find the multiplicative inverse of 26 modulo 49.
Solution. We want to solve 26x ≡ 1 (mod 49). From the previous example,
we saw via the (reversed) Euclidean algorithm that 1 = 17 × 26 − 9 × 49, so
26 × 17 ≡ 1 (mod 49), meaning that 26−1 ≡ 17 (mod 49).
When given the general linear congruence ax ≡ c (mod m), if the
multiplicative inverse of a exists, we can multiply both sides of the
congruence by this value a−1 , giving x ≡ a−1 c (mod m).
If the multiplicative inverse of a does not exist, either there is no solution to
the congruence, or gcd(a, m) | c, in which case dividing the whole
congruence through by gcd(a, m) will produce a new congruence that we can
solve by repeating the above approach.
MATH1081 Topic 2 – Number theory and relations Lecture 2.04 – Solving linear modular congruences 10/10
MATH1081 – Discrete Mathematics
Topic 2 – Number theory and relations
Lecture 2.05 – Relations and equivalences

Lecturer: Dr Sean Gardiner – sean.gardiner@unsw.edu.au


Relations
Definition. Given sets X and Y , a relation from X to Y is a subset
of X × Y .
Notation. A relation R from a set X to a set Y is declared as R ⊆ X × Y .
If (x, y ) ∈ R, we can say “x is related to y ”. Instead of writing (x, y ) ∈ R,
we can also write x R y . If (x, y ) ̸∈ R, we can write x ̸R y .
A function is a relation with the additional condition that each element of x
has exactly one corresponding y value. That is, R ⊆ X × Y is a function if
and only if for every x ∈ X , there is exactly one y ∈ Y such that x R y .
Notation. Relations can be represented by capital letters like R, but also by
symbols like ∼ or ⪯. In fact, we have already encountered many relations
including =, <, ≤, ∈, ⊆, and |.
For example, the divisibility relation R ⊆ Z × Z is defined by the statement
a R b if and only if b = ak for some k ∈ Z.
So we have R = {(0, 0), (1, 0), (1, 1), (1, 2), ... , (2, 0), (2, 2), (2, 4), ... }.
Equivalently, we could just define the divisibility relation | on Z by
a | b if and only if b = ak for some k ∈ Z.
MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 1/10
Representations of relations
Just like for functions, we can represent relations using arrow diagrams.
For example, in the case with sets X = {a, b, c} and Y = {1, 2}, and
relation R ⊆ X × Y given by R = {(a, 1), (b, 1), (b, 2)}, the relation R can
be represented with an arrow diagram as follows:
X R Y
a
1
b
2
c
Note we no longer require each element of X has exactly one outgoing arrow.
We can also represent relations using a relation matrix. For a relation from
X to Y , we can construct a matrix whose rows are indexed by elements of X
and whose columns are indexed by elements of Y such that each matrix
entry is either 1 if its corresponding row element is related to its
corresponding column element, or 0 otherwise. Note that the appearance of
a relation matrix is dependent on the chosen order ofrows and  columns.
1 0
Using the above example, a relation matrix for R is 1 1.
0 0
MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 2/10
Arrow diagrams as directed graphs
Most of the time, we are interested in relations from a set to itself. We refer
to a relation R ⊆ X × X for some set X as a relation on X .
To represent a relation R on X , we can write out the elements of X just
once and represent the relation as arrows pointing between these elements.
Recall this is known as a directed graph, which will appear again in Topic 5.
For example, in the case with set X = {a, b, c} and relation R on X given
by R = {(a, a), (b, a), (b, c), (c, b)}, the relation R can be represented with
a directed graph arrow diagram as follows:

a b a b

or

c c

Notice that if two elements are related to each other, we can draw two
separate arrows representing these two relations, or just one arrow pointing
in both directions.

MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 3/10
Example – Representing relations
Example. Consider the set of people S = {a, b, c, d, e, f } representing
students Alyx, Barney, Chell, Dog, Eli, and Freeman. The relation R on the
set S is defined by x R y if and only if x considers y to be their friend.
Alyx’s friends are Dog, Eli, and Freeman. Barney’s friends are Freeman and
himself. Dog’s friend is Alyx. Eli’s friends are Alyx and Freeman. Freeman is
friends with everyone else. Represent this relation by a relation matrix and
an arrow diagram.
Solution. A relation matrix and arrow diagram for R are provided below.
 
0 0 0 1 1 1 a b
0 1 0 0 0 1
 
0 0 0 0 0 0
 
1 0 0 0 0 0
 
1 0 0 0 0 1 f
1 1 1 1 1 0 e c

d
MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 4/10
Reflexivity
Definition. A relation R on a set X is reflexive if and only if for all x ∈ X ,
we have x R x.
In an arrow diagram, a loop is an arrow pointing from one element to itself.
In terms of arrow diagrams, a relation R is reflexive if and only if every
element has a loop.
Diagrammatically, this property can be represented as:
implies

Example. Which of the following relations on X = {1, 2, 3, 4} are reflexive?


• R = {(1, 1), (1, 3), (2, 2), (3, 1), (3, 3), (4, 4)} is reflexive since for every
element x ∈ X , we have x R x.
• R = {(1, 1), (1, 3), (2, 4), (3, 1), (3, 3), (4, 2), (4, 4)} is not reflexive since
for the element 2 ∈ X , we do not have 2 R 2.
• R = {(1, 1), (2, 2), (3, 3)} is not reflexive since for the element 4 ∈ X , we
do not have 4 R 4.

MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 5/10
Symmetry
Definition. A relation R on a set X is symmetric if and only if for all
x, y ∈ X , whenever x R y we have y R x.
In terms of arrow diagrams, a relation R is symmetric if and only if every
non-loop arrow points in both directions.
Diagrammatically, this property can be represented as:
implies

Example. Which of the following relations on X = {1, 2, 3, 4} are


symmetric?
• R = {(1, 1), (1, 3), (2, 2), (3, 1), (3, 3), (4, 4)} is symmetric since for every
pair of elements x, y ∈ X , whenever x R y , we have that y R x.
• R = {(1, 1), (1, 3), (2, 4), (3, 1), (3, 3), (4, 4)} is not symmetric since for
the elements 2, 4 ∈ X , we have 2 R 4 but 4 ̸R 2.
• R = {(1, 1), (2, 2), (3, 3)} is symmetric since for every pair of elements
x, y ∈ X , whenever x R y , we have that y R x.
• R = {} is symmetric since the symmetry condition is satisfied vacuously.
MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 6/10
Transitivity
Definition. A relation R on a set X is transitive if and only if for all
x, y , z ∈ X , whenever x R y and y R z, we have x R z.
In terms of arrow diagrams, a relation R is transitive if and only if every pair
of points connected by a path of arrows also has a single arrow from the first
point to the last.
Diagrammatically, this property can be represented as:

implies , and implies

Example. Which of the following relations on X = {1, 2, 3, 4} are transitive?


• R = {(1, 1), (1, 2), (1, 3), (2, 3), (3, 3), (4, 4)} is transitive since for all
elements x, y , z ∈ X , whenever x R y and y R z, we have that x R z.
• R = {(1, 2), (2, 3), (3, 4), (4, 1)} is not transitive since for the elements
1, 2, 3 ∈ X , we have 1 R 2 and 2 R 3 but 1 ̸R 3.
• R = {(1, 1), (1, 3), (2, 2), (3, 1), (4, 4)} is not transitive since for the
elements 1, 3 ∈ X , we have 3 R 1 and 1 R 3 but 3 ̸R 3.
• R = {} is transitive since the transitivity condition is satisfied vacuously.
MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 7/10
Equivalence relations
Definition. A relation R on a set X is an equivalence relation if and only if
it is reflexive, symmetric, and transitive.
If two mathematical objects are related by an equivalence relation, we can
interpret this as meaning they are the same in some particular sense.
For example, a very familiar equivalence relation is = itself. We can easily
check that = on any appropriate set is reflexive, symmetric, and transitive.
Example. Show that the relation ∼ on Z defined by setting x ∼ y if and
only if x ≡ y (mod 3) is an equivalence relation.
Solution. We proceed by proving ∼ is reflexive, symmetric, and transitive.
Reflexivity: Let x ∈ Z. Since x = x + 3 × 0 and 0 ∈ Z, we can write that
x ≡ x (mod 3). So x ∼ x, and thus ∼ is reflexive.
Symmetry: Let x, y ∈ Z, and suppose x ∼ y . Then x = y + 3k for some
integer k. So y = x + 3(−k) where −k ∈ Z, which means y ≡ x (mod 3).
So y ∼ x, and thus ∼ is symmetric.
Transitivity: Let x, y , z ∈ Z, and suppose x ∼ y and y ∼ z. Then x = y + 3k
and y = z + 3l for some integers k and l. So x = z + 3(l + k) where
l + k ∈ Z, which means x ≡ z (mod 3). So x ∼ z, and thus ∼ is transitive.
MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 8/10
Equivalence classes
Definition. Given an equivalence relation ∼ on a set X , and some element
a ∈ X , the equivalence class of a with respect to ∼, written as [a], is the set
of all elements in X that are related to a. That is,
[a] = {x ∈ X : x ∼ a}.
For example, if ∼ is the equivalence relation on Z defined by setting x ∼ y if
and only if x ≡ y (mod 2), then the equivalence class of 0 with respect to ∼
is the set of all integers that have remainder 0 when divided by 2, that is,
[0] = {even numbers}. Similarly, we have [1] = {odd numbers}. Notice that
we could also write [2k] = [0] and [2k + 1] = [1] for any integer k.
Indeed, whenever we write a ≡ b (mod m), we are really saying [a] = [b]
where the equivalence classes are with respect to “congruence modulo m”.
Example. For each of the following equivalence relations ∼ on Z, find the
equivalence class of 6.
• Given x ∼ y if and only if x = y , we have [6] = {6}.
• Given x ∼ y if and only if x ≡ y (mod 3), we have [6] = {3k : k ∈ Z}.
• Given x ∼ y if and only if x has the same number of letters as y when
spelled out in English, we have [6] = {1, 2, 6, 10}.
MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 9/10
Properties of equivalence classes
Lemma. Given an equivalence relation ∼ on a set X , for all x ∈ X we have
that x ∈ [x].
Proof. Since ∼ is reflexive, we know x ∼ x for all x ∈ X . Thus x ∈ [x].
Lemma. Given an equivalence relation ∼ on a set X , for all x, y ∈ X ,
whenever x ∼ y we have [x] = [y ].
Proof. For all a ∈ [x], we have a ∼ x, and since x ∼ y , by the transitive
property of ∼ we have a ∼ y . So a ∈ [y ], implying [x] ⊆ [y ]. Next, for all
a ∈ [y ], we have a ∼ y , and since x ∼ y , by the symmetric property of ∼ we
have y ∼ x. So by the transitive property of ∼, we have a ∼ x. So a ∈ [x],
implying [y ] ⊆ [x]. Thus [x] = [y ].
Theorem. Given an equivalence relation ∼ on a set X , the equivalence
classes with respect to ∼ partition X .
Proof. Clearly the union of all the equivalences classes equals X , since every
element x ∈ X is an element of its own equivalence class [x] (by the first
lemma). It remains to show that the different equivalence classes are
pairwise disjoint. Suppose we have some x, y ∈ X such that [x] ∩ [y ] ̸= ∅.
Then there is some a ∈ X such that a ∈ [x] and a ∈ [y ]. So a ∼ x and
a ∼ y , meaning [a] = [x] and [a] = [y ] by the second lemma, and so
[x] = [y ]. Thus any pair of non-equal equivalence classes must be disjoint.
MATH1081 Topic 2 – Number theory and relations Lecture 2.05 – Relations and equivalences 10/10
MATH1081 – Discrete Mathematics
Topic 2 – Number theory and relations
Lecture 2.06 – Partial orders

Lecturer: Dr Sean Gardiner – sean.gardiner@unsw.edu.au


Antisymmetry
Definition. A relation R on a set X is antisymmetric if and only if for all
x, y ∈ X , whenever x R y and y R x, we have x = y .
In terms of arrow diagrams, a relation R is antisymmetric if and only if it
contains no arrows pointing in both directions.
Diagrammatically, this property can be represented as:
implies we do not have

Example. Let X = {1, 2, 3, 4}. Which of the following relations on X are


antisymmetric?
• R = {(1, 1), (1, 3), (2, 2), (2, 3), (3, 3), (4, 4)} is antisymmetric since for
every pair of elements x, y ∈ X , whenever x R y and y R x, we have that
x = y.
• R = {(1, 1), (1, 3), (2, 4), (3, 1), (3, 3), (4, 2), (4, 4)} is not antisymmetric
since for the pair of elements 1, 3 ∈ X , we have both 1 R 3 and 3 R 1,
but 1 ̸= 3.
Notice that symmetry and antisymmetry are not opposite properties! A
given relation can be either, neither, or both symmetric and antisymmetric.
MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 1/11
Partial order relations
Definition. A relation R on a set X is a partial order relation if and only if
it is reflexive, antisymmetric, and transitive.
Definition. If two mathematical objects are related by a partial order
relation, we say they are comparable. If ⪯ is a partial order relation and
x ⪯ y , we can say “x precedes y ” or “y succeeds x”.
For example, a very familiar partial order relation is ≤ on any subset of R.
We can easily check that ≤ on R is reflexive, antisymmetric, and transitive.
Definition. If a relation ⪯ is a partial order relation on a set X , we call X a
partially ordered set or poset. We sometimes write a partially ordered set as
an ordered pair containing the set and the relation, for example (X , ⪯).
Definition. If a partially ordered set has the property that all of its elements
are comparable with each other, it is called a totally ordered set.
For example, (R, ≤) is a totally ordered set.

MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 2/11
Examples of partial order relations
Example. Let S be a set. Show that the relation ⪯ on P(S) defined by
setting X ⪯ Y if and only if X ⊆ Y is a partial order relation.
Solution. We proceed by proving ⪯ is reflexive, antisymmetric, and
transitive.
Reflexivity: Let X ∈ P(S). Since every element of X is of course an element
of X , we know X ⊆ X , so X ⪯ X and thus ⪯ is reflexive.
Antisymmetry: Let X , Y ∈ P(S), and suppose X ⪯ Y and Y ⪯ X . Then
X ⊆ Y and Y ⊆ X , so by definition, we have X = Y . Thus ⪯ is
antisymmetric.
Transitivity: Let X , Y , Z ∈ P(S), and suppose X ⪯ Y and Y ⪯ Z . Then
X ⊆ Y and Y ⊆ Z , so for all x ∈ X we have x ∈ Y since X ⊆ Y , and
therefore x ∈ Z since Y ⊆ Z . So X ⊆ Z , meaning X ⪯ Z , and thus ⪯ is
transitive.
Hence ⪯ acting on P(S) is a partial order relation.

MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 3/11
Examples of partial order relations
Example. Show that the relation ⪯ on N defined by setting x ⪯ y if and
only if x | y is a partial order relation.
Solution. We proceed by proving ⪯ is reflexive, antisymmetric, and
transitive.
Reflexivity: Let x ∈ N. Since x = x × 1 and 1 ∈ Z, we can write that x | x.
So x ⪯ x, and thus ⪯ is reflexive.
Antisymmetry: Let x, y ∈ N, and suppose x ⪯ y and y ⪯ x. Then y = xk
and x = yl for some natural numbers k and l. So x = (xk)l, implying
kl = 1, whose only solution over the natural numbers is k = l = 1. So
x = y , and thus ⪯ is antisymmetric.
Transitivity: Let x, y , z ∈ N, and suppose x ⪯ y and y ⪯ z. Then y = xk
and z = yl for some natural numbers k and l. So z = (xk)l where kl ∈ N,
which means x | z. So x ⪯ z, and thus ⪯ is transitive.
Hence ⪯ acting on N is a partial order relation.
Notice that if this relation ⪯ acted on the set Z instead of N, the relation
would no longer be antisymmetric and therefore (Z, | ) would not be a
partially ordered set. (For example, 1 | −1 and −1 | 1 but 1 ̸= −1.)
MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 4/11
Hasse diagrams
Notation. Given ⪯ is a partial order relation on some set X , we use the
symbol ≺ to mean “precedes but does not equal”. That is, x ≺ y means
x ⪯ y and x ̸= y .
Definition. A Hasse diagram is a simplified way of representing a partially
ordered set. Given a partial order relation ⪯ on a set X , the Hasse diagram
for the partially ordered set (X , ⪯) is constructed as follows:
• Draw a labelled dot for each element of X .
• For each pair of elements x, y ∈ X , draw a line from x to y with x placed
lower than y if and only if both
◦ x ≺ y , and
◦ there does not exist z ∈ X such that x ≺ z and z ≺ y .

A Hasse diagram contains all the information of a usual arrow diagram for a
poset, but in a simpler format.
• Arrowheads are not needed since direction is implied by element position.
• Loops are not included since they must exist at every element.
• Lines implied by transitivity are not included since they must exist for
every upward path.
MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 5/11
Hasse diagrams – subset example
Example. Draw the Hasse diagram for the partially ordered sets
(P({a, b}), ⊆ ) and (P({a, b, c}), ⊆ ).
Solution.
The Hasse diagram for the poset The Hasse diagram for the poset
(P({a, b}), ⊆ ) is: (P({a, b, c}), ⊆ ) is:
{a, b} {a, b, c}

{a, c}
{a} {b} {a, b} {b, c}

{a} {c}
{} {b}

{}

MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 6/11
Hasse diagrams – divisibility example
Example. Draw the Hasse diagram for the partially ordered set
({1, 2, 3, 4, 6, 8, 9, 12, 18}, | ).
Solution. The Hasse diagram for the poset ({1, 2, 3, 4, 6, 8, 9, 12, 18}, | ) is:

8 12 18

9
4 6

2 3

MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 7/11
Least and greatest elements
Definition. A minimal element of a partially ordered set (X , ⪯) is any
element x ∈ X such that there is no y ∈ X where y ≺ x.
In terms of Hasse diagrams, a minimal element is an element with no lines
connecting to it from below.
Definition. A maximal element of a partially ordered set (X , ⪯) is any
element x ∈ X such that there is no y ∈ X where x ≺ y .
In terms of Hasse diagrams, a maximal element is an element with no lines
connecting to it from above.
Definition. The least element of a partially ordered set (X , ⪯) (if it exists)
is the element x ∈ X for which x ⪯ y for all y ∈ X .
In terms of Hasse diagrams, the least element is the element that can reach
all other elements in X by following lines in a strictly upwards path.
Definition. The greatest element of a partially ordered set (X , ⪯) (if it
exists) is the element x ∈ X for which y ⪯ x for all y ∈ X .
In terms of Hasse diagrams, the greatest element is the element that can
reach all other elements in X by following lines in a strictly downwards path.
MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 8/11
Least and greatest elements – Examples and properties
Example. Find the minimal, maximal, least, and greatest elements of
(P({a, b, c}), ⊆ ).
Solution. The only minimal element is {}, which is also the least element.
The only maximal element is {a, b, c}, which is also the greatest element.
Example. Find the minimal, maximal, least, and greatest elements of
({1, 2, 3, 4, 6, 8, 9, 12, 18}, | ).
Solution. The only minimal element is 1, which is also the least element.
The maximal elements are 8, 12, and 18. There is no greatest element, since
for example, 8 and 12 are not comparable.
Fact. The following statements are true for any partially ordered set (X , ⪯).
• If it exists, the least element is unique.
• If it exists, the greatest element is unique.
• If X is finite, the poset has a least element if and only if it has exactly
one minimal element.
• If X is finite, the poset has a greatest element if and only if it has exactly
one maximal element.

MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 9/11
Lower and upper bounds
Definition. Given a partially ordered set (X , ⪯), a lower bound of two
elements x, y ∈ X is any element z ∈ X such that z ⪯ x and z ⪯ y .
In terms of Hasse diagrams, a lower bound of x and y is any element that
can reach both x and y by following lines in strictly upwards paths.
Definition. Given a partially ordered set (X , ⪯), the greatest lower bound of
two elements x, y ∈ X , denoted glb(x, y ), is the greatest element amongst
the set of all lower bounds (if it exists). That is, glb(x, y ) is the greatest
element (if it exists) of {z ∈ X : z ⪯ x and z ⪯ y }.
Definition. Given a partially ordered set (X , ⪯), an upper bound of two
elements x, y ∈ X is any element z ∈ X such that x ⪯ z and y ⪯ z.
In terms of Hasse diagrams, an upper bound of x and y is any element that
can reach both x and y by following lines in strictly downwards paths.
Definition. Given a partially ordered set (X , ⪯), the least upper bound of
two elements x, y ∈ X , denoted lub(x, y ), is the least element amongst the
set of all upper bounds (if it exists). That is, lub(x, y ) is the least element
(if it exists) of {z ∈ X : x ⪯ z and y ⪯ z}.

MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 10/11
Lower and upper bounds – Examples and properties
Example. In the poset (P({a, b, c}), ⊆ ), find glb({a, b}, {b, c}) and
lub({a}, {a, b}) if they exist.
Solution. The lower bounds of {a, b} and {b, c} are {b} and {}, so the
greatest lower bound exists and is {b}. The upper bounds of {a} and {a, b}
are {a, b} and {a, b, c}, so the least upper bound exists and is {a, b}.
Example. In the poset ({1, 2, 3, 4, 6, 8, 9, 12, 18}, | ), find glb(12, 18) and
lub(4, 9) if they exist.
Solution. The lower bounds of 12 and 18 are 1, 2, 3, and 6, so the greatest
lower bound exists and is 6. There is no upper bound for 4 and 9, so their
least upper bound does not exist in this poset.
Fact. For any set S, in the partially ordered set (P(S), ⊆ ), for any two
elements A, B ∈ P(S) we have glb(A, B) = A ∩ B and lub(A, B) = A ∪ B.
Fact. In the partially ordered set (Z+ , | ), for any two elements a, b ∈ Z+
we have glb(a, b) = gcd(a, b) and lub(a, b) = lcm(a, b).
Note that the least element of (Z+ , | ) is 1, but it has no greatest element.
If we use the “alternate definition” given for the GCD and LCM, the above
facts also hold for the poset (N, | ), whose greatest element is 0.
MATH1081 Topic 2 – Number theory and relations Lecture 2.06 – Partial orders 11/11

You might also like