paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Automated transpilation of imperative to functional code using neural-guided program synthesis

使用神经引导程序合成自动将命令式代码转译为函数式代码
OOPSLA 6(OOPSLA1)2022匹配度 4/10 · 该论文属于神经引导的程序合成与代码转译,与PL+AI交叉方向有一定关联,但不涉及用户核心关注的静态分析、形式化验证、LLM/Agent 或浮点/贝叶斯程序分析。引用 27 inbox
Benjamin Mariano, Yanju Chen, Yu Feng, Greg Durrett, Işil Dillig
crossref: 2026-09-10

AI 速览

一句话:提出基于归纳程序合成与神经引导的命令式到函数式 API 代码转译方法,工具 NGST2 显著优于多个基线。

主流语言虽引入函数式 API,但缺乏自动把既有命令式代码转译为函数式变体的技术。本文提出基于归纳程序合成的转译方法,核心观察是源/目标程序大多满足 trace-compatibility:不仅共享语法相同的底层表达式,其在对应执行轨迹中的取值也相同。据此设计神经引导合成算法,采用名为 cognate grammar network(CGN)的新型神经架构,并用 concolic execution 依据中间值剪枝部分程序。作者实现工具 NGST2,将命令式 Java/Python 代码分别转译为使用 Stream 与 functools 的变体。实验显示 NGST2 显著优于多个基线,神经架构与剪枝技术对效果至关重要。

问题
Java、Python、C# 等语言不断引入函数式 API,但尚无有效技术能自动将已有命令式代码翻译为使用这些 API 的函数式变体。
方法
利用源/目标程序普遍满足的 trace-compatibility 性质,设计神经引导的归纳程序合成算法:以 cognate grammar network(CGN)引导搜索,并用 concolic execution 按中间值剪枝部分程序。
评估
实现工具 NGST2,将命令式 Java 与 Python 代码转译为使用 Stream 和 functools 的函数式变体,并与多个基线对比,同时消融验证神经架构与剪枝技术的必要性。
原文摘要(Abstract)

While many mainstream languages such as Java, Python, and C# increasingly incorporate functional APIs to simplify programming and improve parallelization/performance, there are no effective techniques that can be used to automatically translate existing imperative code to functional variants using these APIs. Motivated by this problem, this paper presents a transpilation approach based on inductive program synthesis for modernizing existing code. Our method is based on the observation that the overwhelming majority of source/target programs in this setting satisfy an assumption that we call trace-compatibility: not only do the programs share syntactically identical low-level expressions, but these expressions also take the same values in corresponding execution traces. Our method leverages this observation to design a new neural-guided synthesis algorithm that (1) uses a novel neural architecture called cognate grammar network (CGN) and (2) leverages a form of concolic execution to prune partial programs based on intermediate values that arise during a computation. We have implemented our approach in a tool called NGST2 and use it to translate imperative Java and Python code to functional variants that use the Stream and functools APIs respectively. Our experiments show that NGST2 significantly outperforms several baselines and that our proposed neural architecture and pruning techniques are vital for achieving good results.

链接与引用

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

BibTeX
@article{paperbot1526,
  title = {Automated transpilation of imperative to functional code using neural-guided program synthesis},
  author = {Benjamin Mariano and Yanju Chen and Yu Feng and Greg Durrett and Işil Dillig},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {6},
  number = {OOPSLA1},
  year = {2022},
  doi = {10.1145/3527315}
}