E-Graphs With Bindings
Aleksei Tiurin, Dan R. Ghica, Nick Hu
TL;DR
This work addresses the lack of native binding support in traditional e-graphs by embedding e-graphs into closed semilattice-enriched symmetric monoidal categories and representing morphisms as string diagrams. It introduces a combinatorial model using hierarchical e-hypergraphs and develops a DPOI rewriting framework that is sound and complete with respect to rewriting closed $\Sigma^{+}$-terms modulo the monoidal laws, absorbing binding and equivalence structure into composition. The key contributions include a categorical semantics for binding-enabled e-graphs, a hypergraph-based representation that accommodates binding through hierarchical boxes, and an EDPOI rewriting strategy that faithfully implements equational reasoning for the monoidal setting. This framework enables robust equality-saturation techniques for languages with binding (notably $\lambda$-calculus) and offers a principled path toward more scalable optimization and reasoning in compilers and formal methods.
Abstract
Equality saturation, a technique for program optimisation and reasoning, has gained attention due to the resurgence of equality graphs (e-graphs). E-graphs represent equivalence classes of terms under rewrite rules, enabling simultaneous rewriting across a family of terms. However, they struggle in domains like $λ$-calculus that involve variable binding, due to a lack of native support for bindings. Building on recent work interpreting e-graphs categorically as morphisms in semilattice-enriched symmetric monoidal categories, we extend this framework to closed symmetric monoidal categories to handle bindings. We provide a concrete combinatorial representation using hierarchical hypergraphs and introduce a corresponding double-pushout (DPO) rewriting mechanism. Finally, we establish the equivalence of term rewriting and DPO rewriting, with the key property that the combinatorial representation absorbs the equations of the symmetric monoidal category.
