简体   繁体   English

是语言{0 ^ n 1 ^ n 0 ^ k | k!= n}上下文免费?

[英]Is the language {0^n 1^n 0^k | k != n} context free?

I believe this language isn't context free, because there is no chance that a PDA could compare 2 blocks of 0's and 1's of the same length and also remember it's length for later use. 我相信这种语言不是没有上下文的,因为PDA不可能比较2个0和1的相同长度的块,并且还记住它的长度供以后使用。

Unfortunately, I have no idea how to prove it. 不幸的是,我不知道如何证明它。

I tried using the pumping lemma to no avail... 我尝试使用泵浦引理无济于事......

I've also tried to assume by contradiction that the language is context free and use the fact that the intersection of a context free language with a regular language is also context free (by finding some mysterious regular language L), and surprisingly (or not) - all my efforts were in vain... 我还试图通过矛盾来假设语言是无上下文的,并且使用这样一个事实,即上下文无关语言与常规语言的交集也是无上下文的(通过找到一些神秘的常规语言L),并且令人惊讶(或者不是) ) - 我所有的努力都是徒劳的......

Any help would be appreciated 任何帮助,将不胜感激

Is the language { 0 n 1 n 0 k | 语言是{0 n 1 n 0 k | k != n} context free? k!= n}上下文免费?

No , the language L = { 0 n 1 n 0 k | ,语言L = {0 n 1 n 0 k | k!=n } is not a context free language . k!= n} 不是无上下文语言 Also, Class of Regular Languages is subset of class Context free languages . 此外, 经典语言类是类无上下文语言的子集

You Idea using PDA is correct and obvious way to show that language is not context free. 你使用PDA想法是正确和明显的方式来表明语言不是上下文。 And we can't draw PDA for language 0 n 1 n 0 k because after matching prefix 0 n to 1 n stack become empty, then we don't have stored information to check weather suffix 0 K are equal to n or not. 并且我们不能为语言0 n 1 n 0 k绘制PDA ,因为在匹配前缀0 n到1 n堆栈变为空之后,我们没有存储信息来检查天气后缀0 K是否等于n

HINT: For formal proofs 提示:正式证明

  • First 第一

L = {0 n 1 n 0 k | L = {0 n 1 n 0 k | k!=n } now complement of L is L ' . k!= n}现在L的补码是L '

L ' = {{0 n 1 n 0 n } that is well known context sensitive language (can be proof). L ' = {{0 n 1 n 0 n },这是众所周知的上下文敏感语言(可以证明)。

And the complement of a context-sensitive language is itself context-sensitive. 上下文敏感语言的补充本身就是上下文敏感的。

  • Second 第二

For Pumping Lemma: 对于泵送引理:

L = {0 n 1 n 0 k | L = {0 n 1 n 0 k | k!=n } is Union of L 1 and L 2 , Where k!= n}是L 1和L 2的联合 ,其中
L 1 = {0 n 1 n 0 k | L 1 = {0 n 1 n 0 k | k > n } and L 2 = {0 n 1 n 0 k | k> n}且L 2 = {0 n 1 n 0 k | k < n }, k <n},

L = L 1 UL 2 L = L 1 UL 2

L 1 and L 2 both are non-context-free Language. L 1和L 2都是非上下文语言。 and union of two non-context free languages are non-context-free. 两种非上下文免费语言的联合是非上下文无关的。 ( that can easily proof by grammar) (可以通过语法轻松证明)


Also, The union, concatenation of two context-sensitive languages is context-sensitive. 此外, 联合,两个上下文相关语言的串联是上下文敏感的。

暂无
暂无

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

相关问题 语言A = {0 ^ n 1 ^ n 0 ^ n}是否上下文无关? - Is the language A = {0^n 1^n 0^n} context free? 这是语法 {a^2n b^n | n &gt;= 0} 是否上下文无关? - Is this grammar {a^2n b^n | n >= 0} context free or not? 证明形式为0 ^ n(其中n为素数)的语言既不是常规语言也不是上下文无关语言 - prooving that a language of form 0^n where n is prime is neither regular nor context free 将数组大小n分成k个相同大小的组 - array size n into k same size groups 如何在线性时间内对长度为k的n个单词进行排序? - How can I sort n words with length k in linear time? 是a ^ n,其中n&gt; 1000是常规语言吗? - Is a^n, where n>1000 a regular language? L = {a^na^nb^m |m, n ≥ 0} 是规则语言还是不规则语言? - Is L = {a^n a^n b^m |m, n ≥ 0} a regular or irregular language? 在深度为k且分支因子为n的树中找到最大和最小节点 - Finding max and min nodes possible in a tree of depth k and with a branching factor of n 是n log n = O(n)且是n log n = Omega(n) - Is n log n = O(n) and is n log n = Omega(n) pda 接受语言 L={a^nb^m | n <m}< div><div id="text_translate"><p> 我知道如何解决 m&lt;n,但我很难理解 m&gt;n 的逻辑。</p><p> 在 m&lt;n 中,我们将所有 a 压入堆栈,当我们得到 b 时,我们弹出一个 a,当输入以包含 mn a 的堆栈结束时,机器应该进入最终的 state</p><p> 我该怎么办 m&gt;n.... </p></div></m}<> - pda to accept the language L={a^n b^m | n<m}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM