next up previous contents
Next: Exercise Chapter 2.5 Up: Solutions and Comments Previous: Exercise Chapter 2.3

Exercise Chapter 2.4

  1. liable_for_fine(X):- owns_car(X,Y), untaxed(Y).

    We assume that liable_for_fine/1 holds when its argument is (a person) liable for a fine, that owns_car/2 holds when the first argument possesses the object named in the second argument (and this object is a car), and that untaxed/1 holds for all those objects that are required by law to be taxed and are not!

  2. same_house(X,Y):- address(X,Z), address(Y,Z).

    The same_house/2 relation holds between two arguments (people) if the address/2 relation holds between one of these arguments and a third object and between the other and the same third object.

    Note that this makes same_house(fred,fred) true.

  3. siblings(X,Y):- mother(X,M), mother(Y,M), father(X,P), father(Y,P).

    The siblings/2 relation holds between the two arguments when each is related via the mother/2 relation to a common object and via the father/2 relation to a (different) common object.

    This is not correct if the intended meaning is to prevent one person being their own sibling. We would revise this by adding a subgoal such as not_same(X,Y).

    Note that we could have designed a parents/3 predicate (relation) such that, for example, the second argument is the mother and the third is the father of the first argument. This would result in siblings(X,Y):- parents(X,M,P), parents(Y,M,P).



Paul Brna
Mon May 24 20:14:48 BST 1999