Constraint (Handling) Rules in Java Spirit and Form

May 14, 2013

Dragan Ivanović


Constraint (Handling) Rules in Java Spirit and Form

Time:   11:00am
Location:   Meeting room 302 (Mountain View), level 3

Constraint and logic programming languages offer programmers powerful, declarative ways to go about solving complex computational problems that involve logical reasoning in one form or another. In particular, the Constraint Handling Rules (CHR) have been developed as a language for developing constraint solvers. CHR can be seen as a language parametric relative to an underlying host programming language of choice. While CHR traditionally integrates well with Prolog, its integration with the mainstream languages such as Java is much less smooth, and the support for IDEs and debugging practically non-existent. Yet writing solvers in Prolog/CHR and then interfacing them with Java is not really an option if one wants to populate the universe of discourse with complex Java objects whose implementations we don’t know and reason directly on them.

In this talk I shall present a general-purpose Java library that I developed for the purpose of writing CHR-style constraint solvers and reactive rule / event processing programs directly in Java, without another language layer. The CHR-style rules are written in a subset of Java, and are easily amenable to the usual code refactoring tools found in modern IDEs such as Eclipse, NetBeans, or IntelliJ/IDEA. Two additional orthogonal features are the ability to save/restore the state of the constraint store, and the event notification system that allows us to distribute events and helps us build console-based and visual debuggers.