Try Pro free

Lex Fridman Podcast · 8 min · Oct 26, 2026

AI formalized Fermat’s Last Theorem in 13 million lines

Alex Kontorovich describes how AI produced a Lean-verified proof of Fermat’s Last Theorem far beyond what he expected.

The episode’s best minutes

Full analysis
  1. 1:11:29AI formalized Fermat’s Last Theorem in 13 million lines8 min
  2. 1:41:57Viscosity may not prevent every fluid blow-up6 min
  3. 2:56:09Fine-tuning can transmit behaviors hidden in random data4 min
  4. 5 more moments in the full episode
“On Friday, there was a drop of 13 million lines of code. From the axioms, Fermat's last theorem is proved.”
Alex Kontorovichat 1:14:14 · Lex Fridman Podcast
1:14:14

Takeaways

  1. The proof used 13 million lines of Lean code.
  2. A verified proof can be correct without being elegant.
  3. AI exceeded expectations for formalizing deep mathematics.

About this segment

Alex Kontorovich describes how AI produced a Lean-verified proof of Fermat’s Last Theorem far beyond what he expected. The result is correct, but still needs substantial work to become clean and reusable.

Alex Kontorovich

Mathematician, Rutgers

Advances analytic number theory through research on automorphic forms, homogeneous dynamics and representation theory.

  • Lex Fridman, Host · Host, Lex Fridman Podcast

    Robotics and AI researcher at MIT; started the show in 2018.

From “AI Crisis in Math: Navier-Stokes, Riemann Hypothesis & Complexity Theory | Lex Fridman Podcast #503”, Oct 26, 2026. Watch the full episode

Transcript

Transcribed by machine (Whisper) from the episode’s audio, so a word may be off here and there.

  1. 1:11:34

    It was in Lean, it was formalized. How big was the formalized last year in Lean? 13 million lines. 13 million lines, okay. So I just, two days before, I gave a colloquium in the Princeton math department where I explained in painstaking detail what Lean is, what Mathlib is, but also that AI systems today, you know, there's this Mathlib library where everything is kind of perfectly done, exactly the right levels of generality.

  2. 1:11:58

    There's not supposed to be any code that's reusing. code that's reproving theorem somewhere else. Everything is the most general, the most abstract. And what AI systems are capable of doing is building like one or two layers on top of that. But what they're doing is jerry-rigging. They have not been trained yet. I'm not saying they can't do it, but they're not good at it right now, at what I call canonization, which is taking kind of sloppy code, refactoring it, figuring out exactly where in the library it belongs, what's the canonical version of this statement of this lemma and then everything every proof should just be a combination of you apply this lemma from over here you apply that lemma from over there put put all these things together there's your theorem and then it's really clean

  3. 1:12:40

    it's really beautiful very elegant that's what mathlib is going for and what i said in my colloquium is where we are today is that you can get entire textbooks formalized as long as they're in the mathlib halo as long as they're like one maybe two steps removed from things that have already been done in mathlib but when you start and this had been my practice my experience had been when you start asking it to do things that are you know three or four steps removed from the library the way that it came up with the definition of this object and the way that it came up with some other definition of the same object because it was doing it for two different purposes then they clash you can't stitch these things back together like you really need the library, MathLib, to grow in order to get to a place where you can do research manuscripts,

  4. 1:13:26

    you know, that are really using, synthesizing tons of different areas of mathematics. Which is why you would expect Fermat's Last Theorem to take, because it's so far outside of the halo of MathLib, it would take quite a bit of time. Exactly right. So Kevin Buzzard had a million-dollar grant to spend the next five years, or maybe he's already a year or two into that grant, to reduce the formalization of Fermat's last theorem to things that were known in the 1980s. So he wanted to do that last step, the seven years of Wiles' work and Wiles-Taylor to finally finish Fermat's last theorem, but built on top of things that we knew would be extraordinarily difficult. He wasn't going to do Langland's Tunnel. He wasn't going to do Maser. There were all kinds of things that were expected to be even much more difficult than what

  5. 1:14:12

    these five years would take. And everything I said in that colloquium was wrong. And I think my colloquium was on a Wednesday. On Friday, there was a drop of 13 million lines of code. From the axioms, Fermat's last theorem is proved. The statement of Fermat's last theorem is completely elementary. There's no semantic alignment to check. You just glance at it. Yes, that's the statement. Lean says it's sorry free. Can you explain how it was done? How it was done? So it systems just got really really good it's still not a nice proof it's not the clean proof it's not there's still a ton of work that needs to be done to make that proof a math lib quality proof and i think that's important work and work that uh we want to do but in terms of just getting that sorry free theorem they just blasted through all of these they jerry-rigged this they jerry-rigged

  6. 1:15:00

    that and you know 13 million lines later they had a sorry free formal lean proof of from as last It's just absolutely shocking. By the way, it's beautiful to always, because of how rapid everything is, there's going to be a lot of statements that everybody makes, the world experts make that are wrong. That's the whole point of it. And that's the fun thing about human discussion is we have disagreements and I would venture to say somewhere between 40 to 80% of everything said today will be wrong in five years because everything's changing so fast.

  7. 1:15:34

    But that's the whole point of human discussion, and deliberation and discourse and even the scientific process is saying shit and seeing what sticks over time, over 10 years, over 100 years and so on. I was describing my experience. I had a lot of experience with Lean and with using AI. I started doing Lean before AI existed in the sense that we understand it now. And it was very painstaking. And the second AI systems came on, you know, the first LLM.

  8. 1:16:02

    systems were coming online. They were, they were crap at lean, but then they got a little bit better, a little bit better. And I was like, Oh my God, I can do library search. I don't have to sit there looking. I know there's a lemma that does this, but I don't know what it's called. And I don't know which exactly is it in the manifolds library? Is it in the algebraic geometry library? Like, give me this, give me this lemmas. It was great at that. And I was like, Oh, this is amazing. I'm going to keep using these systems. And every bit of my experience told me that they can do like x but not 10x and this was a million x it was just completely outside of the distribution in my mind of what systems were capable of do you have a ballpark estimate of how many humans were involved in that and like what is the level of human involvement

  9. 1:16:41

    in generating those 13 million lines of code uh i believe it was two or three humans okay and i believe most of their involvement was keep going all caps okay all right so you think it's really just like uh gentle guidance not like you know pathway creating and as far as i understand there was no domain expertise okay on the parts of the people who were doing this as the meme goes with with open ai or anthropic you know the prompt is solve math or something right do a breakthrough yeah dude yeah do a break do a breakthrough that's the prompt and it goes and does it of course you never know from a company perspective there's a lot of incentive to sort of sell it as that even though there might have been a lot of intermediate steps that led with any stages of the training or maybe some things left unsaid even though the final prompt is do a breakthrough

  10. 1:17:39

    there could be a lot of groundwork before that that led to we don't know so i remember that was a friday because i just was completely like my mind was completely exploded and it was labor day and we we just took the kids to the beach and i needed a few days of you know i'm not checking my phone i'm not on twitter i'm just throwing you know throwing my kids into the ocean and did you have that moment where you're just sitting and looking at the ocean and contemplating like what what does it all mean yeah yeah so i had already gone through that a month before yeah And I was like, I, so now what that says is that auto formalization is basically solved.

  11. 1:18:18

    It's not solved in the way that I would want it to be solved. I want, and I, and people are still going to work very, very hard on this. There's all kinds of other things that happen, just like there's all kinds of other things that happen when you prove theorems that are byproducts of that, that process for human understanding. There's all kinds of other things when you work on making a beautiful library of mathematics and that process will continue.

  12. 1:18:40

    That process will be very difficult. it's going to be the you know thousands of man hours people around the world contributing in this open source way but in terms of can you get a sorry free proof of something that human beings have written down on paper i think that problem is done and so you're standing there with a whiskey having gone through this a month before and now again right this was round three because when i