Negation by Failure - PowerPoint PPT Presentation

About This Presentation
Title:

Negation by Failure

Description:

Title: Logic Programming Author: T. K. Prasad Last modified by: Prasad Created Date: 9/30/1996 6:28:10 PM Document presentation format: On-screen Show (4:3) – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 19
Provided by: TK5
Learn more at: http://cecs.wright.edu
Category:

less

Transcript and Presenter's Notes

Title: Negation by Failure


1
Negation by Failure
  • t.k.prasad_at_wright.edu
  • http//www.knoesis.org/tkprasad/

2
Motivation
  • p(X) - q(X).
  • q(a).
  • ?-q(a). true
  • ?-p(a). true
  • ?-q(b). false
  • ?-p(b). false
  • false really corresponds to cannot prove.
    That is, true and false are responses to the
    question Is it a theorem/logical consequence?

3
Closed World Assumption
  • The database is complete with respect to positive
    information.
  • That is, all positive atomic consequences are
    provable.
  • Failure to prove goal G can be interpreted as
    evidence that G is false, or that negation of G
    (that is, G) is true .

4
Negation as failure operator (in the query)
  • p(X) - q(X).
  • q(a).
  • ?- q(a). true
  • ?- p(a). true
  • ?- q(b). false
  • ?- \ q(b). true
  • ?- \ p(b). true

5
Nonmonotonic Reasoning
  • p(X) - q(X).
  • q(a).
  • q(b).
  • ?-q(b). true
  • ?-p(b). true
  • Previous conclusions (e.g., \ q(b), \ p(b),
    etc ) overturned/overridden when new facts are
    added.
  • This is in stark contrast with classical logics,
    where the set of theorems grows monotonically
    with the axioms.

6
Monotonic vs non-monotonic entailment
7
Negation as failure in a rule
  • p(X) - q(X), \ r(X).
  • q(a).
  • r(a).
  • q(b).
  • ?-p(a). false
  • ?-p(b). true
  • ?-q(c). false
  • ?-p(c). false
  • ?- \ p(c). true

8
Negation Theory vs Practice
  • p - \ p.
  • ?-p.
  • Computation infinite loop
  • Translation into logic p
  • Recursion through negation results in a
    computation that does not fail finitely.

9
Negation Theory vs Practice
  • p(X) - p(s(X)).
  • ?-p(a).
  • Computation infinite loop
  • ?- \ p(a).
  • Computation infinite loop
  • Ideally, the latter should succeed because p(a)
    is not provable from the input, but the Prolog
    query \ p(a) loops, as p(a) does not fail
    finitely.

10
Negation Meta-predicate Simulation using Cut
Negation Meaning
  • not(p) - p, !, fail.
  • not(p).
  • Informally, if p succeeds, then not(p) fails.
  • Else, not(p) succeeds.
  • p - \ q(X).
  • Informally, p succeeds if there is no x such that
    q(x) succeeds.
  • p fails if there is some x such that q(x)
    succeeds.

11
Example Correct use of \
  • Hotel is full if there are no vacant rooms.
  • Room 13 is vacant.
  • Room 113 is vacant.
  • hotelFull - \ vacantRoom(X).
  • vacantRoom(13).
  • vacantRoom(113).
  • ?- hotelFull.
  • No, because there are vacant rooms.
  • Note that some implementations will complain
    about variables inside negated goals, as
    explained later.

12
Example Incorrect use of \
  • X is at home if X is not out.
  • Sue is out.
  • John is Sues husband.
  • home(X)- \ out(X).
  • out(sue).
  • husband(john,sue).
  • ?- home(john). True.
  • ?- home(X). False.
  • Even though John is at home, it is not extracted.
  • I.e., the query is equivalent to Is everyone
    out?

13
Example Characteristics of \
  • student(bill).
  • married(joe).
  • unmarriedStudent(X)-
  • \ married(X), student(X).
  • ?- unmarriedStudent(X). False.
  • bachelor(X)-
  • student(X), \ married(X).
  • ?- bachelor(X). X bill
  • Negated goals do not generate bindings.

14
Recursion through Negation Revisited
  • p - \ q.
  • q - \ p.
  • Logically equivalent to p v q
  • Ambiguity
  • Minimal models p and q.

15
Stratified Negation
  • p1 - p2, \ q.
  • p2 - p1, \ r2.
  • q1 - q2, q3, \ r1.
  • q4.
  • r1 - r2.
  • r2.

16
Stratified Negation
  • Syntactic restriction for characterizing good
    programs
  • What is the purpose?
  • Associate unique meaning
  • How is it obtained?
  • Mutual recursion among same level predicates
  • Negated predicates / atoms must contain lower
    level predicates
  • No recursion through negation

17
Example Common-sense Reasoning
  • fly(X) - bird(X).
  • bird(X) - eagle(X).
  • bird(tweety).
  • eagle(toto).
  • ?- fly(tweety). True.
  • ?- fly(toto). True.
  • Monotonic reasoning?
  • Birds fly.

18
Example Common-sense Reasoning(Exceptions)
  • fly(X) - bird(X), \ abnormal(X).
  • abnormal(X) - penguin(X).
  • bird(X) - penguin(X).
  • penguin(tweety).
  • ?- fly(tweety). False.
  • Non-monotonic reasoning
  • Typically, birds fly.
  • Infer abnormality only if it is provable.
  • Otherwise, assume normal.
Write a Comment
User Comments (0)
About PowerShow.com