Index of theproofnetwork/open-problems@860a535/Prove2Me/Definitions/Def_StabilizerRank.lean
qedmarket’s copy of theproofnetwork/open-problems@860a535, 1 Dec 2026original source ↗
/-From Prove2Me, definition `StabilizerRank` (https://prove2.me/definitions/9334b029-c77e-4ab1-b939-554a495acafe). Apache-2.0 per Prove2Me's terms.-/import Mathlib namespace StabilizerRank /-- Computational-basis index set for `n` qubits: bit strings of length `n`. -/abbrev Bits (n : ℕ) := Fin n → Bool /-- A (not necessarily normalised) `n`-qubit state vector, i.e. an element of `ℂ^(2^n)`. -/abbrev QState (n : ℕ) := Bits n → ℂ variable {n : ℕ} /-- The Pauli operator `X^a Z^b`, acting on the computational basis by`|x⟩ ↦ (-1)^(b·x) |x ⊕ a⟩`. -/noncomputable def pauliMatrix (a b : Bits n) : Matrix (Bits n) (Bits n) ℂ := Matrix.of fun y x => if y = (fun i => xor (a i) (x i)) then (-1 : ℂ) ^ (Finset.univ.filter (fun i => b i && x i)).card else 0 /-- The `n`-qubit Pauli group: the operators `i^c X^a Z^b`. -/noncomputable def pauliGroupSet (n : ℕ) : Set (Matrix (Bits n) (Bits n) ℂ) := {P | ∃ (c : Fin 4) (a b : Bits n), P = Complex.I ^ (c : ℕ) • pauliMatrix a b} /-- A Clifford unitary: a unitary normalising the Pauli group. -/def IsCliffordUnitary (U : Matrix (Bits n) (Bits n) ℂ) : Prop := U ∈ Matrix.unitaryGroup (Bits n) ℂ ∧ ∀ P ∈ pauliGroupSet n, U * P * star U ∈ pauliGroupSet n /-- The computational basis state `|0…0⟩`. -/def zeroState (n : ℕ) : QState n := fun x => if x = (fun _ => false) then 1 else 0 /-- A stabilizer state: the image of `|0…0⟩` under a Clifford unitary. -/def IsStabilizerState (ψ : QState n) : Prop := ∃ U, IsCliffordUnitary U ∧ ψ = U.mulVec (zeroState n) /-- The stabilizer rank `χ(ψ)`: the least `r` with `ψ = ∑_{j<r} c j • φ j`, each `φ j` astabilizer state. -/noncomputable def stabRank (ψ : QState n) : ℕ := sInf {r : ℕ | ∃ (c : Fin r → ℂ) (φ : Fin r → QState n), (∀ j, IsStabilizerState (φ j)) ∧ ∀ x, ψ x = ∑ j, c j * φ j x} /-- The `n`-fold tensor power of the magic state `|H⟩ = cos(π/8)|0⟩ + sin(π/8)|1⟩`. -/noncomputable def hState (n : ℕ) : QState n := fun x => ∏ i, (if x i then (Real.sin (Real.pi / 8) : ℂ) else (Real.cos (Real.pi / 8) : ℂ)) end StabilizerRank