AI
New Framework Exposes Gaps in AI-Generated Code Specifications
Researchers reveal that formal specifications generated by LLMs can pass standard checks while still failing to capture what users actually need.
When systems use large language models (LLMs) to write verifiable code from natural language requirements, they typically rely on two critical steps: generating formal specifications (the contract for what the code must do) and then proving the code meets those specs. But a new study shows that this pipeline has a blind spot—a specification can satisfy all the mathematical proofs while fundamentally misunderstanding what the user intended.
The Specification Generation Problem#
Creating formal specifications that can be checked by theorem provers has long been the bottleneck in automated code verification. Unlike proof generation, which receives clear pass-or-fail feedback from a prover, specification generation (SpecGen) lacks an objective yardstick to confirm it accurately reflects user intent. As a result, a correct proof against a flawed specification can give false confidence that the code is truly correct.
A Unified Evaluation Framework#
To address this gap, researchers assembled a dataset of 350 formal specification tasks from two existing benchmarks—189 from VERINA and 161 from CLEVER—and developed a comprehensive evaluation framework. Their approach goes beyond simple syntax checking to assess three dimensions:
- Formal validity: Does the specification compile and run without errors?
- Reference similarity and equivalence: How closely does the generated spec match established reference specifications?
- Behavioural adequacy: Does the specification actually enforce the intended constraints on inputs and outputs?
Why Coverage Matters#
A striking finding emerged when the team applied a stricter similarity measurement (generalized tree edit distance, or GTED) to a subset of 32 VERINA tasks: the top-performing configuration suddenly dropped from second to fourth place in rankings. This shift demonstrates that measurement scope critically influences how we assess these systems—a broader or narrower evaluation lens can flip which approach appears superior.
The Input-Output Blind Spot#
In a particularly revealing case study, an author-written specification achieved perfect scores on output validation tests while accepting zero percent of valid inputs. The spec correctly verified what the code produced but couldn't accept correct input data—making it unusable in practice. This result underscores a key insight: . A specification that guards outputs perfectly but gates inputs wrongly is fundamentally broken, even if postcondition scores suggest otherwise.

