A constraint interpreter

It is very easy to write a constraint interpreter by using action rules. The following shows such an interpreter:
      interp_constr(Constr), n_vars_gt(1,0), 
            {generated,ins(Constr),bound(Constr)} 
            => 
           reduce_domains(Constr).
      interp_constr(Constr) => test_constr(Constr).
If a constraint Constr contains at least one variable, the interpreter delays the constraint, and invokes the procedure reduce_domains(Constr) in order to exclude no-good values from the variables in Constr. The two kinds of events, namely ins(Constr) and bound(Constr), ensure that the constraint will be reconsidered whenever a bound of a variable in Constr is updated, or whenever a variable is bound to any value.



Neng-Fa Zhou 2013-01-25