Horn clause: definition, forms, role in logic programming and complexity
A Horn clause is a logical clause with at most one positive literal. This article explains its forms, first-order semantics, use in resolution and Prolog, model theory, and computational properties.
A Horn clause is a formula in propositional or first-order logic formed as a disjunction of literals that contains at most one positive (unnegated) literal. Introduced by Alfred Horn in 1951, Horn clauses are a restricted but highly useful fragment of classical logic because their structure supports efficient automated reasoning and a natural interpretation as rules in logic programming. The restriction to at most one positive literal gives Horn clauses computational and semantic properties that distinguish them from general clauses used in arbitrary satisfiability problems.
Basic forms and examples
Horn clauses are commonly classified by how many positive literals they include. In ordinary notation these forms are:
- Definite clause: exactly one positive literal and zero or more negative literals. It corresponds to an implication where a conjunction of premises implies a single conclusion. Example (propositional): ¬p ∨ ¬q ∨ r, often written as (p ∧ q) → r.
- Fact: a definite clause with no negative literals — simply a positive atom asserted true (for example r). Facts act as base truths in a knowledge base.
- Goal (or query) clause: a clause with no positive literal, i.e., a disjunction of negative literals. Under implication reading it represents a requirement or query: ¬p ∨ ¬q is equivalent to (p ∧ q) → false. Goals are used to express things to be proved.
In first-order logic variables in a Horn clause are usually implicitly universally quantified over the whole clause. For instance the clause ¬human(X) ∨ mortal(X) is syntactic shorthand for ∀X (¬human(X) ∨ mortal(X)), which is classically equivalent to the implication ∀X (human(X) → mortal(X)). Thus definite Horn clauses provide a compact way to state universally quantified implications about objects.
Syntax, rewriting and common notations
Definite clauses are often written as implications or as Prolog-style rules. The logical disjunction ¬p ∨ ¬q ∨ r can be rewritten as (p ∧ q) → r, and in a backward-chaining notation the same rule can be displayed as r ← p, q. In Prolog source code the rule becomes:
r :- p, q.
That presentation emphasizes a procedural interpretation: to prove r, attempt to prove both p and q. A goal clause that is the negation of a conjunction, such as ¬p ∨ ¬q, corresponds to asking whether p and q can both be established; failure yields a refutation or a solution depending on the chosen semantics. These different readings mean that the same syntactic clause may be used both as a logical assertion and as a procedural step in a search.
Use in automated reasoning and logic programming
Horn clauses are central to automated theorem proving and to the design of logic programming languages because they behave well under resolution. The resolvent of two Horn clauses is itself a Horn clause, and resolving a goal clause with a definite clause produces another goal clause. These closure properties make goal-directed proof search (backward chaining) efficient in many cases, and they are the foundation of SLD resolution, the inference mechanism used in Prolog and related systems. The method repeatedly replaces a goal by the body of a matching definite clause, progressively reducing the problem until facts supply the needed atoms.
Logic programming languages and rule engines typically restrict programs to sets of definite Horn clauses so that execution corresponds to repeated application of these resolution steps. Logic programming and the language Prolog exploit this connection: programs express knowledge as rules and facts, while queries are treated as goal clauses that drive the proof search.
Semantics: minimal models and consequences
On the model-theoretic side, sets of definite Horn clauses have a strong semantic characterization: every such set has a unique minimal Herbrand model (or, more generally, a unique minimal model under the usual ordering of interpretations). An atomic formula is logically implied by the program exactly when it belongs to this minimal model. This property makes reasoning with definite clauses monotonic and straightforward: if a ground atom is derivable by repeated application of rules from facts, it is true in the minimal model and hence a logical consequence. Van Emden and Kowalski developed this view and used it to connect operational proof search with declarative semantics.
Complexity, decidability and practical variants
From a computational perspective, propositional Horn satisfiability (often called HORNSAT) is tractable: deciding whether a conjunction of propositional Horn clauses is satisfiable can be done in linear time by a simple propagation algorithm. In complexity-theoretic terms, HORNSAT is P-complete, contrasting sharply with the general Boolean satisfiability problem (SAT), which is NP-complete. For first-order Horn clauses the situation becomes more complex: satisfiability or general entailment is undecidable in the unrestricted first-order case, although many useful fragments (for example the Datalog subset without function symbols) are decidable and widely used in databases and static analysis. Boolean satisfiability and the class NP-complete problems illustrate the broader complexity landscape into which Horn fragments fit.
Applications and notable distinctions
Horn clauses underpin many practical systems: logic programming, deductive databases, rule-based expert systems, and certain kinds of program analysis. Variants include definite programs, stratified programs with controlled negation, and extensions used in nonmonotonic reasoning (for example stable model semantics). The restriction to at most one positive literal is the essential distinguishing feature: it permits an implication-like reading and enables linear-time propositional inference, while still allowing expressive rule-based knowledge representation when combined with function symbols and quantifiers (at the cost of decidability).
Important distinctions to keep in mind are between propositional and first-order Horn clauses, between definite clauses and general Horn clauses, and between operational readings (as in backward chaining and Prolog execution) and declarative, model-theoretic readings (minimal model semantics). Research and practice continue to explore trade-offs between expressive power and computational tractability in systems built on Horn-like fragments.
Further reading and resources
- Historical overview and Horn's original work: see classical logic literature and survey articles. Horn clause origins.
- Introductory texts on logic programming for practical Prolog examples and SLD resolution details. Logic programming resources.
- Complexity discussions comparing HORNSAT and general SAT. SAT vs HORNSAT and computational complexity.
Questions and answers
Q: What is a Horn clause?
A: A Horn clause is a logic disjunction of literals, where at most one of the literals is positive and all the others are negative.
Q: Who first described them?
A: Alfred Horn first described them in an article in 1951.
Q: What is a definite clause?
A: A Horn clause with exactly one positive literal is called a definite clause.
Q: What is a fact?
A: A definite clause with no negative literals is sometimes referred to as a "fact".
Q: What is a goal clause?
A: A Horn clause without a positive literal is sometimes called a goal clause.
Q: How do variables in non-propositional cases work?
A: In the non-propositional case, all variables in a clause are implicitly universally quantified with scope the entire clause. This means that they apply to every part of the statement.
Q: What role do Horn clauses play in constructive logic and computational logic? A: Horn clauses play an important role in automated theorem proving by first-order resolution because the resolvent of two Horn clauses or between one goal and one definite clausse can be used to create greater efficiencies when proving something represented as the negation of its goal clausse. They are also used as basis for logic programming languages such as Prolog, where they behave like goal reduction procedures.
Related articles
Author
AlegsaOnline.com Horn clause: definition, forms, role in logic programming and complexity Leandro Alegsa
URL: https://en.alegsaonline.com/art/45117
Sources
- doc.ic.ac.uk : The semantics of predicate logic as a programming language