Relations

Discrete Systems I
Lecture 05
Relations
Profs. Koike and Yukita
1. Examples of relations
•
•
•
•
“less than”
“is parallel to”
“is a subset of”
“are equal”
Disc Sys 05
2
Sorts of Relations
• Equivalence relations
a  b, ABC  DEF , ABC  DEF , 8  3 mod 5
• Order relations
a  b, a  b,
A  B, a | b
• Functions
y  f (x)
Disc Sys 05
3
Ordered Pair
(a, b) is an ordered pair.
Given two ordered pairs (a, b) and (c, d )
we say they are equal if and only if
a  c and b  d .
When the order is irrelevant , we write as
{a, b} and call it a pair(an unordered pair).
Disc Sys 05
4
2. Product Sets
A  B  {( a, b) | a  A, b  B}
A  A A
2
Disc Sys 05
5
Examples
R  R  R  {( x, y ) | x  R, y  R}
2
Two dimensiona l real vector space.
Do not confuse with the following.
{( x, x) | x  R, x  R}
This set is a subset of R  R.
Disc Sys 05
6
Examples
A  {1,2}, B  {a, b, c}
A  B  {(1, a ), (1, b), (1, c), (2, a ), (2, b), (2, c)}
B  A  {( a,1), (a,2), (b,1), (b,2), (c,1), (c,2)}
A  A  {(1,1), (1,2), (2,1), (2,2)}
n( A  B)  n( A)  n( B ) for any finite sets A and B.
Disc Sys 05
7
Products of finite number of sets
A1  A2   An or
n
A
i
i 1
 {( x1 , x2 ,  , xn ) | xi  Ai }
A  A A A
3
Disc Sys 05
8
3. Definition of a relation
A relation from A to B is a subset of A  B.
(i) (a, b)  R; "a is related to b ", written aRb.
(ii) (a, b)  R; "a is not related to b ", written aRb.
{a | (a, b)  R for some b  B}
: The domain of R.
{b | (a, b)  R for some a  A} :The range of R.
When A  B, we say "R is a relation on A."
Disc Sys 05
9
Examples
Let us say that t wo countries are adjacent,
if they have some part of their boundaries
in common. Let us denote by R the " is adjacent t o"
relation.
(Italy, Switzerlan d)  R
(Canada, Mexico)  R
Disc Sys 05
10
Examples
(i) Set inclusion  is a relation on any collection
of sets.
(ii) When integer m divides n, we write m | n.
Then "|" is a relation on Z. For example,
6 | 30, 7 | 25.
Disc Sys 05
11
Equality
Let A be any set. Equality " " is a relation on A.
The equality relation on A is
{( a, a) | a  A}.
The identity relation, the diagonal relation on A.
Disc Sys 05
12
Inverse relation
1
R  {( b, a) | (a, b)  R}
For example the inverse relation of  on
a collection of sets is  .
Disc Sys 05
13
4. Pictorial representations
The equation x 2  y 2  25 defines a relation
S  R 2 , where
S  {( x, y ) | ( x, y )  R 2 , x 2  y 2  25}.
y
0
Disc Sys 05
5
x
14
Matrix of a relation
x
A  {1,2,3},
y
z
1 0 1 1
B  {x, y, z}
R  {(1, y ), (1, z ), (3, y )}
Disc Sys 05
2 0 0 0
3 0 1 0
15
Problem 1
Find the matrix representation for the relation R
below.
A  {1,2,3,4},
B  {x, y, z}
R  {(1, y ), (2, z ), (3, x), (4, z )}
Disc Sys 05
16
Arrow diagram of a relation
A  {1,2,3},
B  {x, y, z}
R  {(1, y ), (1, z ), (3, y )}
Disc Sys 05
1
x
2
y
3
z
A
B
17
Problem 2
Draw an arrow diagram of the relation R below.
A  {1,2,3,4},
B  {x, y, z}
R  {(1, y ), (2, z ), (3, x), (4, z )}
Disc Sys 05
18
Directed graph of
a relation on a set
A  {1,2,3,4}
R  {(1,2), (2,2), (2,4), (3,2), (3,4), (4,1), (4,3)}
1
2
3
4
Disc Sys 05
19
Problem 3
Draw the graph of the relation R below.
A  {1,2,3,4}
R  {(1,1), (2,2), (2,4), (3,3), (3,4), (4,1), (4,3)}
Disc Sys 05
20
5. Composition of relations
Let A, B, and C be sets, and let R be a relation
from A to B and let S be a relation from B to C.
R  S  {( a, c) | there exists b  B for which
(a, b)  R, (b, c)  S }
The compositio n of R and S .
Disc Sys 05
21
Example of composition(1)
A  {1,2,3,4}, B  {a, b, c, d }, C  {x, y, z}
R  {(1, a), (2, d ), (3, a ), (3, b), (3, d )}
S  {( b, x), (b, z ), (c, y ), (d , z )}
R  S  {( 2, z ), (3, x), (3, z )}
Let us work out the composition by drawing
arrow diagrams.(See the next two slides).
Disc Sys 05
22
Example of composition(2)
1
a
x
2
b
y
3
c
z
4
d
S
R
Disc Sys 05
23
Example of composition(3)
1
x
2
y
3
z
4
R S
Disc Sys 05
24
Composition by matrices(1)
a
b
c
d
x
y
z
1
1
0
0
0
a
0
0
0
MR  2
0
0
0
1,
MS  b
1
0
1
3
1
1
0
1
c
0
1
0
4
0
0
0
0
d
0
0
1
Let us multiply these two matrices. See the next slide.
Disc Sys 05
25
Composition by matrices(2)
x
1
y
z
0 0
0
M RS  M R M S  2 0 0 1
3 1
0
2
4 0 0
0
Disc Sys 05
Non-zero
26
Problem 4
Work out the composition by drawing
arrow diagrams.
A  {1,2,3,4}, B  {a, b, c, d }, C  {x, y, z}
R  {(1, a), (2, d ), (3, b), (4, b)}
S  {( b, x), (b, z ), (c, y ), (d , z )}
R  S  {( 2, z ), (3, x), (3, z ), (4, x), (4, z )}
Disc Sys 05
27
Problem 5
a
b
c
d
x
y
z
1
1
0
0
0
a
0
0
0
MR  2
0
0
0
1,
MS  b
1
0
1
3
0
1
0
0
c
0
1
0
4
0
1
0
0
d
0
0
1
Multiply these two matrices.
Disc Sys 05
28
Associative law
( R  S )  T  R  (S  T )
Disc Sys 05
29
6. Types of relations
Reflexive relations
A relation R on a set A is reflexive if aRa ,
that is, (a, a)  R for all a  A.
Disc Sys 05
30
Problem 6: Which are reflexive?
A  {1,2,3,4}
R1  {(1,1), (1,2), (2,3), (1,3), (4,4)}
R2  {(1,1), (1,2), (2,1), (2,2), (3,3), (4,4)}
R3  {(1,3), (2,1)}
R4  
R5  A  A
Disc Sys 05
31
Problem 7: Which are reflexive?
(1) Relation  on the set Z of integers.
(2) Set inclusion  on a collection C of sets.
(3) Relation  (perpendic ular) on the set L of
lines in the plane.
(4) Relation || (parallel) on the set L of lines
in the plane.
(5) Relation | of divisibili ty on the set N of
positive integers.
Disc Sys 05
32
Symmetric relations
A relation R on a set A is symmetric
if whenever aRb then bRa ,
that is,
if whenever (a, b)  R then (b, a)  R.
Disc Sys 05
33
Problem 8: Which are symmetric?
A  {1,2,3,4}
R1  {(1,1), (1,2), (2,3), (1,3), (4,4)}
R2  {(1,1), (1,2), (2,1), (2,2), (3,3), (4,4)}
R3  {(1,3), (2,1)}
R4  
R5  A  A
Disc Sys 05
34
Problem 9: Which are symmetric?
(1) Relation  on the set Z of integers.
(2) Set inclusion  on a collection C of sets.
(3) Relation  (perpendic ular) on the set L of
lines in the plane.
(4) Relation || (parallel) on the set L of lines
in the plane.
(5) Relation | of divisibili ty on the set N of
positive integers.
Disc Sys 05
35
Transitive relations
A relation R on a set A is transitive
if whenever aRb and bRc then aRc ,
that is,
if whenever (a, b)  R and (b, c)  R
then (a, c)  R.
Disc Sys 05
36
Problem 10:Which are transitive?
A  {1,2,3,4}
R1  {(1,1), (1,2), (2,3), (1,3), (4,4)}
R2  {(1,1), (1,2), (2,1), (2,2), (3,3), (4,4)}
R3  {(1,3), (2,1)}
R4  
R5  A  A
Disc Sys 05
37
Problem11:Which are transitive?
(1) Relation  on the set Z of integers.
(2) Set inclusion  on a collection C of sets.
(3) Relation  (perpendic ular) on the set L of
lines in the plane.
(4) Relation || (parallel) on the set L of lines
in the plane.
(5) Relation | of divisibili ty on the set N of
positive integers.
Disc Sys 05
38
Summary with a graph view
• Let R be a relation on a finite set A.
• R is reflexive if and only if every vertex has a
loop-back arrow.
• R is symmetric if and only if every arrow has an
inverse arrow.
• R is transitive if and only if for every sequence of
arrows there is a short cut, that is, an arrow that
connects the start and end vertices.
Disc Sys 05
39