Logic Programming¶
A programming paradigm that expresses relations as logical clauses and obtains answers through inference under a declared semantics and evaluation strategy.
Core Idea¶
Logic programming writes a program as logical clauses and asks what answers follow under stated rules for interpreting and evaluating them. Clauses can include facts with no conditions and rules that derive one relation from others. A Prolog user often poses a goal; a Datalog program can request an output relation. A facts-only Prolog knowledge base is still a program. The exact meaning and search behavior depend on the language and its chosen controls.[ref-93d6a3e08c33][ref-a394cd1edbed][ref-818f74c15e77][ref-b28cf8717e75]
Scope of Application¶
Kowalski's definite-clause factorial program shows clauses with both a logical reading and a way to reduce a goal into subgoals. His program has a base factorial clause, a recursive clause and a necessary Times helper relation. Soufflé's Datalog tutorial shows a different setting: graph edge facts and recursive reachable rules produce a relation of connected vertex pairs.[ref-93d6a3e08c33][ref-818f74c15e77]
The label covers more than these two examples. Pure finite Datalog has restrictions that practical Soufflé arithmetic extensions can relax, sometimes losing termination. Prolog's depth-first search can also follow an infinite path before reaching an answer; a declarative reading alone does not guarantee full answer enumeration.[ref-818f74c15e77][ref-b28cf8717e75]
Clarity¶
For a claimed logic program, identify its clauses, interpretation, answer target and evaluation strategy. If a query fails, distinguish a missing logical answer from a search path that did not reach an available one. Negation-as-failure is weaker than classical negation, and Prolog's cut can prune search alternatives; these controls must not be silently read as ordinary classical implication.[ref-b28cf8717e75][ref-ad8a10e891ad][^ref-786abd0de411]
Manages Complexity¶
A small set of clauses can describe many instances of a relation. Soufflé's two reachable rules describe paths of varying lengths without listing each path. Kowalski's factorial clauses describe a family of inputs while a goal selects one computation. This compactness helps when the clauses and their semantics are clear. It can also hide operational cost or nontermination, so the evaluation regime must be stated.[ref-93d6a3e08c33][ref-818f74c15e77][^ref-b28cf8717e75]
Abstract Reasoning¶
Given a goal or output relation, first ask what the clauses say. Next ask how the engine seeks the answer. In the Soufflé graph, each edge is reachable and the recursive rule extends reachability through intermediate vertices. In Kowalski's program, the factorial goal is reduced through the recursive clause and Times. If the answer is not produced, check the clauses, the declared semantics and the search behavior separately.[ref-93d6a3e08c33][ref-818f74c15e77][^ref-b28cf8717e75]
Knowledge Transfer¶
The literal pattern transfers between logic languages: represent relations with logical clauses and evaluate a specified target. A Prolog goal and a Datalog output relation realize that pattern differently, and their syntax and termination conditions need separate checks. The live Programming Paradigm entry is the strict parent: it covers families of computational concepts, composition and reasoning across implementations. Logic programming adds logical clauses and inference-based answers; its words “logic” and “rule” do not by themselves make it a cross-domain Prime.[ref-93d6a3e08c33][ref-818f74c15e77]
Example¶
Kowalski's Fact relation represents factorial. Its base clause is Fact(0,s(0)), and its recursive clause uses a smaller factorial result and a Times relation. The worked goal Fact(s(s(0)),x) asks for two factorial. Mapped back: the Fact and Times clauses are the logical program; definite-clause implication gives its meaning; the Fact goal is the target; goal reduction is the evaluation. The Times helper is required for the worked computation.[^ref-93d6a3e08c33]
In Soufflé's graph example, edge facts and two reachable rules define transitive reachability, including reachable("a","d"). Mapped back: edge and reachable clauses are the program; Datalog rule meaning defines the relation; .output reachable chooses the answer; rule evaluation derives it. This does not make one search order or pure-Datalog termination guarantee universal to every extended program.[^ref-818f74c15e77]
Relationships to Other Abstractions¶
Current abstraction Logic Programming Domain-specific
Parents (1) — more general patterns this builds on
-
Logic Programming is a kind of Programming Paradigm Domain-specific
Logical clauses, answer targets, semantics and inference-based evaluation organize program composition and reasoning across Prolog and Datalog implementations, making logic programming a strict programming paradigm.
Hierarchy path (1) — routes to 1 parentless root
- Logic Programming → Programming Paradigm
Neighborhood in Abstraction Space¶
Logic Programming sits in a sparse region of the domain-specific corpus (97th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.
Family — Unclustered & Miscellaneous (2551 abstractions)
Nearest neighbors
- Formal Theory — 0.77
- Logical Consequence — 0.77
- Principle of Explosion — 0.77
- Peirce's Law — 0.77
- Nota Accusativi — 0.76
Computed from structural-signature embeddings · 2026-10-08
Not to Be Confused With¶
A facts-only program: it remains a valid logic program when the facts are logical clauses available to queries. An imperative algorithm with the same result: output alone does not decide the program form. All declarative programming: some declarative programs use other organizing structures. A guarantee of complete search: Prolog control and depth-first execution can change what the user actually sees. Classical negation: negation-as-failure has a different interpretation.[ref-a394cd1edbed][ref-b28cf8717e75][^ref-ad8a10e891ad]
References¶
[^ref-93d6a3e08c33]: Robert A. Kowalski, “Predicate Logic as Programming Language,” Proceedings of IFIP Congress 1974 (1974), pp. 569–574, especially the definite-clause procedural/declarative discussion and factorial Fact example. https://www.doc.ic.ac.uk/~rak/papers/IFIP74.pdf
[^ref-818f74c15e77]: Soufflé development team, “Tutorial,” Soufflé: A Datalog Synthesis Tool for Static Analysis, “Introduction to Datalog,” “Transitive closure,” and the paragraph on arithmetic functors. https://souffle-lang.github.io/tutorial
[^ref-a394cd1edbed]: Patrick Blackburn, Johan Bos and Kristina Striegnitz, “Facts, Rules, and Queries,” Learn Prolog Now!, Chapter 1, SWI-Prolog-hosted edition, facts-only first program. https://lpn.swi-prolog.org/lpnpage.php?pageid=lpn-htmlse1&pagetype=html
[^ref-ad8a10e891ad]: SWI-Prolog, “Control Predicates,” SWI-Prolog Reference Manual, cut operator and choice-point behavior. https://www.swi-prolog.org/pldoc/man?section=control
[^ref-786abd0de411]: SWI-Prolog, “Constraint Logic Programming,” SWI-Prolog Reference Manual, §8 note about cut and declarative semantics. https://www.swi-prolog.org/pldoc/man?section=clp
[^ref-b28cf8717e75]: SWI-Prolog, “Glossary of Terms,” SWI-Prolog Reference Manual, entries for classes of logic programs, weak versus strong negation, SLD-resolution, and Prolog's leftmost, top-to-bottom, depth-first search and possible infinite proof paths. https://www.swi-prolog.org/pldoc/man?section=glossary