[ library(chr) | The ECLiPSe Libraries | Reference Manual | Alphabetic Index ]

# chr_get_constraint(?Constraint)

Remove a constraint unifying with Constraint from the constraint store.

?Constraint
  A constraint (callable term) defined by constraint handling rules.

## Description

Removes a constraint unifying with Constraint from the constraint store. Note that if the unification with Constraint binds variables occurring also in other constraints in the constraint store, these constraints may be simplified (see last examples). Thus it is recommended to use either a free variable or a term with variable arguments for Constraint. Used by advanced constraint handling rules users to manipulate themselves the constraints defined by constraint handling rules.

### Fail Conditions

Fails if there is no constraint (defined by constraint handling rules) in the constraint store that unifies with Constraint.

### Resatisfiable

Yes.

## Examples

       Example using the constraint handler for Booleans  bool.chr:
    [eclipse]: chr_get_constraint(C).
    no (more) solution.

    [eclipse]: and(X,Y,Z), or(X,Y,Z).

    Constraints:
    (1) X_g745 * Y_g777 = Z_g809 % pretty print of and/3 constraint
    (2) X_g745 + Y_g777 = Z_g809 % pretty print of or/3 constraint

    yes.

    [eclipse]: and(X,Y,Z), or(X,Y,Z), chr_get_constraint(C).

    C = X * Y = Z

    Constraints:
    (2) X_g765 + Y_g797 = Z_g829
         More? (;)

    C = X + Y = Z

    Constraints:
    (1) X_g765 * Y_g797 = Z_g829
         More? (;)
    no (more) solution.

    [eclipse]: and(X,Y,Z), or(X,Y,Z), chr_get_constraint(and(1,A,B)).
    % or/3 - constraint is solved when X is bound to 1
    X = 1
    Y = A
    Z = 1
    A = A
    B = 1

    [eclipse]: and(X,Y,Z), or(X,Y,Z), chr_get_constraint(and(1,1,0)).
    no (more) solution. % or/3 - constraint fails

    [eclipse]: and(X,Y,Z), chr_get_constraint(and(1,1,0)).

    X = 1
    Y = 1
    Z = 0

       The predicate chr_labeling/0 can be defined as:
    labeling :-
       chr_get_constraint(C),
       chr_label_with(C),
       !,
       chr_resolve(C),
       labeling.

    labeling.

## See Also

chr_labeling / 0, chr_label_with / 1, chr_resolve / 1, chr_get_constraint / 1, chr_get_constraint / 2