Discovering formally verified quantum programs with AI
Abstract: The timeline by which quantum computers can solve breakthrough problems in science depends on improved quantum algorithms as much as on better hardware. Such algorithmic advances are typically achieved through many years of expert human collaboration. In mathematics and computer science, LLMs have accelerated progress through automated discovery loops. However, quantum algorithms can only be evaluated by classical computers on restricted or small instances. Here we demonstrate automated discovery of quantum programs beyond these regimes including order-of-magnitude improvements on scientific applications. To achieve this, we build a quantum program library in the Lean theorem prover in which LLM agents synthesize novel programs against formal problem specifications and verify their correctness and cost. Agent teams collaborate, sharing results and knowledge through wikis and discussing ideas at organized conferences. Our results improve on prior baselines for parallel search (up to 1.4x), quantum arithmetic (290x), and simulations relevant to fusion, photochemistry and drug-metabolism by 11x, 8x and 2.5x respectively. Combining human and artificial intelligence at scale, under the rigor of mathematical proof, lets researchers design algorithms that today's classical and quantum computers cannot test, shortening the path to practical quantum computation.
Paper Prompts
Sign up for free to create and run prompts on this paper.
Explain it Like I'm 14
1. What is this paper about?
This paper is about using artificial intelligence to invent better quantum-computer programs.
Quantum computers work differently from ordinary computers. They may one day help scientists study medicines, chemical reactions, fusion energy, and other difficult problems. However, designing quantum programs is very complicated and usually requires years of work by expert scientists.
The researchers created a system in which AI agents suggest new quantum programs. A special mathematical computer program then checks whether those suggestions are actually correct and how expensive they would be to run.
The paper’s main idea is:
AI can help discover new quantum algorithms, while formal mathematical proofs make sure the algorithms are not wrong.
2. What questions did the researchers ask?
The researchers wanted to find out whether AI could:
- Invent new quantum programs, rather than only repeat programs already known by humans.
- Discover programs that are too large or complicated to test on today’s ordinary computers.
- Prove that the programs give the correct answers.
- Calculate how many qubits and operations the programs need.
- Improve existing quantum algorithms for scientific problems.
A qubit is the quantum version of a computer bit. A normal bit is either 0 or 1, while a qubit can behave like a mixture of 0 and 1 until it is measured.
The researchers also asked whether several AI agents working together would be more effective than one AI agent. Their system allowed agents to share ideas, successful solutions, mistakes, and unfinished attempts.
3. How did they do the research?
Writing quantum programs
The researchers built a library of quantum-programming tools inside a system called Lean. Lean is a computer program that checks mathematical proofs.
They also used a formal system called quantum Hoare logic. This is a way to describe what a program should do using three parts:
- Starting conditions: What must be true before the program begins.
- The program itself: The instructions the computer follows.
- Ending conditions: What should be true after the program finishes.
This is similar to saying:
If a recipe starts with the correct ingredients and you follow every step, the finished dish should have the expected result.
For a quantum program, the “ingredients” might be the starting state of the qubits, and the “finished dish” is the final quantum state or answer.
Using AI agents
The researchers gave AI agents a formal problem specification. This specification explained:
- What the program must calculate.
- What rules it must obey.
- How much it is allowed to cost in qubits and operations.
The AI agents then proposed possible programs. Lean checked each proposal. If there was an error, the agents received feedback and tried again.
The agents also worked as a team:
- They stored useful discoveries in a shared wiki.
- They discussed ideas in virtual “conferences.”
- They shared failed attempts so that other agents would not repeat the same mistakes.
- Independent checking systems reviewed the proposed proofs.
This is important because an AI system can produce convincing-looking but incorrect answers. Lean acts like a very strict referee: it accepts a result only when the mathematical proof is valid.
Measuring program cost
The researchers measured resources such as:
- The number of qubits needed.
- The number of important quantum operations needed.
- The total amount of computation.
For some programs, they used a measure called , where:
- is the number of qubits.
- is the number of costly gates.
The goal was to make this total smaller. A smaller cost means that a future quantum computer may be able to run the program more easily.
4. What did they find?
The AI system discovered formally verified improvements in several areas. According to the paper, the new programs were better than earlier methods by the following amounts:
| Problem | Improvement reported |
|---|---|
| Parallel search | Up to $1.4$ times better |
| Quantum arithmetic for computing | Up to $290$ times better |
| Fusion-related simulation | About $11$ times better |
| Photochemistry-related simulation | About $8$ times better |
| Drug-metabolism simulation | About $2.5$ times better |
The researchers studied five main types of problems, including:
- Computing the mathematical function .
- Searching many possibilities in parallel.
- Simulating energy levels in molecules.
- Studying fusion particles.
- Modeling chemical reactions connected to medicines.
The most dramatic improvement was in the quantum arithmetic example. The system found a way to calculate using far fewer resources than the earlier method.
The paper also emphasizes that some of these programs are too large to test directly on today’s classical computers. Instead, their correctness was checked using mathematical proofs. This allowed the researchers to study algorithms for quantum computers that do not yet exist.
5. Why are these findings important?
Quantum computers are expected to be useful for problems that are extremely difficult for ordinary computers. However, useful quantum computers will need to perform huge numbers of operations accurately.
Better algorithms can reduce the amount of hardware needed. For example, if a new algorithm needs ten times fewer operations, a future quantum computer may be able to solve the problem sooner or with fewer qubits.
The research is also important because it combines two strengths:
- AI is good at trying many possible ideas quickly.
- Formal mathematics is good at checking whether an idea is truly correct.
This is similar to having a very creative inventor working together with an extremely careful inspector. The inventor suggests unusual designs, while the inspector checks that they follow all the rules.
6. Possible impact of the research
If this approach works well, it could speed up the development of quantum computing. Scientists might use AI to discover algorithms for:
- Designing new medicines.
- Understanding chemical reactions.
- Improving batteries and materials.
- Studying fusion energy.
- Solving difficult search and optimization problems.
The system could also change how scientists work. Instead of spending most of their time manually writing and checking every quantum circuit, researchers could focus more on:
- Describing the scientific problem.
- Deciding what a good solution should achieve.
- Understanding what the resulting algorithm means.
However, the research does not mean that useful quantum computers are available now. The programs still need future quantum hardware, and the claimed improvements will need to be studied and tested by other researchers.
Simple conclusion
This paper shows a new way to use AI for quantum-computer research. AI agents create possible programs, and the Lean system proves whether those programs are correct and estimates their cost. The researchers report large improvements for several important problems.
The main message is that creative AI plus strict mathematical checking may help scientists design powerful quantum algorithms faster than humans working alone.
Practical Applications
Immediate Applications
- Formally verified quantum-program development tools (software, quantum computing; deployable now)
- Package the Lean-based quantum program library, quantum Hoare logic, correctness proofs, and resource-counting mechanisms as a developer toolkit or research platform.
- A practical workflow would allow researchers to specify a target computation and resource bound, generate candidate programs with LLM agents, and accept only candidates whose correctness and cost proofs pass the Lean kernel.
- Potential products: Lean libraries for quantum algorithms, IDE plugins, proof-checking services, and APIs connecting LLM coding agents to quantum-program verification.
- Dependencies: Continued maintenance of the formal library; integration with existing circuit languages and hardware SDKs; sufficient documentation and training data for users unfamiliar with Lean and quantum Hoare logic.
- Pre-hardware validation of quantum algorithms (quantum-computing R&D; deployable now)
- Use formal proofs to evaluate algorithms that cannot be tested on current quantum processors or simulated classically, including algorithms requiring thousands of logical qubits.
- This can replace incomplete numerical testing with machine-checked guarantees about functional correctness, qubit requirements, expected costs, worst-case costs, and gate counts.
- Potential workflow: specify an algorithm independently of hardware, prove its abstract correctness, optimize its logical resources, and later compile it to a target fault-tolerant architecture.
- Dependencies: The formal model must accurately represent the intended computational model, fault-tolerant gate set, and cost metric. A proof of the abstract algorithm does not by itself guarantee performance on noisy physical hardware.
- Automated quantum-circuit and arithmetic optimization (quantum hardware and compiler engineering; deployable now for research and simulation)
- Apply the discovery framework to optimize arithmetic subroutines, inverse trigonometric functions, search procedures, and other reusable primitives.
- The reported improvements—including a reduction for and improvements to parallel search—could inform quantum compiler libraries and benchmark suites.
- Potential tools: verified replacements for arithmetic kernels, resource-aware compiler passes, and catalogs of formally certified circuits indexed by qubit count and -gate cost.
- Dependencies: Improvements are tied to the paper’s specifications and cost model. They must be independently benchmarked under the constraints of particular hardware architectures, connectivity graphs, error-correction schemes, and fault-tolerant gate libraries.
- Resource estimation for quantum-computing investment and planning (industry strategy, hardware roadmaps, policy; deployable now)
- Use machine-checked resource bounds to compare candidate algorithms before committing to hardware development or large-scale experimental programs.
- Hardware companies could use the verified estimates to identify whether a proposed application fits projected logical-qubit and operation budgets.
- Potential outputs: transparent resource-estimation reports, algorithm–hardware co-design dashboards, and procurement or roadmap models based on reproducible proof artifacts.
- Dependencies: Estimates must include compilation overhead, error correction, routing, magic-state factories, measurement costs, and classical control overhead; otherwise they may substantially understate real deployment costs.
- Reproducible collaboration infrastructure for quantum-algorithm research (academia and industrial laboratories; deployable now)
- Adopt the paper’s shared wiki, independent verification, agent-team, and scheduled “conference” workflow for collaborative algorithm discovery.
- Research groups can record successful approaches, failed attempts, partial proofs, and resource comparisons, reducing duplicated work and preserving negative results.
- Potential products: version-controlled quantum-algorithm knowledge bases, proof-aware experiment trackers, and multi-agent research orchestration systems.
- Dependencies: Clear authorship and credit policies, protection of confidential industrial research, reproducible software environments, and human review of specifications and agent-generated claims.
- Education and training in verified quantum programming (academia and professional education; deployable now)
- Use the formal specifications and proof obligations as advanced teaching materials for quantum computing, formal methods, programming languages, and algorithm design.
- Students can modify a quantum program, attempt an optimization, and receive kernel-level feedback when correctness or resource arguments fail.
- Potential tools: interactive notebooks, verified quantum-programming assignments, and automated tutors that explain failed proof obligations.
- Dependencies: The current formalism may have a steep learning curve and may require simplified interfaces, educational examples, and integration with conventional quantum languages such as Qiskit or Cirq.
- Formal benchmarking and auditing of AI-generated quantum code (software assurance and AI governance; deployable now)
- Treat the Lean kernel as an independent acceptance layer for quantum programs generated by LLMs. Candidate code can be rejected when it fails a theorem, violates a resource bound, or exploits an incorrectly specified interface.
- This is particularly useful for reducing hallucinated gates, invalid state transformations, and unsupported asymptotic claims in AI-assisted quantum software.
- Dependencies: Formal verification only protects properties included in the specification. Incomplete specifications, incorrect axioms, or bugs in translations from hardware languages can still produce misleading assurance.
Long-Term Applications
- Verified quantum simulation for fusion and plasma physics (energy and high-energy physics; requires fault-tolerant quantum hardware)
- The reported reduction in the cost of alpha-particle stopping-power simulations could eventually support quantum simulations of energy deposition and plasma behavior in fusion systems.
- A mature workflow could generate formally certified simulation kernels, connect them to plasma models, and execute them on fault-tolerant quantum processors.
- Dependencies: The claimed resource reductions must be validated against complete physical models, realistic precision requirements, state-preparation and readout costs, and hardware capable of supporting the required logical qubits and operations.
- Quantum chemistry and photochemistry simulation (chemicals, materials, energy; long-term)
- The framework could produce optimized, formally verified algorithms for molecular energy levels, excited-state dynamics, and non-Born–Oppenheimer processes.
- Potential applications include catalyst discovery, photochemical reaction design, battery materials, solar-energy conversion, and molecular spectroscopy.
- Dependencies: Practical value depends on achieving chemically meaningful precision, efficient state preparation, treatment of electron correlation, favorable end-to-end runtime, and access to thousands of error-corrected qubits. The paper’s resource reductions are algorithmic and do not yet establish commercial quantum advantage.
- Drug discovery and pharmacology based on cytochrome P450 simulation (healthcare and pharmaceuticals; long-term)
- The cytochrome P450 results could contribute to quantum workflows for predicting drug metabolism, metabolic pathways, toxicity, and drug–enzyme interactions.
- A future product might combine formally verified quantum subroutines with classical molecular-dynamics, docking, and pharmacokinetic pipelines.
- Dependencies: Molecular models must be sufficiently accurate for biological predictions; simulations must represent environmental effects and conformational dynamics; and results require experimental and clinical validation. Formal correctness of the quantum routine does not validate the biological model or establish medical efficacy.
- Automated algorithm discovery for large-scale scientific computing (research automation across physics, chemistry, materials, and engineering; long-term)
- Multi-agent systems could search over algorithmic abstractions rather than only circuit-level substitutions, discovering new methods for Hamiltonian simulation, quantum linear algebra, optimization, and differential-equation solving.
- Shared knowledge bases and independent proof agents could allow thousands of specialized agents to explore alternatives while preserving mathematical guarantees.
- Dependencies: The approach must scale to larger specifications, richer programming languages, more expressive cost models, and substantially longer proofs. Agent coordination, computational cost, and the risk of search stagnation also require evaluation.
- Verified quantum compiler stacks with hardware-aware optimization (quantum software and hardware; long-term)
- The formal layer could eventually extend from abstract quantum programs to complete compiler pipelines: logical algorithm, fault-tolerant decomposition, qubit routing, error-correction scheduling, and physical execution.
- A compiler could emit both executable circuits and machine-checkable certificates that the compiled circuit preserves the original specification and remains within a resource budget.
- Dependencies: Formal models of noise, leakage, measurement, timing, connectivity, magic-state production, and architecture-specific error correction are needed. Proofs must also account for compiler transformations that currently occur outside the abstract algorithmic model.
- Safety and certification standards for quantum software (policy, regulated industries, and critical infrastructure; long-term)
- Regulators and standards bodies could require proof-carrying quantum software for applications involving cryptography, finance, energy systems, or safety-critical scientific decisions.
- Certification packages could include the formal specification, verified implementation, resource bounds, compiler assumptions, and independent reproduction instructions.
- Dependencies: Standards must define acceptable proof systems, trusted kernels, audit procedures, model-update requirements, and how to handle hardware noise and probabilistic outputs. Formal certification should complement—not replace—empirical validation and security analysis.
- Cryptographic and financial optimization workflows (cybersecurity and finance; long-term)
- The same discovery methodology could search for verified quantum procedures for cryptanalysis, amplitude estimation, portfolio optimization, risk estimation, and combinatorial search.
- Financial institutions could use verified resource estimates to assess whether a proposed quantum method could outperform classical methods under realistic cost and error assumptions.
- Dependencies: The paper does not demonstrate practical cryptanalytic or financial advantage. Applications depend on suitable problem formulations, data loading costs, privacy protections, classical baselines, and fault-tolerant machines with sufficient scale. Formal correctness also cannot guarantee economic profitability or security against implementation-level attacks.
- Human–AI research systems for mathematically rigorous discovery (general academia and industrial R&D; long-term)
- The paper’s broader model—human-authored specifications, heterogeneous AI agents, shared memory, adversarial review, and independent proof checking—could be transferred to mathematics, robotics, control, formal software engineering, and scientific modeling.
- In daily professional use, researchers could delegate routine design-space exploration to agents while retaining responsibility for objectives, assumptions, interpretation, and experimental validation.
- Dependencies: Generalization requires domain-specific formal languages and proof libraries, reliable agent communication, safeguards against specification gaming, and evaluation of whether AI-generated discoveries remain interpretable and scientifically useful.
Glossary
- Asymptotic algorithm: An algorithm analyzed according to how its resource requirements grow as the input size approaches infinity. “resource reductions across asymptotic algorithms and large-scale scientific simulations”
- Automated reasoning: The use of computational systems to derive conclusions or proofs without direct human intervention. “LLMs are rapidly advancing mathematics and classical algorithms via execution-based search and automated reasoning”
- Born–Oppenheimer dynamics: Molecular dynamics that does not assume the separation of nuclear and electronic motion used in the Born–Oppenheimer approximation. “non-Born--Oppenheimer molecular dynamics”
- Classical–quantum programming language: A programming language that combines classical control structures with quantum operations. “combining a classical-quantum programming language, a classical-quantum [PERSON_NAME] logic to reason about program correctness”
- Cytochrome P450: A family of enzymes involved in oxidation and drug metabolism, studied here through quantum simulation. “cytochrome P450 energy levels”
- Error-corrected qubit: A logical qubit protected from physical hardware errors through quantum error-correction procedures. “thousands of error-corrected (logical) qubits”
- Fault-tolerant quantum processor: A quantum computer designed to perform reliable computation despite noisy physical components. “early fault-tolerant processors”
- Formal verification: The use of mathematical representations and mechanically checked proofs to establish that a system satisfies specified properties. “Formally Verified Multi-Agent Discovery”
- Grover search: A quantum search algorithm that provides a quadratic speedup for unstructured search problems. “parallel search~\cite{grover1996fast}”
- Lean kernel: The trusted core of the Lean theorem prover that checks the validity of definitions, terms, and proofs. “agent team, which iterates on error feedback from the Lean kernel”
- Logical qubit: An error-protected qubit encoded using multiple physical qubits. “better logical qubits from noisy physical qubits”
- Machine-checked proof: A proof whose correctness is verified by a formal proof assistant rather than assessed solely by human inspection. “circuits with machine-checked proofs of correctness and cost”
- Mid-program qubit measurement: Measurement of a quantum state during program execution, potentially influencing subsequent classical or quantum operations. “mid-program qubit measurement”
- Multi-agent workflow: A computational process in which multiple autonomous agents collaborate on a shared task. “engineer a multi-agent research workflow built around it”
- Numerical heuristic: An approximate computational technique used to guide search or find useful solutions without guaranteeing optimality. “with access to tools such as numerical heuristics where they are effective”
- Parallel search: A search procedure that distributes or performs multiple search operations concurrently. “Parallel [PERSON_NAME] search”
- Quantum arithmetic: The implementation of arithmetic operations using quantum circuits or quantum algorithms. “quantum arithmetic~\cite{haner2018optimizing}”
- Quantum error correction: Techniques for detecting and mitigating errors in quantum information without directly measuring the encoded quantum state. “improvements in hardware and quantum error correction”
- Quantum–Hoare logic (QHL): A formal logic for specifying and proving properties of programs that manipulate quantum and classical data. “a Lean~\cite{demoura2021lean4} verification library based on quantum [PERSON_NAME] logic (QHL)”
- Quantum program synthesis: The automated generation of quantum programs or circuits that satisfy specified functional and resource requirements. “LLM agents synthesize novel programs against formal problem specifications”
- Quantum resource counting: The formal measurement of computational resources such as qubits and quantum gates required by an algorithm. “support for resource counting”
- Quantum supremacy/reach beyond classical simulation: The ability of a quantum computation to address instances that cannot feasibly be simulated by classical computers. “Beyond classical simulation”
- Spacetime cost: A fault-tolerant quantum-computing cost metric obtained by multiplying the number of qubits by the number of costly operations, such as gates. “For fault-tolerant circuits we use the spacetime cost ”
- Stopping power: The rate at which a material or medium removes energy from a moving particle. “fusion alpha-particle stopping power”
- Theorem prover: A software system that formally checks mathematical statements and proofs expressed in a formal language. “the Lean theorem prover”
- Unitary transformation: A reversible quantum operation represented mathematically by a unitary operator that preserves quantum-state norms. “unitary transformations”
- Weakest precondition: The least restrictive condition on a program’s initial state that guarantees a specified postcondition after execution. “Triples are proved backwards from the postcondition by computing the weakest preconditions for each step of the program”
- [PERSON_NAME] triple: A formal specification consisting of a precondition, a program, and a postcondition used to state program-correctness properties. “Correctness theorems are formulated as so-called [PERSON_NAME] triples of (precondition, program, postcondition)”