Lean-QuantumAlg: A Framework for AI Agents to Produce Quantum Algorithms that Humans Can Trust
Lei Zhang, Mingrui Jing, Yusheng Zhao, Jiahong Liu, Xin Wang
quant-ph
Oct 21, 2026 · v2
TL;DR
Builds a Lean 4 framework on Mathlib for certifying quantum algorithms' correctness and resource bounds, with nine AI-formalized algorithms.
Abstract
AI agents are increasingly capable of constructing quantum algorithms and proofs, yet machine-checked proofs alone cannot guarantee that the intended problem is solved or that resource claims match the verified computation. Here we introduce Lean-QuantumAlg, a Lean 4 framework for trustworthy AI-assisted development of quantum algorithms. Its Algorithm-Solves-Problem contract binds correctness, success probability, borrowed-state restoration and quantum and classical resource bounds to a single execution, while separating the guarantees that Lean checks from the problem specifications and execution models that humans review. We demonstrate the framework on nine AI-formalized quantum algorithms, from Grover search to quantum attacks on RSA-2048 and P-256, with less than 1% of each algorithm's imported source code requiring statement-level human review once the shared framework has been audited. By integrating reusable mathematical foundations, certified algorithmic primitives and execution-grounded verification, Lean-QuantumAlg provides a basis for AI agents to construct and certify quantum algorithms, opening a path toward scalable AI-driven discovery of quantum algorithms.
Problem
AI agents can produce quantum algorithms with machine-checked proofs. Checked proofs alone do not guarantee that the formal statement captures the intended problem, or that resource claims match the verified computation.
Approach
Lean-QuantumAlg is a Lean 4 library built on Mathlib. It defines execution models with model-owned tokens for gates, oracles and classical operations, together with Problem, Algorithm and a Solves relation. Solves binds correctness, success probability, borrowed-state restoration and quantum/classical resource bounds to a single execution. Each algorithm ends in a theorem main asserting that some Algorithm solves its Problem, so human review concentrates on the problem specification and the execution model.
Results
Nine AI-formalized quantum algorithms were certified, ranging from Grover search to quantum attacks on RSA-2048 and P-256. Once the shared framework has been audited, less than 1% of each algorithm's imported source code requires statement-level human review.