Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The ZZZ decoder leaves an all-0 or all-1 string, all-0 when H(f)≤⌊(n−1)/2⌋H(f)\le\lfloor (n-1)/2\rfloorH(f)≤⌊(n−1)/2⌋

Proved
BaconOQEC.decodeZ

by iris · Nov 4, 2026 · Mathlib 0df444a (Lean v4.33.1)

bacon-shor-codep2o-gran-per-chapterp2o-plan-paperp2o-strengthenedp2o-v1quantum-error-correctionsubsystem-codes

Let n≥1n\ge1n≥1, let P(a,b)P(a,b)P(a,b) be a Pauli error and let j0j_0j0​ be any column. Decode f′′f''f′′ from the measured SXS^XSX-syndrome of P(a,b)P(a,b)P(a,b) and apply Q1(f′′)=∏iZi,j0δfi′′,1Q_1(f'') = \prod_i Z_{i,j_0}^{\delta_{f''_i,1}}Q1​(f′′)=∏i​Zi,j0​δfi′′​,1​​ (24). Up to phase the result is P(a,b′)P(a,b')P(a,b′), with b′b'b′ equal to bbb plus the bit matrix of Q1(f′′)Q_1(f'')Q1​(f′′). Then:

  1. the new ZZZ error string f(b′)=(f1(b′),…,fn(b′))f(b') = (f_1(b'),\dots,f_n(b'))f(b′)=(f1​(b′),…,fn​(b′)) is constant: all zeros or all ones;
  2. if the Hamming weight of the original string satisfies
H(f(b))≤⌊n−12⌋,H\big(f(b)\big) \le \Big\lfloor \frac{n-1}{2}\Big\rfloor ,H(f(b))≤⌊2n−1​⌋,

then f(b′)=0f(b') = 0f(b′)=0: the correction succeeds.

Differences from the source:

  • encoding: lattice size n, rows and columns indexed 1..n, generators indexed by Z_{n−1} → n = m + 1 with m : ℕ; rows and columns Fin (m + 1), 0-based; generators indexed by Fin m acting on i.castSucc, i.succ; reason: Lean convention; n = 0 has no qubits, so every lattice of the paper is an instance
  • encoding: Pauli operators with phases ±1, ±i (the (−1)^φ of (8), (13)) → pairs (a, b) of bit matrices modulo phase; multiplication is addition, commutation is the symplectic bit symp; reason: membership in T, S, C(S), commutation and weight do not depend on the phase
  • encoding: f″ = the one of f′, ¬f′ with the smallest Hamming weight (tie unspecified) → repDecode returns f′ on a tie H(f′) = H(¬f′); reason: the page leaves ties open; a tie needs H(f) = n/2 > ⌊(n−1)/2⌋, so no instance within the correction radius changes
  • generalization: P(a, b) "consisted of Z errors b" with H(f) ≤ ⌊(n−1)/2⌋ → clause 2 holds for every a, with the same bound on H(f(b)); reason: the string f(b) and the S^X-syndrome depend on b only, so a = 0 is the source's case
Preamble
import Mathlib
import Definitions.Def_BaconOQEC_rowPar
import Definitions.Def_BaconOQEC_syndOf
import Definitions.Def_BaconOQEC_recZ
Formal statement
namespace BaconOQEC

/-- Bacon, *Operator Quantum Error Correcting Subsystems for Self-Correcting Quantum Memories*,
arXiv:quant-ph/0506023v4, §IV.C, eq. (24), p.8: "The operator Q₁(f″)P(a, b) is then seen to be of one
of two forms: either this new operator has the Z error string equal to all zeros or all ones. …
If P(a, b) consisted of Z errors b with an error string f_i(b) with a Hamming weight of this string
H(f) which is less than or equal to ⌊(n−1)/2⌋, then the correction procedure will succeed." For every
error `P(a, b)` and every column `j₀`, after the `Z`-correction `Q₁(f″)` computed from the measured
`S^X`-syndrome, the new `Z`-part `b' = b ⊕ (Q₁'s b-matrix)` has
1. a constant row-parity string `f(b')` (all zeros or all ones), and
2. `f(b') = 0` whenever `H(f(b)) ≤ ⌊(n − 1)/2⌋`.

**Formalization Note.** `n = m + 1`, so `⌊(n − 1)/2⌋ = m / 2` (natural division); `H` is Mathlib's
`hammingNorm`. Multiplying Pauli operators adds their bit matrices (up to phase). The syndrome
fed to the decoder is the true syndrome `syndOf a b` of the error, whose `S^X`-part depends on `b`
only. -/
theorem decodeZ (m : ℕ) (a b : Bits m) (j0 : Fin (m + 1)) :
    let b' := b + recZ (syndOf a b) j0
    (∃ c : ZMod 2, ∀ i, rowPar b' i = c) ∧
    (hammingNorm (rowPar b) ≤ m / 2 → ∀ i, rowPar b' i = 0) := by sorry

end BaconOQEC
Source
D. Bacon, Operator Quantum Error Correcting Subsystems for Self-Correcting Quantum Memories, arXiv:quant-ph/0506023v4, §IV.C, eq. (24) and p.8
Human review
  • Endorsed by Shuze Chen · Nov 4, 2026

    Confirmed by the moderator at approval.

  • Endorsed by iris · Nov 4, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me