Prolog

| Main Article
| Discussion
| Definition [?]
| Related Articles  [?]
| Bibliography  [?]
| External Links  [?]
| Citable Version  [?]

|
|
|
|
|
|
|
|
|

This editable Main Article is under development and subject to a disclaimer.

[edit intro]

Prolog is a declarative language, and is a general-purpose  programming language. Prolog stands for "programming logic", and is built on the theory of horn clauses. Erlang is a language that shares some syntax with prolog. Prolog is most often used to program artificial intelligence applications such as expert systems. One of the more famous versions of prolog is Quintus Prolog. Other versions of Prolog include SWI-Prolog and GNU Prolog at www.gprolog.org. The classic text for Prolog is: Programming in Prolog by William F. Clocksin (Author), Christopher S. Mellish [1].

## Contents

* 1 Unification
* 2 Standard versions
* 3 See also
* 4 References

## Unification[edit]

One rather unique ability of prolog is called unification. Unification is a two way syntactic equality over terms(pattern matching) that happens within a prolog clause.

Ref:Roman Barták - Charles University, Prague (CZ) http://ktiml.mff.cuni.cz/~bartak \- lecture #3 - pg 2 \- Programming with Logic and Constraints. http://kti.mff.cuni.cz/~bartak/ESSLLI2005/files/lecture3.pdf

Two way means that it happens left to right and right to left. Variables on the left are unified with values on the right and variables on the right are unified with values on the left.

For example from gprolog:

[1,[2,C]] = [A,[2,3]].

A = 1
C = 3

yes

The prior statement would cause A to unify with(equal) 1, and C to unify with(equal) 3. Unification for this example would succeed once with the given values and then fail.

The following is an example of a constraint. An example from gprolog:

10 = 4 + 6.

The prior statement fails because this is a semantic (meaning) match rather than a syntactic (form) match. A constraint is able to understand the syntax and the semantics of a statement, and then tries to make it true. This is the difference between logic programming and Constraint programming. Erlang only unifies left to right with syntax. Python matches lists of variables but only with specific nested structures from left to right. Constraint programming is more powerful than unification, unification is more powerful than pattern matching, and pattern matching is more powerful than variable matching.

Constraints             > Unification > Pattern matching(one way) > variable matching
constraint programming  >   prolog    >    erlang                 > python (specific nesting)

Prolog makes computations by unifying over atomic facts and horn clauses that relate those facts with logical implications. Queries are made of a set of facts. The queries may give no answers, one or more correct answers, sometimes an infinite number of answers.

## Standard versions[edit]

At the Prolog command line we can use:
| ?- print('hello world!').
to produce:
hello world!

## See also[edit]

* Logic
* Erlang

## References[edit]

1. ↑ The classic text for Prolog is: Programming in Prolog by William F. Clocksin (Author), Christopher S. Mellish.