Prolog

Prolog was created around 1972 off the back of the resolution principle. It was accepted as being based off Mathematical Logic due to the backward chaining from goal to subgoal that it employed (i.e. A goal can be proven if all of it's subgoals can be proven). Unlike a procedural language, a programmer supplies Prolog with a database of clauses, which can then be queried by the user, or by other programs.

 

A Prolog program is made up of three different things:

1)
Elements: Since Prolog has no notion of data types, data is considered as elements. Examples of elements are atoms, terms and lists (since they are defined recursively).
2)

Facts: A Prolog fact is a propositional sentence; that is a predicate informing the database of a relation which holds true. e.g. fun(logic). states that fun(logic) is true (trivially). The database could then be queried with

? - fun(logic).

yes.

3)
Rules: A rule (clause) in Prolog involves a head and a body. The logical form is body → head. That is, the head is the goal, and the body is a conjunction of subgoals. In Prolog, this is written head :- body. .

 

These three things are all that is required to produce a Prolog program, however there is extra syntax for various other concepts. Two of these concepts are not identical in Prolog to Mathematical Logic, namely Negation and Disjunction. Negation is often implemented using a technique called Negation as Failure which tries proving the formula being negated and upon reaching finite failure, treats the negated formula as true.

previous page next page