Equivalence of DFA and NFA
The equivalence of DFA and NFA such that L(M)=L(M')
Difference between NFA and DFA
condition | NFA | DFA |
---|---|---|
initial state | not unique | only |
mark on arc | word (single-character word, ε) | character |
conversion relationship | Not sure | Sure |
Equivalence Proof of DFA and NFA
Assuming NFA M=<S, Σ, δ, S 0 , F>, we modify the state transition diagram of M as follows:
Introduce new initial state node X and final state node Y, X, Y∉S, from X to S 0 any state node connects an ε arrow arc, from any state node in F connects an ε arrow arc to Y. (solve the uniqueness of the initial state)
Further replacement is performed on the state transition graph of M, where k is the newly introduced state. (simplified mark on arc)
Then the following is the state before and after the NFA transition
The total time is two steps, the first step is to add a unique initial state, the second step is to introduce an intermediate node, and split the mark on the arc into single characters
Equivalence Proof of DFA and NFA
- NFA Deterministic--Subset Method (Solving Epsilon Arc and Transition Relations)
- Let I be a subset of the state set of , and define the ε-closure ε-closure(I) of I as:
- If s∈I, then s∈ε-closure(I);
- If s∈I, any state s' that can be reached from s through any ε arc belongs to ε-closure(I), that is, ε-closure(I)=I∪{s'| Starting from I, it can reach s'} through any ε arc
Let a be a character in Σ, define I a = ε-closure(J)
where , J is the set of states that a certain state in I reaches through an arc a.
conversion process
Deterministic: Without loss of generality, assuming that the alphabet contains only two a and b, we construct a transition table for computing the state set:
- First, set the first row and the first column of ε-closure({X}) to find I a , I b of this column;
- Then, check these two I a , I b to see if they have appeared in the first column of the table, and fill in the first column of the empty row that did not appear, and find the second and third of each row. Collections on Columns...
- Repeat the above process until all subsets of columns 2 and 3 appear in the first column
Transformation matrix:
I | He | Ib |
---|---|---|
ε-closure({X})={X,1,2} | {1,5,2} | {1,6,2} |
{1,5,2} | {1,3,5,2,4,Y} | {1,6,2} |
{1,6,2} | {1,5,2} | {1,3,6,2,4,Y} |
{1,3,5,2,4,Y} | {1,3,5,2,4,Y} | {1,6,4,2,Y} |
{1,3,6,2,4,Y} | {1,5,4,2,Y} | {1,3,6,2,4,Y} |
{1,5,4,2,Y} | {1,3,5,2,4,Y} | {1,6,4,2,Y} |
{1,6,4,2,Y} | {1,5,4,2,Y} | {1,3,6,2,4,Y} |
- Think of tables as state transition matrices and subsets as states
- The transformation table uniquely characterizes a definite finite automaton M
- The initial state is
ε-closure({X})
2.. The final state is the subset containing the original final state Y
- The initial state is
- It is not difficult to see that this DFA M is equivalent to M'
- For each NFA M there exists a DFA M' such that L(M)=L(M')
- NFA and DFA are equivalent
matrix entry simplification
Refer to the course document of "The Principle of Compilation" of MOOC National Defense University of Science and Technology of China