1 / 18

Negation by Failure

Negation by Failure. t.k.prasad@wright.edu http://www.knoesis.org/tkprasad/. Motivation. p(X) :- q(X). q(a). ?-q(a). true ?-p(a). true ?-q(b). false ?-p(b). false

Download Presentation

Negation by Failure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Negation by Failure t.k.prasad@wright.edu http://www.knoesis.org/tkprasad/ L7Negation

  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?” L7Negation

  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 . L7Negation

  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 L7Negation

  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. L7Negation

  6. Monotonic vs non-monotonic entailment L7Negation

  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 L7Negation

  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. L7Negation

  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. L7Negation

  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. L7Negation

  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. L7Negation

  12. Example: Incorrect use of \+ • X is at home if X is not out. • Sue is out. • John is Sue’s 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?” L7Negation

  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. L7Negation

  14. Recursion through Negation Revisited p :- \+q. q :- \+p. Logically equivalent to:p v q • Ambiguity • Minimal models {p} and {q}. L7Negation

  15. Stratified Negation p1 :- p2, \+q. … p2 :- p1, \+ r2. q1 :- q2, q3, \+r1. … q4. r1 :- r2. r2. L7Negation

  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 L7Negation

  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. L7Negation

  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. L7Negation

More Related