Guided equality saturation

Koehler, T., Goens, A., Bhat, S., Grosser, T., Trinder, P. and Steuwer, M. (2024) Guided equality saturation. Proceedings of the ACM on Programming Languages, 8(POPL), 58. (doi: 10.1145/3632900)

[img] Text
308331.pdf - Published Version
Available under License Creative Commons Attribution.

510kB

Abstract

Rewriting is a principled term transformation technique with uses across theorem proving and compilation. In theorem proving, each rewrite is a proof step; in compilation, rewrites optimize a program term. While developing rewrite sequences manually is possible, this process does not scale to larger rewrite sequences. Automated rewriting techniques, like greedy simplification or equality saturation, work well without requiring human input. Yet, they do not scale to large search spaces, limiting the complexity of tasks where automated rewriting is effective, and meaning that just a small increase in term size or rewrite length may result in failure. This paper proposes a semi-automatic rewriting technique as a means to scale rewriting by allowing human insight at key decision points. Specifically, we propose guided equality saturation that embraces human guidance when fully automated equality saturation does not scale. The rewriting is split into two simpler automatic equality saturation steps: from the original term to a human-provided intermediate guide, and from the guide to the target. Complex rewriting tasks may require multiple guides, resulting in a sequence of equality saturation steps. A guide can be a complete term, or a sketch containing undefined elements that are instantiated by the equality saturation search. Such sketches may be far more concise than complete terms. We demonstrate the generality and effectiveness of guided equality saturation using two case studies. First, we integrate guided equality saturation in the Lean 4 proof assistant. Proofs are written in the style of textbook proof sketches, as a series of calculations omitting details and skipping steps. These proofs conclude in less than a second instead of minutes when compared to unguided equality saturation, and can find complex proofs that previously had to be done manually. Second, in the compiler of the Rise array language, where unguided equality saturation fails to perform optimizations within an hour and using 60 GB of memory, guided equality saturation performs the same optimizations with at most 3 guides, within seconds using less than 1 GB memory.

Item Type:Articles
Additional Information:This work was funded in part by the Engineering and Physical Sciences Research Council, through grant reference EP/V038699/1.
Status:Published
Refereed:Yes
Glasgow Author(s) Enlighten ID:KOEHLER, Thomas and Steuwer, Dr Michel and Trinder, Professor Phil
Authors: Koehler, T., Goens, A., Bhat, S., Grosser, T., Trinder, P., and Steuwer, M.
College/School:College of Science and Engineering > School of Computing Science
Journal Name:Proceedings of the ACM on Programming Languages
Publisher:ACM
ISSN:2475-1421
ISSN (Online):2475-1421
Published Online:05 January 2024
Copyright Holders:Copyright © 2024 The Authors
First Published:First published in Proceedings of the ACM on Programming Languages 8(POPL): 58
Publisher Policy:Reproduced under a Creative Commons License
Related URLs:

University Staff: Request a correction | Enlighten Editors: Update this record