Re: [eclipse-users] reified constraints

From: Joachim Schimpf (Independent Contractor) <"Joachim>
Date: Wed, 19 Sep 2007 00:43:56 +0100
Malcolm Ryan wrote:
> In a related problem, I want use the reified version of in/2 from  
> ic_sets:
> 
> B #= (I in Set)
> 
> but I find that it only propagates when I is instantiated, not when  
> it is constrained, so:
> 
> [eclipse 32]: I :: [0,1,2,3,4], B #= (I in [1,2]), I #> 2.
> 
> B = B{[0, 1]}
> I = I{[3, 4]}
> 
> B is not instantiated even though clearly I cannot be in [1,2].

Hmm, right.  And I notice that the unreified notin/2 has the same
problem.  It would be more expensive to propagate this, but it
seems clearly desirable.  If anybody wants to have a go at it,
the implementation is in a file called generic_sets.ecl.


> 
> I have discovered, however, that the following trick works:
> 
> [eclipse 8]: I :: [0,1,2,3,4], J in [1,2], B #= (I #= J), I #> 2.
> 
> I = I{[3, 4]}
> J = J{[1, 2]}
> B = 0
> Yes (0.00s cpu)
> 
> Can anyone think of a good reason why doing this would be inadvisable?

I assume the idea is to leave J uninstantiated.  If your other code only
labels the I variables, but not J or B, you can end up with unwanted
delayed goals at the end of the computation:

?- I :: [0, 1, 2, 3, 4], J :: [1, 2], B #= (I #= J), I = 1.
I = 1
J = J{[1, 2]}
B = B{[0, 1]}
There is 1 delayed goal.
Yes (0.00s cpu)


-- Joachim
Received on Wed Sep 19 2007 - 00:44:03 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:19 CEST