Textbook / teaching anchor
Basics of quantum information
Beginner-friendly state-vector, measurement, multi-system, and circuit explanations.
Beginner layer · first ASPBE problem
You know the desired amplitudes. The construction problem is to find a unitary whose action on the easy input |0…0⟩ produces exactly those amplitudes.
Textbook / teaching anchor
Beginner-friendly state-vector, measurement, multi-system, and circuit explanations.
Textbook / teaching anchor
Foundations, entanglement, circuits, algorithms, and error correction.
Strict mathematics, after the picture
Every symbol used here is connected below to a compiled declaration or a clearly marked research-source formula.
Textbook / teaching anchor
Beginner-friendly state-vector, measurement, multi-system, and circuit explanations.
Textbook / teaching anchor
Foundations, entanglement, circuits, algorithms, and error correction.
Learn Lean while learning quantum computing
structure ComplexStatePreparationCertificate where
target
gate
normalizationProof
preparationProof
The circuit, target, and proofs travel together. A downstream theorem cannot accidentally forget normalization or unitarity.
The full proof-backed declarations for this chapter are shown immediately below.
State preparation · Chapter 3 of 9
Ask one concrete question: which unitary sends the all-zero basis state to the normalized state we want?
QuantumBlockEncoding/StatePreparation.leanQuantumBlockEncoding/ConcreteSemantics.leanQuantumBlockEncoding/TextbookStatePreparation.leanTextbook lesson
State preparation asks for one observable action: start in the all-zero basis state and end at a specified normalized target.
The input is fixed, but U must still be a unitary on the whole 2^n-dimensional space. Specifying only the desired output vector is not yet a circuit.
X exchanges the two computational-basis states. The formal example represents X as Mathlib's swap matrix and obtains unitarity from self-invertibility.
The plus state has two equal amplitudes. Lean separately proves the square-root normalization, H's unitary equation, and the zero-state action.
Open both complete certificates below and identify the exact line that proves normalization, unitarity, and preparation.
Mathematical order and conventions adapted from Lin, Lecture Notes on Quantum Algorithms for Scientific Computation. The formal checkpoints and ASPBE status distinctions are specific to this library.
Route at a glance
flowchart LR T["Target state<br/>|ψ⟩"] --> N["Check normalization<br/>⟨ψ|ψ⟩ = 1"] N --> C["Choose a circuit<br/>or unitary completion"] C --> U["Prove U is unitary"] C --> A["Prove the state action<br/>U|0ⁿ⟩ = |ψ⟩"] U --> L["Lean state-preparation<br/>certificate"] A --> L L --> E["Export one certified<br/>finite instance"] classDef target fill:#ffffff,stroke:#6b6045,color:#222222,stroke-width:1.5px; classDef work fill:#ffffff,stroke:#64747a,color:#222222,stroke-width:1.25px; classDef proof fill:#ffffff,stroke:#2f7355,color:#18382b,stroke-width:1.5px; class T,N target; class C,U,A work; class L,E proof;
Selected declarations
A compiled route means that the reusable theorem or constructor and at least one finite witness compile. Hardware- and problem-specific downstream instantiations are out of scope, not universal claims made by these cards.
Lean result
QuantumBlockEncoding.TextbookStatePreparation.hadamardCertificate_prepares_plus
The standard Hadamard matrix is proved unitary and maps the zero ket to the normalized equal superposition.
The first column of H contains the two target amplitudes, both equal to one over square root two. This is the smallest complete example where normalization is genuinely more than a basis-vector check.
Prove the square-root identity, check H times its conjugate transpose is identity, and identify column zero with the target vector.
QuantumBlockEncoding.TextbookStatePreparation.hadamard_unitary; QuantumBlockEncoding.TextbookStatePreparation.plusTarget_normalized| Mathematical step | Lean object or step |
|---|---|
| Prove the target has norm one. | plusTarget_normalized |
| Prove the matrix is unitary. | hadamard_unitary |
| Evaluate H on the zero ket. | hadamard_prepares_plus |
| Package all three facts. | hadamardCertificate |
theorem hadamardCertificate_prepares_plus :
applyVec hadamardCertificate.gate.matrix (zeroKet 1) =
hadamardCertificate.target.amplitudes :=
hadamardCertificate.preparesVector
Local declaration · Verso Blueprint · commit-pinned GitHub source
Lean result
QuantumBlockEncoding.TextbookStatePreparation.pauliXCertificate_prepares_one
The Pauli X permutation is proved unitary and sends the zero basis state to the one basis state.
X swaps the two basis columns; selecting its first column therefore gives the one-state amplitudes. It gives beginners a complete certificate without irrational amplitudes or hidden analytic assumptions.
Use Mathlib's swap matrix, its self-inverse theorem, and the basis-ket column-selection lemma.
QuantumBlockEncoding.TextbookStatePreparation.pauliX_unitary; QuantumBlockEncoding.TextbookStatePreparation.oneTarget_normalized| Mathematical step | Lean object or step |
|---|---|
| Represent X as a swap matrix. | pauliX |
| Use self-inverse to prove unitarity. | pauliX_unitary |
| Select the zero-input column. | pauliX_prepares_one |
| Package the certificate and cost. | pauliXVerified |
theorem pauliXCertificate_prepares_one :
applyVec pauliXCertificate.gate.matrix (zeroKet 1) =
pauliXCertificate.target.amplitudes :=
pauliXCertificate.preparesVector
/-- The certified Hadamard example prepares the equal superposition. -/
Local declaration · Verso Blueprint · commit-pinned GitHub source
Lean result
QuantumBlockEncoding.StatePreparationCandidate.preparesTarget
The candidate unitary prepares the target from the zero basis state.
The target amplitudes are the first column of the unitary matrix. It gives state preparation its own acceptance test, independent of any later use in block encoding.
Unfold the candidate action on the zero basis vector and compare every amplitude.
QuantumBlockEncoding.StatePreparationTarget; QuantumBlockEncoding.StatePreparationCandidateQuantumBlockEncoding.StatePreparationCandidate.certifyQuantumBlockEncoding.StatePreparationCandidate.certify_firstColumn| Mathematical step | Lean object or step |
|---|---|
| Select the all-zero input column. | candidate.unitary row (zeroBasisIndex qubits) |
| Match it with the requested amplitude. | = candidate.target.amplitudes row |
def preparesTarget (candidate : StatePreparationCandidate α qubits) : Prop :=
FirstColumnMatches candidate.unitary candidate.target
/-- Reuse the block-encoding resource order for state-preparation candidates. -/
Local declaration · Verso Blueprint · commit-pinned GitHub source