What is Lean 4? Lean 4 is an open-source programming language and proof assistant that checks mathematical proofs and program properties step by step, with a small trusted kernel that accepts or rejects every inference. It’s the tool Anthropic researcher Levent Alpöge used in November 2026 to release a machine-checked proof, built with Claude, that he says settles the generalized Riemann hypothesis.
This guide explains how Lean’s proof checker decides what’s true, what the Riemann claim does and doesn’t show, and how to run your first proof.
What is Lean 4?
Lean 4 is a functional programming language and interactive theorem prover. You state a theorem as a type, write a proof as a program of that type, and Lean’s kernel checks every step. If the kernel accepts it, the proof is correct relative to Lean’s logic and axioms. If any step fails, the file doesn’t compile.

A few facts from the Lean FRO’s own history page:
- Leonardo de Moura created Lean in 2013, after working on automated reasoning at Microsoft Research and SRI International.
- Lean 4.0 was officially released in September 2023.
- The Lean Focused Research Organization (Lean FRO), a non-profit founded in July 2023 by de Moura and Sebastian Ullrich, now maintains it.
- The latest release on GitHub is v4.36.0, published November 16, 2026.
Lean is two tools in one: a language that compiles to native code, and a proof assistant whose dependent type system lets you prove code meets its specification for every input, not just the ones you tested.
Why Lean 4 is in the news: the Claude Riemann proof
On Friday, November 20, 2026, Levent Alpöge, a member of Anthropic’s technical staff, posted a four-page note on his website: “I believe I have, working with Claude, discovered a proof of the Riemann Hypothesis.” He didn’t publish a conventional paper. He released the argument as Lean code, Al Jazeera reported, and wrote that “Claude far outpaced me near the finish line.”
Get the scope right, because many headlines don’t:
- What’s claimed: a proof of the generalized Riemann hypothesis, which extends Riemann’s 1859 conjecture about the zeros of the zeta function to a wider family of functions (Dirichlet L-functions).
- What’s checked: the Lean code. The Lean FRO’s timeline lists it as “a Lean-verified proof of the Riemann Hypothesis.”
- What isn’t done yet: human understanding. Kevin Buzzard of Imperial College London told Al Jazeera, “It’s 17 million lines of Lean code, and this might correspond to tens of thousands of pages of mathematics.” Mathematicians expect it to take weeks to digest.
- What came before: in August 2026, Anthropic announced results related to the Riemann zeta function with Lean formalizations that passed Comparator validation. That was a partial result, not the hypothesis itself.
Why does Lean matter here? No one can read 17 million lines. The claim deserves attention because a small, well-studied program has already checked every one of them.
How the Lean 4 proof checker works
Lean splits the job into an untrusted front end and a trusted back end. Everything clever happens in the front end. Everything you have to trust lives in the kernel, which Lean’s site describes as a “minimal trusted kernel.”

Here’s the pipeline in order:
- You (or an AI) write source. Definitions, theorem statements and tactic scripts such as
simp,omegaorgrind. - The elaborator expands it. It fills in implicit arguments, runs tactics and turns your script into a full proof term. Tactics can be buggy; that’s fine, because nothing here is trusted.
- The kernel type-checks the term. It checks that the proof term really has the type of the theorem, using a small set of rules from dependent type theory. Accept or reject, nothing in between.
- Independent checkers can re-check it. Lean can export proofs so a separate program re-verifies them. The Lean FRO launched Comparator, a sandboxed judge that exports and re-checks proofs independently, and con-leche, an external checker proven consistent in Lean.
This is why an AI-written proof can be trusted: most attempts are wrong, and only terms the kernel accepts survive.
Two escape hatches matter. sorry lets you skip a step, and Lean flags every declaration that uses it. Extra axioms let you assume things. The command #print axioms lists every axiom a theorem depends on, so a reviewer can see in one line whether anything was assumed.
A tiny Lean 4 proof, line by line
Here’s a complete Lean 4 file you can paste into the Lean playground:
-- A theorem is a type; a proof is a value of that type.
theorem my_add_comm (a b : Nat) : a + b = b + a := by
omega
-- Ask Lean which axioms the proof relies on.
#print axioms my_add_comm
-- A "proof" that skips the work. Lean compiles it,
-- but warns: declaration uses 'sorry'
theorem bogus (n : Nat) : n + 1 = n := by
sorry
Read it top to bottom:
theorem my_add_comm (a b : Nat) : a + b = b + astates the claim for every pair of natural numbers.by omegahands the goal to a decision procedure for linear arithmetic. Lean shows “No goals” when it’s done.#print axioms my_add_commtells you the proof assumed nothing extra.bogusis false, and the only way to “prove” it issorry. Lean marks it, and#print axioms boguslistssorryAx. You can’t hide it.
Reviewers of a big result check this first: no sorry, no unexpected axiom.
How AI and Lean 4 work together
AI theorem proving runs as a loop. The model proposes, Lean answers, the model tries again. Lean’s errors and open goals are the feedback; the kernel’s verdict is final.

This is the same pattern behind earlier work you may have read about. Google DeepMind’s AlphaProof reached IMO silver-medal performance in July 2024 using Lean and Mathlib, and open models such as DeepSeek Prover V2 and DeepSeekMath-V2 train against Lean or self-verify their own steps.
Mathlib is the reason this scales. Lean’s site describes it as a community library of “over a million lines of formalized mathematics” spanning algebra, analysis, topology and probability. A proof about L-functions doesn’t start from the axioms of arithmetic; it builds on what Mathlib has already checked.
Proof checking vs testing: what each one guarantees
Developers know a weaker version of this idea: tests.
| Lean 4 proof | Unit or API test | |
|---|---|---|
| What it checks | A theorem, for every possible input | Specific inputs you chose |
| Who decides pass or fail | The kernel’s type checker | Your assertions |
| What a pass means | The claim holds, given Lean’s axioms | These cases behaved |
| What it can’t see | Whether the theorem statement says what you meant | Every input you didn’t write |
| Cost | High: weeks to formalize | Low: minutes per case |
A proof can be perfect and still prove the wrong statement, which is why mathematicians will spend weeks reading what Alpöge’s Lean code states. A test proves less, but it’s cheap and runs on every commit.
How to install Lean 4 and run your first proof
For a local setup, follow the official manual install guide:
- Install elan, Lean’s version manager:
curl https://elan.lean-lang.org/elan-init.sh -sSf | sh, thensource $HOME/.elan/env. - Install the Lean 4 extension for VS Code, which shows goals and errors as you type.
- Create a project with
lake new helloand open the folder in VS Code. - Add Mathlib if you want the math library, then run
lake exe cache getto download prebuilt files. Skipping that step makes the first build very slow, according to Mathlib’s README. - Build with
lake build. A clean build with nosorrywarnings means every theorem in the project passed the kernel.
Let your coding agent check your API the same way with Apidog CLI
Lean’s lesson for API teams is simple: write the contract down, then let a machine check every result against it. In API work, the contract is your spec, and the check is response validation.
Apidog validates a response against the schema your endpoint spec declares, so missing fields, wrong types and extra properties show up without hand-written assertions. Apidog CLI lets your coding agent run those checks for you, the same way Claude ran Lean in a loop. You write one prompt; the agent reads the spec, writes test cases and runs them.
Set it up once:
npm install -g apidog-cli@latest
apidog auth login --with-token <YOUR_TOKEN>
npx -y skills add https://apidog.com # pick your agent when prompted
Then give Claude Code, Codex or Cursor one prompt:
In Apidog project <projectId>, read the spec for GET /objects/{id}.
Create a test case that calls it with a real id and fails if the
response doesn't match the 200 schema. Run every test case on that
endpoint against Staging and list any schema violations.
The agent looks up the endpoint and its declared responses, writes a test case from the validated schema, then runs every case on the endpoint:
apidog endpoint list --project <projectId>
apidog endpoint get <endpointId> --project <projectId>
apidog cli-schema get test-case-create
apidog cli-schema validate test-case-create --file case.json
apidog test-case create --project <projectId> --file case.json
apidog test-case run --project <projectId> --endpoint <endpointId> -e <envId> -r cli,junit

Like Lean’s kernel, the spec is the referee: when the backend drifts, the run fails and the agent tells you which field broke. Put the same test-case run ... -r junit command in CI so every pull request gets checked; the Apidog CLI CI/CD guide shows the GitHub Actions setup, and Apidog CLI in Claude Code covers the agent side. For the testing theory behind it, see API contract testing. Apidog’s Free plan covers up to 4 users.
FAQ
What is Lean 4 used for? Lean 4 is used to formalize mathematics (Mathlib, Fermat’s Last Theorem project), to verify software and hardware, and as the checker in AI theorem proving. It’s also a general-purpose functional language that compiles to native code.
Did Claude prove the Riemann hypothesis? Levent Alpöge says he found a proof of the generalized Riemann hypothesis working with Claude and released it as Lean code. Lean has checked the code; mathematicians are still working out what the 17 million lines show, which they expect to take weeks.
Is Lean 4 free? Yes. Lean 4 and Mathlib are open source, and the Lean FRO is a non-profit. You can run it locally with elan or in the browser playground at no cost.
Can a proof checker be wrong? In principle, yes, which is why Lean keeps the trusted kernel small and supports independent re-checking with tools like Comparator. The bigger practical risk is a theorem statement that doesn’t say what you meant.
Do I need to know advanced math to learn Lean 4? No. Start with simple theorems about natural numbers and lists, or with Lean as a programming language. Mathlib’s tutorial project and the playground are built for beginners.



