转换给定的NFA

时间:2019-05-21 22:34:56

标签: automata dfa nfa

问题)Σ= {a,b},下图给出了NFA:

  1. 使用NFA到DFA程序,将给定的NFA转换为DFA。
  2. 使用reduce程序,最小化DFA中的状态
    enter image description here

我为nfa和dfa都做了一个过渡表,但是卡住了,不知道q2应该去哪里,或者q0或建立一个新状态,称为q4

1 个答案:

答案 0 :(得分:0)

我们可以通过将NFA的状态子集视为相应DFA的潜在状态,使用子集或幂集构造从NFA转换为DFA。 DFA的初始状态为{q0},这意味着在读取任何输入之前只能达到q0。从{q0}读取a后,我们可以通过消耗a到达q2,然后通过执行lambda转换再次到达q0。因此,f({q0},a)= {q0,q2}。在{q0}中读取b时,我们只能转到q1;因此f({q0},b)= {q1}。

我们在DFA中引入了两个新状态,分别是{q0,q2}和{q1}。片刻的反思将表明{q0,q2}具有与{q0}完全相同的过渡。在输入a上,q1可以转到q1,q2或q0(通过q2);在输入b上,它可以转到q2或q0(通过q2)。因此,f({q1},a)= {q0,q1,q2}和f({q1},b)= {q0,q2}。

我们已经看过{q0,q2}并知道其转换。但是,我们现在需要{q0,q1,q2}的过渡。看来,在输入a时,可以从某个状态到达NFA的所有状态。输入b也是如此。因此,f({q0,q1,q2},a)= {q0,q1,q2}和f({q0,q1,q2},b)= {q0,q1,q2}。

我们没有在此迭代中引入任何新状态,因此我们拥有DFA中可能需要的所有状态。我们的DFA如下所示:

q            s    q'
{q0}         a    {q0, q2}
{q0}         b    {q1}
{q0, q2}     a    {q0, q2}
{q0, q2}     b    {q1}
{q1}         a    {q0, q1, q2}
{q1}         b    {q0, q2}
{q0, q1, q2} a    {q0, q1, q2}
{q0, q1, q2} b    {q0, q1, q2}

除{q1}之外的所有状态都处于接受状态,因为它们都包含来自NFA的接受状态q0。现在,在最小化此DFA之前,让我们重命名状态:

qA = {q0}
qB = {q0, q2}
qC = {q1}
qD = {q0, q1, q2}

我们可以迭代舍弃无法组合的状态对,如下所示:

   qA,qB    qA,qC    qA,qD    qB,qC    qB,qD    qC,qD
   --------------------------------------------------
1.          xxxxx             xxxxx             xxxxx
Reason: qC cannot be combined with others since it is
        not accepting and the others are

2.                   xxxxx             xxxxxx
Reason: f((qA, qD), b) and f((qB, qD), b) equal (qC, qD)
        which was crossed off during the last iteration.

qA,qB cannot be crossed off, so these states can be
combined in a minimal DFA.

生成的最小DFA为:

q            s    q'
qAB          a    qAB
qAB          b    qC
qC           a    qD
qC           b    qAB
qD           a    qD
qD           b    qD