我正在浏览一些Lewis Carrols logical quizzes 我在该页面上有一个关于第60号谜语的问题:
(1) The only animals in this house are cats;
(2) Every animal is suitable for a pet, that loves to gaze at the moon;
(3) When I detest an animal, I avoid it;
(4) No animals are carnivorous, unless they prowl at night;
(5) No cat fails to kill mice;
(6) No animals ever take to me, except what are in this house;
(7) Kangaroos are not suitable for pets;
(8) None but carnivora kill mice;
(9) I detest animals that do not take to me;
(10) Animals, that prowl at night, always love to gaze at the moon.
Univ. "animals"; a = avoided by me; b = carnivora; c = cats; d = detested by me;
e = in this house; h = kangaroos; k = killing mice; l = loving to gaze at the moon;
m = prowling at night; n = suitable for pets, r = taking to me.
现在我想出了以下Prolog程序:
animal(cat).
animal(kangaroo).
prowl_at_night(cat).
carnivore(A) :- prowl_at_night(A).
loves_moongazing(A) :- prowl_at_night(A).
animals_in_house(cat).
suitable_pet(A) :-
animal(A),
A \= kangaroo,
loves_moongazing(A).
can_kill_mice(cat).
can_kill_mice(A) :- carnivore(A).
take_to_me(A) :- animals_in_house(A).
detest(A) :- \+ take_to_me(A).
avoid(A) :- animal(A), detest(A).
现在我首先不确定taking to me
实际意味着什么。
其次,如果我查询Prolog:?- avoid(A)
与A = kangoroo
统一
这是正确答案,但我发现take_to_me
和can_kill_mice
很奇怪
谓词不习惯得到这个答案。
也许我没有看到明显的。
答案 0 :(得分:1)
“接受”某事意味着与之相关。
如果A是动物并且你厌恶它,则避免(A)满意。你讨厌一些不带给你的东西。只有当它是家畜时,你才会采取行动。因此,袋鼠是正确的答案。