Hello,

I'd like to point out a couple of questionable situations in GnuProlog when dealing with FD variables with large domains (eg default domain).

- A*B #= C.                           no
- fd_domain([A,B,C],0,1000000),
  A*B #= C.                           no
- fd_domain([A,B,C],0,10000000),
  A*B #= C.                           yes
- X#<1000000,  4321 rem X #= 1.       no
- X#<10000000, 4321 rem X #= 1.       yes
-   X*X #= Y.                         yes
- X*X*X #= Y.                         no
-  X**3 #= Y.                         yes

Some of these issues might be due to integer overflow. My "numerical problem sniffer" tool suggested for instance to double-check this code snippet from BipsFD/fd_math_fd.fd:

pl_xy_eq_z(fdv X, fdv Y, fdv Z) {
 ...
 start Z in min(X)*min(Y)..max(X)*max(Y)
}

Depending how it gets translated, the integer multiplication might overflow.

Am I off-topic? If not, do you think it is desirable to provide a "mode" where it is ensured that propagation rules avoids overflows that could crash a domain? Could it be proposed as a student project (for how many hours of work)?

Best regards.

_______________________________________________
Users-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/users-prolog

Reply via email to