next up previous contents
Next: Exercise Chapter 2.4 Up: Solutions and Comments Previous: Execise Chapter 2.2

Exercise Chapter 2.3

  1. eat(X,custard):- animal(X).

    This can be paraphrased as `if X is an animal then X eats custard'.

    We ought also to provide the informal semantics for eat/2 and animal/1. Let us assume that this can be done.

    By the way, we could also, but less satisfactorily, write custard_eater(X):- animal(X).

  2. loves(X,Y):- directed_by(bergman,Y).

    The relation `loves' holds between any two objects if the second object is related to bergman via the directed_by relation.

    Note that nowhere have we said that the first argument of the loves/2 relation should be a person. This is implicit in the original statement and, strictly, ought to be enforced.

  3. likes(jim,X):- belongs_to(X,fred).

    The relation `likes' holds between `jim' and some other object if this object is related to `fred' through the `belongs_to' relation.

    Again note that the declarative readings for both likes/2 and belongs_to/2 are not provided by this statement.

  4. may_borrow(X,bike,jane):- need(X,bike).

    The relation `may_borrow' holds between the first argument and the second (where the third is the owner of the second) if these two arguments are related via the `need' relation.

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