AuXSpec / README.md
hcWang942's picture
Add the arXiv paper and the final author list
4e6c529 verified
|
Raw History Blame Contribute Delete
6.44 kB
metadata
license: apache-2.0
language:
  - en
task_categories:
  - text-generation
tags:
  - specification-generation
  - code-generation
  - lean4
  - autoformalization
  - formal-verification
size_categories:
  - 1K<n<10K
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train.jsonl
      - split: test
        path: data/test.jsonl

AuXSpec

AuXSpec: Learning to Autoformalize Program Specifications via Executable Postconditions

Haocheng Wang2,1,*, Weixuan Yuan1,*, Florian Hübler1, Yinya Huang1,4, Zhijiang Guo2,3, Sorrachai Yingchareonthawornchai5, Rasmus Kyng1,†

1 Department of Computer Science, ETH Zurich   2 HKUST(GZ)   3 HKUST   4 ETH AI Center   5 Institute for Theoretical Studies, ETH Zurich

* Equal contribution.   † Corresponding author.

Paper | Website | Collection | License | Citation

1. Introduction

AuXSpec is a Lean framework that pairs each declarative postcondition with an executable postcondition, so that test cases evaluate a declarative specification by execution. This dataset releases the 3,037 LeetCode problems synthesized by the AuXSpec pipeline, each with a Lean 4 specification, a reference implementation and a proved postcondition equivalence theorem. The 300 problems of the test split form AuXSpec-Test, the in-domain benchmark of the paper, and also carry a proved correctness theorem for the reference implementation.

Each problem comes as one Lean file with these parts:

  • Precondition (V): isValidInput, a Boolean predicate that accepts exactly the inputs satisfying the stated constraints.
  • Postcondition (P_spec): <name>_spec, a declarative proposition that characterizes the correct output.
  • Executable postcondition (P_check): <name>_check, a Boolean function that decides the postcondition on valid inputs.
  • Equivalence theorem: <name>_check_iff_spec, which states that on valid inputs the executable postcondition is equivalent to the postcondition.
  • Implementation: a total algorithm, and the correctness theorem <impl>_correct, which states that on valid inputs the implementation satisfies the postcondition.
  • Unit tests: #guard lines that the Lean kernel evaluates, in four layers. L1 and L1b check that the precondition accepts the valid inputs and rejects the invalid ones, L2 and L2b check that the executable postcondition accepts the correct outputs and rejects the wrong ones, L3 checks the implementation on the valid inputs, and L4 checks that the executable postcondition accepts the outputs of the implementation.

2. Dataset Summary

Split Problems Easy / Medium / Hard Equivalence theorem proved Correctness theorem proved
train 2,737 642 / 1,433 / 662 2,737 –
test (AuXSpec-Test) 300 72 / 155 / 73 298 300
  • The problems were synthesized by the AuXSpec pipeline, in which every stage is admitted by the Lean compiler, the test cases and a set of LLM judges. The train problems are part of the SFT data of the AuXSpec models.
  • The test problems were held out from both SFT and RL. Every reference specification, implementation and test case was checked by hand against the problem statement.
  • For two test problems, closest-binary-search-tree-value and soup-servings, the hand check replaced Float by Rat in the specification, and the equivalence theorem of the revised statement is left as sorry.
  • Every file of every field compiles under Lean 4.32.0 with Mathlib. In lean.proved, #print axioms of each proved theorem lists no sorryAx.

3. Data Fields

Field Content
problem_id LeetCode problem slug
split train or test
problem The problem as given: description, constraints, examples and signature (parameter names and types)
test_cases The 9 test cases of the problem: 3 valid inputs with their outputs (valid), 3 invalid inputs (invalid_input) and 3 wrong outputs (wrong_output); each invalid input and wrong output carries the reason it was constructed (rationale)
spec The SpecGen answer: a complete Lean file with the precondition, the postcondition, the executable postcondition, the equivalence theorem left as sorry, and the guards of layers L1, L1b, L2 and L2b
impl The CodeGen answer: a complete Lean file with the specification definitions the implementation calls, the implementation and the guards of layer L3
lean.statement The full Lean file with both theorems left as sorry
lean.proved The same file with the proofs filled in, including the helper lemmas the proofs need
meta title, difficulty (easy, medium or hard) and leetcode_id

lean.statement and lean.proved differ only in the proofs, so a diff of the two shows exactly what the proofs add.

4. Usage

from datasets import load_dataset

ds = load_dataset("eth-algopt/AuXSpec")
row = ds["test"][0]
print(row["problem"]["description"])
print(row["lean"]["proved"])

Each Lean file begins with import Mathlib and compiles in a Lean 4.32.0 project with Mathlib, for example with lake env lean <file>.lean.

5. Limitations

  • The equivalence theorem relates the two postconditions to each other. Whether the postcondition is faithful to the natural-language problem rests on the test cases, the LLM judges and, for the test split, the hand check.
  • The correctness theorem is proved only for the test split.

6. License

This dataset is released under the Apache 2.0 License.

7. Citation

@misc{auxspec2026,
  title  = {AuXSpec: Learning to Autoformalize Program Specifications via Executable Postconditions},
  author = {Haocheng Wang and Weixuan Yuan and Florian H{\"u}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.21421}
}