broyojo.comยท9 november 2026

Formalizing CPython

Image for the article: Formalizing CPython
Image via broyojo.com

AI agents rewrote 613,318 lines of CPython's internals in Lean, a language for machine-checked proofs, uncovering 418 bugs. The project involved copying functions line by line, testing them against real Python, and verifying proofs with a second AI agent. About 55 of the bugs could crash the interpreter or corrupt memory. The effort aimed to formalize Python's behavior, especially in edge cases, and assess the reliability of AI-assisted proof generation.