Conventions: qubits from the left; syndrome bit is iff the error anticommutes with check . The five-qubit checks are , , , , in that order.
Problem 1
Problem 3.1 (Logical operators of small codes).
For the phase-flip code , how many Pauli strings (mod phase) lie in ? Choose and and find the distance.
The code has . Show that , that and are valid logical operators, and that .
In the code, and have the same syndrome. Can a decoder correct both? What does this say about distance-2 codes?
Solution
Two independent checks on three qubits, so (an enumeration agrees). The code is the bit-flip code in the Hadamard basis, so swap in the bit-flip answer: (maps ) and . They anticommute (one clash). Since is a weight-1 logical, .
The checks commute: clashes twice with and with , and the two -checks commute. They are independent ( is the only one with an , and ), so and .
: commutes with (no clash), (two clashes), (no clash). It is not in , since the only stabilizers with s are times -type elements, which have on all four qubits.
: commutes with (two clashes) and with the -checks. It is not a product of and (those give ).
and clash only on qubit 1, so they anticommute as required.
Both have weight 2. No weight-1 operator is logical: any single anticommutes with one of the -checks and any single or anticommutes with . So (a brute-force search agrees, with witness ).
, but is a logical operator. Whichever correction the decoder picks, it is wrong for the other error: applying when happened leaves . A distance-2 code detects every single-qubit error (all have non-zero syndrome) but cannot correct them all, consistent with .
Problem 2
Problem 3.2 (Decoding the five-qubit code).
Using the syndrome table of the notes, decode the syndromes , and .
Show directly (by counting clashes) that has syndrome .
The error occurs. What does the lookup decoder do, and what is the result?
Why can no lookup decoder for this code correct all two-qubit errors?
Solution
, , .
clashes with a check iff the check has or on qubit 3. The third letters of are , so anticommutes with and commutes with : syndrome .
By additivity , the syndrome of . The decoder applies , leaving . This commutes with all checks but is not a stabilizer (all non-identity stabilizers have weight 4), so it is a weight-3 logical operator: the decoder has introduced a logical error.
The code is perfect: the 16 syndromes are all used by “no error” and the 15 single-qubit errors. There are two-qubit Paulis, and each has a syndrome already “claimed” by a weight error. Correcting a two-qubit error with syndrome equal to that of a single-qubit would require , but has weight at most 3 and all stabilizers have weight 4. So every two-qubit error is decoded to a single-qubit correction and fails.
Problem 3
Problem 3.3 (The four-qubit code).
Consider .
Show this is a code.
Verify that , , , form two logical qubits: each anticommutes with and commutes with the other three.
Compute the syndromes of all single-qubit errors. Explain why the code detects but cannot correct single-qubit errors.
Solution
and clash four times, so they commute; they are independent, so . Every single-qubit error anticommutes with at least one check (see part 3), so there is no logical of weight 1; commutes with both checks and is not in , so .
Each of the four operators has an even number of s or s overlapping each check, so they lie in , and none is in . Clash counts: vs : 1 (anticommute); vs : 1 (anticommute); vs : 2; vs : 2; and -type pairs and -type pairs never clash. So the commutation relations are those of two independent qubits.
anticommutes with only: . anticommutes with only: . anticommutes with both: . Every single-qubit error is detected, but the syndrome says nothing about which qubit was hit, and e.g. and differ by , a logical operator. This is the smallest error-detecting code, used for example in post-selected experiments.
Problem 4
Problem 3.4 (Syndrome-extraction circuits).
Show that the ancilla circuit of the notes (, controlled- gates, , measure) leaves the joint state .
Show that . Use it to explain why “ancilla , s, , measure” and “ancilla , CNOTs from data to ancilla, measure” both measure .
Draw (in words) a circuit that measures . On the state with a error on qubit 3, what does the ancilla read?
Solution
After the first the ancilla is . The controlled gates apply to the data exactly when the ancilla is : . The second gives
Outcome occurs with probability and projects onto the eigenspace of .
is symmetric in its two qubits, so it can also be read as “control , apply to ”. Conjugating the target by turns that into : (we also checked this identity with Stim tableaus). In the first circuit the ancilla starts in and undergoes . Since we may insert between consecutive gates, so , which is the second circuit. Both record the parity in the ancilla. (A Stim simulation gives identical outcomes on several test states.)
Ancilla in (that is, then ), CNOTs with the ancilla as control and each of qubits 1-4 as targets, then and a -basis measurement. The state is a eigenvector of ; anticommutes with , so times the state is a eigenvector and the ancilla reads with certainty (confirmed in Stim).
Problem 5
Problem 3.5 (Degeneracy in Shor's code).
Which single-qubit errors have the same syndrome as ? Show they all act identically on the code.
How many weight-2 elements does Shor’s stabilizer group contain? Why does this make the code degenerate in the sense of Definition 3.5?
Shor’s code has 27 single-qubit errors but only 21 distinct single-qubit syndromes, while the five-qubit code has 15 errors and 15 syndromes. Explain why Shor’s code can still correct every single-qubit error.
Solution
(all commute with the checks and anticommute with both -checks; an enumeration finds exactly these three). Their pairwise products , , are stabilizers, so e.g. .
In each block, for the three pairs are stabilizers, giving weight-2 stabilizers (confirmed by enumeration). With , degeneracy asks for a non-identity stabilizer of weight ; these qualify.
By Theorem 3.1 we need for all single-qubit . Errors with different syndromes are fine. and errors all have distinct syndromes, because their parts are located exactly by the checks, and an error never triggers an -check. The only coincidences are , in the same block, which by part 1 differ by the stabilizer . So every product is harmless or detectable. Each block’s three errors share one syndrome, losing two syndromes per block: . Degenerate codes can correct more errors than they have syndromes.
Problem 6
Problem 3.6 (Bounds).
Show that the code meets both the quantum Hamming and the quantum Singleton bound with equality.
What is the smallest for which a nondegenerate code is allowed by the Hamming bound? What does Singleton say?
For a nondegenerate code with , show that . Evaluate the largest allowed at .
Solution
Hamming with : . Singleton: .
With and we need . At : . At : . So for nondegenerate codes. Singleton gives , i.e. , for all codes. (These are only bounds; the smallest distance-5 code actually has .)
With the Hamming bound is , i.e. . The largest integer is at (), at (), and at (, while would need ). The rate can approach for distance 3; the interesting question is what happens when grows with (Module 12).
Problem 7
Problem 3.7 (A brute-force distance finder).
Write a function that takes a list of checks (Pauli strings), computes , and finds by searching Pauli strings in order of increasing weight for one that (a) commutes with every check and (b) is not in the stabilizer group. Use binary vectors : and commute iff , and (mod phase) iff appending ‘s vector to the check matrix does not increase its rank over . Run it on the bit-flip, , , five-qubit, Steane and Shor codes.
Solution
A reference implementation (numpy only):
import itertoolsimport numpy as npdef to_sym(s): return np.array([c in "XY" for c in s] + [c in "ZY" for c in s], dtype=np.uint8)def rank2(M): M = M.copy() % 2 r = 0 for c in range(M.shape[1]): piv = next((i for i in range(r, M.shape[0]) if M[i, c]), None) if piv is None: continue M[[r, piv]] = M[[piv, r]] for i in range(M.shape[0]): if i != r and M[i, c]: M[i] ^= M[r] r += 1 return rdef code_params(checks): n = len(checks[0]) H = np.array([to_sym(g) for g in checks]) r = rank2(H) Lam = np.block([[np.zeros((n, n), int), np.eye(n, dtype=int)], [np.eye(n, dtype=int), np.zeros((n, n), int)]]) for w in range(1, n + 1): for supp in itertools.combinations(range(n), w): for ops in itertools.product("XYZ", repeat=w): s = ["I"] * n for q, o in zip(supp, ops): s[q] = o v = to_sym("".join(s)) if np.any(H @ Lam @ v % 2): # anticommutes with a check continue if rank2(np.vstack([H, v])) > r: # not a stabilizer return n, n - r, w, "".join(s)
Results (each also cross-checked with an independent string-based search):
code
first minimum-weight logical found
bit-flip
five-qubit
Steane
Shor
The search costs candidate strings, which explodes for large codes; computing the minimum distance is NP-hard already for classical linear codes (A. Vardy, 1997). Module 4 recasts this computation entirely in binary linear algebra, and for structured families like the surface code (Module 8) the distance follows from geometry instead.