Conceptcore
Negation as failure
Also called default negation.
The negation not p in a rule body holds when p cannot be derived. Each semantics of logic programs reads "cannot be derived" in its own way, and all of them are nonmonotonic.
Negation as failure is the reading of in a rule body as " cannot be derived", not as " is false" in classical logic. Clark (1978) introduced it as a proof rule: succeeds when every attempt to prove fails finitely. That procedure, with its soundness proof and its limits, is the subject of SLDNF resolution, and the restricted form used in databases, where negation applies only to relations that are already computed, is covered with Datalog. This page is about the idea itself and the main ways to give it a meaning: the completion, the perfect model of stratified programs, stable models and the well-founded model. On some programs these readings agree, and on others they differ.
In plain words
A timetable lists the trains that run. If a train is not in the list, you conclude that it does not run, although the list never says so. Negation as failure is this habit, written into rules: "a train is cancelled if it is not listed as running". The conclusion can change. If a new train is added to the list, an old conclusion about it goes away. Classical logic never loses a conclusion when facts are added, so this is a different kind of negation. The hard cases are rules that depend on their own negation, such as "p holds if p does not hold". Different theories give such rules different meanings, and the choice of theory is the choice of what "cannot be derived" means.
The idea
A normal rule has the form . In a closed world, a definite program (with in every rule) means its least model: what is derived is true, and the rest is false. Negation as failure lets rules refer to that "rest". The trouble is that a rule body can depend on what is not derived, while what is derived depends on the rule bodies. The semantics differ in how they break this circle.
- Finite failure and the completion. Clark read the rules for each atom as an "if and only if" definition, the completion, and proved that finite failure of is sound for in it.
- Stratification. If no atom depends on its own negation through a cycle, the program is evaluated in layers, and each negation refers to a layer that is already complete (Apt, Blair and Walker 1988).
- Stable models. Guess a set of true atoms, read as true exactly when , and keep if the rules then derive exactly (Gelfond and Lifschitz 1988). A program can have no, one or many stable models.
- The well-founded model. Derive only what is forced, and make an atom false when it can only be derived through itself. The result is one three-valued model, with some atoms undefined (Van Gelder, Ross and Schlipf 1991).
The negation is nonmonotonic: with , the program derives , but after adding the fact it does not. It is also not classical: as a formula, would be , which has the two minimal models and , while every semantics above gives only. Answer set programming adds a second, strong negation for atoms that are explicitly false, next to .
Examples
The table gives the meaning of four small ground programs. For the completion and the stable models it lists all models; for the well-founded semantics, the true and false atoms. SLDNF resolution is run on the query .
| program | completion | stable models | well-founded model | SLDNF on |
|---|---|---|---|---|
| true, false | succeeds | |||
| no model | none | undefined | does not terminate | |
| , | , | , | , undefined | does not terminate |
| , | false | does not terminate |
The first program is stratified, and all readings agree. The second has no stable model: the guess blocks the only rule for , and the guess derives . The third has two stable models, while the well-founded semantics, which must give one answer, leaves both atoms undefined. The fourth shows the difference between the completion and the other readings: allows to be true, but nothing derives it.
A classic use is a default with an exception:
flies(X) ← bird(X), not abnormal(X).
abnormal(X) ← penguin(X).
bird(tweety). bird(sam). penguin(sam).
Every reading gives and not . Adding removes the first conclusion.
Where it is used
- Prolog. The operator
\+implements negation as finite failure, with the restrictions and the unsoundness for non-ground calls that the SLDNF page describes. - Deductive databases and SQL. Stratified negation in Datalog corresponds to
NOT EXISTSandEXCEPTon relations that are computed first. - Answer set programming. Answer set programming uses the stable model reading to state search problems: rules such as and make a choice.
- Tabled Prolog systems. SLG resolution computes the well-founded model goal by goal, and terminates where SLDNF resolution loops.
- Knowledge representation. Defaults with exceptions, the frame problem in reasoning about actions, and the closed-world assumption are all written with negation as failure. It is one form of nonmonotonic reasoning, and stable models correspond to the extensions of a default theory.
References
- 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 negation as failure rule and the completed database
- Krzysztof R. Apt, Howard A. Blair and Adrian Walker, Towards a theory of declarative knowledge, in Jack Minker (ed.), Foundations of Deductive Databases and Logic Programming, Morgan Kaufmann, 89 to 148 (1988), stratified programs and their standard model
- Michael Gelfond and Vladimir Lifschitz, The stable model semantics for logic programming, in Robert A. Kowalski and Kenneth A. Bowen (eds.), Logic Programming: Proceedings of the Fifth International Conference and Symposium, MIT Press, 1070 to 1080 (1988), the reading of not as failure to derive relative to a guessed set of beliefs
- Allen Van Gelder, Kenneth A. Ross and John S. Schlipf, The well-founded semantics for general logic programs, Journal of the ACM 38(3), 620 to 650 (1991), the three-valued reading of negation through unfounded sets
- Krzysztof R. Apt and Roland N. Bol, Logic programming and negation: a survey, Journal of Logic Programming 19/20, 9 to 71 (1994), the comparison of the semantics of negation in logic programs
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag ZRPTR9 Edit this page History Report an error Markdown