arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2203.09452cs.PL
收藏

使用神经元引导的程序合成将命令自动转换为功能代码(扩展版)

Automated Transpilation of Imperative to Functional Code using Neural-Guided Program Synthesis (Extended Version)

Benjamin Mariano, Yanju Chen, Yu Feng, Greg Durrett, Isil Dillig

摘要:

虽然许多主流语言(如Java、Python和C#)越来越多地采用函数式API来简化编程并提高并行化/性能,但没有有效的技术可以用于使用这些API将现有的命令式代码自动转换为函数式变体。针对这一问题,本文提出了一种基于归纳程序合成的编译方法,以实现现有代码的现代化。我们的方法是基于这样的观察,即绝大多数的源/目标程序在此设置满足一个假设,我们称之为跟踪兼容性:不仅程序共享语法相同的低级别的表达式,但这些表达式也采取相同的值在相应的执行轨迹。我们的方法利用这一观察结果来设计一种新的神经指导合成算法,该算法(1)使用一种称为同源语法网络(CGN)的新型神经架构,(2)利用一种concolic执行形式来基于计算过程中出现的中间值修剪部分程序。我们已经在一个名为NGST 2的工具中实现了我们的方法,并使用它将命令式Java和Python代码转换为分别使用Stream和functools API的函数变体。我们的实验表明,NGST 2显着优于几个基线,我们提出的神经架构和修剪技术是实现良好的结果至关重要。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑