CS103
HO#41
Slides--Regular Expressions
May 5, 2010
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)
r
∈
R
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 }.
This procedure is known as
The Subset Construction
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.