CS103
HO#31
Slides--NFAs, Regular Expressions
4/25/11
1
Theorem 1.39
: Every nondeterministic finite automaton has an
equivalent deterministic finite automaton.
To convert an NFA
N = (Q,
,
, q
0
, F) recognizing A
into a DFA
M = (Q',
,
'
, q
0
', F
'
):
1.
Q' =
P
(Q)
2.
For R
Q' and a
, let
'
(R, a) = { q
Q | q
(r, a)
for some r
R }.
Alternately, we may write
'
(R, a) =
(r, a)
3. q
0
' = { q
0
}
4. F' = { R
Q' | R contains an accepting state of N }
This does not handle
-transitions.
r
R
without
-transitions.
Theorem 1.39
: Every nondeterministic finite automaton has an
equivalent deterministic finite automaton.
To convert an NFA
N = (Q,
,
, q
0
, F) recognizing A
into a DFA
M = (Q',
,
'
, q
0
', F):
1.
Q' =
P
(Q)
2.
For R
Q' and a
, let
'
(R, a) = { q
Q | q
E(
(r, a))
for some r
R }.
3. q
0
' =
E({ q
0
})
4. F' = { R
Q' | R contains an accepting state of N }
For an NFA with
-transitions, make the changes shown in red,
where
{ E(R) = { q
Q | q can be reached by following 0 or more
-arrows }.
Sipser has a good example of the Subset Construction on
pp. 57 – 58.
For the DFA, Q' =
P
({1, 2, 3}), so there are 8 states.
A Bad Case for the Subset Construction
q
0
q
1
q
2
q
n
...
0, 1
0, 1
0, 1
0, 1
1
0, 1
If we build an NFA like this for some value of n, the language accepted is
the set of all strings of 0's and 1's such that the n
th
symbol from the end is a 1.
If we build a DFA to accept the same language, it will have to "remember"
the last n symbols it has read, and be prepared for any combination of
0's and 1's after the critical 1.
Although converting an NFA to a DFA often results in a machine with roughly
the same number of states as the NFA, this one needs at least 2
n
states.
Reference: Hopcroft, Motwani, and Ullman,
Automata Theory, Languages,
and Computation, 3
rd
Edition
.
Another Bad Case for the Subset Construction
Let
= {a, b, c, ..., z}
Let L
Missing
= {w | there is a symbol from
not in w}
The NFA would look much like the one we had for the