# Why do stabilizer codes in Nielsen and Chuang have Pauli X and Z matrices?

While reading about quantum stabilizer codes I have noticed that almost all codes I have seen have Pauli X and Z matrices. Is there any specific reason for this?

I have been teaching myself about Quantum stabilizer codes through the 10th chapter of Nielsen and Chuang. I should warn (and you should be able to guess from my question) beforehand that my knowledge is superficial at the best.

• If you literally mean that the generators themselves are tensor products of $Z$ and $X$ only, then this might be the case because you have been looking at CSS codes (10.4.2 in Nielsen & Chuang). Commented Oct 6, 2021 at 15:48
• I might suggest refraining from using "almost all" in the question title unless you mean it in the following sense en.wikipedia.org/wiki/Almost_all. Indeed, you haven't looked at almost all stabilizer codes, but more appropriately, just some examples in N&C. Commented Oct 6, 2021 at 16:05

Any matrix can be decomposed into a sum of tensor products where each term is of the form $$X^a Z^b$$ (where $$a$$ and $$b$$ are bits; they can be 0 or 1). For example, the 16 matrices of the form $$(X^{a_1} Z^{b_1}) \otimes (X^{a_2} Z^{b_2})$$ are a basis for the space of 4x4 matrices.
All errors can be thought of as an unwanted matrix applied to your system. And any unwanted matrix can be put into the XZ tensor product basis. So general errors decompose into linear combinations of $$X$$ and $$Z$$ errors.
What this means is that if you just focus on correcting combinations of $$X$$ and $$Z$$ errors, you end up correcting everything. And $$X$$ and $$Z$$ errors have all this structure that makes correcting them easy to think about. They're sparse, they only have real values, they're Hermitian, they're unitary, they're self-inverse, they're closed under Clifford operations; it's so convenient!
This is a special feature of CSS codes: the stabiliser subgroup, $$S$$ say, of a CSS code of length $$n$$ is generated by two commuting subgroups $$S \cong S_X \times S_Z$$. In turn $$S_X$$ has generators of the form $$J_1 \otimes J_2 \cdots \otimes J_n$$ where each $$J_i$$ is either $$X$$ or $$I$$; these generators are specified by the rows of the $$P$$ matrix. Similarly $$S_Z$$ has generators of the form $$K_1 \otimes K_2 \cdots \otimes K_n$$ where each $$K_i$$ is either $$Z$$ or $$I$$; these generators are specified by the rows of the $$Q$$ matrix. The condition $$PQ^t = 0$$ is equivalent to the commuting of the two subgroups.
In general stabiliser codes may have generators that are 'mixed' products of $$I$$, $$X$$ and $$Z$$. For instance, the shortest length of a $$1$$-error correcting quantum code is $$5$$. One such stabiliser code has generators $$X \otimes Z \otimes Z \otimes X \otimes I$$ and its cyclic shifts. (The Wikipedia page specifies the first four shifts: this is equivalent because the final shift is the product of the first four, so in the subgroup they generate.) This code is not a CSS code, for instance because it has odd length.