1.1.1 Knowledge Base 1

Knowledge Base 1 (KB1) is simply a collection of facts. Facts are used to state things that are unconditionally true of the domain of interest. For example, we can state that Mia, Jody, and Yolanda are women, and that Jody plays air guitar, using the following four facts:

woman(mia).
woman(jody).
woman(yolanda).
playsAirGuitar(jody).

This collection of facts is KB1. It is our first example of a Prolog program. Note that the names mia, jody, and yolanda, and the properties woman and playsAirGuitar, have been written so that the first letter is in lower-case. This is important; we will see why a little later.

How can we use KB1? By posing queries. That is, by asking questions about the information KB1 contains. Here are some examples. We can ask Prolog whether Mia is a woman by posing the query:

?- woman(mia).

Prolog will answer

yes

for the obvious reason that this is one of the facts explicitly recorded in KB1. Incidentally, we don't type in the ?-. This symbol (or something like it, depending on the implementation of Prolog you are using) is the prompt symbol that the Prolog interpreter displays when it is waiting to evaluate a query. We just type in the actual query (for example woman(mia)) followed by . (a full stop).

Similarly, we can ask whether Jody plays air guitar by posing the following query:

?- playsAirGuitar(jody).

Prolog will again answer ``yes'', because this is one of the facts in KB1. However, suppose we ask whether Mia plays air guitar:

?- playsAirGuitar(mia).

We will get the answer

no

Why? Well, first of all, this is not a fact in KB1. Moreover, KB1 is extremely simple, and contains no other information (such as the rules we will learn about shortly) which might help Prolog try to infer (that is, deduce whether Mia plays air guitar. So Prolog correctly concludes that playsAirGuitar(mia) does not follow from KB1.

Here are two important examples. Suppose we pose the query:

?- playsAirGuitar(vincent).

Again Prolog answers ``no''. Why? Well, this query is about a person (Vincent) that it has no information about, so it concludes that playsAirGuitar(vincent) cannot be deduced from the information in KB1.

Similarly, suppose we pose the query:

?- tatooed(jody).

Again Prolog will answer ``no''. Why? Well, this query is about a property (being tatooed) that it has no information about, so once again it concludes that the query cannot be deduced from the information in KB1.


Patrick Blackburn, Johan Bos and Kristina Striegnitz
Version 1.2.5 (20030212)