The most recent freqent question was about negation,
Carfield Yim asked :
I need to find the negation of a clause :
if Z is a member of list T and Y is not a member of T, member(Z,T) should return true and member(Y,T) should return false.
I would like to get the negation of this clause, i.e.: not(member(Z,T)) return false and not(member(Y,T)) return true.
Jean Michel LECONTE answered:
You can use the predicate \+(Goal) wich means not provable.
not/1 isn't a builtin in GNU Prolog
a possible definition of not/1 is :
not( Goal ) :- Goal, !, fail. not( Goal ) :- true.
Violetta Cavalli-Sforza <vcs@sfsu.edu> wrote:
not(P) :- P, !, fail ; true.
Daniel Diaz answered :
GNU-Prolog is an ISO Prolog, thus use \+ for the negation, see:
http://gnu-prolog.inria.fr/manual/manual040.html#toc141
If you want a not: not(Goal) :- \+ Goal.
Log in to post a comment.
The most recent freqent question was about negation,
Carfield Yim asked :
I need to find the negation of a clause :
if Z is a member of list T and Y is not a member of T, member(Z,T) should return true and member(Y,T) should return false.
I would like to get the negation of this clause, i.e.: not(member(Z,T)) return false and not(member(Y,T)) return true.
Jean Michel LECONTE answered:
You can use the predicate \+(Goal) wich means not provable.
not/1 isn't a builtin in GNU Prolog
a possible definition of not/1 is :
not( Goal ) :- Goal, !, fail.
not( Goal ) :- true.
Violetta Cavalli-Sforza <vcs@sfsu.edu> wrote:
not(P) :- P, !, fail ; true.
Daniel Diaz answered :
GNU-Prolog is an ISO Prolog, thus use \+ for the negation, see:
http://gnu-prolog.inria.fr/manual/manual040.html#toc141
If you want a not:
not(Goal) :-
\+ Goal.