Formal specification synthesis by LLMs

Determine how to reliably synthesize high-quality formal program specifications with large language models, addressing the unresolved challenge that current LLM-based specification synthesis remains difficult.

Background

The paper compares LLM-generated Rocq specifications with human-written specifications using formal equivalence proofs. Among 29 problems for which both a human and an LLM specification passed the paper’s test-based validation, only 9 were provably equivalent in both directions; several additional cases were judged semantically equivalent despite proof failures attributed to prover limitations. The limited overlap between human and LLM successes indicates that current models do not consistently reproduce the intended formal behavior across the benchmark.

The authors therefore characterize LLM-based formal specification synthesis as an unresolved research challenge. This problem concerns improving the reliability and semantic precision of generated specifications, rather than merely producing syntactically valid Rocq code or specifications that pass a finite test suite.

References

The limited overlap between human and LLM successes suggests complementary strengths: they succeed on distinct problem subsets rather than merely differing in capability level, indicating LLM-based specification synthesis remains a challenging open problem.

— How Powerful are LLMs in Generating Formal Program Specifications?  (2608.13077 - Yang et al., 13 Aug 2026) in Appendix, Section RQ5: Is Formal Specification Generation More Like Math or Code?, subsection Equivalence Analysis

Writing that specification is the hard part: models that must write their own gain nothing over an unaided baseline, and only $62\%$ of their specifications pass our audit. The usual failure is faithfulness, a specification that constrains part of the required behavior and leaves the rest free. Specification quality still tracks the outcome, failing on $89\%$ of unresolved instances against $47\%$ of resolved ones, making faithful specification synthesis a concrete open problem.

— SWE-Proof: Can Language Models Resolve Real-World Issues with Machine-Checked Proofs?  (2609.21190 - Ma et al., 18 Sep 2026) in Abstract