Textbook / teaching anchor
Basics of quantum information
“quantum state vectors are unit vectors with respect to the Euclidean norm.”
Beginner-friendly state-vector, measurement, multi-system, and circuit explanations.
Beginner layer · before the formal matrix API
Do not start by thinking about a mysterious physical particle. For the algorithms in this library, start with two labels, |0⟩ and |1⟩, and attach a complex amplitude to each.
Textbook / teaching anchor
“quantum state vectors are unit vectors with respect to the Euclidean norm.”
Beginner-friendly state-vector, measurement, multi-system, and circuit explanations.
Textbook / teaching anchor
Standard textbook reference for quantum mechanics, qubits, gates, and the circuit model.
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
“quantum state vectors are unit vectors with respect to the Euclidean norm.”
Beginner-friendly state-vector, measurement, multi-system, and circuit explanations.
Textbook / teaching anchor
Standard textbook reference for quantum mechanics, qubits, gates, and the circuit model.
Learn Lean while learning quantum computing
abbrev Matrix (rows cols : Nat) (α : Type u) := Fin rows → Fin cols → α
`Fin 2` means exactly two legal indices. Lean makes an out-of-range basis label impossible to type.
The full proof-backed declarations for this chapter are shown immediately below.
Shared foundations · Chapter 1 of 9
Fix the finite matrix model, pointwise equality, dimensions, and resource records used by every later certificate.
QuantumBlockEncoding/Core.leanQuantumBlockEncoding/Resources.leanTextbook lesson
A quantum state is a complex column vector. For n qubits its dimension is 2^n, so every basis label is a finite index from 0 to 2^n-1.
The amplitudes are complex numbers and the squared magnitudes sum to one. An unnormalized data vector must be rescaled before it can be the exact output of a unitary.
ASPBE fixes column-vector, left-action semantics. This convention determines gate order, first-column state preparation, and clean-block indices.
Lean does not accept a diagram as evidence. It checks each finite index, or a reusable theorem that implies all of those entry equalities.
Before continuing, be able to explain why a one-qubit gate is a 2 by 2 matrix and a two-qubit gate is a 4 by 4 matrix.
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 TB Core["Core / Resources"] --> State["StatePreparation"] Core --> Circuit["Circuit"] Circuit --> Sem["CircuitSemantics"] Core --> Block["BlockEncoding"] State --> Classics["BlockEncodingClassics"] Sem --> Classics Block --> Classics Classics --> Case1["ColdStartTransferE1<br/>BE Case 1"] Classics --> Case2["CubicStatePreparation<br/>BE Case 2"] Classics --> Paper["GHL2025 / RobinHeat"] State --> Case2 Auto["Automation / Literature<br/>OpenProblems"] --> Case1 Auto --> Case2
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.Matrix.PointwiseEq
Two finite matrices are equal when every indexed entry agrees.
Matrix goals become explicit finite entry goals that Lean can rewrite. Block extraction and candidate validation are ultimately entrywise claims.
Expose row and column indices, prove the scalar equality, then recover matrix equality.
QuantumBlockEncoding.Matrix| Mathematical step | Lean object or step |
|---|---|
| Choose arbitrary indices. | intro i j |
| Reduce the matrix claim to the selected entry. | apply Matrix.ext |
def PointwiseEq {rows cols : Nat} {α : Type u}
(a b : Matrix rows cols α) : Prop :=
∀ i j, a i j = b i j
/-- The zero finite matrix. -/
Local declaration · Verso Blueprint · commit-pinned GitHub source
Lean result
QuantumBlockEncoding.Resource
A candidate carries named resource counts instead of an informal cost label.
The proof object and the engineering cost can be compared without conflating them. Candidate search needs deterministic, auditable scoring fields.
Represent each resource coordinate as data and derive decidable comparison support.
QuantumBlockEncoding.gridSizeQuantumBlockEncoding.ExecutableResourceCertificate.resource_eq_program_resourceQuantumBlockEncoding.ExecutableResourceCertificate.cost_gateCountQuantumBlockEncoding.ExecutableResourceCertificate.cost_depth| Mathematical step | Lean object or step |
|---|---|
| Store each cost coordinate. | structure Resource |
| Expose values to scoring and export code. | deriving Repr |
structure Resource where
oneQubit : Nat := 0
cnot : Nat := 0
oracleCalls : Nat := 0
pureAncilla : Nat := 0
depth : Nat := 0
deriving Repr, DecidableEq
Local declaration · Verso Blueprint · commit-pinned GitHub source