A finite domain is a set of ground terms that is given as a list. The special notation Begin..Step..End denotes the set of integers
, where B1=Begin,
Bi = Bi-1+Step for i=2,...,k,
, and Bk+Step>End. When the increment Step is 1, the notation can be abbreviated as Begin..End. For example, the notation 1..2..10 refers to the list [1,3,5,7,9], and 1..3 refers to 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: This is the same as Vars in D.
- domain(Vars,L,U): This is the same as Vars in L..U.
- Vars notin D: Vars does not reside in D.
The following primitives are available for integer domain variables. As domain variables are also suspension variables, primitives on suspension variables, such as frozen/1, can also be applied to domain variables.
- fd_var(V):
V is a domain variable.
- fd_new_var(V):
Creates 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):
Excludes the element E from the domain of V. If this operation results in a hole in the domain of V, 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 element that follows E in V's domain.
- fd_prev(V,E,PrevE):
PrevE is the element that precedes E in V's domain.
- fd_include(V1,V2):
This succeeds if V1's domain includes V2's domain as a set.
- fd_disjoint(V1,V2):
This succeeds if V1's domain and V2's domain are disjoint.
- fd_degree(V,N):
The number of variables that are connected 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 the interval. The default values for Min and Max are -3200 and 3200, respectively.
Neng-Fa Zhou
2013-01-25