Paper commentary
AuXSpec: Learning to Autoformalize Program Specifications via Executable Postconditions
- Problem Lean specifications are costly to write, and training a specification generator with a cheap test-based reward is hard because each test case normally becomes a theorem to prove.
- Method AUXSPEC pairs each declarative postcondition with an executable Boolean counterpart, proves they agree on valid inputs, and then uses test-case execution as the reward for reinforcement learning.
- Results AUXSPEC-27B-RL reached 65.7% SpecGen pass@1 on AUXSPEC-Test, above Claude-Opus-5 at 57.7%, and 84.5% pass@1 on Verina without test cases in the prompt.

Figure 12 . Data synthesis pipeline for AUXSPECon a running example. Stages (1) to (3) synthesize the postcondition, the executable postcondition, and the implementation under separate plans, and stage (4) assembles the components with the theorem statements.
Original paper · CC BY 4.0 · Haocheng Wang, Weixuan Yuan, Florian Hübler, Yinya Huang, Zhijiang Guo, Sorrachai Yingchareonthawornchai, Rasmus Kyng · AuXSpec: Learning to Autoformalize Program Specifications via Executable Postconditions · Original paper figure · Extracted the figure area from page 36 of the original PDF.Why specification feedback is hard to get in Lean
Writing a formal specification in an interactive theorem prover takes expertise and time, so specification becomes a bottleneck for scaling formally verified code generation. Autoformalization from natural-language programming problems could relieve that bottleneck, but it immediately raises the question of whether a generated specification captures the intended problem.
In ordinary code generation, a candidate program is run on input-output tests, and that check is cheap enough to act as a training reward. In Lean, the usual route is symbolic specification testing, which turns each test case into a theorem to prove; when the specification has unbounded quantifiers those proofs can be difficult, and unresolved cases may fall back to an LLM judge.
SMT-based verifiers in auto-active languages can check specifications against tests, but SMT solvers limit how complex a specification can be, which is why Lean is the target here.
Among the compared systems in Table 1, only AUXSPEC lists reinforcement learning in its training column; the others use SFT or no training at all. The other systems validate specifications against expert reference specifications, proofs or LLM judges, whereas AUXSPEC validates them by test execution backed by an equivalence proof.
How a split postcondition makes tests executable
Each synthesized problem is one Lean file that holds a specification, an implementation, two theorems and executable tests. The specification has three parts: a precondition that fixes valid inputs, a declarative postcondition that states what a correct output is without saying how to compute it, and an executable postcondition that expresses the same condition as a Boolean that Lean can evaluate.
The executable postcondition is found in one of two ways. When type class resolution finds a decidability instance, the declarative postcondition can be made executable through decide, and this holds for 35.5% of the synthesized problems; otherwise the executable form is written separately. The postcondition equivalence theorem is the piece that ties the two forms together, stating that they agree on valid inputs, so a separately written executable form inherits its correctness from that proof.
Once the equivalence theorem is proved, a test case can be checked by running the executable postcondition, with no separate proof for that case. Test cases are written as #guard commands that fail compilation when their expression is false, and they check the precondition, the executable postcondition and the implementation. The correctness theorem then requires the implementation to satisfy the declarative postcondition, so the executable check and the proved guarantee refer to one condition.
The four tasks are SpecGen and CodeGen, along with their repair variants SpecGen-Repair and CodeGen-Repair. A repair task receives the rejected output, its compiler errors or failed test cases as diagnostics, and the problem inputs, and it returns a revised component.
Synthesis yield and the AUXSPEC-Test benchmark
Synthesis ran over 3,109 problems and produced a complete Lean file for 3,037 of them, a yield of 97.7%. Only 34.8% of the problems passed every stage on the first attempt, and repair brought most of the remainder through within two rounds. Small test inputs cannot reveal nontermination or inefficiency, so the implementation judge rejected 19.6% of the implementations that had passed all test cases.
Proving the postcondition equivalence theorem for all 3,037 problems exposed statement errors in 31 of them, which is 1.0%, and all 31 had passed both the test layers and the judges. Nineteen of those errors sit in the declarative postcondition, a part that execution never evaluates, so the test-based checks could not catch them. After repair, the equivalence theorem is provable for the remaining 99.0% of problems as first synthesized.
Manual review of every component against the problem description found errors in 21 problems, and proof attempts on the correctness theorems found one more error, so 22 problems were corrected. The other 278 problems, which is 92.7% of the benchmark, needed no change to their definitions.
Evaluation of model outputs uses the reference component in the pairing: a generated specification is paired with the reference implementation for SpecGen, and a generated implementation with the reference specification for CodeGen. Because evaluation depends on test cases and judges rather than on matching the reference specification, a correct alternative formulation can be accepted.
Expert iteration, then RL with a graded reward
Expert iteration expands the supervised data over three rounds to 19.5K samples, and each round fine-tunes Qwen3.8-27B from the base model on everything accumulated so far. Only outputs that meet the acceptance criteria enter the accumulated set, and the same samples fine-tune Qwen3.5-9B, which gives AUXSPEC-9B-SFT and AUXSPEC-27B-SFT. Further problems come from Codeforces, AtCoder, Aizu, CodeChef and GeeksforGeeks through TACO and open-r1/codeforces.
RL then runs for one epoch on 13,637 SpecGen and CodeGen tasks drawn from 8,579 problems that are disjoint from the SFT data and from AUXSPEC-Test.
Each rollout receives a six-stage progressive reward that follows the acceptance order: format 0, compilation 0.1, test execution 0.2, test case alignment 0.1, non-tautology 0.1 and overall quality 0.4, with full success giving 1. A rollout that fails at stage k receives that stage's value v_k, so the reward has the form \[ r(y)=\begin{cases} 1 & \text{if } y \text{ passes all stages} \\ v_k & \text{if } k \text{ is the first stage that } y \text{ fails} \end{cases} \]
The non-tautology value is set at 0.1 so that specifications which restate the computation rank below specifications that fail the tests on the problem itself. Enumerative specifications and correct but slow implementations pass all stages yet receive 0.4 and 0.5, because the evaluation accepts them.
The policy update extends DAPO, and it normalizes advantages by the standard deviation over the batch rather than over each group. Each token of rollout i carries a mask m_{i,t} in {0,1} that multiplies its clipped surrogate ℓ_{i,t}, and the objective is \( J(\theta)=\mathbb{E}\!\left[\frac{\sum_{i,t} m_{i,t}\,\ell_{i,t}(\theta)}{\sum_{i,t} m_{i,t}}\right] \), which reduces to the original algorithm when every mask is 1 and the normalization is by group.
In-domain results on AUXSPEC-Test
AUXSPEC-27B-RL reaches 65.7% SpecGen pass@1, above Claude-Opus-5 at 57.7%, which is the strongest frontier model in that comparison. AUXSPEC-9B-RL reaches 58.6% SpecGen pass@1, which also exceeds every frontier model on that metric.
To check false positives in SpecGen acceptance, the postcondition equivalence theorem was proved for 99.2% of accepted RL outputs. Expert review of 90 of 100 sampled outputs confirmed them, and the errors that did appear all lay in the validity predicate.
Out-of-domain results on Verina
With the default prompt that has no test cases, AUXSPEC-9B-RL reaches 73.7% SpecGen pass@1 and AUXSPEC-27B-RL reaches 84.5%, against 47.6% reported for VeriSpecGen-30B-A3B in the original paper. The pass@4 comparison is not like for like: VeriSpecGen-30B-A3B reaches 63.9% at pass@10 in its original paper, whereas the two RL models reach 90.5% at pass@4 without test cases.
On CodeGen with test cases in the prompt, the 9B RL model reaches 92.6% pass@1 and the 27B RL model 91.8%, against 56.6% for the best baseline in that column.
What the progressive reward changes during training
Under a binary reward, every group without a passing rollout has equal zero rewards, so dynamic sampling would discard it.
The stage values were checked by replaying the training rollouts with one value changed and recording the advantage of each stage. At 0.1, a failed test case alignment has a positive advantage for only 0.8% of SpecGen-Repair rollouts, whereas at 0.2 it has one for 58.3% of them.
The share of slow programs among correct CodeGen rollouts of the 27B model rose to 67.4% early in training and fell to 0.4% at the end, while the 9B model ended with 30.4%. Enumerative specifications for the 27B model fell from 17.0% to 2.8% of otherwise accepted specifications. In SpecGen, 29% to 52% of groups remained without a passing rollout in each period, so hard problems kept supplying a learning signal throughout training.
Does RL widen the set of solved problems?
At large k, a model whose gains come only from sharpening its sampling distribution should catch up with the RL model, so the comparison at large k separates the two cases.
The RL model stays above the SFT model at every k, and the gap narrows from 13.0 to 10.6 points between k=128 and k=256 as the RL model approaches the ceiling. Within 256 samples, 33 problems of AUXSPEC-Test are solved only by the RL model, 1 only by the SFT model, 256 by both and 10 by neither. Per solved SpecGen sample, the RL model uses 20.3% of the output tokens of the most economical frontier model.
Refinement on ICPC-Eval and general capabilities
On ICPC-Eval, a benchmark of problems from 11 recent ICPC contests, AUXSPEC-27B-RL solves 82.7% of problems with refine@16, above its 61.3% with pass@16. Refinement here uses compiler and judge feedback at test time, and this comparison covers one model on one benchmark.
AUXSPEC-9B-RL surpasses its backbone on both code benchmarks.
Limitations
Expert review of AUXSPEC-Test was carried out by one author, and two authors reviewed the accepted outputs. The expert review of accepted RL outputs covered 100 sampled outputs rather than all of them.
The VeriSpecGen figures are numbers reported in the original paper, scored by the Verina evaluator, because those models are not publicly available. The VeriSpecGen pass@4 values are listed at pass@10, and the table has no VeriSpecGen entries for the prompt with test cases.
Specification evaluation in this study uses AUXSPEC-Test, Verina and the ICPC-Eval refinement setting.
Paper info
- Authors
- Haocheng Wang, Weixuan Yuan, Florian Hübler, Yinya Huang, Zhijiang Guo, Sorrachai Yingchareonthawornchai, Rasmus Kyng
- Venue
- arXiv · Preprint
- First published
- 2026-11-16
- Added
- 2026-11-18
- Updated
- 2026-11-16
- Version
- v1
- arXiv
- 2611.21421
- Category
- cs.SE · cs.CL
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
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
Quote from the paper
Haocheng Wang, Weixuan Yuan, Florian Hübler, Yinya Huang, Zhijiang Guo, Sorrachai Yingchareonthawornchai, Rasmus Kyng (2026). AuXSpec: Learning to Autoformalize Program Specifications via Executable Postconditions. arXiv:2611.21421v1. https://arxiv.org/abs/2611.21421v1
BibTeX
@misc{wang2026auxspec,
title = {{AuXSpec: Learning to Autoformalize Program Specifications via Executable Postconditions}},
author = {Haocheng Wang and Weixuan Yuan and Florian Hübler and Yinya Huang and Zhijiang Guo and Sorrachai Yingchareonthawornchai and Rasmus Kyng},
year = {2026},
eprint = {2611.21421},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.21421v1}
}