## Composing correctable channels

We have already seen that we can compose quantum channels both in sequence and in parallel, using matrix multiplication or the tensor product (respectively).
When we compose two correctable channels, do we still get a correctable channel?
Well, if \{V_i\} and \{W_m\} are two sets of channels then
(V_j\otimes W_n)^\dagger(V_i\otimes W_m)
= (V_j^\dagger V_i)\otimes(W_n^\dagger W_m)
and so if the V_i and the W_m are all isometries, then so too is their parallel composition, since the above then equals \delta_{ij}\delta_{mn}\mathbf{1}\otimes\mathbf{1}.
Similarly, if V_i\colon\mathcal{B}(\mathcal{H})\to\mathcal{B}(\mathcal{H}') and W_m\colon\mathcal{B}(\mathcal{H}')\to\mathcal{B}(\mathcal{H}''), then the composition W_mV_i is meaningful, and
(W_nV_j)^\dagger(W_mV_i)
= V_j^\dagger W_n^\dagger W_m V_i
and so if the V_i and W_m are all isometries, then so too is their sequential composition, since the above then equals \delta_{ij}\delta_{mn}\mathbf{1}.

Let’s apply this to our continuing example of single-qubit error correction.
Recall the isometries
\begin{aligned}
V_{00} &= |000\rangle\langle 0| + |111\rangle\langle 1|
\\V_{01} &= |001\rangle\langle 0| + |110\rangle\langle 1|
\\V_{10} &= |010\rangle\langle 0| + |101\rangle\langle 1|
\\V_{11} &= |100\rangle\langle 0| + |011\rangle\langle 1|.
\end{aligned}
from Section 13.1.
If we write \overline{x} to mean the complement \texttt{NOT}(x) of a binary string x, then these can all be expressed as
V_x
= |0x\rangle\langle 0| + |1\overline{x}\rangle\langle 1|.
We can define a related set of isometries by
W_x
= (H\otimes H\otimes H)V_x
which correct for any single Z error, using the fact that HXH=Z.
Then the composites
(V_{y_1}\otimes V_{y_2}\otimes V_{y_3})W_x
= (V_{y_1}\otimes V_{y_2}\otimes V_{y_3})(H\otimes H\otimes H)V_x
define a set of isometries that map a single qubit to nine qubits as a correctable channel.

If we look at the y_1=y_2=y_3=x=00 case, then we can use this to define an encoding procedure, as in Figure 13.10.

What errors can this code cope with?
Trivially, an X on any of the nine qubits corresponds to a different isometry, by construction.
For example, applying an X at location 3 in Figure 13.10 is picked out by y_2=10.
In other words, each block of three qubits behaves just as it did before.

We also know that, by construction, the code would correct for a single X error at location 1 in the circuit.
If we propagate this error through the circuit, this is the same as a Z error in location 2, which corresponds to the isometry with x=10, and shows that Z errors on the first, fourth, and seventh (i.e. the first in each block of three) qubits can be corrected.
What about other Z errors?
Well, let’s go back to the subspace created by one of the V_x, say V_{00} which is spanned by |000\rangle and |111\rangle.
Then the effect of a single Z error on that space is the same no matter where the Z is applied: a Z error at location 3 has exactly the same effect as a Z error at location 2, since it corresponds to the same isometry, and so the error can still be detected and corrected *without ever needing to know whether the error was at location 2 or location 3*.
This lack of knowledge means that the code is said to be **degenerate**.

This circuit gives a nine-qubit encoding that can correct for *any* *single-qubit* error.
The resulting code is called the **Shor [[9,1,3]]-code**, where the 9 tells us the size of the encoding, the 1 tells us the input size, and the 3 tells us the distance (defined below).

We will describe how the Shor [[9,1,3]]-code provides single-qubit error correction in more detail in Section 13.10.

Note that, for the Shor [[9,1,3]]-code, operators such as Z_1Z_2\coloneqq Z\otimes Z\otimes\mathbf{1}^{\otimes7} are undetectable, but they do not change the logical state:
Z_1Z_2(V_{y_1}\otimes V_{y_2}\otimes V_{y_3})W_x
= (V_{y_1}\otimes V_{y_2}\otimes V_{y_3})W_x.
However, operators such as X_1X_2X_3 are undetectable *and do change* the logical state:
(X\otimes X\otimes X)V_{y_i}
= V_{y_i}X.
In fact, this is the smallest possible operator (said to be **of weight 3**, since it is built as a tensor product of three non-trivial gates) that can cause this problem of undetectable but fatal errors, and so we say that the Shor code has **distance d=3**.
In general, the number of errors that can be corrected by a distance d code is \lfloor d/2\rfloor.