Using Constraint Handling Rules in Curry

Constraint Handling Rules (CHR) is a rule-based language to specify application-oriented constraint solvers. In order to use such solvers also in Curry, there is an approach to embed the definition of CHR also in Curry programs. This paper describes the conceptual ideas of this embedding.

In order to compile a Curry/CHR specification, load the CHR specification into the PAKCS environment and execute compileCHR targetmodule chrrulelist, where targetmodule is the name of the target module to be generated and chrrulelist is a list of constraint handling rules defining the solver. leqCHR.curry and boolCHR.curry are two examples containing the definition of a solver for a less-or-equal constraint and a solver for Boolean constraints, respectively. For instance, these solvers can be compiled by the shell commands

"pakcs -r leqCHR" or "pakcs -r boolCHR"
if you have the PAKCS environment installed. After successful compilation, you can import the generated target module in order to provide access to the CHR constraints in the Curry program, e.g.,
  > pakcs -l Bool
  ...
  Bool> and x y z & neg False z  where x,y,z free
  Free variables in goal: x, y, z
  Result: success
  Bindings: 
  x=True
  y=True
  z=True

Important note: This is a first prototype to demonstrate the possibility to integrate CHR into Curry. Thus, it does not implement the full functionality of CHR. Furthermore, it is possible that the general concept might be extended or changed in a future version.


Curry Homepage | CHR Homepage | Paper | Curry CHR library | leq solver | Boolean solver

Michael Hanus
Last modified: Mon Feb 27 17:42:45 CET 2006