Rado's Radical Reflections

Why formalize mathematics - more than catching errors

I read a good post by one of the authors of the Isabelle theorem prover, that got me thinking. The author, Lawrence Paulson, observed that most math proofs are trivial, but writing them (preferably with a proof assistant) is a worthwhile activity, for reasons similar to safety checklists - “Not every obvious statement is true.”

As I have been a bit obsessed with doing formalized mathematics, this got me thinking about why I am excited to spend many hours recently writing formalized proofs in Lean for exercises from Tao’s Real Analysis (along with this recent attempt to write a companion to Riehl’s Category Theory In Context). On a very personal level, I just like math, computers and puzzles, and writing Lean proofs feels like doing all three at once. But I do believe formalization is important beyond nerd-snipping folks like me.

While Paulson focuses on the obvious benefit of finding potential errors in proofs as they are checked by a computer, I will discuss some other less obvious benefits of shifting to formal math or “doing math with computers” as I tell my friends who ask me what I am obsessing over.

To understand these benefits let me begin by sharing a parallel from my engineering career.

TypeScript story

TypeScript is an optional static type system for JavaScript (a dynamic language without static types). Very briefly, when writing TypeScript, one is roughly writing JavaScript with some extra annotations - types. Those are checked by the TypeScript compiler, as part of the compilation / build process. If the type annotations are not consistent - say you said the function f expects a number but somewhere you also wrote f('foo') an error will be emitted. If no such errors are found, the type annotations are erased and JavaScript is emitted for further execution.

It seems all TypeScript is good for is catching errors and rejecting your programs. So when we went around Google pitching different teams to migrate, the questions were always around how many bugs this system can find. What we soon realized is that actually finding bugs in code that was tested and in production for many years is not that valuable. Some of it is due to JavaScript being mainly used for UIs, so worst case scenario one often can just refresh the page (thankfully no one is writing mission critical software in JS, right?!?). And even more surprising the risk of fixing the “bug” that TS found was often higher, due to new errors that might arise.

If correctness wasn’t that big of a deal (especially over established codebases) what good is this type-checking? As I learned more about it, the following benefits emerged:

Analogy with Lean and Math

So by analogy, formalizing math with Lean has the following similar benefits outside correctness and assistance in writing proofs.

Basically, the process of doing math will become more efficient and hopefully more pleasant. The price one has to pay is proving many more trivial proofs than they wish. Mathematicians are not against trivial proofs, textbooks are full of proofs that are “follow-your-nose” style. What is hard to accept, is that Lean will not allow anyone to control what they call “trivial”. To Lean everything needs a proof, but there are more and more powerful tactics being built, so “trivial” is what Lean’s current set of tactics can close in one-line, the rest need more work.

Finally, note that a lot of the benefits I am describing above don’t even need to have the full formal proofs, just formal statements are enough. This effort by Kevin Buzzard with support from Renaissance Philanthropy seems to confirm that just having statements is a very valuable task by itself - Renaissance Philanthropy formalized theorem statements.

Will these extra benefits tip the scale to make it worthwhile for mathematicians to change how they have been doing math for millennia, adopt new tools with steep learning curves? I hope so, but only time will tell.