一句话:提出 SpecPylot,用 LLM 生成 icontract 规约,并借助 CrossHair 符号执行验证与反例驱动迭代修正。
手工编写形式规约成本高,而现有大语言模型生成的规约常因语法错误、约束过严或与程序行为不匹配而无法通过验证。SpecPylot 面向 Python 程序合成可执行的 icontract 注解:由 LLM 提议候选契约,再用 CrossHair 的符号执行进行验证;当发现具体反例时,只更新生成的契约,不修改原程序。该工具还能生成覆盖率驱动的 pytest 桩,并保留详细的执行工件以辅助调试。评估表明,SpecPylot 能为多数程序生成 CrossHair 兼容的契约,同时也揭示了有界符号探索和 LLM 行为差异带来的实际限制。
Automatically generating formal specifications could reduce the effort needed to improve program correctness, but in practice, this is still challenging. Many developers avoid writing contracts by hand, which limits the use of automated verification tools. Recent large language models (LLMs) can generate specifications from code, but these specifications often fail in terms of verification. The reason is syntax errors, overly strict constraints, or mismatches with program behavior. We present SpecPylot, a Python tool that synthesizes executable specifications for Python programs as icontract annotations and checks them using CrossHair's symbolic execution. The tool relies on LLMs to propose candidate contracts and uses CrossHair to validate them. When CrossHair finds a concrete counterexample, SpecPylot updates only the generated contracts and leaves the program itself untouched. In addition, the tool can produce coverage-driven pytest stubs and keep detailed execution artifacts that are useful during debugging. Overall, the evaluation indicates that SpecPylot is able to generate CrossHair-compatible contracts for most programs, but it also highlights the practical limits introduced by bounded symbolic exploration and differences in LLM behavior.