Code Distance and Logical Operators

A quantum error-correcting code hides logical information inside a subspace — the codespace C\mathcal{C} — of a much larger Hilbert space, betting that the noise thrown at the physical qubits will land in a region the code can recognize and undo. The single number that governs how good that bet is, is the code distance dd: the smallest number of physical qubits that noise (or a clever adversary) must touch to carry one valid codeword into a different valid codeword while leaving the syndrome detectors completely dark. An undetectable move of that kind is not a hardware bug; it is a genuine logical operation on the encoded qubit, performed by accident. So the distance measures two things at once — how far apart the codewords are pitched in Hilbert space, and how many independent single-qubit errors the code can tell apart before two of them become confusable. For stabilizer codes the story turns crisp and algebraic. The codespace is the joint +1+1 eigenspace of an abelian group S\mathcal{S} of Pauli operators, and an error is caught precisely when it anticommutes with a stabilizer generator. The errors that slip through are those that commute with every stabilizer — the normalizer N(S)N(\mathcal{S}) — yet are not themselves stabilizers. These are exactly the logical Pauli operators, and the distance is the minimum weight over this coset, d=min⁡{wt(E):E∈N(S)∖S}d=\min\{\mathrm{wt}(E): E\in N(\mathcal{S})\setminus\mathcal{S}\}. Because a logical operator can swallow any stabilizer without changing its action, weight is a property of an equivalence class, not of a single operator — which is what makes finding dd subtle, and finding high-dd codes an art.

Key takeaways
  • The code distance dd is the minimum weight of a nontrivial logical Pauli — an operator that commutes with every stabilizer (so it is undetectable) yet acts nontrivially on the encoded qubits.
  • Logical operators are elements of the normalizer N(S)N(\mathcal{S}) modulo the stabilizer group S\mathcal{S}; any representative can be reshaped by multiplying by stabilizers, and dd is the lightest weight over the whole coset LˉS\bar{L}\mathcal{S}.
  • A distance-dd code corrects every error of weight t=⌊(d−1)/2⌋t=\lfloor(d-1)/2\rfloor and detects every error up to weight d−1d-1; both follow from the Knill–Laflamme conditions.
  • An [[n,k,d]][[n,k,d]] code encodes kk logical qubits in nn physical qubits, using n−kn-k independent stabilizer generators and 2k2k logical operators Xˉi,Zˉi\bar{X}_i,\bar{Z}_i.
  • The Shor [[9,1,3]][[9,1,3]], Steane [[7,1,3]][[7,1,3]], and perfect [[5,1,3]][[5,1,3]] codes all have d=3d=3 and correct one arbitrary single-qubit error; the quantum Singleton bound d≤(n−k)/2+1d\le(n-k)/2+1 caps how far distance can be pushed.
  • Key idea: the distance is the minimum weight not of any operator but of an equivalence class — a logical Pauli can absorb any stabilizer, so d=min⁡E∈N(S)∖Swt(E)d=\min_{E\in N(\mathcal{S})\setminus\mathcal{S}}\mathrm{wt}(E), minimized over each coset LˉS\bar{L}\mathcal{S}.

Where this lives today

Distance stopped being a textbook parameter and became an engineering dial the moment surface codes reached the lab. In the surface code the logical operators are strings of Pauli operators running across a lattice, and the distance is literally the shortest homologically nontrivial path — the smallest loop or cut that wraps the code — so increasing dd means tiling more physical qubits. In 2023–2024 Google's Quantum AI group demonstrated the payoff directly: scaling a surface code from distance 33 to 55 to 77 (the d=7d=7 patch using 101101 superconducting qubits), they measured the logical error rate dropping with each increase in distance, with a suppression factor Λ≈2\Lambda\approx2 per two units of dd — the first convincing "below-threshold" operation, where adding qubits helps rather than hurts. That is exactly the pL∼(p/pth)⌊(d+1)/2⌋p_L\sim(p/p_{\mathrm{th}})^{\lfloor(d+1)/2\rfloor} scaling from the worked example. Meanwhile the frontier is to escape the surface code's punishing overhead: quantum LDPC codes achieve distance d=Θ(n)d=\Theta(n) at constant rate, and 2024 neutral-atom experiments ran logical algorithms on dozens of logical qubits built from such codes. In every case the figure of merit quoted first is the distance, and the object the decoder fights not to apply by accident is a minimum-weight logical operator.

The physical picture

Picture the valid codewords as a scattered set of points in an enormous Hilbert space, and picture errors as moves that hop from a point to a nearby point, each hop costing one unit of weight per physical qubit it disturbs. Around every codeword there is a ball of radius tt: any error of weight tt or less lands inside its own ball, the decoder reads the syndrome, and walks the state back to the centre. The danger is a path that starts on one codeword, never lights up a single syndrome detector, and ends on a different codeword. The length of the shortest such path is the distance. Short paths are lethal — a light, invisible, logic-scrambling error. High distance means every invisible path is long, so all the light errors are catchable. The first figure freezes this: two codewords, their correctable balls, and the shortest undetectable tunnel between them.

Figure
Distance as the shortest undetectable path: two codewords 0̄ and 1̄ sit far apart in Hilbert space, and every weight-1 error lands inside a correctable ball of radius t = 1, while the lightest operator that stays invisible to all syndromes yet flips 0̄ into 1̄ has weight d = 3 — a logical operator
Distance d = min weight of an undetectable, codeword-changing path correctable ball, weight ≤ t = 1 correctable ball, weight ≤ t = 1 logical operator: weight d = 3, syndrome = 0 1 qubit 2 3 |0̄⟩ |1̄⟩ green moves stay inside → detected + reversed red path never trips a detector → logical fault

Logical operators come in equivalence classes because the stabilizers are do-nothing transformations on the codespace: multiply a logical Xˉ\bar{X} by any stabilizer SS and the product acts identically on every codeword, even though its Pauli string — and its weight — can look completely different. So the weight of the Xˉ\bar{X} you happened to write down is only an upper bound on its class; the honest number is the lightest member of the coset XˉS\bar{X}\mathcal{S}. This is precisely the classical problem of finding a minimum-weight codeword, which is why distance is NP-hard in general and why a degenerate code — one whose stabilizers can be lighter than dd — costs you nothing: a light stabilizer is harmless. The second figure makes this concrete on the first full quantum code, Shor's nine-qubit code, where both minimal logicals have weight exactly 3.

Figure
The Shor 9-qubit code as an explicit realization: nine physical qubits in three blocks of three encode k = 1 logical qubit with distance d = 3, where the logical Z̄ = X₁X₂X₃ runs down one block and X̄ = Z₁Z₄Z₇ takes one qubit per block, and because they overlap only on qubit 1 they anticommute — so t = 1
Shor [[9,1,3]]: Z̄ = X₁X₂X₃ (weight 3), X̄ = Z₁Z₄Z₇ (weight 3), d = 3 block A block B block C q1XZ q2X q3X q4Z q5 q6 q7Z q8 q9 X̄ Z̄ q1 carries both → the two logicals overlap on one qubit → X̄ Z̄ = − Z̄ X̄

The factor of two that turns distance into a correction guarantee is the same sphere-packing bookkeeping as in classical coding. Two errors of weight ≤t\le t combine into an operator of weight ≤2t\le 2t; if 2t<d2t<d that combination is too light to be a nontrivial logical, so it is either a stabilizer (harmless) or detectable, and either way the decoder is never fooled. That is the whole content of t=⌊(d−1)/2⌋t=\lfloor(d-1)/2\rfloor, made exact next.

The core equations

The codespace is defined not by writing down its states but by naming the operators that fix them. For a stabilizer code every valid state is a +1+1 eigenstate of the whole abelian group S\mathcal{S}, and this fixed-point description is what makes syndromes and logical operators computable by pure Pauli algebra.

C={ ∣ψ⟩:S∣ψ⟩=∣ψ⟩  ∀S∈S }(1)\mathcal{C}=\{\,|\psi\rangle : S|\psi\rangle=|\psi\rangle\ \ \forall S\in\mathcal{S}\,\} \qquad (1)

where: C\mathcal{C} — the codespace (logical Hilbert space); S\mathcal{S} — an abelian subgroup of the nn-qubit Pauli group PnP_n with −I∉S-I\notin\mathcal{S}; SS — a stabilizer element. Reading it: the code is the intersection of the +1+1 eigenspaces of every stabilizer, and measuring the generators (the syndrome) tells you which eigenspace you fell into without disturbing the encoded state. The distance is the minimum weight over the operators that are simultaneously undetectable and nontrivial. Detectability is anticommutation with a stabilizer; triviality is membership in S\mathcal{S}; the survivors form the coset complement N(S)∖SN(\mathcal{S})\setminus\mathcal{S}, and their lightest member sets dd.

d=min⁡E ∈ N(S)∖S wt(E)(2)d=\min_{E\,\in\,N(\mathcal{S})\setminus\mathcal{S}}\ \mathrm{wt}(E) \qquad (2)

where: N(S)N(\mathcal{S}) — the normalizer (which for Paulis equals the centralizer) of S\mathcal{S} in PnP_n; wt(E)\mathrm{wt}(E) — the Pauli weight, the count of qubits on which EE is not the identity; N(S)∖SN(\mathcal{S})\setminus\mathcal{S} — the undetectable-but-nontrivial operators, i.e. the logical Paulis. Reading it: you exclude the harmless stabilizers and minimize weight over the dangerous ones, and because each dangerous operator can be reshaped by a stabilizer, this minimum is taken over entire cosets, not single strings. The three integers of a code are packaged as [[n,k,d]][[n,k,d]], and the first two are fixed by counting: n−kn-k independent commuting generators cut the 2n2^n-dimensional space down to a 2k2^k-dimensional codespace.

[[n,k,d]]:∣⟨S⟩∣=2 n−k,dim⁡C=2 k(3)[[n,k,d]]:\qquad |\langle\mathcal{S}\rangle|=2^{\,n-k},\qquad \dim\mathcal{C}=2^{\,k} \qquad (3)

where: nn — physical qubits; kk — logical (encoded) qubits; dd — distance; n−kn-k — the number of independent stabilizer generators. Reading it: each independent generator is one binary constraint that halves the surviving dimension, so n−kn-k generators leave 2n/2n−k=2k2^{n}/2^{n-k}=2^{k} logical dimensions. The logical operators themselves are not a set but a group — the quotient of the normalizer by the stabilizer. This quotient is isomorphic to the Pauli group on kk qubits, which is why a kk-qubit code has exactly 2k2k independent logical generators.

N(S)/S ≅ ⟨ Xˉ1,Zˉ1,…,Xˉk,Zˉk ⟩(4)N(\mathcal{S})/\mathcal{S}\ \cong\ \langle\,\bar{X}_1,\bar{Z}_1,\dots,\bar{X}_k,\bar{Z}_k\,\rangle \qquad (4)

where: Xˉi,Zˉi\bar{X}_i,\bar{Z}_i — the logical Pauli operators acting on encoded qubit ii, obeying XˉiZˉj=(−1)δijZˉjXˉi\bar{X}_i\bar{Z}_j=(-1)^{\delta_{ij}}\bar{Z}_j\bar{X}_i; N(S)/SN(\mathcal{S})/\mathcal{S} — logical operators identified modulo stabilizer equivalence. Reading it: two Pauli strings that differ by a stabilizer are the same logical operation, so a logical is a coset and the group of cosets is a copy of PkP_k. Correctability of an error set is decided by the Knill–Laflamme conditions, the master theorem behind everything here. A set {Ea}\{E_a\} is correctable exactly when the projected products collapse onto the codespace projector with codeword-independent coefficients.

P Ea†Eb P=cab P(5)P\,E_a^{\dagger}E_b\,P = c_{ab}\,P \qquad (5)

where: PP — the projector onto C\mathcal{C}; Ea,EbE_a,E_b — members of the error set; cabc_{ab} — entries of a Hermitian matrix that does not depend on the codeword. Reading it: no codeword may leak information about which error occurred (that would spoil the encoded state), so the overlap PEa†EbPPE_a^\dagger E_bP must be blind to the logical content — a single number times PP. Feeding the set of all Paulis of weight ≤t\le t into (5) yields the correction guarantee, the number every code designer quotes first.

t=⌊d−12⌋(6)t=\left\lfloor \frac{d-1}{2}\right\rfloor \qquad (6)

where: tt — the largest weight of an arbitrary Pauli error the code is guaranteed to correct; dd — the distance. Reading it: the floor is not cosmetic — it is forced by requiring 2t<d2t<d for integer tt, and it is why odd distances (d=3,5,7d=3,5,7) are the useful ones and an even distance buys detection, not extra correction. For the workhorse CSS family, built from two classical linear codes, the quantum distance reduces to a classical minimum-distance computation on the XX- and ZZ-sectors separately.

dCSS=min⁡ ⁣(dX, dZ)(nondegenerate)(7)d_{\mathrm{CSS}}=\min\!\big(d_X,\,d_Z\big)\quad(\text{nondegenerate}) \qquad (7)

where: dX,dZd_X,d_Z — the classical minimum Hamming distances of the coset codes carrying XX-type and ZZ-type logicals; the "nondegenerate" caveat flags that degeneracy can only make the true distance larger, never smaller. Reading it: CSS structure decouples bit-flip and phase-flip protection, so a code's distance is the weaker of its two classical guardrails.

Derivation AFrom distance to the correction guarantee

The goal is to prove the central operational fact — that a distance-dd stabilizer code corrects every Pauli error of weight at most t=⌊(d−1)/2⌋t=\lfloor(d-1)/2\rfloor — starting only from the definition of distance as a minimum coset weight and the Knill–Laflamme conditions, and to see exactly where the sphere-packing factor of two enters. We take the candidate error set to be all Paulis of weight ≤t\le t, form the products that the Knill–Laflamme criterion tests, and show each product is either a stabilizer or detectable, never a nontrivial logical.

Step 1. Take any two errors Ea,EbE_a,E_b with wt(Ea),wt(Eb)≤t\mathrm{wt}(E_a),\mathrm{wt}(E_b)\le t and form F≡Ea†EbF\equiv E_a^{\dagger}E_b. Since a product of Paulis is a Pauli (up to phase) supported on the union of the two supports, wt(F)≤wt(Ea)+wt(Eb)≤2t\mathrm{wt}(F)\le \mathrm{wt}(E_a)+\mathrm{wt}(E_b)\le 2t. Why: the Knill–Laflamme test is a statement about the products Ea†EbE_a^\dagger E_b, so the object we must control is FF, and its weight is bounded by simple support-counting.

Step 2. Impose t=⌊(d−1)/2⌋t=\lfloor(d-1)/2\rfloor, which means 2t≤d−12t\le d-1, hence wt(F)≤2t≤d−1<d\mathrm{wt}(F)\le 2t\le d-1<d. Why: this is the one place the factor of two lives — two independent weight-tt errors can conspire to weight 2t2t, and we need that combined weight to fall strictly below the distance.

Step 3. Classify FF using the distance definition. Because dd is the smallest weight of any operator in N(S)∖SN(\mathcal{S})\setminus\mathcal{S} and wt(F)<d\mathrm{wt}(F)<d, FF cannot be a nontrivial logical. Only two possibilities remain: F∈SF\in\mathcal{S}, or F∉N(S)F\notin N(\mathcal{S}). Why: the definition of distance is precisely a floor on the weight of the "bad" operators, so anything lighter than dd is automatically not bad.

Step 4. Handle the stabilizer case F∈SF\in\mathcal{S}. A stabilizer fixes every codeword, so PFP=PPFP=P and cab=1c_{ab}=1 up to the phase of FF. This is the degenerate case: distinct errors produce the same recovery, corrected without ever being distinguished. Why: degeneracy is a feature, not a loophole — two physically different errors share one syndrome and one fix, which is how degenerate codes beat the nondegenerate counting bounds.

Step 5. Handle the detectable case F∉N(S)F\notin N(\mathcal{S}). Then some stabilizer SS anticommutes with FF, so PFP=PFSP=−PSFP=−PFPPFP=P F S P=-P S F P=-PFP, forcing PFP=0PFP=0 and cab=0c_{ab}=0. Combining Steps 4 and 5, every product satisfies PEa†EbP=cabPPE_a^\dagger E_bP=c_{ab}P with Hermitian, codeword-independent cc — the conditions hold and all weight-≤t\le t errors are correctable. Why: SS commutes through PP but anticommutes with FF, and together those annihilate the matrix element — the syndrome of FF is nonzero, so the two errors are told apart.

Go deeper · Derivation B · 2 minLogical operators and the distance of the Shor code
Derivation BLogical operators and the distance of the Shor code

The goal is to make the coset definition concrete by exhibiting minimum-weight logical operators for Shor's nine-qubit code, verifying by direct Pauli algebra that they are undetectable, nontrivial, and mutually conjugate, and confirming that no lighter representative exists so that d=3d=3. The Shor code concatenates an outer phase-flip repetition code across three blocks with an inner bit-flip repetition code inside each block, and its logicals can be read straight off that layered structure.

Step 1. Fix the stabilizers. Inside each block of three qubits the bit-flip checks are Z1Z2,Z2Z3Z_1Z_2,Z_2Z_3, Z4Z5,Z5Z6Z_4Z_5,Z_5Z_6, Z7Z8,Z8Z9Z_7Z_8,Z_8Z_9 — six ZZ-type generators — and the phase-flip checks across blocks are X1X2X3X4X5X6X_1X_2X_3X_4X_5X_6 and X4X5X6X7X8X9X_4X_5X_6X_7X_8X_9 — two XX-type generators. That is 8=n−k8=n-k generators for n=9,k=1n=9,k=1. Why: the 88 constraints cut 292^9 down to 212^1, so there is exactly one encoded qubit and its two logical operators must live in N(S)∖SN(\mathcal{S})\setminus\mathcal{S}.

Step 2. Propose Zˉ=X1X2X3\bar{Z}=X_1X_2X_3. It commutes with each ZZ-type check (it overlaps Z1Z2Z_1Z_2 and Z2Z3Z_2Z_3 on an even number of qubits) and trivially with the all-XX checks, so its syndrome is zero; yet on the encoded states it flips the relative sign of ∣000⟩±∣111⟩|000\rangle\pm|111\rangle in the first block, i.e. it maps ∣0L⟩↔∣1L⟩|0_L\rangle\leftrightarrow|1_L\rangle up to the logical phase. Weight 33. Why: an even overlap between two Pauli strings means they commute, and X1X2X3X_1X_2X_3 acting on one block realizes a logical phase operation while staying invisible — the signature of a logical.

Step 3. Propose Xˉ=Z1Z4Z7\bar{X}=Z_1Z_4Z_7. It is all-ZZ, so it commutes with every ZZ-type check, and it overlaps each XX-type check on an even count (qubits 1,41,4 with the first, 4,74,7 with the second), so it too is undetectable; a single ZZ per block sends each ∣000⟩+∣111⟩|000\rangle+|111\rangle to ∣000⟩−∣111⟩|000\rangle-|111\rangle, implementing the conjugate logical. Weight 33. Why: one ZZ per block is the lightest way to touch all three phase-blocks at once, which is what a phase-type logical must do.

Step 4. Check conjugacy: Xˉ\bar{X} and Zˉ\bar{Z} share exactly one qubit (qubit 11, where ZZ meets XX), so they anticommute, XˉZˉ=−ZˉXˉ\bar{X}\bar{Z}=-\bar{Z}\bar{X} — precisely the algebra required of a logical XX–ZZ pair. Why: a single anticommuting qubit overlap gives one minus sign, confirming these are genuinely conjugate encoded Paulis and not two copies of the same logical.

Step 5. Argue minimality. Any weight-11 Pauli anticommutes with some check (a lone ZZ trips an XX-check, a lone XX trips a ZZ-check), and no weight-22 Pauli is both undetectable and outside S\mathcal{S}; so the lightest member of N(S)∖SN(\mathcal{S})\setminus\mathcal{S} has weight 33, giving d=3d=3 and t=⌊(3−1)/2⌋=1t=\lfloor(3-1)/2\rfloor=1. Why: exhausting weights 11 and 22 shows nothing lighter than the exhibited logicals survives, so the minimum coset weight — the distance — is exactly 33, and the Shor code corrects any single-qubit error.

Go deeper · Derivation C · 2 minThe quantum Singleton bound
Derivation CThe quantum Singleton bound

The goal is to derive the ceiling on distance, d≤(n−k)/2+1d\le (n-k)/2+1, which no [[n,k,d]][[n,k,d]] code can exceed, using only that a distance-dd code can recover from the erasure of any d−1d-1 located qubits together with the no-cloning theorem. This bound is the quantum analogue of the classical Singleton bound and it is what makes the five-qubit code "perfect": it saturates the inequality.

Step 1. Note that a distance-dd code corrects the erasure of any d−1d-1 qubits. Erasure is error at a known location, so it is easier than a general error: correcting located faults of weight up to d−1d-1 needs only d−1<dd-1<d, whereas correcting unlocated faults needs weight ≤⌊(d−1)/2⌋\le\lfloor(d-1)/2\rfloor. Why: knowing where the damage is halves the job, so the erasure-correcting weight budget is the full d−1d-1 rather than (d−1)/2(d-1)/2.

Step 2. Suppose 2(d−1)≤n2(d-1)\le n and split the nn qubits into two disjoint blocks AA and BB, each of size d−1d-1, plus a remainder. Erasing AA must be recoverable from the survivors, which include all of BB; erasing BB must be recoverable from the survivors, which include all of AA. Why: the erasure-correction property says the logical information survives the loss of any d−1d-1 qubits, and we apply it to two disjoint such blocks.

Step 3. Invoke no-cloning. If both AA and BB could each be discarded and the full kk logical qubits still reconstructed from the rest, then the environment holding AA and the environment holding BB would each retain enough to rebuild the logical state — two independent copies of unknown quantum information, which no-cloning forbids unless the redundancy is large enough that neither block alone carries it. The clean counting statement this forces is k≤n−2(d−1)k\le n-2(d-1). Why: two disjoint recoverable regions would clone the encoded state, so the redundancy budget n−kn-k must be at least 2(d−1)2(d-1) to keep any single (d−1)(d-1)-block from being informationally complete.

Step 4. Rearrange: k≤n−2(d−1)k\le n-2(d-1) gives 2(d−1)≤n−k2(d-1)\le n-k, i.e. d≤n−k2+1d\le \dfrac{n-k}{2}+1. For the perfect code, n=5,k=1n=5,k=1: d≤5−12+1=3d\le \dfrac{5-1}{2}+1=3, and the [[5,1,3]][[5,1,3]] code meets it with equality — a quantum MDS code, the smallest code correcting an arbitrary single-qubit error. Why: saturation is the definition of an MDS (maximum-distance-separable) code, and the arithmetic 3=(5−1)/2+13=(5-1)/2+1 certifies the five-qubit code as extremal.

Limiting cases

How distance behaves across the canonical codes and regimes:

CaseResultMeaning
Detection-only coded=2,  t=⌊1/2⌋=0d=2,\ \ t=\lfloor 1/2\rfloor=0detects any single-qubit error but corrects none; the [[4,2,2]][[4,2,2]] code is the smallest example and saturates Singleton at t=0t=0
Single-error-correctingd=3,  t=1d=3,\ \ t=1corrects any one arbitrary-qubit error: Shor [[9,1,3]][[9,1,3]], Steane [[7,1,3]][[7,1,3]], perfect [[5,1,3]][[5,1,3]]
Quantum Singleton ceilingd≤n−k2+1d\le \tfrac{n-k}{2}+1no [[n,k,d]][[n,k,d]] code can exceed this; codes that meet it (e.g. [[5,1,3]][[5,1,3]]) are quantum MDS
Degenerate codestabilizer weight <d<d allowedlight stabilizers are harmless — distance counts only N(S)∖SN(\mathcal{S})\setminus\mathcal{S}, so degeneracy can raise dd but never lower it
Sub-threshold scalingpL∼(p/pth)⌊(d+1)/2⌋p_L\sim (p/p_{\mathrm{th}})^{\lfloor (d+1)/2\rfloor}below threshold each extra unit of distance suppresses the logical error rate by another power of p/pthp/p_{\mathrm{th}}

Worked examples

1 · Reading correction, detection, and thresholds off the distance (fully worked)

For the canonical codes [[9,1,3]][[9,1,3]], [[7,1,3]][[7,1,3]], [[5,1,3]][[5,1,3]], and [[4,2,2]][[4,2,2]], compute the guaranteed correction weight tt, the detection weight, and check each against the quantum Singleton bound. Then estimate how a distance-77 surface code suppresses logical errors when the physical error rate sits a factor of ten below threshold.

Step 1. Correction weight t=⌊(d−1)/2⌋t=\lfloor(d-1)/2\rfloor. For the three d=3d=3 codes, t=⌊2/2⌋=1t=\lfloor 2/2\rfloor=\mathbf{1} — each corrects any single arbitrary-qubit error. For the d=2d=2 code, t=⌊1/2⌋=0t=\lfloor 1/2\rfloor=\mathbf{0} — it corrects nothing.

Step 2. Detection weight is d−1d-1. The d=3d=3 codes detect any error of weight up to 2\mathbf{2} (even though they only correct weight 11); the [[4,2,2]][[4,2,2]] code detects any single-qubit error, weight up to 1\mathbf{1}. Detection is always more generous than correction because detecting requires only a nonzero syndrome, not a unique one.

Step 3. Singleton check d≤(n−k)/2+1d\le(n-k)/2+1. For [[5,1,3]][[5,1,3]]: (5−1)/2+1=3=d(5-1)/2+1=3=d — saturated, a quantum MDS code; for [[4,2,2]][[4,2,2]]: (4−2)/2+1=2=d(4-2)/2+1=2=d — saturated too. For [[9,1,3]][[9,1,3]] the ceiling is 55 and for [[7,1,3]][[7,1,3]] it is 44, both with slack — Shor and Steane trade optimality for simpler structure.

Step 4. Sub-threshold scaling. Below threshold a distance-dd topological code's logical rate falls as pL≈A (p/pth)⌊(d+1)/2⌋p_L\approx A\,(p/p_{\mathrm{th}})^{\lfloor(d+1)/2\rfloor}, the exponent being the ⌈d/2⌉\lceil d/2\rceil physical faults needed for one logical fault. For d=7d=7 it is ⌊8/2⌋=4\lfloor 8/2\rfloor=4; with p/pth=0.1p/p_{\mathrm{th}}=0.1 and A∼0.1A\sim0.1, pL≈0.1×(0.1)4=10−5p_L\approx 0.1\times(0.1)^{4}=\mathbf{10^{-5}} per cycle. Each two units of distance add one more factor of p/pthp/p_{\mathrm{th}} of suppression — why roadmaps chase larger dd.

2 · Coset freedom on the Shor code: a weight-7 disguise of a weight-3 logical

Take the Shor logical Xˉ=Z1Z4Z7\bar{X}=Z_1Z_4Z_7 and multiply it by the stabilizer X1X2X3X4X5X6X_1X_2X_3X_4X_5X_6. Show that the product is a legitimate representative of the same logical operator, that it has weight 77, and that multiplying by the same stabilizer again returns the weight-33 form — demonstrating that distance must be minimized over the coset.

Step 1. Multiply qubit by qubit, using ZX=−iYZX=-iY (the phase is irrelevant to weight and to the logical action). On qubit 11: Z⋅X=YZ\cdot X=Y. Qubits 2,32,3: I⋅X=XI\cdot X=X. Qubit 44: Z⋅X=YZ\cdot X=Y. Qubits 5,65,6: I⋅X=XI\cdot X=X. Qubit 77: Z⋅I=ZZ\cdot I=Z. Qubits 8,98,9: untouched. So Xˉ⋅(X1⋯X6)=Y1X2X3Y4X5X6Z7\bar{X}\cdot(X_1\cdots X_6)=\mathbf{Y_1X_2X_3Y_4X_5X_6Z_7}, weight 7\mathbf{7}.

Step 2. Confirm it is the same logical. Multiplying a logical by a stabilizer never changes its action on the codespace — the stabilizer is the identity there — so Y1X2X3Y4X5X6Z7Y_1X_2X_3Y_4X_5X_6Z_7 and Z1Z4Z7Z_1Z_4Z_7 implement the identical encoded Xˉ\bar{X}. A decoder that only ever saw the weight-77 form would wrongly conclude the code needs seven faults to flip the logical qubit.

Step 3. Reduce it back. Multiply the weight-77 operator by X1X2X3X4X5X6X_1X_2X_3X_4X_5X_6 once more; each XX hits its partner and X⋅X=IX\cdot X=I on qubits 11–66 (with Y⋅X=iZY\cdot X=iZ restoring ZZ on qubits 1,41,4), returning exactly Z1Z4Z7Z_1Z_4Z_7, weight 3\mathbf{3}. The heavy and light strings sit in one coset XˉS\bar{X}\mathcal{S}; the distance uses the light one.

Step 4. The moral in one line: the distance d=3d=3 is a property of the coset, not of any single Pauli string — the same logical wore a weight-7 costume, and only coset minimization stripped it back to its true weight 3. This is precisely why computing distance is, in general, a hard combinatorial search and why constructing provably high-distance codes is delicate.

Physics of the portrait

The modern language of distance and logical operators — normalizers, cosets, the [[n,k,d]][[n,k,d]] triple — was not there at the birth of quantum error correction in 1995; it was imposed a couple of years later, when a graduate student recast the whole subject as group theory.

Origins · 1 minDaniel Gottesman and how this was discovered
DG
Daniel Gottesman
b. 1970 · the stabilizer formalism and fault-tolerant quantum computation

When Peter Shor wrote down the first quantum error-correcting code in 1995, the argument was explicit and hand-built: nine qubits, a specific entangled state, a case-by-case check that single errors could be undone. Within two years the field had a fistful of such codes — Steane's seven-qubit code, the five-qubit perfect code, the CSS constructions from classical linear codes — but no unifying language. Daniel Gottesman supplied it in his 1997 Caltech PhD thesis, Stabilizer Codes and Quantum Error Correction, which reframed a code not as a state but as an abelian group S\mathcal{S} of Pauli operators. In that picture everything becomes algebra: the codespace is the joint +1+1 eigenspace, the syndrome is the list of anticommutations, the logical operators are the normalizer modulo the stabilizer, and the distance is a minimum coset weight — the definition this article is built around. The same formalism produced the Gottesman–Knill theorem, showing that Clifford circuits on stabilizer states are efficiently classically simulable, sharpening exactly where quantum advantage must come from. Gottesman went on to help found fault-tolerant quantum computation and magic-state distillation. The stabilizer language he introduced is now so standard it is easy to forget it was a choice: it turned quantum error correction from a collection of ingenious constructions into a systematic theory where [[n,k,d]][[n,k,d]] is a sentence anyone can parse.

History
1995
— Shor encodes one qubit in nine, the first quantum error-correcting code
1996
— Steane's seven-qubit code, the CSS construction, and the five-qubit perfect code appear
1997
— Knill and Laflamme state the general conditions for a correctable error set
1997
— Gottesman's thesis recasts codes as stabilizer groups and fixes the n,k,d language
2003
— Kitaev's toric code makes distance a topological, homological quantity

Going further

Texts. Nielsen & Chuang, Quantum Computation and Quantum Information, Ch. 10 (stabilizer codes, distance, Knill–Laflamme) · Preskill, Lecture Notes on Quantum Computation, Ch. 7 · Gottesman, Stabilizer Codes and Quantum Error Correction (Caltech PhD thesis, 1997) · Wilde, Quantum Information Theory, 2nd ed., Ch. 22 · Kitaev, Shen & Vyalyi, Classical and Quantum Computation, Ch. 15. A symplectic check confirms that Zˉ=X1X2X3\bar Z=X_1X_2X_3 and Xˉ=Z1Z4Z7\bar X=Z_1Z_4Z_7 commute with all eight Shor stabilizers, anticommute with each other, and have weight 33; the coset representative Y1X2X3Y4X5X6Z7Y_1X_2X_3Y_4X_5X_6Z_7 likewise reduces to weight 33 on multiplication by the stabilizer X1X2X3X4X5X6X_1X_2X_3X_4X_5X_6. Key checkpoints: the two-case Knill–Laflamme sign flip PFP=−PFP⇒PFP=0PFP=-PFP\Rightarrow PFP=0; the Shor commutation table; the arithmetic 3=(5−1)/2+13=(5-1)/2+1 saturating Singleton for [[5,1,3]][[5,1,3]]; and the sub-threshold exponent ⌊(d+1)/2⌋=4\lfloor(d+1)/2\rfloor=4 at d=7d=7.

Prerequisites. Stabilizer Formalism · Pauli Group and Clifford Group · Knill–Laflamme Conditions · Discretization of Errors. Leads to. Quantum Hamming and Singleton Bounds · Syndrome Measurement and Decoding · CSS Codes · Steane Seven-Qubit Code.

Ask the tutor: ask me to compute the minimum-weight logical operators — and hence the distance — of any small stabilizer code you name, and I will walk the coset minimization step by step.

Is the distance the weight of the logical operator, or something more subtle?

Something more subtle. Any logical operator can be multiplied by a stabilizer without changing what it does to the encoded qubits, and that reshapes its Pauli string — often changing its weight. So a logical operator is really an equivalence class (a coset LˉS\bar{L}\mathcal{S}), and the weight that matters is the minimum over the class; the distance minimizes that once more over every nontrivial class. Quoting one representative's weight gives only an upper bound — the true distance can be far smaller.

Why do we exclude the stabilizers when computing the distance?

Because stabilizers are, by definition, the identity on the codespace — they fix every codeword. A stabilizer of weight 22 therefore causes no logical fault no matter how light it is; it just relabels the physical description of a state the code already regards as correct. Distance is meant to measure the smallest harmful undetectable operator, and a stabilizer is undetectable but not harmful. That is exactly why the definition uses N(S)∖SN(\mathcal{S})\setminus\mathcal{S} (undetectable and nontrivial) rather than all of N(S)N(\mathcal{S}), and why a degenerate code with light stabilizers pays no penalty.

What is the difference between detecting and correcting an error?

Detecting an error only requires a nonzero syndrome — the code notices something is wrong. Correcting requires the syndrome to point uniquely to the fix. A distance-dd code detects any error up to weight d−1d-1 (any lighter error either has a nonzero syndrome or is a harmless stabilizer) but corrects only up to weight t=⌊(d−1)/2⌋t=\lfloor(d-1)/2\rfloor, because two distinct weight-tt errors can share a syndrome, and to correct you must never be fooled about which one happened. This is why a d=2d=2 code detects a single error but corrects none, and why even distances buy detection, not extra correction.

Why is there a factor of two — why t = ⌊(d−1)/2⌋ and not d−1?

It is sphere-packing. Correction must handle the true error EaE_a being mistaken for EbE_b; the two are confusable exactly when Ea†EbE_a^\dagger E_b is an undetectable, nontrivial logical. Since wt(Ea†Eb)≤wt(Ea)+wt(Eb)\mathrm{wt}(E_a^\dagger E_b)\le\mathrm{wt}(E_a)+\mathrm{wt}(E_b), keeping both below weight tt keeps their combination below 2t2t; demanding 2t<d2t<d makes it too light to be a logical fault. Solving 2t≤d−12t\le d-1 for integer tt gives the floor. Erasures, where the location is known, avoid the factor of two and only need weight <d<d.

How do logical operators relate to fault-tolerant gates?

The logical operators are the targets. To perform an encoded Xˉ\bar X you must apply some physical operator in the coset XˉS\bar X\mathcal{S}, and a fault-tolerant implementation wants one that is low-weight and does not spread errors — ideally transversal (one physical gate per qubit). Knowing the minimum-weight representatives tells you which transversal gates are available and how a fault on one physical qubit propagates. In the surface code, where a logical operator is a string across the lattice, this same picture drives lattice surgery: you enact logical gates by cutting and joining the boundaries the logical strings terminate on.

Does degeneracy help or hurt a code?

It helps, or at worst is neutral. A degenerate code is one where distinct errors can act identically on the codespace — their product is a stabilizer — so they share a syndrome and a single recovery corrects both. This means the code can have stabilizers lighter than its distance without penalty, and degenerate codes can even beat the counting (quantum Hamming) bound that constrains nondegenerate codes, because they do not need a distinct syndrome for every correctable error. Degeneracy never lowers the distance, since distance already excludes stabilizers; it only ever gives you more room.

Before this

Where this leads