0% found this document useful (0 votes)
21 views31 pages

Relation Lecture1

rela-1-1-1

Uploaded by

raiyun.mushfiq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views31 pages

Relation Lecture1

rela-1-1-1

Uploaded by

raiyun.mushfiq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Relation-Part 1

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) : aA, bB, 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 AB.
( Note AB = { (a,b) : aA and bB } )
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

A B R  AB = { (0,a) , (0,b) , (1,a)


(1,b) , (2,a) , (2,b)}
0
a R R
1
b
2

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

R = { (1,1), (1,2), (1,3), (1,4),


(2,2), (2,4),
(3,3),
(4,4) }
Example . Consider the following relations
on Z.
R1 = { (a, b) | a  b } Which of these relations
R2 = { (a, b) | a > b }
contain each of the pairs
R3 = { (a, b) | a = b or a = -b }
(1,1), (1,2), (2,1), (1,-1),
R4 = { (a, b) | a = b }
and (2,2)?
R5 = { (a, b) | a = b+1 }
R6 = { (a, b) | a + b  3 }

(1,1) (1,2) (2,1) (1,-1) (2,2)


R1 x x x

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 aA.
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, bA,
(a, b)R  (b, a)R.
(2) A relation R on a set A is called
antisymmetric if for a, bA,
(a, b)R and (b, a)R  a = b.
Example– Symmetric and
Antisymmetric Relation

Example . Which of the relations from


are symmetric or antisymmetric ?
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) }

Sol :
R2, R3 are symmetric
R4 are antisymmetric. [(2,1) but no (1,2)…so on]
Transitive Relation

Def. 5. A relation R on a set A is


called
transitive if for a, b, c A,
(a, b)R and (b, c)R  (a, c)R.
Example– Transitive Relation
Example- Which of the relations are transitive ?
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) }

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

Example . Let A = {1, 2, 3} and B = {1, 2, 3, 4}.


The relation R1 = {(1,1), (2,2), (3,3)}
and R2 = {(1,1), (1,2), (1,3), (1,4)} can be
combined to obtain
R1 ∪ R2 ={(1,1), (2,2), (3,3), (1,2), (1,3), (1,4)}
R1 ∩ R2 = {(1,1)}
R1 - R2 = {(2,2), (3,3)}
R2 - R1 = {(1,2), (1,3), (1,4)}
R1 R2 = {(2,2), (3,3), (1,2), (1,3), (1,4)}
Example– Relation

Example - Let A = {1,2,3}, find a relation R on A s.t.


R is both symmetric and antisymmetric, but
not reflexive.
Sol :
R = { (1,1), (2,2) } [(3, 3) is missing]
Representing Relations by
Matrices
Matrices
Suppose that R is a relation from A={a1, a2, …, am}
to B = {b1, b2,…, bn }.
The relation R can be represented by the matrix
MR = [mij], where
1, if (ai,bj)R
mij =
0, if (ai,bj)R
Relation Representation Using
Matrix
Example . Suppose that A = {1,2,3} and B =
{1,2}
Let R = {(a, b) | a > b, aA, bB}.
What is MR ?
B
Sol : 1 2
1  0 0  0 0
A
   
2

1 0
  M R  1 0 
3  1 1
  1 1
Symmetric Relation Using Matrix

The relation R is symmetric iff (ai,aj)R  (aj,ai)R.


This means mij = mji
 1 
 
 
M R  1 0 ( M R )t
 
 
 0 
Reflexive Relation Using Matrix

Let A={a1, a2, …,an}.


A relation R on A is reflexive iff (ai,ai)R,i.
a1 a2 … … an
i.e., a1 1 
a2  1 
 
M R :   
 
:   
an  1
AntiSymmetric Relation Using
Matrix
The relation R is antisymmetric iff
(ai,aj)R and i  j  (aj,ai)R.
This means that if mij=1 with i≠j, then mji=0.
i.e.,
 1 
0 0 
M R  
 1 0
 
 0 
Relations in 0-1 Matrix
Relation Using 0-1 Matrix

Example . Suppose that the relation R on a set is


represented by the matrix
 1 1 0
M R  1 1 1
 0 1 1
Is R reflexive, symmetric, and / or antisymmetric ?

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)}

R.S={11, 12= (1,2)


13, 31= (1,1)
21, 12= (2,2)
13, 33= (1,3)
22, 23= (2,3)}
So, Composite R.S={(1,1), (1,2),
(1,3), (2,2), (2,3)}
Representing Relations Using Digraphs.

(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 : 11, 13, 21
23, 24, 31
32, 41
4 3
Reflexive and Symmetric
Relation Using Digraph
The relation R is reflexive iff
for every vertex,
(loop)

The relation R is symmetric iff


 x y
x y
Transitive Relation Using Graph
The relation R is transitive iff
for a, b, c A,
(a, b)R and (b, c)R  (a, c)R.
This means:
a b a b

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

You might also like