/**************************/ /* */ /* Answers to worksheet 1 */ /* */ /**************************/ /* This stuff was already given */ /* A Zoological Example */ zebedee_isa_mammal. zebedee_has_hooves. zebedee_has_stripes. zebedee_isa_ungulate :- zebedee_isa_mammal, zebedee_has_hooves. zebedee_isa_zebra :- zebedee_isa_ungulate, zebedee_has_stripes. zebedee_has_camouflage :- zebedee_has_stripes. zebedee_has_camouflage :- zebedee_has_spots. /* Exercise 1.1 */ /* Zebedee is a rhino if he has a horn and he has leathery skin. */ zebedee_isa_rhino :- zebedee_has_horn, zebedee_has_leathery_skin. /* Zebedee is a canivore if he is a mammal and eats meat, or if he */ /* has claws, pointed teeth, and his eyes point forward. */ zebedee_isa_carnivore :- zebedee_isa_mammal, zebedee_eats_meat. zebedee_isa_carnivore :- zebedee_has_claws, zebedee_has_pointed_teeth, zebedee_has_forward_eyes. /* If Zebedee has feathers, he is a bird. Alternatively, if he */ /* flies and lays eggs, he is a bird. */ zebedee_isa_bird :- zebedee_has_feathers. zebedee_isa_bird :- zebedee_flies, zebedee_lays_eggs. /* If Zebedee is a carnivore and has spots, he is a cheetah. */ zebedee_isa_cheetah :- zebedee_isa_carnivore, zebedee_has_spots. /* We can tell whether Zebedee is a tiger because we know */ /* that a tiger is a canivore that has stripes. */ zebedee_isa_tiger :- zebedee_isa_carnivore, zebedee_has_stripes. /* Similarly, we know that giraffes are ungulates with spots and a */ /* long neck. */ zebedee_isa_giraffe :- zebedee_isa_ungulate, zebedee_has_spots, zebedee_has_long_neck. /* Exercise 1.2 */ /* The answers to the queries will not be affected by any changes */ /* to the ordering. */ /* Exercise 1.3 */ /* This rule launches an infinite computation. The system runs out */ /* of space to keep track of the progress of the computation and */ /* so stops with an out of stack message. */