Here is the GNU-Prolog portion of the code with the solution limiting to the final domains:
$ gprolog | ?- [user]. compiling user for byte code... ten(A,B,C,D) :- fd_domain([A,B,C,D],0,9999999), 10
Ctrl + D
| ?- ten(A,B,C,D), fd_labeling([A,B,C,D]).
As you can see, it solves the problem of large ranges , for example, 0-9999999
A = 0 B = 0 C = 0 D = 10 ? ; A = 0 B = 0 C = 1 D = 9 ? ; A = 0 B = 0 C = 2 D = 8 ? ; ...
PS Thanks for Przemysław Kobylański for his blog with clear, very nice Prolog examples , where I found inspirational examples.
PPS When playing with finite domains, you can use fd_set_vector_max / 1 . In the above case, this is not necessary, but depending on the restriction it may be useful - in more detail, when Gnu-Prolog runs on ranges, when on vectors of possible values can be found in the manual "The ultimate domain resolver and built-in predicates - Introduction"