Skip to content

The Shor code protects one qubit using nine physical qubits arranged in three blocks of three. Checks within a block locate bit flips; checks between blocks locate phase flips. Together they correct an arbitrary error on any one physical qubit, including coherent noise and noise coupled to an environment. This is the [[9,1,3]][[9,1,3]] code introduced by Shor (1995).

Its most instructive feature is degeneracy: a phase flip on any of the three qubits in the same block has exactly the same effect on the encoded state. Recovery can reverse that effect without learning which qubit flipped. The discussion below assumes ideal encoding, check measurements, and corrections; noisy operations require the additional methods of fault tolerance.

Required background. Three-Qubit Codes explains bit- and phase-repetition encoding. Stabilizer Formalism supplies commuting Pauli checks, their syndromes, and code projectors.

Use blocks A=(1,2,3)A=(1,2,3), B=(4,5,6)B=(4,5,6), and C=(7,8,9)C=(7,8,9), with qubit 1 on the left in tensor strings. Define the normalized states

∣G±⟩=∣000⟩±∣111⟩2.\lvert G_\pm\rangle =\frac{\lvert000\rangle\pm\lvert111\rangle}{\sqrt2}.

The logical basis is

∣0L⟩=∣G+⟩⊗3,∣1L⟩=∣G−⟩⊗3.\begin{aligned} \lvert0_L\rangle&=\lvert G_+\rangle^{\otimes3},\\ \lvert1_L\rangle&=\lvert G_-\rangle^{\otimes3}. \end{aligned}

These states are orthogonal because ⟨G+∣G−⟩=0\langle G_+\vert G_-\rangle=0. Encoding maps an unknown α∣0⟩+β∣1⟩\alpha\lvert0\rangle+\beta\lvert1\rangle to the superposition α∣0L⟩+β∣1L⟩\alpha\lvert0_L\rangle+\beta\lvert1_L\rangle. It does not make nine copies of the input.

To see the construction, first encode into the phase-repetition states ∣+++⟩\lvert+++\rangle and ∣−−−⟩\lvert---\rangle. Encode each of these three qubits using ∣0⟩↦∣000⟩\lvert0\rangle\mapsto\lvert000\rangle and ∣1⟩↦∣111⟩\lvert1\rangle\mapsto\lvert111\rangle. Thus ∣+⟩\lvert+\rangle becomes ∣G+⟩\lvert G_+\rangle and ∣−⟩\lvert-\rangle becomes ∣G−⟩\lvert G_-\rangle. The outer encoding protects phase information; the inner encoding adds protection against bit flips.

Each component repetition code has full Pauli distance one: it protects against one type of error while leaving the other type unprotected. Consequently, multiplying two claimed distances of three is not a valid proof. We will prove the distance of the combined code directly.

Let XA=X1X2X3X_A=X_1X_2X_3, with analogous definitions for XBX_B and XCX_C. Choose the checks

g1=Z1Z2,g2=Z2Z3,g3=Z4Z5,g4=Z5Z6,g5=Z7Z8,g6=Z8Z9,g7=XAXB,g8=XBXC.\begin{aligned} g_1&=Z_1Z_2,&g_2&=Z_2Z_3,\\ g_3&=Z_4Z_5,&g_4&=Z_5Z_6,\\ g_5&=Z_7Z_8,&g_6&=Z_8Z_9,\\ g_7&=X_AX_B,&g_8&=X_BX_C. \end{aligned}

The first six check whether neighboring bits agree within each block. The last two compare the XXXXXX eigenvalues of neighboring blocks. Although a single XX anticommutes with a single ZZ, an outer check overlaps each inner check at zero or two sites, so all eight commute. They are independent and stabilize both logical basis states. Their common +1+1 eigenspace therefore has dimension 29−8=22^{9-8}=2, with projector

P=∏a=18I+ga2.P=\prod_{a=1}^{8}\frac{I+g_a}{2}.

This separate choice of all-XX and all-ZZ generators makes the Shor code a CSS code. The stabilizer description follows the general construction in Gottesman (1997).

Three blocks of three qubits, with adjacent Z checks inside each block and X checks joining pairs of blocks.

The six solid brackets indicate ZZZZ checks. Each dashed bracket indicates an XX on every qubit of its two blocks. The checks compare relations within and between blocks; they do not measure the logical amplitudes α\alpha and β\beta. Brackets show operator support, not a measurement circuit.

For the chosen logical basis,

X‾=Z1Z4Z7,Z‾=X1X2X3.\overline X=Z_1Z_4Z_7, \qquad \overline Z=X_1X_2X_3.

A physical ZZ exchanges G+G_+ and G−G_- in its block. One ZZ in every block therefore exchanges the logical basis states, which explains the name X‾\overline X. Conversely, XXXXXX has eigenvalues +1+1 and −1-1 on G+G_+ and G−G_-, so XAX_A acts as logical ZZ. Physical Pauli letters do not determine logical Pauli names; their action on the chosen basis does. The two representatives anticommute and commute with all checks.

Write a syndrome bit as sa=0s_a=0 for a +1+1 check result and sa=1s_a=1 for a −1-1 result. Arrange the syndrome as the three inner pairs followed by the outer pair:

s=(s1s2, s3s4, s5s6; s7s8).s=(s_1s_2,\ s_3s_4,\ s_5s_6;\ s_7s_8).

An XX or YY error changes the inner pair in its block. A ZZ or YY error changes the outer pair. Both decoding steps use the same small table:

Pair Inner correction within that block Outer phase correction
0000 None None
1010 XX on the first qubit Z1Z_1 in block AA
1111 XX on the second qubit Z4Z_4 in block BB
0101 XX on the third qubit Z7Z_7 in block CC

For example, an XX at the second position anticommutes with both adjacent ZZZZ checks, giving 1111. A phase flip in block BB anticommutes with both outer checks, also giving 1111. The same binary pattern describes two different comparisons, so keep track of which pair was measured.

Apply the inner corrections in each block, then the outer correction. Call the resulting Pauli CsC_s. This specifies a recovery for all 256 syndromes, including those caused by several errors. It guarantees success for arbitrary one-qubit noise; success for larger errors depends on their pattern.

Suppose Y5Y_5 occurs. Its syndrome is

s(Y5)=(00,11,00;11).s(Y_5)=(00,11,00;11).

The inner step applies X5X_5 and the outer step applies Z4Z_4. Since Y5=iX5Z5Y_5=iX_5Z_5, their combined action leaves

CsY5=Z4X5Y5=iZ4Z5=ig3.C_sY_5=Z_4X_5Y_5=iZ_4Z_5=i g_3.

Every code state is a +1+1 eigenstate of g3g_3, so recovery restores the original state up to an irrelevant phase. It need not literally apply the same Pauli that caused the error.

The syndrome projectors and recovery channel are

Πs=∏a=18I+(−1)saga2,R(ρ)=∑sCsΠsρΠsCs†.\begin{aligned} \Pi_s&=\prod_{a=1}^{8}\frac{I+(-1)^{s_a}g_a}{2},\\ \mathcal R(\rho)&=\sum_s C_s\Pi_s\rho\Pi_s C_s^\dagger. \end{aligned}

Each CsC_s has syndrome ss and takes its sector back to the code space. Because the projectors sum to II, this channel preserves trace on the whole nine-qubit space. The syndrome-measurement page explains the associated measurement instrument and why retaining or discarding the classical result matters.

Why indistinguishable errors can be corrected

Section titled “Why indistinguishable errors can be corrected”

Within block AA, the stabilizers imply

Z1P=Z2P=Z3P.Z_1P=Z_2P=Z_3P.

Thus these errors have both the same syndrome and the same action on every encoded state. Correction by Z1Z_1 reverses any of them. The same reasoning applies to blocks BB and CC. This is degeneracy, rather than a failure to measure enough information.

The identity and 27 single-qubit Paulis occupy

1+9+9+3=221+9+9+3=22

different syndrome sectors: one for the identity, nine each for XjX_j and YjY_j, and three for the blockwise ZZ classes. Each sector has dimension two, so these errors occupy 44 of the 512 Hilbert-space dimensions. The code is not a perfect packing such as the five-qubit code.

More formally, order the error operators as II, the nine XjX_j, the nine YjY_j, and the nine ZjZ_j. The Knill–Laflamme condition is

PEa†EbP=CabP.PE_a^\dagger E_bP=C_{ab}P.

Here

C=I19⊕J3⊕J3⊕J3,C=I_{19}\oplus J_3\oplus J_3\oplus J_3,

where J3J_3 is the 3×33\times3 all-ones matrix. Its off-diagonal entries express the equality of the three phase errors in each block. The matrix has rank 22; it need not be diagonal for correction to work.

This condition corrects the linear span of the listed operators. For instance, a rotation e−iθY5/2e^{-i\theta Y_5/2} is a combination of II and Y5Y_5 and is corrected for every θ\theta, not merely to first order. An arbitrary one-qubit interaction with an environment likewise expands in I,X,Y,ZI,X,Y,Z. The environment coefficients can be unknown and nonorthogonal. Logical-state independence of CC ensures that recovery preserves superpositions and entanglement with an untouched reference. See Why Quantum Error Correction Is Possible for the general argument.

The correctable span can also contain coherent sums of operators on different sites. This does not imply that every operator acting simultaneously on two qubits is correctable.

Distance three and errors that imitate one another

Section titled “Distance three and errors that imitate one another”

Distance concerns a Pauli that commutes with all checks but acts nontrivially on the logical qubit. Global Pauli phases are ignored in this statement; a scalar such as −I-I is not a nontrivial logical operation.

Represent a Pauli, up to phase, by bit strings (x,z)(x,z), where xjx_j records an XX component and zjz_j a ZZ component. Commutation with the inner ZZZZ checks forces xx to be constant within each block. An operator of weight at most two must therefore have x=0x=0.

Let a,b,ca,b,c be the parity of its ZZ support in the three blocks. Commutation with the outer checks gives a=b=ca=b=c. Weight at most two rules out three odd parities, so all are even. The only nonidentity possibilities are two ZZ operators in a single block, and these are stabilizers. Thus no nontrivial logical Pauli has weight one or two. The displayed weight-three X‾\overline X and Z‾\overline Z prove d=3d=3.

Every error on one physical qubit is consequently correctable. Every Pauli of weight two satisfies the detection condition PEP=cEPPEP=c_EP, but a stabilizer has cE=1c_E=1 and raises no alarm: it does no damage to the encoded state.

Other weight-two errors can imitate weight-one errors while acting differently on the code:

Actual error Same syndrome as Residual after the stated recovery
Z1Z2Z_1Z_2 II ILI_L
X1X2X_1X_2 X3X_3 Z‾\overline Z
Z1Z4Z_1Z_4 Z7Z_7 X‾\overline X

For example, X1X2X_1X_2 causes the decoder to apply X3X_3, leaving X1X2X3=Z‾X_1X_2X_3=\overline Z. This ambiguity is different from degeneracy: Z1Z_1 and Z2Z_2 act identically on the code, whereas X1X2X_1X_2 and X3X_3 differ by a logical operation. Returning to the code space alone does not establish successful recovery.

For a concrete error-rate calculation, take independent noise on each qubit with

Dp(ρ)=(1−p)ρ+p3(XρX+YρY+ZρZ).\mathcal D_p(\rho)=(1-p)\rho +\frac p3(X\rho X+Y\rho Y+Z\rho Z).

Here pp is the probability of a nonidentity Pauli; complete depolarization occurs at p=3/4p=3/4. Use the recovery specified by the two repetition rules, including its action on syndromes from multiple errors. The resulting logical channel is a Pauli channel, but generally not a depolarizing channel: the code and decoder treat the two logical axes differently.

There are (92)32=324\binom92 3^2=324 weight-two Pauli strings. Their residual logical classes are

Residual class Number Contribution at order p2p^2
ILI_L 180180 No logical error
X‾\overline X 108108 12p212p^2
Y‾\overline Y 00 Zero
Z‾\overline Z 3636 4p24p^2

Thus the probability of a nonidentity logical Pauli is

pL=16p2+O(p3).p_L=16p^2+O(p^3).

The 36 logical-ZZ failures have two bit-flip components in one block. The 108 logical-XX failures have phase-flip components in two different blocks. Exercise 7 derives these counts. In particular, an isotropic physical Pauli distribution can produce anisotropic logical noise.

An exact calculation at larger pp can enumerate the 494^9 Pauli strings. If Nw,LN_{w,L} counts strings of weight ww with residual logical class LL, then

pL(p)=∑w=09∑L≠ILNw,L(p3)w(1−p)9−w.p_L(p)=\sum_{w=0}^{9}\sum_{L\ne I_L} N_{w,L}\left(\frac p3\right)^w(1-p)^{9-w}.

This expression also explains two checks: pL(0)=0p_L(0)=0, and pL(3/4)=3/4p_L(3/4)=3/4 because uniform physical Paulis give equally many strings in each logical class. Neither the small-pp coefficient nor the exact finite-code result is a fault-tolerance threshold. Noisy check extraction, correlations, and repeated correction change the problem.

1. Read the logical operators from the codewords

Section titled “1. Read the logical operators from the codewords”

Prove that the codewords are orthonormal and stabilized by all eight checks. Explain why the physical ZZ product represents logical XX, and the physical XX product represents logical ZZ.

Solution

Each cat state is normalized and their overlap vanishes, so the tensor products are orthonormal. Adjacent ZZZZ checks give +1+1 on both 000000 and 111111. Also XXX∣G±⟩=±∣G±⟩XXX\lvert G_\pm\rangle=\pm\lvert G_\pm\rangle. Each outer check multiplies two equal block eigenvalues, giving +1+1 for either logical codeword.

The operator Z1Z4Z7Z_1Z_4Z_7 exchanges all three cat signs, so it exchanges 0L0_L and 1L1_L. The operator X1X2X3X_1X_2X_3 multiplies 0L0_L by +1+1 and 1L1_L by −1-1. These are exactly the actions defining logical XX and logical ZZ. Their overlap at qubit 1 contributes one anticommutation.

Starting from outer phase repetition and inner bit repetition, derive the two six-qubit checks. Why does this construction still require a separate distance argument?

Solution

The outer checks are XAXBX_AX_B and XBXCX_BX_C. Inner bit repetition replaces the XX of each outer qubit by the product of three physical XX operators. This yields g7=X1X2X3X4X5X6g_7=X_1X_2X_3X_4X_5X_6 and g8=X4X5X6X7X8X9g_8=X_4X_5X_6X_7X_8X_9. The six inner checks are the two adjacent ZZZZ pairs in each block.

Each repetition code separately has a weight-one logical Pauli on its unprotected axis and therefore full distance one. Its ability to correct a particular type of error is insufficient for multiplying full quantum-code distances. The direct commutation argument above establishes the combined code’s distance three.

Find the syndromes and recovery residuals for Z2Z_2, X8X_8, and Y5Y_5. Use the specified two-stage decoder.

Solution

The syndromes are

s(Z2)=(00,00,00;10),s(X8)=(00,00,11;00),s(Y5)=(00,11,00;11).\begin{aligned} s(Z_2)&=(00,00,00;10),\\ s(X_8)&=(00,00,11;00),\\ s(Y_5)&=(00,11,00;11). \end{aligned}

The corrections are Z1Z_1, X8X_8, and Z4X5Z_4X_5. They leave Z1Z2=g1Z_1Z_2=g_1, II, and iZ4Z5=ig3iZ_4Z_5=i g_3, respectively. Each acts as a scalar on the code. The phase in the third result has no effect on the recovered density operator.

Derive the nonzero entries and eigenvalues of CC in the Knill–Laflamme condition. What does a zero eigenvalue mean here?

Solution

Each Pauli squared gives II, so each diagonal entry is one. Distinct errors with different syndromes give zero projected cross terms. The exceptions are ZZ errors within one block: their products are stabilizers, giving off-diagonal entries one. Therefore C=I19⊕J3⊕J3⊕J3C=I_{19}\oplus J_3\oplus J_3\oplus J_3.

Each J3J_3 has eigenvalues 3,0,03,0,0. Thus CC has nineteen eigenvalues one, three eigenvalues three, and six zero eigenvalues. A null direction such as Z1−Z2Z_1-Z_2 annihilates the code. It expresses redundant error descriptions, not a lost logical state.

Apply U=cos⁡(θ/2)I−isin⁡(θ/2)Y5U=\cos(\theta/2)I-i\sin(\theta/2)Y_5 to an encoded state, possibly entangled with a reference. Show that syndrome measurement and correction restore it for every angle.

Solution

Let ∣Ψ⟩\lvert\Psi\rangle include the untouched reference. The two terms lie in the zero syndrome and the Y5Y_5 syndrome, so their probabilities are cos⁡2(θ/2)\cos^2(\theta/2) and sin⁡2(θ/2)\sin^2(\theta/2), independent of the logical state. The zero branch requires no correction. In the second branch, CsY5=ig3C_sY_5=i g_3; hence the factor −i-i in UU cancels the residual ii and the branch is proportional to ∣Ψ⟩\lvert\Psi\rangle.

After discarding the syndrome, the output is

[cos⁡2θ2+sin⁡2θ2]∣Ψ⟩⟨Ψ∣=∣Ψ⟩⟨Ψ∣.\left[\cos^2\frac\theta2+\sin^2\frac\theta2\right] \lvert\Psi\rangle\langle\Psi\rvert =\lvert\Psi\rangle\langle\Psi\rvert.

Linearity extends the result to mixed reference-entangled inputs. No small-angle approximation has been used.

6. Separate harmless degeneracy from a logical mistake

Section titled “6. Separate harmless degeneracy from a logical mistake”

Compare Z1Z2Z_1Z_2, X1X2X_1X_2, and Z1Z4Z_1Z_4. Does distance three imply that all weight-two errors cause logical failure?

Solution

Z1Z2Z_1Z_2 is a stabilizer and needs no correction. The two inner bit flips X1X2X_1X_2 produce pair 0101 in block AA, causing correction X3X_3 and leaving Z‾\overline Z. The two phase flips Z1Z4Z_1Z_4 produce outer pair 0101, causing correction Z7Z_7 and leaving X‾\overline X.

Distance three guarantees correction of all weight-one errors and excludes lower-weight nontrivial logical operators. It does not require every larger error to fail. Some are stabilizers, and others happen to be reversed by the chosen decoder. Here 180 of the 324 weight-two Pauli strings have identity residual logical class.

Derive the 36 and 108 weight-two failures in the table. Explain why no logical YY appears at this order. For an optional computational extension, enumerate all Pauli strings and check the uniform-noise limit.

Solution

A logical ZZ needs two bit-flip components in one block. Choose the block, a pair of sites, and either XX or YY at each site:

3(32)22=36.3\binom32 2^2=36.

A logical XX needs phase-flip components in two distinct blocks. Choose two blocks, a site in each, and either ZZ or YY at each site:

(32)3222=108.\binom32 3^2 2^2=108.

With only two affected qubits, the first event requires the same block and the second requires different blocks. They cannot occur together, so there is no logical YY at weight two. Each particular weight-two Pauli has probability (p/3)2(1−p)7(p/3)^2(1-p)^7. Higher weights enter at order p3p^3, giving

pL=(36+108)p29+O(p3)=16p2+O(p3).\begin{aligned} p_L&=(36+108)\frac{p^2}{9}+O(p^3)\\ &=16p^2+O(p^3). \end{aligned}

For the extension, compute each string’s syndrome, apply the two correction rules, and classify the residual by its commutation with X‾\overline X and Z‾\overline Z. Each of the four logical classes contains 65,536 strings. At p=3/4p=3/4 all 494^9 strings are equally probable, so three quarters produce a nonidentity logical Pauli. This exact limit does not justify using the leading 16p216p^2 approximation at large pp.