

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Subset construction, NFA construction, Operations, Algorithm, Transition table of NFA, DFA construction, Input symbol, Start state of equivalent DFA, Enoding of DFA are the points from this lecture. You can find series of lecture notes for compiler construction here.
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


NFA? DFA Construction
The algorithm is called subset construction. In the transition table of an NFA, each entry is a set of states. In DFA, each entry is a single state. The general idea behind NFA-to- DFA construction is that each DFA state corresponds to a set of NFA states. The DFA uses its state to keep track of all possible states the NFA can be in after reading each input symbol.
We will use the following operations.
Before it sees the first input symbol, NFA can be in any of the state in the set ε -closure(s 0 ) , where s 0 is the start state of the NFA. Suppose that exactly the states in set T are reachable from s 0 on a given sequence of input symbols. 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). 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). When we allow for ε-transitions, NFA can be in any of the states in ε -closure(move(T,a)) after seeing a.
Subset Construction
Algorithm: Input: NFA N with state set S, alphabet Σ, start state s 0 , final states F Output: DFA D with state set S’, alphabet Σ, start states, s 0 ’ = ε-closure(s 0 ), final states F’ and transition table: S’ x Σ? S’
// initially, e-closure(s 0 ) is the only state in D states S’ and it is unmarked s 0 ’ = ε-closure( s 0 ) S’ = { s 0 ’ } (unmarked)
while (there is some unmarked state T in S’) mark state T for all a in Σ do U =? εclosure( move( T , a ) ); if U not already in S’ add U as an unmarked state to S’ Dtran( T , a ) = U ; end for end while
for each DFA state S if S contains an NFA final state mark S as DFA final state end algorithm
Example Let us apply the algorithm to the NFA for (a | b )abb.* Σ is { a , b }.
ε
ε
ε ε
ε
a
b
ε
ε
ε
a b (^) b
The start state of equivalent DFA is ε -closure(0) , which is A = {0,1,2,4,7}; these are exactly the states reachable from state 0 via ε-transition. The algorithm tells us to mark A and then compute ε -closure(move(A, a ))
move(A, a )) , is the set of states of NFA that have transition on ‘ a’ from members of A. Only 2 and 7 have such transition, to 3 and 8. So, ε-closure(move( A , a )) = ε-closure({3,8}) = {1,2,3,4,6,7,8}. Let B = {1,2,3,4,6,7,8}; thus Dtran [ A , a ] = B
For input b , among states in A , only 4 has transition on b to 5. Let C = ε-closure({5}) = {1,2,4,5,6,7}. Thus, Dtran [ A , b ] = C
We continue this process with the unmarked sets B and C, i.e., ε-closure( move ( B , a )), ε-closure( move ( B , b )), ε-closure( move ( C , a )) and ε-closure( move ( C , b )) until all sets and states of DFA are marked. This is certain since there are only 211 (!) different subsets of a set of 11 states. A set, once marked, is marked forever. Eventually, the 5 sets are:
A is start state because it contains state 0 and E is the accepting state because it contains state 10.