+ All Categories
Home > Documents > Negation by Failure

Negation by Failure

Date post: 25-Feb-2016
Category:
Upload: noura
View: 51 times
Download: 0 times
Share this document with a friend
Description:
Negation by Failure. [email protected] http://www.knoesis.org/tkprasad/. Motivation. p(X) :- q(X). q(a). ?-q(a). true ?-p(a). true ?-q(b). false ?-p(b). false - PowerPoint PPT Presentation
Popular Tags:
18
cs774 (Prasad) L7Negation 1 Negation by Failure [email protected] http://www.knoesis.org/ tkprasad/
Transcript
Page 1: Negation by Failure

cs774 (Prasad) L7Negation 1

Negation by Failure

[email protected]://www.knoesis.org/tkprasad/

Page 2: Negation by Failure

Motivationp(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?”

cs774 (Prasad) L7Negation 2

Page 3: Negation by Failure

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 .

cs774 (Prasad) L7Negation 3

Page 4: Negation by Failure

‘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

cs774 (Prasad) L7Negation 4

Page 5: Negation by Failure

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.

cs774 (Prasad) L7Negation 5

Page 6: Negation by Failure

Monotonic vs non-monotonic entailment

cs774 (Prasad) L7Negation 6

wvw

,

wv

w

,

}){()(:icityNonmonoton

TheoremsTheorems

Page 7: Negation by Failure

‘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

cs774 (Prasad) L7Negation 7

Page 8: Negation by Failure

Negation : Theory vs Practice

p :- \+ p.?-p.

Computation: infinite loopTranslation into logic: {p}

• Recursion through negation results in a computation that does not fail finitely.

cs774 (Prasad) L7Negation 8

Page 9: Negation by Failure

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.

cs774 (Prasad) L7Negation 9

Page 10: Negation by Failure

Negation Meta-predicate: Simulation using Cut

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.

cs774 (Prasad) L7Negation 10

Negation : Meaning

Page 11: Negation by Failure

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.cs774 (Prasad) L7Negation 11

Page 12: Negation by Failure

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

cs774 (Prasad) L7Negation 12

Page 13: Negation by Failure

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.

cs774 (Prasad) L7Negation 13

Page 14: Negation by Failure

Recursion through Negation Revisited

p :- \+ q.q :- \+ p.

Logically equivalent to: p v q

• Ambiguity • Minimal models {p} and {q}.

cs774 (Prasad) L7Negation 14

Page 15: Negation by Failure

Stratified Negation

cs774 (Prasad) L7Negation 15

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

Page 16: Negation by Failure

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

cs774 (Prasad) L7Negation 16

Page 17: Negation by Failure

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.

cs774 (Prasad) L7Negation 17

Page 18: Negation by Failure

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.

cs774 (Prasad) L7Negation 18


Recommended