
Suppose we have a Non-Deterministic Finite State Automaton (NFSA) and we want to derive a DFSA from it. Lets take for example, a NFSA that accepts strings containing at least '00' or '11' and can be of even or odd length:
First lets observe the transitions when we input 0's and 1's:
If we input a 0, we remain in q0 and at the same time we go to q1 therefore q0q1
If we input a 1 we remain in q0 and go to q3 therefore q0q3
Now that we have the transitions for q0, we now have new states q0q1 and q0q3 and we now have to deal with them.
if we are in q0q1 and we input a 1, if 0 enters q0 it transits to q1 and if 0 enters q1 it transits to q2. We then get a new state q0q1q2. And when we are in q0q1 and we get a 1, we remain in q0 and it transits to q3 as well. When we get a 1 for q1, there is no state transition for 1 so we don't move anywhere. Then we get state q0q3 which we already found for the transitions for q0.
Now, we have to take care of q0q3. If we get a 0 we remain in q0 and branch to q1 and when we get a zero for q3, we don't move anywhere since there are no state transitions described for a 0 input. Then we get state q0q1. Now when we get a 1 in q0, we remain in q0 and branch to q3. When we get a 1 for q3, we branch to q4. So we geta new trsnaition state q0q3q4 and we have to take care, as always for every new state derived, of it and observe its transitions. If we get a 0 for q0q1q2 we get the same state transition: q0q1q2 and if we get a 1, we get q0q3.
Similarly if we get a 0 for q0q3q4 we get q0q1 and if we get a 1 we get q0q3q4 again. In our NFSA, q2 and q4 were final accepting states so in our DFSA, any state containing q2 or q4 will be accepting states as well. We will highlight them in red and all others in blue. So now we dont have anymore new states and we can start building our DFSA but lets build the transition table first so that we get a clearer picture of what's happening:
-------------------Inputs--------------|
---------------0-------------1---------
q0-----------q0q1---------q0q3
q0q1--------q0q1q2-------q0q3
q0q3--------q0q1---------q0q3q4
q0q1q2------q0q1q2------q0q3
q0q3q4------q0q1--------q0q3q4
And our DFSA looks like this:
1 comment:
ayo mo la tete!
Post a Comment