TL;DR
Large language models can effortlessly translate natural language into clean, executable code—but does that mean they actually understand how code works? By asking top reasoning models to formally prove that their own clean code does the exact same thing as an unconventional, machine-discovered program, the authors reveal a massive blind spot: even after spending tens of thousands of tokens "thinking," LLMs fail almost completely. Writing working code and reasoning about code turn out to be two very different skills.
What Problem Does This Paper Address?
Imagine a student who aces every calculus exam by memorizing hundreds of worked examples. Give them a familiar problem, and they look like a genius; give them a weirdly phrased problem that requires applying fundamental rules from scratch, and they freeze.
Today's LLMs are in a similar boat. They routinely write working code on the first try without compiler feedback. However, existing code-reasoning benchmarks struggle to separate true semantic understanding from pattern matching. First, they test LLMs on standard, human-style code full of familiar idioms. Second, they usually just check final answers—like predicting an output or answering "yes/no" to whether two programs do the same thing—which leaves room for lucky guesses or flawed logic that accidentally lands on the right value. To test true code reasoning, we need valid code that looks completely alien, paired with a task that requires justifying every single step of execution.
Methods
To strip away familiar coding patterns, the authors set up an adversarial pairing inside Lean 4, a system that acts as both a functional programming language and a strict mathematical proof checker.
For a given mathematical integer sequence, they take two wildly different implementations:
- The Unfamiliar Code: A program discovered via automated search (drawn from prior synthesis work), built from a minimal domain-specific language (DSL) of basic integer loops, conditionals, and arithmetic. Because a search algorithm found it, it lacks human idioms and looks strange.
- The Familiar Code: A clean, standard Lean 4 program written in a single attempt by an LLM (
DeepSeek-V4-Pro) reading the sequence's text description.
The model's task is to write a formal proof of extensional equivalence—mathematically proving that for every possible natural number input $n$, both functions output the exact same result. Because Lean 4 has subtle rules around type conversions (e.g., subtraction on natural numbers stops at zero, while integers go negative), the model must read the exact operational semantics of the language rather than skimming the surface syntax. Models are evaluated in a single attempt without interactive compiler feedback, matching the exact conditions under which the LLM wrote the code in the first place.
Datasets
The authors introduce OEIS-Equiv, a new benchmark of 200 self-contained equivalence-proving tasks in Lean 4.
- Sources: Built from the On-Line Encyclopedia of Integer Sequences (OEIS) and Sequencelib (which houses Lean 4 translations of synthesized DSL programs).
- Validation & Rigor: Every pair is numerically checked across hundreds of inputs (up to $n = 5001$), stripped of identifying metadata so models can't cheat by recognizing sequence IDs, and accompanied by a verified reference proof (ranging from 9 to 1,012 lines of code) to guarantee every task is genuinely solvable.
Key Insights and Ideas
- Generation $\neq$ Comprehension:
DeepSeek-V4-Prowrote all 200 standard implementations in the benchmark without breaking a sweat, yet could not prove a single one of them equivalent to its DSL counterpart. - The bottleneck isn't proof-writing—it's reading the code: You might wonder if formal theorem proving in Lean 4 is simply too hard. To test this, the authors ran simple, one-line automated proof scripts (combining basic definition unfolding, induction, and standard solvers) across the benchmark. Twenty-one tasks were solved automatically—15 of them using older Lean tactics that existed well before the evaluated LLMs were trained. Yet the LLMs failed on most of these "one-liner" tasks too, showing they stumble on understanding how the two programs relate, not on complex proof machinery.
- More "thinking" tokens don't fix blind spots: General-purpose reasoning models spent medians of 60,800 to 114,000 tokens reasoning per problem, usually stopping on their own well before hitting the 128k token ceiling. They had plenty of room to think, yet spun their wheels without landing on valid proofs.
Key Results
The authors evaluated three flagship reasoning models (DeepSeek-V4-Pro, GLM-5.2, MiniMax-M3) and three specialized formal theorem provers (DeepSeek-Prover-V2-7B, Goedel-Prover-V2-8B, and 32B):
- Near-zero solve rates:
MiniMax-M3topped the leaderboard by solving just 3/200 (1.5%) tasks.GLM-5.2andDeepSeek-Prover-V2-7Bsolved 2/200 (1.0%) each,Goedel-Prover-V2-32Bsolved 1/200 (0.5%), and bothDeepSeek-V4-ProandGoedel-Prover-V2-8Bscored 0/200 (0.0%). - Beaten by simple scripts: Simple one-line automated Lean tactic scripts solved 21/200 (10.5%) tasks directly. Out of those 21 mechanically easy tasks, 13 were solved by zero LLMs.
Limitations and Future Work
- Zero-feedback setting: Models were tested without interactive feedback from the Lean 4 compiler. While this intentionally mirrors how LLMs write working code in one shot, allowing iterative tool feedback could change performance dynamics.
- Excluded operators: The benchmark filters out unbounded minimization searches (
compr) from the DSL because bounded approximations in Lean might break true mathematical equivalence for all $n$, slightly restricting the types of Turing-complete programs tested. - Future Directions: The authors hope OEIS-Equiv pushes the community to evaluate code models beyond simple input/output checks, inspiring architectures that interpret code by its strict underlying rules rather than its surface familiarity.
Summary updated