michel levy a écrit :
?- X*X #=23.
no
I don't understand how this answer is produced.
I was expecting X #= 1..23
this is simplified as X = sqrt(23) which is not an integer.
?- X*X #=25.
X = 5
yes
I don't understand how this answer is produced.
I was expecting X #= 1..25
similarly this is X=sqrt(25)
BTW when dealing with non-linear constraint in GNU Prolog it is
important to define the initial domain of the variables.
For instance:
| ?- X*Y#=25.
No
because the max(X)*max(Y) overflows. So use for instance:
| ?- fd_domain(X,1,1000), X*Y#=23.
X = _#3(1..23)
Y = _#25(1..23)
You can also obtain a more precise domain using full lookahead
(using #= # instead of #= but the computation is more costly) :
| ?- fd_domain(X,1,1000), X*Y#=#25.
X = _#3(1:5:25@)
Y = _#25(1:5:25@)
Where (papers, books,..) is it possible to have informations on the
finite domains constraints resolution ?
You can have a look at the PVH's book:
P. Van Hentenryck. Constraint Satisfaction in Logic Programming.
Logic Programming Series, The MIT Press, 1989.
There a lot of other articles (do a search on google with:
constraint finite domain propagation)...
Hope this helps
_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog