arXiv:2610.01246cs.PLOct 2026

Manuscript Offprint

arXiv:2610.01246

Augmenting Rewrite Rule Sets via Knuth-Bendix Completion

Michael Schifferer, Marcel Ullrich, Sebastian Hack

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

1 Introduction

Optimizing compilers rely heavily on program transformations to improve code performance. However, applying these transformations sequentially introduces the phase ordering problem, where the order of applied optimizations heavily limits the final program quality. EqSat addresses this challenge by representing multiple equivalent programs simultaneously within a specialized data structure known as an e-graph. By systematically applying transformations without committing to a single path, EqSat exhaustively explores the search space of candidate programs to find the optimal representation.

While EqSat proves to be an effective optimization framework, its feasibility and performance depend on the underlying rewrite rules used to derive equivalent programs. Compiler developers handcraft these rule sets to carefully balance the trade-off between enabling a deep search space and preventing the e-graph from growing out of control. Designing these rule sets requires strong domain knowledge, intuition, and extensive testing. Because manual rule creation is prone to human error, developers often miss valuable, non-obvious transformations. Furthermore, little is known about the exact properties of highly effective rule sets, and the automated tools available to generate them remain limited.

To address this limitation, we evaluate Knuth-Bendix Completion (KBC), a well-established procedure from automated theorem proving, as a method for automatically generating and augmenting rewrite rules for program optimization. We develop a methodology to process an initial, handwritten rule set using KBC and evaluate the resulting rules in two distinct environments. First, we test the KBC-generated rules within the standard EqSat framework to see if they can uncover previously missed optimizations. Second, we evaluate them using a custom greedy rewriting engine, which trades the exhaustive exploration of EqSat for compile time and memory efficiency at the risk of result programs of inferior quality.

Our experiments show that augmenting handwritten rules with KBC-generated rules results in faster optimization and allows the system to reach better terms with previously missed optimizations. In this paper, we present

  • different methods for generating and processing rewrite rule sets for program optimization using KBC,

Authors' Contact Information: Michael Schifferer, misc00021@stud.uni-saarland.de, Saarland University, Saarland Informatics Campus, Saarbrücken, Germany; Marcel Ullrich, ullrich@cs.uni-saarland.de, Saarland University, Saarland Informatics Campus, Saarbrücken, Germany; Sebastian Hack, hack@cs.uni-saarland.de, Saarland University, Saarland Informatics Campus, Saarbrücken, Germany.

Michael Schifferer, Marcel Ullrich, and Sebastian Hack

  • an experimental evaluation demonstrating that KBC-augmented rule sets improve equality saturation in terms of overall simplification effectiveness and running time compared to strictly handwritten rules, and

  • analyze the viability of greedy rewriting as a resource-efficient alternative to EqSat, finding that while it minimizes memory and time usage, it still achieves considerably less effective simplification than EqSat.

Section 2 establishes the background on term rewriting, equality saturation, and Knuth-Bendix completion. Section 3 details our methodology for rule generation and the experimental setup. Section 4 presents our results across both the EqSat and greedy rewriting frameworks. Finally, we discuss related work in Section 5 and our conclusion in Section 6.

References (7)