Prolog Article Index for
Prolog
Articles about
Prolog
Website Links For
Prolog
 

Information About

Prolog





Programming Information

  name Prolog
  paradigm Logic Programming
  year 1972
  designer Alain Colmerauer and Robert Kowalski
  implementations GNU Prolog , Quintus, SICStus, SWI-Prolog , YAP
  dialects ISO Prolog, Edinburgh Prolog
  influenced Mercury Programming Language , Oz


Prolog is a Logic Programming language. The name ''Prolog'' is taken from ''programmation en logique'' ( French for "programming in logic"). It was created by Alain Colmerauer and Robert Kowalski around 1972 as an alternative to the American-dominated Lisp Programming Language s. It was an attempt to make a Programming Language that enabled the expression of logic instead of carefully specified instructions on the Computer . In some ways Prolog is a subset of Planner , e.g., see Kowalski's early history of logic programming. The ideas in Planner were later further developed in the Scientific Community Metaphor .

Prolog is used in many Artificial Intelligence programs and in Computational Linguistics (especially Natural Language Processing , which it was originally designed for). Its syntax and semantics are considered very simple and clear. (The original goal was to provide a tool for computer-illiterate linguists.) A lot of the research leading up to modern implementations of Prolog came from spin-off effects caused by the Fifth Generation Computer Systems Project (FGCS) which chose to use a variant of Prolog named ''Kernel Language'' for their operating system (but this area of research is now actually almost defunct).

Prolog is based on First-order Predicate Calculus ; however it is restricted to allow only Horn Clause s. See Logic Programming for a discussion of the relationship of Prolog to Mathematical Logic . Execution of a Prolog program is effectively an application of theorem proving by First-order Resolution . Fundamental concepts are Unification , Tail Recursion , and Backtracking .


DATA TYPES

Prolog does not employ Data Type s in the way common programming languages usually do. We may rather speak about Prolog lexical elements instead of data types.


Atoms

The text constants are introduced by means of atoms. An atom is a sequence consisting of letters, numbers and underscores, which begins with a lower-case letter. Usually, if a non-alphanumeric atom is needed, it is surrounded with apostrophes (e.g. 'an atom containing spaces')..


Numbers

Most Prolog implementations do not distinguish integers from real numbers.


Variables

Variables are denoted by a string consisting of letters, numbers and underscore characters, and beginning with an upper-case letter or underscore. In the Prolog environment, a variable is not a container that can be assigned to (unlike Imperative Programming languages). Its behaviour is closer to a pattern, which is increasingly specified by Unification .

The so called ''anonymous variable'' (explained below), a wildcard which means 'any variable', is written as a single underscore (_).


Terms

Terms are the only way Prolog can represent complex data. A term consists of a head, also called functor (which must be an atom) and parameters (unrestricted types) listed within parentheses and separated by commas. The number of parameters, the so called Arity of term, is significant. A term is identified by its head and arity, usually written as functor/arity.


Lists

A list isn't a standalone data type, because it is defined by a recursive construction (using term '.'/2):

# atom {Link without Title} is an empty list
# if ''T'' is a list and ''H'' is an element, then the term '.'(''H'', ''T'') is a list.
The first element, called the head, is ''H'', which is followed by the contents of the rest of the list, designated ''T'' or tail.
The list 2, 3 would be represented internally as '.'(1, '.'(2, '.'(3, []))).
  Prepending Single Element: "abc" class="copylinks" target="_blank"> ''L1''
  Prepending Multiple Elements: "abc," class="copylinks" target="_blank">1, f(x) ''L2''
  Elems( "HT" class="copylinks" target="_blank">{Link without Title} , X) :- elems(T, Y), X is Y + 1
  Id( "xX" class="copylinks" target="_blank">{Link without Title} ,X)
  Assign Op( "=X" class="copylinks" target="_blank">{Link without Title} ,X)
  Digit( "2X" class="copylinks" target="_blank">{Link without Title} ,X)
  <stat Part> :: <statement> <stat_part> <statement>
  <expression> :: <operand> <expression> <operator> <operand>
  <operand> :: <id> <digit>
  <id> :: a b
  <operator> :: + -
  Split(H, "AX]," class="copylinks" target="_blank">[AY , Z) :-
  Split(H, "AX]," class="copylinks" target="_blank">Y, [AZ ) :-
  Quicksort( "HT" class="copylinks" target="_blank">{Link without Title} , S, X) :-
  Quicksort(A, S, "HY" class="copylinks" target="_blank">{Link without Title} ),
  { Class "wikitable"