\+/1\+ +P
Fails if the goal P has a solution, and succeeds otherwise.
This is not real negation ("P is
false"), which is not possible in Prolog, but negation-by-failure
meaning "P is not provable". P may not contain a
cut. The goal \+ P behaves exactly like
( P -> fail ; true)
type_error
context_error
Remember that with prefix operators such as this
one, it is necessary to be careful about spaces if the argument starts
with a (. For example:
| ?- \+ (P, Q).
is the \+/1 operator applied to the conjunction of P
and Q,
but
| ?- \+(P, Q).
would require a predicate \+/2 for its solution. The
prefix
operator can, however, be written as a functor of one argument; thus
| ?- \+((P,Q)).
is also correct.
library(not) -- defines a safer form of
negation as failure.