Lecture 17: General Quantum Errors CSS Codes: CPSC 519/619: Quantum Computation John Watrous, University of Calgary
Lecture 17: General Quantum Errors CSS Codes: CPSC 519/619: Quantum Computation John Watrous, University of Calgary
for some choice of a, b, c, d ∈ C. Forget about the fact that A may not be unitary for a moment,
and imagine that A is applied to the j-th qubit in some n qubit state |ψi, which we will view as
encoding one or more qubits in some quantum error correcting code. We obtain
where the superscript (j) indicates which qubit each mapping acts on.
Assuming that the code protects against any one of the four errors given by the Pauli matrices,
the first step of error correction would result in the state
a |ψi |I syndromei
+b σx(j) |ψi |σx(j) syndromei
+c σy(j) |ψi |σy(j) syndromei
+d σz(j) |ψi |σz(j) syndromei .
1
Correcting according to the syndrome then gives
Alternately, if the syndrome is measured and the error is corrected appropriately, the state |ψi is
recovered regardless of the measurement outcome.
Now, if an arbitrary one-qubit admissible operation occurs on qubit j, we obtain
N †
(j) (j)
X
(j)
Φ (|ψi hψ|) = Ak |ψi hψ| Ak
k=1
(j)
Ak = ak I + bk σx(j) + ck σy(j) + dk σz(j) .
A slightly messy (but conceptually simple) calculation shows that if the syndrome is computed and
measured, we obtain the mixed state
N
|ak |2 |ψi hψ| ⊗ |I syndromei hI syndrome|
X
k=1
|bk |2 σx(j) |ψi hψ| σx(j) ⊗ |σx(j) syndromei hσx(j) syndrome|
|ck |2 σy(j) |ψi hψ| σy(j) ⊗ |σy(j) syndromei hσy(j) syndrome|
|dk |2 σz(j) |ψi hψ| σz(j) ⊗ |σz(j) syndromei hσz(j) syndrome| .
The fact that there are no cross-terms in this expression is a consequence of measuring the syn-
drome (with respect to the standard basis).
Although the above expression might look unappealing to you, it is expressing something quite
remarkable. The act of computing the syndrome and measuring has effectively projected the ar-
bitrary error represented by Φ into one of the four discrete errors I, σ x , σy , or σz . Correcting
according to the syndrome then gives
N
|ak |2 |I syndromei hI syndrome|
X
|ψi hψ| ⊗
k=1
+ |bk |2 |σx(j) syndromei hσx(j) syndrome|
+ |ck |2 |σy(j) syndromei hσy(j) syndrome|
+ |dk |2 |σz(j) syndromei hσz(j) syndrome| .
Here we are of course relying on the fact that the code corrects the four Pauli operators correctly.
Throwing the syndrome in the trash gives |ψi hψ| as desired.
2
CSS codes
The last thing we will discuss on the topic of quantum error correction is CSS codes, named
after their co-discoverers Robert Calderbank, Peter Shor, and Andrew Steane. These codes are
interesting because they illustrate how classes of classical error correcting codes can sometimes be
turned into classes of quantum codes. They are also useful for one of the simpler proofs of security
of the BB84 quantum key-distribution protocol, which we will discuss next week.
Generator matrix. A generator matrix G for an [n, k] linear code C is an n × k matrix over Z n2
such that
def
C = range(G) = {Gx : x ∈ Zk2 }.
To encode a string x ∈ Zk2 , we simply multiply by G, i.e., x ∈ Zk2 is encoded as Gx ∈ Zn2 .
Parity check matrix. A parity check matrix K for an [n, k] linear code C is an (n − k) × n matrix
over Z2 such that
def
C = ker(K) = {y ∈ Zn2 : Ky = 0}.
The syndrome for a given string y 0 ∈ Zn2 is Ky 0 ∈ Z2n−k .
Once either of these two matrices is chosen, the code is determined. It is helpful, however, to have
both.
Let us briefly discuss why the syndrome given by the parity check matrix is helpful. Suppose
that we have a codeword y ∈ C and errors occur on one or more of the bits. We can write the
resulting string y 0 as y + e where e ∈ Zn2 indicates where the errors took place (a 1 in each position
where an error takes place, and 0 everywhere else). Then we see that Ky 0 = K(y + e) = Ke is
3
a function only of the errors and not the original codeword. If the Hamming weight of e is small
enough, the syndrome Ke will uniquely determine the error vector e. More specifically, there
cannot be two distinct strings e and e0 both of Hamming weight less than d/2 such that Ke0 = Ke.
Example 1. Let us define a [7, 4] linear code C as follows. The generator matrix is
1 0 0 0
0 1 0 0
0 0 1 0
G= 0 0 0 1
0 1 1 1
1 0 1 1
1 1 0 1
This particular code is called a [7, 4] Hamming code. (More generally, Hamming codes are
[2m − 1, 2m − m − 1] codes obtained by taking the parity check matrix to have as columns all
of the nonzero strings of length n − k.) All Hamming codes including the above one have dis-
tance 3. Because the distance is 3, the code can tolerate up to one bit-flip.
For example, the encoding of the string 1001 is 100100 and the encoding of 1111 is 1111111,
because
1 1
0 1
1
0 1
1 1
0
G0 = 1
and G1 = 1 .
1 1
1
0 1
1
0 1
Dual codes
Suppose that we have an [n, k] linear code C. The dual code to C is denoted C ⊥ , and contains all
strings that have modulo 2 inner product 0 with all codewords of C. In symbols:
Therefore, C ⊥ is an [n, n − k] linear code. If we have a generator matrix G and a parity check
matrix K for C, then the generator matrix for C ⊥ is K T and the parity check matrix is GT . A code
C is weakly self dual if C ⊆ C ⊥ and is strictly self dual (or just self dual) if C = C ⊥ .
4
Example 2. The code C = {00, 11} is a very simple self dual [2, 1] linear code. The [7, 4]
Hamming code above is not weakly self dual. In order for C to be weakly self dual, it is necessary
and sufficient that the generator matrix G for C satisfies GT G = 0. This is not the case for the
[7, 4] Hamming code. However, the dual code C ⊥ of that code is weakly self dual. This follows
from the fact that the generator matrix of C ⊥ is K T , which satisfies (K T )T K T = KK T = 0.
CSS codes
Now we are ready to define CSS codes. In order to define a CSS code, we must have two classical
linear codes C1 and C2 that satisfy certain properties:
1. C1 must be an [n, k1 ] linear code and C2 must be an [n, k2 ] linear code for k2 < k1 .
2. It must be that C2 ⊆ C1 .
3. If both C1 and C2⊥ can correct up to t errors, then the resulting CSS code will be an [n, k1 − k2 ]
code that corrects up to t quantum errors (meaning an arbitrary error confined to t qubits).
Example 3. Let C1 be the [7, 4] Hamming code discussed above and let C2 = C1⊥ . Then C2 is
a [7, 3] (weakly self dual) linear code. We have C2 ( C1 by virtue of the fact that C2 is weakly
self dual and is clearly not equal to C1 (because it has fewer vectors). Because C1 corrects up to
one error and C2⊥ = C1 , the CSS code constructed will be a [7, 1] quantum code that can correct 1
quantum error.
The encoding for the CSS code constructed from codes C1 and C2 as above is as follows.
1. Let N = 2k1 −k2 . The space spanned by all possible encodings will have dimension N . Choose
codewords x0 , . . . , x2N −1 ∈ C1 satisfying the condition
xi + xj 6∈ C2
for i 6= j. (This will always be possible because C1 /C2 is a space of dimension k1 − k2 over
Z2 , and each element of this space gives rise to at least one good choice of x j .)
2. Identify the classical states of the k1 − k2 qubits to be encoded with numbers 0, . . . , N − 1 in
binary. Then the encoding corresponds to the linear mapping defined by
1 X
|ji 7→ |xj + C2 i = p |xj + yi .
|C2 | y∈C2
The fact that hxi + C2 |xj + C2 i = 0 for i 6= j follows from the fact that xi + xj 6∈ C2 for i 6= j.
Example 4. Let C1 and C2 be as in the previous example. Then N = 2, so we need just two
codewords x0 and x1 in C1 so that x0 + x1 6∈ C2 . We may take x0 = 0000000 and x1 = 1111111.
Enumerating all elements of C2 = C1⊥ is not so hard in this case—we have
5
Thus, the encoding for the corresponding CSS code will be:
1
|0i 7→ √ (|0000000i + |0001111i + |0110011i + |1010101i
8
+ |0111100i + |1011010i + |1100110i + |1101001i)
1
|1i 7→ √ (|1111111i + |1110000i + |1001100i + |0101010i
8
+ |1000011i + |0100101i + |0011001i + |0010110i).
It remains to discuss error correction for CSS codes. Suppose we have an n qubit state con-
tained in a register R that we want to correct. The procedure for doing this is very simple:
1. First, reversibly compute the syndrome of R for code C1 , which corresponds to the reversible
transformation
|yi |00 · · · 0i 7→ |yi |s1 (y)i ,
where s1 (y) denotes the syndrome of y with respect to code C1 . Measure this syndrome, and
correct bit-flips by applying NOT gates to the appropriate qubits of R.
2. Apply a Hadamard transform to every qubit of R.
3. Repeat the same procedure as in step 1, except using the code C 2⊥ .
4. Again apply Hadamard transforms to all qubits of R.
Under the assumption that at most t bit-flips and t phase-flips occurred on X starting from some
valid encoding |ψi, the result will be that the encoding |ψi is recovered. Let us see why this is the
case.
First, some notation is needed. Suppose that bit-flips are represented by a vector e ∈ Z n2 and
phase-flips are represented by f ∈ Zn2 , with both vectors containing at most t ones. If, for a given
vector v ∈ Zn2 we denote X v = X v[1] ⊗ · · · ⊗ X v[n] and similarly Z v = Z v[1] ⊗ · · · ⊗ Z v[n] , this
means that the overall error is given by X e Z f . It will be helpful to note that for any choice of
u, v ∈ Zn2 the following simple formulas hold:
(a) X u Z v = (−1)u·v Z v X u ,
(b) H ⊗n X u = Z u H ⊗n , and
(c) H ⊗n Z u = X u H ⊗n .
Now, consider an arbitrary valid encoded state with respect to the CSS code:
N
X −1
αj |xj + C2 i .
j=0
6
If the errors represented by e and f occur, the state becomes
N
X −1 N
X −1
e f
αj X Z |xj + C2 i = αj (−1)e·f Z f |xj + e + C2 i .
j=0 j=0
Step (1) of the error correction procedure computes and measures the syndrome with respect to C 1 .
Error correction is performed by applying NOT gates to the qubits indicated by the syndrome.
Because e has at most t ones, the syndrome reveals the vector e, and after correction the state
becomes
N
X −1 N
X −1
e·f e f
αj (−1) X Z |xj + C2 + ei = αj Z f |xj + C2 i .
j=0 j=0
Notice that here is where we require that C2 ⊆ C1 —it must be that every string in xj + C2 is a
codeword with respect to C1 . It will be convenient for the next step to write the above state as
N
X −1
αj Z f X xj |C2 i .
j=0
Next, the Hadamard transforms are performed. It is a straightforward calculation to show that
H |C2 i = |C2⊥ i, and so the state becomes
⊗n
N
X −1 N
X −1 N
X −1
⊗n f xj f xj
αj H Z X |C2 i = αj X Z |C2⊥ i = αj (−1)f ·xj Z xj |f + C2⊥ i .
j=0 j=0 j=0
Step (3) of the error correction procedure detects the vector f in a similar way to e being detected
in step (1). The correction works by applying NOT gates in the positions indicated by f , which
results in the state
N
X −1 N
X −1
αj (−1)f ·xj X f Z xj |f + C2⊥ i = αj Z xj |C2⊥ i .
j=0 j=0