Prolog

Prolog is the classic logic programming language: you state facts and rules, and Prolog’s inference engine — resolution with backtracking — finds answers. It is a DSL for symbolic reasoning, grammars, and constraint solving.

Purpose

Prolog is declarative: a program is a theory (facts plus rules), and running it is asking queries. Logic, not control flow, is the programming unit.

The Problem It Solves

Problems that are naturally relational — genealogy, grammar parsing, expert rules, constraint satisfaction — become tiny in Prolog. You describe what is true; the engine searches for what follows. Backtracking explores alternatives automatically, and unification does pattern matching that other languages fake with libraries.

Where It Fits

Prolog anchors the logic-languages phase: Datalog (its data-focused relative), Clingo/ASP (its answer-set cousin), and MiniZinc (constraint modeling) all descend from or interoperate with this lineage. It remains the standard for symbolic AI work.

History

Prolog is a 1970s European creation with a remarkable staying power.

Origins

Alain Colmerauer and Philippe Roussel developed Prolog at the University of Aix-Marseille between 1970 and 1972, building on Robinson’s resolution theorem proving and Kowalski’s logic programming ideas. The name abbreviates PROgrammation en LOGique.

Milestones

  • 1977 — the Edinburgh (DECsystem-10) syntax, created by David Warren and colleagues, becomes the standard dialect.
  • 1980s — Warren’s Abstract Machine (WAM) makes compiled Prolog practical; Japan’s Fifth Generation project puts logic programming on the world stage.
  • 1995 — ISO/IEC 13211-1 standardizes the language; Erlang, type systems, and Datalog inherit key ideas.
  • Today — SWI-Prolog (maintained since 1987) is the community workhorse, >1 million downloads and counting.

Current Status

Mature, niche, and alive: ISO standard plus actively developed implementations (SWI-Prolog, SICStus, GNU Prolog, Trealla, Tau Prolog for the browser), with lively communities in computational linguistics, semantic web, and education.

Stage

Prolog is a mature standard with actively maintained, modern implementations.

Maturity

Fully mature: ISO/IEC 13211-1 defines the core, and SWI-Prolog (maintained since 1987) adds practical extensions — tabling, CLP(FD) constraint solving, RDF/semantic-web support, and web services.

Governance & Maintenance

Decentralized: SWI-Prolog is BSD-2-licensed with a dedicated maintainer; SICStus is commercial with academic licensing; GNU Prolog, Trealla, and Tau Prolog (browser) are open source. The ISO committee keeps the standard current.

Popularity & Usability

Prolog ranks low in popularity surveys and high in its niches.

Adoption

Standard tooling for computational linguistics (DCG grammars), semantic web/ontology work, expert and advisory systems, and university AI courses. SWI-Prolog reports over a million downloads.

Learning Curve

The paradigm is the challenge: you define relations and let the engine search, rather than write steps. Unification and backtracking take deliberate practice. Once clicked, the same skills transfer to Datalog, ASP, and type-inference machinery.

Tooling

SWI-Prolog ships an IDE (PceEmacs), tracer/debugger, tabling, CLP(FD/BD), web server (Pengines), and SWISH — a browser playground. Language servers and VS Code extensions exist for modern editing.

Use Cases

Prolog shines when the problem IS a set of facts and rules.

Primary Domains

  • Natural-language grammars (DCGs) and parsing pipelines.
  • Expert/advisory systems and rule engines for business and law.
  • Constraint and scheduling problems via CLP(FD).
  • Semantic web: RDF reasoning, ontology queries, SPARQL adjacent work.
  • Education: the language that teaches search, unification, and logic.

Strengths

Declarative clarity for relational problems, automatic backtracking search, built-in pattern matching, and a lineage that produced Erlang and modern type systems.

Weak Spots

Performance ceilings on large state spaces, fewer libraries than mainstream languages, and a small hiring pool for production maintenance.

Performance

Prolog’s performance is about search efficiency, not raw speed.

Execution Model

Programs compile to Warren Abstract Machine (WAM) instructions; queries resolve via SLD resolution with chronological backtracking. SWI-Prolog’s tabling (SLG resolution) memoizes results and terminates more programs, at the cost of memory.

Published Claims

Modern Prolog systems execute millions of logical inferences per second — fine for search- and knowledge-based workloads. The honest guidance: Prolog is not for numeric loops; keep computation in constraints (CLP(FD)) or call out to C for hot paths.

Example

A family tree with rules: facts, a recursive rule, and a query Prolog answers by backtracking.

Facts, Rules, Query

% family.pl — facts and rules
parent(tom, ann).     % fact: tom is a parent of ann
parent(ann, sam).
parent(ann, liz).

grandparent(X, Z) :-       % rule: X is a grandparent of Z
    parent(X, Y),          %   if X is a parent of someone Y,
    parent(Y, Z).          %   and that Y is a parent of Z.

The comma between goals means AND; the :- reads as “if”. When the query fails to find another solution, Prolog backtracks automatically and keeps searching.

How to Run

swipl -f family.pl -g "grandparent(tom, Who), write(Who), nl, fail."   # prints sam, liz
# or interactively:  swipl -f family.pl   then:  ?- grandparent(tom, Who).

The fail goal forces backtracking so you see all solutions — the standard Prolog idiom for enumerating answers.

Learn More

Official sources and free materials; the full categorized catalog is on the References & Downloads page.

Official Docs & Downloads

Learning Material