Prolog Programming

Prolog is a language based upon programming in logic. It is possible because Alan Robinson's resolution theorem prover can be implemented efficiently. Prolog does not have a notion of a program as such. There is a database of facts and rules. Rules are Horn clauses with a head consisting of a single functor and a body which can be a disjunction of terms. A fact is a rule whose body is empty (or more properly the single term true.

Goals and Goal Satisfaction

A goal is a conjunction a1,a2, ..., an of terms. To satisfy a goal the prolog inference engine chooses the leftmost term in the goal (a1 in this case) and tries to match it with a clause in the database. If such a clause (eg).

a1 :- b1,b2,b3.

is found then a1 in the goal is replaced by the body of the clause so that the goal becomes.

b1,b2,b3,a2, ..., an

Note that if the clause is a fact then the matched head is discarded.

The goal is satisfiable if this process continues until the goal is empty. If a particular choice of matching clause fails the system backtracks and uses the next clause in the database that matches.

A summary of the Prolog Language and how to use it. This is a work in progress. Various techniques of prolog programming are described in this collection. Amongst these are


Jonathan Hodgson
Last Change: 23/11/1994

To return to the AI home page click AIHOME.