Next: Solutions and Comments Up: Solutions and Comments Previous: Exercise Chapter 2.6

# Exercise Chapter 2.7

1. studies(bill,ai2).

We have revised `AI2' to `ai2'. We could have simply put quotes around as in studies(bill,`'`AI2`'`).

2. population(france,50).

where the reading is that the population of the first object in the relation population/2 is the second object expressed in millions of people.

Note we have changed `France' to `france'.

3. rich_country(italy).

Here, the statement has been expressed as a unary `relation' of something being a rich country.

4. height(jane,tall).

We have covered a similar example previously.

5. prime(2).

We have asserted that the attribute of primeness belongs to the number 2.

6. british(X):- welsh(X).

The statement has been turned into the equivalent `everybody who is welsh is british'. This is an alternative to the statement subset(welsh,british). We read this as meaning that the subset/2 relation holds between the set of welsh people and the set of british people.

As usual, we have lower-cased the words `Welsh' and `British'.

7. author(hamlet,someone).

This is a trick question. You cannot answer this one from the notes. Why not? Well, let me give the meaning of the above: the author/2 relation holds between `hamlet' (which stands for the famous play called ``Hamlet: Prince of Denmark'') and the unique atom `someone' which has been conjured from thin air.

The problem lies in expressing existential statements such as ``someone likes ice-cream'' and so on. This is informally recast as there exists some person such that this person likes ice-cream. In first order predicate logic, we would formalise this as x likes(x,ice_cream). This can be turned into likes(whatshisname,ice_cream) (this is known as Skolemisation). Without going into technicalities, we give a legitimate context when this `trick' can be done ---whenever we have no universal quantifiers ( i.e. indicated by words such as all, everyone, etc) then we may introduce a unique atom (we should be able to guarantee its uniqueness) to stand for the `someone'.

8. mortal(X):- human(X).

This is an example of a universally quantified statement. It is equivalent to x human(x) mortal(x).

Note that, in the Prolog version, this `universal quantification' is implicit.

9. pays_taxes(X):- person(X), rich(X).

Again, the universal quantification is implicit in the Prolog version.

Here, we have a body with a conjunction of two goals. This could be avoided with pays_taxes(X):- rich_person(X). Which you prefer depends on the way other relevant information is to be used or, how it is provided.

10. takes(bill,umbrella):- raining.

This is a version where it is true that `Bill' takes his umbrella whenever it is raining.

Note that in many of these examples, there is no mention of how the truth of various statements change with time.

11. no_supper(X):- naughty(X).

Here, we might have tried to write supper(X):- naughty(X). This is, however, illegal in Prolog but not for syntactic reasons.

Another way of doing this might be eats_supper(X,false):- naughty(X). This allows for a more uniform treatment of both those who are `naughty' and those who aren't.

Again, we have gone for the representation `most likely' to be useful.

We could hide much of this as firebrigade_employs(X):- over_six_foot(X).

Next: Solutions and Comments Chapter 3 Up: Solutions and Comments Previous: Exercise Chapter 2.6

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