next up previous
Next: Negation Examples Up: prolog Previous: Prolog Lispism

Negation

How can Prolog handle verification that a goal is not entailed by the knowledge base?

The not predicate.

Consider the program:

bachelor(P) :- male(P), not(married(P)).

male(henry).
male(tom).

married(tom).

Then

?- bachelor(henry).
yes
?- bachelor(tom).
no
?- bachelor(Who).
Who= henry ;
no
?- not(married(Who)).
no.