Exercises: Chapter 24 — Quantum Error Correcting Codes: The Shor Code, Steane Code, and Stabilizer Formalism
Exercise 24.1 — Shor Code Stabilizer Verification. Verify that all 8 stabilizer generators of the Shor code commute with each other. Show that the logical operators $X_L = X_1 X_2 X_3 X_4 X_5 X_6 X_7 X_8 X_9$ and $Z_L = Z_1 Z_2 Z_3 Z_4 Z_5 Z_6 Z_7 Z_8 Z_9$ commute with all stabilizers and anticommute with each other.
Exercise 24.2 — Steane Code Codewords. Write a Python function that generates all 16 codewords of the $[7,4,3]$ Hamming code. From these, construct the explicit expansions of $|0_L\rangle$ and $|1_L\rangle$ for the Steane code. Verify that $\langle 0_L|1_L\rangle = 0$ and that both states are normalized.
Exercise 24.3 — Knill-Laflamme Conditions. For the 3-qubit bit-flip code, verify the Knill-Laflamme conditions for the error set $\{I, X_1, X_2, X_3\}$. Show that $\langle i_L|E_a^\dagger E_b|j_L\rangle = C_{ab} \delta_{ij}$ holds, and compute the matrix $C_{ab}$.
Exercise 24.4 — CSS Code Construction. Let $C$ be the $[7,4,3]$ Hamming code. Verify that $C^\perp \subseteq C$ (the dual is contained in the code). Construct the CSS code $CSS(C, C)$ and show that it yields the Steane code. What are the parameters of $CSS(C, C^\perp)$?
Exercise 24.5 — Syndrome Decoding Table. For the Steane code, construct the complete syndrome lookup table mapping each of the $2^6 = 64$ possible syndromes to the corresponding error (or "no error" / "uncorrectable"). Implement a Python function steane_decode(syndrome) that returns the correction operation. Test it on all 21 possible single-qubit Pauli errors (7 qubits $\times$ 3 error types).
Exercise 24.6 — 5-Qubit Code. Look up the stabilizer generators of the $[[5,1,3]]$ perfect quantum code. Verify that they commute. Show that any single-qubit Pauli error gives a unique syndrome. How many syndrome outcomes are there, and how many single-qubit errors can be identified?
Exercise 24.7 — Degenerate Codes. A quantum code is degenerate if different errors can produce the same syndrome without affecting the code space. Show that the Shor code is degenerate: find two distinct single-qubit errors that produce the same syndrome. Explain why degeneracy is actually an advantage (it means some errors are "free" to correct).
Exercise 24.8 — Transversal Gates. Show that the logical CNOT gate for the Steane code can be implemented transversally as $\text{CNOT}^{\otimes 7}$. That is, prove that applying CNOT between corresponding qubits of two Steane code blocks implements the logical CNOT. Verify that this maps valid codewords to valid codewords.
Exercise 24.9 — Error Digitization Simulation. Write a Qiskit simulation that applies a continuous rotation $R_x(\theta)$ to one qubit of the 3-qubit bit-flip code, then measures the stabilizers. Show that the measurement outcome is either "no error" or "X error" with probabilities $\cos^2(\theta)$ and $\sin^2(\theta)$, and that in either case the correction is exact.
Exercise 24.10 — Quantum Singleton Bound. Prove the quantum Singleton bound: for an $[[n, k, d]]$ quantum code, $n - k \geq 2(d-1)$. (Hint: Use the fact that deleting the last $d-1$ qubits from a code with distance $d$ should still leave enough information to distinguish $2^k$ logical states.) Show that the 5-qubit code saturates this bound.