PROLOG (PROgramming in LOGic) - Cheat Sheet

Under construction ...

PROLOG history

Prolog originated in France [University of Marseilles (Prolog : Manuel de Reference et d'Utilisation by P. Roussel, Groupe d'Intelligence Artificielle, Marseille-Luminy, 1975] as a language for deductively analyzing logical arguments.

Its implementation makes it a relatively simple tool for parsing problems which can be phrased in terms of relations which have a natural representation as tree structures. Two easily appreciated examples are - genealogy and English grammar.

It also has a powerful unification mechanism which allows quick prototyping of ``template'' or ``pattern matching'' systems.

Structure of a program

Here are three distinct ways of describing the form and actions of a Prolog program. (Other interpretations are also useful.)

Procedure View

Like normal imperative programming languages, a Prolog program consists of procedures, which are collections of statements. A program is executed by running a sequence of statements. Each of these statements executes by "calling" a procedure, which calls other procedures, etc.

/* file: */

fac(N,X) :- N > 0, M is N - 1, fac(M,Y), X is Y * N.

Logic View

A Prolog program consists of a collection of theorems (or rules) and axioms (its assertions). Running a program consists of asking a query (a set of "goals") to see if it is provable from the axioms by using the existing theorems.