Integer Comparison

As a convenience the finite domain solver provides a couple of comparisons between integers. The following features are provided in connection with integer comparison:

• Constraint Factoring
• Global Constraints

Our finite domain solver is probably unique in that it allows posting element hood for arbitrary expressions. This feature is used to internally implement integer comparison. We find the usual comparisons such as #\=/2, #</2, #>/2, #=</2 and #>=/2.  Comparisons are reconstructed from element hood when displaying constraints.

Example:
?- Y - X in 0..sup.
X #=< Y

The constraint solver also attempts to combine element hood constraints. Element hood constraints over the same expression are intersected similarly to domain constraints. Consequently comparisons can be contracted, subsumed or conflict. Also interaction with equations is possible, which are then treated as singleton element hood constraints.

Example:
?- X #> Y, X #= Y.
No

The integer comparisons can be used to define more complex conditions. A recurring problem is stating the inequality of a couple of value expressions. The predicate all_different/2 has been defined as a corresponding convenience.

The following integer comparison predicates are provided:

A #\= B:
If A and B are value expressions then their inequality is posted.
A #< B:
If A and B are value expressions then is posted that A is less than B.
A #> B:
If A and B are value expressions then is posted that A is greater than B.
A #=< B:
If A and B are value expressions then is posted that A is less or equal than B.
A #>= B:
If A and B are value expressions then is posted that A is greater or equal than B.
all_different([A1, .., An]):
If A1, .., An are value expressions then their inequality is posted.