paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Translating canonical SQL to imperative code in Coq

在 Coq 中将规范 SQL 翻译为命令式代码
OOPSLA 6(OOPSLA1)2022匹配度 2/10 · 该论文在 Coq 中机械化验证 SQL 到命令式代码的编译器,属于形式化验证与 PL 工程,但未涉及静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户核心关注的 PL 与 AI 交叉方向关联很弱。引用 3 inbox
Véronique Benzaken, Évelyne Contejean, Mohammed Houssem Hachmaoui, Chantal Keller, Louis Mandel, Avraham Shinnar, Jérôme Siméon
crossref: 2026-09-10

AI 速览

一句话:在 Coq 中机械化验证了从规范 SQL 查询到命令式代码的编译器 DBCert,覆盖相关查询与 NULL 语义。

SQL 虽广泛使用,但在相关查询与 NULL 值语义等关键特性上,许多实现存在分歧或缺陷。本文提出 DBCert:首个从规范形式 SQL 查询到命令式代码的机械化验证编译器。其贡献包括:形式化并机械化从 SQL 到嵌套关系代数(NRA)的完整翻译,以支持查询优化;定义小型命令式语言 Imp,足以表达 SQL 并可面向 JavaScript 等多种执行语言;以及以嵌套关系演算(NRC)为中间步骤,机械化从 NRA 到 Imp 的翻译。整个编译管线在 Coq 中构造并证明,从而为 SQL 查询编译提供可信基础。

问题
SQL 的关键语义(如相关查询和 NULL 值)在不同实现中不一致甚至出错,如何为 SQL 到可执行命令式代码的编译提供可信保证。
方法
在 Coq 中机械化构建 DBCert 编译器:将规范 SQL 翻译为嵌套关系代数,再经嵌套关系演算翻译到小型命令式语言 Imp。
评估
通过 Coq 机械化实现并验证编译器 DBCert;Imp 设计为可面向 JavaScript 等多种执行语言。
原文摘要(Abstract)

SQL is by far the most widely used and implemented query language. Yet, on some key features, such as correlated queries and NULL value semantics, many implementations diverge or contain bugs. We leverage recent advances in the formalization of SQL and query compilers to develop DBCert, the first mechanically verified compiler from SQL queries written in a canonical form to imperative code. Building DBCert required several new contributions which are described in this paper. First, we specify and mechanize a complete translation from SQL to the Nested Relational Algebra which can be used for query optimization. Second, we define Imp, a small imperative language sufficient to express SQL and which can target several execution languages including JavaScript. Finally, we develop a mechanized translation from the nested relational algebra to Imp, using the nested relational calculus as an intermediate step.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1529,
  title = {Translating canonical SQL to imperative code in Coq},
  author = {Véronique Benzaken and Évelyne Contejean and Mohammed Houssem Hachmaoui and Chantal Keller and Louis Mandel and Avraham Shinnar and Jérôme Siméon},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {OOPSLA1},
  year = {2022},
  doi = {10.1145/3527327}
}