I've started learning PROLOG and I have a problem with a very basic example. I'm using SWI PROLOG and the code is as follows:
is_true(a).
is_true(c).
is_true(d).
is_false(b).
is_false(e).
and(A,B) :- is_true(A),is_true(B).
nand(A,B) :- \+(and(A,B)).
Then:
[imanol@I56106 prolog]$ swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.6.4)
Copyright (c) 1990-2013 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- consult(test).
% test compiled 0.00 sec, 8 clauses
true.
?- and(a,X).
X = a ;
X = c ;
X = d.
Everything is great ATM, I made PROLOG backtrack all the possible values that comply the goal and(A,B) for A=a. But if I try with the goal nand(A,B):
?- nand(a,X).
false.
Either it thinks that the goal is impossible or it doesn't backtrack, and I haven't got the slightest clue why. :/
Does someone know what I'm doing wrong?
Thanks in advance.
PS: I also tried with:
nand(A,B) :- not(and(A,B)).
And it yields the same result.
EDIT: Seeing that my question is cryptic for some:
I'd like PROLOG to give me a list of values for the variables A and B which make and(A,B) unsatisfiable
EDIT2: I expect PROLOG to tell me:
?- nand(a,X).
X = e ;
X = b.