SpecBridge: Learning Natural-Language Formalization Plans for the Formal Specification Synthesis Task
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,…
- arXiv
- 2612.01482
- Authors
- Wenjie Zhang, Yun Lin, Zining He, Meiqi Wu, Jin Song Dong
- Categories
- cs.SE