Node:Range Expressions, Next:, Previous:Indexicals, Up:Defining Primitive Constraints

Range Expressions

A range expression has one of the following forms, where R_i denote range expressions, T_i denote integer valued term expressions, S(T_i) denotes the integer value of T_i in S, X denotes a variable, I denotes an integer, and S denotes the current store.

evaluates to D(X,S)
evaluates to \S(T_1),\ldots,S(T_n)\. Any T_i containing a variable that is not "quantified" by unionof/3 will cause the indexical to suspend until this variable has been assigned.
evaluates to the interval between S(T_1) and S(T_2).
evaluates to the intersection of S(R_1) and S(R_2)
evaluates to the union of S(R_1) and S(R_2)
evaluates to the complement of S(R_2)
evaluates to S(R_2) or S(T_2) added pointwise to S(R_1)
evaluates to S(R_2) negated pointwise
evaluates to S(R_2) or S(T_2) subtracted pointwise from S(R_1) or S(T_1)
R_1 mod R_2
R_1 mod T_2
evaluates to S(R_1) pointwise modulo S(R_2) or S(T_2)
R_1 ? R_2
evaluates to S(R_2) if S(R_1) is a non-empty set; otherwise, evaluates to the empty set. This expression is commonly used in the context (R_1 ? (inf..sup) \/ R_3), which evaluates to S(R_3) if S(R_1) is an empty set; otherwise, evaluates to inf..sup. As an optimization, R_3 is not evaluated while the value of R_1 is a non-empty set.
evaluates to the union of S(E_1),\ldots,S(E_N), where each E_I has been formed by substituting K for X in R_2, where K is the I:th element of S(R_1). See N Queens, for an example of usage.
Please note: if S(R_1) is infinite, the evaluation of the indexical will be abandoned, and the indexical will simply suspend.

evaluates to S(E) if S(T_1) equals K and MapList contains a pair K-E. Otherwise, evaluates to the empty set. If T contains a variable that is not "quantified" by unionof/3, the indexical will suspend until this variable has been assigned.

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}])).