Question

I'm going through some of Lewis Carrols logical quizzes and I have a question with riddle number 60 on that page:

(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.

Now I come up with the following Prolog program:

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).

Now first I'm not sure what taking to me actually means. Second, if I query Prolog: ?- avoid(A) unifies with A = kangoroo which is the correct answer, but I find it strange that the take_to_me and can_kill_mice predicates are not used to get this answer. Maybe I'm not seeing the obvious.

Was it helpful?

Solution

To "take to" something means to get attached to it.

avoid(A) is satisfied if A is an animal and you detest it. You detest something that doesn't take to you. You take to something only if it's a house animal. Thus, Kangaroo is the correct answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top