[Next]
[Up]
[Previous]
[Contents]
[Index]
Next: Arithmetic constraints
Up: CLP(FD)
Previous: CLP(FD)
  Contents
  Index
A finite domain is a list of different ground terms in the form: [e1,e2,...,en].
The special notation L..U denotes a set of integers between L and U, inclusive.
A Prolog variable Var becomes a finite-domain variable after its domain is declared by:
Var :: D
or
Var in D
where D is a finite-domain. For example, the call
X :: 1..3
says that X is an integer between 1 and 3 and the call
X :: [a,b,c]
says that X can be a, b, or c.
Let Vars be a list of variables that share the same domain D. The domain of the variables can be declared as follows:
Vars :: D
If the domain is the set of integers between L and U, then the domain can also be declared as
domain(Var,L,U)
for one variable Var and as
domain(Vars,L,U)
for a list of variables Vars.
The following primitives restrict the domains of variables.
- domain(Var,L,U): The domain of the variable Var is the set of integers between L and U. L and U must be integers. If Var is an integer, the call is equivalent to
Var>=L,Var=<U
If Var is neither a variable nor an integer, this call raises the illegal_argument exception.
- domain([V1,...,Vn],L,U): Equivalent to:
domain(V1,L,U),...,domain(Vn,L,U)
- Var :: D: The domain of the variable Var is D, where D is either an integer interval L..U or a list of ground terms. If D is a list that contains non-integer terms, then the call is equivalent to member(Var,D).
- [V1,...,Vn] :: D: Equivalent to:
V1 :: D,...,Vn :: D
- Var notin D: Var does not reside in D.
- [V1,...,Vn] notin D: Equivalent to:
V1 noin D,...,Vn noin 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 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 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_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.
[Next]
[Up]
[Previous]
[Contents]
[Index]
Next: Arithmetic constraints
Up: CLP(FD)
Previous: CLP(FD)
  Contents
  Index
Neng-Fa Zhou ()
2007-06-05