🤖 AI Summary
E-graphs (as implemented in Egg) lack formal semantic foundations and support for modeling concurrent operations in equality-saturation–based program optimization.
Method: We introduce the first categorical modeling of E-graphs as structures within an adhesive category, defining node equivalence relations and operator closures via rigorous categorical semantics to formally characterize rewriting behavior, dynamic merging, and concurrent updates.
Contribution/Results: This framework unifies confluence proofs, parallel rewriting analysis, and compositional transformation verification, while providing a categorical foundation for dynamically adding equivalent components. By deeply integrating graph rewriting theory with equality saturation—unlike prior approaches that treat them separately—our method significantly strengthens correctness guarantees and formal verifiability of optimization processes. The adhesive category setting ensures well-behaved pushouts and pullbacks, enabling precise reasoning about structural changes during saturation. This advances the theoretical underpinnings of e-graph–based optimizers and supports mechanized verification of their semantics.
📝 Abstract
The use of rewriting-based visual formalisms is on the rise. In the formal methods community, this is due also to the introduction of adhesive categories, where most properties of classical approaches to graph transformation, such as those on parallelism and confluence, can be rephrased and proved in a general and uniform way.E-graphs (EGGs) are a formalism for program optimisation via an efficient implementation of equality saturation. In short, EGGs can be defined as (acyclic) term graphs with an additional notion of equivalence on nodes that is closed under the operators of the signature. Instead of replacing the components of a program, the optimisation step is performed by adding new components and linking them to the existing ones via an equivalence relation, until an optimal program is reached. This work describes EGGs via adhesive categories. Besides the benefits in itself of a formal presentation, which renders the properties of the data structure precise, the description of the addition of equivalent program components using standard graph transformation tools offers the advantages of the adhesive framework in modelling, for example, concurrent updates.