0

This gives me a result:

?- {5/(X) = (5/2)}.
X = 2.0 ;

This shows me a constraint, but doesn't let me use X in any material way:

?- {5/(3-X) = (5/2)}.
{-2.5+5/(3-X)=0.0}.

?- {5/(3-X) = (5/2)}, Z is X.
ERROR: Arguments are not sufficiently instantiated

Of course, if I explicitly give the solution, the constraint goes away and it evaluates as true.

?- {5/(3-X) = (5/2)}, X = 1.
X = 1.

Why, and how can I make it work?

Name McChange
  • 2,750
  • 5
  • 27
  • 46

1 Answers1

0

See section A10.3 at https://www.swi-prolog.org/man/clpqr.html

However, clpBNR seems better:

?- pack_install(clpBNR).
?- use_module(library(clpBNR)).

?- {5/(3-X) =:= 5/2}, Z = X.
X = Z, Z = 1.
brebs
  • 3,462
  • 2
  • 3
  • 12
  • Interesting tip with clpBNR, but section A10.3 doesn't seem to answer my question. It says "Instead of using the {}/1 predicate, you can also use the standard unification mechanism to store constraints." – Name McChange May 18 '22 at 23:13
  • Instead of "Z is X", use one of the three methods shown at the bottom of section A.10.3, i.e.: `{Z =:= X}` or `{Z = X}` or `Z = X` – brebs May 19 '22 at 08:01