Hostname: page-component-77f85d65b8-8v9h9 Total loading time: 0 Render date: 2026-03-28T00:57:27.822Z Has data issue: false hasContentIssue false

FreeCHR – An Algebraic Framework for Constraint Handling Rules Embeddings

Published online by Cambridge University Press:  16 June 2025

SASCHA RECHENBERGER
Affiliation:
Institute of Software Engineering and Programming Languages, Ulm University, Ulm, Germany (e-mails: sascha.rechenberger@uni-ulm.de, thom.fruehwirth@uni-ulm.de)
THOM FRÜHWIRTH
Affiliation:
Institute of Software Engineering and Programming Languages, Ulm University, Ulm, Germany (e-mails: sascha.rechenberger@uni-ulm.de, thom.fruehwirth@uni-ulm.de)
Rights & Permissions [Opens in a new window]

Abstract

We introduce the framework FreeCHR which formalizes the embedding of Constraint Handling Rules (CHR) into a host language, using the concept of initial algebra semantics from category theory. We hereby establish a high-level implementation scheme for CHR as well as a common formalization for both theory and practice. We propose a lifting of the syntax of CHR via an endofunctor in the category Set and a lifting of the very abstract operational semantics of CHR into FreeCHR, using the free algebra, generated by the endofunctor. We give proofs for soundness and completeness with its original definition. We also propose a first abstract execution algorithm and prove correctness with the operational semantics. Finally, we show the practicability of our approach by giving two possible implementations of this algorithm in Haskell and Python. Under consideration in Theory and Practice of Logic Programming.

Information

Type
Original Article
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2025. Published by Cambridge University Press
Figure 0

Fig. 1. Very abstract operational semantics for ground and pure CHR.

Figure 1

Fig. 2. Very abstract operational semantics of freeCHR.

Figure 2

Algorithm 1 Implementation of Exec

Figure 3

Algorithm 2 Implementation of run

Figure 4

Fig. 3. Wrapped solver function type.

Figure 5

Fig. 4. Greatest common divisor.

Figure 6

Fig. 5. Implementations of rule.

Figure 7

Fig. 6. Lazy matching.

Figure 8

Fig. 7. Implementations of compose.

Figure 9

Fig. 8. Implementation of all_diff constraint.

Figure 10

Fig. 9. Implementations of run.