paperbot · PL 论文追踪

全部论文 待读 收藏

P1 Translation Tag Team: Formal Rules and LLMs Translate More Macros Together Than Apart

翻译接力队:形式规则与 LLM 合作比分开翻译更多宏
ASE Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering2026匹配度 6/10 · 论文将形式化宏翻译器与LLM结合用于C到Rust的宏翻译,并提供首个宏翻译基准MacroBench,属于PL与LLM交叉,且兼具形式化、工程实现和问题驱动基准设计,与“AI→PL”方向有交集;但其核心任务是程序翻译而非静态分析或形式化验证,也不涉及浮点程序分析或贝叶斯程序分析,因此并非正中研究方向核心。引用 0 inbox
Brent Pappas, Joseph Zalusky, Zachary Burkett, Paul Gazzillo
crossref: 2026-10-09

AI 速览

一句话:提出形式化宏翻译器 MerC 与基准 MacroBench,并证明 MerC 先翻译、LLM 补余的接力法优于单独使用。

现代关键软件大量用 C,但 C 缺乏内存安全,促使研究者自动将 C 翻译为 Rust。真实 C 程序常使用宏,而宏不属于 C 语言本身;现有方法先预处理再翻译,会内联所有宏定义,导致译文与源码结构差异大。为在译文中保留宏,本文提炼宏与 C 共享的语言特性,设计首个形式化规约的宏翻译器 MerC,并提出首个宏翻译基准 MacroBench,其用例来自真实 C 程序随机采样的宏。实验表明,MerC 支持 50% 用例;LLM 比 MerC 多翻译 22%–77%,但有 8%–28% 的翻译错误,而 MerC 只产生正确翻译。关键洞见是先运行 MerC,再用 LLM 处理剩余宏:该接力法平均失败率比 LLM 低 32%,比 MerC 多翻译 51% 用例。

问题
真实 C 代码中的宏不属于 C 语言本身,现有先预处理再翻译的方法会内联宏定义,破坏译文与原代码的相似性;本文研究如何直接翻译宏并在译文中保留宏使用。
方法
提炼宏与 C 共享的语言特性,提出首个形式化规约的宏翻译器 MerC;构建首个宏翻译基准 MacroBench,并设计先由 MerC 翻译、剩余交予 LLM 的接力流程。
评估
在 MacroBench 上,MerC 支持 50% 用例;LLM 比 MerC 多翻译 22%–77%,但有 8%–28% 错误;接力法比 LLM 平均失败率低 32%,比 MerC 多翻译 51%。
原文摘要(Abstract)

Modern critical software infrastructure is largely written in C. Since C lacks memory safety, researchers are investigating automatic translation of C to safer languages like Rust. But real-world C software consists of more than just C code, often using named code fragments called macros which are not part of the C language proper. State-of-the-art techniques avoid translating macros by preprocessing C code first before translating it. But this approach produces translations that are dissimilar to the original C code, because preprocessing inlines all macro definitions. To preserve macro usage in translated code, we study the language features that macros and C share and distill them into the first formally- specified translator, MerC. To evaluate MerC, we introduce the first macro translation benchmark, MacroBench, with test cases based on macros randomly sampled from real-world C programs. We find that MerC supports 50% of MacroBench’s macro test cases. We also use MacroBench to evaluate how effective large language models (LLMs) are at performing the previously-unstudied task of macro translation. LLMs translate 22% to 77% more of MacroBench than MerC, but with 8% and 28% of these translations being incorrect translations requiring additional validation by developers. In contrast, MerC only produces correct translations. Our key insight is that running MerC first then using LLMs on the remainder reaps greater benefits than using either technique alone. This tag team approach has an average failure rate 32% lower than that of LLMs, while also translating an average of 51% more test cases than MerC.

链接与引用

DOI 原文 · arXiv ·

BibTeX
@inproceedings{paperbot12420,
  title = {Translation Tag Team: Formal Rules and LLMs Translate More Macros Together Than Apart},
  author = {Brent Pappas and Joseph Zalusky and Zachary Burkett and Paul Gazzillo},
  booktitle = {ASE},
  year = {2026},
  doi = {10.1145/3832783.3837412}
}