Documentation

LeanPool.LeanQuantumAlg.Core.State

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 #

Main definitions #

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.

@[reducible, inline]

Raw Hilbert-space vector for an n-qubit pure-state register.

Equations
Instances For
    structure QuantumAlg.PureState (n : ) :

    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.

    • norm_eq_one : self.vec = 1

      Pure states are normalized by definition.

    Instances For
      @[implicit_reducible]
      noncomputable instance QuantumAlg.PureState.instNorm {n : } :
      Equations
      @[implicit_reducible]
      noncomputable instance QuantumAlg.PureState.instInnerComplex {n : } :
      Equations
      @[implicit_reducible]
      Equations
      @[implicit_reducible]
      Equations
      @[simp]
      theorem QuantumAlg.PureState.hAdd_apply {n : } (ψ φ : PureState n) (i : Fin (2 ^ n)) :
      (ψ.vec + φ.vec).ofLp i = ψ.vec.ofLp i + φ.vec.ofLp i
      @[simp]
      theorem QuantumAlg.PureState.hSub_apply {n : } (ψ φ : PureState n) (i : Fin (2 ^ n)) :
      (ψ.vec - φ.vec).ofLp i = ψ.vec.ofLp i - φ.vec.ofLp i
      @[simp]
      theorem QuantumAlg.PureState.hSMul_apply {n : } (c : ) (ψ : PureState n) (i : Fin (2 ^ n)) :
      (c ψ.vec).ofLp i = c * ψ.vec.ofLp i

      Build a pure state from a normalized Hilbert-space vector.

      Equations
      Instances For
        @[simp]
        theorem QuantumAlg.PureState.coe_ofVec {n : } (v : StateVector n) (h : v = 1) :
        (ofVec v h).vec = v
        @[simp]
        theorem QuantumAlg.PureState.ofVec_apply {n : } (v : StateVector n) (h : v = 1) (i : Fin (2 ^ n)) :
        (ofVec v h).vec.ofLp i = v.ofLp i
        @[simp]
        theorem QuantumAlg.PureState.ext {n : } {ψ φ : PureState n} (h : ∀ (i : Fin (2 ^ n)), ψ.vec.ofLp i = φ.vec.ofLp i) :
        ψ = φ
        theorem QuantumAlg.PureState.ext_iff {n : } {ψ φ : PureState n} :
        ψ = φ ∀ (i : Fin (2 ^ n)), ψ.vec.ofLp i = φ.vec.ofLp i
        def QuantumAlg.PureState.ket {n : } (x : Fin (2 ^ n)) :

        The computational basis ket |x⟩ : PureState n, big-endian (qubit 0 is the most significant bit of x).

        Equations
        Instances For
          @[simp]
          theorem QuantumAlg.PureState.ket_apply {n : } (x i : Fin (2 ^ n)) :
          (ket x).vec.ofLp i = if i = x then 1 else 0
          theorem QuantumAlg.PureState.norm_ket {n : } (x : Fin (2 ^ n)) :