I want to finish with some terminology. So far, I've talked about
the ``verb'' in a fact, such as loves
or suits
or
has_duty
. This is not a very good name, because the word often doesn't
take the form of a verb. It may for example be a preposition or a
preposition plus a verb, such as february is_after january
.
Programmers often write like this when describing spatial or temporal
relationships.
In future therefore, I shall borrow the terminology of
formal logic, and call this part of a fact the predicate. All the
Prolog literature uses this name.
The things in brackets are the predicate's arguments. So,
in john loves mary
, the arguments are john
and mary
. This is a
specialised meaning of ``argument'', and it has nothing to do with
disputes or disagreements; again, it comes from logic.
I shall use the word rule to mean a conditional fact from now
on, that is one containing an if
. Prolog is not the only type of
programming system to use ``if ...then ...'' statements; many
expert systems and other AI programs do too, and such statements are
generally referred to as rules.
When I want to talk about an unconditional fact (no if
) I shall
say so specifically; I shall use the word fact on its own to mean
either. Sometimes I may use the word clause instead of fact,
following the custom of the Prolog literature.
I shall also talk about defining a predicate. In logic programming, the meaning of a predicate is defined solely by the clauses for it. There is no other authority Prolog can appeal to; it does not have an internal encyclopaedia telling it what a predicate ``ought'' to mean (apart from a very few ``built-in'' predicates, which you'll meet later).
Predicate definitions can be of two kinds. Some are what logicians call intensional: they consist of a general rule or two which try to capture the essence of (say) what it means for one person to be the ancestor of another, or what it means for one number to be the factorial of another. You will see some of these in Lesson 2. For example, if Bert is an ancestor of Charles, and Amanda of Caroline, there is something in common about the way both are related. Bert has a child who is Charles, or who has a child who is Charles, or who has a child who is Charles, ...Amanda has a child who is Caroline, or who has a child who is Caroline, or who has a child who is Caroline, .... To write intensional definitions, you have to extract these structural regularities and work out how to formalise them in logic.
Other predicates
are extensional. Here, the definition is
often just a long list of unconditional facts. For example, the facts
you accumulated about loves
in Lesson 1. Expert system rules for
domains like medicine are often of this form; lacking a decent theory of
the underlying principles, all you can do is to write down all the rules
of thumb that experts have built up by experience. The knowledge bases
of the skiing and disease exercises are of this kind.
In either case, the definition of a predicate will consist of one or more clauses. Each clause will express some part of the meaning, but you need them all in order for the definition to be complete.