Consider using the built-in predicates true/0 and false/0 directly, and use toplevel to display the results (regardless of the next few write/1 calls, use format/2 ):
boolean(true). boolean(false). cnf(X, Y, Z) :- maplist(boolean, [X,Y,Z]), (\+ X; Y ; \+ Z), ( X ; \+ Y ; Z), ( X ; Y ; Z), ( \+ X ; \+ Y ; Z).
Example:
?- cnf(X, Y, Z). X = true, Y = true, Z = true .
EDIT . As @repeat explained, also take a serious look at CLP (B): Constraint Solving over Booleans.
With CLP (B) you can write the whole program above:
:- use_module(library(clpb)). cnf(X, Y, Z) :- sat(~X + Y + ~Z), sat(X + ~Y + Z), sat(X + Y + Z), sat(~X + ~Y + Z).
See @repeat answer for more on this.
source share