egg: Fast and Extensible Equality Saturation

Max Willsey, Chandrakana Nandi, Yisu Remy Wang, Oliver Flatt, Zachary Tatlock +1 more
4/7/2020
cs.PL

Official code: egraphs-good/egg (1,854 stars, MIT, Rust, last commit 2026-09-28). 1 more implementation below.

Abstract

An e-graph efficiently represents a congruence relation over many expressions. Although they were originally developed in the late 1970s for use in automated theorem provers, a more recent technique known as equality saturation repurposes e-graphs to implement state-of-the-art, rewrite-driven compiler optimizations and program synthesizers. However, e-graphs remain unspecialized for this newer use case. Equality saturation workloads exhibit distinct characteristics and often require ad-hoc e-graph extensions to incorporate transformations beyond purely syntactic rewrites. This work contributes two techniques that make e-graphs fast and extensible, specializing them to equality saturation. A new amortized invariant restoration technique called rebuilding takes advantage of equality saturation's distinct workload, providing asymptotic speedups over current techniques in practice. A general mechanism called e-class analyses integrates domain-specific analyses into the e-graph, reducing the need for ad hoc manipulation. We implemented these techniques in a new open-source library called egg. Our case studies on three previously published applications of equality saturation highlight how egg's performance and flexibility enable state-of-the-art results across diverse domains.

View on arXivView PDF

Code Implementations(2)

egraphs-good/eggOfficial100%
RustMIT

egg is a flexible, high-performance e-graph library

1,854211Rust, MakefileApr 25, 20193 weeks agoMIT
mwillsey/eggOfficial100%
RustMIT

egg is a flexible, high-performance e-graph library

130Rust, MakefileFeb 1, 20222 years agoMIT

Similar Papers

Cite this paper

@article{willsey2020egg,
  title  = {egg: Fast and Extensible Equality Saturation},
  author = {Max Willsey and Chandrakana Nandi and Yisu Remy Wang and Oliver Flatt and Zachary Tatlock and Pavel Panchekha},
  year   = {2020},
  eprint = {2004.03082},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2004.03082}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2004.03082.svg)](https://codeofpaper.com/paper/2004.03082)

Discussion