Prolog

Prolog is a logic programming language that has its origins in artificial intelligence, automated theorem proving and computational linguistics.

[11][12] Prolog is a Turing-complete, general-purpose programming language, which is well-suited for intelligent knowledge-processing applications.

The name Prolog was chosen by Philippe Roussel, at the suggestion of his wife, as an abbreviation for Programmation en logique (French for Programming in logic).

[13] It was created around 1972 by Alain Colmerauer with Philippe Roussel, from the Artificial Intelligence Group of the Faculty of Sciences of Luminy of Aix-Marseille II University of France.

It was based on Robert Kowalski's procedural interpretation of Horn clauses, and it was motivated in part by the desire to reconcile the use of logic as a declarative knowledge representation language with the procedural representation of knowledge that was popular in North America in the late 1960s and early 1970s.

[14][15][16] The first implementation of Prolog was an interpreter written in Fortran by Gerard Battani and Henri Meloni.

Pure Prolog was originally restricted to the use of a resolution theorem prover with Horn clauses of the form: The application of the theorem-prover treats such clauses as procedures: Pure Prolog was soon extended, however, to include negation as failure, in which negative conditions of the form not(Bi) are shown by trying and failing to solve the corresponding positive conditions Bi.

Subsequent extensions of Prolog by the original team introduced constraint logic programming abilities into the implementations.

"[22] Software developed in Prolog has been criticised for having a high performance penalty compared to conventional programming languages.

In particular, Prolog's non-deterministic evaluation strategy can be problematic when programming deterministic computations, or when even using "don't care non-determinism" (where a single choice is made instead of backtracking over all possibilities).

Cuts and other language constructs may have to be used to achieve desirable performance, destroying one of Prolog's main attractions, the ability to run programs "backwards and forwards".

[24] The order of clauses in a Prolog program is significant, as the execution strategy of the language depends on it.

Watson uses IBM's DeepQA software and the Apache UIMA (Unstructured Information Management Architecture) framework.

[note 1] Special cases of compound terms: Prolog programs describe relations, defined by means of clauses.

As a general purpose language, Prolog also provides various built-in predicates to perform routine activities like input/output, using graphics and otherwise communicating with the operating system.

Execution of a Prolog program is initiated by the user's posting of a single goal, called the query.

Example of a basic query in a couple of popular Prolog dialects: This comparison shows the prompt ("?-" vs "| ?-") and resolution status ("true".

[39] Some systems chose to implement module concepts as source-to-source compilation into base ISO Prolog, as is the case of Logtalk.

Most notably, the rewriting equips the predicate with two additional arguments, which can be used to implicitly thread state around,[clarification needed] analogous to monads in other languages.

Its implicit execution strategy makes it possible to write a concise meta-circular evaluator (also called meta-interpreter) for pure Prolog code: where true represents an empty conjunction, and clause(Head, Body) unifies with clauses in the database of the form Head :- Body.

For example, Sterling and Shapiro present a meta-interpreter that performs reasoning with uncertainty, reproduced here with slight modifications:[43]: 330 This interpreter uses a table of built-in Prolog predicates of the form[43]: 327 and clauses represented as clause_cf(Head, Body, Certainty).

Pure Prolog is based on a subset of first-order predicate logic, Horn clauses, which is Turing-complete.

[53][54] Some Prolog systems, such as WIN-PROLOG and SWI-Prolog, now implement hashing to help handle large datasets more efficiently.

Some Prolog systems, (B-Prolog, XSB, SWI-Prolog, YAP, and Ciao), implement a memoization method called tabling, which frees the user from manually storing intermediate results.

If a subgoal is re-encountered, the evaluation reuses information from the table rather than re-performing resolution against program clauses.

During the Fifth Generation Computer Systems project, there were attempts to implement Prolog in hardware with the aim of achieving faster execution with dedicated architectures.

[61] A more recent approach has been to compile restricted Prolog programs to a field programmable gate array.

It is suited to large-scale combinatorial optimisation problems[75] and is thus useful for applications in industrial settings, such as automated time-tabling and production scheduling.

Oblog is a small, portable, object-oriented extension to Prolog by Margaret McDougall of EdCAAD, University of Edinburgh.

Objlog was a frame-based language combining objects and Prolog II from CNRS, Marseille, France.

Timeline of some early Prolog systems, up to the ISO Standard
Prolog Heritage.
Systems with a dark gray background are not supported any more. Arrows denote influences and inspiration of systems. Quick legend: JIT = "Just in Time Compiler", JVM = "Java Virtual Machine", TOAM = "Tree-Oriented Abstract Machine"