Documentation

CsdLean4.Mathlib.QuantumInfo.Register

Computational-basis register (R1 foundation) #

Category: 1-Mathlib (CSD-free; staged as a Mathlib-upstream candidate).

The foundation for the quantum-algorithm branch (specs/nqubit-register-plan.md). A register state over a finite computational basis ι is a vector in EuclideanSpace ℂ ι; the n-qubit register is the instance where the basis is the bitstrings:

QReg n := EuclideanSpace ℂ (Fin n → Fin 2).

This file provides the computational basis basisState, the Born probability prob, the coordinate-of-a-sum bridge sum_coord, and the core API: Born as a squared inner product (prob_eq_inner_sq), normalisation of a unit state (sum_prob_eq_one), and that a basis state is measured with certainty (prob_basisState). Downstream files add the Hadamard transform, the QFT (Fourier.lean), phase estimation (PhaseEstimation.lean), oracles, and the algorithms.

Generalised 2026-08-29 (a strict widening, at the second consumer per CONVENTIONS.md §9): the primitives were stated for bitstrings only, and Empirical/QM/Algorithms/ShorCore.lean carried a verbatim second copy over a general finite index for its ZMod N and Fin T registers. The general form subsumes both; the bitstring statements are the ι = Fin n → Fin 2 instances and every consumer elaborates as before.

@[reducible, inline]
abbrev QuantumInfo.QReg (n : ) :

An n-qubit register state: a vector in the 2ⁿ-dimensional Hilbert space indexed by bitstrings Fin n → Fin 2. The bitstring instance of the general finite-basis register below.

Equations
Instances For
    noncomputable def QuantumInfo.basisState {ι : Type u_1} [DecidableEq ι] (x : ι) :

    The computational basis state |x⟩ indexed by an arbitrary finite type.

    Equations
    Instances For
      @[simp]
      theorem QuantumInfo.basisState_apply {ι : Type u_1} [DecidableEq ι] (x y : ι) :
      (basisState x).ofLp y = if y = x then 1 else 0
      noncomputable def QuantumInfo.prob {ι : Type u_1} (ψ : EuclideanSpace ι) (z : ι) :

      The Born probability of measuring computational-basis outcome z in state ψ: ‖ψ z‖² = ‖⟨z|ψ⟩‖².

      Equations
      Instances For
        theorem QuantumInfo.prob_nonneg {ι : Type u_1} (ψ : EuclideanSpace ι) (z : ι) :
        0 prob ψ z
        theorem QuantumInfo.prob_eq_inner_sq {ι : Type u_1} [DecidableEq ι] [Fintype ι] (ψ : EuclideanSpace ι) (z : ι) :

        Born rule, inner-product form: the probability is the squared modulus of the amplitude ⟨z|ψ⟩.

        theorem QuantumInfo.normSq_eq_sum_prob {ι : Type u_1} [Fintype ι] (ψ : EuclideanSpace ι) :
        ψ ^ 2 = z : ι, prob ψ z

        ‖v‖² = ∑ z, ‖v z‖² on the register (Parseval in coordinate form).

        theorem QuantumInfo.sum_prob_eq_one {ι : Type u_1} [Fintype ι] {ψ : EuclideanSpace ι} ( : ψ = 1) :
        z : ι, prob ψ z = 1

        Normalisation: the Born probabilities of a unit register state sum to one.

        @[simp]
        theorem QuantumInfo.basisState_norm {ι : Type u_1} [DecidableEq ι] [Fintype ι] (x : ι) :
        @[simp]
        theorem QuantumInfo.prob_basisState {ι : Type u_1} [DecidableEq ι] (x z : ι) :
        prob (basisState x) z = if z = x then 1 else 0

        A computational basis state is measured with certainty: prob |x⟩ z = [z = x].

        theorem QuantumInfo.sum_coord {ι : Type u_1} {κ : Type u_2} (s : Finset κ) (f : κEuclideanSpace ι) (y : ι) :
        (∑ ks, f k).ofLp y = ks, (f k).ofLp y

        Coordinatewise: a finite sum of register states evaluates as the sum of coordinates.