Topic:

Prolog

Location:

Artificial Intelligence : Logic : Logic Programming : Languages

Author:

Jason Waltman

Date:

28 June 1999

Revisions:

DRAFT 21 July 1999 (1.0.1)

Prolog is a rule-based, declarative programming language. Unlike other languages where a program’s solution is determined by the ordering of code, in Prolog, facts and rules are stated and the program itself determines how to solve the problem. The use of Prolog is most common in expert system design and other artificial intelligence research, but recently has been useful in industrial domains as well.


Overview

Prolog, as well as logic programming in general, originated around 1970, mostly from the research of Alain Colmerauer (in natural language processing) and Robert Kowalski (in automatic theorem proving). Colmerauer had hopes of creating a natural language processing system, however he found the task to be harder than expected. With the help of a few other scientists (Kowalski, Robert Floyd), he turned his efforts toward a general-purpose programming language. Headed by Colmerauer, the first official Prolog implementation was completed in 1973, at the University of Marseilles, France.

Given its unusual background, it’s not difficult to understand why Prolog is so unique. Prolog is a rule-based programming language, based on the declarative paradigm. In this paradigm the order of code does not determine the correct operation of the program (in contrast to more common paradigms). Instead, rules are used to express relationships and those relationships are used to arrive at a solution.


Description & Analysis

A program written in Prolog is really nothing more than a carefully designed problem description that can be executed. The programmer gives a set of facts that relate--in the real world--to objects. In addition, there is a set of rules that give relationships of objects to one another. Beginning with a question, a Prolog program will execute as directed by the applicable subset of facts and rules. The actual order of the facts and rules in the code does not determine the solution to the problem. (Note the difference between Prolog and traditional languages in which the programmer must write the code in the order that it will be executed to solve the problem.)

As an example, suppose we have the facts: "Andy is a goalie," and "Matt plays soccer." Also suppose that we have the following rule: "If someone is a goalie, then he/she plays soccer." If our program were to ask the question "Who plays soccer?" the answer would be Andy and Matt. The program would match Andy to soccer through the use of the rule. It is easy to see how with additional rules and facts, Prolog can be a powerful tool. Also important to note is Prolog works under a "closed world assumption." That is, Prolog only knows the information in the logic-base. If we were to ask, "Does Andy play hockey?" the answer returned from Prolog would be No, although Andy, being a goalie, might actually play Hockey as well--the logic-base just doesn’t know that.

When first developed, the language was used exclusively in academic and artificial intelligence (AI) research. At that time, Prolog was used in applications such as expert systems, knowledge bases, human-computer interaction, and the analysis of natural language. Today however, besides being used in AI research, Prolog is being used to develop important industrial and commercial applications. Example domains include: finance, insurance, medicine, law, agriculture, defense, transportation, documentation, planning and scheduling, database management, and diagnostics.

Prolog has been standardized by ISO. Absent however from the current standard, is support for object-oriented programming.


Commercial Products

SICStus Prolog / Quintus Prolog - Swedish Institute of Computer Science
http://www.sics.se/sicstus/
http://www.sics.se/quintus/

SICStus Prolog is available for many UNIX platforms, as well as the Windows (9x, NT), OS/2, and Macintosh operating systems. Support is provided for stand-alone and embedded applications; modules; coroutines; exception handling; unbounded precision integer arithmetic; and bi-directional interfaces to C/C++, Java, and Visual Basic. Among others, library modules are provided for object-oriented programming and communication with Tcl/Tk, for graphical user interface construction. SICStus Prolog is mostly used as a research system.

Quintus Prolog is available only for the UNIX and Windows (9x, NT) platforms. Both stand-alone applications and modules, that can be linked to programs written in other languages, can be created. Quintus Prolog has a richer set of library modules than SICStus Prolog, including TCP (Network Communications Package) and interfaces to X Windows. Support is provided for embeddability in C/C++ and interface to the C/C++ (bi-directional), FORTRAN, and Pascal languages. The UNIX version has a visual development environment and tools for building graphical user interfaces, debugging and optimizing programs, and memory management. Add-ons are available for development of graphical interfaces, database interfaces, and expert systems. An object oriented programming extension is available as well. By design, Quintus Prolog is more common in an industrial setting.

WIN-PROLOG / MacProlog32 - Logic Programming Associates
http://www.lpa.co.uk/

These packages from Logic Programming Associates are 32-bit Prolog compilers for the Windows (95, NT, 3.1) and Macintosh operating systems. Both use an incremental compiler, which provide interpreted behavior, but faster execution time. WIN-PROLOG and MacProlog32 can be used independent of other applications to develop software, however also both have links to C/C++, Delphi, Visual Basic, and Java. Optional add-on software is available to aid in topics such as building expert systems, object-oriented programming, and designing user-interfaces.

Visual Prolog - Prolog Development Center
http://www.visual-prolog.com/

Visual Prolog is an integrated development environment for creating independent applications with a graphical user interface (GUI), or integrating Prolog code with other languages. Visual Prolog includes features such as: input/output procedures, arithmetic and string manipulation functions, external database support, and a visual programming interface for creating portable GUI applications. GUI support is available for DOS, Windows (3.x, 9x, NT), and OS/2 (2.x and higher) platforms. Text-mode, command-line, and CGI script support is available for SCO UNIX and Linux platforms.

Prolog + Logic Server - Amzi!
http://www.amzi.com/

The Logic Server provides a means of accessing a logic-base of rules from a wide variety of development tools including C/C++, Java, Visual Basic, Delphi, Excel, and Access, through an application program interface. In addition, Prolog can be extended to call code written C/C++ or Delphi, or link to other libraries. Prolog components are written, tested, and debugged using an interactive development environment (Windows version), or through command-line tools. Support is available for Windows (3.x, 95, NT), DOS, and Solaris operating systems.


Useful Links

Logic Programming
http://www.logic-programming.org/

This site contains many links relevant to the use of Prolog in logic programming. Included are descriptions of case studies in which Prolog is being used, as well as links to vendors, FAQs, people working in the field, papers, and access to the ISO Prolog standard.

CMU Prolog Repository
http://www.cs.cmu.edu/ afs/cs.cmu.edu/project/ai-repository/ai/lang/prolog/0.html

Site maintained and located at the School of Computer Science at Carnegie Mellon University. Includes various Prolog code, documentation, freeware and shareware implementations, technical reports and papers, and miscellaneous utilities for programming in Prolog.

Logic Programming at Oxford University
http://www.comlab.ox.ac.uk/archive/logic-prog.html

Contains links to Logic Programming repositories of a variety of organizations and universities, as well as related meetings. Links to various platform implementations of Prolog (some free) are also included. Site maintained by the Oxford University Computing Laboratory.

Prolog Tutorial
http://www.csupomona.edu/ ~jrfisher/www/prolog_tutorial/contents.html

This site contains a thorough tutorial by Professor of Computer Science John R. Fisher at the California State Polytechnic University, in Pomona. Many sample programs are included.

email at jasonwaltman dot com

(c) 2000-2007 jason waltman