arXiv:2610.35596stat.COOct 2026

Manuscript Offprint

arXiv:2610.35596

KAPPA: Checking the Proofs in Statistics Papers with Lean 4 and Language Model Agents

Zihua She, Xiao Wang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Papers in statistical theory rest on long proofs that few readers check line by line. We present KAPPA (Kit of Agents for Proof-checking Papers with a proof Assistant), open-source software that organizes language model agents, run by Claude Code, to translate the proofs of a IATEX paper into the proof assistant Lean 4 with its library Mathlib and check them there, result by result. Each numbered result receives one of four verdicts: verified unconditionally; verified conditionally, with every cited or unproved input stated as a named hypothesis; issue recorded, with its place in the paper and the side at fault; or unfinished, with the reason. The kit follows the paper's own proof step by step, rather than finding a new one. Separate agents write and review, each statement is compared with the paper before it is proved and fingerprinted afterwards, and every verdict rests on evidence that can be rerun without a language model. The kit runs unattended for hours, waits out usage limits, re-checks only what a revision changed and reports its cost by role, model and result. We describe the design, walk through a complete run, and apply the kit to four example papers with answer keys and to three published statistical papers, checked blind in their versions from before public corrections. In all three, the kit found the published error at the step that the correction names, together with further problems that we confirmed by hand. Given the same papers directly, the same language model working with Lean classified fewer results correctly on the longest paper and reported some statements narrower than the paper's as proved; no verdict of the kit claimed more than its Lean evidence showed.

Keywords: proof checking, formal verification, Lean, language models, statistical theory, reproducibility.

1 Introduction

A theorem in a statistics paper usually rests on a proof in an appendix, often several pages long, that combines a few cited results with many routine steps. Readers and referees follow the main line of the argument, and errors in the routine steps can go unnoticed. Journals publish corrections when such errors come to light (three recent ones are Henzi and Ziegel 2022a; Arab, Lando, and Oliveira 2026; Livingstone, Betancourt, Byrne, and Girolami 2026). Two of these three leave the theorem true and repair its proof, one corrects a false statement, and in each the error sits in a single step that a careful reader could have checked.

A specialist can formalize such a result in a proof assistant such as Lean 4 (de Moura and Ullrich 2021) with the library Mathlib (The mathlib Community 2020), and a small trusted kernel then checks every step; formalizing one statistics paper in this way can take weeks of expert work. A language model reads a proof in minutes, but its answer is another informal argument that someone has to check.

KAPPA (She and Wang 2026), a kit of agents for proof-checking papers with a proof assistant, combines the two. For each numbered result of a IATEX paper, agents translate the statement and the paper's own proof into Lean, other agents review the translation, and the Lean kernel checks the proof. The outcome is one of four verdicts (Section 3). A result is verified when the paper's proof compiles step by step. A cited lemma enters as a named hypothesis of the theorem. A problem is recorded once a second agent has confirmed it, preferably with a counterexample in Lean. Where the paper's argument fails, the kit reports the failing step and leaves the repair to the authors. The report also says what a person still has to check, and where. For a verified result, this is the statement, which the report prints beside its place in the paper; for a conditional result, also the named inputs. An issue comes with the failing step, its class and its evidence, so that the authors know where a repair has to start.

Three features of the task shape the design. A Lean proof can be correct for a statement that differs from the printed one, so every statement is compared with the paper before it is proved and fingerprinted, which makes any later change visible (Section 5.2). Language model output differs from run to run, so every verdict is tied to evidence that stays the same: compiled files, axiom lists and dependency walks that can be rerun offline (Section 8). Checking a research paper takes hours of agent work, so the kit runs unattended, survives interruptions and re-checks only what a revision changed (Section 5.6).

The software consists of agent definitions, rules and Bash and Python scripts for Claude Code (Anthropic 2026b), together with Lean commands for auditing. In spirit it is close to tools that check the reliability of statistical computations, such as accuracy (Altman, Gill, and McDonald 2007), which find problems and make the evidence inspectable. As infrastructure it resembles workflow tools such as BatchJobs (Bischl, Lang, Mersmann, Rahnenführer, and Weihs 2015) and Benchpress (Rios, Moffa, and Kuipers 2025), which run many jobs unattended and keep their state in files.

As an example, in the paper on Hamiltonian Monte Carlo of Section 6.3, a corollary is called “a direct consequence” of a theorem whose conditions include a bound on the growth of the gradient. The kit found that this bound fails for part of the family that the corollary covers. It proved in Lean that the bound fails exactly for 2<β<log⁡262 < \beta < \log_2 6 and holds for larger β\beta, and it recorded the gap at its place in the paper. The authors’ corrigendum, posted seven years after the paper and not available to the run, describes the same range.

Section 2 compares the kit with formalization by experts, with language model provers and with language model reviews of papers. Section 3 defines the verdicts and what each of them lets a reader conclude, and Section 4 follows a complete run on a short paper. Section 5 describes the design, Section 6 the case studies, and Section 7 compares the kit with a direct use of a language model and evaluates its cost, its fact check and its revisions. Section 8 explains what can be reproduced and how, and Section 9 states the limitations.

The kit is available at https://github.com/ziwaa-se/kappa under the MIT license. This paper describes version 1.3.1, with which all runs were made. Version 1.3.4 adds fixes for problems that these runs revealed, and the current release, 1.4.0, gives the kit its present name; earlier versions were released as the TeX Proof-Check Kit. It needs Claude Code, Lean 4.19.0 and the Mathlib revision pinned in the repository, Python 3.6 or later and a Bash shell. The replication materials are described in Section 8.

References (34)