ToyCHR 3.1


ToyCHR is a very simple reference implementation of Constraint Handling Rules (CHR) for Prolog using the refined operational semantics. The toyCHR package contains two different CHR interpreters:

  • -- a simple CHR compiler; and
  • -- a simple CHR interpreter and trace debugger.
More information about CHR can be found at the CHR Homepage.

Disclaimer: ToyCHR is not a serious CHR implementation. To implement CHR applications in Prolog, please use the K. U. Leuven CHR System.


  • -- Prolog (tested with Sicstus & SWI, but any Prolog should be okay);
  • -- SWI Prolog.


  • -- Cannot extend other constraint solvers, so ground data only.
    (Note that variables can be used as long as they are immediately bound the first time the constraint is called.)
  • -- No limitations, fully implements the refined operational semantics of CHRs.


  • gcd.chr -- One of the most basic CHR programs, it calculates the greatest common divisor between two numbers.
  • leq.chr -- Classic less-than-or-equal-to solver. Note only works with for non-ground goals.
  • ray.chr -- A very simple ray tracer implemented in CHRs.

Latest release:

© Copyright 2013, all rights reserved