简体   繁体   English

非确定性上下文无关语言的补充

[英]Complement of non-deterministic context-free language

The complement of a context-free language is not always context-free.上下文无关语言的补充并不总是上下文无关的。 It is not allowed to just swap the final and non-final states of an NPDA and assume that it produces the complement of the language.不允许只交换 NPDA 的最终和非最终状态并假设它产生语言的补码。 Could someone give an example where it goes wrong?有人可以举一个出错的例子吗? And why does the above described procedure work for regular languages given a DFA?为什么上述过程适用于给定 DFA 的常规语言? Maybe because DFA and NFA are equivalent and DPDA and NPDA are not?也许是因为 DFA 和 NFA 是等价的,而 DPDA 和 NPDA 不是?

Well, swapping the final vs non-final states of an NFA doesn't even guarantee you'll get the complement of the language.好吧,交换 NFA 的最终状态和非最终状态甚至不能保证您会得到该语言的补充。 Consider this rather curious NFA:考虑一下这个相当奇怪的 NFA:

----->q0--a-->[q1]
      |
      a
      |
      V
      q2

This NFA accepts the language {a}.该 NFA 接受语言 {a}。 Swapping the final and non-final states, the accepted language becomes {e, a}.交换最终状态和非最终状态,接受的语言变为 {e, a}。 These languages are not complementary since they have an intersection.这些语言不是互补的,因为它们有交集。

In exactly the same way, swapping the states of a NPDA is not guaranteed to work either.以完全相同的方式,交换 NPDA 的状态也不能保证有效。 The difference, as you point out, is that for any NFA, there is some equivalent DFA (indeed, there are lots), and swapping toggling the finality of states will work for those, so the languages are guaranteed to be closed under complementation.正如您所指出的,不同之处在于,对于任何 NFA,都有一些等效的 DFA(确实有很多),并且交换切换状态的最终性将适用于这些,因此可以保证语言在互补下关闭。

For NPDAs, though, we do not necessarily have equivalent DPDAs (where swapping finality would work fine).但是,对于 NPDA,我们不一定有等效的 DPDA(交换最终性可以正常工作)。 Thus, it is possible that the complement of some languages accepted only by NPDAs is not context-free.因此,仅 NPDA 接受的某些语言的补语可能不是上下文无关的。

Indeed, the context-free language {a^ib^jc^k |事实上,上下文无关语言 {a^ib^jc^k | i != j or j != k} is accepted only by NPDAs and its complement {strings not of the form a^ib^jc^k or strings of that form with i=j=k) is not context-free. i != j 或 j != k} 仅被 NPDA 接受,并且它的补码{不是 a^ib^jc^k 形式的字符串或具有 i=j=k 形式的字符串)不是上下文无关的。

The grammar which does not specify a unique move from at least one sigma element.没有从至少一个 sigma 元素中指定唯一移动的语法。

From any state by taking one input we can not determine to which step we will reach so the grammar generating such type of situation is called non deterministic grammar.从任何 state 获取一个输入,我们无法确定我们将到达哪一步,因此生成这种情况的语法称为非确定性语法。

[enter image description here][1] https://i.stack.imgur.com/U6vaJ.jpg For a particular input the computer will give different output on different execution. [在此处输入图像描述][1] https://i.stack.imgur.com/U6vaJ.jpg对于特定的输入,计算机将在不同的执行时给出不同的 output。

Can't solve the problem in polynomial time.不能在多项式时间内解决问题。

Cannot determine the next step of execution due to more than one path the algorithm can take.由于算法可以采用的路径不止一条,因此无法确定执行的下一步。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM