DMS Module 2
DMS Module 2
Discrete Mathematics
Module II
Lecture-1
Relation
Anant Kr Jayswal
ASET(CSE)
1
Amity School of Engineering & Technology (CSE)
Module I:
q Relation and properties of relation
2
Amity School of Engineering & Technology (CSE)
OBJECTIVES
After completing this section, you will be able to
3
Amity School of Engineering & Technology (CSE)
Relation
Introduction
Relation
Introduction
Formally, we define a relation in terms of these “ordered pairs”.
Relations, as noted above, will be defined in terms of ordered pairs (a, b)
of elements, where a is designated as the first element and b as the
second element.
Relation
Some definitions required to define relation
Relation
RELATION
Let A and B are two nonempty sets. A binary relation or, simply, relation
from A to B is a subset of A X B i.e.
R is a relation from A to B R (AB)
Example1
Let A = {1, 2,3} and B= {a, b, c}
Then AB={(1,a),(1,b),(1,c),(2,a),(2,b),(2,c),(3,a),(3,b),(3,c)}
R1={(1,a),(1,c)}
R2={(1,a),(2,a),(2,c)}
R3={(3,c)} are all examples of relations from A to B.
Relation
Domain and Range of a Relation
If R (AB) is a relation from AB, then
v Domain(R)={a: (a,b)R} and
v Range(R)={b: (a,b)R}.
The domain of a relation R is the set of all first elements of the ordered
pairs which belong to R, and the range of R is the set of second
elements.
Example
Let A = {1, 2,3} and B= {a, b, c}
Then AB={(1,a),(1,b),(1,c),(2,a),(2,b),(2,c),(3,a),(3,b),(3,c)}
R={(1,a),(2,a),(2,c)}
v Domain(R)={1,2}
v Range(R)={a,c}.
8
Amity School of Engineering & Technology (CSE)
Relation
Some Examples
Example1: Let A={1,2,3,4}. Define a relation R on A by writing (x,y)R if x
< y. Then
R = {(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)}.
9
Amity School of Engineering & Technology (CSE)
Summary
10
Amity School of Engineering & Technology (CSE)
11
Amity School of Engineering & Technology (CSE)
Discrete Mathematics
Module II
Lecture-2
Types of Relation
Anant Kr Jayswal
ASET(CSE)
12
Amity School of Engineering & Technology (CSE)
Module I:
q Types of Relation
13
Amity School of Engineering & Technology (CSE)
OBJECTIVES
After completing this section, you will be able to
14
Amity School of Engineering & Technology (CSE)
Types of Relations
15
Amity School of Engineering & Technology (CSE)
Types of Relations
Let A be a given non empty set then a relation RAA is called a
binary relation on A.
Binary relations that satisfy certain special properties can be very
useful in solving computation problems. So let’s discuss some of
these properties:
17
Amity School of Engineering & Technology (CSE)
Types of Relation
Reflexive
A relation R on a set A is reflexive if for every aA, aRa. that is, a relation
R in a set A is said to be reflexive if every element of A is related to itself
i.e. aRa is true for every aA.
Example:
Example1: Let A be the set of all straight lines in a plane. The relation R
“x is parallel to y” is reflexive since every straight line is parallel to itself.
Example2: Let A be the set of numbers and relation R in A is defined by
“x is equal to y” is reflexive” since each number is equal to itself.
Example3: Let A={1,2,3} and the relation R in A is defined by
R={(1,1),(2,2),(2,3)} is not reflexive because (3,3) does not belongs to R.
The given relation R will be reflexive, if every ordered pair (a,a)R for all
aA. 18
Amity School of Engineering & Technology (CSE)
Types of Relation..
Irreflexive Relations
Example:
Example1: Let A= {1,2,3} and let R= {(1, 1),(3,2)}.
Here R is not reflexive since (2,2) or (3,3)R. Also R is not irreflexive,
since (1, 1)R.
Example2: Let A={a,b,c}be a non empty set. Let R={(a,b),(b,c),(c,a)}
Here R is irreflexive since (a,a) )R for every aA. Also note that there is no
loop at any node.
19
Amity School of Engineering & Technology (CSE)
Types of Relation
Symmetric Relation
Example
Example1: Let A={set of all straight lines in a plane}. The Relation R on A
is defined by “ a is perpendicular to be” is a symmetric relation because
ab ba.
Example2: Let N={set of Natural numbers}. The Relation R on N is
defined by “ a is equal to b” is symmetric since aRbbRa.
20
Amity School of Engineering & Technology (CSE)
Types of Relation
Asymmetric Relation
Example
Example1: Let A={set of all straight lines in a plane}. The Relation R on A
is defined by “ a is perpendicular to be” is a symmetric relation because
ab ba.
Example2: Let N={set of Natural numbers}. The Relation R on N is
defined by “ a is equal to b” is symmetric since aRbbRa.
21
Amity School of Engineering & Technology (CSE)
Types of Relation
Anti-Symmetric Relation
Example
22
Amity School of Engineering & Technology (CSE)
23
Amity School of Engineering & Technology (CSE)
Types of Relation
Transitive Relation
Example
Consider the following five relations on the set A = {1, 2, 3, 4, 5}:
R = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4)}
24
Amity School of Engineering & Technology (CSE)
25
Amity School of Engineering & Technology (CSE)
Summary
26
Amity School of Engineering & Technology (CSE)
27
Amity School of Engineering & Technology (CSE)
Discrete Mathematics
Module II
Lecture-2
Digraph Representation
of Relation
Anant Kr Jayswal
ASET(CSE) 28
Amity School of Engineering & Technology (CSE)
Module II:
q Digraph Representation of
Relation
29
Amity School of Engineering & Technology (CSE)
OBJECTIVES
After completing this section, you will be able to
30
Amity School of Engineering & Technology (CSE)
31
Amity School of Engineering & Technology (CSE)
Example
The less than relation R on the set of integers A ={1,2,3,4} is
the set {(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)}
and it can be represented by the following digraph:
32
Amity School of Engineering & Technology (CSE)
33
Amity School of Engineering & Technology (CSE)
Example
34
Amity School of Engineering & Technology (CSE)
35
Amity School of Engineering & Technology (CSE)
Summary
Ø A relation R on a set A is called reflexive if there is a self loop
at each node in directed graph of a relation.
36
Amity School of Engineering & Technology (CSE)
37
Amity School of Engineering & Technology (CSE)
Discrete Mathematics
Module II
Lecture-3
Equivalence and Partial
order relation
Anant Kr Jayswal
ASET(CSE)
38
Amity School of Engineering & Technology (CSE)
Module I:
q Equivalence and Partial Order
Relation
39
Amity School of Engineering & Technology (CSE)
OBJECTIVES
After completing this section, you will be able to
40
Amity School of Engineering & Technology (CSE)
Equivalence Relation
A relation R in a set A is said to be an equivalence relation if
41
Amity School of Engineering & Technology (CSE)
The set over which a partial order is defined is called a partially ordered
set (or POSET). It is denoted by (A,R) where A is a given set and R is a
relation which satisfy the above three conditions.
Example: The relation ≤ (less than or equal to) on the set R of real
numbers is a partial order relation.
Since the relation () is:
1. Reflexive i.e. aa, aR
2. Anti-symmetric i.e. a b and b aa=b, a,bR
3. Transitive i.e ab and bc, ac a,b,cR
42
Amity School of Engineering & Technology (CSE)
OBJECTIVES
Summary
43
Amity School of Engineering & Technology (CSE)
44
Amity School of Engineering Technology
Warshall Algorithm
• Input: Adjacency matrix A of relation R on a set of n elements
• Output: Adjacency matrix T of the transitive closure of R.
Algorithm
• Body:
• T := A [initialize T to A]
for j := 1 to n
for i := 1 to n
if Ti, j = 1 then
ai := ai ∨ aj [form the Boolean OR of row i and row j, store
it in i a ]
next i
next j
end Algorithm
45
Amity School of Engineering Technology
Example
•
• Let A =
46
Amity School of Engineering Technology
j = 1 i = 1, Ti, j = 0 no action
i = 2 Ti, j = 0 no action
i = 3 Ti, j = 0 no action
Therefore W = T [1] = A
47
Amity School of Engineering Technology
j = 2 i = 1 Ti, j = 1
(0 1 0) OR (0 1 1) = (0 ∨ 0,1∨1,0 ∨1) =
(0 1 1) row 1 of T becomes (0 1 1)
i = 2 Ti, j = 1 row 2 OR row 2 is
computed and put into row 2 however, row
2 OR row 2 = row 2
i = 3 Ti, j = 0 no action
48
Amity School of Engineering Technology
j = 3 i = 1 Ti, j = 0 no action
i = 2 Ti, j = 1 (0 1 1) OR (0 0 0)
= ( 0 ∨ 0,1∨ 0,1∨ 0) = (0 1 1) result is put into
row 2, which is unchanged
i = 3 Ti, j = 0 no action.
At this stage T = [3] W = [2] W above. We
now have the transitive closure.
49
Amity School of Engineering Technology
Poset
A relation R on a set S is called a partial order if it is
• Reflexive
• Antisymmetric
• Transitive
Notation:
a b, when (a,b) R
50
Amity School of Engineering Technology
Example
• Let R ={1,2,3} identify the relation RxR is
poset or not.
• RxR
={(1,1),(1,2)(1,3),(2,1),(2,2),(2,3),(3,1),(3,
2),(3,3)}
• The 3 condition for poset are:
– Reflexive : {(a,a) should belongs to R for
Every element of set}
– In our case it is true hence it is refelxive
51
Amity School of Engineering Technology
52
Amity School of Engineering Technology
Hasse Diagrams
• Patrial order set have conventional
graphical representation called Hasse
diagram.
• Hasse diagram can be drawn from
digraph of the relation
• Remove all self loops
• Remove all transitive edges
• Remove directions on edges assuming
that they are oriented upwards 53
Amity School of Engineering Technology
Example
• Convert the following Digraph to Hasse
Diagram.
54
Amity School of Engineering Technology
Hasse Diagram
55
Amity School of Engineering Technology
58
Amity School of Engineering Technology
Example
In the figure, we have 3 minimal
elements (2,3,5)
And 3 maximal elements (10,15,24)
No Minimum element
No maximum element
59
Amity School of Engineering Technology
60
Amity School of Engineering Technology
61
Amity School of Engineering Technology
62
Amity School of Engineering Technology
Example
In the poset above {a, b, c} is the greatest
element.
Ø is the least element.
63