[ library(gfd) | Reference Manual | Alphabetic Index ]

impose_domain(?Var, ?DomVar)

Restrict (if required) the domain of Var to the domain of DomVar.
(Domain) variable or integer
(Domain) variable or integer


This predicate is provided mainly for compatibility with IC solver. If you intend to impose the same domain on multiple variables, it is more efficient to use the lib(gfd) specific gfd_vars_impose_domain/2, which additionally offer more flexibility in allowing the domain to be specified as a list.

Primitive for restricting the domain of Var to the domain of DomVar. Any values in the domain of Var, which are not also in the domain of DomVar, are removed. DomVar remains unaffected. The domain update on Var may fail (when the update empties the domain), succeed (possibly updating the variable's domain), or instantiate the variable (in the case where the domain gets restricted to a singleton value).

Note that this predicate is intended for use only in implementing constraint propagators, and should not be called from ordinary user code. The waking behaviour is the same as discussed for impose_min/2 and impose_max/2. Apart from this, the effect is similar to unifying Var with a copy of DomVar.


    ?- X::1..9, Y::5..7, impose_domain(X, Y).
    X = X{5 .. 7}
    Y = Y{5 .. 7}

    ?- X::1..9, impose_domain(X, 7).
    X = 7

    ?- X::1..3, Y::5..7, impose_domain(X, Y).
    No (0.00s cpu)

    ?- Y::1..5, impose_domain(3, Y).
    Y = Y{1 .. 5}

    ?- Y::1..5, impose_domain(6, Y).
    No (0.00s cpu)

    ?- Y::1..5, impose_domain(X, Y).
    Y = Y{1 .. 5}
    X = X{1 .. 5}

See Also

impose_min / 2, impose_max / 2, impose_bounds / 3, exclude / 2, exclude_range / 3