Negation as failure
Negation as failure (NAF, for short) is a non-monotonic inference rule in logic programming, used to derive (i.e. that is assumed not to hold) from failure to derive . Note that can be different from the statement of the logical negation of , depending on the completeness of the inference algorithm and thus also on the formal logic system.
Negation as failure has been an important feature of logic programming since the earliest days of both Planner and Prolog. In Prolog, it is usually implemented using Prolog's extralogical constructs.
Planner semantics
In Planner, negation as failure could be implemented as follows:
- if (not (goal p)), then (assert ¬p)
which says that if an exhaustive search to prove p fails, then assert ¬p.[1] This states that proposition p shall be assumed as "not true" in any subsequent processing. However, Planner not being based on a logical model, a logical interpretation of the preceding remains obscure.
Prolog semantics
In pure Prolog, NAF literals of the form can occur in the body of clauses and can be used to derive other NAF literals. For example, given only the four clauses
NAF derives , and .
Completion semantics
The semantics of NAF remained an open issue until Keith Clark [1978] showed that it is correct with respect to the completion of the logic program, where, loosely speaking, "only" and are interpreted as "if and only if", written as "iff" or "".
For example, the completion of the four clauses above is
The NAF inference rule simulates reasoning explicitly with the completion, where both sides of the equivalence are negated and negation on the right-hand side is distributed down to atomic formulae. For example, to show , NAF simulates reasoning with the equivalences
In the non-propositional case, the completion needs to be augmented with equality axioms, to formalise the assumption that individuals with distinct names are distinct. NAF simulates this by failure of unification. For example, given only the two clauses
- t
NAF derives .
The completion of the program is
augmented with unique names axioms and domain closure axioms.
The completion semantics is closely related both to circumscription and to the closed world assumption.
Autoepistemic semantics
The completion semantics justifies interpreting the result of a NAF inference as the classical negation of . However, Michael Gelfond [1987] showed that it is also possible to interpret literally as " can not be shown", " is not known" or " is not believed", as in autoepistemic logic. The autoepistemic interpretation was developed further by Gelfond and Lifschitz [1988] and is the basis of answer set programming.
The autoepistemics semantics of a pure Prolog program P with NAF literals is obtained by "expanding" P with a set of ground (variable-free) NAF literals Δ that is stable in the sense that
- Δ = { | is not implied by P ∪ Δ}
In other words, a set of assumptions Δ about what can not be shown is stable if and only if Δ is the set of all sentences that truly can not be shown from the program P expanded by Δ. Here, because of the simple syntax of pure Prolog programs, "implied by" can be understood very simply as derivability using modus ponens and universal instantiation alone.
A program can have zero, one or more stable expansions. For example,
has no stable expansions.
has exactly one stable expansion Δ = {}
has exactly two stable expansions Δ1 = {} and Δ2 = {}.
The autoepistemic interpretation of NAF can be combined with classical negation, as in extended logic programming and answer set programming. Combining the two negations, it is possible to express, for example
- (the closed world assumption) and
- ( holds by default).
Footnotes
- Clark, Keith (1978). Logic and Data Bases (PDF). Springer-Verlag. pp. 293–322 (Negation as a failure). doi:10.1007/978-1-4684-3384-5_11.
References
- K. Clark [1978, 1987]. Negation as failure. Readings in nonmonotonic reasoning, Morgan Kaufmann Publishers, pages 311-325.
- M. Gelfond [1987] On Stratified Autoepistemic Theories Proc. AAAI 1987, pages 207-211.
- M. Gelfond and V. Lifschitz [1988] The Stable Model Semantics for Logic Programming Proc. 5th International Conference and Symposium on Logic Programming (R. Kowalski and K. Bowen, eds), MIT Press, pages 1070-1080.
- J.C. Shepherdson [1984] Negation as Failure: A Comparison of Clark's Completed Data Dase and Reiter's Closed World Assumption, Journal of Logic Programming, vol 1, 1984, pages 51–81.
- J.C. Shepherdson [1985] Negation as Failure II, Journal of Logic Programming, vol 3, 1985, pages 185-202.
External links
- Report from the W3C Workshop on Rule Languages for Interoperability. Includes notes on NAF and SNAF (scoped negation as failure).