Five-Qubit Perfect Code

The five-qubit perfect code is what optimality looks like in quantum error correction: the smallest possible code that undoes an arbitrary single-qubit error. To diagnose an error on one of nn qubits you must tell apart the identity and the three Paulis XX, YY, ZZ on each qubit — 1+3n1+3n possibilities for a code carrying one logical qubit. Four parity checks supply 24=162^{4}=16 distinct syndromes, and 1616 is exactly 1+3×51+3\times5: every address in the book is filled, once, with no collisions and no spares. That is the literal meaning of perfect — the quantum Hamming bound 2n−1≥1+3n2^{n-1}\ge 1+3n is saturated, and the code is non-degenerate. Concretely it is a stabilizer code, the joint +1+1 eigenspace of four commuting Pauli operators with a beautiful cyclic form, g1=XZZXIg_1=XZZXI rotated one step at a time. Its logical operators Xˉ=XXXXX\bar X=XXXXX and Zˉ=ZZZZZ\bar Z=ZZZZZ have weight five, yet lighter weight-three representatives exist, pinning the distance at d=3d=3 and the correctable weight at t=1t=1. Because XX and ZZ are braided inside every generator, the code is not CSS — it cannot be split into a bit-flip code and a phase-flip code, sharply separating it from the Shor and Steane families. And in a final twist its codewords are absolutely maximally entangled — every two-qubit marginal completely mixed — making it a perfect tensor that reappears far from its origins, in holographic toy models of spacetime.

Key takeaways
  • The five-qubit perfect code, written [[5,1,3]][[5,1,3]], encodes one logical qubit into five and corrects an arbitrary single-qubit error — the smallest quantum code with distance d=3d=3.
  • It is a non-CSS stabilizer code with cyclic generators XZZXI,  IXZZX,  XIXZZ,  ZXIXZXZZXI,\;IXZZX,\;XIXZZ,\;ZXIXZ; its 24=162^{4}=16 syndromes are in exact bijection with the 1+3×5=161+3\times5=16 weight-≤1\le1 error classes.
  • Saturating the quantum Hamming bound 2n−1≥1+3n2^{n-1}\ge 1+3n at n=5n=5 makes it perfect (non-degenerate); it also saturates the Singleton bound k≤n−2(d−1)k\le n-2(d-1), making it quantum MDS.
  • Logical operators Xˉ=XXXXX\bar X=XXXXX, Zˉ=ZZZZZ\bar Z=ZZZZZ (weight 5) have weight-3 equivalents such as Zˉ∼XXIZI\bar Z\sim XXIZI, so d=3d=3 and t=1t=1.
  • Continuous single-qubit noise is corrected because syndrome measurement discretizes any channel into the Pauli basis {I,X,Y,Z}\{I,X,Y,Z\}, each with its own unique syndrome.
  • Its codewords are AME(5,2) states — every two-qubit marginal is 14I4\tfrac14 I_4 — so the code is a perfect tensor and the tile of the HaPPY holographic code.
  • Key idea: saturating the quantum Hamming bound 2n−1≥1+3n2^{n-1}\ge 1+3n at n=5n=5 forces a non-degenerate [[5,1,3]][[5,1,3]] code whose 16 stabilizer syndromes are in exact bijection with the 16 weight-≤1\le1 error classes.

Where this lives today

The five-qubit code remains the reference point of quantum error correction. As the smallest distance-3 code, it is the first thing implemented when a platform claims quantum memory: Knill, Laflamme, Martinez and Negrevergne benchmarked it in liquid-state NMR in 2001, and it has since run on trapped ions and superconducting processors as a proof-of-principle logical qubit. Its trivial sixteen-entry lookup-table decoder makes it ideal for validating syndrome-extraction circuits before scaling to the far larger syndrome spaces of surface codes. Its non-CSS structure keeps it central to fault-tolerance pedagogy — the standard example of limited transversality. And its perfect-tensor character carries it beyond coding: it is the tile of the HaPPY holographic code, a toy model of how bulk information is encoded on a boundary in AdS/CFT, and a primitive for quantum secret sharing where any two of five shares reveal nothing.

The physical picture

Think of error correction as a lost-and-found desk. Every single-qubit error walks in wearing a badge — its syndrome, the pattern of stabilizer checks it trips — and the desk returns the exact inverse operation. For the scheme to work every error must wear a different badge; for it to be perfect every badge must be claimed by exactly one error, none left over. The first figure is that ledger: four parity checks generate sixteen badges, and all sixteen are spoken for.

Figure
The perfect address book: four stabilizer measurements produce a 4-bit syndrome, and all 2⁴ = 16 syndromes are used exactly once — one for the no-error case and one for each of the 3×5 = 15 single-qubit Pauli errors, so 16 = 1 + 15 with no collisions and no spares
Perfect code: 2⁴ = 16 syndromes = 1 + 3×5 = 16 single-qubit error classes measure g₁ g₂ g₃ g₄ → 4-bit syndrome s₁s₂s₃s₄ → look up the unique culprit and undo it 00 01 10 11 00 01 10 11 s₁s₂ s₃s₄ IIIII X···· ··Z·· ····X ····Z ·Z··· ···X· ····Y ·X··· ···Z· Z···· Y···· ··X·· ·Y··· ··Y·· ···Y· no error X error Y error Z error ·=I (dot marks an untouched qubit)

The second picture shows why four checks suffice so elegantly: the code has a fivefold cyclic symmetry. Label the qubits around a ring; the single generator XZZXIXZZXI, rotated one step at a time, produces all four, so no qubit is special. That even-handedness is what makes the codewords' two-qubit marginals maximally mixed — the encoded information is smeared across all five qubits so evenly that any two, examined alone, betray nothing.

Figure
Cyclic structure on a ring of five qubits: the generator g₁ = X Z Z X I lives on the sites, and each further generator is a one-step rotation, g₂ = I X Z Z X, g₃ = X I X Z Z, g₄ = Z X I X Z. The logical operators logical-X = XXXXX and logical-Z = ZZZZZ have weight 5, but weight-3 equivalents exist, so the distance is d = 3
Cyclic generators: rotate XZZXI one step to get the next check — no qubit is special shift i → i+1 (mod 5) Xq₁ Zq₂ Zq₃ Xq₄ Iq₅ g₁ = X Z Z X I (weight 4) g₁ = X Z Z X I g₂ = I X Z Z X g₃ = X I X Z Z g₄ = Z X I X Z X̄ = X X X X X Z̄ = Z Z Z Z Z weight-3 rep: Z̄ ~ X X I Z I ⇒ distance d = 3, corrects t = 1 every 2-qubit marginal = ¼ I₄ (AME)

The core equations

The code is defined by its stabilizer: the abelian group of Paulis that fix every codeword. Four independent generators suffice — a single weight-4 string with its cyclic shifts — and everything downstream (codespace dimension, distance, syndromes) is read off from them.

S=⟨ XZZXI,  IXZZX,  XIXZZ,  ZXIXZ ⟩(1)\mathcal{S}=\langle\, XZZXI,\;IXZZX,\;XIXZZ,\;ZXIXZ \,\rangle \qquad (1)

where: X,Z,IX,Z,I — the single-qubit Paulis and identity on each tensor factor; S\mathcal{S} — the stabilizer group, an abelian subgroup of the Pauli group not containing −I-I; each generator is a one-step cyclic shift of g1=XZZXIg_1=XZZXI. Four commuting generators on five qubits leave a 25−4=22^{5-4}=2-dimensional codespace: one logical qubit. The encoded qubit is manipulated by logical operators — Paulis that preserve the codespace but act nontrivially inside it, lying in the normalizer of S\mathcal{S} but not in S\mathcal{S}. The natural representatives are the all-XX and all-ZZ strings.

Xˉ=XXXXX,Zˉ=ZZZZZ(2)\bar{X}=XXXXX,\qquad \bar{Z}=ZZZZZ \qquad (2)

where: Xˉ,Zˉ\bar X,\bar Z — logical Paulis realizing the encoded qubit's algebra; both have weight 5, but multiplying by stabilizers gives weight-3 equivalents (e.g. Zˉ∼XXIZI\bar Z\sim XXIZI). Xˉ\bar X and Zˉ\bar Z anticommute (five (X,Z)(X,Z) overlaps, odd), exactly as a qubit's XX and ZZ must. The code is perfect because it saturates the quantum Hamming bound: counting weight-≤1\le1 errors against available syndromes gives an inequality first holding, with equality, at n=5n=5.

2 n−1  ≥  1+3n⟹n≥5(3)2^{\,n-1}\;\ge\;1+3n \qquad\Longrightarrow\qquad n\ge 5 \qquad (3)

where: nn — number of physical qubits; 1+3n1+3n — weight-≤1\le1 error classes (identity plus X,Y,ZX,Y,Z on each qubit); 2 n−12^{\,n-1} — syndromes from n−1n-1 generators when k=1k=1. At n=5n=5 this reads 16≥1616\ge16: equality, so every syndrome is used and the code non-degenerate. Correctability is governed by the Knill–Laflamme conditions, the general criterion for a set of errors to be correctable; for a stabilizer code they reduce to a statement about syndromes.

⟨ψi∣ Ea†Eb ∣ψj⟩=Cab δij(4)\langle\psi_i|\,E_a^{\dagger}E_b\,|\psi_j\rangle = C_{ab}\,\delta_{ij} \qquad (4)

where: ∣ψi⟩|\psi_i\rangle — an orthonormal codespace basis (i=0,1i=0,1); Ea,EbE_a,E_b — correctable errors (all weight-≤1\le1 Paulis); CabC_{ab} — a Hermitian matrix independent of i,ji,j. Here Cab=δabC_{ab}=\delta_{ab}: distinct errors give orthogonal, uniquely-labelled outcomes — a non-degenerate code. The logical states come from projecting a product state onto the codespace: the projector built from the generators gives an equal superposition over the sixteen stabilizer images of the seed.

∣0ˉ⟩=14∑g∈Sg ∣00000⟩,P=∏i=14I+gi2=116∑g∈Sg(5)|\bar 0\rangle=\frac{1}{4}\sum_{g\in\mathcal S} g\,|00000\rangle,\qquad P=\prod_{i=1}^{4}\frac{I+g_i}{2}=\frac{1}{16}\sum_{g\in\mathcal S} g \qquad (5)

where: ∣0ˉ⟩|\bar 0\rangle — the logical-zero codeword; PP — the projector onto the joint +1+1 eigenspace; 14=1/16\tfrac14=1/\sqrt{16} normalizes it. Then ∣1ˉ⟩=Xˉ∣0ˉ⟩=4 P ∣11111⟩|\bar 1\rangle=\bar X|\bar 0\rangle=4\,P\,|11111\rangle, orthogonal to ∣0ˉ⟩|\bar 0\rangle; both are equal-amplitude sums of sixteen basis states. Syndrome extraction reads one bit per generator — whether the error commutes or anticommutes with each gig_i — the four bits indexing the table above.

si(E)={0[E,gi]=01{E,gi}=0(6)s_i(E)=\begin{cases}0 & [E,g_i]=0\\[2pt] 1 & \{E,g_i\}=0\end{cases} \qquad (6)

where: si(E)s_i(E) — the ii-th syndrome bit for a Pauli error EE; gig_i — the ii-th generator, measured without disturbing the encoded information since gi2=Ig_i^2=I and the gig_i commute. A weight-≤1\le1 error yields one of the sixteen syndromes in the first figure; the identity gives 00000000. Finally, the structural jewel: the codewords are absolutely maximally entangled — trace out any three qubits and the other two are completely mixed (AME(5,2)).

ρij=Tr⁡ij‾ ∣ψˉ⟩⟨ψˉ∣  =  14 I4for every pair i<j(7)\rho_{ij}=\operatorname{Tr}_{\overline{ij}}\,|\bar\psi\rangle\langle\bar\psi| \;=\;\tfrac14\,I_4 \qquad\text{for every pair } i<j \qquad (7)

where: ρij\rho_{ij} — the two-qubit reduced density matrix on qubits i,ji,j of any codeword ∣ψˉ⟩|\bar\psi\rangle; 14I4\tfrac14 I_4 — the maximally mixed two-qubit state. This AME(5,2) property makes the code a perfect tensor — an isometry from any two legs to the other three.

Derivation AMinimality — why five qubits is the smallest single-error-correcting code

The goal is a hard lower bound: a direct counting argument that no code encoding one logical qubit with distance three exists below five physical qubits, so the five-qubit code is provably optimal, not merely a clever construction. The strategy: count what must be distinguished (error classes) against what distinguishes them (syndromes), demand an injective assignment, and solve the inequality — the quantum Hamming bound at k=1k=1.

Step 1. Count the error classes to diagnose. On nn qubits the weight-≤1\le1 Pauli errors are the identity plus XX, YY, ZZ on each qubit — a total of 1+3n1+3n. Why: after discretization (Derivation C) any single-qubit channel collapses onto exactly this Pauli set, so distinguishing these classes is necessary and sufficient.

Step 2. Count the syndromes available. A code encoding k=1k=1 qubit into nn uses n−1n-1 independent generators, each measured to one parity bit, giving 2 n−12^{\,n-1} syndromes. Why: the syndrome is the only information extracted, so resolvable error classes cannot exceed syndromes.

Step 3. Demand injectivity for a non-degenerate distance-3 code: each of the 1+3n1+3n error classes needs its own syndrome, so 2 n−1≥1+3n2^{\,n-1}\ge 1+3n. Evaluate: n=3n=3 gives 4<104<10; n=4n=4 gives 8<138<13; n=5n=5 gives 16=1616=16. Why: the inequality fails for every n<5n<5, so no [[4,1,3]][[4,1,3]] or smaller code can correct an arbitrary single error.

Step 4. Read off perfectness. Equality at n=5n=5 leaves no slack: all sixteen syndromes are consumed and the code is non-degenerate, saturating the Hamming bound. Why: a strict inequality would leave unused syndromes and permit a degenerate code; equality is precisely the definition of a perfect quantum code. *Verified: 24=16=1+3×52^{4}=16=1+3\times5 and the failures at n=3,4n=3,4 reproduce the quantum Hamming bound and match the perfect-code result of Laflamme, Miquel, Paz and Zurek (1996), confirmed by direct syndrome enumeration.*

Go deeper · Derivation B · 1 minDistance is exactly three
Derivation BDistance is exactly three

The goal is to establish that the distance equals three by bracketing it from both sides: no undetectable logical operator of weight one or two exists (giving d≥3d\ge3), while an explicit weight-three logical operator does (giving d≤3d\le3). The distance is the minimum weight of a Pauli in the normalizer N(S)N(\mathcal S) not in S\mathcal S, so both halves are minimum-weight statements that together pin the correctable weight at t=1t=1.

Step 1. Rule out weight one. Every single-qubit Pauli anticommutes with at least one generator — all fifteen weight-1 errors have nonzero syndrome (the first figure shows none lands on 00000000). Why: a nonzero syndrome means the error is detected, so it is not a silent logical fault; d>1d>1.

Step 2. Rule out weight two. A product of two distinct weight-1 errors has weight ≤2\le2, and the stabilizer holds no non-identity element below weight four. A direct check confirms every weight-2 Pauli either anticommutes with a generator or would be undetectable only if in S\mathcal S, which it is not. Why: an undetectable non-stabilizer element is a logical operator; none of weight ≤2\le2 exists, giving d≥3d\ge3.

Step 3. Exhibit weight three. Multiplying Zˉ=ZZZZZ\bar Z=ZZZZZ by suitable stabilizers yields an equivalent logical operator of weight three, e.g. Zˉ∼XXIZI\bar Z\sim XXIZI; likewise Xˉ∼XZIIZ\bar X\sim XZIIZ. Why: an equivalent operator differs from Zˉ\bar Z by a stabilizer, acting identically on the codespace while weighing only three — capping the distance at d≤3d\le3.

Step 4. Combine the bounds. With d≥3d\ge3 and d≤3d\le3, the distance is exactly d=3d=3, so the code corrects t=1t=1 error and detects any weight-2 error. Why: distance three is the minimum for any single-error-correcting code, and the five-qubit code achieves it. *Verified: an exhaustive search over all 45−14^5-1 non-identity Paulis returns minimum normalizer-minus-stabilizer weight 3, with explicit weight-3 representatives (XXIZI for Z̄, XZIIZ for X̄), consistent with Gottesman's thesis.*

Go deeper · Derivation C · 1 minDiscretization — defeating continuous single-qubit noise
Derivation CDiscretization — defeating continuous single-qubit noise

The goal is to explain the apparent miracle by which correcting a discrete set of four Pauli errors defeats the full continuum of physical single-qubit errors — amplitude damping, small rotations, depolarization, everything. The key is that any single-qubit operator expands in the Pauli basis, so a codeword hit by a continuous error becomes a superposition of Pauli-corrupted codewords, and measuring the syndrome projects onto one branch, reversed exactly.

Step 1. Expand the error. Any single-qubit operator (a Kraus element) on qubit jj is a combination E=αI+βX+γY+δZE=\alpha I+\beta X+\gamma Y+\delta Z, since {I,X,Y,Z}\{I,X,Y,Z\} span the 2×22\times2 matrices. Why: a basis statement true of every single-qubit map, so nothing about the specific channel need be known in advance.

Step 2. Apply it to a codeword: E∣ψ⟩=α∣ψ⟩+βXj∣ψ⟩+γYj∣ψ⟩+δZj∣ψ⟩E|\psi\rangle=\alpha|\psi\rangle+\beta X_j|\psi\rangle+\gamma Y_j|\psi\rangle+\delta Z_j|\psi\rangle, a superposition of the clean codeword and three weight-1 Pauli-corrupted versions, each with its own syndrome. Why: linearity carries the Pauli decomposition to the state, turning a continuous error into a superposition over four discrete, individually-correctable branches.

Step 3. Measure the syndrome. Reading g1…g4g_1\dots g_4 collapses the superposition onto one sector, randomly selecting one branch of {I,Xj,Yj,Zj}\{I,X_j,Y_j,Z_j\}. Why: the outcomes of this projective measurement are exactly the four branches, so the continuum is discretized by the measurement, not by any approximation.

Step 4. Recover. Apply the inverse of the identified Pauli and the encoded state is restored exactly. Because the code corrects all four Paulis on every qubit, it corrects every channel on one qubit. Why: correcting a spanning set of errors corrects their span — the discretization theorem, and why quantum error correction is possible despite continuous noise. *Verified: the standard discretization argument of Nielsen and Chuang, specialized to the five-qubit code's complete weight-1 Pauli coverage; the sixteen distinct syndromes over all fifteen single-qubit Paulis plus identity are enumerated numerically.*

Limiting cases

How the five-qubit code sits among neighbouring codes and information-theoretic bounds:

CaseResultMeaning
Quantum Hamming bound2 n−k=1+3n⇒n=5, k=12^{\,n-k}=1+3n\Rightarrow n=5,\,k=1Saturated — perfect, non-degenerate. Contrast Shor, where 28=256≫282^{8}=256\gg 28, highly degenerate.
Quantum Singleton boundk≤n−2(d−1)⇒1≤5−4=1k\le n-2(d-1)\Rightarrow 1\le 5-4=1Also saturated: the code is quantum MDS, equivalently a perfect tensor and an AME(5,2) state.
Correctable weightt=⌊(d−1)/2⌋=1t=\lfloor(d-1)/2\rfloor=1Corrects every weight-1 error; detects but cannot correct a generic weight-2 error.
Smallest distance-3 codenShor=9>nSteane=7>nfive=5n_{\text{Shor}}=9>n_{\text{Steane}}=7>n_{\text{five}}=5Five is provably the minimum nn for any [[n,1,3]][[n,1,3]] code.
DegeneracyCab=δabC_{ab}=\delta_{ab}Non-degenerate: distinct errors give distinct, orthogonal syndromes.

Worked examples

1 · Decoding a single-qubit error from its syndrome

A logical state is hit by a YY error on qubit 1, i.e. E=YIIIIE=YIIII. Compute the 4-bit syndrome, look it up, and give the recovery. Then confirm no other weight-≤1\le1 error produces the same syndrome.

Step 1. Compute each syndrome bit from equation (6): si=0s_i=0 if EE commutes with gig_i, else 11. Two Paulis anticommute iff they differ (both non-identity, unequal) on an odd number of positions, so with E=YIIIIE=YIIII only qubit 1 of each generator matters.

Step 2. Read qubit 1 of each generator against the YY. For g1=XZZXIg_1=XZZXI it is XX: (Y,X)(Y,X) anticommute, s1=1s_1=\mathbf{1}. For g2=IXZZXg_2=IXZZX it is II: commute, s2=0s_2=\mathbf{0}. For g3=XIXZZg_3=XIXZZ it is XX: anticommute, s3=1s_3=\mathbf{1}. For g4=ZXIXZg_4=ZXIXZ it is ZZ: (Y,Z)(Y,Z) anticommute, s4=1s_4=\mathbf{1}.

Step 3. Assemble s1s2s3s4=1011s_1s_2s_3s_4=\mathbf{1011}. Looking it up (first figure, row 1010, column 1111) returns the unique culprit YY on qubit 1; recovery is to reapply Y1Y_1, since Y12=IY_1^2=I: the encoded state is restored exactly.

Step 4. Confirm uniqueness. Of the sixteen weight-≤1\le1 errors, the identity gives 00000000 and the fifteen Paulis give the fifteen nonzero syndromes, each once; no other error gives 10111011. Syndrome 1011 → recovery Y1Y_1, unambiguous — the meaning of a perfect, non-degenerate code.

2 · Two ways the code is optimal — Hamming and Singleton

Show that the code saturates both the quantum Hamming and quantum Singleton bounds, and contrast its non-degeneracy with the Shor nine-qubit code.

Step 1. Hamming (packing) bound. With n=5n=5, k=1k=1, the syndrome count 2n−k=24=162^{n-k}=2^{4}=16 equals the weight-≤1\le1 error count 1+3n=161+3n=16. Being equal, no syndrome is wasted — the code is perfect and non-degenerate.

Step 2. Singleton bound. It reads k≤n−2(d−1)k\le n-2(d-1); for n=5n=5, d=3d=3: 5−4=1=k5-4=1=k, saturated. A code meeting it is quantum MDS — equivalently, its codewords are AME(5,2).

Step 3. Contrast with Shor. The Shor code has 28=2562^{8}=256 syndromes for only 1+3×9=281+3\times9=28 weight-≤1\le1 errors — a vast surplus, so it is highly degenerate: many errors share a syndrome and correction. The five-qubit code is the opposite extreme — every syndrome does exactly one job, which is why five is the provable minimum while nine is wasteful.

Physics of the portrait

The five-qubit code was discovered twice in the same year, from two directions — one group hunting the smallest possible code, another studying how entanglement can be purified.

:::physicist[five-qubit perfect code|the smallest single-error-correcting code, 5,1,3, discovered 1996|stabilizer quantum error correction] Quantum error correction was born in 1995 when Peter Shor exhibited a nine-qubit code, silencing the belief that no-cloning and measurement back-action made it impossible; Andrew Steane's seven-qubit CSS code followed within months. How small could a single-error-correcting code be? In 1996 two teams answered five, independently. Raymond Laflamme, Cesar Miquel, Juan Pablo Paz and Wojciech Zurek published the explicit five-qubit code and proved it perfect, saturating the quantum Hamming bound. The same year, Charles Bennett, David DiVincenzo, John Smolin and William Wootters reached the identical code from mixed-state entanglement and purification, showing it was entanglement-optimal too — the two viewpoints, minimal redundancy and maximal entanglement, describe one and the same state. Daniel Gottesman's 1997 thesis then supplied the stabilizer formalism that recast the code as four commuting generators with a clean cyclic symmetry, the description used ever since. Decades later the same perfect tensor resurfaced as the tile of the HaPPY holographic code, a toy model of AdS/CFT — a combinatorial optimum from coding theory becoming a building block for quantum gravity.

Origins · 1 minhow this was discovered
History
1995
— Shor's nine-qubit code proves quantum error correction is possible
1996
— Laflamme, Miquel, Paz and Zurek publish the five-qubit perfect code
1996
— Bennett, DiVincenzo, Smolin and Wootters reach the same code from mixed-state entanglement
1997
— Gottesman's stabilizer formalism recasts the code as four commuting generators
2015
— the code becomes the perfect-tensor tile of the HaPPY holographic model

Going further

Texts. Nielsen and Chuang, Quantum Computation and Quantum Information, §10.5.6 and §10.3 · Preskill, Lecture Notes on Quantum Computation, Ch. 7 · Gottesman, Stabilizer Codes and Quantum Error Correction (PhD thesis, 1997) · Kitaev, Shen and Vyalyi, Classical and Quantum Computation, §15 · Wilde, Quantum Information Theory, Ch. 10.

Provenance. The stabilizer generators, logical operators, and [[5,1,3]][[5,1,3]] parameters are from Nielsen and Chuang §10.5.6, Gottesman's thesis (1997), and Laflamme, Miquel, Paz and Zurek, Phys. Rev. Lett. 77, 198 (1996); the mixed-state-entanglement route is Bennett, DiVincenzo, Smolin and Wootters, Phys. Rev. A 54, 3824 (1996). Every claim was re-verified numerically: the Hamming arithmetic 24=16=1+3×52^{4}=16=1+3\times5 and its failure at n=3,4n=3,4; pairwise commutation of the four generators and codespace dimension 2; Xˉ,Zˉ\bar X,\bar Z commuting with every generator and mutually anticommuting; distance d=3d=3 by exhaustive minimum-weight search, with weight-3 representatives XXIZIXXIZI and XZIIZXZIIZ; sixteen weight-≤1\le1 errors mapping to sixteen distinct syndromes; the AME(5,2) property ρij=14I4\rho_{ij}=\tfrac14 I_4; and ∣1ˉ⟩=4 P∣11111⟩|\bar 1\rangle=4\,P|11111\rangle orthogonal to ∣0ˉ⟩|\bar 0\rangle. Singleton/MDS and perfect-tensor properties are cross-checked against Bennett et al. and the AME literature.

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

Ask the tutor: Ask me to walk through the sixteen-entry syndrome table by hand, or to show exactly how multiplying Zˉ=ZZZZZ\bar Z=ZZZZZ by a stabilizer produces the weight-3 logical operator XXIZIXXIZI.

Why exactly five qubits — why won't four do?

Because the counting does not close before five. Correcting an arbitrary single error demands a distinct syndrome for each of the 1+3n1+3n weight-≤1\le1 Pauli errors, and n−1n-1 generators supply only 2 n−12^{\,n-1} syndromes. The requirement 2 n−1≥1+3n2^{\,n-1}\ge1+3n gives 4<104<10 at n=3n=3 and 8<138<13 at n=4n=4: too few syndromes, so some error is misdiagnosed. At n=5n=5 the numbers meet exactly, 16=1616=16, and the code becomes possible — and perfect, with no slack. Four qubits provably cannot host a distance-3 code.

What does "perfect" actually mean for a quantum code?

It means the code saturates the quantum Hamming (sphere-packing) bound with equality: the number of syndromes exactly equals the number of correctable error classes, so every syndrome is used and none wasted. Equivalently the code is non-degenerate — distinct errors always give distinct, orthogonal syndromes, so the Knill–Laflamme matrix CabC_{ab} is simply δab\delta_{ab}. "Perfect" is about tightness, not reliability: the code still fails on weight-2 errors, just as the classical Hamming code is perfect. Degenerate codes like Shor's have far more syndromes than errors and let several errors share one correction.

Is the five-qubit code a CSS code, and why does it matter?

No. CSS codes have generators that are each purely XX-type or purely ZZ-type, letting bit-flip and phase-flip errors be handled by two independent classical codes. The five-qubit generators, like XZZXIXZZXI, mix XX and ZZ within one string, so no such separation exists. This matters practically: CSS shortcuts such as a transversal logical CNOT and independent XX/ZZ decoding do not apply, and you must use the full stabilizer formalism throughout. That extra demand is exactly why the code teaches so well — quantum error correction stripped of the classical scaffolding.

Why can't the code correct a weight-2 error?

Its distance is d=3d=3, and a distance-dd code corrects t=⌊(d−1)/2⌋t=\lfloor(d-1)/2\rfloor errors, here t=1t=1. Correcting up to weight tt needs the "spheres" of radius tt around distinct codewords disjoint; distance 3 makes radius-1 spheres disjoint but radius-2 spheres overlap. A generic weight-2 Pauli either shares a syndrome with some weight-1 error — so the decoder miscorrects and leaves a residual logical fault — or lands on a logical operator directly. The code can detect many weight-2 errors but cannot reliably correct them; that needs a distance-5 code.

How can measuring only four Pauli parities correct a continuous error?

This is the discretization theorem. Any single-qubit error, however continuous — a small rotation, amplitude damping, dephasing — expands in the Pauli basis as αI+βX+γY+δZ\alpha I+\beta X+\gamma Y+\delta Z. On a codeword it gives a superposition of the clean state and three Pauli-corrupted states, each with a distinct syndrome. Measuring the four generators collapses this onto one branch, selecting a definite Pauli error you then invert exactly. The measurement itself does the discretizing — so correcting the four Paulis on every qubit corrects the whole continuum of single-qubit channels.

What is the significance of the codewords being absolutely maximally entangled?

The codewords are AME(5,2) states: trace out any three of the five qubits and the remaining two are exactly maximally mixed, 14I4\tfrac14 I_4, revealing nothing about the logical state. This is the strongest possible entanglement for five qubits, equivalent both to the code being quantum MDS (saturating the Singleton bound) and to it being a perfect tensor — an isometry from any two legs to the other three. The property that minimizes qubit count also maximizes entanglement, which is why the code doubles as a primitive for quantum secret sharing and the tile of the HaPPY holographic code.

Why is the cyclic symmetry of the generators useful?

Writing the code as the single generator XZZXIXZZXI and its cyclic shifts exposes a Z5\mathbb{Z}_5 symmetry: rotating the qubit labels i→i+1i\to i+1 leaves the code invariant, so no qubit is distinguished. This has real payoffs. It makes the AME property manifest — if every qubit is equivalent, so is every pair, and their marginals must be identical (and maximally mixed). It compresses the code to essentially one operator, and makes it a clean, symmetric benchmark where treating all five qubits alike simplifies circuit compilation and error characterization.

Before this

Where this leads