babble: Learning Better Abstractions with E-Graphs and Anti-unification
David Cao, Rose Kunkel, Chandrakana Nandi, Max Willsey, Zachary Tatlock, Nadia Polikarpova
Abstract
Library learning compresses a given corpus of programs by extracting common structure from the corpus into reusable library functions. Prior work on library learning suffers from two limitations that prevent it from scaling to larger, more complex inputs. First, it explores too many candidate library functions that are not useful for compression. Second, it is not robust to syntactic variation in the input.
We propose library learning modulo theory (LLMT), a new library learning algorithm that additionally takes as input an equational theory for a given problem domain. LLMT uses e-graphs and equality saturation to compactly represent the space of programs equivalent modulo the theory, and uses a novel e-graph antiunification technique to find common patterns in the corpus more directly and efficiently.
We implemented LLMT in a tool named babble. Our evaluation shows that babble achieves better compression orders of magnitude faster than the state of the art. We also provide a qualitative evaluation showing that babble learns reusable functions on inputs previously out of reach for library learning.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Cited by top-tier papers25
- LILO: Learning Interpretable Libraries by Compressing and Documenting CodeGabriel Grand, Lionel Wong, Matthew Bowers, Theo X. Olausson et al.ICLR 2024 · 35 citations
- Top-Down Synthesis for Library LearningMatthew Bowers, Theo X. Olausson, Lionel Wong, Gabriel Grand et al.POPL 2023 · 32 citations
- ShapeCoder: Discovering Abstractions for Visual Programs from Unstructured PrimitivesR. Kenny Jones, Paul Guerrero, Niloy J. Mitra, Daniel RitchieSIGGRAPH 2023 · 19 citations
- Automatic Generation of Vectorizing Compilers for Customizable Digital Signal ProcessorsSamuel Thomas, James BornholtASPLOS 2024 · 16 citations
- Improving Unsupervised Visual Program Inference with Code Rewriting FamiliesAditya Ganeshan, R. Kenny Jones, Daniel RitchieICCV 2023 · 13 citations
Builds on12
- egg: Fast and extensible equality saturationMax Willsey, Chandrakana Nandi, Yisu Remy Wang, Oliver Flatt et al.POPL 2021 · 170 citations
- DreamCoder: bootstrapping inductive program synthesis with wake-sleep library learningKevin Ellis, Catherine Wong, Maxwell I. Nye, Mathias Sablé-Meyer et al.PLDI 2021 · 97 citations
- Synthesizing structured CAD models with equality saturation and inverse transformationsChandrakana Nandi, Max Willsey, Adam Anderson, James R. Wilcox et al.PLDI 2020 · 65 citations
- Leveraging Language to Learn Program Abstractions and Search HeuristicsCatherine Wong, Kevin Ellis, Joshua B. Tenenbaum, Jacob AndreasICML 2021 · 59 citations
- Vectorization for digital signal processors via equality saturationAlexa VanHattum, Rachit Nigam, Vincent T. Lee, James Bornholt et al.ASPLOS 2021 · 57 citations
Related papers
- Fast and Optimal Extraction for Sparse Equality GraphsAmir Kafshdar Goharshady, Chun Kit Lam, Lionel ParreauxOOPSLA 2024 · 11 citations
- ReGAL: Refactoring Programs to Discover Generalizable AbstractionsElias Stengel-Eskin, Archiki Prasad, Mohit BansalICML 2024 · 23 citations
- Automating Constraint-Aware Datapath Optimization using E-GraphsSamuel Coward, George A. Constantinides, Theo DraneDAC 2023 · 19 citations
- Dis/Equality GraphsGeorge Zakhour, Pascal Weisenburger, Jahrim Gabriele Cesario, Guido SalvaneschiPOPL 2025 · 3 citations
- Automated Knowledge-Aware Test ReuseZiyuan Zhang, Yi Gao, Xing Hu, Xin Xia et al.FSE 2026
