9.7 Summary


Facts make up the program database of a simple Prolog program. A fact consists of a term and a period. The term can't be a variable.


Queries are questions written in the syntax of Prolog. A query must be terminated with a period. We don't write the initial "?-" because the Prolog system does this for us. The answer can either be


meaning "Yes", or it can be


meaning "No". (This is a slight simplification, which we will have occasion to correct below.)


A query is made up of one or more subgoals. When Prolog attempts to answer a query, it tries to satisfy the subgoals. All of the subgoals in the query must be satisfied for the query to succeed.


Matching is the process used when satisfying subgoals. We will get back to matching in detail later.


Variables are names we give to memory storage locations within the computer. They are used to refer to values which we wish to compute. A variable can be free, meaning it does not have a value, or it can be bound, meaning it has been given a value. When answering queries whose subgoals contain variables, the result is a list of variable bindings, such as the following:

{X = 5}

Structures within structures

Because the arguments of a structure are terms, and since structures are also terms, it follows that we can have structures within structures.

PrevLite: 9.5 Variables
NextLite: 9.8 Quiz: A simple Prolog program

Prev: 9.6 Structures within structures (Ad)
Up: 9 A simple Prolog program
Next: 9.8 Quiz: A simple Prolog program