{"id":{"repo_id":"mit","oai_identifier":"oai:dspace.mit.edu:1721.1/177359"},"canonical_url":"https://search.ndltd.org/etd/mit/oai:dspace.mit.edu:1721.1/177359","repository":{"repo_id":"mit","name":"MIT","base_url":"https://dspace.mit.edu/oai/request"},"display":{"title":"Program Optimization With Collection Annotations and Database-Style Term Rewriting","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.","abstract_html":"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.","abstract_has_math":false,"creators":["Zhang, Xin"],"institution":"Massachusetts Institute of Technology","degree_name":"Master","degree_level":null,"degree_discipline":null,"degree_department":null,"school":null,"contributors":[],"advisors":["Chlipala, Adam"],"committee_chairs":[],"committee_members":[],"year":2026,"date_issued":"2026-05","date_published":"2026-05","updated_at":"2026-11-27T07:24:33Z","subjects":[],"languages":[],"rights":["In Copyright - Educational Use Permitted","Copyright retained by author(s)"],"rights_urls":["https://rightsstatements.org/page/InC-EDU/1.0/"],"identifier_entries":[],"person_identifier_entries":[]},"links":{"outbound_url":"https://dspace.mit.edu/handle/1721.1/177359","outbound_label":"Repository record","outbound_source":"dc:identifier.uri","record_url":"https://dspace.mit.edu/handle/1721.1/177359","record_label":"Repository record","record_kind":"record","record_source":"dc:identifier.uri","access_status":null,"embargo_until":null,"access_note":null},"oai_pmh_record":{"url":"https://union.ndltd.org/oai-pmh/?verb=GetRecord&metadataPrefix=oai_dc&identifier=oai%3Aunion.ndltd.org%3Arepo%3Amit%3Aoai%3Adspace.mit.edu%3A1721.1%2F177359","prefix":"oai_dc"},"source_record":{"url":"https://dspace.mit.edu/oai/request?verb=GetRecord&metadataPrefix=dim&identifier=oai%3Adspace.mit.edu%3A1721.1%2F177359","prefix":"dim"},"metadata_groups":[{"id":"people","label":"People","entries":[{"key":"dc:contributor.advisor","label":"Advisor","values":["Chlipala, Adam"]},{"key":"dc:creator","label":"Author","values":["Zhang, Xin"]}]},{"id":"academic_context","label":"Academic Context","entries":[{"key":"dc:date.accessioned","label":"Dc Date Accessioned","values":["2026-10-28T17:05:56Z"]},{"key":"dc:date.available","label":"Dc Date Available","values":["2026-10-28T17:05:56Z"]},{"key":"dc:date.issued","label":"Date","values":["2026-05"]},{"key":"dc:date.submitted","label":"Dc Date Submitted","values":["2026-08-03T16:27:18.326Z"]},{"key":"dc:publisher","label":"Institution","values":["Massachusetts Institute of Technology"]},{"key":"dc:type","label":"Dc Type","values":["Thesis"]},{"key":"thesis:degree_name","label":"Degree Name","values":["Master","Master of Science in Electrical Engineering and Computer Science"]}]},{"id":"language_rights","label":"Language and Rights","entries":[{"key":"dc:rights","label":"Dc Rights","values":["In Copyright - Educational Use Permitted","Copyright retained by author(s)"]},{"key":"dc:rights.uri","label":"Rights URI","values":["https://rightsstatements.org/page/InC-EDU/1.0/"]}]},{"id":"identifiers","label":"Identifiers","entries":[{"key":"dc:identifier.uri","label":"Identifier URI","values":["https://dspace.mit.edu/handle/1721.1/177359"]}]},{"id":"additional","label":"Additional Metadata","entries":[{"key":"cerif:openaire","label":"Cerif Openaire","values":["<Publication xmlns=\"https://www.openaire.eu/cerif-profile/1.1/\" id=\"400489d4-08d2-4655-9f22-83d4081452a4\"> <Type xmlns=\"https://www.openaire.eu/cerif-profile/vocab/COAR_Publication_Types\">http://purl.org/coar/resource_type/c_1843</Type> <Title>Program Optimization With Collection Annotations and Database-Style Term Rewriting</Title> <PublishedIn> <Publication> </Publication> </PublishedIn> <PublicationDate>2026-05</PublicationDate> <Authors> <Author> <DisplayName>Zhang, Xin</DisplayName> <Affiliation> <OrgUnit> </OrgUnit> </Affiliation> </Author> </Authors> <Editors> </Editors> <Publishers> <Publisher> <DisplayName>Massachusetts Institute of Technology</DisplayName> <OrgUnit /> </Publisher> </Publishers> <License>https://rightsstatements.org/page/InC-EDU/1.0/</License> <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.</Abstract> <Access xmlns=\"http://purl.org/coar/access_right\" > </Access> </Publication>"]},{"key":"dc:description.abstract","label":"Abstract","values":["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."]},{"key":"dc:description.degree","label":"Dc Description Degree","values":["S.M."]},{"key":"dc:format.mimetype","label":"Dc Format Mimetype","values":["application/pdf"]},{"key":"dc:title","label":"Title","values":["Program Optimization With Collection Annotations and Database-Style Term Rewriting"]},{"key":"dspace:entity.type","label":"Dspace Entity Type","values":["Publication"]},{"key":"others:access_status","label":"Others Access Status","values":["unknown"]}]}],"canonical_facts":{"cerif:openaire":["<Publication xmlns=\"https://www.openaire.eu/cerif-profile/1.1/\" id=\"400489d4-08d2-4655-9f22-83d4081452a4\"> <Type xmlns=\"https://www.openaire.eu/cerif-profile/vocab/COAR_Publication_Types\">http://purl.org/coar/resource_type/c_1843</Type> <Title>Program Optimization With Collection Annotations and Database-Style Term Rewriting</Title> <PublishedIn> <Publication> </Publication> </PublishedIn> <PublicationDate>2026-05</PublicationDate> <Authors> <Author> <DisplayName>Zhang, Xin</DisplayName> <Affiliation> <OrgUnit> </OrgUnit> </Affiliation> </Author> </Authors> <Editors> </Editors> <Publishers> <Publisher> <DisplayName>Massachusetts Institute of Technology</DisplayName> <OrgUnit /> </Publisher> </Publishers> <License>https://rightsstatements.org/page/InC-EDU/1.0/</License> <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.</Abstract> <Access xmlns=\"http://purl.org/coar/access_right\" > </Access> </Publication>"],"dc:contributor.advisor":["Chlipala, Adam"],"dc:creator":["Zhang, Xin"],"dc:date.accessioned":["2026-10-28T17:05:56Z"],"dc:date.available":["2026-10-28T17:05:56Z"],"dc:date.issued":["2026-05"],"dc:date.submitted":["2026-08-03T16:27:18.326Z"],"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."],"dc:description.degree":["S.M."],"dc:format.mimetype":["application/pdf"],"dc:identifier.uri":["https://dspace.mit.edu/handle/1721.1/177359"],"dc:publisher":["Massachusetts Institute of Technology"],"dc:rights":["In Copyright - Educational Use Permitted","Copyright retained by author(s)"],"dc:rights.uri":["https://rightsstatements.org/page/InC-EDU/1.0/"],"dc:title":["Program Optimization With Collection Annotations and Database-Style Term Rewriting"],"dc:type":["Thesis"],"dspace:entity.type":["Publication"],"others:access_status":["unknown"],"thesis:degree_name":["Master","Master of Science in Electrical Engineering and Computer Science"]},"updated_at":"2026-11-27T07:24:33Z"}