🤖 AI Summary
Existing CHR embedding implementations lack a unified formal foundation, impeding maintainability and undermining correctness guarantees. To address this, we propose an optimized execution algorithm for the FreeCHR framework—the first to provide a provably correct, efficient matching and rule-execution mechanism while preserving classical CHR semantics. Our approach integrates a formally grounded exact matching algorithm, constraint rewriting optimizations, and benchmark-driven evaluation. Experimental results across multiple CHR benchmarks demonstrate significant speedups in execution time. Moreover, the algorithm exhibits cross-host-language applicability, thereby reconciling correctness, efficiency, and maintainability—filling a critical gap between abstract CHR frameworks and concrete, optimized implementations.
📝 Abstract
Constraint Handling Rules (CHR) is a rule-based programming language that rewrites collections of constraints. It is typically embedded into a general-purpose language. There exists a plethora of implementations for numerous host languages. However, the existing implementations often re-invent the method of embedding, which impedes maintenance and weakens assertions of correctness. To formalize and thereby unify the embedding of a ground subset of CHR into arbitrary host languages, we introduced the framework FreeCHR and proved it to be a valid representation of classical CHR. For the sake of simplicity, abstract implementations of our framework did not yet include a concrete matching algorithm nor optimizations. In this paper, we introduce an improved execution algorithm for FreeCHR. We also provide an evaluation of the algorithm via benchmarks which suggest the effectiveness of our implemented optimizations.