SpecBridge: Learning Natural-Language Formalization Plans for the Formal Specification Synthesis Task
Abstract
LLMs now generate large amounts of usable code, but formal verification can certify it only against a specification, and in practice the intended specification usually exists only as an informal natural-language comment. We study Formal Specification Synthesis: given a natural-language requirement and a fixed formal signature, synthesize a Lean specification of the intended input-output relation. Direct LLM translation makes formalization choices, such as relation shape, guard scope, and collection semantics, implicitly in one step, and often yields plausible but under-constrained specifications. We present SpecBridge, which introduces a learned intermediate representation, the Natural-Language Formalization Plan (NLFP), before Lean generation. A fixed NLFP grammar gives each formalization choice an explicit slot (e.g., soundness, coverage, and multiplicity obligations); what is learned are reusable formalization instructions in the prompts that write and read NLFPs. Learning these instructions lacks supervision in two ways. No plan annotations exist, so plans are supervised by reconstruction: reference specifications are encoded into NLFPs and decoded back by a shared decoder, so a plan is adequate only if the reference can be rebuilt from it. Equivalence between specifications is rarely provable, so SpecBridge approximates semantic similarity to the reference on testcases derived from a canonical program: validation feedback runs the specification as executable pre/post-condition checks, and verification feedback uses Lean proofs to check that it accepts correct outputs and rejects corrupted ones. On CLEVER, SpecBridge improves over few-shot + CoT by 6.1, 15.2, and 28.4 percentage points in LLM-judged specification alignment and in validation and verification pass rates, and its learned prompts transfer across LLM backends and to VERINA.
Create a lesson
Metadata
- Comments
- Accepted at NeurIPS 2026. 24 pages, 9 figures, 9 tables
Related papers
SWE-GPU-Bench: Can Language Models Solve Real-World GPU Software Engineering Tasks?
Shared title terminologycs.SEFeng Chen, Binbin Liu, Wenhan Han et al.
Managing Specification. Not code: A feasibility study of Graph -> Contract -> Code Deployment and Maintenance
Shared title terminologycs.SEHenry Yeung
Codit-Bench - Can Large Language Models Find Bugs in Code Auditing?
Shared title terminologycs.SEYuesong Feng, Zheng Zhang, Haoran Ding et al.
A Large Language Model-Based Framework for Automated Game Quest Testing
Shared title terminologycs.SEEnhong Mu, Nianyu Li, Jinyu Cai et al.
Solution or Skeleton? Distributional Alignment and Mode Switching in Code Language Models
Shared title terminologycs.SEShaojie Zhang, Yue Yu, Yu Zhang
Quantifying the Risk of Software Attacks Using Formal Verification
Shared title terminologycs.SEFlorian Lanzinger, Frederik Reiche, Felix Dörre et al.