A project posted at broyojo.com used AI agents to rewrite CPython’s internals in Lean, a language where a computer can check mathematical proofs. The Lean copies follow the C source line by line, including how the C code’s numbers wrap around when they get too big. So far that’s 613,318 lines of Lean across 1,539 files, with 18,898 theorems and lemmas.
Functions go through four steps: copy, test against real Python, prove, then review. The review step came out of an early problem. The agents wrote proofs that were correct but empty, true of a function that always crashes. Reviewers now ask one question about a proof: could a broken version of the function pass it too? Proved statements are also run against real Python, which caught proofs that were valid and still wrong about the real thing.
The work has produced 418 bug reports against Python 3.15.2, each with a short script that shows the bug. About 55 can crash the interpreter or corrupt memory using ordinary Python code.…