Relation Lecture1
Relation Lecture1
Mahmuda Naznin
CSE 103
Relations and Properties.
The most direct way to express a
relationship between elements of two sets
is to use ordered pairs.
For this reason, sets of ordered pairs are
called binary relations.
Example 1-
A : the set of students in your school.
B : the set of courses.
R = { (a, b) : aA, bB, a is enrolled in course b }
Set and Relation
Def .1.a. Let A and B be sets. A binary
relation
from A to B is a subset R of AB.
( Note AB = { (a,b) : aA and bB } )
Def. 1.b. We use the notation aRb to denote
that (a, b)R, and aRb to denote that
(a,b)R.
Moreover, a is said to be related to b
by R if aRb.
Example. Let A={0, 1, 2} and B={a, b},
then {(0,a),(0,b),(1,a),(2,b)} is a relation R
from A to B. This means, for instance, that
0Ra, but that 1Rb
R
Relations vs. Functions
Note. Relations vs. Functions
A relation can be used to express a 1-to-
many
relationship between the elements of the
sets
A and B. (For function it can not be 1 to many
Def. 2. A relation on the set A is a subset of A A
output)
( i.e., a relation from A to A ).
Example– Relation
Example. Let A be the set {1, 2, 3, 4}. Which
ordered pairs are in the relation R = { (a, b)| a
divides b }?
Sol : 1 1
2 2
3 3
4 4
R2 x x
R3 x x x
R4 x x
R5 x
R6 x x x x
Reflexive Relation
Def. 3. A relation R on a set A is called
reflexive
if (a,a)R for every aA.
Example. Consider the following relations on
{1, 2, 3, 4} :
R2 = { (1,1), (1,2), (2,1) }
R3 = { (1,1), (1,2), (1,4), (2,1), (2,2), (3,3), (4,1), (4,4) }
R4 = { (2,1), (3,1), (3,2), (4,1), (4,2), (4,3) }
which of them are reflexive ?
Sol :
R3
Reflexive Relation
Example. Which of the relations
R1 =are
{ (a,reflexive
b) | a b ?
}
R2 = { (a, b) | a > b }
R3 = { (a, b) | a = b or a = -b }
R4 = { (a, b) | a = b }
R5 = { (a, b) | a = b+1 }
R6 = { (a, b) | a + b 3 }
Sol :
Symmetric, Antisymmetric
Relation
Def. 4.
(1) A relation R on a set A is called symmetric
if for a, bA,
(a, b)R (b, a)R.
(2) A relation R on a set A is called
antisymmetric if for a, bA,
(a, b)R and (b, a)R a = b.
Example– Symmetric and
Antisymmetric Relation
Sol :
R2, R3 are symmetric
R4 are antisymmetric. [(2,1) but no (1,2)…so on]
Transitive Relation
Sol :
R2 is not transitive since
(2,1) R2 and (1,2) R2 but (2,2) R2.
R3 is not transitive since
(2,1) R3 and (1,4) R3 but (2,4) R3.
R4 is transitive.
Operations on Relation
Sol :
reflexive, symmetric, not antisymmetric.
Examples of Relations Using
Example. SupposeMatrix
that S={0,1,2,3} Let R be a
relation containing (a, b) if a b, where a S and b
S. Is R reflexive, symmetric, antisymmetric ?
Sol :
0 1 2 3
∴ R is reflexive and
0 1 1 1 1
1
0 1 1
1
MR antisymmetric,
2 0 0 1 1 not symmetric.
3 0 0 0 1
Examples of Relations
Using Matrix
Union and Intersection
Operations on Relations Using
Matrix
Composite Operations of
Relations Using Matrix
Set A={1,2,3}, Relations R and S
R={(1,1),(1,3),(2,1),(2,2)}
S={(1,2), (2,3), (3,1), (3,3)}
(Directed Graphs)
Example. Show the directed graph (digraph)
of the relation R={(1,1),(1,3),(2,1),(2,3),(2,4),
(3,1),(3,2),(4,1)} on the set {1,2,3,4}.
Sol : 1 2
vertex : 1, 2, 3, 4
edge : 11, 13, 21
23, 24, 31
32, 41
4 3
Reflexive and Symmetric
Relation Using Digraph
The relation R is reflexive iff
for every vertex,
(loop)
d c d c
Example. Determine whether the relations R
and S are reflexive, symmetric, antisymmetric,
or transitive a b
Sol :
reflexive, S
R: a not symmetric, c d
not antisymmetric,
not transitive not reflexive,
(a→b, b→c, a→c) symmetric
not antisymmetric
not transitive
(b→a, a→c, b→c)
b c
(a,b), (b,c),(c,b),(a,a) (a,b), (b,a),(a,d),(d,a)
(b,b),(c,c),(c,a) (a,c),(c,a),(b,b)
Acknowledgement
• Kenneth Rosen
• Susanna S. Epp (Reading Materials)
• R.S.Chang, CSIE, NDHU