You are on page 1of 7

1 CS 30 : Discrete Mathematics for Computer Science I

Lesson 6: Relations
Main reference : Discrete mathematics and Its Applications, 7th edition, Kenneth H. Rosen

1 Relations
Recall the definition of a Cartesian Product:

Definition 1 The Cartesian Product of two sets, A, and B, is given as:

A × B = {(a, b)|a ∈ A and b ∈ B}

Definition 2 Given sets X and Y , a relation X to Y is a subset of X × Y , denoted as R.


When (x, y) ∈ R, we say that x is related to y under R, written as xRy. Similarly, (x, y) ∈
/R
is denoted as x 6R y.

The infix notation is commonly used for binary relations.

Example 1 Commonly used binary relations.


1. =, 6=, ≤, ≥, <, > for real numbers.

2. ⊆, ⊂, ⊇, ⊃ for sets.
3. ∈, for set membership relation A × P(A).

Note that arithmetic operators are also relations. Consider the addition operation, +:
x + y = z, for x, y, z ∈ R. The + relation can be expressed as + : (R × R) × R.

Definition 3 The inverse of a given relation R from a set X to set Y is the relation R−1
= {(y, x) : y ∈ Y, x ∈ X, and (x, y) ∈ R}.

Example 2 Consider the divisibility relation R ⊆ Z × Z:

xRy if and only if x|y.

The inverse of R, R−1 , can be defined as:

yR−1 x if and only if x|y.

Here, R−1 can be read as y is a multiple of x.

Example 3 Consider the square operation y = x2 . Here, define a relation R ⊆ R × R as:


xRy if and only if y = x2 . The inverse relation R−1 can be defined as yR−1 x if and only if
1 √
x = y 2 = y.

1.1 Properties of Relations on Sets


Definition 4 A relation R on a set X (X × X) is said to be:
• reflexive if ∀x ∈ X, xRx.
• symmetric if ∀x, y ∈ X, xRy → yRx.

• antisymmetric if ∀x, y ∈ X, xRy and yRx → x = y.


• transitive if ∀x, y, z ∈ X, xRy and yRz → xRz.

Copyright c 2020 Nestine Hope S. Hernandez, Richelle Ann B. Juayong and Kelvin C. Buño
nshernandez@up.edu.ph;rbjuayong@up.edu.ph;kcbuno@up.edu.ph
2 CS 30 : Discrete Mathematics for Computer Science I

Example 4 Determine if the following relations, over the set of real numbers, are reflexive,
symmetric, antisymmetric, or transitive:

= < ≤ 6=
R O X O X
S O X X O
AS O O O X
T O O O X

Example 5 Let R≡3 over Z be defined as follows:

mR≡3 n if and only if 3 | (m − n)

• R≡3 is reflexive.
Proof: Suppose m is an integer. We have to show that mR≡3 m. Note here that
m − m = 0, and 3 | 0. Therefore, mR≡3 m.

• R≡3 is symmetric.
Proof: Suppose that m and n are integers, and that mR≡3 n. We have to show that
nR≡3 m. By definition of R≡3 , 3 | (m − n). By definition of divisibility, m − n = 3k,
for some integer k. Multiplying both sides by (−1), we obtain, n − m = 3(−k). Note
here that (−k) is an integer. Hence, 3 | (n − m). Therefore, nR≡3 m.

• R≡3 is transitive.
Proof: Suppose that m, n, and p are integers, and mR≡3 n, and nR≡3 p. We have to
show that mR≡3 p. By definition of R≡3 , 3 | (m − n) and 3 | (n − p). By definition
of divisibility, m − n = 3k, and n − p = 3l, for some integers k and l. By algebra,
n = m − 3k = 3l + p,

m − 3k = 3l + p
m − p = 3l + 3k
m − p = 3(l + k)

Note that (l + k) is an integer, and hence, 3 | (m − p). Therefore, mR≡3 p.

2 Equivalence Relations
Definition 5 An equivalence relation on a set X is a relation that is reflexive, symmetric,
and transitive.
Given an equivalence relation R on a set X, and two elements x, y ∈ X, x and y are said
to be equivalent if and only if xRy.

Example 6 Let R be a relation on the set R2 , defined by

(x1 , y1 )R(x2 , y2 ) if and only if by1 c = by2 c

Show that R is an equivalence relation.

Copyright c 2020 Nestine Hope S. Hernandez, Richelle Ann B. Juayong and Kelvin C. Buño
nshernandez@up.edu.ph;rbjuayong@up.edu.ph;kcbuno@up.edu.ph
3 CS 30 : Discrete Mathematics for Computer Science I

Proof:

(R is reflexive.) Suppose (x, y) ∈ R2 . Note that byc = byc. Hence, (x, y)R(x, y). There-
fore, R is reflexive.

(R is symmetric.) Suppose (x1 , y1 ), (x2 , y2 ) ∈ R2 , and (x1 , y1 )R(x2 , y2 ). By definition


of R, by1 c = by2 c. By definition of the floor function, there exists a unique integers n1 , n2
such that, n1 = by1 c, and n2 = by2 c. So, n1 = n2 . By symmetry of =, n2 = n1 , and hence,
by2 c = by1 c. Hence, (x2 , y2 )R(x1 , y1 ). Therefore, R is symmetric.

(R is transitive.) (x1 , y1 ), (x2 , y2 ), (x3 , y3 ) ∈ R2 , and (x1 , y1 )R(x2 , y2 ), and (x2 , y2 )R(x3 , y3 ).
By definition of R, by1 c = by2 c, and by2 c = by3 c. By transitivity of =, by1 c = by3 c. Hence,
(x1 , y1 )R(x3 , y3 ). Therefore, R is transitive.
Definition 6 Given an equivalence relation R on a set X, the equivalence class (under
R) of an element x ∈ X is the set {y|y ∈ X ∧ yRx} of all elements of X that are equivalent
to x. The equivalence class of x ∈ X under R is denoted as [x]R .
Properties of Equivalence classes
Let X be any set, and let R be an equivalence relation on X. For all x, y ∈ X,
1. yRx if and only if [y] = [x]
2. [y] 6= [x] if and only if [y] ∩ [x] = ∅
Example 7 Congruence Modulo n: For a fixed n ∈ N, n > 1, define a relation R on Z, by
aRb if and only if a≡b (mod n) if and only if n|(a − b)
1. Show that R is an equivalence relation.
2. What are the set of distinct equivalence classes of the integers modulo n?

{[0], [1], [2], ..., [n − 1]}


Definition 7 A partition of the set A is a finite or infinite collection of non-empty, mu-
tually disjoint subsets whose union is A.
For a set A, the collection of sets A1 , A2 , ... is a partition of A if the following condition
holds:
1. Ai ∩ Aj = ∅, whenever i 6= j, and
2. For an infinite collection of non-empty sets:

[
A= Ai
i=1

and for a finite collection of non-empty set, if there are n sets, then:
n
[
A= Ai
i=1

Example:
1. Let A be the closed interval [−5, 5]. Let P be the collection
{−5} ∪ {(n, n + 1]|n ∈ Z ∧ −5 ≤ n ≤ 4}
Is P a partition of A?

Copyright c 2020 Nestine Hope S. Hernandez, Richelle Ann B. Juayong and Kelvin C. Buño
nshernandez@up.edu.ph;rbjuayong@up.edu.ph;kcbuno@up.edu.ph
4 CS 30 : Discrete Mathematics for Computer Science I

2. Let A be the open interval (−5, 5). Let P be the collection


{(n, n + 1)|n ∈ Z ∧ −5 ≤ n ≤ 5}
Is P a partition of A?
Lemma 1 Given an equivalence relation R on a set X, the collection of distinct equivalence
classes
{[x]|x ∈ X}
is a partition of X.

3 Partial Ordering Relations


Definition 8 Let R be a relation defined on a set X. R is a partial order relation if,
and only if, R is reflexive, antisymmetric, and transitive.
X is said to be a partially ordered set or poset under R, that is, (X, R) is a poset.
Definition 9 (Alternative definition) A relation R over a set X is antisymmetric if, and
only if, for a, b ∈ X,
if a 6= b and a R b → b 6R a
Remark: Prove equivalence of this definition with that in Definition 4.
Definition 10 Let R be a partial order relation on a set X. For two elements x, y ∈ X, x
is comparable to y (under R) if and only if x R y, or y R x.
Example 8 Let R be a relation on Z+ defined as:
a R b ⇔ a|b
1. Is R a partial ordering relation? YES

• As previously discussed, any positive integer divides itself, hence the reflexive prop-
erty. The transitivity of divisibility is already known. That leaves the proof for
anti-symmetry.
Proof:
(R is anti-symmetric) Suppose that x, y ∈ Z+ , and that xRy and yRx. Need to show
that x = y. By definition of R, x|y means that y = ax, and y|x means that x = by,
for some integers a, b. Note here that because x and y are positive integers, then a and
b are also positive integers. By algebra, substituting x with by, we have that y = aby.
For this to be true, a = 1 and b = 1. This implies that x = y. Therefore, R is
anti-symmetric.

2. If R is a relation on Z with the same definition, is R still a partial ordering relation?


NO

Proof: A counter-example to the anti-symmetry of R over Z is to have an integer k


and its negative −k. The two integers divide each other, but they are not equal.
Example 9 Let P be the set of all people who have ever lived. Let R be relation over P
defined as:
r R s ⇔ r is an ancestor of s, or r is the same person as s (r = s)
Is R a partial ordering relation? Prove or give a counter-example.

Copyright c 2020 Nestine Hope S. Hernandez, Richelle Ann B. Juayong and Kelvin C. Buño
nshernandez@ up. edu. ph; rbjuayong@ up. edu. ph; kcbuno@ up. edu. ph
5 CS 30 : Discrete Mathematics for Computer Science I

Definition 11 A partial order relation R on a set X is called a total order relation or


linear order relation if every pair of elements is comparable.
X is said to be a totally ordered set under R.

Examples:

1. The relation ≤ over the set of real numbers is a total order relation.
2. Let A be a set. The relation ⊆ over the set of subsets of A (or P(A)) is not a total
order relation.

Copyright c 2020 Nestine Hope S. Hernandez, Richelle Ann B. Juayong and Kelvin C. Buño
nshernandez@up.edu.ph;rbjuayong@up.edu.ph;kcbuno@up.edu.ph
6 CS 30 : Discrete Mathematics for Computer Science I

Definition 12 • Let Σ be a set of symbols, referred to as an alphabet.


→ →
• A finite word/string, x over Σ is a sequence of symbols x = x1 x2 ...xn , where xi ∈ Σ,
for 1 ≤ i ≤ n, and n ∈ Z+ ∪ {0}.
→ →
• Let x = x1 x2 ...xn be a finite string over an alphabet Σ. | x | denotes the number of
→ →
symbols x has, that is | x | = n.

• The empty string, a finite string of length 0, is denoted by ε.

Definition 13 Let Σ be an alphabet, and let S be the set of all finite strings over Σ. Let R
be a partial ordering relation on Σ.
The lexicographical ordering relation, denoted as , is a relation over S defined as
follows:
→ →
1. Let x = x1 x2 ...xm , y = y1 y2 ...yn ∈ S, for some integers m and n. If m ≤ n, and xi = yi
→ →
for all i, 1 ≤ i ≤ m, then, x  y .
→ →
2. Let x = x1 x2 ...xm , y = y1 y2 ...yn ∈ S, for some integers m and n. If for some integer
k, k ≤ m, n, and k ≥ 1, xi = yi , for all i, 1 ≤ i ≤ k − 1, and xk Ryk , and xk 6= yk ,
→ →
then x  y .
→ →
3. For any string z ∈ S, ε  z .

As a final note, when the term partial order relation is used, it refers to the reflexive
or non-strict partial order relation.

Copyright c 2020 Nestine Hope S. Hernandez, Richelle Ann B. Juayong and Kelvin C. Buño
nshernandez@up.edu.ph;rbjuayong@up.edu.ph;kcbuno@up.edu.ph
7 CS 30 : Discrete Mathematics for Computer Science I

4 Exercises
1. Let R be a relation on Z × (Z − {0}), defined as

(a, b) R (c, d) ⇔ ad = bc

(a) Show that R is an equivalence relation.


(b) Give 5 examples for each of the following the equivalence class under R:
i. [(3, 4)]
ii. [(1, 2)]
iii. [(10, 30)]
2. Let R be an equivalence relation on a set X. Show that ∀x, y, z ∈ X, if x ∈ [y], and
y ∈ [z], then [x] = [z].
3. Let A = {−4, −3, −2, −1, 0, 1, 2, 3, 4}. Let R be a relation on A defined as

m R n ⇔ 5|(m2 − n2 )

Find the distinct equivalence classes on R.


4. Partition the set of numbers {20, 500, 5, 176, 80, 605} according to the following equiv-
alence relations:
(a) “has the same number of digits as”
(b) “has the same set of prime divisors as”
(c) “ends with the same digit as”
5. Find a simple equivalence relation that yields the given partition on the of file names
{hw1.ods, hw1.odt, hw2.odp, hw2.ods, hw2.odt}.
(a) {hw1.odt, hw2.odt}, {hw1.ods, hw2.ods}, {hw2.odp}
(b) {hw1.odt, hw1.ods}, {hw2.odt, hw2.ods, hw2.odp}
You can express your answer as phrases.
6. For any set A, give a relation R over A that is reflexive, symmetric, antisymmetric,
and transitive.
7. The greatest element of a partially ordered set A under a relation R, is the element
a ∈ A, such that for all b ∈ A, b R a. Likewise, the least element of A is the element
a ∈ A, such that for all b ∈ A, a R b.
Determine if the following sets has a greatest element or least element under the relation
≤ (“Less than or equal to”). Justfiy your answer.

(a) The set real numbers, R.


(b) The open interval (0, 1).
(c) The closed interval [0, 1].
(d) The interval [0, +∞).
(e) The interval (−∞, 0].
(f) Let a, b ∈ Z. The set {x ∈ Z|a ≤ x ≤ b}.

8. Let R be a partial order relation on a set A, and let B be a subset of A. Show that B
is also a partially ordered set under R.

Copyright c 2020 Nestine Hope S. Hernandez, Richelle Ann B. Juayong and Kelvin C. Buño
nshernandez@up.edu.ph;rbjuayong@up.edu.ph;kcbuno@up.edu.ph

You might also like