[Next] [Up] [Previous] [Contents] [Index]
Next: Arithmetic constraints Up: CLP(FD) Previous: CLP(FD)   Contents   Index

Finite-domain variables

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.

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.


[Next] [Up] [Previous] [Contents] [Index]
Next: Arithmetic constraints Up: CLP(FD) Previous: CLP(FD)   Contents   Index
Neng-Fa Zhou () 2007-06-05