1

ルイス・キャロルの論理クイズをいくつかやって いて、そのページのなぞなぞ番号 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実際に何を意味するのかわかりません。第 2 に、Prolog をクエリすると、 どちらが正しい答えであるかが?- avoid(A)統一 されますが、この答えを得るために述語と述語が使用されていないのは奇妙です。多分私は明らかなことを見ていない。A = kangorootake_to_mecan_kill_mice

4

1 に答える 1