$$ % Dirac notation \newcommand{\ket}[1]{\left|#1\right\rangle} \newcommand{\bra}[1]{\left\langle#1\right|} \newcommand{\braket}[2]{\left\langle#1\middle|#2\right\rangle} \newcommand{\expect}[1]{\left\langle#1\right\rangle} % Common operators \newcommand{\tr}{\operatorname{tr}} \newcommand{\Tr}{\operatorname{Tr}} \DeclareMathOperator*{\argmin}{arg\,min} \DeclareMathOperator*{\argmax}{arg\,max} % Complexity \newcommand{\bigO}[1]{\mathcal{O}\!\left(#1\right)} $$

The [[4,2,2]] Error Detection Code

1. The [[4,2,2]] Code Space

The [[4,2,2]] code encodes 2 logical qubits into 4 physical qubits. It is the smallest quantum error-detecting code and can detect any single-qubit error.

The code is defined by two stabilizer generators:

\[S_X = X^{\otimes 4} = X_1 X_2 X_3 X_4, \qquad S_Z = Z^{\otimes 4} = Z_1 Z_2 Z_3 Z_4\]

The code space consists of all 4-qubit states that are simultaneous \(+1\) eigenstates of both \(S_X\) and \(S_Z\). Because we have 2 stabilizers acting on 4 qubits, the code space is \(2^{4-2} = 4\)-dimensional, encoding exactly 2 logical qubits.


2. Error Detection Simulator

Apply a single-qubit error to the logical state \(|00\rangle_L\) and observe how the stabilizer measurements detect it.


3. Logical Bell State Fidelity

The power of error detection via post-selection: even a simple [[4,2,2]] code can produce logical Bell pairs with fidelity far exceeding the raw physical fidelity. Adjust the physical error rates below to see how post-selection boosts fidelity.


4. Flying Ancilla Protocol

In the velocity-enabled architecture, a flying ancilla atom physically moves past the data qubits to perform stabilizer measurements. This avoids the need for static long-range connectivity. Below is an animated visualization of the \(Z^{\otimes 4}\) stabilizer measurement protocol.