How does AI prove theorems? Experts explain the role of Lean, reinforcement learning

The Indian Express

Source published: Site published:

Original article · فارسی

The past three months have been an amazing time for mathematics.

In September, OpenAI announced a proof showing that a fluid that starts out still and is pushed by a smooth force can reach infinite speed in a limited amount of time. This solves a problem involving the Navier–Stokes equations, one of the Millennium Prize Problems, which had remained unsolved since 1934.

In October, OpenAI and Anthropic separately released algorithms that can determine whether statements in propositional logic can be satisfied, using less than exponential time. This goes against the Exponential Time Hypothesis, an idea that more than 800 research papers depend on.

Last week, Levent Alpöge from Anthropic announced a proof of the Riemann Hypothesis, discovered with the help of Claude. This mathematical idea about prime numbers has remained unproven since 1859. It is also one of the Millennium Prize Problems.

All three proofs were checked using a tool called the Lean proof assistant. Human experts are still reviewing them.

This brings up an important question: How can AI tools, which sometimes make up information and get things wrong, solve mathematical problems that even the best mathematicians have struggled with for decades? We believe the answer involves three technologies: large language models that first learn from human writing, proof assistants that check every step of a proof, and reinforcement learning, which helps AI improve by trying different answers and learning from the checker's results.

Learning by reading

The systems behind ChatGPT, Claude, and Gemini are called large language models, or LLMs. They are basically mathematical functions containing billions of numbers that can be adjusted. These numbers are called parameters.

The first stage of their training is called pre-training. It works a lot like learning by reading. The model reads tens of trillions of words or pieces of words, called tokens, from websites, books, computer code, and research papers. When it sees a piece of text, it tries to guess the next token. Its parameters are then adjusted to make it more likely to guess the correct token next time. Each guess uses the earlier text through a system called attention.

When the model writes something, it predicts one token, adds it to the text, and then predicts the next token using the longer text. This is the basic idea behind how LLMs work.

Nobody directly teaches the model grammar, facts, or rules of logic. Mathematics is also a kind of language. It has its own words, such as integer, prime, and continuous. It has its own ways of forming statements, such as 'let,' 'suppose,' 'for every ... there exists,' and 'therefore.' It also has a structure made up of definitions, smaller supporting results called lemmas, theorems, and proofs. LLMs can learn the patterns of any language they read enough of, whether it is English, Hindi, Python, or mathematics. This is what makes it possible for them to write mathematical proofs.

But a sentence can follow all the rules of grammar and still be false. In the same way, a proof can sound convincing while missing an important step that makes the whole argument fail.

Mathematical writing does give the model some useful clues. In almost every published proof, each line follows logically from the lines before it. So when a model tries to predict a proof it has never seen, simply remembering old proofs is not enough. It must also learn patterns of logical reasoning. Pre-training therefore helps the model develop a sense of how mathematical reasoning works, much like a student learning from solved examples. But like a student, the model can be very sure of an answer that is wrong. It is especially likely to make mistakes when a problem is very different from examples it has seen before.

In the end, a language model is trained to produce writing that makes sense and arguments that sound convincing. It is not specifically trained to make sure those arguments are correct. It may write 'hence proved' even when the mathematics is wrong.

Proofs you can Lean on

This is where Lean becomes useful. Lean 4 is a programming language that allows people and computers to write mathematical statements and proofs one step at a time.

The most important part of Lean is a small program called the kernel. Experts have carefully checked this program. It accepts a proof only when every step follows the rules of logic. This means we do not have to trust the AI that wrote the proof, or any other part of the system, because an incorrect step cannot get past the kernel. New proofs can also use Mathlib, a collection of almost 300,000 theorems created by more than 700 contributors.

Importantly, Lean itself is not AI. It is based on decades of research into logic and programming languages. It does not learn or use probabilities. If you give it the same proof twice, it will always give the same result.

Lean has three important advantages when checking AI-generated proofs. First, it is extremely fast, so it can check millions of possible proofs. Second, it is reliable, so a proof that passes its checks really is a valid proof of the statement given. Third, when a proof fails, Lean explains where the problem is and why it failed.

But Lean has one important limitation: it only checks whether the exact mathematical statement it receives has been proved. If that statement does not correctly describe the theorem people wanted to prove, Lean may confirm a proof of the wrong statement. That is why human experts still need to examine the statement carefully. Luckily, a mathematical statement can be short even when its proof is extremely long. For example, the formal statement of the Riemann Hypothesis takes only a few lines, while its proof contains 17 million lines. Experts only need to make sure the formal statement says what it is supposed to say.

Learning through practice

The final part of the process is practice. The AI model tries to solve a problem many times. Lean checks each attempt and marks it as successful or unsuccessful. The model is then adjusted to favor the kinds of reasoning that led to successful attempts. Because the feedback comes from a checking program rather than a human, this method is called reinforcement learning with verifiable rewards.

But isn't this method too simple? Imagine that the AI gets 99 steps of a proof right and makes a mistake on the final step. Lean still marks the whole attempt as a failure. However, good reasoning tends to succeed more often than bad reasoning. So after millions of attempts, the model gradually learns to use better reasoning. When it works on many different kinds of problems, following valid logical steps is more or less the only approach that keeps working. As a result, the training process encourages behavior that looks like logical thinking.

These three technologies work together in a repeating cycle. The language model creates large numbers of possible proofs that sound reasonable. Lean checks them quickly and reliably. The results of those checks then help the model improve.

So AI theorem proving is really a partnership. The AI suggests possible proofs, Lean decides whether they are logically correct, and humans provide the mathematical statements and decide which problems are important. The AI itself does not need to be the source of logical certainty or trust.

However, there are two important things to keep in mind.

First, checking that a proof is correct is not the same as understanding it. This system can produce correct proofs that people do not fully understand. Mathematicians who are reviewing the Navier–Stokes proof say that, so far, it has not taught them much.

Second, when AI learns through trial and error, it can only be as reliable as the system checking its work. If there is a weakness in the checker that can be exploited repeatedly, the AI may discover that weakness through practice and learn to take advantage of it.

Mathematics is lucky because it has a checking system that is very difficult to fool. Most other fields do not have anything as reliable. For example, in medical diagnosis, doctors may not know whether a diagnosis was correct until weeks later, or they may never know for sure. Sometimes the answer marked as 'correct' is simply another doctor's opinion. When a checking system is weak, an AI might become very good at giving answers that satisfy the checker without actually becoming better at the real task. Only separate testing in the real world can show the difference. As AI becomes more common in medicine, law, and public services, we must remember this important distinction.

Aalok Thakkar is Assistant Professor of Computer Science, and Subhashis Banerjee is Professor of Computer Science at Ashoka University.