Negation by Failure t k prasadwright edu http
Negation by Failure t. k. prasad@wright. edu http: //www. knoesis. org/tkprasad/ cs 774 (Prasad) L 7 Negation 1
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? ” cs 774 (Prasad) L 7 Negation 2
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. cs 774 (Prasad) L 7 Negation 3
‘Negation as failure’ operator (in the query) p(X) : - q(X). q(a). ? ? ? cs 774 (Prasad) q(a). p(a). q(b). + p(b). L 7 Negation true false true 4
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. cs 774 (Prasad) L 7 Negation 5
Monotonic vs non-monotonic entailment cs 774 (Prasad) L 7 Negation 6
‘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 cs 774 (Prasad) L 7 Negation 7
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. cs 774 (Prasad) L 7 Negation 8
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. cs 774 (Prasad) L 7 Negation 9
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. cs 774 (Prasad) 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. L 7 Negation 10
Example: Correct use of + • Hotel is full if there are no vacant rooms. • Room 13 is vacant. • Room 113 is vacant. hotel. Full : - + vacant. Room(X). vacant. Room(13). vacant. Room(113). ? - hotel. Full. • No, because there are vacant rooms. – Note that some implementations will complain about variables inside negated goals, as explained later. cs 774 (Prasad) L 7 Negation 11
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? ” cs 774 (Prasad) L 7 Negation 12
Example: Characteristics of + student(bill). married(joe). unmarried. Student(X): + married(X), student(X). ? - unmarried. Student(X). False. bachelor(X): student(X), + married(X). ? - bachelor(X). X = bill • Negated goals do not generate bindings. cs 774 (Prasad) L 7 Negation 13
Recursion through Negation Revisited p : - + q. q : - + p. Logically equivalent to: p v q • Ambiguity • Minimal models {p} and {q}. cs 774 (Prasad) L 7 Negation 14
Stratified Negation p 1 : - p 2, + q. … p 2 : - p 1, + r 2. q 1 : - q 2, q 3, + r 1. … q 4. r 1 : - r 2. cs 774 (Prasad) L 7 Negation 15
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 cs 774 (Prasad) L 7 Negation 16
Example: Common-sense Reasoning fly(X) : bird(X) : eagle(X). bird(tweety). eagle(toto). ? - fly(tweety). ? - fly(toto). True. • Monotonic reasoning? Birds fly. cs 774 (Prasad) L 7 Negation 17
Example: Common-sense Reasoning (Exceptions) fly(X) : - bird(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. cs 774 (Prasad) L 7 Negation 18
- Slides: 18