This NFA to DFA conversion is confusing me

人盡茶涼 提交于 2020-01-05 06:42:13

问题


I'm trying to convert this NFA into DFA.

I have the transition table for both the NFA and DFA:

I have then tried to set up different states for the empty strings. But whatever i do i keep getting a DFA that doesn't work with the original NFA.

I'm a bit over going round in circles, can someone show me what i'm doing wrong?


回答1:


Well, as I understand it, the algorithm to produce an equivalent DFA for an NFA takes as the set of states of the DFA the power set of the set of states of the NFA; that is, if our NFA has states q0 and q1, our DFA will have states {}, {q0}, {q1}, {q0, q1}. Then, we add the productions as follows: if the NFA has a transition from q to q' on a, then the DFA has a transition from p to p' on a where p' is the state corresponding to the set of states of the NFA which can be reached by any of the states in the set corresponding to p of states of the NFA on the input a. For us:

  • {} can lead only to itself; it is a dead state. Transitions {} to {} on 0 or 1.
  • {q0} contains q0 which leads to q0 or q1 on 0 and nowhere on 1. Transitions {q0} to {q0, q1} on 0 and {q0} to {} on 1.
  • {q1} contains q1 which leads to q0 or q1 on 1 and nowhere on 0. Transitions {q1} to {q0, q1} on 0 and {q1} to {} on 1.
  • {q0, q1} contains both q0 and q1. q0 goes to q0 or q1 on 0, and q1 goes nowhere; so transition {q0, q1) to {q0, q1} on 0. q1 goes to q0 or q1 on 1, and q0 goes nowhere on 1; so transition {q0, q1} to {q0, q1} on 1.

Here is a table:

                0 |       1
     {} |      {} |      {}
   {q0} | {q0,q1} |      {}
   {q1} |      {} | {q0,q1}
{q0,q1} | {q0,q1} | {q0,q1}

Here is a graph:

           0,1
          /   \
         |     |
          \    v
{q0} -0-> {q0,q1} <-1- {q1}
   \                   /
    \                 /
     \-1--> { } <--0-/

Note that in this construction, the final states are any states of the DFA which correspond to sets containing accepting states of the NFA. For us, the accepting states are {q0} and {q0,q1} since q0 is the only accepting state in the NFA.

Note also in this construction that the initial state is the one corresponding to the set containing only the initial state of the NFA; for us, {q0}.



来源:https://stackoverflow.com/questions/42747828/this-nfa-to-dfa-conversion-is-confusing-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!