As someone who engages in reverse engineering for fun, I'm the type of sicko who looks at a multi-gigabyte binary, cracks my knuckles and says "let's go". It's truly fun to treat it like a puzzle and see what you can find. Much like working through a proof for the satisfaction of understanding it, breaking a complex object down into its parts is a true joy.
That same instinct is why I enjoy minimal hardware architectures like RISC-V (where I am proud to serve as a leader in the RISC-V Software Ecosystem, RISE)—and why, last weekend, I downloaded the Lean sources released by Levent Alpöge to dig around and see what we could find. The original archive (released in his note saying he found the proof "working with Claude" at Anthropic) is about 239 MB compressed, unpacking into 175,187 Lean modules and roughly 17.4 million lines. The Lean Focused Research Organization (FRO) and Mathlib Initiative certified the result, and independent proof checkers—multiple Lean type-checker kernels alongside third-party reimplementations—have confirmed that it compiles and matches Mathlib's statement of the Riemann Hypothesis.
Still, nobody can read 17 million lines of machine-generated Lean end to end. Mathematicians like Kevin Buzzard and Maksym Radziwiłł have pointed out that "we don't even know why the theorem is true," while J. L. Nielsen has even argued in a preprint that the geometric core behaves like "a manufactured witness" (which verifiers answer by pointing out that the output theorem was matched directly against Mathlib's definition). Folks are already making progress on the human-readability side with an interactive map of the modules and a community cleanup that has condensed the proof toward 300,000 lines. I wasn't trying to audit the whole argument or re-verify Lean's type-checker kernel—I was betting there were small, concrete, independently checkable pieces waiting inside if we just started looking for them.
My hypothesis was that there are primitives waiting to be found somewhere in the Lean sources: foundational building blocks assembled in novel ways. Going back to my reverse engineering analogy, imagine having a fully linked static binary of Microsoft Windows. How would we figure out which functions refer to which syscalls, then work our way back up the call graph? This was what I started doing, blindly.
Let's just say I found a lot. Most of this math (really, almost ALL of it) is over my head, so just as Alpöge leaned on Claude to assemble the proof, I leaned on LLMs and coding agents alongside Python scripts and the Lean toolchain to explore the graph and verify every claim I wanted to repeat.
Lean gave me something I'd love to have when staring at a binary. The names
were still there. Starting from the root declaration riemannHypothesis, the
compiled reference graph reaches 1,478,219 declarations. Counting how many
distinct declaration bodies mention each name (ten references from one body
still count as one) puts generic plumbing like Nat (844,862 bodies) and Eq
(841,407) at the top. Once we filtered out boilerplate and searched along paths
bridging the analytic and arithmetic halves of the proof, we narrowed the search
to six small, self-contained candidates:
- Pieri coefficient-word schedule. For polynomials with the right column weights and a lower-triangular target, a finite list of operations picks out the same target coefficient as direct substitution.
- Nullspace length from determinant valuation. Over a discrete
valuation ring (for instance, pick a prime
pand take a square integer matrix acting on copies of the p-adic quotient ℚₚ/ℤₚ), the matrix kernel (its nullspace) has length equal to the number of factors ofpin the determinant, counted with multiplicity, and infinite length when the determinant is zero. - Discrete valuation ring sublattice counts. An exact recurrence counts
the sublattices of index
qⁿin a rank-rfree lattice over a discrete valuation ring whose residue field hasqelements. - Hermitian Gauss-sum magnitude. For a quadratic Hermitian character
sum
∑ χ(a⟨y,y⟩ + ⟨y,v⟩)over a finite ring of sizeq², the theorem gives an upper bound ofqⁿ. Under its hypotheses the proof actually gets equality, then weakens it to the bound. - Adaptive substitution weights. Given a finite family of nonzero power series, choose weights so that substituting powers of one variable keeps every series nonzero. For polynomials, you can get the monomials the construction needs from their finite lists of terms.
- Hecke mass kernel (here "kernel" means a small, self-contained
arithmetic core, not a Lean type-checker or a matrix nullspace). Exact
rational arithmetic for class masses (
21direct callers in the graph) and normalized Hecke coefficients (12direct callers) from finite tables.
Items 1–5 are structural theorems, recurrences, or polynomial and character bounds. Item 6 caught my eye because it compiles all the way down to plain rational arithmetic on finite lists—something I could pull out into a standalone, zero-dependency Lean model, tie back to Alpöge's exact declarations via a formal equivalence bridge, and replay identically in C and Rust.
Here's why that appealed to me. I can get lost pretty quickly reading a definition that starts with a double coset. Hand me a list of integers and tell me what the answer ought to be and now I've got something I can poke at.
Take the classic test case at level p = 11. There are two isomorphism classes
of supersingular elliptic curves in characteristic 11. Let's call them A and B.
A has four symmetries, B has six, and an object with more symmetries gets less
weight when you count it. How much weight? One divided by the number of
symmetries. That's the whole calculation once somebody hands you the right
list.
class_mass([4, 6]) = 1/4 + 1/6 = 5/12
There's a nice convention to trip over here. If you go looking for those numbers in Benedict Gross's 1987 paper Heights and the special values of L-series, you'll find 2 and 3. Gross counts symmetries up to the central sign. Count both signs and you get the full orders 4 and 6 used above.
Now look at the neighbours of those same two curves under 2-isogenies (at the
prime 2). Start at A and the three destinations are A, B, B. Start at B and
they're A, A, A. Say I want to know how many of A's neighbours land in B. Give
each B a 1 and each A a 0. The sum is 2. That's one entry in the Brandt matrix
Gross printed back in 1987. It's also a call I can make to the second function
in the kernel. In this level-11 example the normalization factor is 1; in
general, the kernel scales the sum by u⁻¹ · q^(-k · floor(rank / 2)) for a
rational character value u and local place parameters q, k, and rank
(which the higher-rank Rust example exercises directly).
And here's a bug you can write without knowing any number theory. You're exporting a graph. You've got the destinations A, B, B. Who wants duplicate destinations in a graph? Throw them in a set. You've still got a picture with an arrow from A to B. Only now a random step from A lands in B half the time. A minute ago it was two thirds.
There's even a known invariant that catches you: detailed balance (the
weighted symmetry wᵢ · Bᵢⱼ = wⱼ · Bⱼᵢ of Brandt matrices, or equivalently
equal stationary probability flow across every edge). Divide those two class
weights by their total and you get 3/5 of the weight at A and 2/5 at B. Across
the original edges, (3/5) × (2/3) = 2/5 goes one way and (2/5) × 1 = 2/5
comes back. They match. Run the set version and suddenly you've got 3/10
going out and 2/5 coming back. You can run the Rust example from the
root of the hecke-mass-kernel checkout. It gets those destinations
independently from the roots of the classical modular polynomial Φ₂ modulo 11,
repeated roots and all.
cargo run --locked --manifest-path examples/rust/Cargo.toml --example isogeny_graph
What the kernel computes
If you'd rather see where the numbers came from, I put together this silent walkthrough. Keep an eye on the two arrows that go from A to B.
Where the proof uses it
OK, so what did that have to do with the pile of Lean I started with? I
followed two paths out of the root declaration in the original
4e8bb36 archive. One gets to classMass in 15 links; along that path there's
a theorem that cuts a volume into pieces and identifies the volume with the sum
of their weights. The other gets to Setup.hecke in 19 links; there the sum
tells you what value a transformed function has to take, and a later lemma
carries that same requirement over when the construction copies the setup. You
can follow those links in the source without taking my word for any of it.
One important caveat: reference-graph reachability in the original archive is not the same as logical necessity. Tracing those chains tells you what Alpöge's original 17-million-line build actually routed through, not that any proof of the Riemann Hypothesis—or even the community's condensed rewrite—is forced to go that way.
The formalization has its own data, and the little level-11 graph is mine to
play with. What I pulled out was the finite boundary where the representatives
and their values are already sitting on the table and all that's left is exact
rational arithmetic. The standalone Lean package proves algebraic
laws and a mass-stopping theorem over rational tables with zero external
dependencies, generates 303 test fixtures replayed identically by C (GMP) and
Rust, and ships a formal bridge inside the pinned Lean 4.33.1
environment proving that those rational formulas match Alpöge's classMass and
Setup.hecke. If somebody hands me the wrong stabilizer orders, all three
implementations can still faithfully give me the same wrong mass—certifying the
input tables is a separate job.
I went looking for something I could understand inside a proof I couldn't.
Gross got to the arithmetic a few decades ahead of me. What I came home with
was a verified rational bridge from riemannHypothesis down to a sum I could do
on a napkin, and a detailed-balance check that catches me throwing away
perfectly good edges. For a weekend spent poking at somebody else's code? I'll
take it.