Integer Sets

Set expressions are posted via the predicate in/2 respectively ins/2 and are similarly handled to equality. Further forward checking and duplicate detection is also applied. But element hood provides additional functionality. Namely we find the following additional inference rule for the element hood:

The interval consistency has been both implemented for the scalar product and multiplication. A restricted form of interval consistency has been implemented. Namely intervals only propagate to the lexical head of a scalar product respectively multiplication. Directed interval consistency also works for the recently introduced abs/1 function.

Examples:
?- X in 0..9, Y #= X+1, Z #= Y+1, X #= Z+1.
Z #= X-1,
Z in 2..8,
...

?- X in 0..sup, Y #= X+1, Z #= Y+1, X #= Z+1.
Z #= X-1,
Z #> 1,
...

This directed form of interval consistency is weaker than the full interval consistency. The directed form might accept equations that would otherwise be detected as inconsistent. But it has the advantage that it never loops and therefore also works for unbounded domains.

The following integer set expressions are provided:

I (finite):
An integer I represents a singleton set {I}.
I..J (finite):
If I and J are integers then the expression represents the interval [I..J]. It is also possible that I takes the value inf or that J takes the value sup. The expression then denotes the corresponding half interval or even the full integer domain.
A \/ B (finite):
If A and B are set expressions then union is also a set expression.
A /\ B (finite):
If A and B are set expressions then the intersection is also a set expression.
\ A (finite):
If A a set expressions then the complement is also a set expression.

The following integer value predicates are provided:

A in S:
If A is a value expression and S is a set expression then the element hood is posted.
[A1, .., An] ins S:
If A1, .., An are value expression and S is a set expression then the element hood is posted for each value expression.

Comments