# Mathematical proof, powered by AI. And no hallucinations!

> Source: <https://www.amazon.science/blog/mathematical-proof-powered-by-ai-and-no-hallucinations>
> Published: 2026-11-18 18:55:35+00:00

**Key takeaway:** Connect AI agents to Isabelle through MCP using the AutoCorrode I/Q, I/R and Isabelle Assistant tools so every generated proof step is machine-checked instead of trusted.

Every day brings new evidence of the awesome power of AI. There have been dramatic developments in mathematics: AI models are solving tough problems from Mathematical Olympiads and even some *big* open research problems.

But AI agents are notorious for simply making stuff up, or “hallucinating”: don’t we have to check their solutions carefully? In fact, the computer can check the agent’s proofs for us, and better still, proof checking can be interleaved with proof generation, keeping it on the right track.

To be checked, the proof must be written in some *logical formalism*: a precise language that expresses mathematical reasoning. *Proof assistants* are apps designed for writing and checking formal proofs. They include [Lean](https://www.amazon.science/blog/how-the-lean-language-brings-math-to-coding-and-coding-to-math), favored by many mathematicians; HOL Light, used at AWS to [formally verify high-performance cryptographic code](https://www.amazon.science/blog/formally-verified-aes-xts-the-first-aes-algorithm-to-join-s2n-bignum) (including for [post-quantum cryptography](https://www.amazon.science/blog/verifying-and-optimizing-post-quantum-cryptography-at-amazon)); and Isabelle, used at AWS to [verify the Nitro Isolation Engine](https://www.amazon.science/blog/isabelle-hol-the-proof-assistant-behind-the-nitro-isolation-engine). They were originally built to help human users write proofs, but now the “user” will be an AI agent. Most proof assistants are suitable for this task. In this post, we’ll focus on Isabelle.

To generate formal proofs, we need a way for the AI agent and the proof assistant to talk to each other. Fortunately, we have the [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro) (MCP), which is supported by all the leading AI agents.

Conceptually, the MCP is a wire connecting an agent to a tool (here, a proof assistant), which may need to be modified to accept the connection. Some proof assistants, like HOL Light, provide a simple command-line interface, sometimes called a REPL (for read-eval-print loop): the user types commands, and HOL Light replies. Connecting an agent to a REPL is easy. But most proof assistants provide sophisticated user interfaces, such as the Lean extension for Microsoft VS Code. That’s great for human users, but an AI agent needs something simple and direct. So we are proud to announce the following tools, which are publicly available in the [AutoCorrode verification suite](https://github.com/awslabs/AutoCorrode):

- *I/Q* : This enables an AI agent to communicate with a live Isabelle session running on your computers. It allows you to temporarily hand over control of the proof assistant to the AI to fill in some formal material or to assess the context and provide advice.
- *I/R* : This enables an agent to develop proofs or other formal material while the user keeps working with the proof assistant. The agent still “talks” directly to the proof assistant to know if its proofs work, but it does not take control the way I/Q does.
- *Isabelle Assistant* : Powered by I/Q, this provides an Isabelle user with a chat window to an AI agent, which can observe and modify the user’s session, developing or fixing proofs. It’s less powerful than the full I/Q and I/R package but runs in a convenient window, right out of the box.

To get an idea of how effective AI is at solving mathematical problems, let’s look at some well-known examples, done automatically with the help of Isabelle Assistant.

**The square root of two is irrational**

The ancient Greeks were already aware that the square root of two could not be written as a fraction. Suppose that √2 = *a*/*b* is a fraction in lowest terms. Then 2*b*<sup>2</sup> = *a*<sup>2</sup>, implying that *a* is even. But then *a* = 2*k* for some *k*. Then 2*b*<sup>2</sup> = 4*k*<sup>2</sup>, so *b*<sup>2</sup> = 2*k*<sup>2</sup> and now *b* is even. But in that case, *a/b* is not a fraction in lowest terms. From this contradiction, we conclude that no such fraction exists.

Here is the same proof, formalized for Isabelle by Claude Opus 4.6:

As with all proof assistants, the language is designed to be checkable by computer. But it is also designed to be human-readable. Here is a little guide:

- *assume* introduces an assumption
- *have* and*show* claim some formula to be true
- *obtain* claims that certain values exist
- *by* gives the justification of a claim

We use *show* when proving facts that we are committed to proving and *have* when proving facts that we need along the way. The justifications invoke *proof methods*, which typically refer to existing theorems, but we needn’t go into detail about those.

Now we can read the code and see the mathematics. We start by *assuming* that √2 belongs to the set of rational numbers, ℚ. Then we obtain integers *a* and *b*, etc.; note that the *coprime* statement expresses that its two operands have no common factor. The proof continues to the ultimate contradiction as outlined above. This AI-generated proof is surprisingly idiomatic, though more detailed than strictly necessary.

**Finding *N* consecutive composite numbers**

The claim is that for every integer *N* > 0, there exists a block of *N* consecutive integers that are composite, i.e., that are not prime numbers. So although the primes go on forever, they are spaced further and further apart. This example is not so well known, so when proposing it to Claude, we also gave it the following proof: Take *N*! (*N* factorial, i.e., the product of the integers from 1 to *N*). *N*!  + 2 must be even, *N*! + 3 must be divisible by 3, and so forth to *N*! + *N*. I hope you can spot what is wrong with this “proof”. When I supplied it to Claude, it came up with three facts.

The first states that if *k* > 1 is a divisor of *n* > 0, then *n* + *k* is not prime. The second states that if 2 ≤ *k* ≤ *N* + 1, then (*N* + 1)! + *k* is not prime. And that is essentially our conclusion. But the third fact is the theorem presented in the correct form. Claude noticed that our proof gave us only *N* - 1 consecutive integers and made the necessary correction. Let’s skip the lemmas and just look at the main theorem:

The theorem statement (after *shows*) is in symbolic form, but it expresses that there exists *m* such that *m* + *i* is composite for all *i*.

**Definite integral of the sine function**

Now for something a bit harder: calculus. Let’s look at the integral of the function sin *x* over the interval [0, π]. (For those of you who prefer degrees, π corresponds to 180°.) The integral is the shaded area below, and it equals two.

In mathematical notation, the integral is written like this:

But with an AI agent, you don’t have to know how to code such a thing in your favorite proof assistant. All we asked for was “a nice simple example involving calculus”, and a plain English description of the integral would have worked, too. Claude generated this (even the comments):

As you may remember from calculus class — for most people the happiest time of their lives — evaluating this integral requires finding the antiderivative (say *ƒ*) of the sine function and evaluating *ƒ*(π) - *ƒ*(0). This fact is called the *fundamental theorem of calculus*. “Antiderivative” means a function whose derivative is sin *x*, which turns out to be -cos *x*. The Isabelle proof above includes a proof that the derivative of -cos *x* is sin *x*. The calculation is a bit longer than necessary, but at least it is error free, thanks to our approach of interleaving generation and checking.

**Harder projects**

These examples were easy. Much harder problems can still be formalized automatically by a good agent.

To manage the toughest problems, we need I/Q and I/R. Through I/Q we can link an agent running in a terminal window to our Isabelle session, which it can edit directly. But through I/R, it can also create an Isabelle subprocess that works silently and invisibly to prove theorems and undertake other formalization tasks. Because it doesn’t touch the document, we can work at the same time. The AI agent becomes a partner who works for us and who can advise us but also accepts hints from us. It’s a new type of teamwork, and we still need to figure out how to make it work best.

The hardest problems still require human thought, but thinking is hard work, and people get tired. Being able to direct an agent to carry out straightforward but lengthy and tiresome tasks — say, to refactor a working but messy proof development or study a trace to diagnose a problem — leaves us fresh enough to make key decisions when we must. I/R can be run standalone: we can set it up ourselves and direct it to run autonomously for a long time. But the key novelty is that I/Q itself, running as a general problem solver, can call I/R to prove theorems. The power now at our fingertips is unbelievable.

Postscript

Claude not only generated all the proofs in this post but chose most of the examples. The proofs are given as they emerged from Claude. They look remarkably natural. It is true that computer-generated material often contains complications and detours that a human would try to avoid. But these can be removed by a polishing phase, which can be partially automated.

Although the proofs given above are essentially a form of computer code, they are at least somewhat readable. There are mathematical assertions every other line, so you always know what is going on. When using AI, we are concerned about hallucinations, which we prevent here by automated proof checking. But we also ensure that people can check the proofs. This allows the AI agent and a human user to work together, which is the best way to tackle tough problems.

AI-powered proving is part of our everyday work at AWS. We want to give our customers the best performance and the highest reliability, without compromising one for the other. As we strive to accomplish this aim, huge and technically complex problems arise, which AI agents can cope with. They automate many tasks, and when they cannot succeed unaided, they can explain the options, pause for the human user to fix something or give advice, and then continue. Contrary to people’s fears, this technology does not replace us: it assists us.

**Acknowledgments:** Dominic Mulligan, who wrote Isabelle Assistant
