Logic programs are a powerful approach for solving NP-Hard problems. However, due to their declarative nature, debugging logic programs poses significant challenges. Unlike procedural paradigms, which allow for step-by-step inspection of program state, logic programs require reasoning about logical statements for fault localization. This complexity is amplified in learning environments due to students' inexperience. We introduce FormHe, a novel tool that combines logic-based techniques and Large Language Models to identify and correct issues in Answer Set Programming submissions. FormHe consists of two components: a fault localization module and a program repair module. First, the fault localizer identifies a set of faulty program statements requiring modification. Subsequently, FormHe employs program mutation techniques and Large Language Models to repair the flawed ASP program. These repairs can then serve as guidance for students to correct their programs. Our experiments with real buggy programs submitted by students show that FormHe accurately detects faults in 94% of cases and successfully repairs 58% of incorrect submissions.
翻译:逻辑程序是解决NP难问题的有效方法。然而,由于其声明式特性,调试逻辑程序面临重大挑战。与允许逐步检查程序状态的过程式范式不同,逻辑程序需要对逻辑语句进行推理以实现故障定位。在学习环境中,由于学生经验不足,这种复杂性进一步加剧。本文提出FormHe——一种结合基于逻辑的技术与大语言模型的新型工具,用于识别和修正答案集编程提交中的问题。FormHe包含两个组件:故障定位模块与程序修复模块。首先,故障定位器识别出一组需要修改的错误程序语句;随后,FormHe运用程序变异技术和大语言模型对存在缺陷的ASP程序进行修复。这些修复结果可为学生修正程序提供指导。通过对学生提交的真实错误程序进行实验,结果表明FormHe在94%的情况下能准确检测故障,并成功修复58%的错误提交。