问题
I'm trying to convert this NFA into DFA.
I have the transition table for both the NFA and DFA:
I have then tried to set up different states for the empty strings. But whatever i do i keep getting a DFA that doesn't work with the original NFA.
I'm a bit over going round in circles, can someone show me what i'm doing wrong?
回答1:
Well, as I understand it, the algorithm to produce an equivalent DFA for an NFA takes as the set of states of the DFA the power set of the set of states of the NFA; that is, if our NFA has states q0
and q1
, our DFA will have states {}, {q0}, {q1}, {q0, q1}
. Then, we add the productions as follows: if the NFA has a transition from q
to q'
on a
, then the DFA has a transition from p
to p'
on a
where p'
is the state corresponding to the set of states of the NFA which can be reached by any of the states in the set corresponding to p
of states of the NFA on the input a
. For us:
{}
can lead only to itself; it is a dead state. Transitions{}
to{}
on0
or1
.{q0}
containsq0
which leads toq0
orq1
on0
and nowhere on1
. Transitions{q0}
to{q0, q1}
on0
and{q0}
to{}
on1
.{q1}
containsq1
which leads toq0
orq1
on1
and nowhere on0
. Transitions{q1}
to{q0, q1}
on0
and{q1}
to{}
on1
.{q0, q1}
contains bothq0
andq1
.q0
goes toq0
orq1
on0
, andq1
goes nowhere; so transition{q0, q1)
to{q0, q1}
on0
.q1
goes toq0
orq1
on1
, andq0
goes nowhere on1
; so transition{q0, q1}
to{q0, q1}
on1
.
Here is a table:
0 | 1
{} | {} | {}
{q0} | {q0,q1} | {}
{q1} | {} | {q0,q1}
{q0,q1} | {q0,q1} | {q0,q1}
Here is a graph:
0,1
/ \
| |
\ v
{q0} -0-> {q0,q1} <-1- {q1}
\ /
\ /
\-1--> { } <--0-/
Note that in this construction, the final states are any states of the DFA which correspond to sets containing accepting states of the NFA. For us, the accepting states are {q0}
and {q0,q1}
since q0
is the only accepting state in the NFA.
Note also in this construction that the initial state is the one corresponding to the set containing only the initial state of the NFA; for us, {q0}
.
来源:https://stackoverflow.com/questions/42747828/this-nfa-to-dfa-conversion-is-confusing-me