Category: error-correction | Difficulty: intermediate | Qubits: 4 | Gates: 4 | Depth: 4
The [[4,2,2]] code is the smallest quantum error detecting code. It encodes 2 logical qubits into 4 physical qubits and detects (but cannot correct) any single-qubit error. The logical |00_L⟩ = (|0000⟩+|1111⟩)/√2, equivalent to a 4-qubit GHZ state. Two stabilizer generators ⟨XXXX, ZZZZ⟩ define the code space. A single-qubit error maps the state out of the code space, detectable by measuring stabilizers.
50% |0000⟩, 50% |1111⟩ (logical |00_L⟩)
The OpenQASM 2.0 circuit is in circuit.qasm.
OPENQASM 2.0;
include "qelib1.inc";
// [[4,2,2]] code: prepare logical |00_L> = (|0000> + |1111>) / sqrt(2)
qreg q[4];
creg c[4];
h q[0];
cx q[0],q[1];
cx q[0],q[2];
cx q[0],q[3];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
error-detection css-code stabilizer fault-tolerant
MIT — part of the OpenQC Algorithm Catalog.