Previous Table of Contents Next


Part V
Prolog

6  Prolog: Programming in Logic

Chapter 6
Prolog: Programming in Logic

by James H. Andrews

Prolog had a quiet birth but a tumultuous childhood. Developed in 1972, it became widely known only two years later and quickly became a topic of controversy. Even today, Prolog can provoke surprisingly strong feelings in some people, comparable to those around languages such as COBOL and Smalltalk.

Yet Prolog is just another programming language. It has its strengths and its weaknesses, application areas where it shines and application areas where it is best passed over. It brings a new perspective to many problems, and many programmers find it a useful addition to their toolkit. In these respects, it is no different from any other programming language.

However, in several respects, Prolog does differ from most other languages. It has a useful and powerful pure subset in which programs can be read as logical formulas. This pure subset allows us to solve problems by expressing the conditions under which a solution exists, without explicitly stating how to find the solution. This property allows a succinct and readable expression of tasks in problem domains with an inherently logical structure, such as deductive systems. Programs are naturally expressed using pattern-matching clauses, making Prolog ideal for such tasks as parsing and translating.

The programmer has to be aware, however, of how a running Prolog program does find a solution; this Prolog execution model, which is more complex than the imperative or functional model, is the main stumbling block in learning to use Prolog effectively. Prolog is not dogmatic about logic. Impure, extralogical additions allow us to circumvent the rigidity of logic whenever we need to, in the spirit of a truly pragmatic programming language.

6.1. History and Background

6.1.1. The Early Days

Prolog was invented in the early 1970s by Alain Colmerauer and was implemented by him and his group at the University of Marseilles around 1972. Its name was chosen as a contraction of programmation en logique, which translates to programming in logic. It was a practical embodiment of ideas that were being explored at the same time by Robert Kowalski in Edinburgh. Several other researchers, such as Elcock, Boyer, and Moore, had also studied programming involving logic, but mainly in a functional programming setting. When Kowalski encountered Prolog, he wrote an article for a prominent conference in 1974 that described these new ideas of “predicate logic as a programming language” to the world. Thus the logic programming paradigm was born.

At the time, the dialog in the artificial intelligence community was dominated by the battle of the “neats ” and the “scruffies” in North America. The neats, typified by John McCarthy, wanted to do artificial intelligence (AI) by formulating broad theories based on principles; the scruffies, typified by Marvin Minsky, wanted to do AI by writing heuristic programs that worked, regardless of principles. Prolog quickly became a football in this battle. The neats praised it for allowing logical thought to be expressed more directly than in other programming languages, and the scruffies criticized it for being slow and pedantic.

Many neats became disenchanted with Prolog, however, when it became clear that most implementations used incomplete reasoning and had features that were not in accord with the neats’ strict logical principles. That disenchantment, coupled with the perception that Prolog was exclusively an AI language and the lack of a strong academic tradition in Prolog in North America, led to it being largely rejected by North American computer science. It still enjoys popularity outside North America, however, and among a fair number of people in North America who are interested in symbolic computing.

Researchers interested in Prolog continued to develop the language after its initial release. The first implementation of Prolog to leave Marseilles was an interpreter written in Fortran. The early culmination of the development was the C-Prolog interpreter of the early 1980s, developed at the Artificial Intelligence department of the University of Edinburgh. C-Prolog was based on earlier work by David H. D. Warren, Fernando Pereira, Luis Pereira, and others. It was the first widely available Prolog with a usable debugger and extensive library. Its syntax and library became a de facto standard and are often referred to together as Edinburgh Prolog.

In the mid-1980s, the software company Borland marketed Turbo Prolog, a cut-down and somewhat modified version of the language for IBM PC-compatibles. C-Prolog and Turbo Prolog, although somewhat obsolete, were very useful and are still the first (or only) implementations of Prolog many people have encountered.


Previous Table of Contents Next