Debargha commited on
Commit
1c6aa6f
·
0 Parent(s):

LeetCode Rust-to-Lean: 2,126 programs and 24,617 theorems

Browse files
.gitattributes ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.avro filter=lfs diff=lfs merge=lfs -text
4
+ *.bin filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
7
+ *.ftz filter=lfs diff=lfs merge=lfs -text
8
+ *.gz filter=lfs diff=lfs merge=lfs -text
9
+ *.h5 filter=lfs diff=lfs merge=lfs -text
10
+ *.joblib filter=lfs diff=lfs merge=lfs -text
11
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
13
+ *.mds filter=lfs diff=lfs merge=lfs -text
14
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
+ *.model filter=lfs diff=lfs merge=lfs -text
16
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
17
+ *.npy filter=lfs diff=lfs merge=lfs -text
18
+ *.npz filter=lfs diff=lfs merge=lfs -text
19
+ *.onnx filter=lfs diff=lfs merge=lfs -text
20
+ *.ot filter=lfs diff=lfs merge=lfs -text
21
+ *.parquet filter=lfs diff=lfs merge=lfs -text
22
+ *.pb filter=lfs diff=lfs merge=lfs -text
23
+ *.pickle filter=lfs diff=lfs merge=lfs -text
24
+ *.pkl filter=lfs diff=lfs merge=lfs -text
25
+ *.pt filter=lfs diff=lfs merge=lfs -text
26
+ *.pth filter=lfs diff=lfs merge=lfs -text
27
+ *.rar filter=lfs diff=lfs merge=lfs -text
28
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
29
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
31
+ *.tar filter=lfs diff=lfs merge=lfs -text
32
+ *.tflite filter=lfs diff=lfs merge=lfs -text
33
+ *.tgz filter=lfs diff=lfs merge=lfs -text
34
+ *.wasm filter=lfs diff=lfs merge=lfs -text
35
+ *.xz filter=lfs diff=lfs merge=lfs -text
36
+ *.zip filter=lfs diff=lfs merge=lfs -text
37
+ *.zst filter=lfs diff=lfs merge=lfs -text
38
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
39
+ # Audio files - uncompressed
40
+ *.pcm filter=lfs diff=lfs merge=lfs -text
41
+ *.sam filter=lfs diff=lfs merge=lfs -text
42
+ *.raw filter=lfs diff=lfs merge=lfs -text
43
+ # Audio files - compressed
44
+ *.aac filter=lfs diff=lfs merge=lfs -text
45
+ *.flac filter=lfs diff=lfs merge=lfs -text
46
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
47
+ *.ogg filter=lfs diff=lfs merge=lfs -text
48
+ *.wav filter=lfs diff=lfs merge=lfs -text
49
+ # Image files - uncompressed
50
+ *.bmp filter=lfs diff=lfs merge=lfs -text
51
+ *.gif filter=lfs diff=lfs merge=lfs -text
52
+ *.png filter=lfs diff=lfs merge=lfs -text
53
+ *.tiff filter=lfs diff=lfs merge=lfs -text
54
+ # Image files - compressed
55
+ *.jpg filter=lfs diff=lfs merge=lfs -text
56
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
57
+ *.webp filter=lfs diff=lfs merge=lfs -text
58
+ # Video files - compressed
59
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
60
+ *.webm filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Debargha Ganguly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md ADDED
@@ -0,0 +1,447 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ pretty_name: LeetCode Rust-to-Lean (unofficial)
4
+ language:
5
+ - en
6
+ task_categories:
7
+ - text-generation
8
+ tags:
9
+ - code
10
+ - rust
11
+ - lean4
12
+ - formal-verification
13
+ - theorem-proving
14
+ - autoformalization
15
+ - aeneas
16
+ size_categories:
17
+ - 10K<n<100K
18
+ configs:
19
+ - config_name: programs
20
+ default: true
21
+ data_files:
22
+ - split: train
23
+ path: data/programs/train.parquet
24
+ - split: test
25
+ path: data/programs/test.parquet
26
+ - config_name: specs
27
+ data_files:
28
+ - split: train
29
+ path: data/specs/train.parquet
30
+ - split: test
31
+ path: data/specs/test.parquet
32
+ ---
33
+
34
+ # LeetCode Rust-to-Lean (unofficial)
35
+
36
+ > Unofficial. This dataset is an independent reproduction of the methodology of
37
+ > [*Scaling Lean Theorem Proving for Real-World Code Verification*](https://arxiv.org/abs/2610.38174),
38
+ > made by the paper's first author. It is not an official release of the paper.
39
+ > If you use it, please cite the paper (BibTeX at the bottom).
40
+
41
+ Theorem provers are now very good at competition mathematics, and the benchmarks for it are
42
+ close to saturated. Proving that real code is correct is a different and much harder problem,
43
+ and it is the one that matters for software. This dataset applies the methodology of the paper
44
+ above from scratch and contributes 24,617 new theorems about real code for the community to
45
+ prove.
46
+
47
+ It contains 2,126 programs and 24,617 theorems about them:
48
+
49
+ 1. Each program is a Rust solution to a LeetCode problem that passes every test case of the
50
+ problem, together with its translation to Lean 4 by the [Aeneas](https://github.com/AeneasVerif/aeneas)
51
+ tool. The Lean code is the program itself, with machine integers, overflow checks, loops and
52
+ panics, not a clean mathematical model of it. The translation was run on test cases and
53
+ reproduces the Rust program's answers.
54
+ 2. Each theorem states one property of one of these programs, in natural language and in
55
+ Lean 4: functional correctness, absence of failure, bounds, edge cases, relations between
56
+ inputs and outputs, and more. Each program's theorems include one main theorem, which
57
+ relates its result to the answer the problem asks for.
58
+
59
+ The task is to prove the theorems. The release contains the statements only; the proofs are open.
60
+
61
+ ## What it is for
62
+
63
+ - Benchmarking provers on code. Every theorem is a self-contained, mechanically checked task.
64
+ - Reinforcement learning. A proof is accepted or rejected by Lean's kernel, so every theorem is
65
+ a reward signal that cannot be gamed by a judge model.
66
+ - Autoformalization. Every theorem comes in natural language and in Lean, against the same
67
+ program: 24,617 aligned pairs for learning to turn a specification into a formal statement.
68
+ - Verified code generation. Every program comes with its problem, its test cases, its Lean
69
+ translation and the full record of how it was written.
70
+
71
+ ## The task
72
+
73
+ You are given one program (its Lean translation) and one theorem about it, stated in Lean with
74
+ `sorry` as its proof. Prove the theorem, or prove its negation. Every theorem comes with its
75
+ negation already stated (`lean_negation`), so a refutation always targets the same statement.
76
+
77
+ A solution is a copy of the program's specification file (`lean_specs`) in which that one
78
+ theorem (or its negation) has a proof. You may add any definitions and lemmas you need before
79
+ it, and you may add imports from the same Lean, Mathlib and Aeneas versions. You may not change
80
+ the statement. The proof must not use `sorry`, and it may only use the standard axioms
81
+ `propext`, `Quot.sound` and `Classical.choice`. This rules out `native_decide`, which adds an
82
+ axiom of its own.
83
+
84
+ The check is mechanical. Lean's built-in `lake comparator` compares the solution with the
85
+ original statement, checks the axioms, and replays the proof in the Lean kernel (see "Checking a
86
+ proof" below). Nothing is graded by hand or by a model.
87
+
88
+ ## An example
89
+
90
+ LeetCode 633, `sum-of-square-numbers`: given `c`, decide whether `c = a² + b²` for some integers
91
+ `a` and `b`. The Rust program:
92
+
93
+ ```rust
94
+ pub fn judge_square_sum(c: i64) -> bool {
95
+ let mut b: i64 = 0;
96
+ while (b + 1) * (b + 1) <= c {
97
+ b += 1;
98
+ }
99
+ let mut a: i64 = 0;
100
+ while a <= b {
101
+ let sum = a * a + b * b;
102
+ if sum == c {
103
+ return true;
104
+ }
105
+ if sum < c {
106
+ a += 1;
107
+ } else {
108
+ b -= 1;
109
+ }
110
+ }
111
+ false
112
+ }
113
+ ```
114
+
115
+ Its main theorem, `spec_1`, and the theorem that it never fails, `spec_2`:
116
+
117
+ ```lean
118
+ /-- Whenever judge_square_sum(c) returns a result r, r = true if and only if there exist integers a and b such that a*a + b*b = c.
119
+ Preconditions: c is an integer with 0 <= c <= 2147483647 (2^31 - 1). -/
120
+ theorem spec_1 (c : Std.I64) (r : Bool)
121
+ (hc0 : 0 ≤ c.val) (hc1 : c.val ≤ 2147483647)
122
+ (hr : judge_square_sum c = ok r) :
123
+ (r = true ↔ ∃ a b : ℤ, a * a + b * b = c.val) := by
124
+ sorry
125
+
126
+ /-- The function judge_square_sum(c) returns a result r; it does not fail, panic, or overflow.
127
+ Preconditions: c is an integer with 0 <= c <= 2147483647 (2^31 - 1). -/
128
+ theorem spec_2 (c : Std.I64)
129
+ (hc0 : 0 ≤ c.val) (hc1 : c.val ≤ 2147483647) :
130
+ ∃ r : Bool, judge_square_sum c = ok r := by
131
+ sorry
132
+ ```
133
+
134
+ Together the two say that the program always returns, and that what it returns is the right
135
+ answer. Neither says anything about how the program works. To prove `spec_1` you need an
136
+ invariant for the two-pointer loop: it never skips a pair `(a, b)` that could sum to `c`. To
137
+ prove `spec_2` you need to show that both loops terminate and that `(b + 1) * (b + 1)` and
138
+ `a * a + b * b` never overflow 64 bits for any `c` in the range. The program has 6 more
139
+ theorems, about witnesses, invariance and the relation between inputs and outputs.
140
+
141
+ ## Why this is hard
142
+
143
+ The Lean code is a faithful model of the Rust program, so a proof has to deal with everything
144
+ the program does:
145
+
146
+ - Integers are 64-bit machine integers. Every `+`, `*` and `-` can overflow, and the proof
147
+ must show it does not.
148
+ - Every operation that can panic in Rust (overflow, index out of bounds, division by zero)
149
+ returns a `Result` in Lean, and the proof must rule the failure out or reason about it.
150
+ - Loops become recursive functions. Each one needs an invariant and a termination argument.
151
+ - Vectors are lists, mutation becomes passing updated copies, and the code is written for
152
+ execution, not for proofs.
153
+ - The theorems are stated against the problem, not the code. The main theorems relate the
154
+ program to a mathematical definition of the answer (a maximum over all subsets, the existence
155
+ of a valid ordering, the least number of insertions that makes a string a palindrome), so a
156
+ proof must connect the algorithm to that definition.
157
+
158
+ The paper that introduced this methodology found that tasks of this kind stay hard even for
159
+ provers that nearly saturate competition benchmarks. For a sense of scale here: a machine-found
160
+ proof of the main theorem of
161
+ `maximum-tastiness-of-candy-basket`, a Medium problem solved by binary search with a greedy
162
+ check, is about 1,000 lines of Lean with 44 lemmas and definitions.
163
+
164
+ ## Quick start
165
+
166
+ ```python
167
+ from datasets import load_dataset
168
+
169
+ programs = load_dataset("Debargha/leetcode-rust-lean", "programs")
170
+ specs = load_dataset("Debargha/leetcode-rust-lean", "specs")
171
+
172
+ s = specs["test"][0]
173
+ print(s["task_id"], s["theorem"]) # e.g. shortest-distance-after-road-addition-queries-i AegisSpec.ShortestDistanceAfterQueries.spec_1
174
+ print(s["statement"]) # the property in natural language
175
+ print(s["lean_statement"]) # the same property in Lean
176
+
177
+ p = programs["test"].filter(lambda r: r["task_id"] == s["task_id"])[0]
178
+ print(p["lean_specs"]) # the Lean file with every theorem of this program
179
+ ```
180
+
181
+ ## The two subsets
182
+
183
+ `programs` has one row per program. `specs` has one row per theorem. They join on `task_id`.
184
+
185
+ ### `programs`
186
+
187
+ | Column | What it is |
188
+ |---|---|
189
+ | `task_id`, `question_id` | LeetCode slug and number, e.g. `running-sum-of-1d-array`, `1480` |
190
+ | `difficulty` | `Easy`, `Medium` or `Hard` |
191
+ | `tags` | LeetCode topic tags |
192
+ | `description` | the problem statement |
193
+ | `leetcode_signature` | the original (Python-style) signature, e.g. `runningSum(nums: list_int) -> list_int` |
194
+ | `rust_signature` | the Rust signature the solution implements, e.g. `pub fn running_sum(nums: &[i64]) -> Vec<i64>` |
195
+ | `rust_solution` | the Rust program (safe Rust only; see "The Rust subset") |
196
+ | `lean_function` | full Lean name of the translated function, e.g. `Aegis.RunningSum.running_sum` |
197
+ | `lean_types` | Lean type definitions produced by Aeneas (`Types.lean`) |
198
+ | `lean_funs` | Lean function definitions produced by Aeneas (`Funs.lean`). This is the main Lean file. |
199
+ | `lean_funs_external` | Lean models of Rust library functions Aeneas cannot translate itself (e.g. `Vec::pop`, `sort`). Empty for most rows (non-empty for 168). |
200
+ | `lean_specs` | the Lean file stating this program's theorems (see below) |
201
+ | `num_specs` | number of theorems in `lean_specs` |
202
+ | `lean_eval` | a Lean file that runs the Lean function on test cases and prints `CASE <i> true/false` |
203
+ | `test_cases` | all test cases: list of `{input, output}` (JSON strings), sorted from smallest to largest input |
204
+ | `num_test_cases` | how many test cases (3 to 450, median 97) |
205
+ | `order_insensitive` | `true` if the problem says "return the answer in any order". Then outputs were compared as multisets (64 rows). |
206
+ | `rust_cases_passed` | test cases the Rust passes. Always equal to `num_test_cases`. |
207
+ | `lean_check` | result of running the Lean translation on the 10 smallest test cases: `verified` or `verified_partial` (see "How the programs were checked") |
208
+ | `lean_check_cases`, `lean_check_cases_true` | how many cases that check used, and how many the Lean reproduced |
209
+ | `num_llm_calls` | how many times the model was called to write this program (1 for 1,801 rows) |
210
+ | `total_completion_tokens` | total tokens the model generated for it, reasoning included |
211
+ | `trajectory` | the full history of how the program was written; see "The trajectory" |
212
+
213
+ ### `specs`
214
+
215
+ | Column | What it is |
216
+ |---|---|
217
+ | `task_id` | the program this theorem is about |
218
+ | `spec_id` | `n` in `spec_n`, numbered in file order |
219
+ | `theorem` | full Lean name, e.g. `AegisSpec.JudgeSquareSum.spec_1` |
220
+ | `main` | `true` for the program's main theorem (exactly one per program) |
221
+ | `category` | what kind of property it is (table below) |
222
+ | `statement` | the property in natural language |
223
+ | `preconditions` | the assumptions on the inputs, in natural language (usually the problem's constraints) |
224
+ | `lean_statement` | the theorem in Lean, exactly as in `lean_specs` |
225
+ | `lean_negation` | its negation, `theorem spec_n_neg : ¬ (∀ ..., ...)`, to prove if the theorem is false |
226
+ | `difficulty` | difficulty of the problem |
227
+
228
+ | `category` | Theorems | 24,617 (train 22,557 / test 2,060), on 2,124 programs |
229
+ |---|---|---|
230
+ | `relational` | 4,683 | how the output relates to the input or to itself (e.g. the output is a permutation of the input) |
231
+ | `edge` | 4,429 | behaviour on special inputs (empty, single element, all equal, ...) |
232
+ | `bounds` | 4,102 | the output lies in a range |
233
+ | `invariance` | 3,015 | the output does not change under some change of the input (reversal, relabelling, ...) |
234
+ | `functional` | 2,904 | the output is exactly a mathematically defined answer. All main theorems are here. |
235
+ | `witness` | 2,140 | the output is achieved by some explicit object (a subset, a path, an index) |
236
+ | `no_failure` | 2,100 | the program returns a result: no overflow, no out-of-bounds access, no panic |
237
+ | `shape` | 1,183 | length, sortedness or structure of the output |
238
+ | `monotonicity` | 61 | the output grows or shrinks with the input |
239
+
240
+ ### The Lean specification file
241
+
242
+ `lean_specs` is a complete Lean file. It imports the program (`import Aegis.<Problem>.Code.Funs`),
243
+ defines the helper notions the theorems need, and states every theorem of the program inside
244
+ `namespace AegisSpec.<Problem>`, each with its natural-language statement as its docstring and
245
+ `sorry` as its proof. Some files also contain small helper lemmas with complete proofs. Every
246
+ file in the dataset builds, and so does every theorem's negation.
247
+
248
+ As in all Aeneas-based verification, the theorems are about the Lean translation of the program,
249
+ with the definitions in `lean_funs_external` taken as given.
250
+
251
+ ## Checking a proof
252
+
253
+ Lay out a Lake project like this (`<Problem>` is the second component of `lean_function`):
254
+
255
+ ```
256
+ lakefile.toml
257
+ lean-toolchain leanprover/lean4:v4.36.0
258
+ config.json
259
+ Aegis/<Problem>/Code/Types.lean lean_types
260
+ Aegis/<Problem>/Code/Funs.lean lean_funs
261
+ Aegis/<Problem>/Code/FunsExternal.lean lean_funs_external (only if non-empty)
262
+ Proofs/Challenge.lean lean_specs, unchanged
263
+ Proofs/Solution.lean your copy of lean_specs, with the proof
264
+ ```
265
+
266
+ `lakefile.toml`:
267
+
268
+ ```toml
269
+ name = "aegis"
270
+
271
+ [[lean_lib]]
272
+ name = "Aegis"
273
+ globs = ["Aegis.+"]
274
+
275
+ [[lean_lib]]
276
+ name = "Proofs"
277
+ globs = ["Proofs.+"]
278
+
279
+ [[require]]
280
+ name = "aeneas"
281
+ git = "https://github.com/AeneasVerif/aeneas.git"
282
+ rev = "0c19cd5bff9298565362c6ca9c4f48a29033a0e9"
283
+ subDir = "backends/lean"
284
+ ```
285
+
286
+ `config.json`, naming the theorem you proved:
287
+
288
+ ```json
289
+ {
290
+ "challenge_module": "Proofs.Challenge",
291
+ "solution_module": "Proofs.Solution",
292
+ "theorem_names": ["AegisSpec.JudgeSquareSum.spec_2"],
293
+ "permitted_axioms": ["propext", "Quot.sound", "Classical.choice"]
294
+ }
295
+ ```
296
+
297
+ Then:
298
+
299
+ ```bash
300
+ lake update && lake exe cache get # fetch Aeneas and Mathlib, download the Mathlib cache
301
+ lake build Proofs.Challenge Proofs.Solution
302
+ lake comparator --config config.json # needs bwrap (Bubblewrap) on PATH
303
+ ```
304
+
305
+ The last command prints `Your solution is okay!` when the proof is accepted. To refute a theorem
306
+ instead, add its `lean_negation` right after the theorem in both files, prove it in
307
+ `Solution.lean`, and name `spec_n_neg` in `config.json`. Several theorems of the same
308
+ program can be checked at once by listing them all in `theorem_names`.
309
+
310
+ ### How the theorems were written
311
+
312
+ The theorems were written the way the paper describes, in three steps:
313
+
314
+ 1. A model wrote 5 to 20 properties per program in natural language, from the problem
315
+ statement, the function signature and examples, but not from the code. The properties
316
+ describe what the program should do, not what it happens to do.
317
+ 2. A second, independent review pass checked every property, fixed or removed unclear and
318
+ redundant ones, and added the ones that were missing.
319
+ 3. A Lean agent stated each property as a Lean theorem about the extracted program.
320
+
321
+ Every resulting file was then checked mechanically: it builds from scratch, every property has
322
+ its theorem, every theorem's negation elaborates, the only `sorry`s are the theorem proofs, and
323
+ every theorem constrains the program's actual behaviour (statements that never mention the
324
+ program or never use its result were removed). The model is DeepSeek-V4.1-Flash throughout.
325
+
326
+ The theorems were fixed before any proof was attempted. A theorem that claims more than the
327
+ program guarantees is solved by proving its negation.
328
+
329
+ ## Evaluating a prover
330
+
331
+ We suggest reporting results on the `test` split: 2,060 theorems about 175 programs. Report
332
+ the fraction of theorems solved (a proof of the theorem or of its negation), overall and for the
333
+ main theorems, by difficulty and by category, together with the attempt and time budget per
334
+ theorem. The paper uses 30 minutes per theorem. A prover may read everything in the dataset
335
+ row: the problem, the Rust code, the Lean code and the other theorems of the same program.
336
+
337
+ ## How the programs were checked
338
+
339
+ Rust: every program passes all of its test cases with `cargo test` (debug build, so an
340
+ integer overflow counts as a failure, not a silent wrap-around).
341
+
342
+ Lean: Aeneas translates the Rust program into Lean. We then run the Lean version with
343
+ Lean's `#eval` on the 10 smallest test cases and check that it returns the same answers:
344
+
345
+ - `verified`: the Lean reproduced all 10 (2,094 rows).
346
+ - `verified_partial`: the Lean reproduced at least 3, never gave a wrong answer, and the
347
+ rest were too slow or too big to finish (32 rows, mostly dynamic programming).
348
+
349
+ Lean is slow on large inputs because its version of the program is written for proofs, not
350
+ speed. Aeneas represents a Rust vector as a list (so `v[i]` takes time proportional to `i`)
351
+ and every integer as a bit-vector with overflow checks.
352
+
353
+ ## How to read the Lean code
354
+
355
+ Aeneas turns each Rust function into a Lean function that returns a `Result`:
356
+
357
+ ```lean
358
+ def running_sum (nums : Slice Std.I64) : Result (alloc.vec.Vec Std.I64) :=
359
+ ...
360
+ ```
361
+
362
+ - `Result α` is "either a value of type `α`, or an error". `ok x` means success with
363
+ value `x`. `fail e` means the Rust program would have panicked: integer overflow,
364
+ index out of bounds, division by zero, and so on.
365
+ - `do` and `←` chain steps that can fail, like Rust's `?`. `let x ← f y` runs `f y`,
366
+ stops with the error if it fails, and otherwise names the result `x`.
367
+ - Machine integers are `Std.I64`, `Std.Usize`, `Std.U8`, ... `x.val` is the value of `x` as
368
+ a mathematical integer, which is how the theorems talk about numbers. Literals look like
369
+ `5#i64`. Arithmetic such as `x + y` returns a `Result`, because it can overflow.
370
+ - `Slice α` is a Rust slice `&[α]`, and `alloc.vec.Vec α` is a Rust `Vec<α>`. Their
371
+ contents as a plain Lean list are `s.val`.
372
+ - Loops become two functions: `f_loop0.body` (one iteration) and `f_loop0` (the loop),
373
+ built from `loop`, which repeats the body until it returns `done`.
374
+ - Strings are byte arrays: Rust `&[u8]` / `Vec<u8>`, Lean `Slice Std.U8`.
375
+ - Trees and linked lists are Rust enums, translated to Lean inductive types in `lean_types`.
376
+ - `lean_funs_external` holds hand-written Lean models of the few Rust library functions
377
+ Aeneas cannot translate (`Vec::pop`, `[T]::sort`, `Vec` comparison, the panic raised by
378
+ `%` on zero). These are trusted definitions, not machine translations.
379
+
380
+ ## The trajectory
381
+
382
+ `trajectory` (in `programs`) is the list of events recorded while the program was produced.
383
+
384
+ | `type` | Meaning | Main fields |
385
+ |---|---|---|
386
+ | `run_start` | start of an attempt. A retry says what failed before in `note`. | `note` |
387
+ | `llm` | one call to the language model | `messages` (full input), `response`, `reasoning`, `finish_reason`, `prompt_tokens`, `completion_tokens`, `cached_prompt_tokens` |
388
+ | `tool` | one tool run | `command`, `exit_code`, `timed_out`, `output`, `duration_ms` |
389
+ | `llm_error` | an API error that was retried | `note` |
390
+ | `run_end` | end of an attempt | `verdict`, `note` |
391
+
392
+ `phase` tells you which step an event belongs to: `rust` (write the program and run
393
+ `cargo test`), `extract` (translate with Charon and Aeneas), `lean` (build the Lean and
394
+ evaluate it), or `lean_repair_rust` / `lean_repair_extract` (rewrite the program after the
395
+ Lean failed to build). When a step fails, its error output goes back to the model, which
396
+ writes a new version. The model is DeepSeek-V4.1-Flash at its default reasoning effort.
397
+
398
+ ## The Rust subset
399
+
400
+ Aeneas only translates part of Rust. The solutions therefore use plain code only: `i64`,
401
+ `usize`, `bool`, `u8` values; slices and `Vec`s; `while`/`for` loops with explicit indexing;
402
+ no `HashMap`/`HashSet`, no `String` (strings are `&[u8]` bytes), no closures or iterator
403
+ chains, no `unsafe`. Backtracking is written with an explicit stack rather than recursion
404
+ inside a loop. The code can look unusual compared to idiomatic Rust.
405
+
406
+ ## Numbers
407
+
408
+ | | |
409
+ |---|---|
410
+ | Programs | 2,126 (train 1,951 / test 175, the split of the source dataset) |
411
+ | Difficulty | Easy 523, Medium 1,124, Hard 479 |
412
+ | Theorems | 24,617 (train 22,557 / test 2,060), on 2,124 programs |
413
+ | Theorems per program | 2 to 20, median 12 |
414
+ | Theorems by difficulty | Easy 5,600, Medium 13,319, Hard 5,698 |
415
+ | Test cases | 202,511 (3 to 450 per program, median 97) |
416
+ | Median size | Rust 49 lines, Lean `Funs.lean` 172 lines |
417
+
418
+ The train/test split follows the source dataset. Theorems inherit the split of their program,
419
+ so no program or theorem appears in both splits.
420
+
421
+ ## Versions
422
+
423
+ Lean 4 `v4.36.0`, Aeneas `0c19cd5b`, Charon `5a2a17bd`, Mathlib at the revision Aeneas pins
424
+ (`fc4f59e5`).
425
+
426
+ ## Source and license
427
+
428
+ Problems, statements and test cases come from
429
+ [newfacade/LeetCodeDataset](https://huggingface.co/datasets/newfacade/LeetCodeDataset)
430
+ (Apache-2.0). The problems themselves are from LeetCode. This dataset is released under
431
+ the MIT license.
432
+
433
+ ## Citation
434
+
435
+ If you use this dataset, please cite:
436
+
437
+ ```bibtex
438
+ @misc{ganguly2026scalingleantheoremproving,
439
+ title={Scaling Lean Theorem Proving for Real-World Code Verification},
440
+ author={Debargha Ganguly and Divya Raghunathan and Dejan Jovanović and Vikash Singh and Soonho Kong and Aaron Tomb and Aman Goel and Ferhat Erata and Sam Bayless},
441
+ year={2026},
442
+ eprint={2610.38174},
443
+ archivePrefix={arXiv},
444
+ primaryClass={cs.CL},
445
+ url={https://arxiv.org/abs/2610.38174},
446
+ }
447
+ ```
data/programs/test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9befce2eb7722ddd855e39d9852159ae926b72b76736de376845c4be9e7bfb38
3
+ size 3677468
data/programs/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be39ad4758422c3f86f6a53909d2c237d81e65b1430b4ee52c5d16be5b0ead5c
3
+ size 33166180
data/specs/test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8064cf451ebb8ee7195c6fc8d657fd93a5fac46e949279ffc478b8bea838578b
3
+ size 390727
data/specs/train.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67786f09887d849ebde1bd72c3fe1f89dee20b04c6b6b4e76c1a1e514f7603ca
3
+ size 3970012