|q⟩ Bad Qubits

advanced · Physics · Stabilizer Formalism & CSS Codes

The Check Matrix

Stabilizer arithmetic is really linear algebra over the two-element field F2\mathbb{F}_2. The bridge between Pauli operators and binary vectors is the check matrix, and once we cross it, questions about commutation, independence, and code dimension become routine matrix operations.

From Pauli strings to binary vectors

A phase-free Pauli string P=P1PnP = P_1 \otimes \cdots \otimes P_n is encoded by two length-nn binary vectors x=(x1,,xn)x = (x_1,\dots,x_n) and z=(z1,,zn)z = (z_1,\dots,z_n) via the rule

I(0,0),X(1,0),Z(0,1),Y(1,1),I \mapsto (0,0), \quad X \mapsto (1,0), \quad Z \mapsto (0,1), \quad Y \mapsto (1,1),

read componentwise: xjx_j flags an XX or YY on qubit jj, and zjz_j flags a ZZ or YY. The single string PP becomes the row vector (xz)F22n(x \mid z) \in \mathbb{F}_2^{2n}. Multiplying two Paulis (ignoring phase) corresponds to adding their binary vectors mod 2 — exactly what you would expect, since XY=iZX\cdot Y = iZ has x,zx,z bits (1,0)+(1,1)=(0,1)Z(1,0)+(1,1) = (0,1) \mapsto Z.

The check matrix

Stack the binary rows of rr stabilizer generators g1,,grg_1,\dots,g_r into an r×2nr \times 2n matrix:

H=[HX    HZ],H = \big[\, H_X \;\big|\; H_Z \,\big],

where HXH_X holds the xx-parts and HZH_Z the zz-parts. This is the check matrix of the code. Each row is one generator; each of the 2n2n columns is one F2\mathbb{F}_2 coordinate.

For the three-qubit bit-flip code with g1=Z0Z1g_1 = Z_0 Z_1, g2=Z1Z2g_2 = Z_1 Z_2 the check matrix is

H=[000110000011].H = \left[\begin{array}{ccc|ccc} 0 & 0 & 0 & 1 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 & 1 \end{array}\right].

The empty left block (HX=0H_X = 0) tells you the code uses only ZZ-type stabilizers.

Commutation via the symplectic form

The symplectic inner product of two rows becomes a matrix statement. Define the 2n×2n2n \times 2n symplectic form

Λ=(0InIn0).\Lambda = \begin{pmatrix} 0 & I_n \\ I_n & 0 \end{pmatrix}.

Then two generators u=(xuzu)u = (x^u \mid z^u) and v=(xvzv)v = (x^v \mid z^v) commute iff

uΛvT=xu ⁣zv+zu ⁣xv0(mod2).u\,\Lambda\,v^{\mathsf T} = x^u\!\cdot z^v + z^u\!\cdot x^v \equiv 0 \pmod 2.

The whole stabilizer is abelian precisely when HΛHT=0H\,\Lambda\,H^{\mathsf T} = 0 over F2\mathbb{F}_2. This is a single matrix equation we can check mechanically.

Independence and code dimension

The generators are independent iff the rows of HH are linearly independent over F2\mathbb{F}_2, i.e. rankF2(H)=r\operatorname{rank}_{\mathbb{F}_2}(H) = r. Row reduction (Gaussian elimination with XOR as the "add" operation) computes this rank. For a stabilizer code on nn qubits, the number of encoded logical qubits is

k=nrankF2(H).k = n - \operatorname{rank}_{\mathbb{F}_2}(H).

Each independent generator removes one degree of freedom, halving the codespace; whatever survives encodes the logical information.

Try it

Build the 4×104 \times 10 check matrix of the famous five-qubit perfect code with cyclic generators XZZXI,IXZZX,XIXZZ,ZXIXZXZZXI,\, IXZZX,\, XIXZZ,\, ZXIXZ, compute its F2\mathbb{F}_2 rank, and report k=nrank(H)k = n - \operatorname{rank}(H). You should find k=1k = 1: the [[5,1,3]][[5,1,3]] code.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.