Sei sulla pagina 1di 49

Discrete Math by R.S. Chang, Dept.

CSIE, NDHU 1
Chapter 7 Relations: The Second Time Around
Relations: The Second Time
Around
Chapter 7
Equivalence Classes
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 2
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 s
1
,s
2
in S, define s
1
Rs
2
if v(s
1
,x)=s
2
for some x in I.
Relation R establishes the first level of reachability.
(b) The second level of reachability. s
1
Rs
2
if v(s
1
,x
1
x
2
)=s
2

for some x
1
x
2
in I
2
. For the general reachability relation we
have v(s
1
,y)=s
2
for some y in I*.
(c) Given s
1
,s
2
in S, the relation 1-equivalence, which is denoted
by s
1
E
1
s
2
, is defined when w(s
1
,x)=w(s
2
,x) for all x in I. This
idea can be extended to states being k-equivalence, where
s
1
E
k
s
2
if w(s
1
,y)=w(s
2
,y) for all y in I
k
.
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 3
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 = {1,2,3,4}, a relation R will be reflexive
if and only if R {(1,1), (2,2), (3,3), (4,4)}. R = {( , )|
, , } is reflexive on .
Ex. 7.5 If | | = , | | = There are relations on .
How many of these are reflexive?
We must include {( The remaining pairs
can be either included or excluded from the relation. Therefore,
there are reflexive relations.
2
i
A A A
x y
x y A x y A
A n A A n A
a a a A n n
n
i i
n n
_
_
e s

.
, )| }.
2
2
2
2
2
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 4
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
Def. 7.3 Relation R on set is call symmetric if ( , ) R
( , ) R, for all , .
A x y
y x x y A
e
e e
Ex. 7.6 With A={1,2,3}, we have:
(a) R
1
={(1,2),(2,1),(1,3),(3,1)}, symmetric, but not reflexive;
(b) R
2
={(1,1),(2,2),(3,3),(2,3)}, reflexive, but not symmetric;
(c) R
3
={(1,1),(2,2),(3,3)}, R
4
={(1,1),(2,2),(3,3),(2,3),(3,2)},
both reflexive and symmetric;
(d) R
5
={(1,1),(2,3),(3,3)}, neither reflexive nor symmetric.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 5
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
To count the symmetric relations on = { write
as where and
contains
1
2
subsets of
the form {( Therefore, there are
symmetric relations on . And reflexive and
symmetric relations on .
Def. 7.4 For a set , a relation R on is called if for
all , , , ( ,
1
1 2
2
A a a a
A A A A A a a i n A
a a i j n i j A n n
a a a a
A
A
A A transitive
x y z A x y
n
i i
i j
i j j i
n
n n
n n
, , , },
, {( , | }
{( , )| , , }. ( )
, ), ( , )}.
( )
( )
2
1 2
2
1
2
1
2
1
1
2 2
2
2
2

= s s =
s s =

), ( , ) R ( , ) R. y z x z e e
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 6
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 R when
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 , R is called
if for all , , ( R and R ) = .
Ex. 7.11 the subset relation: R if , reflexive, transitive,
antisymmetric, but not symmetric.
Ex. 7.12 = {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.
a b
ab
A antisymmetric
a b A a b b a a b
A B A B
A
>
e
_
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 7
Chapter 7 Relations: The Second Time Around
7.1 Relations Revisited: Properties of Relations
To count the antisymmetric relations on = { write
as where and
contains
1
2
subsets of
the form {( There are 3 choices for this kind of
subsets: select one or none of them. Therefore, there are
antisymmetric relations on . And
reflexive and antisymmetric relations on .
1
1 2
2
A a a a
A A A A A a a i n A
a a i j n i j A n n
a a a a
A
A
n
i i
i j
i j j i
n
n n n n
, , , },
, {( , | }
{( , )| , , }. ( )
, ), ( , )}.
( ) ( )
2
1 2
2
1
2
1
2
1
1
2 3 3
2 2

= s s =
s s =


Discrete Math by R.S. Chang, Dept. CSIE, NDHU 8
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: , , , , s > _ _
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 {(a
i
,a
i
)|a
i
in A} is both a partial order and
an equivalence relation.
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.8 If , , and are sets with R and R
then the composite relation R R is a relation from to
defined by R R and there are exists
with ( , ) R R
1 2
1 2
1 2
1 2
A B C A B B C
A C
x z x A z C
y B x y y z
_ _
= e e
e e e
,
{( , )| , ,
, ( , ) }.

(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
R
1
={(1,x),(2,x),(3,y),(3,z)}, a relation from A to B, and R
2
=
{(w,5),(x,6)}, a relation from B to C. Then R
1
R
2
={(1,6),(2,6)}
is a relation from A to C.

Theorem 7.1 Let A, B, C, and D be sets with R


R and R Then R R R
( R R R
1
2 3 1 2 3
1 2 3
_
_ _ =
A B
B C C D
,
, . ( )
) .


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
Def. 7.9 Given a set and a relation R on , we define the
R recursively by (a) R R; and (b) for Z R
R R
Ex. 7.19 If ={1,2,3,4} and R ={(1,2), (1,3), (2,4), (3,2)}, then
R R and for 4, R
Def. 7.10 - (Use boolean operation, 1 +1 =1)
Ex. 7.20
1
is a 3 4 (0,1) - matrix.
1 + +1
2 3
A A power
of n
A
n
zero one matrix
n
n
n
= e =
= = > =

(
(
(

,
.
{( , ), ( , ), ( , )}, {( , )}, .

1 4 1 2 3 4 1 4
0 0 1
0 1 0 1
1 0 0 0
|
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 11
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}.
R
1
={(1,x),(2,x),(3,y),(3,z)}, a relation from A to B, and R
2
=
{(w,5),(x,6)}, a relation from B to C.
relation matrix
M M
w
x
y
z
w x y z
M M M
( ) , ( )
( ) ( ) (
R R
5 6 7
R R R
1 2
1 2
=

(
(
(
(
=

(
(
(
(
=

(
(
(
(

(
(
(
(
=

(
(
(
(
=
1
2
3
4
0 1 0 0
0 1 0 0
0 0 1 1
0 0 0 0
1 0 0
0 1 0
0 0 0
0 0 0
0 1 0 0
0 1 0 0
0 0 1 1
0 0 0 0
1 0 0
0 1 0
0 0 0
0 0 0
0 1 0
0 1 0
0 0 0
0 0 0
1 2)
R
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
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(R
m
)=[M(R)}
m
, for m in Z
+
.

Def. 7.11 Let = ( , = ( be two (0,1) -


matrices. We say that precedes, or is less than, , and we
write , if for all , .
Ex. 7.23 With =
1
0
0
0
1
1
and =
1
0
0
1
1
1
we have .
In fact, there are eight (0,1) - matrices for which .
E e F f m n
E F
E F e f i m j n
E F E F
G E G
ij m n ij m n
ij ij
) )
,
,


s s s s s s

(
s
s
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
Def. 7.12 For Z is the (0,1) - matrix
where
if =
if
Def 7.13 Let = ( be a (0,1) - matrix. The transpose of
, written , is the matrix ( where
for all 1 , .
Ex. 7.24 =
+
ij
tr * *
tr
n I n n
i j
i j
A a
A A a a a
i m j n
A A
n ij n n
ij m n
ji n m ji ij
e =
=
=

=
s s s s

(
(
(
=

, ( )
,
,
)
) ,
, .
o
o
1
0
1
0 1
0 0
1 1
0
1
0
0
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
Theorem 7.2 Given a set with | | = , and a relation R on ,
let denote the relation matrix for R. Then
(a) R is reflexive if and only if
(b) R is symmetric if and only if =
(c) R is transitive if and only if =
(d) R is antisymmetric if and only if
tr
2
tr
A A n A
M
I M
M M
M M M M
M M I
n
n
s
s
s
= = = =
.
.
.
.
( , ) 0 0 0 1 1 0 01 1 1
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 15
Chapter 7 Relations: The Second Time Around
Proof of (c) Let If ( , ), ( , ) R,
1 1 1 Hence ( , ) R.
Conversely, if R is transitive and is the relation matrix for R,
let be the entry in row and column of with
For to be 1 in there must exist at least one where
in . This happens only if ( , ), ( , ) R. With
R transitive, it then follows that ( , ) R.
2
2
2
M M x y y z
M x z
M
s x z M s
s M y A
m m M x y y z
x z
xy yz xz
xz xz
xz
xy yz
s e

(
(
(

(
(
(
=

(
(
(
s e
=
e
= = e
e
.
.
, .
,

1
1
So and
2
m
M M
xz
=
s
1
.
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
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
Def. 7.14 Directed Graphs G=(V,E) (Digraph)
Ex. 7.25
1
2
4 3 5
isolated vertex (node)
a loop
V={1,2,3,4,5}
E={(1,1),(1,2),(1,4),(3,2)}
1 is adjacent to 2.
2 is adjacent from 1.
Undirected graphs: no direction in edges
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 17
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Ex. 7.26
(s
1
) b:=3;
(s
2
) c:=b+2;
(s
3
) a:=1;
(s
4
) d:=a*b+5;
(s
5
) e:=d-1;
(s
6
) f:=7;
(s
7
) e:=c+d;
(s
8
) g:=b*f;
Construct a directed graph G=(V,E), where
V={s
1
, s
2
, s
3
, s
4
, s
5
, s
6
, s
7
, s
8
} and (s
i
, s
j
) in E
if s
i
must be executed before s
j
.
s
3
s
1
s
6
s
4
s
2
s
8
s
5
s
7
precedence graph
precedence constraint scheduling
3 processors: 3 time units
2 processors: 4 time units
In general, n tasks,
m processors: NP-complete
m=2: polynomial
m=3: open problem
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.27 relations and digraphs
A={1,2,3,4}, R={(1,1),(1,2),(2,3),(3,2),(3,3),(3,4),(4,2)}
1
2
3
4
directed graph
representation
1
2
3
4
associated
undirected graph
a connected graph: a path
exists between any two
vertices
cycle: a closed path (the
starting and ending vertices
are the same)
path: no repeated vertex
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 19
Chapter 7 Relations: The Second Time Around
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Ex. 7.28 Components
1
2
3 4
two components
1
2
3 4
one component
Ex. 7.29 Complete Graphs: K
n
K
1
K
2
K
3 K
4
K
5
(n vertices with n(n-1)/2 edges)
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
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 21
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 22
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
natural counting: N
x+5=2 : Z
2x+3=4 : Q
x
2
-2=0 : R
x
2
+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 23
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Ex. 7.36 PERT (Performance Evaluation and Review Technique)
J
1
J
6
J
3
J
2
J
5
J
4
J
7
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.
A poset
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 24
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
not partial order
1 2
1
2
3
not antisymmetric not transitive or not antisymmetric
Ex. 7.37 Hasse diagram
1
2 3
4
1
2 3
4
a partial
order
corresponding Hasse diagram
Read bottom up.
reflexivity and
transitive links
are not shown.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 25
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Ex. 7.38
{1,2,3}
{1,2} {1,3} {2,3}
{1} {2} {3}
|
subset relation
exactly division relation
1
2
4
8
2 3 5 7
2 3 5 7 11
6
12
385
35
equality
relation
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 26
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 27
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
topological sorting for a partially ordered set
A
C
B E
G
F
D
Hasse diagram for
a set of tasks
How to execute the tasks one at a time
such that the partial order is not violated?
For example, BEACGFD, EBACFGD, ...
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 28
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
topological sorting sequence (linear extension)
a
b
c
d
a^bc^d: 2 jumps

a^bd^c: 2 jumps

b^ac^d: 2 jumps

b^a^d^c: 3 jumps

bd^ ac: 1 jumps
Find a linear extension
with minimum jumps.
(an NP-complete problem)
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 29
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Def. 7.17 If ( , R) is a poset, then an element of is called
a of if for all , ( , ) R.
( R = ) An element is called a minimal element of
if whenever and , then ( , ) R ( R = ).
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.
A x A
imal element A a A a x x a
x a x a y A
A b A b y b y b y b y
e
e = e
e
e = e
s
s
max
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 30
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
{1,2} {1,3} {2,3}
{1} {2} {3}
|
1 min
2
4
8 max
2 3 5 7
2 3 5 7 11
6
12
385
35
Ex.7.43
{1,2,3}max
min
max and min
min
max
unique max and min
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 31
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Theorem 7.3 If ( , R) is a poset and is finite, then has both
a maximal and a minimal element.
Proof: Let . If there is no element where and
R , then is maximal. Otherwise there is an element
with and R If no element , satisfies
R , then is maximal. Otherwise we can find so that
while R and R Continuing in this
manner, since is finite, we get to an element with
( R for any where
1
1 1
1 2 2
2 2
3 1 2 2 3
A A A
a A a A a a
a a a a A
a a a a a A a a
a a a a A
a a a a a a a a
A a A
a a a A a a
n
n
1
2
2 1
3
3 2 1
e e =
e
= e =
e
= =
e
e e =
. ,
, .
, )
n n
a , so 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 32
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Def 7.18 If ( , R) is a poset, then an element is called
a element if R for all . Element is called a
element if R for all .
Ex. 7.44 Let = {1,2,3} and R be the subset relation.
(a) With = ( ), the poset ( , ) has as a least element
and as a greatest element.
(b) For = the collection of nonempty subsets of , the
poset ( , ) has as a greatest element. There is no least
element.
(c) For = the collection of proper subsets of , the
poset ( , ) has as a least element. There is no greatest
element
A x A
least x a a A y A
greatest a y a A
U
A P U A
U
B U
B U
C U
C
e
e e
e
_
_
_
|
|
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 33
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 ( , R) be a poset with . An element is
called a ( ) for if R ( R ) for all .
An element ' is called a , , (
, ) if it is a lower bound (upper bound) of and
for all other lower bounds (upper bounds) " of we have
"R ' ( ' R ").
A B A x A
lower upper bound B x b b x b B
x A greatest lower bound least
upper bound B
x B
x x x x
_ e
e
e glb
lub
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 34
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|q
2
<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 35
Chapter 7 Relations: The Second Time Around
7.3 Partial Orders: Hasse Diagrams
Theorem 7.5 If ( , R) is a poset and , then has at most
one lub (glb).
Def 7.20 The poset ( , R) is called a if for any ,
the element lub{ , } and glb{ , } both exist in .
Ex. 7.48 For = N and , N, define R by . Then
{ , } = { , }, { , } = { , }, and (N, )
is a lattice.
Ex. 7.49 ( ( ), ) is a lattice with lub{ , } = and
{ , } = for , .
A B A B
A lattice x y A
x y x y A
A x y x y x y
x y x y x y x y
P U S T S T
S T S T S T U
_
e
e s
s
_
_
lub max glb min
glb
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.21 Given a set and an index set , let for
each . Then { is a partition of if
(a) = and (b) for all , where .
Each subset is called a or of the partition.
Ex. 7.51 = {1,2,3,4,5,6,7,8,9,10}, then each of the following
determines a partition of :
(a)
b)
c)
1
1
A I A A
i I A A
A A A A i j I i j
A cell block
A
A
A A
A A A
A i i
i
i i I
i
i I
i j
i
i
|
|
= _
e
= e =
= =
= = =
= +
e
e
}
,
{ , , , , }, { , , , , }
( { , , }, { , , , }, { , , }
( { ,

12 34 5 6 7 8 910
12 3 4 6 7 9 5810
5
2
2 3
}, .
[ , ).
}
1 5
1
s s
e = +
e
i
A i A i i
A
i
i i
Ex. 7.52 = R, and for each Z, let Then
{ is a partition of R.
Z
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 37
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 . For
any , the equivalence class of , denoted is defined
by R
Ex. 7.53 R if 4| ( - ) for , Z. For this equivalence we
find that 0 Z
1 Z
2 Z
3
A
x A x x
x y A y x
x y x y x y
k k
k k
k k
e
= e
e
= = e
= = + e
= = + e
= =
,
{ | }.
{ , , , , , , } { | }
{ , , , , , , } { | }
{ , , , , , , } { | }
{ , , , , , , } {




8 4 0 4 8 4
7 3159 4 1
6 2 2 610 4 2
5 13711
| | | | | | | |
4 3
1 2 3
k k Z + e | }.
, , , } And { 0 provides a partition of Z.
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.54 For , Z, R if Then R is an equivelence
relation. What can we say about the corresponding partition of
Z? In general, forn any Z Therefore,
Z = [ ]
Theorem 7.6 If R is an equivalence relation on a set , and
, , then (a) [ ]; (b) R if and only if and
(c) [ ] =[ ] or [ ] [ ] = .
2
+
=
a b a b a b
n n n n n
n
A
x y A x x x y x y
x y x y
n
e =
e = =
e e =

2
0
.
, { , }.
.
;

|
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.58 If an equivalence relation R on A={1,2,3,4,5,6,7} induces
the partition ? What is R?
A = { , } { } { , , } { } 12 3 4 57 6
R = ({1,2} {1,2}) ({3} {3}) {(4,5,7} {4,5,7})
({6} {6}), | R| = 2
2

+ + + = 1 3 1 15
2 2 2
.
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 40
Chapter 7 Relations: The Second Time Around
7.4 Equivalence Relations and Partitions
| |
Ex. 7.59 (a) If = {1,2,3,4,5,6}, how many relations on are
equivalence relations?
one - to - one correspondence between equivalence relations
and partitions
( , )
(b) How many of the equivalence relations satisfy 1,2 4
1,2,4 are in the same partition. ( , )
=
A A
S i
S i
i
i


=
e


=
=
6 203
4 15
1
6
1
4
.
.
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
Given s
1
,s
2
in S, the relation 1-equivalence, which is denoted
by s
1
E
1
s
2
, is defined when w(s
1
,x)=w(s
2
,x) for all x in I. This
idea can be extended to states being k-equivalence, where
s
1
E
k
s
2
if w(s
1
,y)=w(s
2
,y) for all y in I
k
.

If two states are k-equivalent for all k in Z
+
, then they are called
equivalent, denoted by s
1
Es
2
. 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 42
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 and are not 2 - equivalent, then there exists in
such that ( , ) ( So for any ,
(
= (
1 2
2
s s xy
I w s xy w s xy z I
w s xyz w s xy w v s xy z w s xy w v s xy z
w s xyz
1 2
1 1 1 2 2
2
= e
= =
, ).
, ) ( , ) ( ( , ), ) ( , ) ( ( , ), )
, ).
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 43
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
observations:
(b) Suppose E We wish to determine whether E
That is does ( ( for all strings
Because E E w(s
Consequently, ( ( if
( ( ( ( That is, if
( E
In general, for s
2 1 3
2 1 1
2
s s s s
w s x x x w s x x x
x x x I s s s s x w s x
w s x x x w s x x x
w v s x x x w v s x x x
v s x v s x
1 2 2
1 1 2 3 2 1 2 3
1 2 3
3
1 2 1 2 1 2 1
1 1 2 3 2 1 2 3
1 1 2 3 2 1 2 3
1 1 2 1
. ?
, ) , )
? , , ) ( , ).
, ) , )
, ), ) , ), ).
, ) ( , ).
=
e =
=
=
1 2 1 +
1
, s we have E if and only if
(i) E and (ii) ( E for all .
e
e
S s s
s s v s x v s x x I
k
k k
1 2
2 1 2
, ) ( , )
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
s
1
s
4
s
3
0 1
s
2
s
5
s
2
1 0
s
3
s
2
s
4
0 0
s
4
s
5
s
3
0 0
s
5
s
2
s
5
1 0
s
6
s
1
s
6
1 0
Ex. 7.60
0 1 0 1
v w
step 1: determine 1-equivalent states by
examining outputs
P
1
: {s
1
},{s
2
,

s
5
,

s
6
},{

s
3
,

s
4
}
input 0
s
5
s
2
s
1
s
2
s
5
P
2
: {s
1
},{s
2
,

s
5
},{

s
6
},{

s
3
,

s
4
}
input 1
s
2
s
5


s
4
s
3
P
3
=P
2
, the process is complete with 4 states.
A
C
B
D
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
Could it be that P
3
=P
2
, but P
3
=P
4
?
Def. 7.23 If are any partitions of a set , then
is called a refinement of and we write if every
cell of is contained in a cell of When and
we write This occurs when at least one cell
in is properly contained in a cell in
In the minimization process, because ( +1) -
equivalence implies - equivalence. So each successive
partition refines the preceding partition.
2 2
1
2 1 2
2 2
2 1
+
P P A P
P P P
P P P P
P P P P
P P
P P k
k
k k
1
2 1
1
1 1
1
,
, ,
.
.
.
s
s
= <
s
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
Theorem 7.9 In applying the minimization process, if 1
and and are partitions with then
for any +1.
Proof: If not, let ( +1) be the smallest subscript such that
Then so there exist with E
but E But E E for all .
And with we then find that E for
all . So
+ + +
+ + 1
+ 1
k
P P P P P P
r k
r k
P P P P s s S s s
s s s s v s x v s x x I
P P v s x v s x
x I
k k k k r r
r r r r r
r r r
r r r
>
= =
>
>
= < e
e
=
e

1 1 1
1 1 1 2 2
1 1 2 2 1 1 2
1 1 2
,
. , ,
. ( , ) ( , )
, ( , ) ( , )
s s P P
r r r 1 + +
E Consequently,
1 2 1
.
.
=
If there must be a smallest integer 0 such that
E but E That is, there is an such that
( (but they will agree on the first outputs)
is called a for and
1
1 1
+
1 2
s s k
s s s s x I
w s x w s x k
x distinguishing string s s
k k
k
= >
e
=
+
2
2 1 2
1
1 2
,
.
, ) ( , ).
.
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
How to find the minimal length distinguishing string?
s
1
s
4
s
3
0 1
s
2
s
5
s
2
1 0
s
3
s
2
s
4
0 0
s
4
s
5
s
3
0 0
s
5
s
2
s
5
1 0
s
6
s
1
s
6
1 0
0 1 0 1
v w
Ex. 7.61
P
1
: {s
1
},{s
2
,

s
5
,

s
6
},{

s
3
,

s
4
}
input 0
s
5
s
2
s
1
s
2
s
5
P
2
: {s
1
},{s
2
,

s
5
},{

s
6
},{

s
3
,

s
4
}
input 1
s
2
s
5


s
4
s
3
A distinguishing string for s
2
and s
6
is 00 (or 01).
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 48
Chapter 7 Relations: The Second Time Around
7.5 Finite State Machines: The Minimization Process
s
1
s
4
s
2
0 1
s
2
s
5
s
2
0 0
s
3
s
4
s
2
0 1
s
4
s
3
s
5
0 1
s
5
s
2
s
3
0 0
0 1 0 1
v w P
1
: {s
1
,s
3
,

s
4
},{s
2
,

s
5
}
input 1
s
2
s
2
s
5
s
2
s
3
input 1
s
2
s
2
s
5
Ex. 7.62
P
2
: {s
1
,s
3
,

s
4
},{s
2
},{

s
5
}
P
3
: {s
1
,s
3
},{

s
4
},{s
2
},{

s
5
}
distinguishing string for s
1
and

s
4
: 111
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 49
Chapter 7 Relations: The Second Time Around
Exercise: P318:10
P330:20
P340:26
P346:10
P356:14

Potrebbero piacerti anche