claimcheck:测量与提升规范的忠实度
claimcheck: Measuring and Improving Specification Faithfulness
AI总结:
本研究针对LLM生成代码与规范时的需求-规范差距问题,构建含3234条目的多语言规范形式化基准,提出claimcheck工具检测错误形式化,在四种语言上提升了宏观召回率。
摘要:
形式化验证可证明程序满足其规范,但无法说明该规范是否捕捉到了作者的真实意图。随着大型语言模型(LLM)越来越多地编写代码和规范,作者的自然语言需求与规范之间的差距成为了现实风险。对一个比所请求属性更窄的属性进行机器验证的证明毫无价值,却能通过所有检查。缩小这一差距需要解决规范形式化问题:给定自然语言需求,生成含义与其匹配的形式化产物。为测量该差距,我们整理了一个用于规范形式化的端到端基准,涵盖四种形式化语言:Dafny 契约、Lean 4、Isabelle 和 Rocq 定理陈述。该基准的 3234 个条目均配对了自然语言需求、形式化产物以及通过执行、证明或基准来源确定的标签。其中三分之一的条目是对形式化产物的含义保留重写,且保留了忠实标签,因此评判者无法通过检测条目是否被编辑来评分。我们引入 claimcheck 工具,用于检测不正确的形式化:形式化产物由一个从未见过需求的模型翻译回纯自然语言,而另一个模型(评判者)则判断该非正式化结果与需求是否表达相同的保证。在所有四种语言上,该工具的宏观召回率比仅展示需求和形式化产物的单次调用高出 8.2 至 9.8 个百分点,比提供相同含义保留重写列表的单次调用高出 4.2 至 6.0 个百分点。向评判者展示形式化产物会使召回率降低 1.4 至 4.5 个百分点。在同样看到形式化产物的四位评判者中,随着评判者能力增强,召回率增益会缩小,最强评判者的增益与知情单次调用的差距在 1 个百分点以内。
英文摘要:
Formal verification proves that a program satisfies its specification, but says nothing about whether the specification captures what the author meant. As LLMs increasingly write both code and specifications, a gap between the author's natural-language requirement and the specification becomes a live risk. A machine-checked proof of a property narrower than the one requested is worthless but passes every check. Closing this gap is solving the spec formalization problem: given a natural-language requirement, produce a formal artifact whose meaning matches it. To measure the gap, we curate an end-to-end benchmark for spec formalization spanning four formal languages: Dafny contracts and Lean 4, Isabelle and Rocq theorem statements. Each of its 3,234 rows pairs a natural-language requirement with a formal artifact and a label established by execution, by proof, or by the benchmark it is drawn from. A third of the rows are meaning-preserving rewrites of the artifact that keep the faithful label, so a judge cannot score by detecting that a row was edited. We introduce claimcheck, a tool that detects incorrect formalizations: the formal artifact is translated back into plain English by a model that never sees the requirement, and a separate model, the judge, decides whether the informalization and the requirement express the same guarantee. On all four languages it gains 8.2 to 9.8 points of macro recall over a single call shown the requirement and the artifact, and 4.2 to 6.0 over that call handed the same list of meaning-preserving rewrites. Showing the judge the artifact as well costs 1.4 to 4.5 points. Across four judges that also see the artifact, the gain shrinks as the judge gets stronger, to within a point of the informed single call for the strongest.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。