Abstract
Recently, large language models have presented promising results in aiding formal mathematical reasoning. However, their performance is restricted due to the scarcity of formal theorem-proving data, which requires additional effort to be extracted from raw formal language corpora. Meanwhile, a significant amount of human-written formal language corpora remains underutilized. To address this issue, we propose LEAN-GitHub, a dataset consisting of large-scale formal data extracted from almost all Lean 4 repositories on GitHub. After fine-tuning InternLM-math-plus on this dataset, our model achieved accuracies of 48.8% with a single pass and 54.5% with 64 passes on the Lean 4 miniF2F test, surpassing state-of-the-art method at 52%. And it also achieves state-of-the-art on two other Lean 4 benchmarks (ProofNet and Putnam) targeting different fields/levels of math. These results demonstrate that our proposed dataset is beneficial for formal reasoning on a wide range of math topics. We open-source our model at https://github.com/InternLM/InternLM-Math and our data at https://huggingface.co/datasets/InternLM/Lean-GitHub
Introduction
Large Language Models (LLMs) are increasingly proficient at informal mathematics, but "formal" theorem proving—where a computer assistant like Lean 4 verifies every logical step—remains a massive challenge. The primary bottleneck is data scarcity. Unlike general-purpose programming languages, formal proof code is rare and difficult to author. Furthermore, training effective models requires access to "intermediate states"—the specific goals and hypotheses visible to the prover at each step—which are typically hidden until the code is compiled.
Existing datasets have largely relied on Mathlib, Lean’s centralized library. This leaves a vast amount of diverse, human-written formalization on GitHub untapped because these repositories are often difficult to compile at scale due to complex dependencies and versioning issues.
The LEAN-GitHub Dataset
To unlock this data, the researchers developed a specialized extraction pipeline designed to handle the "messy" nature of GitHub repositories. Instead of relying on standard build tools like Lake, which often fail on non-standard projects, they utilized the underlying leanc compiler directly. This approach allowed for the construction of a global import graph and the compilation of isolated files that would otherwise be discarded.
The resulting LEAN-GitHub dataset was extracted from 147 repositories, yielding 28,597 theorems and 218,866 tactics (approximately 0.131 billion tokens). This dataset covers a much broader range of mathematical topics and coding styles than Mathlib alone, providing the diversity necessary for better model generalization.
Technical Innovations: InternLM2-StepProver
The authors introduced InternLM2-StepProver, a 7B-parameter model fine-tuned on a combination of Mathlib, synthetic data, and the new LEAN-GitHub corpus. A key technical contribution is the implementation of State De-duplication.
During a proof search, different sequences of tactics often lead to logically identical states. Without intervention, a prover might waste significant computational resources exploring redundant paths. The authors implemented a normalization method that renames free variables based on their internal storage order. This allows the prover to recognize and skip duplicate states; findings suggest that over 50% of intermediate states in typical searches are redundant.
Experimental Results
InternLM2-StepProver set new records across several major benchmarks:
- miniF2F-test: Reached 54.5% accuracy (with 64 passes), surpassing the previous state-of-the-art, DeepSeek-Prover (52.0%).
- ProofNet: Achieved 18.1% Pass@1, a significant jump over the previous leader, ReProver (13.8%).
- PutnamBench: Solved 5 out of 640 problems. While 5 sounds small, these are notoriously difficult problems that most previous Lean 4 provers failed to solve (GPT-4 and COPRA solved only 1 each).
- IMO 1983 P6: The model successfully found a proof for this International Mathematical Olympiad problem, which the authors claim had not been solved in Lean 4 previously.
Conclusion
The success of InternLM2-StepProver highlights that diversity in training data is often more impactful than sheer volume. By tapping into the broader ecosystem of GitHub repositories, the researchers provided the model with a richer variety of mathematical reasoning patterns. Future work will focus on overcoming compilation failures for older repositories and improving "auto-formalization" to bridge the gap between natural language mathematics and formal code.
Summary updated