error_sphere_dimension
theoremverifiedimported Lean
Dimension of the error sphere of a non-degenerate code. Let $C \le \mathcal{H}_n$ be a code on $n$ qubits that is non-degenerate for $t$ errors, meaning it satisfies the Knill--Laflamme condition $P_C E^\dagger F P_C = \lambda_{EF} P_C$ for all Pauli strings $E,F$ of weight at most $t$ and moreover $P_C E^\dagger F P_C = 0$ whenever $E \neq F$. Then the error sphere $\mathrm{ES}(C,t) = \bigvee_{\mathrm{wt}(p)\le t} \hat{p}(C)$ has dimension \[ \dim_{\mathbb{C}} \mathrm{ES}(C,t) = |\mathcal{E}(n,t)| \cdot \dim_{\mathbb{C}} C, \] where $\mathcal{E}(n,t)$ is the set of Pauli strings of weight at most $t$.
Statement
set_option linter.mathlibStandardSet false in open scoped BigOperators in open scoped Real in open scoped Nat in open scoped Classical in open scoped Pointwise in set_option maxRecDepth 4000 in set_option synthInstance.maxHeartbeats 20000 in set_option synthInstance.maxSize 128 in set_option relaxedAutoImplicit false in set_option autoImplicit false in open Complex Matrix in lemma error_sphere_dimension {n t : ℕ} {C : Submodule ℂ (Hn n)} (h_nondeg : IsNondegenerate n C t) : Module.finrank ℂ (ErrorSphere n t C) = (PauliErrorsLe n t).card * Module.finrank ℂ C
- Source
- TCSlib, `error_sphere_dimension`
- Lean proof
- By Allan Li, Hydroxyi (from the file's git history), from github.com/Shilun-Allan-Li/tcslib at
c8a02591b1e5(Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.error_sphere_dimension← error_sphere_dimension (TCSlib/ErrorCorrectingCodes/QuantumHamming.lean:322): adapted
What was changed in
error_sphere_dimension--- TCSlib/ErrorCorrectingCodes/QuantumHamming.lean:322 (error_sphere_dimension) +++ as compiled here @@ -1 +1,13 @@ +set_option linter.mathlibStandardSet false in +open scoped BigOperators in +open scoped Real in +open scoped Nat in +open scoped Classical in +open scoped Pointwise in +set_option maxRecDepth 4000 in +set_option synthInstance.maxHeartbeats 20000 in +set_option synthInstance.maxSize 128 in +set_option relaxedAutoImplicit false in +set_option autoImplicit false in +open Complex Matrix in lemma error_sphere_dimension {n t : ℕ} {C : Submodule ℂ (Hn n)} @@ -107,3 +119,3 @@ exact Function.ne_iff.mp hij - exact Matrix.invertibleOfLeftInverse _ _ h_inv + exact _root_.invertibleOfLeftInverse _ _ h_inv intro x y hxy - Verified
- 16 Oct 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 18
- error_subspaces_orthogonalOrthogonality of distinct error subspaces. Let $C \le \mathcal{H}_n$ be a code that is non-degenerate for $t$-error correction, and let…
- ErrorSphereThe error sphere $\mathrm{ES}(C,t)$ is the subspace $\bigvee_{\mathrm{wt}(p)\le t} \hat{p}(C)$, i.e.\ the supremum of the Pauli…
- HnThe $n$-qubit Hilbert space $\mathcal{H}_n = \ell^2\!\bigl(\{0,1\}^n,\mathbb{C}\bigr)$, implemented as \texttt{EuclideanSpace ℂ (Fin n →…
- IsNondegenerateA code is non-degenerate if it satisfies the Knill--Laflamme condition and additionally $P_C E^\dagger F P_C = 0$ whenever…
- PauliBasis.toMatrixMaps each Pauli basis element $\{I,X,Y,Z\}$ to its corresponding $2\times 2$ matrix $\{\sigma_I,\sigma_X,\sigma_Y,\sigma_Z\}$.
- PauliErrorsLeThe set of all Pauli strings of weight at most $t$:…
- PauliStringA Pauli string of length $n$ is a function $p : \mathrm{Fin}\,n \to \mathrm{PauliBasis}$.
- pauliMatrixFor a Pauli string $p$ on $n$ qubits, the $2^n\times 2^n$ matrix obtained as the tensor product of the single-qubit Pauli matrices…
- pauliOpFor $p \in \mathrm{PauliString}\,n$, the associated Pauli operator $\hat{p} : \mathcal{H}_n \to \mathcal{H}_n$.
- sigmaIThe $2\times 2$ identity matrix over $\mathbb{C}$, i.e.\ the Pauli operator $I$.
- sigmaXThe bit-flip Pauli matrix $X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}$ over $\mathbb{C}$.
- sigmaYThe bit-phase-flip Pauli matrix $Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}$ over $\mathbb{C}$.
- sigmaZThe phase-flip Pauli matrix $Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}$ over $\mathbb{C}$.
- weightThe support $\mathrm{supp}(p) \subseteq \mathrm{Fin}\,n$ consists of coordinates where $p(i) \neq I$; the weight is…
- codeProj_applyAction of the code projection. Let $C$ be a closed subspace of the $n$-qubit Hilbert space $\mathcal{H}_n$, and let…
- instFintypePauliStringinstFintypePauliString
- instFiniteDimensionalComplexSubtypeHnMemSubmoduleinstFiniteDimensionalComplexSubtypeHnMemSubmodule
- PauliBasisThe four Pauli basis elements $\{I,X,Y,Z\}$, represented as an inductive type.
- Used by 1
- quantum_hamming_bound_rawQuantum Hamming bound for non-degenerate codes. Let $C \le \mathcal{H}_n$ be a subspace of the $n$-qubit Hilbert space that is a…
Lean source view module on GitHub
set_option linter.mathlibStandardSet false in open scoped BigOperators in open scoped Real in open scoped Nat in open scoped Classical in open scoped Pointwise in set_option maxRecDepth 4000 in set_option synthInstance.maxHeartbeats 20000 in set_option synthInstance.maxSize 128 in set_option relaxedAutoImplicit false in set_option autoImplicit false in open Complex Matrix in lemma error_sphere_dimension {n t : ℕ} {C : Submodule ℂ (Hn n)} (h_nondeg : IsNondegenerate n C t) : Module.finrank ℂ (ErrorSphere n t C) = (PauliErrorsLe n t).card * Module.finrank ℂ C := by /- proof strat: - show the family `(C.map (pauliOp E))` is pairwise disjoint (inf = ⊥) via orthogonality - use finrank of supremum over pairwise disjoint finite family - show each `pauliOp E` restricts to a linear equiv on `C` (invertible/unitary), hence `finrank (C.map (pauliOp E)) = finrank C` -/ have h_dim_sum : ∀ (S : Finset (PauliString n)), (∀ E ∈ S, weight E ≤ t) → Module.finrank ℂ (↥(Finset.sup S (fun E => C.map (pauliOp E)))) = Finset.card S * Module.finrank ℂ C := by intro S hS induction' S using Finset.induction with E S hES ih · simp +decide · have h_orthogonal : Submodule.IsOrtho (C.map (pauliOp E)) (Finset.sup S (fun E => C.map (pauliOp E))) := by have h_orthogonal : ∀ F ∈ S, Submodule.IsOrtho (C.map (pauliOp E)) (C.map (pauliOp F)) := by intro F hF apply error_subspaces_orthogonal h_nondeg E F (hS E (Finset.mem_insert_self E S)) (hS F (Finset.mem_insert_of_mem hF)) simp_all only [Finset.mem_insert, or_true, implies_true, forall_const, forall_eq_or_imp, ne_eq] obtain ⟨left, right⟩ := hS apply Aesop.BuiltinRules.not_intro intro a subst a simp_all only [not_true_eq_false] have h_orthogonal_sup : ∀ (T : Finset (PauliString n)), (∀ F ∈ T, Submodule.IsOrtho (C.map (pauliOp E)) (C.map (pauliOp F))) → Submodule.IsOrtho (C.map (pauliOp E)) (Finset.sup T (fun F => C.map (pauliOp F))) := by intro T hT induction T using Finset.induction <;> aesop exact h_orthogonal_sup S h_orthogonal have h_dim_sum : Module.finrank ℂ (↥(C.map (pauliOp E) ⊔ Finset.sup S (fun E => C.map (pauliOp E)))) = Module.finrank ℂ (↥(C.map (pauliOp E))) + Module.finrank ℂ (↥(Finset.sup S (fun E => C.map (pauliOp E)))) := by rw [← Submodule.finrank_sup_add_finrank_inf_eq] simp +zetaDelta at * exact h_orthogonal.disjoint.eq_bot convert h_dim_sum using 1 · rw [Finset.sup_insert] · rw [Finset.card_insert_of_notMem hES, ih (fun E hE => hS E (Finset.mem_insert_of_mem hE))] have h_inv : Function.Injective (pauliOp E) := by have h_inv : Invertible (pauliMatrix E) := by have h_inv : (pauliMatrix E).conjTranspose * pauliMatrix E = 1 := by ext i j simp +decide [Matrix.mul_apply, pauliMatrix] -- Since these are Pauli matrices, we know that their product is zero unless i = j. have h_pauli_prod : ∀ k : Fin n, ∑ x : Fin 2, (starRingEnd ℂ ((E k).toMatrix x (i k))) * ((E k).toMatrix x (j k)) = if i k = j k then 1 else 0 := by intro k rcases E k with (_ | _ | _ | _) <;> norm_num [Fin.sum_univ_succ, Matrix.mul_apply, PauliBasis.toMatrix] · rcases i_k : i k with (_ | _ | i_k) <;> rcases j_k : j k with (_ | _ | j_k) <;> norm_num [Fin.ext_iff, sigmaI] <;> tauto · rcases i_k : i k with (_ | _ | i_k) <;> rcases j_k : j k with (_ | _ | j_k) <;> norm_num [Fin.ext_iff, sigmaX] <;> tauto · rcases i_k : i k with (_ | _ | i_k) <;> rcases j_k : j k with (_ | _ | j_k) <;> norm_num [Fin.ext_iff, sigmaY] <;> tauto · rcases i_k : i k with (_ | _ | i_k) <;> rcases j_k : j k with (_ | _ | j_k) <;> norm_num [Fin.ext_iff, sigmaZ] <;> tauto simp +decide [← Finset.prod_mul_distrib] rw [show (∑ x : Fin n → Fin 2, ∏ x_1 : Fin n, (starRingEnd ℂ) ((E x_1 |> PauliBasis.toMatrix) (x x_1) (i x_1)) * (E x_1 |> PauliBasis.toMatrix) (x x_1) (j x_1)) = ∏ k : Fin n, (∑ x : Fin 2, (starRingEnd ℂ) ((E k |> PauliBasis.toMatrix) x (i k)) * (E k |> PauliBasis.toMatrix) x (j k)) from by exact Eq.symm (Fintype.prod_sum fun i_1 j_1 => (starRingEnd ℂ) ((E i_1).toMatrix j_1 (i i_1)) * (E i_1).toMatrix j_1 (j i_1))] · simp +decide [h_pauli_prod, Matrix.one_apply] by_cases hij : i = j <;> simp +decide [hij, Finset.prod_ite] exact Function.ne_iff.mp hij exact _root_.invertibleOfLeftInverse _ _ h_inv intro x y hxy have h_eq : (pauliMatrix E).mulVec x.ofLp = (pauliMatrix E).mulVec y.ofLp := by simpa [pauliOp] using congrArg WithLp.ofLp hxy have h_of : x.ofLp = y.ofLp := by simpa using congr_arg (fun z => ((pauliMatrix E)⁻¹).mulVec z) h_eq exact WithLp.ofLp_injective _ h_of have h_dim_map : ∀ (f : Hn n →ₗ[ℂ] Hn n), Function.Injective f → ∀ (C : Submodule ℂ (Hn n)), Module.finrank ℂ (↥(C.map f)) = Module.finrank ℂ C := by intro f hf C have h_iso : C ≃ₗ[ℂ] C.map f := by exact Submodule.equivMapOfInjective f hf C exact LinearEquiv.finrank_eq h_iso.symm have h_map_finrank : Module.finrank ℂ (↥(Submodule.map (pauliOp E) C)) = Module.finrank ℂ C := by exact h_dim_map _ h_inv _ rw [h_map_finrank] ring exact h_dim_sum _ (fun E hE => (Finset.mem_filter.mp hE).2)