arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.18616cs.SEcs.AIcs.CL
收藏

迈向大语言模型辅助的程序细化

Towards Large Language Model Aided Program Refinement

National University of Singapore(新加坡国立大学);Griffith University(格里菲斯大学);Peking University(北京大学);Singapore Institute of Technology(新加坡科技设计大学);Shanghai Jiaotong University(上海交通大学);Singapore Management University(新加坡管理大学)

Yufan Cai, Zhe Hou, Xiaokun Luan, David Miguel Sanan Baena, Yun Lin, Jun Sun, Jin Song Dong

AI总结:

针对传统程序细化缺乏自动化及LLM生成代码不可靠的问题,提出LLM4PR工具,结合形式化细化演算与LLM自动生成并验证代码,确保代码正确性。

摘要:

程序细化涉及将形式化的高层规约语句保持正确性地转换为可执行程序。传统的程序细化验证工具支持高度交互且缺乏自动化。另一方面,大语言模型(LLM)的出现使得从非正式自然语言规约自动生成代码成为可能。然而,LLM生成的代码通常不可靠。此外,LLM提供的从规约到代码的不透明过程是一个不受控制的黑盒。我们提出了LLM4PR,这是一个将形式化程序细化技术与非正式的基于LLM的方法相结合的工具,旨在(1)将规约转换为前置条件和后置条件,(2)基于细化演算自动构建提示,(3)与LLM交互以生成代码,最后(4)验证生成的代码满足细化演算的条件,从而保证代码的正确性。我们使用GPT4、Coq和Coqhammer实现了该工具,并在HumanEval和EvalPlus数据集上对其进行了评估。

英文摘要:

Program refinement involves correctness-preserving transformations from formal high-level specification statements into executable programs. Traditional verification tool support for program refinement is highly interactive and lacks automation. On the other hand, the emergence of large language models (LLMs) enables automatic code generations from informal natural language specifications. However, code generated by LLMs is often unreliable. Moreover, the opaque procedure from specification to code provided by LLM is an uncontrolled black box. We propose LLM4PR, a tool that combines formal program refinement techniques with informal LLM-based methods to (1) transform the specification to preconditions and postconditions, (2) automatically build prompts based on refinement calculus, (3) interact with LLM to generate code, and finally, (4) verify that the generated code satisfies the conditions of refinement calculus, thus guaranteeing the correctness of the code. We have implemented our tool using GPT4, Coq, and Coqhammer, and evaluated it on the HumanEval and EvalPlus datasets.

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

↑