NTH

AuXSpec: Learning to Autoformalize Program Specifications via Executable Postconditions

AuthorsHaocheng Wang, Weixuan Yuan, Florian Hübler, Yinya Huang, Zhijiang Guo, Sorrachai Yingchareonthawornchai, Rasmus Kyng

AffiliationsHKUST(GZ) · Department of Computer Science, ETH Zurich · ETH AI Center · HKUST · Institute for Theoretical Studies, ETH Zurich

November 26, 2026 2 min read
Watch on YouTube
The one-line take

AuXSpec uses executable tests to train AI models to write formal program specifications more accurately.

Key results

3037
Synthesized LeetCode problems

Problems released with specifications, implementations, tests, and equivalence proofs.

19.5K
SFT training samples

Samples assembled through synthesis and expert iteration.

300
AU XS PEC-Test problems

Expert-reviewed held-out benchmark size.

84.3%
27B AU XS PEC-Test SpecGen pass@4

Qwen3.8-27B after training, versus 14.3% for its base model.

90.5%
Verina SpecGen pass@4

Both RL models achieve this score using Verina’s original prompts.

84.5%
Verina pass@1 versus VeriSpecGen

27B model score, compared with VeriSpecGen’s 47.6%.

What the paper found

AuXSpec makes Lean 4 specification generation trainable with direct execution feedback. It pairs a declarative postcondition with an executable Boolean checker: Lean derives the checker through type-class resolution when possible, and otherwise a separately written checker is linked to the specification by an equivalence theorem. Test cases can then reward reinforcement learning without requiring a proof for each test. The team synthesized 3037 LeetCode problems, expanded training through expert iteration to 19.5K samples, and evaluated on the 300-problem AU XS PEC-Test benchmark. Fine-tuning Qwen3.5-9B and Qwen3.8-27B with a staged execution-based reward raises SpecGen pass@4 to 82.7% and 84.3%, respectively, from 0.7% and 14.3% for the base models. On the out-of-domain Verina benchmark, both models reach 90.5% pass@4; their pass@1 scores of 73.7% and 84.5% exceed VeriSpecGen’s 47.6%. The 27B model also beats evaluated frontier systems including Claude Opus 5, OpenAI GPT-5.6, and DeepSeek V4 on in-domain SpecGen pass@4. A key caveat: the equivalence theorem establishes that the checker matches the declarative specification, not that either faithfully captures the original problem, so test cases, judges, and review remain necessary.

Original abstract

Formal specifications define intended program behavior and underpin verification, but writing them in theorem provers such as Lean is slow and expertise-intensive, making specification a major bottleneck to scaling formally correct code. Autoformalization from natural-language problems is promising, yet training specification models requires scalable feedback on whether generated specifications capture intended behavior. Prior approaches obtain this feedback through explicit proofs or separately implemented code with formal correspondence proofs, both expensive. We introduce AuXSpec, a Lean framework that pairs declarative postconditions with executable counterparts, obtained through type class resolution when possible and otherwise defined separately with an equivalence proof. Test cases can then evaluate declarative specifications by execution, letting us use agreement as a reinforcement-learning reward. Using AuXSpec, we synthesize 3,037 LeetCode problems and expand training to 19.5K samples through expert iteration on Codeforces. Experiments show that training Qwen3.5-9B and Qwen3.8-27B with the execution-based reward improves SpecGen pass@4 on AuXSpec-Test 0.7% $\to$ 82.7% and 14.3% $\to$ 84.3%, and the 27B model outperforms all frontier models. On the out-of-domain Verina benchmark with its original prompts, both models improve 7.0% $\to$ 90.5% and 21.9% $\to$ 90.5% and surpass VeriSpecGen-30B-A3B, the prior state of the art among open-source specification models, on pass@1 (theirs 47.6% vs. ours 73.7% and 84.5%) and pass@4 (theirs 63.9% at pass@10 vs. ours 90.5%). We release the weights of the trained 9B and 27B models and the 3,037 problems with test cases, including the 300-problem AuXSpec-Test benchmark with expert review and correctness proofs for future evaluation. Models and data: https://huggingface.co/collections/eth-algopt/auxspec. Website: https://auxspec.org

Read the original paper

More in Code Generation

Browse all 55 papers →
01Code Generation

Evaluation-Free Recursive Self-Improvement for Coding Agents

Zhe Ren, Guowei Rong, Yimeng Chen, Nanbo Li, Piotr Piękos, Mateusz Ostaszewski, Dandan Guo, Jürgen Schmidhuber

ELITE helps coding agents improve by combining promising implementation ideas without repeatedly testing candidates on downstream coding tasks.

Read analysis
03Code Generation

CompoundingKernel: Self-Improving from Zero to First

Qian Qu, Hongyang Wang, Wenbo Chen, Yichuan Li, Jingguo Liu, Xian Li, Xuan Wang, Ruochen Wen, Leo Fan, Yiming Yan, Zheshen Wang, Benoit Dumoulin

CompoundingKernel uses parallel agents and an archive of successful attempts to discover fast, correct GPU kernels.

Read analysis