Download - 5-M131-Chapter8-Suha AlShaikh
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
1
Binary relation
Let A, B be any two sets.
A binary relation R from A to B, written R:A↔B, is a subset of A×B.
The notation a R b or aRb means (a,b)R.
The notation a R b or aRb means (a,b) R.
If aRb we may say “a is related to b (by relation R)”, or “a relates to b (under
relation R)”.
:Example
Let R: A ↔ B
A = {1, 2, 3} represents students
B = {a, b} represents courses
A × B = { (1,a), (1,b), (2,a), (2,b), (3,a), (3,b)}
R = { (1,a), (1,b) } it means that student 1 registered in courses a and b
Roaster Notation: List of ordered pairsA.
Ex: Let A be the set {1,2,3,4}, which ordered pairs are in the relation R={(a,b)| a
divides b}?
R= {(1,1),(2,2),(3,3),(4,4),(1,3),(1,2),(1,4),(2,4)}
Set builder notation B.
Ex: R={(a,b)| a divides b}
Graph C.
R1 = {(1,1),(2,2),(3,3),(4,4),(1,3),(1,2),(1,4),(2,4)}
8.1 Relations and their properties
be represented by:Relations can
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
2
Table D.
R = {(1,1),(2,2),(3,3),(4,4),(1,3),(1,2),(1,4),(2,4)}
Relations on a Set
A (binary) relation from a set A to itself is called a relation on the set A.
of natural numbers. Nthe set on” relation defined as a relation <The “ :Example
let < : N↔N :≡ {(a,b) | a < b}
If (a,b)R then a < b means (a,b) <
ex: (1,2) <
* The identity relation IA on a set A is the set {(a,a)|aA}.
Example:
A = {1,2,3,4}
IA = {(1,1),(2,2),(3,3),(4,4)}
Example:
R1= {(a,b)| a ≤ b}
R2= {(a,b)| a =b or a=-b}
R3= {(a,b)| a+b ≤ 3}
Which of these relations contain each of the following pairs (1,1),(1,2),(1,-1)?
(1,1) is in R1,R2,R3
(1,2) is in R1,R3
(1,-1) is in R2,R3
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
3
Question:
How many relations are there on a set with n elements?
1. A relation on set A is a subset from A x A.
2. A has n elements so A x A has n2 elements.
3. Number of subsets for n2 elements is
2
2n
Thus there are 2
2n relations on a set with n elements.
Example
S ={a, b, c}
There are :
Relations
Reflexivity & Irreflexivity1.
A. a R for every element a,a)if ( eflexiveris Aon RA relation
: Consider the following relations on {1,2,3,4}Ex
1. R1={(1,1),(1,2),(2,1),(2,2),(3,4),(4,1),(4,4}
Not Reflexive
2. R2={(1,1),(2,1),(2,2),(3,3),(3,4),(4,4)}
Reflexive
3. R3 = {(a, b) | a ≤ b} Reflexive
R A, (a, a) a if for every element lexiveirref A relation R on A is
Note: “irreflexive” ≠ “not reflexive”
Example:
A= {1, 2}
R = {(1, 2), (2, 1), (1, 1)}
Not Reflexive because (2, 2) R
Not irrflexive because (1,1) R
51222 932
Properties of Relations
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
4
Example:
Not Reflexive and Not Irreflexive
:Example
2. Symmetry & Antisymmetry
:if symmetricis Aon RA binary relation *
(a,b)R ↔ (b,a)R. where a, b A
:if antisymmetricon A is RA binary relation *
(a,b)R → (b,a)R.
also: (a,b)R (b,a) R →(a=b)
:Example
Let A = {1,2,3}
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
5
Example:
Consider these relations on the set of integers:
R1={(a, b) | a=b}
symmetric , antisymmetric
R2={(a, b) | a>b}
not symmetric, antisymmetric
R3={(a, b) | a=b+1}
not symmetric, antisymmetric
Transitivity3.
A relation R is transitive iff (for all a,b,c)
(a,b)R (b,c)R → (a,c)R.
A= {1,2} :Examples
R1={(1,1),(1,2),(2,1),(2,2)} transitive
R2={(1,1),(1,2),(2,1)} not transitive, (2,2) R2
R3 ={(3,4)} transitive
Special cases
Empty set {}
irreflexive, transitive, symmetric, antisymmetric
U universal set.
Reflexive, transitive, symmetric
Combining Relations:
Let A={1,2,3} , B={1,2,3,4}
R1={(1,1),(2,2),(3,3)}
R2={(1,1),(1,2),(1,3),(1,4)}
R1 R2 = {(1,1),(2,2),(3,3), (1,2),(1,3),(1,4)}
R1 R2= {(1,1)}
R1- R2={(2,2),(3,3)}
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
6
:Composite Relations
If R1 a relation from a set A to a set B, and R2 is a relation from set B to set C, the
R2◦ R1 is a set from A to C.
If (a,c) is in R1 and (c,b) is in R2 then (a,b) is in R2◦ R1 and
: Ex
R is the relation from {1,2,3} to {1,2,3,4}
R={(1,1), (1,4),(2,3),(3,1),(3,4)}
S is the relation from {1,2,3,4} to {0,1,2}
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)}, a relation from {1,2,3} to {0,1,2}
Power
Let R be a relation on the set A.
the power Rn, n=1,2,3… are defined by
R1 =R and R
n = R
n-1 ◦ R
: Let R ={(1,1),(2,1),(3,2),(4,3)}. Ex
Find:
R2 = {(1,1),(2,1),(3,1),(4,2)}
R3 = R
2 ◦ R= {(1,1),(2,1),(3,1),(4,1)}
The Inverse Relation :
Let R be a Relation from a set A to a set B. The inverse relation from B to A denoted
by: R-1
= {(b,a)| (a,b) R}.
The Complementary Relation:
}),(|),{( RbabaR
A 1R B 2R C
CRR 12 A
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
7
Some special ways to represent binary relations:
*With a zero-one matrix.
*With a directed graph.
To represent a relation R by a matrix
MR = [mij], let mij = 1 if (ai,bj)R, else 0.
E.g., Joe likes Susan and Mary, Fred likes Mary, and Mark likes Sally.
The 0-1 matrix representation of that “Likes”relation:
: Example
A={1,2,3} , B={1,2} , R: A↔B such that:
R= {(2,1),(3,1),(3,2)} then the matrix for R is:
8.3 Representing Relations
One Matrices-Using Zero
1 00
010
0 1 1
Mark
Fred
Joe
SallyMarySusan
11
01
00
RM
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
8
One Reflexive, Symmetric-Zero
.ymmetric and antisymmetric,sReflexive, irreflexive-non ,Reflexive :Terms
These relation characteristics are very easy to recognize by inspection of the zero-
one matrix.
all the elements on the main diagonal of1) The relation R is reflexive if : Remark
Are equal to 1 (note that is a square matrix)
(2) The relation R is symmetric if and only if jiij mm for all pairs of integers i
and j with i = 1,2,…..,n and j = 1,2,…….n
(3)The relation R is symmetric if and only if : t
RR MM )(
(4) The relation R is anti symmetric if and only if (a,b)R and (b,a) R → a=b. The
matrix of anti symmetric relation has the property that if
Example:
Is R reflexive, symmetric, antisymmetric?
Reflexive, symmetric, not antisymmetric
Operations
1) Union and the Intersection
The Boolean Operations join and meat can be used to find the matrices
representing the union and the intersection of two relations
Then:
110
111
011
RM
2121
2121
RRRR
RRRR
MMM
MMM
RM
RM
01 jiij mthenjim
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
9
Example:
Suppose R1 and R2:relations on set A are represented by the matrices:
Then :
2) Composite
Suppose that R: A ↔ B, S: B ↔ C
(Boolean Product)
Example:
Let
Find the matrix of
3)Power
• R2 =R ◦ R = MR
[2]
• R3= R
2◦ R = MR
[3]
001
110
101
010
001
101
21 RR MandM
000
000
101
011
111
101
2121
2121
RRRR
RRRR
MMM
MMM
SRRS MMM
101
100
010
000
011
101
SR MandM
RS
000
110
111
RSM
][n
RRMM n
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
11
Example
Find the matrix that represent R2
where the matrix representing R is:
A directed graph or digraph G=(VG,EG) is a set VG of vertices (nodes) with a set
EGVG×VG of edges (arcs,links). Visually represented using dots for nodes, and
arrows for edges. Notice that a relation R:A↔B can be represented as a graph
GR=(VG=AB, EG=R).
Example:
List the vertices and the edges.
Answer: Vertices are a,b,c, and d
Edges are (a,b), (b,b), (c,b), (a,d), (b,d), (d,b), and (c,a).
Example: Draw a diagraph 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}
Solution:
010
111
110
001
110
010
2RR MthenM
1 00
010
0 1 1
Mark
Fred
Joe
SallyMarySusan
Note that : an edge from (a,a) represented using an arc from the
vertex a back to it self. Such an edge is called a loop
Using Directed Graphs
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
11
Digraph Reflexive, Symmetric
It is extremely easy to recognize the reflexive/irreflexive/ symmetric/antisymmetric
properties by graph inspection.
Example: Determine whether the relation for the following directed graph are
reflexive, symmetric , anti symmetric, and or transitive.
Solution: 1) because there are loops at every vertex R is reflexive.
(a,a), (b,b), (c,c) R
2)It is not symmetric because there are (a,b) but not (b,a).
3)R is not anti symmetric, because (b,c) and (c,b) in R.
4)R is not transitive because (a,b), and (b,c) belongs to S, but (a,c) doesn’t belong.
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
12
Definition: For any property X, the “X closure” of a set A is defined as the “smallest”
superset of A that has the given property.
Example
The relation R={(1,1),(1,2),(2,1),(3,2)} on the set A ={1,2,3} is not reflexive.
How can you produce a reflexive relation containing R that is as small as possible?
Answer: By adding (2,2) and (3,3) so :
Reflexive closure of R is:
{(1,1),(1,2),(2,1),(3,2),(2,2),(3,3)}
Example
What is the reflexive closure of the relation:
R={(a ,b)| a < b} on the set of integers?
Answer:
The Reflexive Closure of R is:
{(a ,b)| a < b} {(a,a)| a Z} = {(a,b) | a ≤ b}
The reflexive closure of a relation R on A is obtained by adding (a,a) to R for each
aA not already in R
I.e., it is R IA
Closures of Relations
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
13
Example
The relation
{(1,1),(2,2),(1,2),(3,1),(2,3),(3,2)} on the set {1,2,3} is not symmetric.
How can we produce a symmetric relation that is as small as possible and contains R?
Answer: by adding (2,1) and (1,3) so theSymmetric Closure of R is:
{(1,1),(2,2),(1,2),(3,1),(2,3),(3,2),(2,1),(1,3)}
Example
What is the symmetric closure of the relation:
R={(a ,b)| a > b} on the set of positive integers?
Answer:
The Symmetric Closure of R is:
{(a ,b)| a >b} {(b, a)| a > b} = {(a, b) | a ≠ b}
Example
R={(1,1), (1,2), (2,1),(3,2)} on the set A= {1, 2, 3}
• R* = R R2 R
3
• R2 = R ◦ R = {(1,1),(1,2),(2,2),(3,1)}
• R3 = R
2o R = {(1,1),(1,2),(2,1),(2,2),(3,2)}
• R* = {(1,1),(1,2),(2,1),(3,2),(2,2),(3,1)}
The transitive closure or connectivity relation of R is obtained by repeatedly
adding (a, c) to R for each (a, b), (b, c) in R.
i.e., it is
Or in term of zero-one matrices:
MR*=MR MR[2]…………MR[n]
The symmetric closure of R is obtained by adding (b,a) to R for each (a,b) in R.
i.e., it is R R−1
Zn
nRR*
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
14
Example:
Find MR* for
Questions: 1) let R be the relation on the set {0,1,2,3} containing the pairs
(0,1),(1,1),(1,2),(2,0),(2,2) and (3,0). Find the
a) Reflexive closure of R
b) Symmetric closure of R
Answer: a) reflexive closure of R={(0,0),(0,1),(1,1),(1,2),(2,0),(2,2),(3,0),(3,3)}
b) Symmetric closure of R={(0,1),(0,2),(0,3),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2),(3,0)}
_____________________________________________________________________
2) Let R be the relation {(a,b)| a divides b} on the set of integers. What is the
symmetric closure of R?
Solution: Symm. Closure of R={(a,b)| a divides b or b divides A}
_____________________________________________________________________
3) Draw the directed graph of the reflexive closure and the symm. Closure of the
relation with the directed graph shown
Solution:
111
010
111
011
010
101
]3[]2[* RRRR
R
MMMM
M
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
15
An equivalence relation on a set A is simply any binary relation on A that is reflexive,
symmetric, and transitive.
Example:
A relation on the set of real numbers such that
R={(a, b) | a-b is an integer}
Answer:
R is reflexive since (a,a) is an integer where a-a=0
R is symmetric since a-b and b-a is an integer
R is transitive since for (a,b) then a-b integer and for (b,c) then b-c integer ,
Therefore( a-b )+( b-c) =a-c is also an integer so (a,c) in R
so R is an Equivalence Relation.
Example:
Let R: Z Z, show that R = {(a,b)| a ≡b(mod m)}, m>1} is an equivalence
relation.
Answer:
a ≡b(mod m) iff m divides a-b
*R is reflexive, a ≡a(mod m) , m divides a-a=0
*R is symmetric: suppose a ≡b(mod m) then a-b is divisible by m so that a-b = km
It follows: b-a = (-k)m
So that : b ≡a(mod m)
*R is transitive: Suppose
a ≡b (mod m) and b ≡c ( mod m)
Then: m divides both a-b and b-c
a - b=km and b - c=lm
a-c=(a-b)+(b-c)=km+lm=(k+l)m
Thus: a ≡c ( mod m) So R is Equivalence
Equivalence Relations
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
16
Read example 4 and 5 page 557
Example: show that “divides” relation on the set of positive integers is not an
equivalence relation.
Solution:
reflexive: since a|a for all positive integers →aRa
Symmetric: since 2|4 but 4×2 so R is not symmetric .
so R is not an equivalence relation
Example: let R be the relation on the set of real numbers such that x Ry if and only if
x and y are real numbers that differ by less than 1. That is |x-y|<1. Show that R is not
an equivalence relation.
Solution:
reflexive since |x-x|=0<1 where ever xR Ris reflexive.
Symmetric: suppose xRy→|x-y|<1 but
|x-y|=|y-x|<1→yRx so R is symmetric.
Suppose xRy and yRz
So R is not transitive.
Equivalence classes:
Definition: let R be an equivalence relation on a set A. The set of all elements that are
related to an element a of A is called the equivalence class of a (denoted by [a]R ).
Do example8.
222
2211
11
11
zxzx
zyyxaddzy
yx
zyandyx
Rsasa R ),(|
Rab
Remark: in other words, if R is an equivalence relation on a set A, the equivalence
class of the element a is
If , then b is called a representative of this equivalence class.
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
17
Example: what are the equivalence classes of 0 and 1 for congruence modulo 4?
Solution:
*The equivalence class of 0 contains all integers a such that )4(modoa . The
integers in this class are divisible by 4. so
*The equivalence class of 1 contains all integers a such that )4(modoa
The integers in this class are those that have a remainder 1 when divided by 4.
So
Remark: The congruence classes of an integer a modulo m is denoted by
Refer to last example. Find
,....8,4,0,4,8....,0 4
,....9,5,1,3,7....,1 4
,...2,,,,2......, mamaamamaa m
44 32 and
,...11,7,3,1,5....,3
,...10,6,2,2,6....,2
4
4
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
18
Definition: A relation R on a set S is called a partial ordering or partial order if it is
reflexive, anti symmetric and transitive.
A set S together with R is called a partially ordered set, or poset and is denoted by
(S,R), members of S are called elements of the poset.
Example1: (page566)
Show that the “greater than or equal” relation (≥)is the partial ordering on the set of
integers.
Solution:
1) reflexive: because a≥a for every integer a≥ is reflexive.
2) Anti symmetric: if a ≥ b and b ≥ a, then a=b. Hence ≥ is anti symmetric.
3) transitive: if a ≥ b and b ≥ c then a ≥ b ≥ c. Hence a ≥ c so ≥ is transitive. It follows
that ≥ is a partial ordering on the set of integers and (Z, ≥) is a poset.
Example: Show that |),( Z is a poset. Where Z+ is the set of positive integers,
and ( | is the devision)
Solution: 1) reflexive: since a|a for every positive integer a. | is reflexive.
2) Anti symmetric: if a|b and b|a then a=b. Hence | is anti symmetric.
3) transitive: Suppose a|b and b|c then b=ka and c=lb
C=lb=l(ka)=(lk)a→a|c so | is transitive
It follows that | is a partial ordering on the set of positive integers and and |),( Z
is a poset.
Example: show that the inclusion relation is a partial ordering on the power set of a
set S.
Solution:* reflexive because A A whenever A is a subset of S, is reflexive.
*Anti symmetric: because if A B and B A this implies that A=B.
*Transitive: suppose A B and B C then A B C→A C Hence is
transitive
Therefore is a partial ordering on the power set of a set S; and (p(s), ) is a poset.
8.6: Partial orderings
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
19
Example: page 567
Let R be the relation on the set of people such that xRy if x and y are people and x is
older than y. Show that R is not a partial ordering.
Solution: R is not reflexive because no person is older than himself or herself. That is
xRx for all people x it follows that R is not partial ordering.
Definition: page 567
The elements a and b of a poset (S, ) are called comparable if either a b or b a.
Example: In the poset |),( Z are the integers 3 and 9 comparable? Are 5 and 7
comparable?
Solution: because 3|9, the integers 3 and 9 are comparable. Because 5 | 7, the integers
5 and 7 are in comparable.
Definition: if is a poset and every 2 elements of S are comparable, S is called a
totally ordered or linearly ordered set, and is called a total order or a linear order.
A totally ordered set is also called a chain.
Example:page 568:
the poset (Z,≤) is totally ordered, because a≤b or b≤a whenever a and b are integers.
Example: the poset |),( Z is not totally ordered because it contains elements that are
in comparable, such as 5 and 7.
Lexicographic order: consider the 2 posets . The lexicographic
ordering ≤ on A1×A2 is defined by:
Remark: when every two elements in the set are comparable, the relation is called
a total ordering.
,S
2211 ,, AandA
22211111
21212121 ,,,,
baandbabothiforbaifeither
bbaaisthatbbthanlessisaa
Remark: The notation a is used to denote that (a,b)R in an arbitrary poset
(S,R).
is used to denote the relation in any poset
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
21
Example: determine whether (3,5) (4,8) whether (3,8) (4,5) and
whether (4,9) (4,11) in the poset where is the lexicographic ordering
constructed from the usual ≤ relation on Z.
Solution: because 3<4 it follows that (3,5) (4,8) and that (3,8) (4,5), we have
(4,9) (4,11), because the first entries of (4,9) and (4,11) are the same but 9<11.
Examplepage 569:
note that (1,2,3,5) (1,2,4,3), because the entries in the first 2 positions of these 4-
tuples agree, but in the third position the entry in the first 4-tuples,3 is less than 4 (
here the ordering on 4-tuples is the lexicographic ordering that comes from the usual
“less than or equals” relation on the set of integers).
Hasse diagrams: (finite set)
The Hasse Diagram for the partial ordering relation is obtained from the associated
diagrams by deleting all the loops and all the edges that occur from transitivity
1) Starts with the directed graphs for the given relation (partial ordering set)
2) Remove the loops (since it is reflexive)
3) Remove the edges that must be in-the partial ordering because of the presence
of other edges and transitivity. E.g if (a,b) and (b,c) are in the partial ordering
remove (a,c)
4) Finally arrange each edge so that its initial vertex is below its terminal vertex.
Example: Draw the Hasse Diagram representing the partial ordering {(a,b):a≤b} on
the set {1,2,3,4}
Solution: R{(1,1),(2,2),(3,3),(4,4),(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)}
M131-Chapter8 By Ms. Suha Al-Shaikh-Dammam
21
Example: Draw the Hasse Diagram representing the partial ordering {(a,b):a|b} on
{1,2,3,4,6,8,12}
Answer:
R={(1,1),(1,2),(1,3),(1,4),(1,6),(1,12),(2,2),(2,4),(2,6),(2,8),(2,12),(3,3),(3,6),(3,12),
(4,4),(4,8),(4,12),(6,6),(6,12),(8,8)(12,12)}