/* Lewis Carroll's symbolic logic problem #60 in Picat. From http://www.yesfine.com/carroll_symbolic_logic.htm """ 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. """ From http://www.yesfine.com/carroll_symbolic_logic_simplified_statements.htm """ 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. """ Also, see http://stackoverflow.com/questions/15733986/solving-symbolic-logic-with-prolog for a Prolog solution. Model created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. main => time(go). go ?=> avoid(A), writeln(a=A), fail. go => true. % This index is needed index(-) animal(cat) => writeln($animal(cat)),true. animal(kangaroo) => writeln($animal(kangaroo)),true. prowl_at_night(cat) => writeln($prowl_at_night(cat)),true. carnivore(A) => writeln($carnivore(A)),prowl_at_night(A). loves_moongazing(A) => writeln($loves_moongazing(A)), prowl_at_night(A). animals_in_house(cat) => writeln($animals_in_house(cat)), true. suitable_pet(A) => writeln($suitable_pet(A)), animal(A), A != kangaroo, loves_moongazing(A). can_kill_mice(cat) ?=> writeln($can_kill_mice(cat)),true. can_kill_mice(A) => writeln($can_kill_mice(A)),carnivore(A). take_to_me(A) => writeln($take_to_me(A)),animals_in_house(A). detest(A) => writeln($detest(A)),not take_to_me(A). avoid(A) => writeln($avoid(A)), animal(A), detest(A).