Arithmetic constraints can be reified as e.g.:
| ?- X in 1..2, Y in 3..5, X#=<Y #<=> B. B = 1, X in 1..2, Y in 3..5
Linear arithmetic constraints, except equalities, maintain interval-consistency and their reified versions detect interval-entailment and -disentailment; see The Constraint System.
The following constraints are among the library constraints that general arithmetic constraints compile to. They express a relation between a sum or a scalar product and a value, using a dedicated algorithm, which avoids creating any temporary variables holding intermediate values. If you are computing a sum or a scalar product, it can be much more efficient to compute lists of coefficients and variables and post a single sum or scalar product constraint than to post a sequence of elementary constraints.
sum(
+Xs,
+RelOp,
?Value)
scalar_product(
+Coeffs,
+Xs,
+RelOp,
?Value)
The following constraint is a special case of
scalar_product/4
where RelOp is #=
, and
which is domain-consistent in the Xs:
knapsack(
+Coeffs,
+Xs,
?Value)