Discrete Mathematics : Relations
Abid Afsan Hamid
Lecturer
CSE Department
Northern University of Business and Technology, Khulna
1 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Example of Relation
● Two people are related by blood if they share a common
ancestor
● The relationship between student and teacher
● The relationship between people who work for the same
employer
● The relationship between people who share a common ethnic
background or A is less than B or C is parallel to D or X is a
subset of Y.
2 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Example of Relation
● Relations consider the existence or nonexistence of a certain
connection between pairs of objects taken in a definite order
● Relation is defined in terms of ordered pairs (a, b) of elements
where a is designated as the first element and b is the second
element
3 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Product Sets
● Given sets A and B, the Cartesian product of A and B,
denoted A × B and read “A cross B,” is the set of all ordered
pairs (a, b), where a is in A and b is in B.
● Symbolically:
A × B = {(a, b) | a ∈ A and b ∈ B} .
4 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Product Sets
● Let A ={1, 2, 3} and B ={u, v}
● A × B ={(1, u), (1, v), (2, u), (2, v), (3, u), (3,v)}
● B × A ={(u, 1), (u, 2), (u, 3), (v, 1), (v, 2), (v, 3)}
● B × B ={(u, u), (u, v), (v, u), (v, v)}
● Number of elements in Cartesian Product
n(A × B ) = n(A) × n(B )
5 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Product Sets
● Let A ={0, 1, 2} and B ={1, 2, 3} and
● Let us say that an element x in A is related to an element y in
B if, and only if, x is less than y.
● Let us use the notation xRy as a shorthand for the sentence
“x is related to y.” Then
6 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Product Sets
● Then
0 R 1 since 0 < 1,
0 R 2 since 0 < 2,
0 R 3 since 0 < 3,
1 R 2 since 1 < 2,
1 R 3 since 1 < 3, and
2 R 3 since 2 < 3.
7 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Product Sets
● If the notation x y represents the sentence “x is not related
to y,” then
● 1 1 since 1 1,
● 2 1 since 2 1, and
● 2 2 since 2 2.
8 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Product Sets
● Let A ={0, 1, 2} and B ={1, 2, 3}
● The Cartesian product of A and B, A × B, consists of all
ordered pairs whose first element is in A and whose second
element is in B: A × B = {(x, y) | x ∈ A and y ∈ B}
● In this case, A × B = {(0, 1) ,(0, 2), (0, 3), (1, 1), (1, 2), (1, 3),
(2, 1), (2, 2), (2, 3)}
9 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Product Sets
● Some ordered pairs in A × B are related, Some are not.
Consider the set of all ordered pairs in A × B whose elements
are related
● (0, 1),(0, 2), (0, 3), (1, 2), (1, 3), (2, 3)
10 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Definition of Relation
● Let A and B be sets. A relation R from A to B is a subset of A ×
B. Given an ordered pair (x, y) in A × B, x is related to y by
R, written xRy, if, and only if, (x, y) is in R. The set A is
called the domain of R and the set B is called its range.
11 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Definition of Relation
● The notation for a relation R may be written symbolically as
follows:
xRy means that (x, y) ∈ R.
● The notation x y means that x is not related to y by R:
x y means that (x, y)∉R.
12 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Definition of Relation
● Let A = {eggs, milk, corn} and B ={cows, goats, hens}
● If we define a relation R from A to B by (a, b) ∈ R if a is
produced by b then
● R = {(eggs, hens), (milk, cows), (milk, goats)}
13 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Identity, Universal and Empty of Relation
● Let A be any set. An important relation on A is that of equality
{(a, a):a ∈ A}
● This relation is also called identity or diagonal relation
● Let A be any set. A x A and Φ are subset of A x A and hence
are relation on A called universal relation and empty relation.
14 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Inverse Relation
● Let R be a relation from A to B.
R = {(x, y) ∈ A × B | (x, y) ∈ R}.
● Then inverse relation of R denoted by R−1 from B to A is
defined as follows:
R−1 ={(y, x) ∈ B × A | (x, y) ∈ R}.
15 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Inverse Relation
● Let R be any relation from a set A to a set B. The inverse of R
denoted by R-1, is the relation from B to A which consists of
those ordered pairs which, when reversed, belong to R; that
is R-1 = {( b, a): ( a, b) ∈ R}.
● For instance, the inverse of the relation R = {(1,y), (1, z), (3,
y)} from A={1, 2, 3} to B={x, y, z} is
R-1 ={(y,1), (z,1), (y,3)}
● Inverse of R-1 is R.
16 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Inverse Relation
● Let A ={2, 3, 4} and B ={2, 6, 8} and let R be the “divides”
relation from A to B. For all (x, y) ∈ A × B,
xRy ⇔ x | y x divides y.
● R = {(2, 2), (2, 6), (2, 8), (3, 6), (4, 8)}
● R−1 ={(2, 2), (6, 2), (8, 2), (6, 3), (8, 4)}
17 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Pictorial Representation of R : Matrix
● Let A ={1,2,3}, B={x,y,z} and a relation from A to B is,
R={(1,y),(1,z),(3,y)
x y z
1 0 1 1
2 0 0 0
3 0 1 0
18 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Pictorial Representation of R : Arrow Diagram
● Let A ={2, 3, 4} and B ={2, 6, 8} and let R be the “divides”
relation from A to B:For all (x, y) ∈ A × B,
xRy ⇔ x | y x divides y.
● R = {(2, 2), (2, 6), (2, 8), (3, 6), (4, 8)}
19 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Pictorial Representation of R : Directed Graph
● A ={3, 4, 5, 6, 7, 8} and a relation R on A is defined as
follows: For all x, y ∈ A, xRy ⇔ 2 | (x − y)
● R = {(3,3), (3,5), (3,7), (4,4), (4,6), (4,8), (5,3), (5,5), (5,7),
(6,4),(6,6), (6,8), (7,3),(7,5),(7,7), (8,4), (8,6), (8,8)}
20 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Combining Relations
● Because relations from A to B are subsets of A × B, two
relations from A to B can be combined in any way two sets
can be combined.
21 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Combining Relations
● Set A ={1, 2, 3} , Set B ={1, 2, 3, 4}.
● R1 ={(1, 1), (2, 2), (3, 3)} , R2 ={(1, 1), (1, 2), (1, 3), (1, 4)}
● R1 ∪ R2 ={(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (3, 3)}
● R1 ∩ R2 ={(1, 1)},
● R1 − R2 ={(2, 2), (3, 3)},
● R2 − R1 ={(1, 2), (1, 3), (1, 4)}
22 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Combining Relations : Composition of Relations
● Let R be a relation from a set A to a set B and S a relation
from B to a set C.
● The composite of R and S is the relation consisting of ordered
pairs (a, c), where a ∈ A, c ∈ C, and for which there exists
an element b ∈ B such that (a, b) ∈ R and (b, c) ∈ S.
● We denote the composite of R and S by S◦R.
23 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Combining Relations : Composition of Relations
● Computing the composite of two relations requires that we
find elements that are the second element of ordered pairs in
the first relation and the first element of ordered pairs in the
second relation.
24 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Combining Relations : Composition of Relations
● What is the composite of the relations R and S, where R is
the relation from {1, 2, 3} to {1, 2, 3, 4} with R ={(1, 1), (1, 4),
(2, 3), (3, 1), (3, 4)} and S is the relation from {1, 2, 3, 4} to {0,
1, 2}
● with S ={(1, 0), (2, 0), (3, 1), (3, 2), (4, 1)}?
25 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Combining Relations : Composition of Relations
● R ={(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)}
● S ={(1, 0), (2, 0), (3, 1), (3, 2), (4, 1)}
● S◦R is constructed using all ordered pairs in R and ordered
pairs in S, where the second element of the ordered pair in R
agrees with the first element of the ordered pair in S.
● For example, the ordered pairs (2, 3) in R and (3, 1) in S
produce the ordered pair (2, 1) in S◦R.
● S ◦R ={(1, 0), (1, 1), (2, 1), (2, 2), (3, 0), (3, 1)}.
26 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Types of Relations
● Reflexive Relations
Symmetric Relations
Transitive Relations
● Let A ={2, 3, 4, 6, 7, 9} and a relation R on A is defined as
follows: For all x, y ∈ A,
● xRy ⇔ 3 | (x − y)
27 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Types of Relations
● The directed graph for R has the appearance shown below.
28 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Types of Relations
● An arrow looping around from it back to itself.
● An arrow going from one point to a second, there is an arrow
going from the second point back to the first.
● An arrow going from one point to a second and from the
second point to a third, there is an arrow going from the first
point to the third.
29 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Types of Relations
● Property (1) corresponds to the property of reflexivity
● Property (2) corresponds to the property of symmetry
● Property (3) correspond to the property of transitivity
30 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Types of Relations
● Let R be a relation on a set A.
● R is reflexive if, and only if, for all x ∈ A, xRx.
● R is symmetric if, and only if, for all x, y ∈ A, if xRy then yRx.
● R is transitive if, and only if, for all x, y, z ∈ A, if xRy and yRz
then xRz.
31 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
N-Ary Relations
● Let A1, A2 ,..., An be sets. An n-ary relation on these sets is a
subset of A1 × A2 ×···× An.
● The sets A1, A2 ,..., An are called the domains of the relation,
and n is called its degree.
32 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
N-Ary Relations : Example
● Let R be the relation on N × N × N consisting of triples (a, b,
c), where a, b, and c are integers with a<b<c.
● Then (1, 2, 3) ∈ R, but (2, 4, 3) ∉ R. The degree of this
relation is 3. Its domains are all equal to the set of natural
numbers.
33 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Closure of Relation
● A computer network has data centers in Khulna, Nawapara,
Fultala, Jashore.
● One-way telephone lines
from Khulna to Nawapara
from Nawapara to Fultala
from Nawapara to Jashore
● Let R be the relation containing (a, b) if there is a telephone
line from the data center in a to that in b.
34 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Closure of Relation
● How can we determine if there is some (possibly indirect) link
composed of one or more telephone lines from one center to
another?
● Because not all links are direct, such as the link from Khulna
to Jashore that goes through Nawapara, R cannot be used
directly to answer this.
● In the language of relations, R is not transitive, so it does not
contain all the pairs that can be linked.
35 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Closure of Relation
● We can find all pairs of data centers that have a link by
constructing a transitive relation S containing R such that S is
a subset of every transitive relation containing R. Here, S is
the smallest transitive relation that contains R. This relation is
called the transitive closure of R.
36 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Closure of Relation
● The Reflexive Closure of R is R ∪ ∆
● The Symmetric Closure of R is the relation R ∪ R-1
● The Transitive Closure of R is the relation
R* = R ∪ R2 ∪ R3 ∪ …….∪ Rn where R2 = R ◦ R,
R3 = R2 ◦ R and Rn = Rn-1 ◦ R.
37 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Closure of Relation : Reflexive
● A={1, 2, 3, 4}
● R={(1,1), (1,3), (2,4), (3,1), (3,3), (4,3)}
● ∆ = {(1,1), (2,2), (3,3), (4,4)}
● Reflexive closure of R is R ∪ ∆
● Reflexive(R) = {(1,1), (1,3), (2,4), (3,1), (3,3), (4,3)} ∪ {(1,1),
(2,2), (3,3), (4,4)}
38 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Closure of Relation : Symmetric
● A={1, 2, 3, 4}
● R={(1,1), (1,3), (2,4), (3,1), (3,3), (4,3)}
● R-1 = {(1,1), (3,1), (4, 2), (1, 3), (3,3), (3, 4)}
● Symmetric closure of R is R ∪ R-1
● Symmetric(R) = {(1,1), (1,3), (2,4), (3,1), (3,3), (4,3)} ∪
{(1,1), (3,1.), (4, 2), (1, 3), (3,3), (3, 4)}
39 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Closure of Relation : Transitive
● A = {1, 2, 3}
● R = {(1,2), (2,3), (3,3))
● R2 = R ◦ R = {(1,3), (2,3), (3,3)}
● R3 = R2 ◦ R = {(1,3), (2,3), (3,3)}
● Transitive (R) = R ∪ R2 ∪ R3
= {(1,2), (2,3), (3,3), (1,3))}
40 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Equivalence Relation
● 1/2 , 2/4 , 3/6, −1/−2, −3/−6, 15/30, and so on are all different
ways to represent the same number. They may look different;
they may be called different names; but they are all equal.
The idea of grouping together things that “look different but
are really the same” is the central idea of equivalence
relations.
41 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Equivalence Relation
● A relation on a set A is called an equivalence relation if it is
reflexive, symmetric, and transitive.
● Two elements a and b that are related by an equivalence
relation are called equivalent. The notation a ∼ b is often used
to denote that a and b are equivalent elements with respect to
a particular equivalence relation.
● Let R be the relation on the set of real numbers such that aRb
if and only if a − b is an integer. Is R an equivalence relation?
42 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Equivalence Relation
● Is it reflexive?
● Because a−a = 0 is an integer for all real numbers a, aRa for
all real numbers a.
● Hence, R is reflexive.
43 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Equivalence Relation
● Is it symmetric?
● Now suppose that aRb. Then a−b is an integer, so b−a is also
an integer. Hence, bRa. It follows that R is symmetric.
44 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Equivalence Relation
● Is it transitive?
● If aRb and bRc, then a−b and b−c are integers.
● Therefore, a−c = (a−b) + (b−c) is also an integer. Hence, aRc.
Thus, R is transitive.
● So, R is an equivalence relation.
45 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Relation Induced by Partition
● A partition of a set A is a finite or infinite collection of
nonempty, mutually disjoint subsets whose union is A.
● The diagram illustrates a partition of a set A by subsets A1,
A2,..., A6.
46 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Relation Induced by Partition
● Given a partition of a set A, the relation induced by the
partition, R, is defined on A as follows: For all x, y ∈ A,
● xRy ⇔ there is a subset Ai of the partition such that both x
and y are in Ai .
47 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Relation Induced by Partition
● Let A ={0, 1, 2, 3, 4} and consider the following partition of A:
● {0, 3, 4}, {1}, {2}.
● What is the relation R induced by this partition?
48 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Relation Induced by Partition
49 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Relation Induced by Partition
● The fact is that a relation induced by a partition of a set
satisfies all three properties: reflexivity, symmetry, and
transitivity.
50 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Equivalence Classes
● Consider the relation R on A that consists of all pairs (x, y),
where x and y graduated from the same high school
● Set of all students who graduated from the same high school
as x did
● This subset of A is called an equivalence class of the relation.
51 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Equivalence Classes
● Equivalence Classes / Equivalence Classes of Relation
● Let A ={0, 1, 2, 3, 4}
● R ={(0, 0), (0, 4), (1, 1), (1, 3), (2, 2), (3, 1), (3, 3), (4, 0), (4,
4)}
● Equivalent Class?
52 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Equivalence Classes
● Equivalence class of every element of A
● [0]={x ∈ A | x R 0}={0, 4}
● [1]={x ∈ A | x R 1}={1, 3}
● [2]={x ∈ A | x R 2}={2}
● [3]={x ∈ A | x R 3}={1, 3}
● [4]={x ∈ A | x R 4}={0, 4}
● Note that [0]=[4] and [1]=[3]. Thus the distinct equivalence
classes of the relation are {0, 4}, {1, 3}, and {2} .
53 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Antisymmetric Relation
● A relation R on set A is antisymmetric if whenever aRb and
bRa then a=b, that is, if whenever (a, b), (b, a) ∈ R then a=b.
(b, a)∈ R . Thus R is not antisymmetric if there exists a, b ∈
A such that (a, b) and (b, a) belong to R but a b and
A={1,2,3,4} and R1 ={(1,1),(1,2),(2,3),(1,3),(4,4)}
● R2 ={(1,1),(1,2),(2,1),(2,2),(3,3), (4,4)} - Not Antisymmetric
● R3 =Φ, the empty relation and R4 = AxA, the universal
relation - Not Antisymmetric.
54 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Partial Ordering Relation
● A relation R on set A is called partial ordering or a partial order
if it is reflexive, antisymmetric, and transitive.
● A set A together with a partial ordering R is called a partially
ordered set or poset.
55 CSE Department, Northern Uni. Of Business & Technology 09/04/2023
Partial Ordering Relation
● Example of Partial Ordering Relation
● “Less Than or Equal to” Relation
● Let S be a set of real numbers and define the “less than or
equal to” relation, ≤, on S as follows: For all real numbers x
and y in S,
x ≤ y ⇔ x < y or x = y, x≤ y or y≤ z then x≤ z
56 CSE Department, Northern Uni. Of Business & Technology 09/04/2023