Lean4Lean: Verifying a Typechecker for Lean, in Lean
Mario Carneiro

TL;DR
This paper introduces a new Lean-based external typechecker for Lean 4, enabling formal verification of the kernel and improving trustworthiness, while maintaining competitive performance.
Contribution
It presents the first complete Lean 4 typechecker written in Lean, facilitating formal verification and correctness proofs of the kernel.
Findings
Checker is 20-50% slower than the reference implementation.
Able to verify the entire mathlib library.
Identified and fixed a soundness bug.
Abstract
In this paper we present a new "external checker" for the Lean theorem prover, written in Lean itself. This is the first complete typechecker for Lean 4 other than the reference implementation in C++ used by Lean itself, and our new checker is competitive with the original, running between 20% and 50% slower and usable to verify all of Lean's mathlib library, forming an additional step in Lean's aim to self-host the full elaborator and compiler. Moreover, because the checker is written in a language which admits formal verification, it is possible to state and prove properties about the kernel itself, and we report on progress to formalize the Lean type theory abstractly and prove some theorems about it. Finally, we combine these to get a proof of correctness of parts of the kernel. We plan to use this project to help justify any future changes to the kernel and type theory and ensure…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsManufacturing Process and Optimization · Flexible and Reconfigurable Manufacturing Systems
