Hello,
When I load the following prolog program:
works(L) :-
L = [Z1, Z2],
fd_domain(L, 10, 99),
fd_prime(Z1),
cross_sum(Z1, Z2),
fd_labeling(L),
is_square(Z2)
.
broken(L) :-
L = [Z1, Z2],
fd_domain(L, 10, 99),
fd_prime(Z1),
cross_sum(Z1, Z2),
is_square(Z2),
fd_labeling(L)
.
cross_sum(X, X) :- X #<# 10.
cross_sum(X, Y) :- X #># 9, Y1 #=# X rem 10, X1 #=# X // 10,
cross_sum(X1, Z), Y #=# Z + Y1.
is_square(1).
is_square(4).
is_square(9).
is_square(X) :- fd_domain(Y, 1, X), X #=# Y * Y.
I get an error when invoking broken(L):
| ?- broken(L).
uncaught exception: error(type_error(integer,_#2097948(10..18)),fd_domain/3)
while works(L) gives me results:
| ?- works(L).
L = [79,16] ? ;
L = [97,16] ?
yes
The only difference between the two methods is the order of
fd_labeling(L) and is_square(Z2). To the best of my knowledge the order
should not matter. Thus, I assume that I hit a bug. Can you confirm this?
Information about my environment:
uname -a
Linux tp 2.6.32-5-amd64 #1 SMP Mon Oct 3 03:59:20 UTC 2011 x86_64 GNU/Linux
gprolog --version
Prolog top-Level (GNU Prolog) 1.4.0
Best regards,
Robert