Back to search

Massachusetts Institute of Technology

Program Optimization With Collection Annotations and Database-Style Term Rewriting

Abstract

dc:description.abstract

Since the 1970s, database engines have optimized queries by representing them in core calculi and repeatedly applying algebraic rewrite rules. Larger applications often treat database engines as important external data structures, benefiting from their internal optimizations. However, those applications are typically optimized with more conventional compiler techniques like dataflow analysis. We present here our experiences fusing application code with database logic and jointly optimizing them, now with algebraic rewrites for both, not just queries. That is, database-style data structures and algorithms are optimized with ahead-of-time knowledge of not just access patterns but also how query results are used in general-purpose code. The top new enabling idea is keeping track of contexts around queries using coercions between different consistency levels (list, bag, set). Our method is embodied in a library within the Rocq Prover, allowing rapid assembly of custom compilation pipelines with mechanized proof of correctness. We parameterized our compiler over optimization hints and conducted experiments using a range of example programs. The compiler was formally verified to produce semantically preserving pipelines when instantiated with arbitrary optimization hints. It achieved the expected asymptotic optimizations using hints generated by a large-language model, and the concrete runtime of each optimized program was comparable to that of the corresponding program written in Python with access to a SQLite database.

Degree

thesis:*
Name thesis:degree_name
Master
Grantor dc:publisher
Massachusetts Institute of Technology
Year dc:date.issued
2026

Author and committee

dc:creator, dc:contributor.*
Author dc:creator
  • Zhang, Xin
Advisor dc:contributor.advisor
  • Chlipala, Adam

Rights

dc:rights
Statement dc:rights
  • In Copyright - Educational Use Permitted
  • Copyright retained by author(s)

Identifiers

dc:identifier.*
Repository record dc:identifier.uri
https://dspace.mit.edu/handle/1721.1/177359

Chain of custody

source
Harvested from
MIT
Base URL
dspace.mit.edu/oai/request
Last updated
2026-11-27
Source record
OAI-PMH GetRecord
related terms
citation

Zhang, Xin. Program Optimization With Collection Annotations and Database-Style Term Rewriting. Massachusetts Institute of Technology, 2026. https://dspace.mit.edu/handle/1721.1/177359