What Is Prolog?
Prolog (short for “Programmation en Logique”) is a declarative, logic-based programming language created in 1972 by Alain Colmerauer and Philippe Roussel at the University of Aix-Marseille, building on theoretical work by Robert Kowalski at Edinburgh. Instead of writing step-by-step instructions, you describe facts and rules about a problem domain, and Prolog's inference engine searches for answers to the questions you pose.
Cricket analogy: Rather than scripting every ball of an over, a Prolog program is like handing the scorer a rulebook stating a batter is 'run out' if the bails fall before the bat crosses the crease, letting the third umpire's replay system infer the decision instead of you calling it live.
Declarative vs. Procedural Programming
In an imperative language like Python or C, you write an explicit algorithm: loop through a list, compare values, return a result. In Prolog you instead write a logical specification of what a solution looks like — for example, sibling(X, Y) :- parent(Z, X), parent(Z, Y), X \= Y. — and the Prolog engine performs SLD resolution, systematically trying to unify your query against the clauses in the knowledge base and backtracking when a branch fails.
Cricket analogy: It's the difference between manually calculating Net Run Rate ball-by-ball versus stating the formula (runs scored per over faced, minus runs conceded per over bowled) and letting the scoring software try sub-calculations until the numbers reconcile.
Facts, Rules, and Queries
A Prolog knowledge base is built from two kinds of clauses: facts, which assert something is unconditionally true (e.g., parent(tom, liz).), and rules, which state a conclusion holds if a set of conditions hold (e.g., grandparent(X, Z) :- parent(X, Y), parent(Y, Z).). You interact with this knowledge base by issuing queries at the ?- prompt, and Prolog's resolution engine unifies your query against the database, binding variables and backtracking through choice points until it finds every solution or exhausts the search space.
Cricket analogy: A fact is like the ICC scorebook entry 'Kohli scored 254 not out against South Africa in 2019,' while a rule is 'a batter has a double century if runs >= 200,' and a query like double_century(kohli, Match) makes Prolog search the scorebook for every match that satisfies it.
% facts
parent(tom, liz).
parent(tom, bob).
parent(bob, ann).
% rule: X is a grandparent of Z if X is a parent of Y and Y is a parent of Z
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).
?- grandparent(tom, ann).
true.
?- grandparent(tom, Who).
Who = ann.Prolog belongs to the logic programming paradigm, one of the four major programming paradigms alongside imperative, functional, and object-oriented programming. It remains a core teaching language for artificial intelligence, natural language processing, and symbolic reasoning courses because its unification and backtracking model maps directly onto classic AI search problems.
Where Prolog Is Used Today
Beyond academia, Prolog and its dialects power real production systems: the airline industry has used Prolog-descended constraint solvers for crew scheduling, natural language processing and expert-system projects have long relied on it, and SWI-Prolog specifically is used for semantic web reasoning with RDF and OWL data. Prolog's constraint logic programming extension, CLP(FD), also makes it a practical tool for solving scheduling, timetabling, and combinatorial puzzles like Sudoku.
Cricket analogy: It's like the way IPL franchises use constraint-based scheduling software, similar in spirit to Prolog's CLP(FD), to build a fixture list where no team plays more than two away games in a row across a 74-match season.
Prolog is not a general-purpose language for everyday application development the way Python or JavaScript are — it excels at symbolic reasoning, search, and constraint problems, but I/O, GUIs, and heavy numeric computation are comparatively awkward, so most real systems embed Prolog as a reasoning component rather than build the entire stack in it.
- Prolog is a declarative, logic-based language created in 1972 by Alain Colmerauer and Philippe Roussel.
- Programs consist of facts (unconditional truths) and rules (conditional truths) rather than step-by-step instructions.
- You interact with a Prolog program by issuing queries at the ?- prompt.
- The Prolog engine resolves queries using unification and backtracking through choice points, known as SLD resolution.
- Prolog belongs to the logic programming paradigm, distinct from imperative, functional, and object-oriented paradigms.
- Real-world uses include natural language processing, expert systems, semantic web reasoning, and constraint scheduling via CLP(FD).
- Prolog is typically embedded as a reasoning component rather than used for an entire application stack.
Practice what you learned
1. Who are credited as the original creators of Prolog in 1972?
2. What best describes the Prolog programming paradigm?
3. In the rule grandparent(X, Z) :- parent(X, Y), parent(Y, Z)., what does the :- symbol represent?
4. Which mechanism allows Prolog to try alternative solutions after a query path fails?
5. Which of the following is a realistic modern use of Prolog?
Was this page helpful?
You May Also Like
Facts and Rules in Prolog
How Prolog knowledge bases are built from facts and rules, including how conjunctions (AND) and multiple clauses (OR) combine to express logic.
Prolog Syntax and Terms
A tour of Prolog's core data representation: atoms, numbers, variables, compound terms, and the [Head|Tail] list notation.
Your First Prolog Program
A hands-on walkthrough of writing a family.pl file, loading it into SWI-Prolog, and querying it interactively with backtracking.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics