Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make this CLP(FD) query terminate in a shorter time?

I have the following CLP(FD) query:

?- use_module(library(clpfd)).
?- [I,N,M,J] ins -2147483648..2147483647, 
I - 3*N #= X, X in 1..2, 
I - 5*M #= Y, Y in 1..4, 
I - 15*J #= 0.

In SWI-Prolog already when posing the query without a label/1 goal, the interpreter practically hangs. I don't expect it to terminate in a short time.

How can I modify the query, some reordering etc.. so that it delivers the expected answer "false"?

Bye

P.S.: After pressing ^C and t after some while, I see that the CLP(FD) system is still busy.


1 Answers

Very easy:

First, replace I by J*15 ; and put the big domains last:

?- 15*J - 3*N #= X, X in 1..2, 
      15*J - 5*M #= Y, Y in 1..4, 
      I #= 15*J,
      [I,N,M,J] ins -2147483648..2147483647.
   false.

Factors as above are not always detected, and propagation as such is weak since it could easily blow up the representation of the domain.

like image 117
false Avatar answered Dec 08 '25 22:12

false