ArticleslgStudy

science

Negation as failure

Negation as failure is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Negation as failure rather than just read about it. In short: Negation as failure (NAF, for short) is a non-monotonic inference rule in logic programming, used to derive not p (i.e. that p is assumed not to hold) from failure to derive p. Note that not p can be different from the statement ¬p of the logical negation of p, depending on the completeness of the inference algorithm and thus also on the formal logic system.

Key takeaways

  • Negation as failure belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Negation as failure to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Negation as failure from memory before moving on to harder problems.

Reference excerpt

Negation as failure (NAF, for short) is a non-monotonic inference rule in logic programming, used to derive not p (i.e. that p is assumed not to hold) from failure to derive p. Note that not p can be different from the statement ¬p of the logical negation of p, 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. More generally, this kind of negation is known as weak negation, in contrast with the strong (i.e. explicit, provable) negation.

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. 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 not p can occur in the body of clauses and can be used to derive other NAF literals. For example, given only the four clauses

p←q∧not r q←s q←t t← NAF derives not s, not r and p as well as t and q.

Completion semantics The semantics of NAF remained an open issue until 1978, when Keith Clark 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

p≡q∧not r q≡s∨t t≡true r≡false s≡false 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 not p, NAF simulates reasoning with the equivalences

not p≡not q∨r not q≡not s∧not t not t≡false not r≡true not s≡true In the non-propositional case, the completion needs to be augmented with equality axioms, to formalize the assumption that individuals with distinct names are distinct. NAF simulates this by failure of unification. For example, given only the two clauses

p(a)← p(b)←t NAF derives not p(c). The completion of the program is

p(X)≡X=a∨X=b 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 not p of a NAF inference as the classical negation ¬p of p. However, in 1987, Michael Gelfond showed that it is also possible to interpret not p literally as "p can not be shown", "p is not known" or "p is not believed", as in autoepistemic logic. The autoepistemic interpretation was developed further by Gelfond and Lifschitz in 1988, and is the basis of answer set programming. The autoepistemic 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

Δ = {not p | p 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,

p←not p has no stable expansions.

p←not q has exactly one stable expansion Δ = {not q}

p←not q q←not p has exactly two stable expansions Δ1 = {not p} and Δ2 = {not q}. 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

¬p←not p (the closed world assumption) and p←not ¬p (p holds by default).

Footnotes

References

External links Report from the W3C Workshop on Rule Languages for Interoperability. Includes notes on NAF and SNAF (scoped negation as failure).

Worked examples

Example 1 — a first encounter with Negation as failure

Start with the simplest possible case. Write down what Negation as failure claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Negation as failure before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Negation as failure ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Negation as failure

In research
Negation as failure appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Negation as failure in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Negation as failure is common in secondary-school and first-year university syllabi. It links to neighbouring topics Logic programming, Rules of inference, so understanding it makes those chapters shorter.
In everyday life
Look for Negation as failure outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Negation as failure” →

How to study Negation as failure in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Negation as failure means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Negation as failure out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Negation as failure in simple terms?

Negation as failure (NAF, for short) is a non-monotonic inference rule in logic programming, used to derive not p (i.e. that p is assumed not to hold) from failure to derive p. Note that not p can be different from the statement ¬p of the logical negation of p, depending on the completeness of the…

Why does Negation as failure matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Negation as failure?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Negation as failure.

Tags

  • Logic programming
  • Rules of inference

Keep exploring