问题是:盐被偷了!好吧,我们发现罪魁祸首要么是毛毛虫,要么是蜥蜴比尔,要么是柴郡猫。三人受审并在法庭上发表以下声明:
CATERPILLAR: Bill the Lizard ate the salt.
BILL THE LIZARD: That is true!
CHESHIRE CAT: I never ate the salt.
碰巧的是,其中至少有一个撒了谎,至少有一个说的是真话。谁吃了盐?
我确定比尔是不是真的,比所有的陈述都是真的,如果柴郡是真的,那么所有的都是假的,所以它一定是毛毛虫。
查看谓词演算并对其进行编程,它会是这样的:
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
但是,然后在谓词逻辑中进一步描述这一点,我不会如何描述他们所做的描述或请求。如果一个陈述是真的,那如何暗示其他陈述可能是错误的。