Constraint Handling Rules

The more you CHR, the better you are.

CHR for semantic analysis in voice-controlled systems

In a recent project, Fraunhofer Institute uses CHR for semantic analysis in voice-controlled systems. As part of the project Speech Assistance for Citizen Services (S4CS), the conversation logic is modelled in CHR. This approach is fast, flexible, and can be adapted for different dialogue scenarios. The system uses GoCHR, a new CHR interpreter written in the Go programming language.

Persistent Constraint Store in newest SWI-Prolog

Yesterday Jan Wielemaker published version 7.3.28 of SWI-Prolog. It comes with a new flag toplevel_mode which might be especially useful to test and debug CHR programs. It was highlighted in the version announcements as follows:

After suggestion by Falco Nogatz, it is now possible to run the toplevel in recursive mode such that global variables remain bound. Nice for teaching CHR. Not clear what the other use cases are. Use ?- set_prolog_flag(toplevel_mode, recursive). to enable this.
Some insights on the discussion, implementation and usage of the new flag can be found in the related GitHub issue. It can be used to have a persistent constraint store over multiple queries in the toplevel. This way it is possible to, e.g., use the classical gcd/1 constraint solver incrementally for computing the greatest common divisor of numbers given on by one:
?- set_prolog_flag(toplevel_mode, recursive).
?- gcd(24).
?- gcd(42).
?- X = 3.
X = 3,
As seen in the last query, the contents of the constraint store are printed by default on every query. So, for more advanced usage, it might become handy to use the recursive toplevel mode with CHR’s flag chr_toplevel_show_store set to false and explicitly call the meta-predicate chr_show_store/1.