arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.17193cs.SE
收藏

言者无罪,逻辑难辨:对LLMs在后条件形式化上的基准测试

Talk is Cheap, Logic is Hard: Benchmarking LLMs on Post-Condition Formalization

Utrecht University(乌得勒支大学);Fondazione Bruno Kessler(布鲁诺·凯斯勒基金会)

I. S. W. B. Prasetya, Fitsum Kifetew, Davide Prandi

AI总结:

本文研究LLMs生成程序预条件和后条件形式化的能力,评估24种先进模型在40个任务数据集上的表现,发现LLMs在预条件形式化上表现优于后条件,但所有模型均无法正确完成所有任务,需通过良好测试集提升可靠性。

摘要:

形式化规范,如预条件和后条件为彻底程序验证提供了坚实基础。然而,开发者很少提供此类形式化规范,因此如果AI能帮助构建它们,将使形式化验证成为可能或至少使自动化测试更加有效。本文研究了LLMs在给定程序自然语言描述时生成正式的预条件和后条件的能力。24种最先进的LLMs在新准备的40个任务数据集上进行了评估。本文探讨了不同难度的规范,并讨论了一组更精细的性能指标,除了通用的accept@1性能。此外,本文还研究了使用自动生成的测试用例来验证LLMs提出的解决方案的影响。实验结果表明,总体而言LLMs可以根据程序的自然语言描述生成有效的预条件和后条件。专有模型的错误解决方案也往往接近正确。更仔细的检查显示,开源模型倾向于产生更高比例的错误结果,而专有模型则略高 false negative rates。有趣的是,结果还显示,将手动准备的数据集与自动生成的测试用例相结合,会导致错误解决方案的暴露,这些错误方案本应被接受为正确。总体而言,LLMs在形式化预条件方面优于后条件,专有模型优于开源模型。然而,没有任何LLMs能够正确形式化我们基准中的所有任务。总体而言,通过使用良好的测试集检查LLMs生成的形式化正确性,可以显著提高LLMs在预条件和后条件形式化中的有效性和可靠性。

英文摘要:

Formal specifications, such as pre- and post-conditions provide a solid basis for performing thorough program verification. However, developers rarely provide such formal specifications, hence if AI could help in constructing them, it would make formal verification possible or at least make automated testing much more effective. This paper presents a study on the ability of LLMs in generating formal FULL pre- and post-conditions of a program, given its natural language description. 24 state-of-the-art LLMs were evaluated on a freshly prepared dataset of 40 tasks. The paper investigates specifications of varying difficulty and discusses a set of more refined performance metrics in addition the general accept@1 performance. It also investigates the impact of using automatically generated tests for validation of the solutions proposed by LLMs. The results of the experiment reveal that, in general LLMs can produce valid pre- and post-conditions based on natural language descriptions of programs. Incorrect solutions from proprietary models are also often near correct. A closer inspection shows that open-source models tend to result in a higher proportion of erroneous results while proprietary models tend to have slightly higher false negative rates. Interestingly, the results also show that augmenting the manually prepared dataset with automatically generated tests leads to the exposure of wrong solutions, which would have otherwise been accepted as correct. In general, LLMs perform better in formalizing pre-conditions than on post-conditions and proprietary models perform better than open ones. However, none of the LLMs were able to correctly formalize all the tasks in our benchmark. Overall, the effectiveness and reliability of LLMs in formalizing pre- and post-conditions could be greatly improved by using a good test suite that checks the correctness of the LLM generated formalizations.

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

↑