New We formalized a quantum mechanics textbook in Lean.
From AI Dreams to Verifiable Science: Building a Machine-Verified Formal Library of Physics
Our new paper releases AxQM, a benchmark of 1,019 machine-checkable proof tasks drawn from a near-complete Lean formalization of Quantum Computation and Quantum Information by Nielsen and Chuang. Our system read the textbook and produced a verified proof for every labeled statement in it, showing that autonomous formalization can bring the rigor of formal mathematics to physics at textbook scale.
- formal methods
- autoformalization
- benchmark
Artificial intelligence is rapidly becoming an indispensable tool in scientific work. Today, AI systems such as Lemma can derive equations, write simulation code, analyze data, and search the scientific literature — all core parts of pushing forward the frontier of science.
As these systems become more capable, a fundamental question remains: how do we know that their conclusions are correct? For science, “seems good enough” is not enough. Worse, as the amount of AI-generated code and scientific text skyrockets, the human task of reviewing AI outcomes has only become more daunting. This verification gap is a real challenge we must address to enable scientists to accelerate their work.
This problem is one of trust, and it is especially acute in the physical sciences. Physical reasoning often combines exact mathematics with approximations, modeling choices, and implicit assumptions about the system at hand. Surfacing those reliably remains an open challenge for the community.
One point of light: in mathematics, the ability to formally prove statements has led to the creation of novel results that humans can trust, because they can understand the definitions and the proofs are machine checkable with complete rigor. Can we do this beyond mathematics?
In our paper “AxQM: A Textbook-Scale Benchmark for Formal Proof Synthesis in a Library of Finite-Dimensional Quantum Mechanics”, we released an open-source benchmark for the machine learning and physics community we call AxQM. This benchmark is based upon our team’s formalization of all of the exercises and homework problems in Quantum Computation and Quantum Information by Nielsen and Chuang, a standard textbook in the field of quantum computing and information theory. We’ve proven it’s possible, and we believe that others can as well.
At Axiomatic AI, our aim is to bring about a paradigm of AI for science: one in which the logical steps produced by an AI can be independently and automatically verified. The highest standard for verified reasoning can be found in formal mathematics: once definitions, theorem statements, and proof steps are precisely written in a formal language, the correctness of these reasoning steps can be checked mechanically according to a small set of rules. This process of converting fuzzy reasoning into exact machine-checkable reasoning is called formalization.
In terms of the details: we asked our system based on Axiomatic Intelligence (AxI) to read Nielsen and Chuang. Autonomously, it formalized almost the entirety of the mathematics-based physical reasoning in the book into a coherent code library in Lean, a formal language in which reasoning can be machine-checked. It filled in a rigorous proof for every labeled statement in the book — theorems, examples, exercises — and each one has been verified by Lean, with many additional checks by human experts to confirm the autonomous system’s outputs conform not just to the letter of the text, but to the intent implicit in the exercises. To show what this looks like concretely, there is an interactive walkthrough at the end of this post: Exercise 12.22, on entanglement conversion, taken from the textbook statement through to the Lean one, with every name in it clickable for its definition.
As our system worked through the textbook, it solved new problems using the definitions, theorems, and earlier solved problems as building blocks, and these new results were immediately added to the expanding library. The outcome is a textbook-scale body of quantum theory that is not only generated by AI, but also formally connected to its foundations in a machine-checkable way.
The opportunity here is to combine two capabilities that have so far rarely come together at scale in physics: automation and rigor. We imagined a type of AI system that can work through scientific material on its own, rigorously understand every statement and assumption, formally check every reasoning step, and continuously build on what it has already established. Every isolated problem solved translates into an ever expanding, richly interconnected body of verified scientific knowledge.
The broader significance goes beyond quantum information. If autonomous formalization can be scaled to other areas of physics, it could provide a new foundation for scientific AI: one in which models do not merely generate answers, but continuously build structured bodies of knowledge whose assumptions, dependencies, and conclusions can be checked. This would make it possible to trace a new result back to the principles it depends on, identify which downstream results are affected when an assumption changes, and correct errors in reasoning. AxQM is therefore not only a benchmark for theorem proving in physics, but also a first step toward AI systems that can build and extend scientific knowledge while keeping the formal part of their reasoning verifiable.
From the textbook to Lean · Interactive walkthrough
Nielsen & Chuang, Chapter 12
Exercise 12.22 — entanglement conversion by local operations with no classical communication
We believe that the formalization is only as good as a human expert’s understanding of it.
To facilitate this understanding, our AI system prepared the following explanation of one formalized exercise in AxQM. It is our goal to pair every autoformalization with an “auto-informalization,” and to continuously improve the quality of both.
1 · The statement in the textbook
Exercise 12.22: (Entanglement conversion without communication) Suppose Alice and Bob are trying to convert a pure state into a pure state using local operations only – no classical communication. Show that this is possible if and only if , where is some real vector with non-negative entries summing to 1, and '' means that the vectors on the left and the right have identical non-zero entries.
Transcribed from Quantum Computation and Quantum Information, Nielsen & Chuang, p. 577.
2 · The dictionary between the book's notation and Lean
ψ φ : (A ⊗ B) — the input and target bipartite pure states. | |
ψ.. — Alice's reduced density operator, Bob's side traced out. | |
| the non-zero spectrum of : its eigenvalues, the squared Schmidt coefficients of . | |
| (“identical non-zero entries”) | — a relation stated directly between the two reduced density operators. |
| x (“some real vector…”) | the spectrum of an ancilla state τ : C. Entries non-negative and summing to 1 automatically, because is a density operator. |
the spectrum of , formed with . |
3 · How to read a Lean statement
Every theorem in the library has one shape. Read the three views left to right: the bare shape, the same slots filled with the physics, then the real Lean statement. The example is the exercise itself, and the colors mean the same thing in all three. This theorem has no assumption. Everything before the colon introduces objects, and the whole exercise sits in the claim, as a biconditional.
theorem ⟨name⟩ ⟨the objects involved⟩ : ⟨what is claimed⟩
: Find the last colon. Everything after it is the claim;
the rest introduces the objects. A theorem may also carry assumptions, written
(h : …) before the colon. This one carries none.
theorem “Exercise 12.22” given pure states |ψ⟩, |φ⟩ on A ⊗ B : |ψ⟩ ⇝ |φ⟩ by local operations, no classical communication ⟺ for some ancilla state τ, ρψ ≅ ρφ ⊗ τ (the book's λψ ≅ λφ ⊗ x, with x = λτ)
The same shape with the physics filled in. This is the book's sentence, both directions in one claim, and none of it is Lean yet.
theorem ① {A : QSystem} {B : QSystem} (ψ φ : PureState (A ⊗ B))② : PureState.ConvertibleNoComm ψ φ ↔③ ∃ (C : QSystem) (τ : State C),④ ψ.toState.reducedLeft.SameNonzeroSpectrum (φ.toState.reducedLeft.tmul τ)⑤
- The name encodes the statement. Read it as ‘convertible-no-comm iff there-exists same-nonzero-spectrum with-tensor’.
- The objects: two pure states on the composite system , and the systems and they live on. Nothing else is given — there is no
(h : …), so the theorem assumes nothing. - After the final colon, the claim.
↔reads “if and only if”, so the claim is both directions of the exercise at once. Its left-hand side is the convertibility predicate, built in § 4. ∃ …,reads “there exist … such that”: some ancilla system carrying a state . The eigenvalue list of is the book's probability vector .- The right-hand side. Read the chain left to right, one
.stepat a time: → its density operator (toState) → Alice's marginal (reducedLeft) → “has the same non-zero spectrum as” → 's marginal tensored with (tmul). Altogether: .
ConvertibleNoComm carries the reading of “local operations, no
classical communication”. It is built in § 4, steps 1–3.
4 · The Lean statement of the exercise
Nielsen & Chuang's Exercise 12.22 says that Alice and Bob can turn a bipartite pure state into using local operations alone, with no classical communication, exactly when for some probability vector . Making that a theorem needs a definite operational meaning for "local operations, no communication", and the biconditional stated over it.
Each card states the claim in ordinary notation, then shows the Lean itself.
- One party's channel — Alice's most general local operation. A definition.
- Both parties at once — the two-sided channel. Still a definition.
- What means — convertibility: some such pair of channels does the job. The last definition.
- The exercise — convertibility iff the spectra match, both directions as one iff. The only claim.
Steps 1–3 build vocabulary; nothing is claimed until step 4. The theorem inherits its meaning from those definitions.
Throughout: and are Alice's and Bob's systems, and , , the ancillas a party may adjoin.
variable {A B C : }
variable {CA CB : } steps 1–3What "local operations without communication" is taken to mean
The book's phrase is informal, so these three definitions come first. Each party's operation is written in Stinespring form: adjoin a pure ancilla , apply a unitary on system-plus-ancilla, discard the ancilla, giving . Bob's acts on the right factor directly. Alice's acts on the left factor and is built from the same construction: swap the two factors, dilate on the (now right-hand) factor, then swap back. The two act on disjoint factors and neither is conditioned on the other's result, which is what "no communication" means here. The composite is deterministic, pure state to pure state, matching "convert into ". The existential quantifier runs over dilation data and , not over an abstract type of trace-preserving local maps, so faithfulness rests on Stinespring's theorem rather than on the definition itself.
dilatedChannelNoComm: Bob's dilation, then Alice's, on disjoint
factors, drawn for the successful conversion the exercise asks about (output ). Each box is a
Stinespring dilation in N&C's Chapter-8 sense, built once in the Chapter-11 file
(Alice's is Bob's conjugated with the swap): adjoin a pure ancilla, run one unitary
over system-plus-ancilla, discard the ancilla. “No communication” is only that neither
box's unitary depends on anything about the other: no measurement or classical bit ever
crosses the dashed line.Alice's local operation — a dilated channel on her factor
Nothing can be claimed until “local operation” is pinned down, so the section builds it first, starting with one party:
Alice's half of a local operation: , with . It takes a bipartite state on , a unitary acting on and an ancilla prepared in a pure state , and returns the state after swapping the two factors, running the Chapter-8 dilation on the (now right-hand) A factor, and swapping back.
noncomputable def (ρ : (A ⊗ B)) (U : (A ⊗ C))
(ω : C) : (A ⊗ B) :=
( B A)
(( ( A B) ρ). U ω)The two-sided operation — both parties act on their own factor
One party's channel exists; now let both act, each on its own factor:
The operation the exercise quantifies over: . Given a bipartite state on , Alice's dilation data on and Bob's on , it applies Bob's local channel and then Alice's. The two act on disjoint factors, so the order of application is immaterial.
noncomputable def (ρ : (A ⊗ B)) (UA : (A ⊗ CA))
(UB : (B ⊗ CB)) (ωA : CA) (ωB : CB) : (A ⊗ B) :=
(ρ. UB ωB). UA ωAThe convertibility predicate — what “” means
With both channels defined, the conversion target can be named. The exercise is stated over this definition:
holds when there are ancilla systems CA, CB, a unitary acting on and a unitary acting on , and pure states for the ancillas to start in, such that running Bob's dilated channel then Alice's carries exactly to . Each unitary touches one party's side only, and neither depends on the other's outcome.
def {A B : } (ψ φ : (A ⊗ B)) : Prop :=
∃ (CA : ) (CB : ) (UA : (A ⊗ CA)) (UB : (B ⊗ CB))
(ωA : CA) (ωB : CB),
φ. = ψ.. UA UB ωA ωBstep 4The exercise: convertibility iff
The book's is the list of eigenvalues of the reduced state , i.e. the squared Schmidt coefficients of , and means "identical non-zero entries" — realised here as a relation directly between the two reduced density operators, comparing their non-zero eigenvalues. The book's probability vector appears as the eigenvalue list of an ancilla density operator , so its entries are automatically non-negative and sum to one, and appears as the spectrum of .
The exercise: convertibility
The exercise itself:
For any two bipartite pure states : if and only if there is an ancilla state with — the book's , with the spectrum of .
sorry is Lean's placeholder for a missing proof. It stands here on purpose: the statement is what the benchmark asks a model to prove, so the proof is removed. The real one lives in a solution library we keep private.
theorem
{A : } {B : } (ψ φ : (A ⊗ B)) :
ψ φ ↔
∃ (C : ) (τ : C),
ψ... (φ... τ) := sorry