A finite domain is a set of ground terms given as a list. The special notation
..
..
denotes the set of integers
where
,
for
,
and
. When the increment
is 1, the notation can be abbreviated as
. For example, the notation
means the list [1,3,5,7,9], and
means the list [1,2,3].
- Vars in D: The variables in Vars take on values from the finite domain D, where Vars can be a single variable or a list of variables. For example, the call X in 1..3 states that the domain of X is [1,2,3], the call X in 1..2..5 states that the domain is [1,3,5], and the call X in [a,b,c] states that the domain is [a,b,c].
- Vars :: D: The same as Vars in D.
- domain(Vars,L,U): The same as Vars in L..U.
- Vars notin D: Vars does not reside in D.
The following primitives are available on integer domain variables. As domain variables are also suspension variables, primitives on suspension variables such as frozen/1 can be applied to domain variables as well.
- fd_var(V):
V is a domain variable.
- fd_new_var(V):
Create a new domain variable V whose domain is -268435455..268435455.
- fd_max(V,N):
The maximum element in the domain of V is N. V must be an integer domain variable or an integer.
- fd_min(V,N):
The minimum element in the domain of V is N. V must be an integer domain variable or an integer.
- fd_min_max(V,Min,Max):
The minimum and maximum elements in the domain of V are Min and Max, respectively. V must be an integer domain variable or an integer.
- fd_size(V,N):
The size of the domain of V is N.
- fd_dom(V,L):
L is the list of elements in the domain of V.
- fd_true(V,E):
E is an element in the domain of V.
- fd_set_false(V,E):
Exclude the element E from the domain of V. If this operation results in a hole in the domain of
, then the domain changes from an interval representation into a bit-vector representation however big it is.
- fd_next(V,E,NextE):
NextE is the next element following E in V's domain.
- fd_prev(V,E,PrevE):
PrevE is the element preceding E in V's
domain.
- fd_include(V1,V2):
Succeeds if V1's domain includes V2's domain as a set.
- fd_disjoint(V1,V2):
Succeeds if V1's domain and V2's domain are disjoint.
- fd_degree(V,N):
The number of connected variables with V in the constraint network is N.
- fd_vector_min_max(Min,Max):
Specifies the range of bit vectors. Domain variables, when being
created, are usually represented internally by using intervals. An
interval turns to a bit vector when a hole occurs in it. The default
values for Min and Max are -3200 and 3200, respectively.
Neng-Fa Zhou
2012-01-03