3.1 relations
TRANSCRIPT
-
7/28/2019 3.1 Relations
1/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
-
7/28/2019 3.1 Relations
2/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 2
Chapter 7 Relations: The Second Time Around7.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 s1R s2 if v( s1, x)= s2 for some x in I .
Relation R establishes the first level of reachability .(b) The second level of reachability . s1R s2 if v( s1, x1 x2)= s2
for some x1 x2 in I 2. 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 s1E1 s2, is defined when w( s1, x)=w( s2, x) for all x in I . Thisidea can be extended to states being k-equivalence , where
s1Ek s2 if w( s1, y)=w( s2, y) for all y in I k .If two states are k -equivalent for all k in Z +, then they are calledequivalent .
-
7/28/2019 3.1 Relations
3/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 3
Chapter 7 Relations: The Second Time Around7.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 reflexiveif 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 pairscan 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
.
, )| }.
2
2
2
2
2
-
7/28/2019 3.1 Relations
4/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 4
Chapter 7 Relations: The Second Time Around7.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
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.
-
7/28/2019 3.1 Relations
5/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 5
Chapter 7 Relations: The Second Time Around7.1 Relations Revisited: Properties of Relations
To count the symmetric relations on = { writeas where and
contains12
subsets of
the form {( Therefore, there are
symmetric relations on . And reflexive andsymmetric relations on .
Def. 7.4 For a set , a relation R on is called if for all , , , ( ,
11 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
ni i
i j
i j j i nn n
n n
, , , },, {( , | }
{( , )| , , }. ( )
, ), ( , )}.( )
( )
21 2
2
1
212
1
1
2 2
2
2
2
), ( , ) R ( , ) R. y z x z
-
7/28/2019 3.1 Relations
6/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 6
Chapter 7 Relations: The Second Time Around7.1 Relations Revisited: Properties of Relations
Ex. 7.8 Define the relation R on the set Z + by aR b if a exactlydivides 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 when0. 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 calledif 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 symmetricnor antisymmetric. R = {(1,1), (2,2)} is both symmetric andantisymmetric.
a bab
A antisymmetrica b A a b b a a b
A B A B
A
-
7/28/2019 3.1 Relations
7/49Discrete Math by R.S. Chang, Dept. CSIE, NDHU 7
Chapter 7 Relations: The Second Time Around7.1 Relations Revisited: Properties of Relations
To count the antisymmetric relations on = { writeas where and
contains12
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 . Andreflexive and antisymmetric relations on .
11 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
ni i
i j
i j j i
n n n n n
, , , },, {( , | }
{( , )| , , }. ( )
, ), ( , )}.
( ) ( )
21 2
2
12
12
1
1
2 3 32 2
-
7/28/2019 3.1 Relations
8/49Discrete Math by R.S. Chang, Dept. CSIE, NDHU 8
Chapter 7 Relations: The Second Time Around7.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, andtransitive. (It is called a total order if for any a ,b in A, either a R b or bR a).
Examples of partial order: , , , ,
Ex. 7.15. Define the relation R on the set Z + by aR b if a exactlydivides 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: aR b if a mod n=b mod n
The equality relation {(a i,a i)|a i in A} is both a partial order andan equivalence relation.
-
7/28/2019 3.1 Relations
9/49Discrete Math by R.S. Chang, Dept. CSIE, NDHU 9
Chapter 7 Relations: The Second Time Around7.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 todefined by R R and there are exists
with ( , ) R R
1 21 2
1 21 2
A B C A B B C A C x z x A z C
y B x y y z
,
{( , )| , ,, ( , ) }.
(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
12 3 1 2 3
1 2 3
A B B C C D
,, . ( )
) .
-
7/28/2019 3.1 Relations
10/49Discrete Math by R.S. Chang, Dept. CSIE, NDHU 10
Chapter 7 Relations: The Second Time Around7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Def. 7.9 Given a set and a relation R on , we define theR 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)}, thenR 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
An
zero one matrix
n
n
n
,.
{( , ), ( , ), ( , )}, {( , )}, .1 4 1 2 3 4 1 4
0 0 1
0 1 0 11 0 0 0
-
7/28/2019 3.1 Relations
11/49Discrete Math by R.S. Chang, Dept. CSIE, NDHU 11
Chapter 7 Relations: The Second Time Around7.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
23
4
0 1 0 0
0 1 0 00 0 1 1
0 0 0 0
1 0 0
0 1 00 0 0
0 0 0
0 1 0 00 1 0 0
0 0 1 1
0 0 0 0
1 0 00 1 0
0 0 0
0 0 0
0 1 00 1 0
0 0 0
0 0 0
1 2)R
-
7/28/2019 3.1 Relations
12/49Discrete Math by R.S. Chang, Dept. CSIE, NDHU 12
Chapter 7 Relations: The Second Time Around7.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 therelation 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 = ( , = ( be two (0,1) -matrices. We say that precedes, or is less than, , and wewrite , if for all , .
Ex. 7.23 With = 10
00
11
and = 10
01
11
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
) )
,
,
1 1
-
7/28/2019 3.1 Relations
13/49Discrete Math by R.S. Chang, Dept. CSIE, NDHU 13
Chapter 7 Relations: The Second Time Around7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Def. 7.12 For Z is the (0,1) - matrix
whereif =
if Def 7.13 Let = ( be a (0,1) - matrix. The transpose of
, written , is the matrix ( wherefor all 1 , .
Ex. 7.24 =
+
ij
tr * *
tr
n I n ni j
i j A a
A A a a ai m j n
A A
n ij n n
ij m n
ji n m ji ij
, ( ),
,)
) ,
, .
1
0
10 1
0 01 1
0
1
0
0
1
1
-
7/28/2019 3.1 Relations
14/49Discrete Math by R.S. Chang, Dept. CSIE, NDHU 14
Chapter 7 Relations: The Second Time Around7.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
.
.
.
.( , )0 0 0 1 1 0 0 1 1 1
-
7/28/2019 3.1 Relations
15/49
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. WithR 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
.
.
, .
,
1
1 So and2
m
M M xz 1
.
7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
-
7/28/2019 3.1 Relations
16/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 16
Chapter 7 Relations: The Second Time Around7.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 5isolated 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
-
7/28/2019 3.1 Relations
17/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 17
Chapter 7 Relations: The Second Time Around7.2 Computer Recognition: Zero-One Matrices and Directed Graphs
Ex. 7.26
( s1) b:=3;( s2) c:=b+2;( s3) a :=1;( s4) d :=a*b+5;( s5) e:=d -1;( s6) f :=7;( s7) e:=c+d ;( s8) g :=b* f ;
Construct a directed graph G=(V , E ), whereV ={ s1, s2, s3, s4, s5, s6, s7, s8} and ( s i, s j) in E if s i must be executed before s j.
s3
s1
s6
s4 s2 s8
s5 s7
precedence graph
precedence constraint scheduling3 processors: 3 time units2 processors: 4 time units
In general, n tasks,m processors: NP-completem=2: polynomialm=3: open problem
-
7/28/2019 3.1 Relations
18/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 18
Chapter 7 Relations: The Second Time Around7.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
34
directed graphrepresentation
1
2
34
associatedundirected graph
a connected graph : a path exists between any two
vertices
cycle : a closed path (thestarting and ending vertices
are the same)
path : no repeated vertex
Def. 7.15 Strongly connected digrapha directed path exists between any two vertices
The above graph is not strongly connected. (no directed path from 3 to 1)
-
7/28/2019 3.1 Relations
19/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 19
Chapter 7 Relations: The Second Time Around7.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 nK
1K
2K
3 K 4K
5
(n vertices with n(n-1)/2 edges)
-
7/28/2019 3.1 Relations
20/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 20
Chapter 7 Relations: The Second Time Around7.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 onlyif 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 inits 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 inits directed graph there are no undirected edges aside from loops.
-
7/28/2019 3.1 Relations
21/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 21
Chapter 7 Relations: The Second Time Around7.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 completegraph augmented by loops at every vertex or consists of thedisjoint union of complete graphs augmented by loops at everyvertex.
reflexive: loop on each vertexsymmetric: undirected edgetransitive: disjoint union of complete graphs
-
7/28/2019 3.1 Relations
22/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 22
Chapter 7 Relations: The Second Time Around7.3 Partial Orders: Hasse Diagrams
natural counting: N x+5=2 : Z 2 x+3=4 : Q
x2-2=0 : R x2+1=0 : C
Something was lost when we wentfrom R to C . We have lost the abilityto "order" the elements in C .
Let A be a set with R a relation on A. The pair ( A,R) is calleda 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 xR y if x, y are the same course (reflexive) or if x is a prerequisitefor y. Then R makes A into a poset.
-
7/28/2019 3.1 Relations
23/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 23
Chapter 7 Relations: The Second Time Around7.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
-
7/28/2019 3.1 Relations
24/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 24
Chapter 7 Relations: The Second Time Around7.3 Partial Orders: Hasse Diagrams
not partial order
1 21
2
3
not antisymmetric not transitive or not antisymmetric
Ex. 7.37 Hasse diagram
1
2 3
4
1
2 3
4
a partialorder
corresponding Hasse diagram
Read bottom up .reflexivity andtransitive links
are not shown.
-
7/28/2019 3.1 Relations
25/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 25
Chapter 7 Relations: The Second Time Around7.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 72 3 5 7 11
6
12385
35
equalityrelation
-
7/28/2019 3.1 Relations
26/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 26
Chapter 7 Relations: The Second Time Around7.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 xR y or yR x. In this case R is called a total order .
For example, are total order for N,Z,Q,R. But partiallyordered in C.
But can we list the elements for a partially ordered set insome way?
sorting for a totally ordered set
-
7/28/2019 3.1 Relations
27/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 27
Chapter 7 Relations: The Second Time Around7.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 timesuch that the partial order is not violated?
For example, BEACGFD, EBACFGD, ...
-
7/28/2019 3.1 Relations
28/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 28
Chapter 7 Relations: The Second Time Around7.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 extensionwith minimum jumps.
(an NP-complete problem)
-
7/28/2019 3.1 Relations
29/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 29
Chapter 7 Relations: The Second Time Around7.3 Partial Orders: Hasse Diagrams
Def. 7.17 If ( , R) is a poset, then an element of is calleda 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 nomaximal element.
A x Aimal 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
max
-
7/28/2019 3.1 Relations
30/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 30
Chapter 7 Relations: The Second Time Around7.3 Partial Orders: Hasse Diagrams
{1,2} {1,3} {2,3}
{1} {2} {3}
1 min
2
4
8 max
2 3 5 72 3 5 7 11
6
12385
35
Ex.7.43{1,2,3}max
min
max and min
min
max
unique max and min
-
7/28/2019 3.1 Relations
31/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 31
Chapter 7 Relations: The Second Time Around7.3 Partial Orders: Hasse Diagrams
Theorem 7.3 If ( , R) is a poset and is finite, then has botha maximal and a minimal element.Proof: Let . If there is no element where and
R , then is maximal. Otherwise there is an elementwith and R If no element , satisfies
R , then is maximal. Otherwise we can find so thatwhile R and R Continuing in this
manner, since is finite, we get to an element with( R for any where
11 1
1 2 22 2
3 1 2 2 3
A A A
a A a A a aa a a a A
a a a a a A a aa a a a Aa a a a a a a a
A a Aa a a A a a
nn
12
2 13
3 2 1
. ,
, .
, ) n na, 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.
-
7/28/2019 3.1 Relations
32/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 32
Chapter 7 Relations: The Second Time Around7.3 Partial Orders: Hasse Diagrams
Def 7.18 If ( , R) is a poset, then an element is calleda element if R for all . Element is called aelement 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 elementand as a greatest element.(b) For = the collection of nonempty subsets of , the poset ( , ) has as a greatest element. There is no leastelement.
(c) For = the collection of proper subsets of , the poset ( , ) has as a least element. There is no greatestelement
A x Aleast x a a A y A greatest a y a A
U
A P U AU B U
B U
C U C
-
7/28/2019 3.1 Relations
33/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 33
Chapter 7 Relations: The Second Time Around7.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, itfollows that x= y. The proof for the least element is similar.
Def. 7.19 Let ( , R) be a poset with . An element iscalled a ( ) for if R ( R ) for all .An element ' is called a , , (
, ) if it is a lower bound (upper bound) of andfor all other lower bounds (upper bounds) " of we have
"R ' ( 'R ").
A B A x Alower upper bound B x b b x b B
x A greatest lower bound least upper bound B
x B x x x x
glblub
-
7/28/2019 3.1 Relations
34/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 34
Chapter 7 Relations: The Second Time Around7.3 Partial Orders: Hasse Diagrams
Ex. 7.46 Let U ={1,2,3,4}, with A=P( U ), let R be the subsetrelation 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, agreatest 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 Bhas glb 0 and lub 1. (b) If A=R , B={q in Q |q2
-
7/28/2019 3.1 Relations
35/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 35
Chapter 7 Relations: The Second Time Around7.3 Partial Orders: Hasse Diagrams
Theorem 7.5 If ( ,R) is a poset and , then has at mostone 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
lub max glb min
glb
-
7/28/2019 3.1 Relations
36/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 36
Chapter 7 Relations: The Second Time Around7.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 followingdetermines a partition of :(a) b)c)
11
A I A Ai 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
ii i I
ii I
i j
i
i
},
{ , , , , }, { , , , , }( { , , }, { , , , }, { , , }( { ,
1 2 3 4 5 6 7 8 9 101 2 3 4 6 7 9 5 8 10
5
22 3
}, .
[ , ).}
1 5
1
i
A i A i i A
ii i
Ex. 7.52 = R, and for each Z, let Then{ is a partition of R.Z
-
7/28/2019 3.1 Relations
37/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 37
Chapter 7 Relations: The Second Time Around7.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 wefind that 0 Z
1 Z2 Z3
A x A x x x y A y x
x y x y x yk k
k k k k
,{ | }.
{ , , , , , , } { | }{ , , , , , , } { | }{ , , , , , , } { | }{ , , , , , , } {
8 4 0 4 8 47 31 5 9 4 16 2 2 6 10 4 25 1 3 7 11
4 3
1 2 3k k Z | }.
, , , }And { 0 provides a partition of Z.
-
7/28/2019 3.1 Relations
38/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 38
Chapter 7 Relations: The Second Time Around7.4 Equivalence Relations and Partitions
Ex. 7.54 For , Z, R if Then R is an equivelencerelation. 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
2
0
.
, { , }.
.
;
-
7/28/2019 3.1 Relations
39/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 39
Chapter 7 Relations: The Second Time Around7.4 Equivalence Relations and Partitions
Ex. 7.58 If an equivalence relation R on A={1,2,3,4,5,6,7} inducesthe partition ? What is R? A { , } { } { , , } { }1 2 3 4 5 7 6R = ({1,2} {1,2}) ({3} {3}) {(4,5,7} {4,5,7})
({6} {6}), |R|= 2 2
1 3 1 152 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 anequivalence 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.
-
7/28/2019 3.1 Relations
40/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 40
Chapter 7 Relations: The Second Time Around7.4 Equivalence Relations and Partitions
Ex. 7.59 (a) If = {1,2,3,4,5,6}, how many relations on areequivalence relations?one - to - one correspondence between equivalence relationsand 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
6 203
4 15
1
6
1
4.
.
-
7/28/2019 3.1 Relations
41/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 41
Chapter 7 Relations: The Second Time Around7.5 Finite State Machines: The Minimization Process
Given s1, s2 in S , the relation 1-equivalence , which is denoted by s1E1 s2, is defined when w( s1, x)=w( s2, x) for all x in I . Thisidea can be extended to states being k-equivalence , where
s1Ek s2 if w( s1, y)=w( s2, y) for all y in I k .
If two states are k -equivalent for all k in Z +, then they are calledequivalent , denoted by s1E s2. Hence our objective is to determinethe partition of S induced by the equivalence relation E and select one state for each equivalence class .
h l h d d
-
7/28/2019 3.1 Relations
42/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 42
Chapter 7 Relations: The Second Time Around7.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 22 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 21 1 1 2 2
2
, )., ) ( , ) ( ( , ), ) ( , ) ( ( , ), )
, ).
In general, to find states that are ( k +1)-equivalent, we look atstates that are k -equivalent.
Ch 7 R l i Th S d Ti A d
-
7/28/2019 3.1 Relations
43/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 43
Chapter 7 Relations: The Second Time Around7.5 Finite State Machines: The Minimization Process
observations:(b) Suppose E We wish to determine whether EThat is does ( ( for all strings
Because E E w(sConsequently, ( ( if
( ( ( ( That is, if ( E
In general, for s
2 1 3
2 1 1
2
s s s sw s x x x w s x x x
x x x I s s s s x w s xw s x x x w s x x x
w v s x x x w v s x x xv s x v s x
1 2 21 1 2 3 2 1 2 3
1 2 33
1 2 1 2 1 2 1
1 1 2 3 2 1 2 31 1 2 3 2 1 2 31 1 2 1
. ?, ) , )
? , , ) ( , )., ) , )
, ), ) , ), )., ) ( , ).
1 2 1 +1
, s we have E if and only if (i) E and (ii) ( E for all .
S s s s s v s x v s x x I
k k k
1 22 1 2, ) ( , )
Ch 7 R l i Th S d Ti A d
-
7/28/2019 3.1 Relations
44/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 44
Chapter 7 Relations: The Second Time Around7.5 Finite State Machines: The Minimization Process
s1 s4 s3 0 1 s2 s5 s2 1 0 s3 s2 s4 0 0 s4 s5 s3 0 0 s5 s2 s5 1 0 s6 s1 s6 1 0
Ex. 7.60
0 1 0 1v w step 1: determine 1-equivalent states byexamining outputs
P 1: { s1},{ s2, s5, s6},{ s3, s4}
input 0
s5 s2 s1 s2 s5
P 2: { s1},{ s2, s5},{ s6},{ s3, s4}
input 1 s2 s5 s4 s3
P 3= P 2, the process is complete with 4 states.
A
C
B
D
Ch 7 R l i Th S d Ti A d
-
7/28/2019 3.1 Relations
45/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 45
Chapter 7 Relations: The Second Time Around7.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 , thenis called a refinement of and we write if everycell of is contained in a cell of When and
we write This occurs when at least one cellin 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 21
2 1 22 22 1
+
P P A P P P P
P P P P P P P P
P P
P P k k
k k
12 1
11 1
1
,, ,
..
.
Ch 7 R l i Th S d Ti A d
-
7/28/2019 3.1 Relations
46/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 46
Chapter 7 Relations: The Second Time Around7.5 Finite State Machines: The Minimization Process
Theorem 7.9 In applying the minimization process, if 1and and are partitions with thenfor 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
1 1 1
1 1 1 2 2
1 1 2 2 1 1 21 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
22 1 2
1
1 2
,
., ) ( , ).
.
Ch t 7 R l ti Th S d Ti A d
-
7/28/2019 3.1 Relations
47/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 47
Chapter 7 Relations: The Second Time Around7.5 Finite State Machines: The Minimization Process
How to find the minimal length distinguishing string?
s1
s4
s3 0 1 s2 s5 s2 1 0
s3 s2 s4 0 0 s4 s5 s3 0 0s
5 s 2 s 5 1 0 s6 s1 s6 1 0
0 1 0 1v w
Ex. 7.61 P 1: { s1},{ s2, s5, s6},{ s3, s4}
input 0
s5 s2 s1 s2 s5
P 2: { s1},{ s2, s5},{ s6},{ s3, s4}
input 1
s2 s5 s4 s3
A distinguishing string for s2 and s6 is 00 (or 01).
Ch t 7 R l ti Th S d Ti A d
-
7/28/2019 3.1 Relations
48/49
Discrete Math by R.S. Chang, Dept. CSIE, NDHU 48
Chapter 7 Relations: The Second Time Around7.5 Finite State Machines: The Minimization Process
s1 s4 s2 0 1
s2 s5 s2 0 0 s3 s4 s2 0 1 s4 s3 s5 0 1 s5 s2 s3 0 0
0 1 0 1v w P 1: { s1 , s3, s4},{ s2, s5}
input 1 s2 s2 s5 s2 s3
input 1 s2 s2 s5
Ex. 7.62
P 2: { s1 , s3, s4},{ s2},{ s5}
P 3: { s1 , s3},{ s4},{ s2},{ s5}
distinguishing string for s1 and s4: 111
Ch t 7 R l ti Th S d Ti A d
-
7/28/2019 3.1 Relations
49/49
Chapter 7 Relations: The Second Time Around
Exercise: P318:10P330:20P340:26P346:10P356:14