Chapter 7 Relations: The Second Time Around
Chapter 7
Relations: The Second Time
Around
Equivalence Classes
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
1
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
Ex. 7.3 Consider a finite state machine M=(S,I,O,v,w).
(a) For s1,s2 in S, define s1Rs2 if v(s1,x)=s2 for some x in I.
Relation R establishes the first level of reachability.
(b) The second level of reachability. s1Rs2 if v(s1,x1x2)=s2
for some x1x2 in I2. For the general reachability relation we
have v(s1,y)=s2 for some y in I*.
(c) Given s1,s2 in S, the relation 1-equivalence, which is denoted
by s1E1s2, is defined when w(s1,x)=w(s2,x) for all x in I. This
idea can be extended to states being k-equivalence, where
s1Eks2 if w(s1,y)=w(s2,y) for all y in Ik.
If two states are k-equivalent for all k in Z+, then they are called
equivalent.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
2
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
Def. 7.2 A relation R on a set A is called reflexive if for all
x in A, (x,x) is in R.
Ex. 7.4 For A = {1,2,3,4}, a relation R A A will be reflexive
if and only if R {(1,1), (2,2), (3,3), (4,4)}. R = {(x , y )|
x , y A, x y} is reflexive on A.
2
n2
Ex. 7.5 If | A|= n, | A A|= n . There are 2 relations on A.
How many of these are reflexive?
We must include {(a i , a i )| a i A}. The remaining n 2 n pairs
can be either included or excluded from the relation. Therefore,
there are 2
n2 n
reflexive relations.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
3
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
Def. 7.3 Relation R on set A is call symmetric if (x , y ) R
(y , x ) R, for all x , y A.
Ex. 7.6 With A={1,2,3}, we have:
(a) R1={(1,2),(2,1),(1,3),(3,1)}, symmetric, but not reflexive;
(b) R2={(1,1),(2,2),(3,3),(2,3)}, reflexive, but not symmetric;
(c) R3={(1,1),(2,2),(3,3)}, R4={(1,1),(2,2),(3,3),(2,3),(3,2)},
both reflexive and symmetric;
(d) R5={(1,1),(2,3),(3,3)}, neither reflexive nor symmetric.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
4
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
To count the symmetric relations on A = {a1 , a 2 , , a n }, write
A A as A1 A2 , where A1 {(a i , a i |1 i n} and A2
1
{(a i , a j )|1 i , j n, i j}. A2 contains (n 2 n) subsets of
2
the form {(a i , a j ), (a j , a i )}. Therefore, there are
symmetric relations on A. And
symmetric relations on A.
1 2
( n n)
2
2
1 2
( n n)
n
2 22
reflexive and
Def. 7.4 For a set A, a relation R on A is called transitive if for
all x , y , z A, (x , y ), (y , z ) R (x , z ) R.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
5
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
Ex. 7.8 Define the relation R on the set Z+ by aRb if a exactly
divides b. Then R is transitive, reflexive, but not symmetric (2R6,
but not 6R2)
Ex. 7.9 Consider the relation R on the set Z where aRb when
ab 0. Then R is reflexive, symmetric, but not transitive.
(3R0,0R - 7, but not 3R - 7)
Def. 7.5 Consider a relation R on a set A, R is called antisymmetric
if for all a , b A, (aRb and bRa ) a = b.
Ex. 7.11 the subset relation: ARB if A B, reflexive, transitive,
antisymmetric, but not symmetric.
Ex. 7.12 A = {1,2,3}, R = {(1,2), (2,1), (2,3)} is neither symmetric
nor antisymmetric. R = {(1,1), (2,2)} is both symmetric and
antisymmetric.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
6
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
To count the antisymmetric relations on A = {a1 , a 2 , , a n }, write
A A as A1 A2 , where A1 {(a i , a i |1 i n} and A2
1 2
{(a i , a j )|1 i , j n, i j}. A2 contains (n n) subsets of
2
the form {(a i , a j ), (a j , a i )}. There are 3 choices for this kind of
subsets: select one or none of them. Therefore, there are
1 2
1 2
( n n)
( n n)
n
2 32
antisymmetric relations on A. And 32
reflexive and antisymmetric relations on A.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
7
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
Def. 7.6 A relation R os a set A is called a partial order, or a
partial ordering relation, if R is reflexive, antisymmetric, and
transitive. (It is called a total order if for any a,b in A, either a Rb
or bRa).
Examples of partial order: , , , ,
Ex. 7.15. Define the relation R on the set Z+ by aRb if a exactly
divides b. R is a partial order.
Def. 7.7 An equivalence relation R on a set A is a relation that is
reflexive, symmetric, and transitive.
Examples: aRb if a mod n=b mod n
The equality relation {(ai,ai)|ai in A} is both a partial order and
an equivalence relation.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
8
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Def. 7.8 If A, B , and C are sets with R 1 A B and R 2 B C ,
then the composite relation R 1 R 2 is a relation from A to C
defined by R 1 R 2 {( x , z )| x A, z C , and there are exists
y B with ( x , y ) R 1 , ( y , z ) R 2 }.
(Note the different ordering with function composition.)
Ex. 7.17 A={1,2,3,4}, B={w,x,y,z}, and C={5,6,7}. Consider
R1={(1,x),(2,x),(3,y),(3,z)}, a relation from A to B, and R2=
{(w,5),(x,6)}, a relation from B to C. Then R1 R2={(1,6),(2,6)}
is a relation from A to C.
Theorem 7.1 Let A, B, C, and D be sets with R 1 A B,
R 2 B C , and R 3 C D. Then R 1 ( R 2 R 3 )
( R 1 R 2 ) R 3.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
9
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Def. 7.9 Given a set A and a relation R on A, we define the power
of R recursively by (a) R 1 R; and (b) for n Z + , R n+1
R R n.
Ex. 7.19 If A = {1,2,3,4} and R = {(1,2), (1,3), (2,4), (3,2)}, then
R 2 {(1,4), (1,2), ( 3,4)}, R 3 {(1,4)}, and for n 4, R n .
Def. 7.10 zero - one matrix (Use boolean operation, 1 + 1 = 1)
1 0 0 1
Ex. 7.20 0 1 0 1 is a 3 4 (0,1) - matrix.
1 0 0 0
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
10
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Ex. 7.21 A={1,2,3,4}, B={w,x,y,z}, and C={5,6,7}.
R1={(1,x),(2,x),(3,y),(3,z)}, a relation from A to B, and R2=
{(w,5),(x,6)}, a relation from B to C.
1 0
2 0
M (R1 )
3 0
4 0
w
1 0 0
w 1 0 0
1 0 0
x 0 1 0
, M ( R 2 )
0 1 1
y 0 0 0
0 0 0
z 0 0 0
x y z
5 6 7
0 1 0 0 1 0 0 0
0 1 0 0 0 1 0 0
M (R1 ) M (R 2 )
0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
relation matrix
1 0
1 0
M ( R 1 R 2)
0 0
0 0
11
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Let A be a set with |A|=n and R a relation on A. If M(R) is the
relation matrix for R, then
(a) M(R)=0 (the matrix of all 0's) if and only if R is empty
(b) M(R)=1 (the matrix of all 1's) if and only if R=A A
(c) M(Rm)=[M(R)}m, for m in Z+.
Def. 7.11 Let E = (eij ) m n , F = ( f ij ) m n be two m n (0,1) matrices. We say that E precedes, or is less than, F , and we
write E F , if eij f ij , for all 1 i m,1 j n.
1 0 1
1 0 1
Ex. 7.23 With E =
and F =
, we have E F .
0 0 1
0 1 1
In fact, there are eight (0,1) - matrices G for which E G .
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
12
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Def. 7.12 For n Z + , I n ( ij ) n n is the n n (0,1) - matrix
1, if i = j
where ij
0, if i j
Def 7.13 Let A = (a ij ) m n be a (0,1) - matrix. The transpose of
A, written A tr , is the matrix (a *ji ) n m where a *ji a ij ,
for all 1 i m,1 j n.
0 1
tr 0 0 1
.
Ex. 7.24 A = 0 0 , A
1 0 1
1 1
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
13
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Theorem 7.2 Given a set A with | A|= n, and a relation R on A,
let M denote the relation matrix for R. Then
(a) R is reflexive if and only if I n M .
(b) R is symmetric if and only if M = M tr .
(c) R is transitive if and only if M M = M 2 M .
(d) R is antisymmetric if and only if M M tr I n .
(0 0 0 1 1 0 0,1 1 1)
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
14
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Proof of (c) Let M 2 M . If (x , y ), (y , z ) R,
1 1 1 M . Hence (x , z ) R.
xy yz xz
Conversely, if R is transitive and M is the relation matrix for R,
let sxz be the entry in row x and column z of M 2 , with sxz 1.
For sxz to be 1 in M 2 , there must exist at least one y A where
mxy myz 1 in M . This happens only if (x , y ), (y , z ) R. With
R transitive, it then follows that (x , z ) R. So mxz 1 and
M 2 M.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
15
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Def. 7.14 Directed Graphs G=(V,E) (Digraph)
Ex. 7.25
a loop
V={1,2,3,4,5}
2
E={(1,1),(1,2),(1,4),(3,2)}
1
4
3
1 is adjacent to 2.
2 is adjacent from 1.
5
isolated vertex (node)
Undirected graphs: no direction in edges
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
16
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Ex. 7.26
Construct a directed graph G=(V,E), where
(s1) b:=3;
V={s1, s2, s3, s4, s5, s6, s7, s8} and (si, sj) in E
(s2) c:=b+2; if si must be executed before sj.
(s3) a:=1;
s5
s7
(s4) d:=a*b+5;
precedence graph
(s5) e:=d-1;
(s6) f:=7;
s4
s2
s8
(s7) e:=c+d;
(s8) g:=b*f;
s
s
s
3
1
precedence constraint scheduling
3 processors: 3 time units
2 processors: 4 time units
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
6
In general, n tasks,
m processors: NP-complete
m=2: polynomial
m=3: open problem
17
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Ex. 7.27 relations and digraphs
A={1,2,3,4}, R={(1,1),(1,2),(2,3),(3,2),(3,3),(3,4),(4,2)}
2
2
1
1
3
4
directed graph
representation
3
4
associated
undirected graph
a connected graph: a path
exists between any two
vertices
path: no repeated vertex
cycle: a closed path (the
starting and ending vertices
are the same)
Def. 7.15 Strongly connected digraph
a directed path exists between any two vertices
The above graph is not strongly connected. (no directed path from 3 to 1)
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
18
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Ex. 7.28 Components
1
2
1
2
3
4
3
4
two components
one component
Ex. 7.29 Complete Graphs: Kn (n vertices with n(n-1)/2 edges)
K5
K1
K2
K3
K4
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
19
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
directed graphs
relations
adjacency matrices
relation matrices
Ex. 7.30 If R is a relation on finite set A, then R is reflexive if
and only if its directed graph contains a loop at each vertex.
Ex. 7.31 A relation R on a finite set A is symmetric if and only
if its directed graph contains only loops and undirected edges.
Ex. 7.31 A relation R on a finite set A is transitive if and only if in
its directed graph if there is a path from x to y, (x,y) is an edge.
A relation R on a finite set A is antisymmetric if and only if in
its directed graph there are no undirected edges aside from loops.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
20
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Ex. 7.33 A relation on a finite set A is an equivalence relation
if and only if its associated (undirected) graph is one complete
graph augmented by loops at every vertex or consists of the
disjoint union of complete graphs augmented by loops at every
vertex.
reflexive: loop on each vertex
symmetric: undirected edge
transitive: disjoint union of complete graphs
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
21
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
natural counting: N
x+5=2
:Z
2x+3=4
:Q
x2-2=0
:R
x2+1=0
:C
Something was lost when we went
from R to C. We have lost the ability
to "order" the elements in C.
Let A be a set with R a relation on A. The pair (A,R) is called
a partially ordered set, or poset, if relation R is a partial order.
Ex. 7.34 Let A be the courses offered at a college. Define R on A
by xRy if x,y are the same course (reflexive) or if x is a prerequisite
for y. Then R makes A into a poset.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
22
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Ex. 7.36 PERT (Performance Evaluation and Review Technique)
A poset
J3
J4
J1
J6
J2
J7
J5
Find each job's earliest start time and latest start time.
Those jobs which earliness equals to lateness are critical.
All critical jobs form a critical path.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
23
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
not partial order
1
2
not antisymmetric
Ex. 7.37 Hasse diagram
a partial
order
3
1
not transitive or not antisymmetric
4
2
2
4
3
1
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
2
Read bottom up.
reflexivity and
transitive links
3 are not shown.
1
corresponding Hasse diagram
24
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Ex. 7.38
{1,2,3}
equality
relation
8
{1,2}
{1,3}
385
12
{2,3}
6 35
4
{1}
{2}
{3}
subset relation
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
2
2
3
5
7
2 3 5 7 11
1
exactly division relation
25
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Def. 7.16 If (A,R) is a poset, we say that A is totally ordered if
for all x,y in A either xRy or yRx. In this case R is called a total
order.
For example, <,> are total order for N,Z,Q,R. But partially
ordered in C.
But can we list the elements for a partially ordered set in
some way?
sorting for a totally ordered set
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
26
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
topological sorting for a partially ordered set
G
F
D
How to execute the tasks one at a time
such that the partial order is not violated?
C
A
B
For example, BEACGFD, EBACFGD, ...
E
Hasse diagram for
a set of tasks
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
27
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
topological sorting sequence (linear extension)
d
c
a^bc^d: 2 jumps
a
b
Find a linear extension
with minimum jumps.
a^bd^c: 2 jumps
(an NP-complete problem)
b^ac^d: 2 jumps
b^a^d^c: 3 jumps
bd^ ac: 1 jumps
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
28
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Def. 7.17 If ( A, R) is a poset, then an element of x A is called
a max imal element of A if for all a A, a x ( x , a ) R.
( xRa x = a ) An element y A is called a minimal element of
A if whenever b A and b y , then (b, y ) R (bRy b = y ).
Ex 7.42 With R the "less than or equal to" relation on the set Z,
(Z, ) is a poset with neither a maximal nor a minimal element.
The poset (N, ), however, has a minimal element 0 but no
maximal element.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
29
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Ex.7.43
{1,2,3}max
max
385
8 max
{1,2}
{1,3}
12
{2,3}
max and min
4
{1}
{2}
{3}
min
2
2
1 min
3
5
6
35
7
2 3 5 7 11
min
unique max and min
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
30
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Theorem 7.3 If ( A, R) is a poset and A is finite, then A has both
a maximal and a minimal element.
Proof: Let a1 A. If there is no element a A where a a1 and
a1 Ra , then a1 is maximal. Otherwise there is an element a 2 A
with a 2 a1 and a1 Ra 2 . If no element a A, a a 2 , satisfies
a 2 Ra , then a 2 is maximal. Otherwise we can find a 3 A so that
a 3 a 2 , a 3 a1 while a1 Ra 2 and a 2 Ra 3. Continuing in this
manner, since A is finite, we get to an element a n A with
(a n , a ) R for any a A where a a n , so a n is maximal.
The proof for minimal element is similar.
In topological sorting, each time we find a maximal element,
or each time we find a minimal element.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
31
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Def 7.18 If ( A, R) is a poset, then an element x A is called
a least element if xRa for all a A. Element y A is called a
greatest element if aRy for all a A.
Ex. 7.44 Let U = {1,2,3} and R be the subset relation.
(a) With A = P(U ), the poset ( A, ) has as a least element
and U as a greatest element.
(b) For B = the collection of nonempty subsets of U , the
poset ( B, ) has U as a greatest element. There is no least
element.
(c) For C = the collection of proper subsets of U , the
poset ( C, ) has as a least element. There is no greatest
element
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
32
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Theorem 7.4 If the poset (A,R) has a greatest (least) element,
then that element is unique.
Proof: Suppose that x,y in A and that both are greatest elements.
Then (x,y) and (y,x) are both in R. As R is antisymmetric, it
follows that x=y. The proof for the least element is similar.
Def. 7.19 Let ( A, R) be a poset with B A. An element x A is
called a lower( upper) bound for B if xRb(bRx ) for all b B.
An element x ' A is called a greatest lower bound , glb, (least
upper bound , lub) if it is a lower bound (upper bound) of B and
for all other lower bounds (upper bounds) x " of B we have
x "Rx ' ( x ' Rx ").
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
33
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Ex. 7.46 Let U={1,2,3,4}, with A=P(U), let R be the subset
relation on A. If B={{1},{2},{1,2}}, then {1,2}, {1,2,3},
{1,2,4}, and {1,2,3,4} are all upper bounds for B(in A),
whereas {1,2} is a least upper bound (in B). Meanwhile, a
greatest lower bound for B is the empty set, which is not in B.
Ex. 7.47 Let R be the "less than or equal to" relation for the poset
(A,R). (a) If A=R and B=[0,1] or [1,0) or (0,1] or (0,1), then B
has glb 0 and lub 1. (b) If A=R, B={q in Q|q2<2}. Then B has
2 as a lub and - 2 as glb, and neither of these is in B.
(c) A=Q, with B as in part (b). Here B has no lub or glb.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
34
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Theorem 7.5 If ( A, R) is a poset and B A, then B has at most
one lub (glb).
Def 7.20 The poset ( A, R) is called a lattice if for any x , y A
the element lub{x , y} and glb{x , y} both exist in A.
Ex. 7.48 For A = N and x , y N, define xRy by x y . Then
lub{x , y} = max{x , y}, glb{x , y} = min{x , y}, and (N, )
is a lattice.
Ex. 7.49 (P(U ), ) is a lattice with lub{S , T} = S T and
glb{S , T} = S T for S , T U .
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
35
Chapter 7 Relations: The Second Time Around
7.4 Equivalence Relations and Partitions
Def. 7.21 Given a set A and an index set I , let Ai A for
each i I . Then {Ai }i I is a partition of A if
(a) A = Ai and (b) Ai A j , for all i , j I where i j .
i I
Each subset Ai is called a cell or block of the partition.
Ex. 7.51 A = {1,2,3,4,5,6,7,8,9,10}, then each of the following
determines a partition of A:
(a) A1 {1,2,3,4,5}, A2 {6,7,8,9,10}
(b) A1 {1,2,3}, A2 {4,6,7,9}, A3 {5,8,10}
(c) Ai {i , i 5},1 i 5.
Ex. 7.52 A = R, and for each i Z, let Ai [i , i 1). Then
{Ai }i Z is a partition of R.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
36
Chapter 7 Relations: The Second Time Around
7.4 Equivalence Relations and Partitions
Def. 7.22 Let R be an equivalence relation on a set A. For
any x A, the equivalence class of x , denoted x, is defined
by x {y A| yRx}.
Ex. 7.53 xRy if 4|(x - y ) for x , y Z. For this equivalence we
find that 0 { ,8,4,0,4,8,} {4k | k Z}
1 { ,7,31, ,5,9,} {4k 1| k Z}
2 { ,6,2,2,6,10,} {4k 2| k Z}
3 { ,5,1,3,7,11,} {4k 3| k Z}.
And { 0,1, 2, 3} provides a partition of Z.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
37
Chapter 7 Relations: The Second Time Around
7.4 Equivalence Relations and Partitions
Ex. 7.54 For a , b Z, aRb if a 2 b 2 . Then R is an equivelence
relation. What can we say about the corresponding partition of
Z? In general, forn any n Z + , n n { n, n}. Therefore,
Z = [n].
n= 0
Theorem 7.6 If R is an equivalence relation on a set A, and
x , y A, then (a) x [x ]; (b) xRy if and only if x y; and
(c) [x ] = [y ] or [x ] [y ] = .
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
38
Chapter 7 Relations: The Second Time Around
7.4 Equivalence Relations and Partitions
Ex. 7.58 If an equivalence relation R on A={1,2,3,4,5,6,7} induces
the partition A {1,2} {3} {4,5,7} {6} ? What is R?
R = ({1,2} {1,2}) ({3} {3}) {(4,5,7} {4,5,7})
({6} {6}), |R|= 2 2 12 32 12 15.
Theorem 7.7 If A is a set, then (a) any equivalence relation R on A
induces a partition of A, and (b) any partition of A gives rise to an
equivalence relation on A.
Theorem 7.8 For any set A, there is a one-to-one correspondence
between the set of equivalence relations on A and the set of
partitions of A.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
39
Chapter 7 Relations: The Second Time Around
7.4 Equivalence Relations and Partitions
Ex. 7.59 (a) If A = {1,2,3,4,5,6}, how many relations on A are
equivalence relations?
one - to - one correspondence between equivalence relations
and partitions
6
S (6, i ) 203
i 1
(b) How many of the equivalence relations satisfy 1,2 4.
4
1,2,4 are in the same partition. S (4, i ) 15.
i =1
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
40
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
Given s1,s2 in S, the relation 1-equivalence, which is denoted
by s1E1s2, is defined when w(s1,x)=w(s2,x) for all x in I. This
idea can be extended to states being k-equivalence, where
s1Eks2 if w(s1,y)=w(s2,y) for all y in Ik.
If two states are k-equivalent for all k in Z+, then they are called
equivalent, denoted by s1Es2. Hence our objective is to determine
the partition of S induced by the equivalence relation E and select
one state for each equivalence class.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
41
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
observations:
(1) If two states in a machine are not 2-equivalent, could they
possibly be 3-equivalent?
No. If s1 and s2 are not 2 - equivalent, then there exists xy in
I 2 such that w(s1 , xy ) w(s2 , xy ). So for any z I ,
w(s1 , xyz ) w(s1 , xy )w(v (s1 , xy ), z ) w(s2 , xy )w(v (s2 , xy ), z )
= w(s2 , xyz ).
In general, to find states that are (k+1)-equivalent, we look at
states that are k-equivalent.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
42
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
observations:
(b) Suppose s1 E 2 s2 . We wish to determine whether s1 E 3 s2 ?
That is does w( s1 , x1 x 2 x 3 ) w( s2 , x1 x 2 x 3 ) for all strings
x1 x 2 x 3 I 3 ? Because s1 E 2 s2 s1 E 1 s2 , w(s1 , x1 ) w( s2 , x1 ).
Consequently, w( s1 , x1 x 2 x 3 ) w( s2 , x1 x 2 x 3 ) if
w( v( s1 , x1 ), x 2 x 3 ) w( v( s2 , x1 ), x 2 x 3 ). That is, if
v( s1 , x1 ) E 2 v( s2 , x1 ).
In general, for s1 , s 2 S we have s1 E k +1 s2 if and only if
(i) s1 E k s2 and (ii) v( s1 , x ) E k v( s2 , x ) for all x I .
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
43
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
Ex. 7.60
step 1: determine 1-equivalent states by
v
w
examining outputs
0 1 0 1
P1: {s1},{s2, s5, s6},{ s3, s4}
s4 s3 0 1
A s1
s5 s2 1 0
B s2
input 0
s3
s2 s4 0 0
C
s5 s2 s1
s2 s5
s4
s5 s3 0 0
s5
s2 s5 1 0
P2: {s1},{s2, s5},{ s6},{ s3, s4}
s1 s6 1 0
D s6
input 1
s2 s5
s4 s3
P3=P2, the process is complete with 4 states.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
44
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
Could it be that P3=P2, but P3=P4?
Def. 7.23 If P1 , P2 are any partitions of a set A, then P2
is called a refinement of P1 , and we write P2 P1 , if every
cell of P2 is contained in a cell of P1 . When P2 P1 and
P2 P1 we write P2 P1 . This occurs when at least one cell
in P2 is properly contained in a cell in P1 .
In the minimization process, Pk +1 Pk because (k + 1) equivalence implies k - equivalence. So each successive
partition refines the preceding partition.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
45
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
Theorem 7.9 In applying the minimization process, if k 1
and Pk and Pk +1 are partitions with Pk +1 Pk , then Pr +1 Pr
for any r k + 1.
Proof: If not, let r ( k + 1) be the smallest subscript such that
Pr +1 Pr . Then Pr +1 Pr , so there exist s1 , s2 S with s1E r s2
but s1E r +1s2 . But s1E r s2 v (s1 , x )E r1v (s2 , x ) for all x I .
And with Pr Pr1 , we then find that v (s1 , x )E r v (s2 , x ) for
all x I . So s1E r +1s2 . Consequently, Pr +1 Pr .
If s1 s2 , there must be a smallest integer k 0 such that
s1E k s2 but s1E k 1s2 . That is, there is an x I k +1 such that
w(s1 , x ) w(s2 , x ). (but they will agree on the first k outputs)
x is called a distinguishing string for s1 and s2 .
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
46
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
How to find the minimal length distinguishing string?
Ex. 7.61
v
w
P1: {s1},{s2, s5, s6},{ s3, s4}
0 1 0 1 input 0
s1
s4 s3 0 1
s5 s2 s1
s2 s5
s2
s5 s2 1 0
s3
s2 s4 0 0
P2: {s1},{s2, s5},{ s6},{ s3, s4}
s4
s5 s3 0 0
input 1
s5
s2 s5 1 0
s6
s1 s6 1 0
s 2 s5
s4 s3
A distinguishing string for s2 and s6 is 00 (or 01).
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
47
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
Ex. 7.62
v
s1
s2
s3
s4
s5
0
s4
s5
s4
s3
s2
w
1
s2
s2
s2
s5
s3
0
0
0
0
0
0
P1: {s1 ,s3, s4},{s2, s5}
1
1
0
1
1
0
input 1
s2 s 2 s5
s2 s3
P2: {s1 ,s3, s4},{s2},{ s5}
input 1
s2 s2 s5
P3: {s1 ,s3},{ s4},{s2},{ s5}
distinguishing string for s1 and s4: 111
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
48
Chapter 7 Relations: The Second Time Around
Exercise: P318:10
P330:20
P340:26
P346:10
P356:14
Discrete Math by R.S. Chang, Dept. CSIE, NDHU
49
© Copyright 2026 Paperzz