Construct an Equivalent DFA from NFA.
Every DFA is an NFA, it is clear that the class of languages accepted by NFA’s includes the languages accepted by DFA’s.
To convert NFA to DFA we can carry out the following algorithm:
1- begin with {q0}, start state, and calculate ?({q0},a) for all a in ? this gives a number of new states Q-.
2- For each new states Q-, we again calculate ?(Q-,a) for all a in ? and introduce new states if necessary.
3- Repeat step2 until there are no new states.
4- Final states of new DFA are the states that contain any final state of the previous NFA.
Example:
Convert the following NFSA into equivalent FSA
a b c
a b
M =(Q , ? , q0 , ? , F )
Q ={q0,q1,q2}
? ={a,b,c}
q0 ={q0}
F ={q1,q2}
M- = ( Q- , ? , q0 , ?- , F- )
1- ?(q0,a)?{q0,q1}
2- ? ( {q0,q1} , a )? {q0,q1}
3- ? ( {q0,q1} , b ) ? {q1,q2}
4- ? ({q1,q2} , b ) ? {q1,q2}
5- ? ( {q1,q2} , c) ? {q2}
6- ? ({q2} , c ) ? {q2}
• Convert NFSA with empty move into NFSA without empty move.
If there is NFSA with empty move M = ( Q, ?, q0 , t , F ) then there is SA without empty move M- = (Q- , ?, q0 , t- , F- )
Define t : Q×( ? ? {?} ) ? Q
By
t(K,?)=R(K) or ?-closure(K)
t(K,a)=R(t(R(K),a))
The set of final states F- is F ?{q}if R(q) ?F
Example:
Convert the NFSA with empty move into without empty move.
t(q0,0)=R(t(R(q0),0))=R(t({q0,q1,q2},0))={q0,q1,q2}
t(q0,1)=R(t(R(q0),1))= R(t({q0,q1,q2},1))={q1,q2}
t(q0,2)= R(t(R(q0),2))= R(t({q0,q1,q2},2))={q2}
t(q1,0)=R(t(R(q1),0))=R(t({q1,q2},0))={}
t(q1,1)=R(t(R(q1),1))= R(t({q1,q2},1))={q1,q2}
t(q1,2)= R(t(R(q1),2))= R(t({q1,q2},2))={q2}
t(q2,0)=R(t(R(q2),0))=R(t({q2},0))={}
t(q2,1)=R(t(R(q2),1))= R(t({q2},1))={}
t(q2,2)= R(t(R(q2),2))= R(t({q2},2))={q2}
F-={q0,q1,q2}
Convert NFSA with empty move into NFSA without empty move
if there is NFSA with empty move M=(Q, ?,q0,t,F) then there isSA without empty move M-=(Q-,?,q0,t-,F-)
Define t : Q×( ??{?} ) ? Q
By
t(K,?)=R(K) or ?-closure(K)
t(K,a)=R(t(R(K),a))
The set of final states F- is F ?{q}if R(q) ?F
Example : convert the NFSA with empty move into without empty move
t(q0,0)=R(t(R(q0),0))=R(t({q0,q1,q2},0))={q0,q1,q2}
t(q0,1)=R(t(R(q0),1))= R(t({q0,q1,q2},1))={q1,q2}
t(q0,2)= R(t(R(q0),2))= R(t({q0,q1,q2},2))={q2}
t(q1,0)=R(t(R(q1),0))=R(t({q1,q2},0))={}
t(q1,1)=R(t(R(q1),1))= R(t({q1,q2},1))={q1,q2}
t(q1,2)= R(t(R(q1),2))= R(t({q1,q2},2))={q2}
t(q2,0)=R(t(R(q2),0))=R(t({q2},0))={}
t(q2,1)=R(t(R(q2),1))= R(t({q2},1))={}
t(q2,2)= R(t(R(q2),2))= R(t({q2},2))={q2}
F-={q0,q1,q2}