PROLOG

PROLOG

Bernie Garrett (University of British Columbia, Canada)
DOI: 10.4018/978-1-60566-026-4.ch502
OnDemand PDF Download:
$30.00
List Price: $37.50

Abstract

Prolog is a logic based programming language, and was developed in the early 1970s and is a practical programming language particularly useful for knowledge representation and artificial intelligence (AI) applications. Prolog is different from many common computer languages in that it is not a procedural language (such as Basic, C, or Java). It is an interpreted logic based declarative language and as such has no loops, jumps, type declarations or arrays, and no fixed control constructs. In the past this has led to the impression that Prolog is a restricted language, useful only for highly specialized programming tasks by enthusiasts (Callear, 1994; Krzysztof, 1997). However, this is not the case and modern versions of Prolog are well equipped and versatile, and can be used for any programming task. The latest generations of the language (e.g., Visual Prolog) can also be integrated into more common object oriented languages.
Chapter Preview
Top

Background

Origins

The development and growth in the use of prolog has followed the expansion of interest in artificial intelligence and knowledge based/expert systems. These are computer systems that simulate human cognitive processes, and incorporate large volumes of information in a database using rules to attempt to encapsulate this information as knowledge (or the knowledge of a human expert in the case of expert systems).

Prolog was developed by Alain Colmerauer of Marseilles University, and Robert Kowalski of the University of Edinburgh, in the early 1970s as an alternative to the American Lisp programming languages (early mathematical notation based languages), and Planner (a procedural language representing “knowledge” in the form of high level procedural plans). Kowalski, was a primary advocate in the logic paradigm community (see Fundamental Ideas), and in collaboration with Alain Colmerauer they created a subset of the language “micro planner” called Prolog, Kowalski hoped to demonstrate with Prolog that the logic paradigm was a viable approach to programming. It was Philippe Roussel (also at Marseilles University) who came up with the name as an abbreviation for “PROgrammation en LOGique” to refer to this software tool which was originally devised as a man-machine interface using natural language.

Key Terms in this Chapter

Variables: Are quantities that can take any value, and in Prolog are introduced as strings of characters starting with a capital letter. For example, “animal” is an atom in Prolog whereas “Animal” is a variable and can be instantiated for any animal.

Recursion: In Prolog, recursion appears when a predicate contain a goal that refers to itself. When a rule is called Prolog creates a new query with new variables. A recursive definition always has at least two parts: facts that act like a stopping condition, and a rule that calls itself.

Atom: A group of alphabetical characters in Prolog, similar to a string in other languages

Argument: A word or phrase that occurs in brackets after the head of the predicate, that makes up a fact in the Prolog database (really a predicate consists of a head and one or a number of arguments) for example, in this predicate “animal(mammal).” Mammal is the argument.

Rules: Are another type of statement made in Prolog (along with facts) and are also called “clauses.” Rules are really extensions of facts in Prolog, with added sub-goals that also have to be satisfied to be found true by the interpreter. A rule consists of a head (a predicate and argument) and a body (sub-goals) separated by the:- symbol. For example, fault (electric):- car_will_not_start,no_lights. This rule has two sub-goals which must both be found in the database for the rule to succeed (the car will not start and has no lights).

Predicate: Consists of a word in the Prolog database which succeeds in the Prolog interpreter by writing its argument. It consists of a predicate head (an atom) and one, or a number of arguments. The predicate is the basic unit of Prolog and is always defined to be true. Prolog has some standard built in Predicates to help in programming, such as “write” for example “write(jane).” Will succeed and Prolog will respond “Jane yes.”

Iteration: In computing is the repetition of a process within a computer program. It can be used both as a general term, synonymous with repetition, and to describe a specific form of repetition with a mutable state.

Facts: A type of statement made in Prolog. After you supply a database of facts and rules; and can then perform queries on the database. Facts consist of a predicate head and argument. For example “cat(meows).” could be a fact entered in the database that a cat meows. Facts together with rules are also known as “clauses.”

Occurs Check: A system built into some versions of Prolog to avoid never-ending loops with unification. Whenever an attempt is made to unify a variable with a compound term, a check is made by the system to see if the variable is contained within the structure of the compound term, and if this is so, the unification will fail. For efficiency most versions of Prolog do not perform an occurs check.

Complete Chapter List

Search this Book:
Reset