Next: Prolog Constants Up: Knowledge Representation Previous: First Order Predicate

# We Turn to Prolog

Prolog provides for the representation of a subset of first order predicate calculus. The restrictions on what can be done will become clearer later. We will now explain how we can write logical statements in Prolog.

If ``the capital of france is paris'' then we can represent this in predicate calculus form as:

```
france has_capital paris

```

We have a binary relationship (two things are related) written in infix form. That is, the relationship is written between the two things related.

The relationship (or predicate) has been given the name ``has_capital'' ---hence we say that the predicate name is ``has_capital''.

And in Prolog form by such as:

```
has_capital(france,paris).

```
where we write a prefix form and say that the relationship takes two arguments. Prefix because the relationship is indicated before the two related things.

Note that, in Prolog, if the name of an object starts with a lower case letter then we refer to a specific object. Also, there must be no space between the predicate name and the left bracket ``(''. The whole thing also ends in a ``.'' as the last character on the line.

The exact rule for the termination of a clause is that a clause must end with a ``.'' followed by white space where white space can be any of {space,tab,newline,end_of_file}. It is safest to simply put ``.'' followed by newline.

Also note that relations do not need to hold between exactly two objects. For example,

```
meets(fred,jim,bridge)

```
```
fred meets jim by the bridge

```
Here, three objects are related so it makes little sense to think of the relation meets as binary ---it is ternary.

If we can relate two objects or three then it is reasonable to relate n where . Is there any significance to a relationship that relates one or even zero objects? A statement like

```
jim is tall

```
might be represented either as
```
tall(jim)

```
or
```
jim(tall)

```
It is, perhaps, preferable to see tallness as being a property which is possessed by jim.

A `relation' that has no arguments can be seen as a single proposition. Thus the binary relation ``france has_capital paris'' above might be rewritten as the statement ``france_has_capital_paris'' ---a relation with no arguments.

Next: Prolog Constants Up: Knowledge Representation Previous: First Order Predicate

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