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

# chr_resolve(+Constraint)

Uses the Prolog clauses to solve a constraint Constraint.

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

## Description

Uses the Prolog clauses to solve a constraint Constraint. Used by advanced constraint handling rules users to program labeling procedures for the constraints defined by constraint handling rules.

### Fail Conditions

Fails if there are no Prolog clauses for the constraint or if the bodies of all clauses fail.

### Resatisfiable

Yes.

### Exceptions

(4) instantiation fault
  Constraint is a free variable.
(6) out of range
  Constraint is term which is not a constraint (defined by constraint handling rules).

## Examples

       Example using the constraint handler for Booleans in file  bool.chr:
    [eclipse]: chr_resolve(X).
    instantiation fault in is_predicate(_g671 / _g639)

    [eclipse]: chr_resolve(and(X,Y)).
    out of range in chr_resolve(and(X,Y))

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

    X = 0
    Y = Y
    Z = 0     More? (;)

    X = 1
    Y = Z
    Z = Z
    yes.

    [eclipse]: chr_resolve(and(a,b,c)).
    no (more) solution.

       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_get_constraint / 1, chr_get_constraint / 2