引用本文:王熙灶,沈天琪,宾向荣,卜磊.LLM赋能的Datalog代码翻译技术及增量程序分析框架.软件学报,2025,36(6):2515-2534
【打印本页】   【下载PDF全文】   查看/发表评论  【EndNote】   【RefMan】   【BibTex】
←前一篇|后一篇→ 过刊浏览    高级检索
本文已被:浏览 2059次   下载 2378 本文二维码信息
码上扫一扫!
分享到: 微信 更多
LLM赋能的Datalog代码翻译技术及增量程序分析框架
王熙灶1,2, 沈天琪1,2, 宾向荣1,2, 卜磊1,3
1.计算机软件新技术全国重点实验室(南京大学), 江苏 南京 210023;2.南京大学 计算机学院, 江苏 南京 210023;3.南京大学 软件学院, 江苏 南京 210023
摘要:
Datalog是一种声明式逻辑编程语言, 在不同领域得到了广泛应用. 近年来, 学术界和工业界对Datalog的兴趣高涨, 设计并开发了多种Datalog引擎和相应方言. 然而, 多方言带来的一个问题是以一种Datalog方言实现的代码, 一般而言不能在另一种方言的引擎上执行. 因此, 当采用新Datalog引擎时, 需要将现有Datalog代码翻译到新方言上. 目前的Datalog代码翻译技术可分为人工重写代码和人工设计翻译规则两类, 存在耗时长、大量重复劳动、缺乏灵活性和可拓展性等问题. 提出了一种大语言模型(LLM)赋能的Datalog代码翻译技术, 利用LLM强大的代码理解和生成能力, 通过分治翻译策略、基于少样本提示和思维链提示的提示工程、基于检查-反馈-修复的迭代纠错机制, 可以在不同Datalog方言之间实现高精度代码翻译, 减轻开发人员重复开发翻译规则的工作量. 基于此代码翻译技术, 设计并实现了一种通用的基于Datalog的声明式增量程序分析框架. 在不同Datalog方言对上评估了所提出的LLM赋能的Datalog代码翻译技术的性能, 评估结果验证了所提代码翻译技术的有效性. 对通用声明式增量程序分析框架进行了实验评估, 验证了基于所提代码翻译技术的增量程序分析的加速效果.
关键词:  Datalog  代码翻译  大语言模型  程序分析  增量分析框架
DOI:10.13328/j.cnki.jos.007330
分类号:
基金项目:国家自然科学基金(62232008, 62172200); 江苏省前沿引领技术基础研究专项(BK20202001)
LLM-powered Datalog Code Translation and Incremental Program Analysis Framework
WANG Xi-Zao1,2, SHEN Tian-Qi1,2, BIN Xiang-Rong1,2, BU Lei1,3
1.State Key Laboratory for Novel Software Technology (Nanjing University), Nanjing 210023, China;2.School of Computer Science, Nanjing University, Nanjing 210023, China;3.Software Institute, Nanjing University, Nanjing 210023, China
Abstract:
Datalog, a declarative logic programming language, is widely applied in various fields. In recent years, there has been a growing interest in Datalog from both the academic and industrial communities, leading to the design and development of multiple Datalog engines and corresponding dialects. However, one problem brought about by the multiple dialects is that the code implemented in one Datalog dialect generally cannot be executed on the engine of another dialect. Therefore, when a new Datalog engine is adopted, the existing Datalog code needs to be translated into the new dialect. The current Datalog code translation techniques can be classified into two categories: manually rewriting the code and manually designing translation rules, which have problems such as being time-consuming, involving a large amount of repetitive work, and lacking flexibility and scalability. In this study, a Datalog code translation technology empowered by large language model (LLM) is proposed. By leveraging the powerful code understanding and generation capabilities of LLM, through the divide-and-conquer translation strategy, the prompt engineering based on few-shot and chain-of-thought prompts, and an iterative error-correction mechanism based on check-feedback-repair, high-precision code translation between different Datalog dialects can be achieved, reducing the workload of developers in repeatedly developing translation rules. Based on this code translation technology, a general declarative incremental program analysis framework based on Datalog is designed and implemented. The performance of the proposed LLM-powered Datalog code translation technology is evaluated on different Datalog dialect pairs, and the evaluation results verify the effectiveness of the proposed code translation technology. This study also conducts an experimental evaluation of the general declarative incremental program analysis framework, verifying the speedup effect of incremental program analysis based on the proposed code translation technology.
Key words:  Datalog  code translation  large language model (LLM)  program analysis  incremental analysis framework

引用本文:
【打印本页】   【下载PDF全文】   查看/发表评论  【EndNote】   【RefMan】   【BibTex】
←前一篇|后一篇→ 过刊浏览    高级检索
本文已被:浏览次   下载  
分享到: 微信 更多
摘要:
关键词:  
DOI:
分类号:
基金项目:
Abstract:
Key words: