110 likes | 328 Views
Fall 2008. The Chinese University of Hong Kong. CSC 3130: Automata theory and formal languages. More on DFA minimization and DFA equivalence. Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130. Example.
E N D
Fall 2008 The Chinese University of Hong Kong CSC 3130: Automata theory and formal languages More on DFA minimizationand DFA equivalence Andrej Bogdanov http://www.cse.cuhk.edu.hk/~andrejb/csc3130
Example • Construct a DFA over alphabet {0, 1} that accepts those strings that end in 111 • This is big, isn’t there a smaller DFA for this? 0 0 q000 1 0 q00 1 q001 q0 1 … 0 q01 … qe 1 q101 q10 0 … 1 q1 … 1 q11 1 q111 1
0 1 1 1 1 q0 q1 q2 q3 0 0 0 Smaller DFA • Yes, we can do it with 4 states:
0 1 1 1 1 q0 q1 q2 q3 0 0 0 No smaller DFA! • Last time we saw that • In fact, it is also true that There is no DFA with 3 states for L This is the unique 4-state DFA for L
Theorem • Proof outline • Suppose there are two minimal DFAs M, M’ for L • In bothM and M’, every pair of states is distinguishable The DFA M found by the minimization algorithm is the unique minimal DFA for L M M’ q0 q0’
Proof outline for uniqueness • If M and M’ are not the same, there must be states q1, q2 of M and q’ of M’ like this: • For some strings u and v M M’ u q1 q’ q0 q0’ u, v v q2
Proof outline for uniqueness • Since q1 and q2 are distinguishable, there is a string w such that • But in M’ this cannot happen! M’ M’’ u w q1 q’ w ? u, v v q2 w
Testing equivalence of DFAs • Two DFAs are called equivalent if they accept the same language 0 0 q00 q0 1 0 1 q01 0 qe 1 0 q10 0 1 1 q1 0 1 q11 1 0 1 1 qA qB qC 1 0 0
Testing equivalence of DFAs • How can we tell if M and M’ are equivalent? • Algorithm for testing DFA equivalence: Run DFA minimization algorithm on M Run DFA minimization algorithm on M’ Check that M and M’ are the same
Example • Do the following two NFAsaccept the same language? 0,1 0 0,1 0 1 q0 q0 q1 1 1 q1 0
Answer • We cannot run minimization procedure on NFAs • But we can convert both NFAs to DFA and test equivalence regularexpression NFA DFA