Node:Range Expressions, Next:Term Expressions, Previous:Indexicals, Up:Defining Primitive Constraints
A range expression has one of the following forms, where Ri denote range expressions, Ti denote integer valued term expressions, S(Ti) denotes the integer value of Ti in S, X denotes a variable, I denotes an integer, and S denotes the current store.
dom(X)
{T1,...,Tn}
{S(T1),...,S(Tn)}.
Any term expression containing a
subexpression which is a variable that is not "quantified" by
unionof/3 will only be evaluated when this variable has been assigned.
T1..T2
R1/\R2
R1\/R2
\R2
R1+R2
R1+T2
-R2
R1-R2
R1-T2
T1-R2
R1 mod R2
R1 mod T2
R1 ? R2
(R1 ? (inf..sup) \/ R3), which evaluates to
S(R3) if S(R1) is an empty set; otherwise, evaluates to
inf..sup. As an optimization, R3 is not evaluated
while the value of R1 is a non-empty set.
unionof(X,R1,R2)
switch(T1,MapList)
Key-Expr. Otherwise,
evaluates to the empty set.
When used in the body of an FD predicate (see Goal Expanded Constraints),
a relation/3 expression expands to two
indexicals, each consisting of a switch/2 expression nested
inside a unionof/3 expression. Thus, the following constraints
are equivalent:
p(X, Y) +: relation(X, [1-{1},2-{1,2},3-{1,2,3}], Y).
q(X, Y) +:
X in unionof(B,dom(Y),switch(B,[1-{1,2,3},2-{2,3},3-{3}])),
Y in unionof(B,dom(X),switch(B,[1-{1},2-{1,2},3-{1,2,3}])).