Lecture 1718 Relation
Lecture 1718 Relation
Lecture 1718 Relation
Lecture 17-18
1
Cartesian product (review)
Let
A={a1, a2, ..ak} and
B={b1,b2,..bm}.
a→b
Example:
• Let A = {0, 1, 2}, B = {u,v} and
Example 1:
• Is Rdiv reflexive?
8
Reflexive Relation
Definition (reflexive relation) : A relation R on a set A is
called reflexive if (a,a) ϵ R for every element a ϵ A.
Example 1:
• Is Rdiv reflexive?
9
Reflexive Relation
Definition (reflexive relation) : A relation R on a set A is
called reflexive if (a,a) ϵ R for every element a ϵ A.
Example 2:
• Relation Rfun on A = {1,2,3,4} defined as:
• Rfun = {(1,2),(2,2),(3,3)}.
• Is Rfun reflexive?
10
Reflexive Relation
Definition (reflexive relation) : A relation R on a set A is
called reflexive if (a,a) ϵ R for every element a ϵ A.
Example 2:
• Relation Rfun on A = {1,2,3,4} defined as:
• Rfun = {(1,2),(2,2),(3,3)}.
• Is Rfun reflexive?
11
Symmetric Relation
Definition (symmetric relation): A relation R on a set A is
called symmetric if
a, b A(a, b) R (b, a ) R
Example 1:
• Is Rdiv symmetric?
12
Symmetric Relation
Definition (symmetric relation): A relation R on a set A is
called symmetric if
. a, b A( a, b) R (b, a ) R
Example 1:
• Is Rdiv symmetric?
Example 2:
R≠={(1,2),(1,3),(1,4),(2,1),(2,3),(2,4),(3,1),(3,2),(3,4),(4,1),
(4,2),(4,3)}
• Is R≠ symmetric ?
14
Symmetric Relation
Definition (symmetric relation): A relation R on a set A is
called symmetric if
a, b A(a, b) R (b, a) R
Example 2:
R≠={(1,2),(1,3),(1,4),(2,1),(2,3),(2,4),(3,1),(3,2),(3,4),(4,1),
(4,2),(4,3)}
• Is R≠ symmetric ?
a, b A(a, b) R (b, a ) R
Answer: Yes. 15
Transitive Relation
Definition (transitive relation): A relation R on a set A is
called transitive if
[(a, b) R and (b, c) R] (a, c) R a, b, c A
• Example 1:
• Is Rdiv transitive?
16
Transitive Relation
Definition (transitive relation): A relation R on a set A is
called transitive if
[(a, b) R and (b, c) R] (a, c) R a, b, c A
• Example 1:
• Is Rdiv transitive?
• Answer: Yes.
17
Transitive Relation
Definition (transitive relation): A relation R on a set A is
called transitive if
[(a, b) R and (b, c) R] (a, c) R a, b, c A
• Example 2:
• R≠={(1,2),(1,3),(1,4),(2,1),(2,3),(2,4),(3,1),(3,2),(3,4),(4,1),
(4,2),(4,3)}
• Is R≠ transitive ?
18
Transitive Relation
Definition (transitive relation): A relation R on a set A is
calledtransitive if
[(a, b) R and (b, c) R] (a, c) R a, b, c A
• Example 2:
• Is R≠ transitive ?
Combining Relations
• Relations are sets → combinations via set operations
• Set operations of: union, intersection, difference and
symmetric difference.
20
Combining Relation
Example:
• Let A = {1,2,3} and B = {u,v} and
• R1 = {(1,u), (2,u), (2,v), (3,u)}
• R2 = {(1,v),(3,u),(3,v)}
What is:
• R1 U R2 = ?
21
Combining Relation
Example:
• Let A = {1,2,3} and B = {u,v} and
• R1 = {(1,u), (2,u), (2,v), (3,u)}
• R2 = {(1,v),(3,u),(3,v)}
What is:
• R1 U R2 = {(1,u),(1,v),(2,u),(2,v),(3,u),(3,v)}
• R1 ∩ R2 = ?
22
Combining Relation
Example:
• Let A = {1,2,3} and B = {u,v} and
• R1 = {(1,u), (2,u), (2,v), (3,u)}
• R2 = {(1,v),(3,u),(3,v)}
What is:
• R1 U R2 = {(1,u),(1,v),(2,u),(2,v),(3,u),(3,v)}
• R1 ∩ R2 = {(3,u)}
• R1 - R2 = ?
23
Combining Relation
Example:
• Let A = {1,2,3} and B = {u,v} and
• R1 = {(1,u), (2,u), (2,v), (3,u)}
• R2 = {(1,v),(3,u),(3,v)}
What is:
• R1 U R2 = {(1,u),(1,v),(2,u),(2,v),(3,u),(3,v)}
• R1 ∩ R2 = {(3,u)}
• R1 - R2 = (1,u),(2,u),(2,v)}
• R2 - R1 = ?
24
Combining Relation
Example:
• Let A = {1,2,3} and B = {u,v} and
• R1 = {(1,u), (2,u), (2,v), (3,u)}
• R2 = {(1,v),(3,u),(3,v)}
What is:
• R1 U R2 = {(1,u),(1,v),(2,u),(2,v),(3,u),(3,v)}
• R1 ∩ R2 = {(3,u)}
• R1 - R2 = (1,u),(2,u),(2,v)}
• R2 - R1 = {(1,v),(3,v)}
25
Composite Relation
Examples:
• Let A = {1,2,3}, B = {0,1,2} and C = {a,b}.
• R = {(1,0), (1,2), (3,1),(3,2)}
• S = {(0,b),(1,a),(2,b)}
• SoR = ?
26
Composite Relation
Examples:
• Let A = {1,2,3}, B = {0,1,2} and C = {a,b}.
• R = {(1,0), (1,2), (3,1),(3,2)}
• S = {(0,b),(1,a),(2,b)}
• SoR = {(1,b),(3,a),(3,b)}
27
Composite Relation
• R1 = R and Rn+1 = Rn O R.
Examples
• R = {(1,2),(2,3),(2,4), (3,3)} is a relation on A = {1,2,3,4}.
• R1 = ?
28
Composite Relation
• R1 = R and Rn+1 = Rn O R.
Examples
• R = {(1,2),(2,3),(2,4), (3,3)} is a relation on A = {1,2,3,4}.
• R1 = {(1,2),(2,3),(2,4), (3,3)}
• R2 = ?
29
Composite Relation
• R1 = R and Rn+1 = Rn O R.
Examples
• R = {(1,2),(2,3),(2,4), (3,3)} is a relation on A = {1,2,3,4}.
• R1 = {(1,2),(2,3),(2,4), (3,3)}
• R2 = {(1,3), (1,4), (2,3), (3,3)}
• R3 = ?
30
Composite Relation
• R1 = R and Rn+1 = Rn O R.
Examples
• R = {(1,2),(2,3),(2,4), (3,3)} is a relation on A = {1,2,3,4}.
• R1 = {(1,2),(2,3),(2,4), (3,3)}
• R2 = {(1,3), (1,4), (2,3), (3,3)}
• R3 = {(1,3), (2,3), (3,3)}
• R4 =
31
Composite Relation
• R1 = R and Rn+1 = Rn O R.
Examples
• R = {(1,2),(2,3),(2,4), (3,3)} is a relation on A = {1,2,3,4}.
• R1 = {(1,2),(2,3),(2,4), (3,3)}
• R2 = {(1,3), (1,4), (2,3), (3,3)}
• R3 = {(1,3), (2,3), (3,3)}
• R4 = {(1,3), (2,3), (3,3)}
• Rk = ? when k>3
32
Composite Relation
• R1 = R and Rn+1 = Rn O R.
Examples
• R = {(1,2),(2,3),(2,4), (3,3)} is a relation on A = {1,2,3,4}.
• R1 = {(1,2),(2,3),(2,4), (3,3)}
• R2 = {(1,3), (1,4), (2,3), (3,3)}
• R3 = {(1,3), (2,3), (3,3)}
• R4 = {(1,3), (2,3), (3,3)}
• Rk = {(1,3), (2,3), (3,3)}
33
Transitive Relation
Definition (transitive relation): A relation R on a set A is
called transitive if
• [(a,b) ϵ R and (b,c) ϵ R] → (a,c) ϵ R for all a, b, c ϵ A.
• Example 1:
• Rdiv = {(1,1), (1,2), (1,3), (1,4), (2,2), (2, 3), (2,4), (3,3), (4,4)}
• Is Rdiv transitive?
34
Transitive Relation
Definition (transitive relation): A relation R on a set A is
called transitive if
• [(a,b) ϵ R and (b,c) ϵ R] → (a,c) ϵ R for all a, b, c ϵ A.
• Example 1:
• Rdiv = {(1,1), (1,2), (1,3), (1,4), (2,2), (2, 3), (2,4), (3,3), (4,4)}
• Is Rdiv transitive?
• Answer: Yes.
35
Closure of a Relation
• Answer: ?
36
Closure of a Relation
• Answer: ?
37
Closure of a Relation
39
Closure of a Relation
40
Closure of a Relation
• S=?
41
Closure of a Relation
42
Closure of a Relation
• Is R transitive?
43
Closure of a Relation
• Is R transitive? No.
• How to make it transitive?
• S = {(1,2), (2,2), (2,3)} U {(1,3)}
= {(1,2), (2,2), (2,3),(1,3)}
• S is the transitive closure of R
44
Path length
45
Path length
46
Path length
47
Path length
R Rk
*
k 1
Example:
• A = {1,2,3,4}
• R = {(1,2),(1,4),(2,3),(3,4)}
50
Connectivity Relation
Definition: Let R be a relation on a set A. The connectivity
relation R* consists of all pairs (a,b) such that there is a path (of
any length, ie. 1 or 2 or 3 or ...) between a and b in R.
R Rk
*
k 1
Example:
• A = {1,2,3,4}
• R = {(1,2),(1,4),(2,3),(3,4)}
• R2 =?
51
Connectivity Relation
Definition: Let R be a relation on a set A. The connectivity
relation R* consists of all pairs (a,b) such that there is a path (of
any length, ie. 1 or 2 or 3 or ...) between a and b in R.
R Rk
*
k 1
Example:
• A = {1,2,3,4}
• R = {(1,2),(1,4),(2,3),(3,4)}
• R2 = {(1,3),(2,4)}
• R3 = ?
52
Connectivity Relation
Definition: Let R be a relation on a set A. The connectivity
relation R* consists of all pairs (a,b) such that there is a path (of
any length, ie. 1 or 2 or 3 or ...) between a and b in R.
R Rk
*
k 1
Example:
• A = {1,2,3,4}
• R = {(1,2),(1,4),(2,3),(3,4)}
• R2 = {(1,3),(2,4)}
• R3 = {(1,4)}
•R4 = ?
53
Connectivity Relation
Definition: Let R be a relation on a set A. The connectivity
relation R* consists of all pairs (a,b) such that there is a path (of
any length, ie. 1 or 2 or 3 or ...) between a and b in R.
R Rk
*
k 1
Example:
• A = {1,2,3,4}
• R = {(1,2),(1,4),(2,3),(3,4)}
• R2 = {(1,3),(2,4)}
• R3 = {(1,4)}
•R4 =Ø
• R* =?
54
Connectivity Relation
Definition: Let R be a relation on a set A. The connectivity
relation R* consists of all pairs (a,b) such that there is a path (of
any length, ie. 1 or 2 or 3 or ...) between a and b in R.
R Rk
*
k 1
Example:
• A = {1,2,3,4}
• R = {(1,2),(1,4),(2,3),(3,4)}
• R2 = {(1,3),(2,4)}
• R3 = {(1,4)}
•R4 =Ø
• R* = {(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)}
55
Equivalence Relation
56
Equivalence Relation
Is R reflexive
58
Equivalence Relation
Is R reflexive Yes
Is R symmetric
59
Equivalence Relation
Is R reflexive Yes
Is R symmetric Yes
Is R transitive
60
Equivalence Relation
Is R reflexive Yes
Is R symmetric Yes
Is R transitive Yes
Then 61
Thank You
62