为什么 gprolog 不将 modus ponens 的使用链接在一起?
我正在阅读 立即学习 Prolog,1.1.2 知识库 2 他们写了关于将肯定前件的使用链接在一起。
KB2.pl 文件:
listensToMusic(mia).
happy(yolanda).
playsAirGuitar(mia) :- listensToMusic(mia).
playsAirGuitar(yolanda) :- listensToMusic(yolanda).
listensToMusic(yolanda) :- happy(yolanda).
当查询:
playsAirGuitar(yolanda).
提交给 gprolog 时,它应该响应 yes
,因为它应该能够从 yolanda 快乐的事实推断出这一点。
但 gprolog 的响应为 no
。这是为什么?
I am reading Learn Prolog Now, 1.1.2 Knowledge Base 2 where they write about chaining together uses of modus ponens.
The KB2.pl file:
listensToMusic(mia).
happy(yolanda).
playsAirGuitar(mia) :- listensToMusic(mia).
playsAirGuitar(yolanda) :- listensToMusic(yolanda).
listensToMusic(yolanda) :- happy(yolanda).
When the query:
playsAirGuitar(yolanda).
is submitted to gprolog, it is supposed to respond yes
, because it should be able to infer it from the fact that yolanda is happy.
But gprolog responds with no
. Why is that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为问题在于谓词 ListensToMusic/1 的子句是分开的。
以下代码对我返回 yes:
您应该收到类似的警告
i think that the problem is that the clauses of the predicate listensToMusic/1 are separated.
the following code returns yes for me:
you should get a warning like