Example Constraint Handlers

## 9.3 Example Constraint Handlers

All example files are in the subdirectory lib/chr of the installation-directory of ECLiPSe (which can be found using get_flag(installation_directory,Dir). The files (.chr, .pl, examples) relevant to a particular constraint system can be found by looking at all files that match the pattern given in the following listing with each example handler. The examples include a colour graphic demo about optimal sender placement for wire-less devices in buildings and company sites, small constraint handlers for

- minimum, maximum of and inequalities between terms (*minmax*),
- terms (functor/3, arg/3, =.. as constraints) (*term*),
- lists (similar to Prolog III) (*list*),
- rational trees (*tree*),
- sound if-then-else, negation and checking, lazy conjunction and disjunction (*control*),
- geometric reasoning about rectangles (*demo*),

and larger constraint handlers for

- booleans for propositional logic (*bool*),
- finite and infinite domains (inspired by CHIP) (*domain*),
- sets (*set*),
- terminological reasoning (similar to KL-ONE) [8] (*kl-one*),
- temporal reasoning (over time points and intervals) [7] (*time*),
- equation solving over real numbers (similar to CLP(R)) or rational numbers (*math*).

CHRs have also been used as a committed choice programming language on their own (*prime*).

The example handlers can be loaded using `chr(lib(File))`. For instance the finite domain handler can be made available as follows (the current directory must have write permission so that the pl file can be created):

>     [eclipse 1]: lib(chr), chr(lib(domain)).
>     ...
>     domain.pl  compiled traceable 241028 bytes in 1.22 seconds

>     yes.
>     [eclipse 2]: X::1..10, X ne 5.

>     X = X

>     Constraints:
>     (4) X_g1165 :: [1, 2, 3, 4, 6, 7, 8, 9, 10]

>     yes.