Logic programming is a programming paradigm where programs are sets of logical clauses and computation is automated theorem proving. The programmer declares what is true; the language's inference engine works out how to derive consequences.
Prolog (Colmerauer & Roussel 1972) is the canonical logic programming language. Programs consist of facts and rules in Horn-clause form; queries are solved by SLD resolution, a restricted form of J. A. Robinson's resolution principle.
Example Prolog:
parent(tom, bob).
parent(bob, ann).
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).
?- grandparent(tom, X).
X = ann.
Backward chaining: to prove grandparent(tom, X), find $Y$ such that parent(tom, Y) and parent(Y, X). Unification ($Y =$ bob) and recursion handle the search.
Datalog: a restricted Prolog without function symbols, decidable and efficiently computable. Used for database queries, program analysis, and knowledge representation.
Answer-set programming (ASP): a declarative paradigm for combinatorial search. Stable-model semantics. Solvers like Clingo are competitive with SAT solvers on many problems.
Constraint logic programming: extends logic programming with constraint solvers (linear, finite-domain, real). Used in scheduling, configuration, planning.
Modern relevance:
- Neural-symbolic AI: combine LLMs with logic-programming-style reasoning. Differentiable Datalog, neural theorem provers, retrieval-augmented LLMs querying knowledge graphs.
- Verification: Coq, Lean, Isabelle use logic-programming-style automated tactics.
- Knowledge graphs: SPARQL queries over RDF triples are essentially Datalog.
Logic programming was the dominant AI paradigm of Japan's Fifth Generation Computer Systems Project (1981-1992) and remains influential in formal verification, programme analysis, and Semantic Web tooling.
Related terms: Resolution, alan-robinson, Prolog, Knowledge Representation
Discussed in:
- Chapter 1: What Is AI?, A Brief History of AI