projog

3.46. \+ X - "not".

The \+ X goal succeeds if an attempt to satisfy the goal represented by the term X fails. The \+ X goal fails if an attempt to satisfy the goal represented by the term X succeeds.

Examples

?- \+ true.

no

?- \+ fail.

yes

Note: "not" is a synonym for "\+".

?- not(true).

no

?- not(fail).

yes

?- \+ [A,B,C,9]=[1,2,3,4], A=6, B=7, C=8.
A = 6
B = 7
C = 8

yes

?- \+ ((X=Y,1>2)), X=1, Y=2.
X = 1
Y = 2

yes

test1(X,Y) :- \+ ((X=Y,1>2)), X=1, Y=2.

?- test1(X,Y).
X = 1
Y = 2

yes

test2(X) :- \+ \+ X=1, X=2.

?- test2(X).
X = 2

yes

?- test2(1).

no

?- test2(2).

no