next up previous contents index
Next: Indexicals Up: Programming Constraint Propagation Previous: Programming Constraint Propagation   Contents   Index

A constraint interpreter

It is very easy to write a constraint interpreter by using delay clauses. The following shows such an interpreter:

    delay interp_constr(C):-no_vars_gt(1,0) : 
       {ins(C),min(C),max(C)}, reduce_domains(C).
    interp_constr(C):-true : test_constr(C).
The condition no_vars_gt(1,0) succeeds if there is at least one variable in C. For a constraint C, if there is at least one variable in it, the interpreter delays the constraint and invokes the procedure reduce_domains(C) to exclude no-good values from the variables in C. The three triggers, namely ins(C), min(C) and max(C), ensure that the constraint will be reconsidered whenever either a bound of any variable in C is updated or a variable is bound to any value.



Neng-Fa Zhou
1999-11-24