[英]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 任何帮助,将不胜感激
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 提示:正式证明
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. 上下文敏感语言的补充本身就是上下文敏感的。
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.