← All papers
First page of SpecBridge: Learning Natural-Language Formalization Plans for the Formal Specification Synthesis Task

SpecBridge: Learning Natural-Language Formalization Plans for the Formal Specification Synthesis Task

Wenjie Zhang, Yun Lin, Zining He, Meiqi Wu, Jin Song Dong

cs.SE Dec 1, 2026 · v1
LLM pipeline synthesizes Lean specifications from natural-language requirements, using Lean compilation and Lean proof obligations as feedback; evaluated on CLEVER and VERINA.
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.

Formal verification certifies code only against a specification, but intended specifications usually exist only as informal natural-language comments. Direct LLM translation into Lean makes formalization choices implicitly and often yields plausible but under-constrained specifications.

SpecBridge inserts a learned intermediate representation, the Natural-Language Formalization Plan (NLFP), with explicit grammar slots for choices such as soundness, coverage, and multiplicity obligations. Prompts that write and read NLFPs are learned without plan annotations, using reconstruction: reference Lean specs are encoded into NLFPs and decoded back by a shared decoder. Refinement feedback comes from running specs as executable pre/post-condition checks and from Lean proofs that the spec accepts correct outputs and rejects corrupted ones. At deployment, Lean compilation errors are returned to the decoder for repair.

On CLEVER, SpecBridge improves over few-shot + CoT by 6.1, 15.2, and 28.4 percentage points in LLM-judged alignment, validation pass rate, and verification pass rate. Verification pass rate rises from 58.2% to 86.6%. Learned prompts transfer across LLM backends and to VERINA.