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).
For a constraint Constr, if there is at least one variable in it, the interpreter delays the constraint and invokes the procedure reduce_domains(Constr) 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 either a bound of a variable in Constr is updated or a variable is bound to any value.



Neng-Fa Zhou 2012-01-03