Mercury约束求解

Mercury Constraint Solving

我懂一点Prolog,经常使用CLP(FD)等This paper (written in 2006, apparently) indicates that Mercury now has constraint solving, too. I've found a few mentions of it in the Library Reference Manual.但是,我找不到如何使用它。例如:

main(!IO) :-
   A >= 2,
   A =< 2,
   io.write(A, !IO).

给出编译器错误

test1.m:011: In clause for `main(di, uo)':
test1.m:011:   in argument 1 of call to predicate `int.>='/2:
test1.m:011:   mode error: variable `A' has instantiatedness `free',
test1.m:011:   expected instantiatedness was `ground'.

但在 Prolog 中,使用 clpfd,

A #>= 2, A #=< 2.

工作正常,给出 A = 2 。

(在 Mercury 代码中添加 #s 没有帮助。)

你如何在Mercury中进行约束求解?

那篇论文没有说你现在可以在 Mercury 中进行约束求解 就像您在 Prolog 中所做的一样。它描述了添加到 Mercury 的功能 当时支持在Mercury中编写约束求解器,然后 使用生成的求解器,这是完全不同的。

Mercury 没有,将来也不会有任何内置约束求解器。