语言 A = {0^n 1^n 0^n} 上下文无关吗?

发布于 2024-08-28 15:21:34 字数 108 浏览 2 评论 0原文

我只是对不同的语言进行了一些思考(因为我正在复习即将到来的期末考试),我想不出一个有效的下推自动机来处理语言 A = {0^n 1^n 0^n | n>=0}。这不是上下文无关的语言,我是对的吗?

I was just putting some thought into different languages (as I'm reviewing for final exams coming up) and I can not think of a valid pushdown automata to handle the language A = {0^n 1^n 0^n | n >= 0}. This is not a context-free language, am I correct?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

合久必婚 2024-09-04 15:21:34

我相信你是。它看起来与语言L = { a^ib^ic^i |我> 0 } 维基百科关于泵引理的文章使用了以下示例:如何证明一种语言不是上下文无关的。

I believe you are. It looks quite similar to the language L = { a^i b^i c^i | i > 0 } which the Wikipedia article on the pumping lemma uses as an example of how to prove that a language is not context-free.

萌逼全场 2024-09-04 15:21:34

想一想 {0^n 1^n} 部分。将 0 替换为 (,将 1 替换为 ),您就得到了简单嵌套括号的语言,即这完全暴露了一种语言是不规则的。

添加最后的 0^n 使其与上下文相关(即不是上下文无关)。请记住,CFG 可以由有限状态计算机决定,并将单个堆栈作为其唯一的数据结构。看到 0 会导致一个字符被压入堆栈,看到 1 则会从堆栈中弹出。这保证了 0 的数量与 1 的数量一样多,但是无法匹配更多 0。

Think of just the {0^n 1^n} part for a second. Replace 0 with ( and 1 with ) and you've got the language of simple nested parentheses, which is a dead give-away that a language is not regular.

Adding the final 0^n makes it context-sensitive (i.e. not context-free). Keep in mind that a CFG can be decided by a finite-state computer with a single stack as its only data structure. Seeing a 0 will cause a character to be pushed onto the stack, and seeing a 1 will pop from the stack. This guarantees that there are as many 0's as 1's, but there's no way to then match more 0's.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文