↓ Skip to main content
  1. Posts/

AI Just Wrote a 17-Million-Line Proof of the Riemann Hypothesis: How Anyone Can Verify It with Lean 4

The mathematics and AI communities were recently shaken by a historic announcement: number theorist Levent Alpöge, working alongside Claude, claims to have discovered and formally verified a complete proof of the Riemann Hypothesis (RH)—as well as the Generalized Riemann Hypothesis (GRH).

What makes this release truly unprecedented is how it was published. In his accompanying research note (remark.pdf), Alpöge made an unconventional choice: instead of releasing a traditional paper, he published 14 compressed archives of raw Lean 4 code totaling roughly 17 million lines.

The reason is purely practical. Translating those 17 million lines of machine-checked deductions into human prose would produce an unreadable 250,000-page monolith—one that spends pages proving elementary facts like “because the real numbers are totally ordered, if \(\sigma \neq 1/2\), then \(\sigma > 1/2\) or \(\sigma < 1/2\).”

When AI surpasses the reading limits of human referees, how do we know it isn’t hallucinating? The answer is Lean 4 formal verification. You don’t need a PhD in automorphic forms or iterated theta lifts to understand how the verification works. In fact, with an undergraduate grasp of logic and programming, you can set up Lean 4 in 10 minutes and act as a mathematical referee yourself.


1. How Can You Verify a Landmark Theorem by Reading Three Lines of Code?
#

In traditional mathematics, peer reviewers must scrutinize hundreds of pages line by line; a single overlooked sign error can collapse an entire proof.

In Lean 4 (an interactive theorem prover built on dependent type theory), the rules change under the principle of “Propositions as Types, Proofs as Programs”:

  1. The Theorem Statement acts as the program’s type signature (interface).
  2. The Proof Script acts as the implementation that satisfies that type.

Because of this architecture, you do not need to read or understand the 17 million lines of proof steps. As an independent verifier, you only need to check two things:

  • Inspect the Statement: Confirm that the top-level theorem signature accurately defines the textbook problem (ensuring the AI didn’t prove a watered-down version).
  • Run the Compiler & Axiom Audit: If the code compiles cleanly through Lean’s minimal trusted kernel with zero errors—and relies on zero cheating placeholders—the proof is 100% logically sound, regardless of who or what wrote the intermediate steps.

2. 10-Minute Hands-On Lab: Run Your First Lean 4 Verification
#

Compiling 17 million lines of code requires heavy compute, so let’s build a lightweight, self-contained project using Lean’s standard math library (Mathlib). You will experience the exact workflow used by researchers: define a theorem \(\rightarrow\) let the kernel verify it \(\rightarrow\) audit for hidden assumptions.

Step 1: Minimal Environment Setup
#

  1. Download and install VS Code.
  2. Open the Extensions marketplace in VS Code, search for lean4, and install the official extension.
  3. Create an empty folder on your computer (e.g., lean-verify-demo), open it in VS Code, and create a file named VerifyDemo.lean.
  4. Click the ∀ icon in the top-right corner of VS Code and select Install Lean using Elan. Wait a couple of minutes for the toolchain to configure automatically.

Pro Tip: Press Ctrl + Shift + Enter (Cmd + Shift + Enter on Mac) to open the Lean Infoview panel. Clicking on any line of code will immediately display the exact logical goal state at that step.

Step 2: Initialize a Mathlib Project
#

Open the integrated terminal in VS Code (Ctrl + ~) and run the following commands to create a standard Lean project and download precompiled Mathlib binaries:

lake new my_proof math
cd my_proof
lake exe cache get

Step 3: Verify a Classic Number Theory Theorem
#

Open MyProof.lean and paste the following runnable Lean 4 code. We will formally verify Euclid’s classic theorem: for every natural number \(n\), there exists a prime number \(p \ge n\) (i.e., there are infinitely many primes).

import Mathlib.Data.Nat.Prime.Basic
import Mathlib.Tactic

-- [CRITICAL ZONE 1: THEOREM STATEMENT]
-- Even in a 17-million-line RH project, this is the part humans carefully inspect.
theorem infinitely_many_primes (n : ℕ) : ∃ p, n ≤ p ∧ Nat.Prime p := by
  -- [CRITICAL ZONE 2: PROOF IMPLEMENTATION]
  -- In AI-assisted proofs, millions of lines live here. The compiler checks every step.
  let p := Nat.minFac (Nat.factorial n + 1)
  have hp_prime : Nat.Prime p := by
    apply Nat.minFac_prime
    have h_pos : 0 < Nat.factorial n := Nat.factorial_pos n
    omega
  refine ⟨p, ?_, hp_prime⟩
  by_contra h_lt
  push_neg at h_lt
  have h_dvd_fact : p ∣ Nat.factorial n :=
    Nat.dvd_factorial (Nat.Prime.pos hp_prime) (Nat.le_of_lt h_lt)
  have h_dvd_succ : p ∣ Nat.factorial n + 1 := Nat.minFac_dvd _
  have h_dvd_one : p ∣ 1 := (Nat.dvd_add_right h_dvd_fact).mp h_dvd_succ
  exact Nat.Prime.not_dvd_one hp_prime h_dvd_one

-- [CRITICAL ZONE 3: ANTI-CHEATING AXIOM AUDIT]
#print axioms infinitely_many_primes

Place your cursor on the final line (#print axioms infinitely_many_primes) and look at the Lean Infoview panel on the right. You will see:

'infinitely_many_primes' depends on axioms: [propext, Classical.choice, Quot.sound]

3. How to Read an Axiom Audit Like a Mathematician
#

Whenever a major Lean formalization drops, the very first thing experts check is the output of #print axioms. Here is your cheat sheet for reading the results:

  • ✅ The Three Standard Safe Axioms:

    • propext (Propositional extensionality)
    • Classical.choice (Axiom of choice)
    • Quot.sound (Quotient soundness)
    • If the output contains only these three axioms (or a subset of them) and compiles with zero errors, the proof is mathematically airtight.
  • ❌ The “Cheating” Alarm (sorryAx):

    • If an AI gets stuck on a lemma, it might insert the keyword sorry to bypass the proof. While Lean allows the file to compile with a warning, #print axioms will immediately flag sorryAx in the dependency list. Try replacing omega with sorry in the code above—the Infoview panel will catch the shortcut instantly.
  • 🛡️ Independent Multi-Kernel Replay (The 2026 Standard):

    • What if a massive proof triggers an undiscovered bug in Lean’s own C++ kernel? Following the Lean community’s multi-checker initiative introduced in October 2026, proofs can be exported as standalone environment data and independently re-verified by external type-checkers written in Rust (such as nanoda) or lean4lean. Putting the 17-million-line RH proof through both axiom auditing and independent kernel replay is what gave mathematicians immediate confidence in its logical validity.

Final Thoughts
#

AI is fundamentally reshaping how mathematical truth is established. We are moving away from an era where “humans write proofs and humans referee them” toward a new paradigm: “humans supply intuition, AI writes the formal proof, and a minimal logical kernel serves as the ultimate referee.”

Even if you are still an undergraduate, spending 15 minutes with Lean 4 gives you the exact same verification microscope used at the frontier of modern mathematics. Spin up the code above and try catching a sorryAx yourself!

Related