Skip to content
— CH. 1 · INTRODUCTION —

Prolog

~8 min read · Ch. 1 of 7
7 sections
  • Prolog asks a strange question of any programmer who encounters it for the first time: what if, instead of telling a computer how to do something, you simply told it what is true? That question sits at the heart of a language born in 1972 at the Faculty of Sciences of Luminy, part of Aix-Marseille II University in France. Alain Colmerauer and Philippe Roussel built Prolog not as a conventional tool for writing step-by-step instructions, but as a way to encode facts, rules, and relations, then let the machine figure out how to reason through them.

    The name itself was Philippe Roussel's invention, chosen at the suggestion of his wife. Programmation en logique: programming in logic. That phrase captured something genuinely different. Most languages of the era told a machine what to do, in what order, by what means. Prolog told it what was true, and trusted it to find the answer.

    Where did this idea come from, and why did it split the computing world along national lines? How does a language built on logical inference end up inside Watson, the IBM system that defeated human champions on Jeopardy? And what does it mean that Prolog remains, more than half a century after its creation, the most popular logic programming language in existence?

  • Robert Kowalski supplied the theoretical backbone that made Prolog possible. His procedural interpretation of Horn clauses gave Colmerauer and Roussel the bridge between formal logic and executable computation. A Horn clause of the form H :- B1, ..., Bn reads as a procedure: to prove H, prove B1 and then B2 and so on through Bn. That simple reading transformed a mathematical formalism into something a computer could act on.

    The first working Prolog system was implemented in 1972. Gerard Battani and Henri Meloni wrote the original interpreter in Fortran. David H. D. Warren then carried that interpreter to the University of Edinburgh, where he built a new front-end that defined the Edinburgh Prolog syntax still used by most implementations today. Warren also created the first Prolog compiler, the DEC-10 Prolog, in collaboration with Fernando Pereira. His later work generalised those ideas into the Warren Abstract Machine, a design that went on to influence how Prolog code is compiled across many subsequent systems.

    Prolog's early history was not purely academic. It grew partly from a desire to reconcile two competing philosophies of knowledge representation. In North America during the late 1960s and early 1970s, the dominant approach treated knowledge procedurally. Prolog's creators wanted to show that a declarative approach, grounded in logic, could do the same work. That tension between the two camps never fully resolved, and it would soon play out on a geopolitical stage.

  • European AI researchers threw their weight behind Prolog. American researchers favored Lisp. The rivalry reportedly generated something the source describes as many nationalistic debates on the merits of the two languages. Behind those debates lay a genuine philosophical disagreement about what a program should be: a set of instructions, or a body of knowledge.

    The debate found its most concrete expression in Japan. The Fifth Generation Computer Systems project, known as FGCS, chose a Prolog variant called Kernel Language as the foundation of its first operating system. The project aimed at ambitious performance targets: machines operating at between 0.1 and 1 GLIPS, or giga logical inferences per second. In 1982, the benchmark for conventional machines sat at between 10,000 and 100,000 logical inferences per second, so the targets represented a leap of several orders of magnitude. The Institute for New Generation Computer Technology estimated that one logical inference required roughly 100 operations on a conventional machine. The plan was to end the project in 1992 with a machine running 1,000 processors and achieving 1 GLIPS in total, which meant at least 1 MLIPS per processor.

    The FGCS also prompted much of the modern development of Prolog, injecting energy and resources into the language at a moment when it might otherwise have remained a research curiosity. Sega, meanwhile, took the language in a different direction entirely. In 1986, the company released the Sega AI Computer for the Japanese market, using Prolog to parse natural language input in Japanese via a touch pad.

  • At runtime, execution begins with a single goal posted by the user, called the query. The Prolog engine then tries to find a resolution refutation of the negated query using a method called SLD resolution. If the negated query can be refuted, the original query is a logical consequence of the program, and the engine reports all generated variable bindings to the user.

    When multiple clause heads can match a given call, the system creates a choice-point, tries the first alternative, and continues. If any goal fails during execution, the engine discards all variable bindings made since the most recent choice-point and tries the next alternative. This strategy is called chronological backtracking, and it gives Prolog programs a distinctive quality: the ability to run, in a sense, both forwards and backwards across the relations they define.

    Negation works through a mechanism called negation as failure. The built-in predicate \+/1 attempts to prove a goal and succeeds precisely when that proof cannot be found. This allows non-monotonic reasoning but comes with a limitation: the approach is sound only when the argument contains no unbound variables. An unbound variable opens the door to incompleteness in a way that can surprise programmers accustomed to conventional logic.

    Iterative algorithms are expressed through recursive predicates rather than loops. An ancestor relation, for instance, can be defined in two clauses: X is an ancestor of Y if X is a parent of Y, or if X is a parent of some Z who is itself an ancestor of Y. The second clause calls the predicate it is defining, making it recursive, and the engine handles the rest.

  • Prolog has been used for theorem proving, expert systems, term rewriting, type systems, automated planning, question answering, and natural language processing. That breadth has not translated into widespread adoption across the software industry. Most Prolog applications are small by industrial standards, with few exceeding 100,000 lines of code.

    Two structural problems explain the gap. First, not all Prolog compilers support modules, and the module systems that do exist are mutually incompatible. Virtually no implementation adheres to the modules section of the ISO standard. Most have instead adopted the Quintus/SICStus module system as a de facto standard, but even that convergence leaves subtle differences in semantics between implementations. Portability within what the source calls the Edinburgh/Quintus derived family of implementations improved meaningfully after 2007, allowing portable real-world applications to be maintained, but the problem has never been fully solved.

    Second, Prolog carries a performance penalty compared to conventional languages. Its non-deterministic evaluation strategy creates friction when a computation is intrinsically deterministic. Programmers frequently reach for the cut operator and other extralogical constructs to recover performance, but those constructs require a procedural reading of the program to understand correctly. They also destroy one of Prolog's central attractions: the ability to run programs backwards and forwards across a relation. Pure Prolog is not actually pure in practice; the order of clauses matters, execution depends on it, and many real programs are written to conform to Prolog's depth-first search order rather than as genuinely declarative logic.

  • IBM's Watson system, which drew wide public attention for its question-answering performance, was written in several languages including Prolog. The system ran on SUSE Linux Enterprise Server 11 using the Apache Hadoop framework for distributed computing, with IBM's DeepQA software and the Apache UIMA framework handling unstructured information management. Prolog's specific role was pattern matching over natural language parse trees.

    The Watson developers stated their reasoning directly: they needed a language for conveniently expressing pattern matching rules over parse trees and other annotations such as named entity recognition results, along with a technology that could execute those rules efficiently. They found Prolog to be the ideal choice for the language due to its simplicity and expressiveness.

    Open source graph database TerminusDB is also implemented in Prolog, designed for collaboratively building and curating knowledge graphs. Prolog is additionally used in the low-code development platform GeneXus. These deployments illustrate a consistent pattern in Prolog's industrial footprint: it tends to appear not as the primary language of a system but as the layer handling the most linguistically complex or relationally intricate part of the work, the piece where pattern matching over structured symbolic data is the binding constraint.

  • ISO standardisation gave Prolog a more stable footing than it had in its first two decades. ISO/IEC 13211-1 was published in 1995, aiming to standardise the practices already in use across the many existing implementations. Three corrigenda followed: Cor.1:2007, Cor.2:2012, and Cor.3:2017. ISO/IEC 13211-2, published in 2000, added module support to the standard. The most recent addition to the standard family, 13211-3, was published in 2025.

    Higher-order programming extended the language beyond the boundaries of first-order logic. ISO Prolog now includes built-in higher-order predicates such as call/1 through call/3, findall/3, setof/3, and bagof/3. Higher-order programming style in Prolog was pioneered in HiLog and in the language known as lambda Prolog. Tabling, a memoisation technique implemented in systems including B-Prolog, XSB, SWI-Prolog, YAP, and Ciao, reduces execution time by storing intermediate results in a table and reusing them rather than re-running resolution each time a subgoal is re-encountered.

    Constraint logic programming, which extends Prolog with concepts from constraint satisfaction, has proven particularly useful for large-scale combinatorial optimisation problems and for applications in industrial settings such as automated time-tabling and production scheduling. Most Prolog systems ship with at least one constraint solver for finite domains, and many include solvers for rational numbers as well. The Janus interface, initially developed for XSB by Anderson and Swift and since adopted as a joint initiative by the XSB, Ciao, and SWI-Prolog teams, provides a bi-directional bridge between Prolog and Python, opening a path into the data science ecosystem that Prolog's original architects could not have anticipated.

Common questions

What is Prolog and what programming paradigm does it use?

Prolog is a logic programming language that uses a declarative paradigm: a program is defined as a set of facts and rules, and computation is initiated by running a query over those relations. It is rooted in first-order logic and remains the most popular logic programming language available, with both free and commercial implementations.

Who created Prolog and when was it developed?

Prolog was created around 1972 by Alain Colmerauer and Philippe Roussel, members of the Artificial Intelligence Group at the Faculty of Sciences of Luminy, Aix-Marseille II University in France. The first implementation was an interpreter written in Fortran by Gerard Battani and Henri Meloni.

What does the name Prolog stand for and who chose it?

The name Prolog was chosen by Philippe Roussel, at the suggestion of his wife, as an abbreviation for Programmation en logique, which is French for "programming in logic".

How was Prolog used in IBM Watson?

Prolog was used in Watson for pattern matching over natural language parse trees. The Watson developers stated they needed a language for conveniently expressing pattern matching rules over parse trees and named entity recognition results, and found Prolog ideal due to its simplicity and expressiveness. Watson also used Java, C++, and ran on SUSE Linux Enterprise Server 11 with the Apache Hadoop framework.

What is the Warren Abstract Machine and how does it relate to Prolog?

The Warren Abstract Machine is an influential abstract instruction set for compiling Prolog, created by David H. D. Warren. Warren first built the DEC-10 Prolog compiler in collaboration with Fernando Pereira, then generalised those ideas into the Warren Abstract Machine, which went on to shape how Prolog is compiled across many subsequent implementations.

What are the main limitations of Prolog in industrial software development?

Most Prolog applications are small by industrial standards, with few exceeding 100,000 lines of code. Key obstacles include incompatible module systems across implementations, portability problems between Prolog compilers, and a performance penalty compared to conventional languages, particularly when non-deterministic evaluation is applied to deterministic computations.

All sources

75 references cited across the entry

  1. 1bookProgramming in PrologWilliam F. Clocksin et al. — Springer-Verlag — 2003
  2. 2bookProlog programming for artificial intelligenceIvan Bratko — Addison Wesley — 2012
  3. 3bookNatural language processing for Prolog programmersMichael A. Covington — Prentice Hall — 1994
  4. 5bookBuilding expert systems in PrologMerritt, Dennis — Springer-Verlag — 1989
  5. 6bookFoundations of Programming LanguagesKent D. Lee — Springer — 19 January 2015
  6. 10bookProlog and Natural Language AnalysisFernando C. N. Pereira et al. — Microtome — 2005
  7. 11webNatural Language Processing With Prolog in the IBM Watson SystemAdam Lally et al. — Association for Logic Programming — 31 March 2011
  8. 12journalThe early years of logic programmingR. A. Kowalski — 1988
  9. 13journalThe birth of PrologA. Colmerauer et al. — 1993
  10. 15newsPOP and SNAPDick Pountain — October 1984
  11. 19conferenceRe-thinking PrologOleg Kiselyov et al. — 2014
  12. 20citationDeclarative vs proceduralTorkel Franzen — 1994
  13. 21journalComplexity and Expressive Power of Logic ProgrammingEvgeny Dantsin et al. — 2001
  14. 22citationterminusdb/terminusdbTerminusDB — 2020-12-13
  15. 23bookFoundations of logic programmingLloyd, J. W. — Springer-Verlag — 1984
  16. 24bookSICStus Prolog User's Manual 4.3: Core reference documentationMats Carlsson — BoD – Books on Demand — 27 May 2014
  17. 25journalCoding guidelines for PrologMichael A. Covington et al. — 2011
  18. 26bookConstructing logic programsM. Kirschenbaum et al. — John Wiley & Sons — 1993
  19. 27bookComputational Logic: Logic Programming and BeyondLeon Sterling — 2002
  20. 28conferenceRepresenting Logic Program Schemata in PrologT. S. Gegg-harrison — 1995
  21. 29bookLogic programming: systematic program developmentYves Deville — Addison-Wesley — 1990
  22. 30reportHigher-order logic programming in PrologLee Naish — Department of Computer Science, University of Melbourne — 1996
  23. 32citationFifty Years of Prolog and BeyondPhilipp Körner — November 2022
  24. 33citationLogtalkPaulo Moura — August 2004
  25. 34bookDeclarative Programming for Knowledge ManagementSalvador Abreu et al. — 2006
  26. 35bookComputational Logic — CL 2000Daniel Cabeza et al. — 2000
  27. 36journalXSB as an efficient deductive database engineKonstantinos Sagonas et al. — 1994
  28. 37bookThe Art of Prolog: Advanced Programming TechniquesShapiro, Ehud Y. et al. — MIT Press — 1994
  29. 38bookProlog: the standard: reference manualA. Ed-Dbali et al. — Springer — 1996
  30. 45journalHigh-performance logic programming with the Aquarius Prolog compilerP. Van Roy et al. — 1992
  31. 46bookTerm indexingPeter Graf — Springer — 1995
  32. 47conferenceIndexing Prolog Clauses via Superimposed Code Words and Field Encoded WordsMichael J. Wise et al. — 1986
  33. 48journalEnhancing unification in PROLOG through clause indexingRobert M. Colomb — 1991
  34. 49journalTabling for non-monotonic programmingT. Swift — 1999
  35. 50journalEfficient Fixpoint Computation in Linear TablingNeng-Fa Zhou et al. — 2003
  36. 51journalXSB: Extending Prolog with Tabled Logic ProgrammingT. Swift et al. — 2011
  37. 52bookProceedings of the 14th annual international symposium on Computer architecture - ISCA '87S. Abe et al. — 1987
  38. 53conferenceA Prolog processor based on a pattern matching memory deviceIan Robinson — Springer — 1986
  39. 54journalPerformance and architectural evaluation of the PSI machineK. Taki et al. — 1987
  40. 55journalParallel execution of prolog programs: a surveyG. Gupta et al. — 2001
  41. 57bookThe fifth generation: an annotated bibliographyM. A. Bramer et al. — Addison-Wesley — 1984
  42. 58journalThe Japanese national Fifth Generation project: Introduction, survey, and evaluationEdward Feigenbaum et al. — 1993-07-01
  43. 59magazineSoftware that takes games seriouslyReed Business Information — March 26, 1987
  44. 60journalA polymorphic type system for prologA. Mycroft et al. — 1984
  45. 61bookTypes in logic programmingPfenning, Frank — MIT Press — 1992
  46. 62bookLogic programming: 24th international conference, ICLP 2008, Udine, Italy, December 9-13, 2008: proceedingsTom Schrijvers et al. — 2008
  47. 64bookThe craft of PrologO'Keefe, Richard A. — MIT Press — 1990
  48. 65arxivCoding guidelines for PrologMichael Covington et al. — 2010
  49. 66bookTapsoft '87P. Roy et al. — 1987
  50. 67journalConstraint logic programming: a surveyJ. Jaffar — 1994
  51. 68journalOpening the Prolog III UniverseAlain Colmerauer — 1987
  52. 69bookComputational Logic: Logic Programming and BeyondM. Wallace — 2002
  53. 71webprolog-mpiApps.lumii.lv
  54. 72journalSWI-Prolog and the webJ. Wielemaker et al. — 2008
  55. 73citationUsing {Prolog} as the fundament for applications on the semantic webJan Wielemaker et al. — CEUR-WS.org — 2007
  56. 75journalSecure Prolog-based mobile codeS. W. Loke et al. — 2001