What Is Lean 4? The Proof Checker Behind the Claude Riemann Proof

Lean 4 is the open-source proof assistant whose small trusted kernel checked the Claude-assisted proof of the generalized Riemann hypothesis. See how it works, what the claim shows, and how to start.

Ashley Innocent

Ashley Innocent

23 November 2026

What Is Lean 4? The Proof Checker Behind the Claude Riemann Proof

Apidog for Enterprise

On-Premises Deploy

SSO & RBAC

SOC 2 Compliant

Explore Apidog Enterprise

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:

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:

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.”

Schema of the Lean 4 trust pipeline: source written by a person or an AI goes through the untrusted elaborator and tactics, which produce a proof term; only the small trusted kernel accepts or rejects it, and independent checkers such as Comparator can re-check the exported proof

Here’s the pipeline in order:

  1. You (or an AI) write source. Definitions, theorem statements and tactic scripts such as simp, omega or grind.
  2. 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.
  3. 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.
  4. 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:

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.

Sequence diagram of AI-assisted proving: a mathematician states the theorem, an AI model proposes Lean code, Lean returns errors and open goals in a loop until the kernel accepts with no sorry, and people still read what the checked statement says

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:

  1. Install elan, Lean’s version manager: curl https://elan.lean-lang.org/elan-init.sh -sSf | sh, then source $HOME/.elan/env.
  2. Install the Lean 4 extension for VS Code, which shows goals and errors as you type.
  3. Create a project with lake new hello and open the folder in VS Code.
  4. Add Mathlib if you want the math library, then run lake exe cache get to download prebuilt files. Skipping that step makes the first build very slow, according to Mathlib’s README.
  5. Build with lake build. A clean build with no sorry warnings 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
Apidog CLI listing a sandbox project's endpoints and reading the GET /objects/{id} endpoint spec, then the test-case run command the agent runs next

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.

Explore more

What Is Replit DataCat?

What Is Replit DataCat?

Replit DataCat is an open-source, self-hosted observability stack for metrics, logs and traces. See how it takes OpenTelemetry data, stores it in PostgreSQL or ClickHouse, and pairs with API tests.

23 November 2026

What Is GPT-Live-1.1?

What Is GPT-Live-1.1?

GPT-Live-1.1 is OpenAI's full-duplex voice model in the API: it listens while it speaks, delegates reasoning and tools to a backend model, and bills /bin/zsh.05 per active minute and /bin/zsh.02 per standby minute on v1/live/sessions.

20 November 2026

What Is Firecrawl Local? Run Firecrawl on Your Own Machine

What Is Firecrawl Local? Run Firecrawl on Your Own Machine

Firecrawl Local is one Rust binary that scrapes, crawls and maps websites to markdown on your own machine and serves the Firecrawl v2 API on localhost:3002. Here's what runs locally, what goes to the cloud, how to install it and where its limits are.

19 November 2026

Practice API Design-first in Apidog

Discover an easier way to build and use APIs

What Is Lean 4? The Proof Checker Behind the Claude Riemann Proof