Content deleted Content added
labeling on finite domains |
→Finite domains: broken sentence in two clauses |
||
Line 47:
The third class of constraints used in constraint logic programming is that of finite domains. Values of variables are in this case taken from a finite ___domain, often that of [[integer number]]s. For each variable, a different ___domain can be specified: <code>X::[1..5]</code> for example means that the value of <code>X</code> is between <code>1</code> and <code>5</code>. The ___domain of a variable can also be given by enumerating all values a variable can take; therefore, the above ___domain declaration can be also written <code>X::[1,2,3,4,5]</code>. This second way of specifying a ___domain allows for domains that are not composed of integers, such as <code>X::[george,mary,john]</code>. If the ___domain of a variable is not specified, it is assumed to be the set of integers representable in the language. A group of variables can be given the same ___domain using a declaration like <code>[X,Y,Z]::[1..5]</code>.
The ___domain of a variable may be reduced during execution. Indeed, as the interpreter adds constraints to the constraint store, it performs [[constraint propagation]] to enforce a form of [[local consistency]], and these operations may reduce the ___domain of variables. If the ___domain of a variable becomes empty, the constraint store is inconsistent, and the algorrithm backtracks. If the ___domain of a variable becomes a [[Singleton (mathematics)|singleton]], the variable can be assigned the unique value in its ___domain. The forms of consistency typically enforced are [[arc consistency]], [[hyper-arc consistency]], and [[bound consistency]]. The current ___domain of a variable can be inspected using specific literals;
As for domains of reals, functors can be used with domains of integers. In this case, a term can be an expression over integers, a constant, or the application of a functor over other terms. A variable can take an arbitrary term as a value, if its ___domain has not been specified to be a set of integers or constants.
|