通过负测试作为完整性信号的强化学习用于形式规范综合
SpecRL: Reinforcement Learning with Test-Based Completeness Rewards for Formal Specification Synthesis
AI总结:
本文提出SpecRL框架,利用负测试比例作为规范完整性的信号,提升规范强度和验证成功率,实验显示其在不同模型规模上表现优异。
摘要:
规范综合任务旨在自动生成现有程序的规范及必要的辅助验证注释。此类规范作为行为合同,支持模块化推理和可重用验证。然而,仅依赖验证器反馈存在信息不完整问题。本文提出SpecRL框架,通过生成负测试(无法由程序产生的输入输出对)并利用其拒绝比例作为完整性信号,集成到强化学习训练奖励中。实验表明,SpecRL在不同模型规模上均提升了规范强度和验证成功率,并能泛化至分布外基准,与更大通用LLM相比保持竞争力。
英文摘要:
Specification synthesis asks a model to generate specifications and auxiliary annotations for an existing program. In modern software verification projects, specification accuracy is critical. A specification is the abstraction of a method's behavior, and callers are verified against the callee's specification rather than its implementation. As a result, the specification for a callee can strongly affect what properties callers can prove. However, verifier feedback alone is a poor training signal for specification synthesis: verification can prove that a specification is sound for the implementation, yet it cannot tell whether the specification is too weak. We present SpecRL, a reinforcement learning framework that adds an empirical completeness signal to specification synthesis in Dafny. SpecRL constructs negative tests, or spectests, from implementation-impossible input-output pairs that weak specifications such as ensures true may still admit. During training, SpecRL rewards verified candidates according to the fraction of spectests their specifications reject, thereby ranking these candidates by how many implementation-impossible behaviors they rule out. On the out-of-distribution DafnyComp-Spec benchmark, the 7B SpecRL model improves verification success and completeness over supervised fine-tuning by 49.96% and 26.46%, respectively. These relative gains show that fine-grained spectest feedback improves both verifiability and specification accuracy.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。