AI Automatically Discovers and Formally Verifies Quantum Programs in Lean, Substantially Outperforming Baselines on Multiple Metrics

LLM agents automatically synthesize and formally verify quantum programs in Lean, achieving order-of-magnitude gains across multiple tasks.
This article introduces a study combining LLM agents with the Lean theorem prover to automatically discover quantum algorithms. Since classical computers can only simulate small-scale quantum programs, the team built a Lean-based quantum program library where agents synthesize programs against formal specifications and verify correctness and cost. Agents collaborate as a team via a wiki and organized meetings, with formal specifications as strict criteria. Results show up to 1.4× improvement in parallel search, 290× in quantum arithmetic, and 11×, 8×, and 2.5× in fusion, photochemistry, and drug metabolism simulations. Limitations include reliance on human judgment for specification accuracy and lack of fine-grained analysis of collaboration mechanisms.
Can quantum computing achieve breakthroughs on hard scientific problems? It depends not only on hardware advances but equally on innovation in quantum algorithms. Traditionally, such algorithmic breakthroughs often require years of collaboration among human experts. A new study demonstrates another path: letting large language model agents automatically synthesize quantum programs in the Lean theorem prover and formally verify their correctness and cost, achieving order-of-magnitude performance improvements across multiple scientific applications.

From Manual Collaboration to an Automated Discovery Loop
In mathematics and computer science, large language models have already accelerated research progress through automated discovery loops. But quantum algorithms face a particular dilemma: classical computers can only evaluate quantum programs on restricted or small-scale instances, and cannot directly verify their performance on large-scale problems. This means that screening quantum algorithms via classical simulation inherently has evaluation blind spots.
The research team's approach was to bypass this blind spot. They built a quantum program library based on the Lean theorem prover, letting large language model agents synthesize novel programs against formalized problem specifications and verify their correctness and cost within the prover. Since formal verification does not depend on running the program itself, this pipeline can handle algorithm designs that neither today's classical computers nor quantum computers can test.
Lean is an interactive theorem prover and also a functional programming language. Its core feature is that it is based on dependent type theory, allowing users to express mathematical propositions as types and proofs as terms constructed for that type, with the kernel checking the correctness of the proof step by step. Compared with similar tools such as Coq and Isabelle, Lean has a more active Mathlib ecosystem for mathematics and friendlier editor integration. In quantum program verification scenarios, researchers can use Lean to define the types and semantics of quantum gates, circuits, and measurement operations, then write requirements such as "a certain program implements a certain algorithm and its gate count does not exceed a certain upper bound" as a formal specification; a program submitted by an agent passes only if it comes with a proof term acceptable to the Lean kernel. Since the checking process relies only on logical deduction rather than actually running the program, the verification results are independent of the scale and noise of quantum hardware—this is precisely why it can evaluate "algorithms that today's computers cannot test."
How the Agent Team Collaborates
The organization of this system is worth noting. The agents do not work alone but collaborate as a team: they share results and knowledge through a wiki and discuss ideas in organized meetings. This structure gives the discovery process a certain "research community" flavor, aggregating scattered agent explorations into collective knowledge accumulation.
Methodologically, the formal specification serves as an explicit criterion. Programs synthesized by agents must pass proof checking in Lean, and incorrect implementations cannot slip through. This is stricter than relying on test cases or heuristic evaluation, and it also provides a reliable basis for reusing results across agents.
A formal specification is a document that uses precise mathematical language to describe "what a program should do." Unlike natural-language requirements or test cases, it leaves no room for ambiguity. In Lean, a specification is usually written as a type proposition, for example: "for any input state, the output of this circuit agrees with the target unitary transformation within a given precision, and the number of ancilla qubits does not exceed k." A program is correct if and only if there exists a proof term for that proposition. The specification plays a dual role as both evaluation criterion and search target: agents not only need to know whether a program passes, but can also use information from failed proofs to locate which constraint was not satisfied, thereby iterating on modifications. It should be emphasized that the specification only guarantees that "the program meets the requirements you wrote." If the specification omits physically important conditions (such as a certain error model or resource constraint), passing verification does not mean the program is truly usable—this is also a risk point specifically highlighted in the limitations section of the original paper.
Order-of-Magnitude Improvements Across Multiple Applications
The results cover several directions. On parallel search, the new method improves over previous baselines by up to 1.4×; on quantum arithmetic, the improvement reaches 290×; and on simulation tasks related to fusion, photochemistry, and drug metabolism, it achieves improvements of 11×, 8×, and 2.5×, respectively.
Among these, the 290× improvement in quantum arithmetic is particularly striking, indicating that formalization-driven automated synthesis can unlock enormous room on highly structured subproblems. The improvements in application directions such as fusion, photochemistry, and drug metabolism point to the practical value of quantum algorithms in scientific computing—these are precisely the scenarios where quantum computing is expected to deliver major advances.
Why Formal Verification Is Key
The correctness of quantum programs is difficult to test by classical means, which is the fundamental reason this study chose Lean. Formal proofs provide correctness guarantees independent of hardware and simulation scale, allowing algorithm design to proceed ahead of executable test environments. In the words of the research team, combining humans and AI at scale under the rigor of mathematical proof lets researchers design algorithms that today's computers cannot test, thereby shortening the path to practical quantum computing.
The deeper significance of this approach lies in changing the pace of algorithm discovery. In the past, quantum algorithm breakthroughs depended on long-term collaboration among a small number of experts; now, an automated discovery loop can continuously produce candidate solutions under formal constraints, with the role of human researchers shifting toward specification design and result selection.
The fundamental difficulty in verifying quantum programs via classical simulation is that the state space grows exponentially with the number of qubits. The state of n qubits requires 2^n complex amplitudes to describe; classical computers are already near their limits simulating around 50 qubits, while practical quantum algorithms often require hundreds or even thousands of logical qubits. Therefore, algorithms screened via simulation remain completely untested in the large-scale regime, and an evaluation blind spot can arise where "performance is good at small scale but fails at large scale." Formal verification bypasses this limitation: it does not enumerate quantum states but performs symbolic deduction on the logical structure of the program, proving that it holds for all inputs. The cost is that writing specifications and proofs itself requires specialized knowledge, and proof search can be very time-consuming—so having large language model agents automatically generate candidate proofs becomes a key enabling technology for applying formal methods to algorithm discovery.
Limitations and Open Questions
One additional point: formal verification guarantees the correctness of a program relative to the specification, but whether the specification itself accurately captures all requirements of the physical problem still depends on human judgment. In addition, the original paper does not provide fine-grained analysis of the diversity and exploration efficiency of agent-generated programs, or of the actual contribution of the meeting and wiki collaboration mechanisms. The magnitude of improvements such as the 290× gain in quantum arithmetic also needs further testing for transferability across broader problem classes.
Overall, this work combines the generative capabilities of large language models, multi-agent collaboration, and the rigor of theorem proving, providing a verifiable automated path for quantum algorithm discovery. It does not rely on larger-scale quantum hardware but instead shortens the distance to practical quantum computing from the algorithm side.
One-line Summary
Large language model agents automatically synthesize and formally verify quantum programs in Lean, achieving order-of-magnitude improvements across multiple tasks.
Paragraph Summary
This article introduces a study that combines large language model agents with the Lean theorem prover to automatically discover quantum algorithms. Because classical computers can only simulate small-scale quantum programs, screening algorithms via simulation has evaluation blind spots; the research team instead built a Lean-based quantum program library, letting agents synthesize programs against formal specifications and verify their correctness and cost in the prover. Agents collaborate as a team, sharing knowledge through a wiki and discussing ideas in organized meetings, while formal specifications serve as a strict evaluation criterion. Results show that the method improves parallel search by up to 1.4×, quantum arithmetic by 290×, and fusion, photochemistry, and drug metabolism simulations by 11×, 8×, and 2.5×, respectively. The article also discusses limitations such as the dependence of specification accuracy on human judgment and the lack of fine-grained analysis of the collaboration mechanisms' contribution.
Related articles

Seven Years of Evolution: How Far Has the Foldable Come From the First Generation?
From the first foldable to today's latest models, what has seven years changed? Shallower creases, higher brightness, thinner bodies, and smoother software migration—has the foldable crossed the chasm from enthusiasts to ordinary users? This article discusses the question based on a video comparison.

When Did Humans Start Eating Salt? A 10,000-Year History of Salt
When did humans start eating salt? From salt use at the dawn of agriculture 11,000 years ago to ancient seawater evaporation and rock salt mining, and on to the salt trade, salt taxes, and Gandhi's Salt March, this article traces salt's key role in human civilization.

Microsoft Paza Research: How African Language Speech Recognition Breaks Through Architecture and Data Bottlenecks
Microsoft's Paza research evaluates 53 speech models across 39 African languages, revealing architecture choice matters more than pre-training coverage, 200-300 hours is the practical data threshold, and language typology deeply influences recognition performance.