# [eclipse-users] Why expression in constraint breaks at run-time

From: Bill Wood <william.wood3_at_...71...>
Date: Tue, 31 Jul 2007 12:30:20 -0500
This is driving me nuts.  I am fairly comfortable with Prolog but I'm a
newbie with eclipse.

I used tkeclipse+emacs to, first, build, compile and run a file with
SEND_MORE_MONEY example; it went flawlessly.  I then started modifying
the file to solve a different constraint problem, involving a collection
of digits with constraints on various subsets of them.  Here's the
modified file:

foo( Digits ) :-
Digits = [D01,D02,D03,D04,D05,D06,D07,D08,D09,D10],
Digits :: [0 .. 9],
alldifferent( Digits ),
D01 #\= 0,

(D02 * 100 + D03 * 10 + D04) mod 2 #= 0,
(D03 * 100 + D04 * 10 + D05) mod 3 #= 0,
(D04 * 100 + D05 * 10 + D06) mod 5 #= 0,
(D05 * 100 + D06 * 10 + D07) mod 7 #= 0,
(D06 * 100 + D07 * 10 + D08) mod 11 #= 0,
(D07 * 100 + D08 * 10 + D09) mod 13 #= 0,
(D08 * 100 + D09 * 10 + D10) mod 17 #= 0,
labeling( Digits ).

Doing make in tkeclipse seems to go OK -- I only get the following in
the Message window:

fubb.ecl   compiled traceable 2952 bytes in 0.00 seconds

But when I place the query "foo(Digits)." in the Query window and hit
return I get the following message:

number expected in mod(D02{0 .. 9} * 100 + D03{0 .. 9} * 10 +
D04{0 .. 9}, 2, _894{-1.0Inf .. 1.0Inf})

It looks like a complaint about unbound variables in the expression, but
I can't figure out why the constraints in the SEND_MORE_MONEY can have
variables and the constraints can't.  The tutorial explicitly says that
"IC supports a range of mathematical operators beyond +/2, -/2, */2,
etc.  See the IC chapter in the Constraint Library Manual for full
details." (pg. 78).  Page 70 of the User Manual describes the mod
operator.  I haven't seen anything about some operators being
unavailable in constraint expressions.

-- Bill Wood
Received on Tue Jul 31 2007 - 18:32:06 CEST

This archive was generated by hypermail 2.3.0 : Sun Aug 25 2019 - 06:15:49 CEST