Professional Documents
Culture Documents
Lecture 05
Lecture 05
Construction
Lecture 5
NFA → DFA Construction
The algorithm is called subset
construction.
2
NFA → DFA Construction
The general idea behind
NFA-to-DFA construction is
that each DFA state
corresponds to a set of
NFA states.
3
NFA → DFA Construction
We will use the following
operations.
e-closure(T):
set of NFA states reachable
from some NFA state s in T
on e-transitions alone.
4
NFA DFA Construction
move(T,a):
set of NFA states to which
there is a transition on input
a from some NFA state s in
set of states T.
5
NFA → DFA Construction
Before it sees the first input
symbol, NFA can be in
any of the state in the set
e-closure(s0), where s0 is the
start state of the NFA.
6
NFA → DFA Construction
Let a be the next input
symbol.
On seeing a, the NFA can
move to any of the states in
the set move(T,a).
7
NFA → DFA Construction
Let a be the next input
symbol.
On seeing a, the NFA can
move to any of the states in
the set move(T,a).
8
NFA → DFA Construction
When we allow for
e-transitions, NFA can be in
any of the states in
e-closure(move(T,a))
after seeing a.
9
Subset Construction Example
e
a
2 3
e e
e e a b b
0 1 6 7 8 9 10
e e
b
4 5
e
NFA for (a | b )*abb
10
e
a
2e 3
e e
e e a b b
0 1 6 7 8 9 10
e e
b
4 5
e
The start state of equivalent
DFA is e-closure(0), which is
A = {0,1,2,4,7}
11
e
2e a 3
e e
e e a b b
0 1 6 7 8 9 10
e e
b
4 5
e
A = {0,1,2,4,7}, these are
exactly the states reachable
from state 0 via e-transition.
12
e
2e a 3
e e
e e a b b
0 1 6 7 8 9 10
e e
b
4 5
e
i.e., e-closure(move(B,a)),
e-closure(move(B,b)),
22
e
a
2e 3
e e
e e a b b
0 1 6 7 8 9 10
e e
b
4 5
e
e-closure(move(C,a)) and
e-closure(move(C,b))
23
e
a
2e 3
e e
e e a b b
0 1 6 7 8 9 10
e e
b
4 5
e
Until all sets and states of DFA
are marked.
24
e
a
2e 3
e e
e e a b b
0 1 6 7 8 9 10
e e
b
4 5
e
This is certain since there are
11
only 2 (!) different subsets of
a set of 11 states.
25
e
a
2e 3
e e
e e a b b
0 1 6 7 8 9 10
e e
b
4 5
e
b
DFA for (a | b )*abb
31
Resulting DFA
a a
a b b
A B D E
a
b a
b
C
b a a a a b b
32