简体   繁体   English

汞约束求解

[英]Mercury Constraint Solving

I know a little Prolog, and frequently use CLP(FD) etc. This paper (written in 2006, apparently) indicates that Mercury now has constraint solving, too.我知道一点 Prolog,经常使用 CLP(FD) 等。这篇论文(显然是 2006 年写的)表明 Mercury 现在也有约束求解。 I've found a few mentions of it in the Library Reference Manual.我在图书馆参考手册中发现了一些关于它的提及 However, I can't find how to use it.但是,我找不到如何使用它。 For instance:例如:

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

gives compiler error给出编译器错误

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'.

but in Prolog, with clpfd,但是在 Prolog 中,使用 clpfd,

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

works fine, giving A = 2 .工作正常,给出 A = 2 。

(Adding #s to the Mercury code doesn't help.) (在 Mercury 代码中添加 #s 没有帮助。)

How do you do constraint solving in Mercury?您如何在 Mercury 中进行约束求解?

That paper does NOT say the you can now do constraint solving in Mercury the same way as you can do in Prolog.那篇论文没有说您现在可以像在 Prolog 中一样在 Mercury 中进行约束求解。 It describes features added to Mercury at the time to support writing constraint solvers in Mercury, and then using the resulting solvers, which is quite different.它描述了当时添加到 Mercury 的功能,以支持在 Mercury 中编写约束求解器然后使用生成的求解器,这是完全不同的。

Mercury does not have, and will not have, any builtin constraint solvers. Mercury 没有也不会有任何内置的约束求解器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM