乔姆斯基范式 - 计算理论

发布于 2024-10-07 06:22:48 字数 298 浏览 3 评论 0原文

我想将语法更改为乔姆斯基范式(CNF)。

这是

S--> AB | ɛ

A--> aASb | a

B--> bS

我尝试解决这个问题

S --> [A] [B]

[A] --> [aA] [Sb] | [a]

[aA] --> [a] A

[Sb] --> s [b]

[a] --> a

[b] --> b

的例子,我不确定答案。有人能告诉我这是对还是错吗?

I want to change the grammar in to Chomsky Normal Form(CNF).

This is example

S--> AB | ɛ

A--> aASb | a

B--> bS

I try to solve this

S --> [A] [B]

[A] --> [aA] [Sb] | [a]

[aA] --> [a] A

[Sb] --> s [b]

[a] --> a

[b] --> b

I am not sure about the answer. Could anybody tell me if it is right or wrong?

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

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

发布评论

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

评论(3

不顾 2024-10-14 06:22:48

一个错误是您删除了 S -->; ɛ 过渡。您需要它(CNF 中明确允许 S --> ɛ,尽管 AnyNonTerminalOtherThanS --> ɛ 不允许)。

然后规则[A] --> [a],应该是[A] --> a 因为如果 RHS 上只有一项,那么它必须是终端。

[aA] --> [a] A
[Sb] --> s [b]

这两个看起来像是拼写错误,因为 As 不存在。您可能的意思是:

[aA] --> [a] [A]
[Sb] --> [S] [b]

除此之外,您拥有的都是正确的。

One mistake is that you removed the S --> ɛ transition. You need that (S --> ɛ is specifically allowed in CNF, even though AnyNonTerminalOtherThanS --> ɛ is not).

Then the rule [A] --> [a], should be [A] --> a because if you have only one item on the RHS, it needs to be a terminal.

[aA] --> [a] A
[Sb] --> s [b]

These two seem like typos as A and s don't exist. You probably meant:

[aA] --> [a] [A]
[Sb] --> [S] [b]

Other than that, what you have is correct.

奶气 2024-10-14 06:22:48

将乔姆斯基范式写成上述问题..
获取形式为 S->AB (或)S->aB

[aA] --> [一] [一]
[Sb]--> [S] [b]

To write Chomsky normal form to the above question..
Get the form to either S->AB (or) S->aB

[aA] --> [a] [A]
[Sb] --> [S] [b]

少钕鈤記 2024-10-14 06:22:48

[乔姆斯基范式][1]

点击此处查看乔姆斯基范式示例
[1]: https://i.sstatic.net/F44H0.jpg

[Chomsky normal form][1]

Click on this to see the example of chomsky normal form
[1]: https://i.sstatic.net/F44H0.jpg

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