Q:

Goal satisfaction with negated variable in Prolog

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.

A:

A simplistic approach would be to introduce a predicate that succeeds for a valid variable. So to your existing predicates, add:
is_valid(X) :- is_true(X) ; is_false(X).

Then the nand/2 predicate can work within that domain and confine the universe of possible values. Otherwise, \+ and(A, B) has no idea what values to choose from to determine failure of and(A, B):
nand(A, B) :- is_valid(A), is_valid(B), \+ and(A, B).

| ?- nand(a, X).

X = b ? ;

X = e ? ;

no

Stated another way, is_valid/1 provides a means for nand/2 to generate the possible options for which \+ and(A, B) can be tested.
You could just as reasonably apply this "confining of the universe" to the other predicates, such as and/2: and(A, B) :- is_valid(A), is_valid(B), is_true(A), is_true(B)., but you can see that this would be redundant.

