0% found this document useful (0 votes)
12 views49 pages

6 Relations 1

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

6 Relations 1

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

Relations

Functions as Relations
 Let A and B be nonempty sets.
A function f from A to B is an assignment of
exactly one element of B to each element of A.
We write f(a) = b if b is the unique element of
B assigned by the function f to the element a
of A.

If f is a function from A to B,
we write f:A→B

Relations are a generalization of function

1
Relations
binary relation
Let A, B be sets, a binary relation R from A to
B,
is a subset of A×B. R  AxB

A binary relation from A to B is a set R of


ordered pairs where the first element of each
ordered pairs comes from A and the second
element comes from B.

R:A×B, or R:A,B is a subset of the set A×B.

The notation a R b means that (a,b)R.


The notation a R b means that (a,b)R.

When (a,b) belongs to R , a is said to be 2


related to b by relation R.
Relations
binary relation
Example
Let A be the set of students in your school and
let B be set of courses, and
let R be the relation that consists of those
pairs
(a,b), where a is a student enrolled in
course b.
 If Ahmed, Ali, and Mohamed are enrolled in
CP223
and Ahmed, Ali, and Osman are enrolled in
CS313
 Then the pairs (Ahmed,CP223), (Ali, CP223),
3
(Mohamed, CP223), (Ahmed, CS313), (Ali,
Relations
Representation of relation (Arrow diagram &
table)
Example
Let A ={0,1,2} and B={a,b} and the relation R
from A to B is {(0,a),(0,b),(1,a),(2,b)}.
R a b
0
a 0 x x
1
1 x
b
2 2 x

Arrow diagram table


0Ra 0Rb 1Ra 2Rb
4
1Rb 2Ra
Relations
Representation of relation (digraphs)
A directed graph, or digraph consists of a set
V of vertices (or nodes) together with a set E
of ordered pairs of elements of V called edges
(or arcs).

The vertex a is called the initial vertex of the


edge (a,b), and vertex b is called the terminal
vertex of this edge.
edge or arc
a b

An edge of the form (a,a) is represented by an


arc from the vertex a back to itself and it is
called a loop.
a 5
Relations
Representation of relation (digraphs)
Example

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

4 3

vertex(node)

edge(arc) 6
Relations
Representation of relation (matrix)
A relation between finite sets can be
represented using a zero-one matrix.
Suppose that R is a relation from A={a1,a2,
…,am) to B={b1,b2,….,bn}. This relation can be
represented by the matrix MR=[mij], where:

[mij]= 1 if (ai,bj)  R
0 if (ai,bj)  R
Example a Let
b A ={0,1,2} and B={a,b} and the
relation R from A to B is {(0,a),(0,b),(1,a),
0
(2,b)}. 1 1

1 MR 1 0
= 7
2 0 1
Relations on a Set
 A (binary) relation from a set A to itself is
called a relation on the set A.
Example
Let A={1,2,3,4} which ordered pairs are in the
R={(a,b) | a divides b}.
R 1 2 3 4
1,2,3,4 are positive integer, max is 4
R= {(1,1),(1,2),(1,3),(1,4),(2,2),(2,4),1 x x x x
(3,3),(4,4)}
2 x x

3 x
Draw the arrow diagram, digraph, 4 x
and matrix?
8
Relations on a Set
Example
Consider these relations on the set of integers
R1={(a,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}
Which of these relations contain each of the
pairs (1,1), (1,2), (2,1), (1,-1), and (2,2) ?

The pair (1,1) is in …..


9
…..
Relations on a Set
How many relations are there on a set with n
elements?

A relation on a set A is a subset of AxA.


AxA has n2 elements when A has n elements,
and
a set with m elements has 2m subsets,
2
there are 2 subsets of AxA.
n

2
Thus there are 2 relations on a set with n
n

elements.
2
For example there are 23 = 29 =512 relations
on the set {a,b,c} 10
Properties of Relations
There are several properties that are used to
classify relations on a set.

In some relations an element is always related


to itself.

For example, let R be the relation on the set of


all people consisting of pairs (x,y) where x and
y has the same father and the same mother.
Then xRx for every person x.

11
Properties of Relations
A relation R on a set A is called reflexive if
(a,a)R for every element aA (aA), aRa.
–E.g., the relation ≥ :≡ {(a,b) | a≥b} is
reflexive
 A relation R on the set A is reflexive if
a((a,a)R) when the universe of discourse is
the set of all elements in A.

Reflexive means that every member is related to


itself.

 A relation R on a set A is called irreflexive if


(a,a)  R for every element in A
There is no element in A is related to itself
12
Properties of Relations
Example
Consider the following relations on the
{1,2,3,4}
R1 ={(1,1),(1,2),(2,1),(2,2),(3,4),(4,1),(4,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),(3,4)}
R5 ={(3,4)}
Which of these relations are reflexive?
The relations R3 is reflexive because it
contains all pairs of the form (a,a).
13
Properties of Relations
Example
Consider the following relations on the set of
integers
R1={(a,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}
Which of these relations are reflexive?
The relations R1 , R3 and R4 are reflexive
irreflexive ?
because they both contain all pairs of the form
14
(a,a).
Properties of Relations
Example
 Is the “divides” relation on the set of
positive integers reflexive?

 Is the “divides” relation on the set of


integers reflexive?

Note that 0 does not divide 0.

15
Properties of Relations
A relation R on a set A is called reflexive if and
only if there is a loop at every vertex of the
directed graph.

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

1
2

4 3

irreflexive ? 16
Properties of Relations
A relation R on a set A is called reflexive if and
only if (ai,ai)R this means that mii=1 for
i=1,2,.,n
All the elements on the main diagonal of MR
are equal to 1

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

0 1 1 1
MR
= 0 0 1 1

0 0 0 1
irreflexive ? 17
Properties of Relations
 A relation R on a set A is symmetric
if (b,a)R whenever (a,b)R for all a,b A
ab((a,b) R → (b,a)R )

 A relation R on a set A is antisymmetric


if (a,b)R and (b,a)R then a=b for all a,b A
ab((a,b) R  (b,a)R → (a=b) )

Note that “the term symmetric and


antisymmetric are not opposites, the relation
can have both of these properties or may lack
both of them”
18
Properties of Relations
A relation cannot be both symmetric and
antisymmetric if it contains some pair of the
form (a,b), where a≠b
example
Let R be the following relation defined on the
set
{a, b, c, d}:
R = {(a, a), (a, c), (a, d), (b, a), (b, b), (b, c),
(b, d), (c, b), (c, c), (d, b), (d, d)}.
Determine whether R is:
(a)symmetric. No there is no (c,a) for example
(b) antisymmetric. No b  c b  d
19
Properties of Relations
A relation cannot be both symmetric and
antisymmetric if it contains some pair of the
form (a,b), where a≠b

example
Let R be the following relation defined on the
set
{a, b, c, d}:
R = {(a, a), (b, b), (c, c), (d, d)}.
Determine whether R is:
(a) reflexive. Yes
(b) symmetric. yes
(c) antisymmetric. yes 20
Properties of Relations
Example
Consider the following relations on the
{1,2,3,4}
R1 ={(1,1),(1,2),(2,1),(2,2),(3,4),(4,1),(4,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),(3,4)}
R5 ={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),
(3,3),
(3,4),(4,4)}
R6 ={(3,4)}
21
Which of these relations are symmetric and
Properties of Relations
Example
Consider the following relations on the set of
integers
R1={(a,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}
Which of these relations are symmetric and
which are antisymmetric ?
R3 , R4 ,and R6 are symmetric because in each
22
case (b,a) belongs to the relation whenever
Properties of Relations
Example
Consider the following relations on the set of
integers
R1={(a,b) | a  b} ab and ba imply that
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}
R1 , R2 , R4 , R5 are antisymmetric
R2 is antisymmetric it is impossible for a>b 23
and
Properties of Relations
Example
Is the “divides” relation on the set of positive
integers symmetric? Is it antisymmetric ?
This relation is not symmetric because 1|2, but
2|1.

It is antisymmetric because a|b, and b|a then


a=b.

24
Properties of Relations
A relation R on a set A is called symmetric if
and only if for every edge between distinct
vertices in its directed graph there is an edge
in the opposite direction.

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

Not
symmetri
c
3 4
25
Properties of Relations
A relation R on a set A is called antisymmetric
if and only if there are never two edges in the
opposite direction between distinct vertices in
its directed graph

2
1
Antisymmetr
ic
Not reflexive
Not
3 4
symmetric
26
Properties of Relations
A relation R on a set A is called symmetric if
and only if mij=mji of MR for i=1,2,.,n j=1,2,.,n

R={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),
(3,3),
(3,4),(4,4)}
(a,b) 1 2 3 4

1 1 1 1 1

2 0 1 1 1
Antisymmet MR
ric 3 = 0 0 1 1

4 0 0 0 1
27
Properties of Relations
A relation R on a set A is called symmetric if
and only if mij=mji of MR for i=1,2,.,n j=1,2,.,n

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

(a,b) 1 2 3 4

1 1 1 1 0

2 0 1 1 1
Antisymmet MR
ric 3 = 0 0 1 1

4 0 0 0 1
28
Properties of Relations
Suppose that the relation R on a set A is
represented by the matrix
A relation R is reflexive iff
1 1 0 (ai,ai)R this means that mii=1
for i=1,2,.,n
MR 1 1 1
=
0 1 1

A relation R is symmetric
1 1 0
if (a,b)R ↔ (b,a)R
MR 1 1 1 this means that mij=mji for
= i=1,2,.,n
0 1 1
29
Properties of Relations
Suppose that the relation R on a set A is
represented by the matrix

1 1 0

MR 0 1 1 This relation is reflexive


symmetric
=
0 1 0 antisymmetric

0 0 0
MR 1 1 1 This relation is reflexive
= symmetric
1 0 1 antisymmetric
30
Properties of Relations
Suppose that the relation R on a set A is
represented by the matrix

1 1 0

MR 1 1 1 This relation is reflexive


symmetric
=
0 1 0 antisymmetric

1 1 0
MR 1 1 0 This relation is reflexive
= symmetric
0 0 1 antisymmetric
31
Properties of Relations
Let R be the relation consisting of all pairs
(x,y) of students at your school, where x has
taken more credits than y.
Suppose that x is related to y and y related to
z.
This means that
x has taken more credits than y and
y has taken more credits than z
We can conclude that
x has taken more credits than z, so that x is
related to z.

The relation R has the transitive property. 32


Properties of Relations
A relation R on a set A is called transitive if
whenever (a,b)R and (b,c)R then (a,c)R ,
for all a, b, c  A
abc(( (a,b)R  (b,c)R) → (a,c)R)

33
Properties of Relations
Consider the following relations on the
{1,2,3,4}
R1 ={(1,1),(1,2),(2,1),(2,2),(3,4),(4,1),(4,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)}
R5 ={(1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),
(3,3),
(3,4),(4,4)}
R6 ={(3,4)}
Which of these relations are transitive ?
 The relation is transitive 34
Properties of Relations
Consider the following relations on the set of
integers
R1={(a,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}
Which of these relations are transitive ?

The relation is transitive


If (a,b) and (b,c) belong to the relation
then (a,c) also does. 35
Properties of Relations
Is the “divides” relation on the set of positive
integers transitive?

Suppose that a divides b and b divides c.


Then there are positive integers k and l such
that b=ak and c=bl.

Hence, c=a(kl), so a divides c.


It follows that the relation is transitive

36
Properties of Relations
A relation is transitive if and only if whenever
there is an edge from a vertex x to a vertex y
and an edge from a vertex y to a vertex z,
there is an edge from a vertex x to a vertex z
completing a triangle where each side is a
directed edge with the correct direction.

2
1

3 4
37
Properties of Relations
Exercises PP.542-544
2-3
13-14
22-28
32

38
Combining Relations
Let A={1,2,3} and B={1,2,3,4}
The relation
R1={(1,1),(2,2),(3,3)}
R2={(1,1),(1,2),(1,3),(1,4)}

R1  R2 = {(1,1),(1,2),(1,3),(1,4),(2,2),(3,3)}
R1  R2 = {(1,1)}
R1 - R2 = {(2,2),(3,3)}
R2 - R1 = {(1,2),(1,3),(1,4)}
R1  R2 = R2  R1 = R1  R2 - R1  R2
= {(1,2),(1,3),(1,4),(2,2),(3,3)}
39
Combining Relations
Let A={1,2,3} and B={1,2,3,4}
The relation
R1={(1,1),(2,2),(3,3)}
R2={(1,1),(1,2),(1,3),(1,4)}
Construct MR1 and MR2

R1  R2 = MR1R2 = MR1  MR2


R1  R2 = MR1R2 = MR1  MR2

40
Compositions of Relations
Let R be a relation from a set A to a set B and
S a relation from B to a set C.
The composite of R and S is the relation
consisting of ordered pairs (a,c), where aA ,
cC, and for which there exists an element
bB such that (a,b)R and (b,c)S. we denote
the composite of R and S by SR

Example
R is the relation from {1,2,3} to {1,2,3,4}
S is the relation from {1,2,3,4} to {0,1,2}
R = {(1,1),(1,4),(2,3),(3,1),(3,4)}
S = {(1,0),(2,0),(3,1),(3,2),(4,1)}
SR={(1,0),(1,1),(2,1),(2,2),(3,0),(3,1)}} T/F
41
Compositions of Relations
To find the matrix representing the relation
SR (composite of R and S)

Construct MR and Ms

Then calculate the Boolean product (⊙) of the


matrix MR and Ms

MSR= MR ⊙ Ms

42
Compositions of Relations
•The nth power Rn of a relation R on a set A can
be defined recursively by:
R1 =R Rn+1 = RnR for all n>0.
R2= RR , R3= R2R = (RR)R
Example
R = {(1,1),(2,1),(3,2),(4,3)}, find the powers
Rn,n=2,3,4,….

R2= RR= {(1,1),(2,1),(3,1),(4,2)}


R3= R2R= {(1,1),(2,1),(3,1),(4,1)}
R4= R3R= {(1,1),(2,1),(3,1),(4,1)}= R3
Rn= R3

43
Compositions of Relations
Let R be a relation from a set A to a set B,

 The inverse relation (R-1) from B to A is the


set of ordered pairs { (b,a) | (a,b)  R }

 The complement relation R is the set of


ordered
pairs { (a,b) | (a,b)  R }

Exercises PP. 527-529


1-7 , 24-25 , 32 , 54

44
Closures of Relations
Consider relation R={(1,2),(2,2),(3,3)} on the
set A = {1,2,3,4}.
Is R reflexive? No

What can we add to R to make it reflexive?


(1,1), (4,4)

R’ = R U {(1,1),(4,4)} is called the reflexive


closure of R.

45
Closures of Relations
In general
Let R be a relation on a set A
R may or may not have some property P such
as:
Reflexivity – Symmetry – Transitivity

The closure of relation R on set A with respect


to property P is the relation R’ with
 R  R’
 R’ has property P

R’ is called the closure of R with respect to P


46
Closures of Relations
Let R be the relation on {1, 2, 3, 4} such that
R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 3), (4, 4)}.
Find: (a) the reflexive closure of R.
(b) the symmetric closure of R.
(c) the transitive closure of R.

(a) {(1,1), (1,4), (2,2), (2,3), (3,1), (3,3),


(4,4)}.

(b) {(1,1), (1,3), (1,4), (2,3), (3,1), (3,2), (3,3),


(4,1), (4,4)}.

(c) {(1,1), (1,4), (2,1), (2,3), (2,4), (3,1), (3,3),


(3,4), (4,4)}.
47
Read examples 1 and 2 PP. 454
Equivalence Relations
A relation on a set A is called equivalence
relation if it is reflexive, symmetric, and
transitive.
Two elements a and b that related by an
equivalence relation are called equivalent. a ~
b

Is R is equivalence relation?
R={(a,b) | a=b or a=-b} r,s, and t

Read examples 2,4,5,6,7 PP. 556-557


Exercises PP.553-554
1,3, 5-7
Exercises PP.562-563 48
Equivalence Relations
Congruence Modulo m
Let m be a positive integer m>1 . Show that
the following relation is an equivalence
relation on the set of integers.
R={ (a,b) | ab(mod m) }
Note that ab(mod m) Means m divides a-b
 a-a=0 and is divisible by m ( R is reflexive )
 ab(mod m) then a-b=km where k is an
integer
It follows that b-a=(-k)m means ba(mod
m)
( R is symmetric )
 suppose that ab(mod m) and bc(mod m)
a-b=km and b-c=lm add both equations we
get: 49

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy