Relation PDF
Relation PDF
(Set, Relation )
Sets
Set: collection of distinct objects
Example: attendees in this class; prime numbers
2
Set Definitions
Universe U: set of all possible outcomes
Example: Rolling a die
• U = {f1, f2, f3, f4, f5, f6}
U has 26 = 64 subsets
• Null, {f1}, …, {f6}, {f1,f2}, …, {f5,f6}, {f1,f2,f3}, …, U
3
Venn Diagrams
A
A B A B A
A B B A
(d) AB = . (e) A B.
4
Ordered Pair
Ordered pair (a,b): specific order associated with a and b
• a: first coordinate
• b: second coordinate
Example: mother and daughter; teacher and student
b
Generalization: Ordered n-tuple (a1, a2, …, an)
5
Binary Relation
Binary relation R: set of ordered pairs (a,b)
a R b: a is related to b by R
6
Properties of Relations
Relation R in set A is
Reflexive if it contains (a,a) for every a in A
Symmetric if existence of (a,b) in R implies the existence of (b,a)
Transitive if existence of (b,a) and (a,c) in R implies existence of (b,c)
Example: Relation {(a,a), (b,b), (a,b)} – reflexive and transitive, but not
symmetric
Example: Relation {(a,b), (b,a)} – symmetric, but not transitive since it
does not contain (a,a)
a d
b e
c
f
R = {(a,a), (b,b), (c,c), (d,d), (e,e), (f,f), (a,b), (b,a), (a,c), (c,a), (b,c), (c,b),
(d,e), (e,d)}
Equivalence classes: {a,b,c}, {d,e}, {f}
8
Representation of Relations
Representation of Relations using Graph
✓ For each ordered pair (x, y) in the relation R, there will be a directed
edge from the vertex ‘x’ to vertex ‘y’.
✓ If there is an ordered pair (x, x), there will be self- loop on vertex ‘x’.
Suppose there is a relation
R={(a, a),(b, b),(c, c),(a, b),(b, c), (c, b), (c, a)} on the set
S= {a, b, c}, it can be represented by the following graph
Your Task
1. Draw the directed graph that represents the relation
R ={(1,1), (2, 2), (1, 2), (2, 3), (3,2), (3,1), (3,3)} on the set
S = {1, 2, 3}.
2. Write the relation as a set of ordered pairs from the
digraph as shown below
1 3 4
1 1 1 0
𝑀𝑅 = 3 0 1 0
4 0 0 1
1 0 1 0 1 0
𝑀𝑅 = 0 1 0 and 𝑀𝑆 = 1 1 0
0 0 0 0 0 1
0 1 1
𝑀𝑅∘𝑆 = 1 1 0
0 0 0
Reflexive Closure: The reflexive closure of a relation R
on A is obtained by adding (a, a) to R for each 𝑎 ∈ 𝐴 i.e.
𝑅 (𝑟) = 𝑅 ∪ 𝐼𝐴
where 𝐼𝐴 = { 𝑎, 𝑎 : 𝑎 ∈ 𝐴}.
Symmetric Closure : The symmetric closure of R is
obtained by adding (b, a) to R for each (a, b) ∈ R i.e.
𝑅 (𝑠) = 𝑅 ∪ 𝑅−1
where 𝑅 (𝑟) = { 𝑏, 𝑎 : (𝑎, 𝑏) ∈ 𝑅}.
Transitive Closure: The transitive closure of R is
obtained by repeatedly adding (a, c) to R for each (a, b)
∈ R and (b, c) ∈ R. Let R be the relation defined on A
and A contains m elements one can calculate transitive
closure as
𝑅+ = 𝑅 ∪ 𝑅2 ∪ 𝑅3 … ∪ 𝑅𝑚 .