Title: FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
115-453
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
For next time Read 2.1 2.2
2MINIMIZING DFAs
3IS THIS MINIMAL?
NO
4IS THIS MINIMAL?
5THEOREM
For every regular language L, there exists a
unique (up to re-labeling of the states) minimal
DFA M such that L L(M)
6NOT TRUE FOR NFAs
7EXTENDING ?
Given DFA M (Q, S, ?, q0, F) extend ? to ? Q
? S ? Q as follows
?(q, e)
q
?(q, ?)
?(q, ?)
?(q, w1 wk1 ) ?( ?(q, w1 wk ), wk1 )
A string w ? S distinguishes states q1 from q2
if
?(q1, w) ? F ? ?(q2, w) ? F
8q1
1
0
0,1
1
q0
q2
0
0
1
q3
e distinguishes accept from non-accept states
9Fix M (Q, S, ?, q0, F) and let p, q, r ? Q
Definition
10Fix M (Q, S, ?, q0, F) and let p, q, r ? Q
Define relation
p q iff p is indistinguishable from q
Proposition is an equivalence relation
p p (reflexive)
p q ? q p (symmetric)
p q and q r ? p r (transitive)
p q r
Suppose not
w
w
11Fix M (Q, S, ?, q0, F) and let p, q, r ? Q
Proposition is an equivalence relation
so partitions the set of states of M into
disjoint equivalence classes
q p p q
Q
q
q0
12(No Transcript)
13Algorithm MINIMIZE
Input DFA M
Output DFA MMIN such that
M ? MMIN
MMIN has no inaccessible states
MMIN is irreducible
states of MMIN are pairwise distinguishable
Theorem MMIN is the unique minimum
14Theorem MMIN is the unique minimum
Must show 2 things Suppose M is a DFA equiv
M, then 1. ( states in M) ? ( states in
MMIN) 2. If ( states in M) ( states in
MMIN) then M is isomorphic to MMIN (i.e.,
same up to re-labeling of states)
Idea States of MMIN will be blocks of equivalent
states of M
15Idea States of MMIN will be blocks of equivalent
states of M
16TABLE-FILLING ALGORITHM
Input DFA M (Q, S, ?, q0, F)
Output
(2) EM q q ? Q
Recursion
d
d
d
?
d
p
p?
?
?
d
q
q?
17TABLE-FILLING ALGORITHM
Input DFA M (Q, S, ?, q0, F)
Output
(2) EM q q ? Q
IDEA!
- Make best effort to find pairs of states that are
distinguishable. - Pairs left over will be indistinguishable.
18TABLE-FILLING ALGORITHM
Input DFA M (Q, S, ?, q0, F)
Output
(2) EM q q ? Q
19TABLE-FILLING ALGORITHM
Input DFA M (Q, S, ?, q0, F)
Output
(2) EM q q ? Q
Recursion
d
d
d
?
d
p
p?
?
?
d
q
q?
20q0
q1
d
d
q2
d
q3
d
d
d
q0
q1
q2
q3
0,1
0
1
0
0
1
q0
q1
q2
q3
1
21q1
q0
q0
q2
q3
q1
d
d
q2
q3
d
d
q0
q1
q2
q3
22If 2 states are not distinguished by
table-filling algorithm, then they are equivalent
Proof (by contradiction)
Then there exists w such that
(Why is w gt0 ?)
Of all such bad pairs, let (p, q) be a pair with
the smallest w
So, w ?w?, where ? ? S
Let p? ?(p,?) and q? ?(q,?)
Then (p?, q?) is also a bad pair
23Algorithm MINIMIZE
Input DFA M
Output DFA MMIN
(1) Remove all inaccessible states from M
(2) Apply Table-Filling algorithm to get EM
q q is an accessible state of M
MMIN (QMIN, S, ?MIN, q0 MIN, FMIN)
QMIN EM, q0 MIN q0, FMIN q q ? F
?MIN( q,? ) ?( q,? )
Must show ?MIN is well defined!
24Algorithm MINIMIZE
Input DFA M
Output DFA MMIN
(1) Remove all inaccessible states from M
(2) Apply Table-Filling algorithm to get EM
q q is an accessible state of M
MMIN (QMIN, S, ?MIN, q0 MIN, FMIN)
QMIN EM, q0 MIN q0, FMIN q q ? F
?MIN( q,? ) ?( q,? )
Claim MMIN ? M
25MINIMIZE
q0
q1
q2
261
0
0,1
0
q4
q0
q1
1
1
0
q5
0
q0
0,1
1
q1
d
q3
q2
q3
d
d
q4
d
d
q5
d
d
d
d
q0
q1
q3
q4
q5
271
0
0,1
0
q4
q0
q1
1
1
0
q5
0
q0
q1
d
q3
q3
d
d
q4
d
d
q5
d
d
d
d
q0
q1
q3
q4
q5
28MMIN is the unique minimal DFA equivalent to M
Suppose M??MMIN, and M? has no inaccessible
states and is irreducible
Claim There exists a 1-1 onto correspondence
(preserving transitions) between M? and MMIN
Proof We will construct a map recursively
Base Case q0 MIN ? q0?
Recursive Step
If p ? p?
Then q ? q?
q
q?
29MMIN is the unique minimal DFA equivalent to M
Suppose M??MMIN, and M? has no inaccessible
states and is irreducible
Claim There exists a 1-1 onto correspondence
(preserving transitions) between M? and MMIN
30MMIN is the unique minimal DFA equivalent to M
Suppose M??MMIN, and M? has no inaccessible
states and is irreducible
Claim There exists a 1-1 onto correspondence
(preserving transitions) between M? and MMIN
NB If M is minimal, then M has no inaccessible
states and is irreducible. (So claim implies
) This Claim is also implying the converse, ie if
M has no inaccessible states and is irreducible,
then M is minimal. Proof. Let Mmin (? M ? MMIN)
be minimal. Then Mmin ? MMIN So, by Claim, both
Mmin and M are isomorphic to MMIN
NOT TRUE for NFAs !
31MMIN is the unique minimal DFA equivalent to M
Suppose M??MMIN, and M? has no inaccessible
states and is irreducible
Claim There exists a 1-1 onto correspondence
(preserving transitions) between M? and MMIN
Proof We will construct a map recursively
Base Case q0 MIN ? q0?
Recursive Step
If p ? p?
Then q ? q?
q
q?
32We need to prove
The map is defined everywhere
The map is well defined
The map is a bijection
33The map is defined everywhere
That is, for all q ? MMIN there is a q? ? M?
such that q ? q?
If q ? MMIN, there is w such that ?MIN(q0 MIN,w)
q
Let q? ??(q0?,w)
34The map is well defined
Suppose there exist q? and q?? such that q ? q?
and q ? q??
We show that q? and q?? are indistinguishable,
so it must be that q? q??
35Suppose there exist q? and q?? such that q ? q?
and q ? q??
Suppose q? and q?? are not indistinguishable
MMIN
M?
u
u
w
w
Accept
Accept
q?
q
q0?
q0 MIN
v
w
v
w
Reject
Reject
q??
q
q0?
q0 MIN
36The map is onto
For all q? ? M? there is a q ? MMIN such that q ?
q?
If q? ? M?, there is w such that ??(q0?,w) q?
Let q ?MIN(q0 MIN,w)
37The map is 1-1
Suppose there exist p and q such that p ? q? and
q ? q?
Suppose p and q are not indistinguishable
MMIN
M?
u
u
w
w
Accept
Accept
q?
p
q0?
q0 MIN
v
w
v
w
Reject
Reject
q?
q
q0?
q0 MIN
38How do we prove two regular expressions are
equivalent?
39(No Transcript)
40(No Transcript)
41Finish Reviewing Chapter 1 of the book and Read
2.1 2.2 for next time