Discrete
Mathematics
Relations (Lecture
4)
大葉大學 資訊工程系 黃鈴玲 (Lingling Huang)
[Link]
Outline
Relations and their properties
Reflexive
Symmetric
Transitive
Representing Relations
Matrices
Graphs
Ch8-2
Relations and their 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.
Binary Relation
Let A and B be sets. A binary relation from A to B is
a subset R of A B = { (a, b) : aA, bB }.
Example.
A : the set of students in your school.
B : the set of courses.
R = { (a, b) : aA, bB, a is enrolled in course b }
Ch8-3
Related to: 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 AB = { (0,a) , (0,b) , (1,a)
(1,b) , (2,a) , (2,b)}
0
a R R
1
b
2
R
Ch8-4
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) }
Ch8-5
Example. Consider the following relations on Z.
R1 = { (a, b) | a b }
R2 = { (a, b) | a > b } Which of these relations
R3 = { (a, b) | a = b or a = b } contain each of the pairs
R4 = { (a, b) | a = b } (1,1), (1,2), (2,1), (1,1),
R5 = { (a, b) | a = b+1 } and (2,2)?
R6 = { (a, b) | a + b 3 }
Sol : (1,1) (1,2) (2,1) (1,1) (2,2)
R1 ● ● ●
R2 ● ●
● ● ●
R3
● ●
R4
●
R5
● ● ● ● Ch8-6
Properties of Relations
Reflexive. 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
Ch8-7
Example. Which of the relations from
Example 5 are reflexive?
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 }
Sol : R1, R3 and R4
R6 = { (a, b) | a + b 3 }
Example. Is the “divides” relation on the set of
positive integers reflexive?
Sol : Yes.
Ch8-8
Symmetric and Antisymmetric.
(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.
Ch8-9
Example. Which of the relations from Example 7
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.
Example. Is the “divides” relation on the set of
positive integers symmetric? Is it antisymmetric?
Sol : It is not symmetric since 1|2 but 2 | 1.
It is antisymmetric since a|b and b|a implies a=b.
Ch8-10
Comparison:
antisymmetric vs. symmetric
sym. (b, a)R
(a, b)R, a≠b
antisym. (b,a)R
eg. Let A = {1,2,3}, give a relation R on A s.t.
R is both symmetric and antisymmetric, but
not reflexive.
Sol :
R = { (1,1),(2,2) }
Ch8-11
Transitive. 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. Is the “divides” relation on the set of
positive integers transitive?
Sol : Suppose a|b and b|c
a|c
transitive
Ch8-12
Example. Which of the relations in Example 7 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.
Ch8-13
Combining Relations
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)}
symmetric difference, (R1R2) – (R1 R2)
Ch8-14
Composite. 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 aA, cC, and for which there exists an
element bB such that (a,b)R and (b,c)S. We
denote the composite of R and S by S R.
Example 20. What is the composite of relations R and
S, where R is the relation from {1, 2, 3} to {1, 2, 3, 4}
with R = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)} and S is the
relation from {1, 2, 3, 4} to {0, 1, 2} with S = {(1, 0),
(2, 0), (3, 1), (3, 2), (4, 1)}?
Sol. S R is the relation from {1, 2, 3} to {0, 1, 2} with
S R = {(1, 0), (1,1), (2, 1), (2, 2), (3, 0), (3, 1)}. Ch8-15
Power Relation. Let R be a relation on the set A.
The powers Rn, n = 1, 2, 3, …, are defined recursively
by R1 = R and Rn+1 = Rn R.
Example 22. Let R = {(1, 1), (2, 1), (3, 2), (4, 3)}.
Find the powers Rn, n=2, 3, 4,….
Sol. 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.
Therefore Rn = R3 for n=4, 5, ….
Thm 1. The relation R on a set A is transitive if and
only if Rn R for n = 1, 2, 3, ….
Ch8-16
Representing Relations
Representing Relations using 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
Ch8-17
Example 1. Suppose that A = {1, 2, 3} and B = {1, 2}
Let R = {(a, b) | a > b, aA, bB}.
What is the matrix MR representing R?
Sol :
R = {(2, 1), (3, 1), (3, 2)}
B
1 2
1 0 0
0 0
A 2
1 0
M R 1 0
3 1 1 1 1
Ch8-18
※ Let A={a1, a2, …,an}.
A relation R on A is reflexive iff (ai,ai)R,i.
a1 a2 … … an
i.e., a1 1
1
a2
MR :
:
an 1
※ 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
Ch8-19
※ 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
MR
1 0
0
Ch8-20
Example 3. 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
Ch8-21
eg. Suppose 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
0 1 1 1 1 ∴ R is reflexive and
0 1 1 1 antisymmetric,
1
MR not symmetric.
2 0 0 1 1
3 0 0 0 1
Ch8-22
Example 4. Suppose the relations R1 and R2 on a set A
are represented by the matrices
1 0 1 1 0 1
M R1 1 0 0 M R2 0 1 1
0 1 0 1 0 0
What are the matrices representing R1 R2 and
R1 R2?
Sol :
1 0 1 1 0 1
M R1 R2 1 1 1 M R1 R2 0 0 0
1 1 0 0 0 0
Ch8-23
Example 5. Find the matrix representing the relation
SR, where the matrices representing R and S are
1 0 1 0 1 0
M R 1 1 0 M S 0 0 1
0 0 0 1 0 1
Sol :
1 1 1
M S R M R M S 0 1 1
0 0 0
Ch8-24
Example 6. Find the matrix representing the relation
R2, where the matrix representing R is
0 1 0
M R 0 1 1
1 0 0
Sol :
0 1 1
M R2
1 1 1
0 1 0
Ch8-25
Representing Relations using Digraphs
Digraph. A directed graph (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).
Example 8. Show the 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 3
(4,1) Ch8-26
※ The relation R is reflexive iff
for every vertex,
(has loop)
※ The relation R is symmetric iff for any
vertices x≠y, either
x y
or x y
※ The relation R is antisymmetric iff for any x≠y,
or x
or
x y y x y
Ch8-27
※ 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
Ch8-28
Example 10. Determine whether the relations R
and S are reflexive, symmetric, antisymmetric,
and/or transitive b
a
Sol :
S
R: a reflexive, c d
not symmetric,
not reflexive,
not antisymmetric,
symmetric
not transitive
not antisymmetric
(a→b, b→c, a→c)
not transitive
(b→a, a→c, b→c)
b c
Ch8-29
Homework
Cs173 - Spring 2004
Homework
Cs173 - Spring 2004