Qubit states #
An n-qubit pure state is a unit vector in ℂ^(2^n) with the L2 inner
product. The raw Hilbert-space vector type is StateVector n; PureState n
bundles such a vector with its unit-norm proof.
Naming: PureState, not State #
In quantum mechanics the general notion of a state is a density operator
(density matrix); pure states are the special case of a closed system with
maximal knowledge. The algorithms in this library live entirely in that
special case (pure state + unitary evolution + projective measurement), but
the library does not redefine the standard term: this type is PureState,
and the bare name State is deliberately left undefined, reserved for the
density-operator concept should the library later introduce mixed states
(a pure state then embeds as the rank-one projector |ψ⟩⟨ψ|).
Conventions #
- Endianness: computational basis states of an
n-qubit register are labelled byn-bit strings read as integers0, …, 2^n - 1[dW19, qcnotes.tex:587], leftmost bit most significant. We index qubits left to right, so the basis labelx : Fin (2 ^ n)encodes|q₀ q₁ … q_{n-1}⟩withx = Σ qᵢ · 2^(n-1-i): qubit 0 carries the most significant bit. - Normalization is part of
PureState: every value carries a proof that its underlying vector has norm1. Linear combinations live at the rawStateVectorlayer until separately proved normalized. - Components are accessed by plain application
ψ i; the underlying vector ofψ : PureState nis(ψ : StateVector n).
Main definitions #
LeanPool.LeanQuantumAlg.StateVector n— the Hilbert-space vector typeEuclideanSpace ℂ (Fin (2 ^ n)).LeanPool.LeanQuantumAlg.PureState n— unit vectors inStateVector n.LeanPool.LeanQuantumAlg.PureState.ket x— computational basis ket|x⟩(PiLp.single 2 x 1).
The named one-qubit kets (ket0, ket1, ketPlus, ketMinus) and the
scalar invSqrt2 now live in LeanPool.LeanQuantumAlg.Core.Components.Kets.
Pinned Mathlib API: PiLp.single, PiLp.single_apply, PiLp.norm_single,
EuclideanSpace.norm_eq.
Raw Hilbert-space vector for an n-qubit pure-state register.
Equations
- QuantumAlg.StateVector n = EuclideanSpace ℂ (Fin (2 ^ n))
Instances For
An n-qubit pure state: a unit vector in the computational Hilbert space.
The general (density-operator) notion of state is intentionally not defined here — see the module docstring.
- vec : StateVector n
Underlying Hilbert-space vector.
Pure states are normalized by definition.
Instances For
Equations
Equations
- QuantumAlg.PureState.instNorm = { norm := fun (ψ : QuantumAlg.PureState n) => ‖ψ.vec‖ }
Equations
- QuantumAlg.PureState.instInnerComplex = { inner := fun (ψ φ : QuantumAlg.PureState n) => inner ℂ ψ.vec φ.vec }
Equations
- QuantumAlg.PureState.instHAddStateVector = { hAdd := fun (ψ φ : QuantumAlg.PureState n) => ψ.vec + φ.vec }
Equations
- QuantumAlg.PureState.instHSubStateVector = { hSub := fun (ψ φ : QuantumAlg.PureState n) => ψ.vec - φ.vec }
Equations
- QuantumAlg.PureState.instHSMulComplexStateVector = { hSMul := fun (c : ℂ) (ψ : QuantumAlg.PureState n) => c • ψ.vec }
Build a pure state from a normalized Hilbert-space vector.
Equations
- QuantumAlg.PureState.ofVec v h = { vec := v, norm_eq_one := h }