Re: [eclipse-clp-users] timeout in bb_min/3

From: Kish Shen <kisshen_at_cisco.com>
Date: Thu, 18 Feb 2010 16:04:54 +0000
Marco Gavanelli wrote:
> Amine Marref wrote:
>> I have substituted ";" with "or" and it works. I thought that they are equivalent like "," and "and" are equivalent (I hope they are).
> 
> they are logically equivalent, but they have a different operational 
> semantics (they do different things).
> 
To expand on what Marco says, and/2, or/2 are "reified connectives". The 
constraints occurring within them are reified. Simply put, this means 
they are passive, that is, reified constraints are only passively 
checked to see if they are entailed or dis-entailed or not. On the other 
hand, when you post Cons1, Cons2, this posts both constraints, and their
consequences are actively propagated.

You can see the difference with the simple example of two mutually 
inconsistent constraints:

X #> Y
Y #> X

this should fail. If you post these as constraints (and with a finite 
domain for X and Y), the inconsistency will (eventually) be detected:

X,Y :: [1..1000], X #> Y, Y #> X.

will eventually fail.

[An aside: this is of course the rather well know illustration of a 
weakness of local constraint propagation -- as discussed recently in 
other threads  in this mailing list.]

On the other hand, for the reified version:

X,Y :: [1..1000], (X #> Y and Y #> X).

does not fail, as the consequences of the two constraints are not 
propagated, and the check are performed on the two constraint 
individually -- i.e. X #> Y and X #> X are checked on their own, and 
nothing can be concluded with either constraint on their own. [For 
anything to happen, X and Y need to have domains where the constraints 
can be shown to be either true or false, e.g. X ::[1..50] Y ::[51..100].


Amine Marref wrote:
 > I always wondered what when to use ";", when to use "or", and when to 
 >use multiple definitions of a predicate e.g. "con(X):-X#>0. \n 
 >con(X):-X#<0."

If you want to learn more about Constraint (Logic) Programming, using 
the mailing list is probably not the best way. You may want to read some 
of the textbooks on Constraint Programming, e.g. the ones mentioned in 
the Literature section of the eclipse-clp.org website.

Cheers,

Kish
-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Thu Feb 18 2010 - 16:05:20 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET