变换语法问题
S -> aB | lamda
B -> bB
B 是无用的产生式。现在删除后
S -> a | lamda
这是正确的吗?
S -> aB | lamda
B -> bB
B is a useless production. Now after its removal
S -> a | lamda
Is this correct ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
生产S-> aB 不终止。因为B-> bB 不终止。所以产生式S-> aB没啥用。
答案应该是
production S -> aB does not terminate. Because B -> bB does not terminate. So the production S -> aB is useless.
the answer should be
天哪,我已经很长时间没有看过CFG了。 B 产生 b 的无限级数,不是吗 (b*?)
假设 b* 意味着 B 的无限级数,我想我会简化为:
S -> ab* | λ
编辑:
是的,我上面的回答是错误的。 “无用产生式”的定义是在终端字符串的推导中从未使用过的产生式。由于 B 是非末端的,因此可以将其删除,因此 S → λ。
+1 用户574183 的答案。
Boy it's been a long time since I've looked at CFG's. B produces an infinite series of b's, does it not (b*?)
Assuming b* means an infinite series of B's I think I would reduce to:
S -> ab* | λ
EDIT:
Yes, my answer above is wrong. The definition of a "useless production" is a production that is never used in the derivation of a terminal string. Since B is non-terminal it can be removed thus S -> λ.
+1 to the answer by user574183.