Algorithm Search⌘K

Definitioncore

Clark's completion

Also called program completion, predicate completion.

The completion of a logic program reads the rules for each predicate as an "if and only if" definition, so an atom holds exactly when the body of one of its rules holds.

Clark's completion turns a logic program into a classical theory by reading the rules for each predicate as its full definition: an atom holds if and only if the body of one of its rules holds. Clark (1978) gave it as the declarative meaning of negation as failure, and proved that a finite failure of pp in SLDNF resolution is sound for ¬p\neg p in the completion. The soundness and completeness results for the procedure are on the SLDNF page; this page gives the definition, the ground case that answer set solvers use, and how the completion relates to stable models.

Definition

Propositional case. Let PP be a finite ground normal program over a set AA of atoms. A rule h←b1,…,bm,not c1,…,not ckh \leftarrow b_1, \ldots, b_m, \mathit{not}\ c_1, \ldots, \mathit{not}\ c_k has the body formula b1∧⋯∧bm∧¬c1∧⋯∧¬ckb_1 \wedge \cdots \wedge b_m \wedge \neg c_1 \wedge \cdots \wedge \neg c_k, and an empty body is ⊤\top. The completion Comp(P)\mathrm{Comp}(P) is the set of formulas

a↔⋁r∈P, head(r)=abody(r)for each a∈A,a \leftrightarrow \bigvee_{r \in P,\ \mathrm{head}(r) = a} \mathrm{body}(r) \qquad \text{for each } a \in A,

where the empty disjunction is ⊥\bot, so an atom with no rules gets ¬a\neg a. The models of Comp(P)\mathrm{Comp}(P) are called the supported models of PP. A set M⊆AM \subseteq A is a model of Comp(P)\mathrm{Comp}(P) exactly when M=TP(M)M = T_P(M), where TP(M)T_P(M) is the set of heads of the rules whose body is true in MM: the direction "←\leftarrow" says TP(M)⊆MT_P(M) \subseteq M, and the direction "→\rightarrow" says that each true atom has a rule with a true body.

First-order case. For a predicate pp of arity nn, each rule p(t1,…,tn)←L1,…,Lkp(t_1, \ldots, t_n) \leftarrow L_1, \ldots, L_k with variables y⃗\vec{y} is rewritten as

∃y⃗ (x1=t1∧⋯∧xn=tn∧L1∧⋯∧Lk),\exists \vec{y}\, (x_1 = t_1 \wedge \cdots \wedge x_n = t_n \wedge L_1 \wedge \cdots \wedge L_k),

with fresh variables x1,…,xnx_1, \ldots, x_n and not\mathit{not} read as ¬\neg. If E1,…,EjE_1, \ldots, E_j are these formulas for all rules of pp, the completed definition of pp is ∀x⃗ (p(x⃗)↔E1∨⋯∨Ej)\forall \vec{x}\, (p(\vec{x}) \leftrightarrow E_1 \vee \cdots \vee E_j), and ∀x⃗ ¬p(x⃗)\forall \vec{x}\, \neg p(\vec{x}) if pp has no rules. The completion is the set of completed definitions together with Clark's equality theory, which says that distinct function symbols give distinct terms, that function symbols are injective, and that no term equals a proper subterm of itself. Lloyd's book states these axioms in full.

Examples and non-examples

  • P={p←not q}P = \{p \leftarrow \mathit{not}\ q\}. Then Comp(P)={p↔¬q, ¬q}\mathrm{Comp}(P) = \{p \leftrightarrow \neg q,\ \neg q\}, with the single model {p}\{p\}. This is also the only stable model.
  • P={p←not q, q←not p}P = \{p \leftarrow \mathit{not}\ q,\ q \leftarrow \mathit{not}\ p\}. The completion {p↔¬q, q↔¬p}\{p \leftrightarrow \neg q,\ q \leftrightarrow \neg p\} has the models {p}\{p\} and {q}\{q\}, the same as the stable models.
  • P={p←not p}P = \{p \leftarrow \mathit{not}\ p\}. The completion p↔¬pp \leftrightarrow \neg p is inconsistent. The program has no stable model either.
  • Non-example of agreement. P={p←p}P = \{p \leftarrow p\} has the completion p↔pp \leftrightarrow p, with models ∅\emptyset and {p}\{p\}. The only stable model is ∅\emptyset, because nothing derives pp. The completion accepts support through a positive cycle, which the stable model semantics rejects. Fages' theorem says that without positive cycles the two agree, and loop formulas are the clauses that must be added to the completion to make them agree in general.
  • First order. For even(0)\mathit{even}(0) and even(s(s(X)))←even(X)\mathit{even}(s(s(X))) \leftarrow \mathit{even}(X), the completed definition is ∀x (even(x)↔x=0∨∃y (x=s(s(y))∧even(y)))\forall x\, (\mathit{even}(x) \leftrightarrow x = 0 \vee \exists y\, (x = s(s(y)) \wedge \mathit{even}(y))). With the equality axioms it entails ¬even(s(0))\neg \mathit{even}(s(0)), which SLDNF resolution derives by finite failure.
  • Supported model. A model MM of PP in which each true atom is the head of a rule whose body is true in MM; the same as a model of the completion.
  • Stable model. Every stable model is supported, so it is a model of the completion. The converse holds for tight programs (Fages' theorem).
  • Tight program. A program whose positive dependency graph has no cycle. For a tight program, the completion and the stable models coincide.
  • Closed-world assumption. For a definite program, the closed-world assumption makes false every ground atom that is not a consequence. The completion is weaker: it makes false only what follows from the "only if" halves, so on {p←p}\{p \leftarrow p\} it leaves pp open, while the closed-world assumption makes pp false.
  • Clausal form. For a finite ground program, the completion becomes a set of clauses of size linear in the program after one new atom is introduced for each rule body. Answer set solvers such as ASSAT and clasp give these clauses to a SAT solver or use them in unit propagation.

References

  1. Keith L. Clark, Negation as failure, in Hervé Gallaire and Jack Minker (eds.), Logic and Data Bases, Plenum Press, New York, 293 to 322 (1978), the definition of the completed database and the soundness of negation as failure for it
  2. John W. Lloyd, Foundations of Logic Programming, 2nd edition, Springer (1987), the chapter on normal programs, the completion and its equality axioms
  3. Krzysztof R. Apt and Roland N. Bol, Logic programming and negation: a survey, Journal of Logic Programming 19/20, 9 to 71 (1994), the section on the completion semantics
  4. Fangzhen Lin and Yuting Zhao, ASSAT: computing answer sets of a logic program by SAT solvers, Artificial Intelligence 157(1-2), 115 to 137 (2004), the completion of a finite propositional program as a set of clauses

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/JRMWPA/text.yaml