DIT12113 Discrete Mathematics Topic 3 ST
DIT12113 Discrete Mathematics Topic 3 ST
Topic 3: Relations
Contents :
The most direct way to express a relationship between elements of two sets is to use ordered pairs
made up of two related elements. For this reason, sets of ordered pairs are called binary relations.
In this section we introduce the basic terminology used to describe binary relations.’
Let’s assume that a person owns three shirts and two pairs of slacks. More precisely, let A = {blue
shirt, red shirt, green shirt} and B = {grey slack, red slacks}. Then A × B is the set of all six
possible combinations of shirts and slacks that the individual could wear. However, an individual
may wish to restrict himself or herself to combinations which are color coordinated, or “related.”
This may not be all possible pairs in A × B but will certainly be a subset of A × B . For example,
one such subset may be {(blue shirt, grey slacks), (green shirt, grey slacks)}
Suppose R is a relation from A to B. Then R is a set of ordered pairs where each first element comes
from A and each second element comes from B. That is, for each pair a ∈ A and b ∈ B, exactly one
of the following is true:
Relations are used in mathematics, statistics, and data sciences. It is an integral part of RDBMS
(Relational Database Management Systems) that is used in searching, storing, and sorting large
data.
Relations are more general than functions. A function is a relation where exactly one element of
B is related to each element of A.
Example 3.1
Let A = {0, 1, 2} and B = {4, 5}. Then {(1, 4), (2, 4), (3, 5)} is a relation from A into B.
A relation from a set A into itself is called a relation on A. If R is a relation from a set A to itself,
that is, if R is a subset of A2 = A×A, then we say that R is a relation on A. The domain of a relation R
is the set of all first elements of the ordered pairs which belong to R, and the range is the set of
second elements.
For example, let A = {1, 2, 3} and B = {x, y, z}. Then the inverse of R = {(1, y), (1, z), (3, y)} is
R−1 = {(y, 1), (z, 1), (y, 3)}
Clearly, if R is any relation, then (R−1)−1 = R. Also, the domain and range of R−1 are equal,
respectively, to the range and domain of R. Moreover, if R is a relation on A, then R−1 is also a
relation on A.
Example 3.2
Let A = {0, 1, 2} and B = {a, b}. Then {(0, a), (0, b), (1, a), (2, b)} is a relation from A to B. This
means, for instance, that 0Ra, but that 1R b. Relations can be represented graphically, as shown in
Figure below, using arrows to represent ordered pairs. Another way to represent this relation is to
use a table, which is also done in Figure below.
Example 3.3
How many relations are there on a set with n elements?
Solution :
Solution:
Topic 3 - 2
DIT12113 DISCRETE MATHEMATICS
Properties of Relations
There are several properties that are used to classify relations on a set. In some relations an element
is always related to itself. For instance, let R be the relation on the set of all people consisting of
pairs (x, y) where x and y have the same mother and the same father. Then xRx for every person x.
1. Reflexive Relations
A relation R on a set A is called reflexive if (a, a) ∈ R for every element a ∈ A.
Remark: Using quantifiers we see that the relation R on the set A is reflexive if ∀a((a, a) ∈ R),
where the universe of discourse is the set of all elements in A.
For example, A = {2, 3} then the reflexive relation R on A is, R = {(2, 2), (3, 3)}
Example 3.4:
Consider the following relations on {1, 2, 3, 4}:
R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)},
R2 = {(1, 1), (1, 2), (2, 1)},
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)},
R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)},
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)},
R6 = {(3, 4)}.
Which of these relations are reflexive?
Solution :
2. Symmetric Relations
A relation R on a set A is symmetric if whenever aRb then bRa, that is, if whenever (a, b) ∈ R then
(b, a) ∈ R. Thus R is not symmetric if there exists a, b ∈ A such that (a, b) ∈ R but (b, a) ∈ R.
For example, A = {2, 3} then symmetric relation R on A is, R = {(2, 3), (3, 2)}
3. Antisymmetric Relations
A relation R on a set A is antisymmetric if whenever aRb and bRa then a = b, that is, if a = b and
aRb then bRa. Thus R is not antisymmetric if there exist distinct elements a and b in A such that
aRb and bRa.
Topic 3 - 3
DIT12113 DISCRETE MATHEMATICS
Example 3.5 :
Determine which of the relations in Example 3.4 are symmetric and which are antisymmetric?
Solution :
4. Transitive Relations
A relation R on a set A is transitive if whenever aRb and bRc then aRc, that is, if whenever
(a, b), (b, c) ∈ R then (a, c) ∈ R. Thus R is not transitive if there exist a, b, c ∈ R such that (a, b), (b,
c) ∈ R but (a, c) ∈ R.
For example, set A = {1, 2, 3} then transitive relation R on A is, R = {(1, 2), (2, 3), (1, 3)}
Example 3.6 :
Which of the relations in Example 3.4 are transitive?
Solution :
5. 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.
Example 3.7
Let A = {1, 2, 3} and B = {1, 2, 3, 4}. The relations R1 = {(1, 1), (2, 2), (3, 3)} and
R2 = {(1, 1), (1, 2), (1, 3), (1, 4)} can be combined to obtain
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)}.
Topic 3 - 4
DIT12113 DISCRETE MATHEMATICS
6. Empty Relation
A relation R on a set A is called Empty if the set A is an empty set, i.e. any relation where no
element of set A is not related to the element of set B then it is called an empty relation.
For example, A = {1, 2, 3} and B = {5, 6, 7} where, R = {(x, y) where x + y = 22}, then it is an
empty relation.
7. Equivalence Relation
A relation is an Equivalence Relation if it is reflexive, symmetric, and transitive. i.e. relation
R = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1), (2, 3), (3, 2), (1, 3), (3, 1)} on set A = {1, 2, 3} is
equivalence relation as it is reflexive, symmetric, and transitive.
8. Universal Relation
Universal relation is a relation in which all elements of set are mapped to other element of set
then it is called universal relation. For example, A = {4, 8, 12} and B = {1, 2, 3} then universal
relation is, R = {(x, y) where x > y}
Composite
Let R1 be a relation from a set A to a set B and R2 a relation from B to a set C. The composite of R2
with R1 is the relation from A to C, consisting of ordered pairs (a, c), where a ∈ A, c ∈ C, and for
which there exists an element b ∈ B such that (a, b) ∈ R1 and (b, c) ∈ R2. We denote the composite
by R2 ◦R1.
Example 3.8
What is the composite of the relations R and S (S ◦R), 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)}?
Solution :
Example 3.9:
A = {1,2,3}, B = {1,2,3,4}, C = {0,1,2}
R:A→B
R = {(1,1), (1,4), (2,3), (3,1), (3,4)}
S:B→C
S = {(1,0), (2,0), (3,1), (3,2), (4,1)}
S o R = {(1,0),(1,1),(2,1),(2,2),(3,0),(3,1)}
Topic 3 - 5
DIT12113 DISCRETE MATHEMATICS
n-ary relations.
All the relations discussed above were binary relations. The relationships among elements from
more than two sets are called n-ary relations.
By an n-ary relation, we mean a set of ordered n-tuples. For any set S, a subset of the product set Sn
is called an n-ary relation on S. In particular, a subset of S3 is called a ternary relation on S.
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.
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.
Definition:
Projection Pi1, i2,..,im maps the n-tuple (a1,a2,..,an) to the m-tuple (ai1,..,aim) where m<= n.
Example: P(1,3) on Students Database: <Student_Name, Major>.
Definition:
Selection Sc maps the n-ary relation R to the n-ary relation of all n-tuples from R that satisfy the
condition C.
Example: Condition C can be Major = Computer Science.
Gives a set of n-tuples with students majoring CS.
Definition:
R: relation of degree m. S: relation of degree n. Join Jp(R,S) [p <= m and p <= n], is a relation of
degree m + n – p that consists of all (m + n – p) tuples (a1, a2,..,am-p, c1, c2,.., cp, b1, b2,…, bn-p). (a1,
a2,..,am-p, c1, c2,.., cp) in R. (c1, c2,.., cp, b1, b2,…, bn-p) in S.
Topic 3 - 6
DIT12113 DISCRETE MATHEMATICS
Representing Relations
A relation between finite sets can be represented using a zero- one matrix. Suppose R is a relation
from A = {a1, a2, …, am} to B = {b1, b2, …, bn}.
The elements of the two sets can be listed in any particular arbitrary order. When A = B, we use the
same ordering.
The matrix representing R has a 1 as its (i,j) entry when ai is related to bj and a 0 if ai is not related
to bj
Example 3.11
Suppose that A = {1, 2, 3} and B = {1, 2}. Let R be the relation from A to B containing (a, b) if a∈
A, b ∈ B and a > b. Determine the matrix representing R (assuming the ordering of
elements is the same as the increasing numerical order).
Solution :
Example 3.12
Let A = {a1, a2, a3} and B = {b1, b2, b3, b4, b5}. Which ordered pairs are in the relation R
0 1 0 0 0
represented by the matrix M R = 1 0 1 1 0 ?
1 0 1 0 1
Solution :
Topic 3 - 7
DIT12113 DISCRETE MATHEMATICS
Matrices of Relations on Sets
If R is a reflexive relation, all the elements on the main diagonal of MR are equal to 1.
1
1
MR =
1
1
Let R be the relation from A to B containing (a, b) if a∈ A, b ∈ B and a > b. Determine the matrix
representing R (assuming the ordering of elements is the same as the increasing numerical order).
Solution :
Example 3.13
Find the inverse relation of R = {(1, 3), (2, 4), (3, 5)}
Solution :
Example 3.14
Find the inverse relation of R = {(a, x), (b, y), (c, z)}
Solution :
Topic 3 - 8
DIT12113 DISCRETE MATHEMATICS
Representing Relation using Digraphs
◼ A directed graph, or digraph, consists of a set V of vertices together with a set E of ordered
pairs of elements of V called edges. The vertex a is call the initial vertex of the edge (a,b),
and the vertex b is called the terminal vertex of this edge.
A relation R is transitive if and only if whenever there is an edge from vertex x to a vertex y and an
edge from a vertex y to a vertex z, there is an edge from x to z
Topic 3 - 9
DIT12113 DISCRETE MATHEMATICS
Closures of Relations
◼ Let R be a relation on a set A. R may or may not have some property P, such as reflexivity,
symmetry, or transitivity.
◼ If there is a relation S with property P containing R such that S is a subset of every relation
with property P containing R, then S is called the closure of R with respect to P.
◼ 3 types of Closures exists:
1. Reflexive Closure
2. Symmetric Closure
3. Transitive Closure
Reflexive Closure
◼ Given a relation R on a set A is not reflexive.
◼ The reflexive closure of R can be formed by adding ordered pairs (a,a) not already in A,
where a Є A.
◼ These new additions will make the new relation reflexive which contains R.
Example: A = {1,2,3}
Let R = {(1,1), (1,2), (2,1), (3,2)}
R is not reflexive since it does not contain (2,2) and (3,3).
Adding these two ordered pairs to R will make the new relation, say S, reflexive. Also, S contains
R. Thus, S is a reflexive closure of R.
Symmetric Closure
◼ Given a relation R on a set A is not symmetric.
◼ The symmetric closure of a relation R can be constructed by adding all the ordered pairs of
the form (b,a), where (a,b) is in R, that are not already in R.
Example: A = {1,2,3}
Let R = {(1,1), (1,2), (2,1), (3,2)}
The ordered pair (2,3) is to be added to R. This new relation S will then be symmetric. S will then
be called the symmetric closure of R.
Topic 3 - 10
DIT12113 DISCRETE MATHEMATICS
◼ Let R be a relation on a set A.
◼ There is a path of length n, where n is a positive integer, from a to b if and only if (a,b) Є Rn.
◼ The connectivity relation R* consists of the pairs (a,b) such that there is a path of length at
least one from a to b in R.
◼ Rn consists of the pairs (a,b) such that there is a path of length n from a to b, it follows that
R* = R n
n =1
◼ The transitive closure of a relation equals the connectivity relation R*
Review :
Topic 3 - 11