I want to write a program in SWI-Prolog that solves equations. I know GNU Prolog and that makes me nervous... What is wrong here?
equation(X1,X2) :-
{
2*X1 + 3*X2 =:= 6,
{X1 is 0; X1 is 1},
{X2 is 0; X2 is 1}
}.
X1 and X2 always equal to 0 or 1.
I have a file with
then I compile and run and I get:
It's the result you're expecting?
edit
Section A.8.3 of the documentation says that unification can hold 'outside' constraints specification. Then you can experiment freely with additional bounding. But if you impose that both A and B will bind, you should choose appropriate values. AFAIK the values you posted initially cannot satisfy the equation.