\+/1

Synopsis

\+ +P

Fails if the goal P has a solution, and succeeds otherwise.

Arguments


P callable [MOD]

Description

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)
     

Exceptions


type_error

context_error

Tip

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.

See Also

library(not) -- defines a safer form of negation as failure.