18CS36 Discrete Mathematical Structures: Relations & Functions
18CS36 Discrete Mathematical Structures: Relations & Functions
Module 3
Relations & Functions
Prepared by
Venkatesh P
Assistant Professor
Department of Science and Humanities
Sri Sairam College of Engineering
Anekal, Bengaluru-562106
Content
MODULE -3
RELATIONS AND FUNCTIONS
☻Syllabus:
Relations and Functions: Cartesian Products and Relations, Functions – Plain and One-to One,
Onto Functions. The Pigeon-hole Principle, Function Composition and Inverse Functions.
Relations: Properties of Relations, Computer Recognition – Zero-One Matrices and Directed
Graphs, Partial Orders – Hasse Diagrams, Equivalence Relations and Partitions.
☻Cartesian Products:
For set A, B ⊆ U, the Cartesian product of A and B is denoted by A × B and equals
{(a, b) |a ϵ A, b ϵ B}
Example: Let U = {1,2,3, … .7}, A = {2,3,4}, B = {4,5}
Then (a). A × B = {(2, 4), (2 ,5), (3, 4), (3, 5), (4, 4), (4, 5)}
(b). B 2 = B × B = {(4, 4), (4, 5), (5, 4), (5, 5)}
(c). B 3 = B × B × B = {(a, b, c)|a, b, c ϵ B}
☻Relation:
For sets A, B ⊆ U any subset of A × B is Called a Relation From A to B and any subset of A × A
is called a Binary relation on A.
Example:
Let A and B be finite sets with |B| = 3. If there are 4096 relations from A to B what is |A|?
Solution: If |A| = m, |B| = n then there are 2mn relations from A to B.
Given n = 3, 2mn = 4096 ∴ m = 4 = |A|.
☻Functions:
Let A and B be two non-empty sets. Then a function f from A to B is a relation from A to B such
that for each a in A there is a unique b in B such that (𝐚, 𝐛) 𝛜 𝐟
Types of Functions:
(a). Floor function:
The function 𝑓: 𝑅 → 𝑍, is given by
𝑓(𝑥 ) = ⌊𝑥⌋ = The greatest integer less than or equal to x.
⌊3.8⌋ = 3
⌊−3.8⌋ = −4
(b). Ceiling Function:
In other words, If different elements of A have different images in B under 𝑓; If whenever 𝑓(𝑎1 ) =
𝑓 (𝑎2 ) for 𝑎1 , 𝑎2 ∈ 𝐴, then 𝑎1 = 𝑎2
(f). Surjective or onto: A function 𝑓: 𝐴 → 𝐵 is called onto if for every element b of B there is an
element a of A such that 𝑓(𝑎) = 𝑏
In other words. 𝑓 is an onto function from A to B if every element of B has a Preimage in A.
(g). Bijective or one-to-one correspondence: A function which is both one-to-one and onto is
called Bijective.
n
n
𝑃(𝑛, 𝑚) = ∑ (−1)k (n−k )(n − k)m
k=0
Problems:
1. Let 𝐴 = {1,2,3,4,5,6,7}, 𝐵 = {𝑤, 𝑥, 𝑦, 𝑧}. Find the number of Onto Functions from A to B.
Solution: Given 𝑚 = |𝐴| = 7 & 𝑛 = |𝐵| = 4
n
4
𝑃(7,4) = ∑ (−1)k (4−k )(4 − k)7 = 8400
k=0
☻Pigeonhole Principle:
If 𝑚 pigeons occupy 𝑛 pigeon holes and if 𝑚 > 𝑛, then two or more pigeons occupy the same
pigeonhole.
Generalization:
If 𝑚 pigeons occupy 𝑛 pigeonholes, then at least one pigeonhole must contain (𝑝 + 1) or more
(𝑚−1)
pigeons, where 𝑝 = ⌊ ⌋
𝑛
Problems:
1. ABC is an equilateral triangle whose sides are of length 1cm each. If we select 5 points
inside the triangle, prove that at least 2 of these points are such that the distance between
1
them is less than 2 cm.
Solution:
Consider the triangle DEF formed by the mid points of the sides BC, CA and AB of the given
triangle ABC. Then the triangle ABC is partition into 4 small equilateral triangles, each of which
1
has sides equal to cm treating each of these four portions as a pigeonhole and 5 points chosen
2
inside the triangle as pigeons, we find by using the pigeonhole principle that at least one portion
1
must contain two or more points. Evidently the distance between such points is < 2 cm.
2. A magnetic tape contains a collection of 5 lakh strings made up to four or fewer number of
English Letters can all the strings is the collection be distinct?
Solution:
Each place is an n letter string can be filled in 26 ways. Therefore, the possible number of strings
made up of n letters is 26𝑛 consequently, the total number of different possible strings made up of
four or fewer letter is 264 + 263 + 262 + 26 = 4,75,254.
Therefore, if there are 5 lakh strings in the tape, then at least one string is repeated. Thus, all the
strings in the collection cannot be distinct.
3. Shirts numbered consecutively from 1 to 20 are worn by 20 students of a class. When any
3 of these students are chosen to be a debating team from the class, the sum of their shirt
numbers is used as a code number of the team. Show that if any 8 of the 20 are selected,
then from these 8 we may form at least two different teams having the same code number.
Solution:
From the 8 of the 20 students selected the numbers of teams of 3 students that can be formed is
8
𝐶 3=56. According to the way in which the code number of a team is determined, we note that the
smallest possible code number is 1 + 2 + 3 = 6 and the largest possible code number is 18 +
19 + 20 = 57. Thus, the code number vary from 6 to 57, and these are 52 in number. As such
only 52 code number are available for 56 possible teams, consequently by the pigeonhole principle,
at least two different teams will have the same code number.
☻Composition of functions:
Consider three non-empty sets A, B, C and the functions 𝑓: 𝐴 → 𝐵 and 𝑔: 𝐵 → 𝐶. the composition
of these two functions is defined as the function 𝑔𝑜𝑓: 𝐴 → 𝐶 with (𝑔𝑜𝑓)(𝑎) = 𝑔{𝑓(𝑎)} for all
𝑎𝜖𝐴.
Problems:
1. Consider the function 𝑓 and 𝑔 defined by 𝑓(𝑥) = 𝑥 3 and 𝑔(𝑥) = 𝑥 2 + 1 Ɐ 𝑥𝜖𝑅 find
𝑔𝑜𝑓, 𝑓𝑜𝑔, 𝑓 2 and 𝑔2
Solution:
Here, both f and g are defined on R, therefore all of the functions 𝑔𝑜𝑓, 𝑓𝑜𝑔, 𝑓 2 = 𝑓𝑜𝑓and 𝑔2 =
𝑔𝑜𝑔 are defined on R and we find
(𝑔𝑜𝑓)(𝑥) = 𝑔{𝑓(𝑥)} = 𝑔(𝑥 3 ) = (𝑥 3 )2 + 1 = 𝑥 6 + 1
(𝑓𝑜𝑔)(𝑥) = 𝑓{𝑔(𝑥)} = 𝑓(𝑥 2 + 1) = (𝑥 2 + 1)3
𝑓 2 (𝑥) = (𝑓𝑜𝑓)(𝑥) = 𝑓{𝑓(𝑥)} = 𝑓(𝑥 3 ) = (𝑥 3 )3 = 𝑥 9
𝑔2 (𝑥 ) = (𝑔𝑜𝑔)(𝑥) = 𝑔{𝑔(𝑥 )} = 𝑔(𝑥 2 + 1) = (𝑥 2 + 1)2 + 1
Solution:
(𝑔𝑜𝑓)(1) = 𝑔{ 𝑓 (1)} = 𝑔(4) = 1 = 𝐼𝐴 (1)
(𝑔𝑜𝑓)(2) = 𝑔 {𝑓(2)} = 𝑔(1) = 2 = 𝐼𝐴 (2)
Solution:
We check that for any 𝑥𝜖𝑅
(𝑔𝑜𝑓)(𝑥 ) = 𝑔[𝑓(𝑥 )] = 𝑔(2𝑥 + 5)
= 1/2(2𝑥 + 5 − 5) = 𝑥 = 𝐼𝑅 (𝑥)
(𝑓𝑜𝑔)(𝑥) = 𝑓[𝑔(𝑥)] = 𝑓{1/2(𝑥 − 5)}
= 2{1/2(𝑥 − 5)} + 5 = 𝑥 = 𝐼𝑅 (𝑥)
☻Properties of Functions:
Theorem 1: A function 𝑓: 𝐴 → 𝐵 is invertible if and only if one-to-one and onto.
Proof: Suppose that f is invertible then there exists a unique function 𝑔: 𝐵 → 𝐴 such that 𝑔𝑜𝑓 =
𝐼𝐴 and 𝑓𝑜𝑔 = 𝐼𝐵 Take any 𝑎1 , 𝑎2 𝜖 𝐴 then
𝑓(𝑎1 ) = 𝑓( 𝑎2 ) ⇒ 𝑔{𝑓 (𝑎1 )} = 𝑔{𝑓( 𝑎2 )}
⇒ (𝑔𝑜𝑓)( 𝑎1 ) = (𝑔𝑜𝑓)( 𝑎2)
⇒ 𝐼𝐴 (𝑎1 ) = 𝐼𝐴 ( 𝑎2 )
⇒ 𝑎1 = 𝑎2
This prove 𝑓 is one-to-one
1, if i = j
δij== {
0, if i ≠ j
☻Digraph of a relation:
Let V be a finite nonempty set. A directed graph G on V is made up of the elements of V, called
the vertices or nodes of G, and a subset E, of 𝑉 × 𝑉 that contains the edges or arcs, of G. The set
V is called the vertex set of G, the set E edge set. We then write 𝐺 = (𝑉, 𝐸) to denote the graph.
If 𝑎, 𝑏 ∈ 𝑉 and (𝑎, 𝑏) ∈ 𝐸 then there is an edge from 𝑎 to 𝑏 vertex 𝑎 is called the origin or source
of the edge with 𝑏 the terminus or terminating vertex and we say that 𝑏 is adjacent from 𝑎 and that
𝑎 is adjacent to 𝑏. In addition, if 𝑎 ≠ 𝑏, then (𝑎, 𝑏) ≠ (𝑏, 𝑎). An edge of the form (𝑎, 𝑎) is called
a loop.
Problems:
1. Let 𝐴 = {1,2,3,4} and let R be the relation on A defined by 𝑥𝑅𝑦 if and only if 𝑦 = 2𝑥.
a) Write down R as asset of ordered pairs.
b) Draw the digraph of R.
c) Determine the in-degrees and out-degrees of the vertices in the digraph.
Solution:
a) We observe that for 𝑥, 𝑦 ∈ 𝐴, (𝑥, 𝑦) ∈ 𝑅 if and only if 𝑦 = 2𝑥. thus 𝑅 = {(1,2), (2,4)}.
b) The digraph of R is as shown below
c) From the above digraph, we note that 3 is an isolated vertex and that for the vertex 1,2,4 the in-
degrees and out-degrees are as shown in the table
Vertex 1 2 4
In-degree 0 1 1
Out-degree 1 1 0
3. Find the relation represented by the digraph given below. Also write down its matrix.
Solution:
By examining the given digraph which has 4 vertices, we note that the relation R represented by it
is defined on the set 𝐴 = {1,2,3,4} and is given by 𝑅 = {(1,2), (1,4), (2,2), (2,3), (4,1), (4,4)}.
The matrix of R is
0101
0110
𝑀𝑅 = [ ]
0000
1001
☻Properties of Relations:
1. Reflexive relation:
A relation R on a set A is said to be reflexive, if (𝑎, 𝑎) ∈ 𝑅, for all 𝑎 ∈ 𝐴.
Example: ≤
2. Irreflexive relation:
A relation is said to be irreflexive, if (𝑎, 𝑎) ∉ 𝑅 for any 𝑎 ∈ 𝐴.
Example: < , >
3. Symmetric Relation:
A relation R on a set is said to be symmetric, If (𝑏, 𝑎) ∈ 𝑅 whenever (𝑎, 𝑏) ∈ 𝑅 for all 𝑎, 𝑏 ∈ 𝐴.
A relation which is not symmetric is called an Asymmetric relation.
Example: If 𝐴 = {1,2,3} and 𝑅1 = {(1,1), (1,2), (2,1)}, 𝑅2 = {(1,2), (2,1), (1,3)}
𝑅1 is symmetric and 𝑅2 is asymmetric.
4. Antisymmetric relation:
A relation R on a set A is said to be antisymmetric, if whenever (𝑎, 𝑏) ∈ 𝑅 and (𝑏, 𝑎) ∈ 𝑅 then
𝑎 = 𝑏.
Example: is less than or equal to.
5. Transitive Relation:
A relation on a set A is said to be transitive if whenever (𝑎, 𝑏) ∈ 𝑅 and (𝑏, 𝑐) ∈ 𝑅 then (𝑎, 𝑐 ) ∈ 𝑅
for all 𝑎, 𝑏, 𝑐 ∈ 𝐴.
Examples:
1. Determine nature of the relations.
[1] 𝐴 = {1,2,3}, 𝑅1 = {(1,2), (2,1), (1,3), (3,1)}
- Symmetric but not reflexive.
[2] 𝑅2 = {(1,1), (2,2), (3,3), (2,3)}
- Reflexive but not symmetric.
[3] 𝑅3 = {(1,1), (2,2), (3,3)}
- Reflexive and symmetric.
[4] 𝑅4 = {(1,1), (2,2), (3,3), (2,3), (3,2)}
- Both reflexive and symmetric.
[5] 𝑅5 = {(1,1), (2,3), (3,3)}
- Neither reflexive nor symmetric
2. For a fixed integer 𝑛 > 1 prove that the relation congruent modulo 𝑛 is an equivalence
relation on the set of all integers 𝑍.
Solution: For 𝑎, 𝑏 ∈ 𝑧, we say that 𝑎 is congruent to 𝑏 modulo 𝑛 if 𝑎 − 𝑏 is a multiple of n or
equivalently, 𝑎 − 𝑏 = 𝑘𝑛 for some 𝑘 ∈ 𝑍.
Let us denote this relation by 𝑅 so that 𝑎𝑅𝑏 means 𝑎 ≡ 𝑏 (𝑚𝑜𝑑 𝑛) we have to prove that 𝑅 is
an equivalence relation.
We note that for every 𝑎 ∈ 𝑍, 𝑎 − 𝑎 = 0 is a multiple of 𝑛 ie, 𝑎 ≡ 𝑎(𝑚𝑜𝑑 𝑛), 𝑎𝑅𝑎
R is reflexive. Next for all 𝑎, 𝑏 ∈ 𝑧
𝑎𝑅𝑏 → 𝑎 ≡ 𝑏 𝑚𝑜𝑑 𝑛.
→ 𝑎 − 𝑏 is a multiple of 𝑛
→ 𝑏 − 𝑎 is a multiple of 𝑛
→ 𝑏 ≡ 𝑎 𝑚𝑜𝑑 𝑛
→ 𝑏𝑅𝑎
R is symmetric.
Lastly, we note that for all 𝑎, 𝑏, 𝑐 ∈ 𝑍
𝑎𝑅𝑏 and 𝑏𝑅𝑐 ⇒ 𝑎 ≡ 𝑏(𝑚𝑜𝑑 𝑛) and 𝑏 ≡ 𝑐(𝑚𝑜𝑑 𝑛)
= 𝑎 − 𝑏 and 𝑏 − 𝑐 are multiples of 𝑛
= (𝑎 − 𝑏) + (𝑏 − 𝑐) = (𝑎 − 𝑐) is a multiple of 𝑛
= 𝑎 ≡ 𝑐( 𝑚𝑜𝑑 𝑛) = 𝑎𝑅𝑐
R is transitive. This proves that R is equivalence relation.
☻Equivalence Class:
Let R be an equivalence relation on a set A and 𝑎 ∈ 𝐴. Then the set of all those elements
𝑥 of A which are related to a by R is called the equivalence class of a with respect to R.
𝑎 ̅ = [𝑎] = 𝑅(𝑎) = {𝑥 ∈ 𝐴|(𝑥, 𝑎) ∈ 𝑅}
Example:
𝑅 = {(1,1), (1,3), (2,2), (3,1), (3,3)} defined on the set 𝐴 = {1,2,3} we find elements 𝑥 of A for
which (𝑥, 1) ∈ 𝑅 are 𝑥 = 1, 𝑥 = 3. Therefore {1,3} is the equivalence class of 1
i.e., [1] = {1,3}, [2] = [2], [3] = {1,3}
☻Partition of a set:
Let A be a non-empty set suppose that there exist non-empty subsets A1,A2,A3,…… AK of A such
that the following two conditions hold.
1) A is the union of 𝐴1 , 𝐴2 , 𝐴3 , … … 𝐴𝐾 that is 𝐴 = 𝐴1 𝑈𝐴2 𝑈𝐴3 , … 𝑈𝐴𝐾
2) Any two of the subsets 𝐴1 , 𝐴2 , 𝐴3 , … … 𝐴𝐾 are disjoint i.e., 𝐴𝑖 ꓵ 𝐴𝑗 = ф
for 𝑖 ≠ 𝑗 then the set 𝑃 = { 𝐴1 , 𝐴2 , 𝐴3 , … … 𝐴𝐾 } is called a partition of A. also
𝐴1 , 𝐴2 , 𝐴3 , … … 𝐴𝐾 are called the blocks or cells of the partition.
A partition of a set A with 6 blocks is as shown below
Solution:
By examining the given 𝑅1 we find that [1] = {1}, [2] = {2,3}, [3] = {2,3}, [4] = {4,5}, [5] =
{4,5} of these equivalence classes only [1], [2] and [4] are distinct these constitute the partition
P of A determined by R then
𝑃 = {[1], [2], [4]} is the partition induced by R
𝐴 = [1] 𝑈 [2] 𝑈 [4] = {1}𝑈{2,3}𝑈{4,5}
☻Partial orders:
A relation R on a set A is said to be a partial ordering relation or a partial order on A if (i) R is
reflexive (ii) R is antisymmetric and (iii) R is transitive on A.
Poset:
A set with a partial order R defined on it is called a partially ordered set or Poset.
Example: less than or equal to. On set of integers.
Total Order:
Let R be a partial order on a set A. Then R is called a total order on A. if for all 𝑥, 𝑦 ∈ 𝐴 either
𝑥𝑅𝑦 or 𝑦𝑅𝑥. In this case the poset (𝐴, 𝑅) is called a totally ordered set.
Hasse Diagram:
A Hasse diagram is a graphical rendering of a partially ordered set displayed via the cover
relation of the partially ordered set with an implied upward orientation. A point is drawn for each
element of the poset, and line segments are drawn between these points according to the following
two rules:
1. If 𝑥 < 𝑦 in the poset, then the point corresponding to 𝑥 appears lower in the drawing than the
point corresponding to 𝑦.
2. The line segment between the points corresponding to any two elements 𝑥 and 𝑦 of the poset is
included in the drawing iff 𝑥 covers 𝑦 or 𝑦 covers 𝑥 .
Problems:
1. Let 𝐴 = {1,2,3,4} and 𝑅 = {(1,1), (1,2), (2,2), (2,4), (1,3), (3,3), (3,4), (1,4), (4,4)}.
Verify that R is a partial order on A. also write down the Hasse diagram for R.
Solution:
We observe that the given relation R is reflexive and transitive. Further R does not contain
ordered pairs of the form (𝑎, 𝑏) and (𝑏, 𝑎) with 𝑏 ≠ 𝑎. R is antisymmetric as such R is a partial
order on A.
The Hasse diagram for R must exhibit the relationships between the elements of A as defined by
R. if (𝑎, 𝑏) ∈ 𝑅 there must be an upward edge from a to b.
2. Let 𝐴 = {1,2,3,4,6,8,12} on A, define the partial ordering relation R by 𝑥𝑅𝑦 if and only
if 𝑥/𝑦 draw the Hasse diagram for R.
Solution:
𝑅 = {(1,1), (1,2), (1,3), (1,4), (1,6), (1,8), (1,12), (2,2), (2,4), (2,6), (2,8), (2,12),
(3,3), (3,6), (3,12), (4,4), (4,8), (4,12), (6,6), (6,12), (8,8), (12,12)}.
The Hasse diagram for this R is as shown below.
Solution:
By observing the given diagraph, we note that
Supremum (LꓴB): An element 𝑎 ∈ 𝐴 is called the LꓴB of a subset B of A if the following two
conditions hold.
i) A is an upper bound of B.
ii) If 𝑎𝐼 is an upper bound of B then 𝑎𝑅𝑎𝐼 .
Infimum (GLB): An element 𝑎 ∈ 𝐴 is called the GLB of a subset B of A if the following two
conditions hold
i) A is a lower bound of B.
ii) If 𝑎𝐼 is a lower bound of B then 𝑎𝐼 𝑅𝑎.
Problems:
1. Consider the Hasse diagram of a Poset (A, R) given below.
(iii) The upper bound 𝑓 of B is related to the other upper bounds 𝑔 and ℎ of B. Therefore, 𝑓 is
the LꓴB of B.
(iv) The lower bounds 𝑎 and 𝑏 of B are related to the lower bound 𝑐 of B. therefore C is the GLB
of B.
2. Consider the Poset whose Hasse diagram is shown below. Find LꓴB and GLB of 𝐵 =
{𝑐, 𝑑, 𝑒}
By examining all upward paths from 𝑐, 𝑑, 𝑒 is the given Hasse diagram. We find that LꓴB (𝐵) =
𝑒. by examining all upward paths to 𝑐, 𝑑, 𝑒 we find that 𝐺𝐿𝐵(𝐵) = 𝑎.
☻Lattice:
Let (A, R) be a Poset this Poset is called a lattice. For all 𝑥, 𝑦 ∈ 𝐴 the elements 𝐿ꓴ𝐵 {𝑥, 𝑦} and
𝐺𝐿𝐵 {𝑥, 𝑦} exist is A.
Example: Let (𝐴, 𝑅) be Poset. The Poset is called a.
1). Consider the set N of all-natural numbers and let R be the partial order “less than or equal to”
then for any 𝑥, 𝑦 ∈ 𝑁, we note that 𝐿ꓴ𝐵 {𝑥, 𝑦} = 𝑀𝑎𝑥{𝑥, 𝑦} and 𝐺𝐿𝐵 {𝑥, 𝑦} = 𝑚𝑖𝑛{𝑥, 𝑦} and
both of these belong to 𝑁. Therefore, the Poset (𝑁, ≤ ) is a lattice.
2). Consider the Poset (𝑍 + , ∣) where 𝑍 + is set of all positive integer & ∣ is the divisibility set. We
can check that for any 𝑎, 𝑏 ∈ 𝑍 + , the least common multiple of 𝑎 & 𝑏 is the 𝐿ꓴ𝐵 {𝑎, 𝑏} & the
GCD of 𝑎 & 𝑏 is 𝐺𝐿𝐵 {𝑎, 𝑏}. Since these belongs to 𝑍 + we infer that (𝑍 + , ∣) is a lattice.
3). Consider the poset where Hasse Diagram is
By examining the Hasse diagram, we note that 𝐺𝐿𝐵 {3, 4} does not exist.
∴ The poset is not a Lattice