结果如下:
?- {5/(X) = (5/2)}.
X = 2.0 ;
这给了我一个约束,但不允许我以任何实质性的方式使用X
:
?- {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
当然,如果我显式地给出解,约束就消失了,结果为真。
?- {5/(3-X) = (5/2)}, X = 1.
X = 1.
为什么,我怎样才能使它工作?
参见https://www.swi-prolog.org/man/clpqr.html
然而,clpBNR似乎更好:
?- pack_install(clpBNR).
?- use_module(library(clpBNR)).
?- {5/(3-X) =:= 5/2}, Z = X.
X = Z, Z = 1.