【发布时间】:2015-11-05 20:33:27
【问题描述】:
问题是:盐被偷了!嗯,发现罪魁祸首要么是毛毛虫,要么 比尔蜥蜴或柴郡猫。这三个都试过了,做了以下 法庭陈述:
CATERPILLAR: Bill the Lizard ate the salt.
BILL THE LIZARD: That is true!
CHESHIRE CAT: I never ate the salt.
事实上,其中至少有一个撒了谎,至少有一个说的是真话。谁吃了 盐?
我确定bill是不是真的,比所有的陈述都是真的,如果cheshire是真的,那么所有的都是假的,所以它一定是毛毛虫。
查看谓词演算并对其进行编程,它应该是这样的:
suspect(caterpillar).
suspect(lizard).
suspect(cat).
:- suspect(cat), suspect(lizard).
:- suspect(cat), suspect(caterpillar).
:- suspect(lizard), suspect(caterpillar).
%where these imply not more than one of these can be true or returned in our set
但是,然后在谓词逻辑中进一步描述这一点,我不会如何描述他们所做的描述或请求。如果一个陈述是真的,那又如何暗示其他陈述可能是假的。
【问题讨论】:
标签: prolog logic predicate answer-set-programming