History of AI

What is Prolog, and why did AI researchers build a language out of logic?

· By Robert Scales · 5 min read

Short answer

Prolog, short for the French "programmation en logique," is a programming language created in Marseille in 1972 by Alain Colmerauer and Philippe Roussel, in which you describe facts and rules and the computer answers questions by searching for a logical proof. It became one of the two main languages of symbolic AI, alongside Lisp, and the foundation of Japan's Fifth Generation computer project.

Most programming languages ask you to spell out steps: do this, then this, then repeat. Prolog asks something different. You tell it what is true, in the form of facts and rules, and then you ask it a question. The language itself does the work of figuring out whether the answer follows from what you said, and if so, how.

That idea came out of a small team in Marseille, France, in 1971 and 1972. Its leaders, Alain Colmerauer and Philippe Roussel, were not trying to invent a programming language at all. They wanted a computer that could read sentences in French, reason about them, and answer questions. Prolog was the tool they built along the way.

What happened in Marseille

Colmerauer had spent three years in Canada, where he led the University of Montreal's machine translation project and designed a rule-rewriting language called Q-systems. In 1970 he returned to France and started a project at the new science faculty of Luminy in Marseille. Roussel and Robert Pasero, both 25, joined him, along with Jean Trudel, a Canadian doctoral student who worked on automated theorem proving, meaning programs that check whether a statement follows logically from others.

In 1971 the team built a first question-answering system. It could take sentences such as "Tom is a cat" and "Cats kill mice," and then answer "What does Tom do?" The reasoning part ran on one of Roussel's theorem provers.

The key outside influence was Robert Kowalski of the University of Edinburgh. He visited for a week in June 1971 and for two months in spring 1972, and he brought a proof method called SL-resolution. Its step-by-step way of working looked a lot like how ordinary programs call procedures, which made it practical to run on a computer.

In the fall of 1972, Roussel wrote the first Prolog system in a language called Algol-W, while Colmerauer and Pasero used it, as it took shape, to write a French conversation program. That program had 610 clauses, the basic statements of a Prolog program. Henry Kanoui contributed 104 of them, which handled French word endings. Roussel chose the name, an abbreviation of PROgrammation en LOGique, and the two authors also credit a suggestion from his wife.

In 1973 the team designed a simpler second version, written in Fortran by Gérard Battani, Henry Méloni and René Bazzoli. Accounts differ here: Colmerauer and Roussel call the 1972 Algol-W program the first Prolog, while some summaries name the Fortran interpreter as the first implementation. Both agree that the 1973 version is the one that spread. Copies traveled to Edinburgh, Budapest, Warsaw, Montreal, Waterloo and Leuven, often carried home by visitors. As the authors put it, Prolog "was not really distributed; rather it 'escaped' and 'multiplied'."

How Prolog works

A Prolog program has two kinds of statements. A fact says something is true. A rule says something is true if other things are true. Then you ask a query, and Prolog tries to prove it.

Here is a tiny family program:

parent(ana, ben).
parent(ben, chloe).
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).

The first two lines are facts: Ana is Ben's parent, and Ben is Chloe's parent. The third line is a rule. Read the :- as "if": X is a grandparent of Z if X is a parent of some Y and that Y is a parent of Z. Words starting with a capital letter are variables, placeholders that Prolog fills in.

Now ask ?- grandparent(ana, Who). Here is what Prolog does:

StepProlog's goalWhat happens
1grandparent(ana, Who)Matches the rule, so it now needs parent(ana, Y) and parent(Y, Who)
2parent(ana, Y)Finds the fact parent(ana, ben), so Y becomes ben
3parent(ben, Who)Finds parent(ben, chloe), so Who becomes chloe
4DoneAnswers: Who = chloe

If a step had failed, Prolog would back up to the last choice it made and try the next option. That habit of retreating and trying again is called backtracking, and it is the engine under every Prolog program. The matching of a goal against a fact or rule head, which fills in the variables, is called unification.

Try it: Install a free Prolog system such as SWI-Prolog, type in the three lines above, then add parent(chloe, dan). and write a rule for greatgrandparent. Ask who Ana's great-grandchild is.

Why it mattered

Prolog turned an idea from logic into a working tool. Kowalski later showed that the strategy the Marseille team chose is complete for a restricted kind of rule called Horn clauses, which gave the language a solid theoretical footing. David Warren in Edinburgh wrote the first Prolog compiler, DEC-10 Prolog, with Fernando Pereira, and his syntax became the one most later versions follow.

In the 1970s and 1980s, European AI researchers tended to favor Prolog while American labs favored Lisp, and the rivalry was lively. Prolog suited tasks built on rules: parsing sentences, querying databases, symbolic mathematics and expert systems. In 1982 Japan chose logic programming as the core of its ambitious Fifth Generation computer project. An international standard for the language followed in 1995.

Seen from 2019, Prolog belongs to the "symbolic" branch of AI, where knowledge is written down explicitly as rules a person can read. Most of today's headline AI, such as the language models that predict text, learns patterns from data instead. The two approaches answer different needs: a learned model is good at fuzzy tasks like recognizing speech, while a logic program gives answers you can trace back, step by step, to the facts that justify them.

Is Prolog still worth learning for someone interested in AI?

Yes, if you want to understand how reasoning can be made mechanical. Writing even a small Prolog program forces you to state your knowledge precisely, and watching it backtrack teaches you what search means in AI better than any diagram. Free, well-maintained systems such as SWI-Prolog run on ordinary laptops.

It is less useful if your goal is to build machine-learning models, which are mostly written in Python. Still, the ideas carry over. Rule engines, database query languages and type checkers in many modern tools borrow Prolog's style of matching patterns and searching for answers.

A good path for a beginner is to spend a weekend with Prolog: write family trees, a small map-coloring puzzle and a short grammar that checks simple sentences. You will come away with a clear picture of what "symbolic AI" meant to the researchers of the 1970s and 1980s, and a sharper sense of what today's learning systems do differently.

Sources

  1. The birth of Prolog — Alain Colmerauer and Philippe Roussel (later in ACM SIGPLAN Notices 28(3), 1993), November 19, 1992
  2. Prolog — Wikipedia (archived August 2019), August 21, 2019

Get the free Guide to Artificial Intelligence

Sign up for the weekly newsletter and receive the free guide: what changed in AI this week, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement