## Example programs

The CHR releases in Prolog currently include about 40 constraint solvers, many of them novel or with extended functionality over existing implementations. There are handlers for lists, sets, trees, terms, finite ground term and number domains, booleans, linear polynomials over reals and rationals, for incremental path consistency, for terminological, temporal, geometric reasoning as well as for sound negation and conditional control constructs. Moreover, there are examples showing the use of CHR as general purpose concurrent constraint language with ask and tell, as fairly efficient production rule system, and as system combining forward and backward chaining in theorem proving.

You can run these constraint solvers and programs online with the WebCHR Interactive Demo or even write your own CHR programs.

Simple constraint solvers:

- Greatest Common Divisor (just two rules)
- Inequalities between variables (less-than-or-equal)
- Inequalities plus minimum/maximum constraints (updated!)
- Boolean constraints

Finite and infinite domains:

- Enumeration list domains over integers
- Straightforward interval domains over integers and reals, with arithmetic functions
- Finite domains over arbitrary ground terms and interval domains over integers and reals, but without arithmetic functions

Solving (linear) polynomial (in-,diss-)equations over real or rational numbers:

- Gaussian elimination for equations (only one rule!)
- Variable elimination with slack variables for inequations
- Fouriers algorithm
- Fouriers algorithm for inequations and variable elimination for equations

Constraint solvers for equations over terms and trees:

- Rational trees, equality and disequality over finite and infinite trees (terms)
- Order-Sorted Feature Trees according to the OSF theory
- Feature Trees according to the CFT theory
- Rational trees with disequality and OZ type constraint
- Terminological reasoning (a la KL-ONE or feature trees)
- Prolog term manipulation built-in predicates functor, arg, unif as constraints
- Equality constraints over concatenations of lists (or strings)
- List constraints, Nikolai Kosmatov
- Equalities and type constraints over finite and infinite trees (terms)

Consistency techniques:

- Arc consistency over finite domains
- Path consistency, simple instance
- Path consistency, simple
- Path consistency, advanced

Temporal reasoning with consistency techniques:

- Simple classical scheduling example (in German)
- Time-points
- Time-points and intervals, qualitative and quanitative

Classical algorithms:

Sudoku:

- Sudoku solver by Jon Murua Gonzalez and Henning Christiansen
- variant by Thom Frühwirth
- Sudoku solver by Or Sharir
- Sudoku applet by Marc Meister and students (sources)

Subsuming other languages in CHR:

- The GAMMA language, Hariolf Betz

And...

- Prime numbers, illustrates use of CHR as a general purpose concurrent constraint language
- Example of how to use CHR for model generation in theorem proving (in German)
- Classical monkey and banana problem, illustrates how CHR can be used as a fairly efficient production rule system
- Most of Tarskis axiomatization of geometry as constraint system
- Set constraints (Eclipse Prolog)
- Sound prolog control primitives (Eclipse Prolog)
- The EU car rental business rules example
- A mode analyzer
- Equational Constraint Solving using Quasi-solved Forms, J. Alvez and P. Lucio -- program code
- fluent calculus
- Self Referential Quizzes and N-Queens, comparison of several constraint languages
- Soft/Semi-Ring constraints: dinner application, security applicatoin
- Implementing agents using Constraint Handling Rules by Markus Triska

Example files for the above solvers (not necessarily up-to-date)