2

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

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

works fine, giving A = 2 .

(Adding #s to the Mercury code doesn't help.)

How do you do constraint solving in Mercury?

Erhannis
  • 4,256
  • 4
  • 34
  • 48
  • We added support for constraint solving to Mercury to aid the G12 project, who used it to build MiniZinc, which you can read about and download from minizinc.org. I believe most further development is proprietary; see opturion.com. – Zoltan Somogyi Nov 18 '20 at 02:54
  • @ZoltanSomogyi Oh - do you mean "we originally added the existing support for constraint solvers, as discussed, to help G12, and here are some details", or do you mean "we have recently added a constraint solver to Mercury, to help G12, and here are some details", or do you mean something else? – Erhannis Nov 18 '20 at 05:45

1 Answers1

0

That paper does NOT say the you can now do constraint solving in Mercury the same way as you can do in Prolog. 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 does not have, and will not have, any builtin constraint solvers.

  • Oh, you're right - weird, it's super easy to misinterpret so many of the paper's statements to mean "constraint solvers" rather than "constraint solver SUPPORT/INFRASTRUCTURE". Do you know if there are any good solver libraries implemented, and where to find them? – Erhannis Mar 17 '20 at 17:55