Re: lost access to domain variables?

From: Marco Gavanelli <mgavanelli_at_ing.unife.it>
Date: Fri 31 May 2002 01:58:45 PM GMT
Message-Id: <5.0.2.1.2.20020531155153.00a9c010@mail.ing.unife.it>
At 21:20 29/05/02 -0400, Sebastian Sardina wrote:
>Hello,
>
>Suppose I got the predicate:
>
>
>b:- [X,Y,Z] :: [1..2], X#\=Y, Y#\=Z.
>
>
>Variables X, Y, and Z are "local" to predicate b. So, after b succeeds
>I have no access to them.
>
>The query -? b. will suceeed, however, there will be some constraints
>pending:
>
>[eclipse 7]: b.
>
>Delayed goals:
>         X{[1, 2]} #\= Y{[1, 2]}
>         Y{[1, 2]} #\= Z{[1, 2]}
>Yes (0.00s cpu)
>
>
>
>Now, although b has succeeded it may be the case that the constraints
>pending are inconsistent. In that case, b did not fail because the
>propagation is limited.
>
>Now, is there any way to "recover" the pending  variables that have not
>been assigned any variable so far so that I can label them all and be
>sure that not only b succeeded but there is at least one possible
>consistent assignment to all the pending variables.
>
>I do not want to do the labeling "inside" b/0 tough, I just want to
>"recover" the variables that have pending constraints after b/0 has
>ended and see if it is possible to assign them some value.
>
>One easy way would be to make X, Y and Z arguments of b/0 so I would use
>b/3 instead, and then I can do the query:
>-? b(X,Y,Z), labeling([X,Y,Z]). Is there any other way so that I can
>keep my b/0? Since the pending constraints are stored in a kind of
>database constraints,  maybe there is some tool to retrive all "pending"
>variables....

Dear Sebastian,

You could retrieve all the pending constraints and then select the 
variables in the constraints; in your example:

[eclipse 5]: b, delayed_goals(DG), term_variables(DG,Variables), 
labeling(Variables).

DG = [1#\=2, 2#\=1]
Variables = [1, 2, 1]
More (0.00s cpu) ? ;

DG = [2#\=1, 1#\=2]
Variables = [2, 1, 2]
Yes (0.00s cpu)
[eclipse 6]:

If the constraints are inconsistent, as in:

b1 :- [X,Y,Z] :: [1..2], X#\=Y, Y#\=Z, X #\= Z.

you get:

[eclipse 6]: b1, delayed_goals(GD), term_variables(GD,V), labeling(V).

No (0.00s cpu)

Best regards,
Marco
Received on Fri May 31 14:56:24 2002

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:14 PM GMT GMT