cfg for l = {a^mb^nc^k:k = m× n}

发布于 2025-01-24 13:57:04 字数 40 浏览 1 评论 0原文

我们可以为此语言编写CFG吗?我搜索了多个网站,但找不到任何答案。

Can we write CFG for this language? I searched multiple websites but I couldn't find any answers.

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

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

发布评论

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

评论(1

残月升风 2025-01-31 13:57:04

我们可以证明,使用泵送引理的无上下文语言,这不是不含上下文的。

假设该语言是无上下文的。然后,我们可以用语言编写任何字符串w,因为w = uvxyz where | vxy | < = p,| vy | > 0,对于所有整数k> = 0,u(v^k)x(y^k)z也是语言中的字符串。

考虑字符串a^(2p)b^(3p)c^(6p^2)。这是我们语言的字符串,因为2p x 3p = 6p^2。现在,考虑放置子字符串VXY:

  1. VXY的五个案例仅由A组成。至少将产品泵送至少会将产品减少至少3便士,从而打破了平等。
  2. VXY仅由A和B组成。泵送将至少将产品减少2p,从而打破平等。
  3. VXY仅由B组成。泵送将至少将产品减少2p,从而打破平等。
  4. VXY由B和C组成。如果我们抽水,我们必须删除至少一个B,但不超过P C。因为我们需要删除至少2p c以保持平等性真实,所以这会破坏它。
  5. VXY仅由C组成。泵送会减少产品而不减少无法保持平等性的倍数。

在所有五种可能的情况下,我们都认为平等在抽水时无法保持平等(选择k = 0),因此无法将其串泵向下。但是,语言不能无上下文。

We can prove this is not context-free using the pumping lemma for context-free languages, as follows.

Assume the language were context-free. Then we'd be able to write any string w in the language as w = uvxyz where |vxy| <= p, |vy| > 0 and for all integers k >= 0, u(v^k)x(y^k)z is also a string in the language.

Consider the string a^(2p) b^(3p) c^(6p^2). This is a string in our language since 2p x 3p = 6p^2. Now, consider the five cases for the placement of the substring vxy:

  1. vxy consists only of a's. Pumping down by at least one will reduce the product by at least 3p, breaking the equality.
  2. vxy consists of a's and b's only. Pumping down will reduce the product by at least 2p, breaking the equality.
  3. vxy consists of b's only. Pumping down will reduce the product by at least 2p, breaking the equality.
  4. vxy consists of b's and c's. If we pump down, we must remove at least one b but no more than p c's; because we'd need to remove at least 2p c's to keep the equality true, this breaks it.
  5. vxy consists only of c's. pumping down reduces the product without reducing the multiplicands, which can't maintain the equality.

In all five possible cases we see the equality cannot be maintained while pumping down (choosing k = 0) and so our string cannot be pumped down. But then the language cannot be context-free.

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