Discrete Mathematics
Lecture 4: Sets, Relations and Functions
Partha Sarathi Mandal
IIT Guwahati
Relations
• Let X be a set of all human beings in the world.
• a human x X is related to another human y X if x is father of y.
• (x,y) order is important
• Give two human x and y, they may or may not related to each other.
• First we consider ordered pair (x,y) X x X
• Second we say that the ordered pair (x,y) such that x is related to y form a subset of X x X,
which may be proper.
• A relation R on a nonempty set X is a subset of X x X (R X x X ).
• Given such a subset R X x X, we say that x is related to y under R if (x,y) R.
In this case we write xRy.
• Sometimes it is denoted as xRy and sometime by abuse of notation we will say
R is the relation.
Relation
• A binary relation from A to B is a subset of the cartesian product A x B.
• Example:
A = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K }
B = { S, H, D, C }
Spades = { (1,S), (2,S), (3,S), …, (Q,S), (K,S) }
Spades is a binary relation.
Relation
• A k-ary relation is a subset of a cartesian of k sets.
• Example:
L = { (x, y, z) | x + 2y + 3z = 0, and x, y, z ℝ}
the line L is a ternary relation of the space ℝ3
Binary Relation
• In the remaining of this lecture, we focus on a special type of relations:
• the binary relation from a set A to A.
• Such a relation is called a binary relation on A.
• Example : A = the set of integers
R = { (a, b) | a – b 12 }
Types of Binary Relations
• A binary relation R on A is said to be reflexive if, for every a A,
(a, a) R.
• Which of the following relations are reflexive ?
• R = { (a, b) | a – b 12, a, b are integers }
• S = { (a, b) | a b, a, b are integers }
• T = { (a, b) | a < b, a, b are integers }
• U = { (x, y) | x and y are on the same weekday, x, y are days in July 2023 }
Types of Binary Relations
• A binary relation R on A is said to be irreflexive if (a, a) R for every
a A.
• Which of the following relations are irreflexive ?
• R = { (a, b) | a – b 12, a, b are integers }
• S = { (a, b) | a b, a, b are integers }
• T = { (a, b) | a < b, a, b are integers }
• U = { (x, y) | x and y are on the same weekday, x, y are days in July 2023 }
Types of Binary Relations
• A binary relation R on A is said to be symmetric if, for every a, b A
whenever (a, b) R, then (b, a) R.
• Which of the following relations are symmetric ?
• R = { (a, b) | a – b 12, a, b are integers }
• S = { (a, b) | a b, a, b are integers }
• T = { (a, b) | a < b, a, b are integers }
• U = { (x, y) | x and y are on the same weekday, x, y are days in July 2023 }
Types of Binary Relations
• A binary relation R on A is said to be antisymmetric if, for every a, b
A, whenever (a, b) R and (b, a) R, then a = b.
• Which of the following relations are antisymmetric ?
• R = { (a, b) | a – b 12, a, b are integers}
• S = { (a, b) | a b, a, b are integers }
• T = { (a, b) | a < b, a, b are integers }
• U = { (x, y) | x and y are on the same weekday, x, y are days in July 2023 }
Types of Binary Relations
• A binary relation R on A is said to be transitive if, for every a, b, c A,
whenever (a, b), (b,c) R, then (a, c) R.
• Which of the following relations are transitive ?
• R = { (a, b) | a – b 12, a, b are integers }
• S = { (a, b) | a b, a, b are integers }
• T = { (a, b) | a < b, a, b are integers }
• U = { (x, y) | x and y are on the same weekday, x, y are days in July 2023 }
Representing Binary Relations
• Let A be a finite set
• The binary relation on A can be convenient represented in two
different ways :
1 2 3 4
• Method 1: Matrix Form 1
A = { 1, 2, 3, 4 } 2
R = { (1,1), (1,2), (2,3), (2,4), (3,4), (4,2) } 3
4
Representing Binary Relations
• Method 2: Directed Graph
A = { 1, 2, 3, 4 }
R = { (1,1), (1,2), (2,3), (2,4), (3,4), (4,2) }
1 2
3 4
Closures
• Given a binary relation R, we may obtain a new relation R’ by adding
items into R, such that R’ will have certain property.
• Example :
R = { (1,1), (1,2), (2,3), (2,4), (3,4), (4,2) } on A = { 1, 2, 3, 4 }
If we add (2,2), (3,3), and (4,4) into R, the resulting relation will be reflexive.
Closures
• Let R be a binary relation
• The smallest possible relation R’ that contains R as a subset, such that
R’ has a property P, is the closure of R with respect to P.
1 2 3 4 1 2 3 4
1 1
2 2
3 3
4 4
Reflexive closure of R
Closures
• What is the transitive closure of
R = {(1,1), (1,2), (2,3), (2,4), (3,4), (4,2)} ?
1 2 3 4 1 2 3 4
1 1
2 2
3 3
4 4
Transitive closure of R
Finding Transitive Closure
• Getting the transitive closure seems difficult.
• Is there a systematic way to get this ?
--think about it.
Equivalence Relations
• A relation may have more than one properties.
• A binary relation R on a set A is an equivalence relation if it is
reflexive, symmetric, and transitive.
• Suppose that A = cities in a country X
R = { (x, y) | x can reach y by roads }
• Is R always an equivalence relation, if
1) roads are always two-ways ?
2) some roads may be one-way ?
Equivalence Relations
• Which of the following are equivalence relations ?
Fig-1 Fig-2 Fig-3
Equivalence Relations
• Suppose a binary relation R contains the pairs (a, b) as defined in the
following cases.
• In which of the following cases will R be an equivalence relation ?
1. R1={(a, b) : a – b is an integer ; a, b ℝ}
2. R2={(a, b) : |a – b| < 1 ; a, b ℝ}
3. R3={(a, b) : a – b is divisible by 3 ; a, b ℤ}
4. R4={(a, b) : a divides b ; a, b ℤ +}
Equivalence Classes
• Let R be an equivalence relation on A, and x be an item in A.
• If (x, w) R, we say w is related to x, and we denote this by xRw or
xw or xw.
• The equivalence class of x (with respect to R) is the set of items
related to x :
[x]R = { w | (x, w) R }.
Equivalence Relations
• Example 1 : R = { (a, b) | a – b is divisible by 3, a, b ℤ }
[-1]R = { ? }
[-1]R = { …, -7, -4, -1, 2, 5, 8, 11, … }
[0]R = { ? }
[0]R = { …, -9, -6, -3, 0, 3, 6, 9, … }
[1]R = { …, -8, -5, -2, 1, 4, 7, 10, … }
[2]R = { …, -7, -4, -1, 2, 5, 8, 11, … }
[7]R = { …, -8, -5, -2, 1, 4, 7, 10, … }
Equivalence Classes
• Example 2 :
R = equivalence relation corresponding to the directed graph below.
Equivalence Classes
• Let R be an equivalence relation on A, and
x and y be items in A.
• Theorem: The equivalence classes of x and y are either the same, or
disjoint. That is, either
[x]R = [y]R or [x]R ∩ [y]R = ∅
Equivalence Classes
Proof:
Case 1: x is related to y
xRy yRx (why?)
When xRz, we have yRz (since yRx and xRz)
[x]R = [y]R
Case 2: x is not related to y
Suppose on the contrary that [x]R ∩ [y]R ∅
There exists some z such that zRz and yRz
xRz and zRy (why?) xRy contradiction!
Partition of a Set
• Let S be a set.
• A partition of S is a collection of disjoint subsets of S such that their
union is S. In other words, the collection of subsets A1, A2, …, Ak forms
a partition of S, if and only if
A1 ∪ A2 ∪ …, ∪Ak = S, and
Ai ∩ Aj = ∅ for all i j
Partition of a Set
• Let R be an equivalence relation on a set A.
• Theorem : The equivalence classes of R form a partition of A.
Partition of a Set
• In fact, the converse of the previous theorem is also true.
• Theorem: Let A1, A2, …, Ak be disjoint subsets that form a partition of
a set S. There exists an equivalence relation R on S such that has the
sets A1, A2, …, Ak as its equivalence classes.