## Monday, 23 December 2013

### The Toric Code

Abstract

The toric code is one of the first examples of a surface code \cite{Kitaev}, where a lattice consisting of qubits is deployed for the purposes of error correction. The toric code can be seen as a tool for realizing a quantum memory by exploiting certain topological properties that result from embedding the lattice on the surface of a torus. The model is best understood through the stabilizer formalism for quantum error correction. This post discusses the general properties of the toric code in this regard, and explains how Pauli errors on the encoded state can be corrected. Errors manifest themselves in the toric code as anyonic excitations. Although the theory of anyons provides an insightful interpretation to the dynamics of the toric code, the model will be presented here with minimal emphasis on the anyonic properties at play without sacrificing the essence of the toric code.

Preliminary remarks

Consider  a $k \times k$ square consisting of $k^2$ square faces, $k^2$ vertices, and $2k^2$ edges. By identifying the top of the lattice with the bottom, and the left side with the right side, the lattice can be thought of as being embedded on the surface of a genus-$1$ torus (hence the name 'toric' code). Alternatively, the $k \times k$ lattice can be though of as having periodic boundary conditions, where a path leaving the lattice from the top side returns to the lattice from the corresponding point on the bottom side of the lattice. Likewise, a path leaving the torus from either the left or right sides would return from the opposite side. Instead of visualizing the lattice on the surface of the torus, this latter picture will be used throughout for convenience.

It is worth mentioning that the choice of a $k\times k$ square lattice is somewhat arbitrary in the sense that most of the essential features exhibited by the toric code also hold for $k\times k'$ square lattices with $k\neq k'$. It will be justified later what consequences this has for the code in regards to error correction. Moreover, the choice of using a square lattice can also be modified to include lattice configurations of arbitrary shape. In such cases however, the operators that act on the lattice may also need modification. For the purposes of simplicity, this paper will work with a $k\times k$ square lattice in order to exemplify the properties of the toric code in a more accessible manner.

In the toric code, a qubit is placed on each edge of the lattice so that there are $N:=2k^2$ qubits for a $k \times k$ lattice. Thus, the Hilbert space of the system under consideration is of the form
$\Hil^N=\TENSOR{j=1}{N}\Hil^2_j,$
where $\Hil^2_j$ is the two-dimensional Hilbert space of quibit $j$. For notational purposes, when some single qubit unitary operator $U$ is applied to only qubit $j$, write $U_j$ in order to specify the appropriate Hilbert space $\Hil^2_j$  that  $U$ is meant to act on. That is,
$U_j=I\otimes\dots\otimes I\otimes U\otimes I\otimes\dots\otimes I$
will denote the unitary operator of the whole system $\Hil^N$ that only applies the single qubit unitary $U$ to the qubit of $\Hil^2_j$ and acts trivially on all other qubits (here, $I$ denotes the single qubit identity operator on $\Hil^2$). In this way, the action of the unitary $U$ on the space $\Hil^2_j\subset\Hil^N$ of a single qubit is extended to an operation that acts on the whole space $\Hil^N$. Therefore, if two single qubit unitaries $U$ and $V$ are to be applied to qubits $j_1$ and $j_2$, respectively, it is well defined to simply write this operation as the product $U_{j_1}V_{j_2}$.

The Stabilizer Group

For the toric code, there are two basic type of operators that act on the qubits of the lattice. These operators will be used to construct an algebraic set of operators important for the purposes of error correction.  Define the following two operators on $\Hil^N$ for each vertex $v$ and face $f$ of the lattice, where $\sigma^x$ and $\sigma^z$ are the standard single qubit Pauli operators,
$A_v=\PROD{j\in star(v)}{}\sigma^x_j \ \ \ \text{and} \ \ \ B_f=\PROD{j\in boundary(f)}{}\sigma^z_j .$
Here, $star(v)$ represents the set of $4$ edges that meet at vertex $v$ so that $A_v$ is the operator that applies $\sigma^x$ to each of the $4$ qubits adjacent to vertex $v$, and $boundary(f)$ represents the set of $4$ edges that border the face $f$ so that $B_f$ is the operator that applies $\sigma^z$ to each of the $4$ qubits that border the particular face $f$. These operators are illustrated in the figure below. Note that, since both $\sigma^x$ and $\sigma^z$ are Hermitian operators, so are the $A_v$ and $B_f$. Moreover, both $A_v$ and $B_f$ have eigenvalues $+1$ and $-1$.

The lattice in the toric code has qubits placed on its edges depicted as black dots. The vertex operators $A_v$ applies $\px$ operators to the four edges around vertex $v$, and the face operators $B_f$ apply $\pz$ operators to the four edges bordering a face $f$.

The set $S$ consisting of all possible products of the operators $A_v$ and $B_f$ forms an abelian subgroup of the Pauli group $P_N$, which makes $S$ a stabilizer group (see Appendix). For this to be the case each of the $A_v$ and $B_f$  must commute with one another. Since $A_v$ and $B_p$ are either products of only $\sigma^x$s or only $\sigma^z$s it follows that $A_v$ and $A_{v'}$ commute for any vertices $v$ and $v'$, and that $B_f$ and $B_{f'}$ commute for any faces $f$ and $f'$, because $\sigma^x$ and $\sigma^z$ each commute with themselves. However, even though $\sigma^x$ and $\sigma^z$ anti-commute with one another $A_v$ and $B_f$ do indeed commute for any vertex $v$ and face $f$. To see this, there are two cases to consider. First, suppose $v$ and $f$ are sufficiently far apart so that there are no qubits in common that are acted on by the operators $A_v$ and $B_f$. In this case, $A_v$ and $B_f$ trivially commute since the operators $\sigma^x_j$ and $\sigma^z_{j'}$, with $j\in star(v)$ and $j'\in boundary(f)$, act on different subspaces. The only other possibility  to consider is when the vertex $v$ happens to be one of the corners of the face $f$. In this case, there are two distinct qubits in the intersection of $star(v)$ and $boundary(f)$ as shown in Figure:

Adjacent vertex and face operators commute because they have two edges in common.

Each of these two qubits is acted on by $\sigma^x$ and $\sigma^z$, but since $\sigma^x\sigma^z=-\sigma^z\sigma^x$ there are two minus signs that result from the action of $A_v$ and $B_f$ on each of the two qubits which then cancel implying that $A_vB_f=B_fA_v$. Thus, it has been shown that each of the $A_v$ and $B_f$ commute with one another so that the set $S$ generated by their products is indeed a stabilizer group by definition.

It is worthwhile to calculate the number of independent generators of $S$. A generating set of $S$ is a collection of elements of $S$ such that each element of $S$ can be expressed as some product of elements from the generating set. In addition, it is required that the elements of the generating set be independent, meaning that no element of the generating set can be expressed as a product of the other elements of the generating set. Since the elements of $S$ are all expressible by products of the operators $A_v$ and $B_f$, finding a minimal generating set of $S$ comes down to determining if any of the $A_v$s or $B_f$s can be expressed in terms of others.

In fact, it will now be shown that the following two relationships hold:
$\PROD{v}{}A_v=I \ \ \text{and} \ \ \PROD{f}{}B_f=I,$
where the products range over all vertices $v$ and faces $f$ of the lattice and $I$ is the identity operator on the whole space $\Hil^N$. This is easily seen by noting that for any operator $A_v$ (or $B_f$) acting on a particular vertex $v$ (or face $f$) of the lattice, there are four adjacent operators $A_{v_i}$ (or $B_{f_i}$) where each of the adjacent operators have one edge in common with $A_v$ (or $B_f$). Therefore, the action of two $\sigma^x$ (or $\sigma^z$) operations on the common edges cancel since $\sigma^x\sigma^x=I=\sigma^z\sigma^z$, which cancels the action of the original $A_v$ (or $B_f$).  Similarly, each of these four vertices $v_i$ (or faces $f_i$) have three other vertices (or faces) adjacent to them not including the original vertex $v$ (or face $f$). Then the action of the corresponding $A$ (or $B$) will cancel the $\sigma^x$ (or $\sigma^z$) operations that act on the shared edges. Continuing in this way, the simultaneous action of every $A_v$ (or $B_f$) on the lattice will cancel each other resulting in the trivial action $I$. This pattern is illustrated in the following two figures:

The product of all face operators gives the identity $I$ since each edge of the lattice is acted on by to $\pz$ operators and ${\pz}^2=I$.

The product of all vertex operators gives the identity $I$ since each edge of the lattice is acted on by to $\px$ operators and ${\px}^2=I$.

The relationship derived above implies that any single $A_{v'}$ (or $B_{f'}$) can be expressed as the product of all other $A_{v}$ (or $B_{f}$) with $v\neq v'$ (and $f\neq f'$). That is, since $A_v^2=I$ and $B_f^2=I$, each $A_v$  and $B_f$ is its own inverse. It then follows that
$\PROD{v\neq v'}{}A_v=A_{v'} \ \ \text{and} \ \ \PROD{f\neq f'}{}B_f=B_{f'}.$
Hence, since there are $k^2$ many $A_v$ operators and also $k^2$ many $B_f$ operators defined on the $k\times k$ lattice, there are only $k^2-1$ independent operators of each variety. This shows that a minimal generating set for the stabilizer group $S$ consists of $G:=2(k^2-1)$ independent elements.

This size of the generating set of $S$ will be relevant when analyzing the code space of the toric code to be presented in the next section. The elements of $S$, and in particular the operators forming the generating set of $S$, will play a crucial role in the correction of errors by serving as check operators. Measuring the generators on the qubits of the lattice will (in the ideal case) yield information on whether or not errors have been inflicted on the system, and also serve as means to correct possible the possible errors.

The Code Space

The stabilizer group $S$ generated by the operators $A_v$ and $B_f$ consists of operators that all commute with each other. It is a general result in the theory of linear algebra that such a collection of operators can all be simultaneously diagonalized. This means that there exists a simultaneous eigenspace which is a subspace of $\Hil^N$ consisting of eigenvectors of every element of $S$. Thus, consider the space
$\Hil_S:=\{\ket{\psi}\in\Hil^N : A_v\ket{\psi}=\ket{\psi}, B_f\ket{\psi}=\ket{\psi} \ \text{for all} \ v \ \text{and} \ f\},$
that is the simultaneous eigenspace of eigenvectors of each $A_v$ and $B_f$ having eigenvalue $+1$. Recall that such considerations are possible since the $A_v$ and $B_f$ have eigenvalues $+1$ and $-1$. The subspace $\Hil_S\subset\Hil^N$ is called the code space of the stabilizer group $S$. This space is to be thought of as encoding information that is to remain protected from errors. Each of the states $\ket{\psi}\in\Hil_S$ are states of all $N$  physical qubits of the system, but they only effectively encode some number $N_{c}<N$ of logical qubits, where $N_c=log_2(dim(\Hil_S))$ is the dimension of $\Hil_S$. That is, the states $\ket{\psi}$ in $\Hil_S$ are $N$ qubit states constructed to protect the information contained in the state of only $N_c$ effective qubits through the means of redundancy. In the conventional error correcting nomenclature, the states $\ket{\psi}\in\Hil_S$ are often called code words.

Of course, now the natural question to ask is how many qubits $N_c$ are encoded by $\Hil_S$, or equivalently what is the dimension $N_c:=dim(\Hil_S)$ of the space. As consequence of the stabilizer formalism, the number of logical qubits $N_c$ encoded by the space $\Hil_S$ in general is given by $2^{N-G}$, where $N$ is the total number of qubits under consideration and $G$ is the number of independent stabilizer operators that generate $S$. In the toric code defined on a $k \times k$ lattice, $N=2k^2$ and $G=2(k^2-1)$ as calculated in the previous section. Then the dimension of the code pace $\Hil_S$ is given by $N_c=2^{N-2(k^2-1)}=2^2$. Hence $dim(\Hil_S)=4$ so that the code space $\Hil_S$ only encodes $2$ logical qubits. Intuitively, this result holds because each independent generator of $S$ can be thought of as halving the dimension of the global space $\Hil^N$.  Note that this number $N_c$ does not depend on the characteristic length scale $k$ of the lattice. This implies that no matter how large the lattice is made in the toric code, the number of encoded qubits always remains the same. This will have interesting consequences when considering the error correcting abilities of the toric code for different lattice sizes $k$.

After describing the properties of errors in the toric code and how the errors are to be corrected in the proceeding sections, it will be interesting to revisit and analyze the codespace $\Hil_S$ in order to more explicitly understand the structure of the space in a more topological context. This will be done in a later section.

Errors and Anyons

Assume now that the state of the qubits of the system $\Hil^N$ are prepared in an encoded state of $\Hil_S$ and no errors are present in the system. Then by construction, measuring the $A_v$ and $B_p$ operators will all yield eigenvalue $+1$ since $A_v\ket{\psi}=\ket{\psi}$ and $B_f\ket{\psi}=\ket{\psi}$ for $\ket{\psi}\in\Hil_S$. The violation of any of these conditions signals a possible error having occurred on the encoded state $\cw$. Thus, errors will be detected by performing syndrome measurements using the stabilizer generators $A_v$ and $B_f$.

In what follows, the schemes for detecting possible errors occurring on the encoded state $\ket{\psi}\in\Hil_S$ will initially be described in a case-by-case basis until enough intuition is gathered to describe a more general error correcting scheme. In particular, first we will only analyze $\pz$ errors, and then use this understanding to analogously reason about $\px$ errors. Further, some additional terminology will be introduced to ease the analysis and motivate further topological implications of the toric code. The new entities here will be quasiparticles that are commonly referred to in the literature as anyons. In essence, errors in the toric code manifest themselves as pairs of anyon excitations. Despite having a rich theory in themselves, the relevant details regarding anyon theory will not be presented here.The interested reader is invited to consult the following sources: \cite{Kitaev}, \cite{Rao}. Fortunately, because of the way the toric code model will be presented here, the unacquainted reader need not suffer from their ignorance.

The case of a single $\pz$ error

Suppose now that some $\sigma^z_j$ error occurs on qubit $j$ of the lattice (but the location is not known) so that the encoded state $\cw$ is transformed into the erred state $\ket{\xi}=\pz_j\cw$. In this case, any $B_v$ commutes with $\pz_j$ as $B_v$ is also in terms of $\pz$ operators. Therefore, measuring any of the $B_v$ operators will also return a $+1$ eigenvalue since
$B_f\ket{\xi}=B_f\pz_j\cw=\pz B_f\cw=\pz\cw=\ket{\xi}.$

Any $A_v$ such that $v$ is not one of the two vertices at the end of edge $j$, will trivially commute with $\pz_j$ by the mere fact that these operators act on different qubits of the lattice. However, there exists precisely two $A_v$ operators that will anti-commute with $\pz_j$. Namely, the two $A_v$ that correspond to the two vertices at the ends of edge $j$. These anti-commute because the $A_v$ operators are in terms of $\px$ operators and $\px$ and $\pz$ anti-commute. Hence, when the two $A_v$ operators that act on the qubit on edge $j$ are measured they will give an eigenvalue $-1$:
$A_v\ket{\xi}=A_v\pz_j\cw=-\pz A_v\cw=-\pz\cw=-\ket{\xi}.$
The result of measuring these two $A_v$ operators gives information on exactly which qubit $j$ was inflicted with the $\pz$ error. Moreover, the error can be corrected by applying $\pz_j$ to the erred state which returns it back to the original state $\cw\in\Hil_S$.

The pair of vertices at the ends of the edge $j$ corresponding to the locations of the $\pz_j$ error can be thought of as the locations of a pair of anyon excitations. We will now introduce the notation $z$ to represent a $z$-type anyon, and place two $z$ anyons at these two vertex locations as shown in the figure below. In this way, the syndrome measurements given by the $A_v$ operators can be thought of as detecting the presence of a $z$ anyon at a particular vertex as shown in the figure:

A pair of $z$-anyons are present on the two vertices that uniquely determine the location of the $\pz$ error.

The case of a single $\px$ error

Instead, suppose know that single $\px_j$ error is inflicted on the qubit located on edge $j$, but the precise location of $j$ is not known. The detection and correction of such an error proceeds in an analogous manner to the $\pz_j$ error described in the previous section. This time, the encoded state is transformed into the erred state of the form $\ket{\xi}=\px_j\cw$. Since all the $A_v$ operators are in terms of $\px$ as well, they all commute with $\px_j$. Thus measuring each $A_v$ on the lattice gives an eigenvalue $+1$ yielding no information pertaining to the location of the error since
$A_v\ket{\xi}=A_v\px_j\cw=\px A_v\cw=\px\cw=\ket{\xi}.$
On the contrary, every $B_f$ operator will commute with the $\px_j$ error with the exception of two $B_f$ operators. In this case, the two anti-commuting operators will correspond two the adjacent faces of the lattice that share the common edge $j$. Measuring these these two operators leads to the detection of the $\px_j$ error due to a $-1$ eigenvalue:
$B_f\ket{\xi}=B_f\px_j\cw=-\px B_f\cw=-\px\cw=-\ket{\xi}.$
Since these two $B_f$ operators correspond to the only adjacent faces next to the error, they uniquely determine the error's location and the error can be corrected by simply applying another $\px_j$ operator to  bring the erred state $\ket{\xi}$ back to an encoded state $\cw\in\Hil_S$. To signify the presence of this error, a $x$-type anyon denoted by $x$ will be introduced. This time, however, two $x$ anyons will be placed on the two faces adjacent to the location of the $\px_j$ error as shown in the figure below. Similar to how the $A_v$ operators are able to detect the presence of a $z$}  anyons representing $\pz$ errors, the presence of the two $x$ anyons representing $\px$ errors are detected instead by the $B_f$ operators.

A pair of $x$-anyons are present on the two faces that uniquely determine the location of the $\px$ error.

Strings of multiple $\pz$ errors

In the previous section, it was shown how a single $\pz$ and a single $\px$ error can be detected and corrected. This strategy will also work for correcting multiple $\pz$ and $\px$ errors provided that the  errors act on qubits (edges) that are not adjacent. If there happens to be, say, multiple $\pz$ errors such that the location of the errors forms a chain as depicted in the figure shown below, then the error syndrome will be inherently ambiguous and more care must be taken in attempting to correct the errors.

In order to better reason about a chain of adjacent errors given by the path $\overline{p}$ on the lattice, introduce the following string operator
$S^z(\overline{p})=\PROD{j\in\overline{p}}{}\pz_j,$
which applies a $\pz_j$ along each edge $j$ that is a part of the path $\overline{p}$. The string $\St{z}{p}$ then represents the case where a sequence of adjacent $\pz$ errors have inflicted the qubits along the path $\overline{p}$ on the lattice as shown in the figure below. The case of a $\pz$ error occurring on a single qubit, as discussed in the previous section, is a special case of a string operator $\St{z}{p}$ where the path $\overline{p}$ simply consists of a single edge.

An error $\St{z}{p}$ represents $\pz$ errors applied to all edges along the path $\overline{p}$.

When the string $\St{z}{p}$ effects an encoded state $\cw\in\Hil_S$ the erred state is of the form $\ket{\xi}=\St{z}{p}\cw$. It will now be shown that detecting the exact locations of all the errors induced by the string $\St{z}{p}$ using the stabilizer operators $A_v$ and $B_f$ is inherently ambiguous. Naturally, all $B_f$ commute with $\St{z}{p}$ since $B_f$ consists of $\px$ operators, and so will not yield any useful syndrome information. One may be tempted to think that any $A_v$ operator whose vertex $v$ lies on any part of the path $\overline{p}$ will anti-commute with $\St{z}{p}$ thereby detecting the presence of all the $\pz$ errors, but this is not the case. Actually, any $A_v$ whose vertex $v$ lies on the path $\overline{p}$ with the exception of the two vertices at the endpoints of the path $\overline{p}$ will also commute with the string $\St{z}{p}$, because the path $p$ will always pass through two edges in $star(v)$. For each of these two edges the $\px$ from $A_v$ anti-commutes with the error $\pz$ on that edge producing a $-1$, but since the other $\px$ and $\pz$ acting on the other common edge also produces a $-1$ the effect of the two will cancel yielding a trivial syndrome measurement. The only two $A_v$ that manage to detect an error produced by $\St{z}{p}$ via a $-1$ syndrome are the two $A_v$ corresponding to the endpoints of the path $\overline{p}$. These two $A_v$ anti-commute with $\St{z}{p}$ because $A_v$ and $\St{z}{p}$ only act on a single common edge in this case. Hence, there are two $z$ anyons that reside at the endpoints of $\overline{p}$ as shown in the figure below. This exemplifies the important property of the $z$ anyons that they will always appear as pairs whenever $\pz$ errors are present.

Two $z$-anyons are placed at the endpoints of the error string $\St{z}{p}$ to signify the vertex locations with nontrivial syndrome measurements.

Since the syndrome measurements in the case of a string $\St{z}{p}$ of $\pz$ errors only gives information specifying the endpoints of the error string $\St{z}{p}$, how then are all the errors to be corrected? It would be ideal if the exact path defining the string $\St{z}{p}$ was known, because then the errors can be corrected by simply applying all the $\pz$ operators comprising the string. To understand how to overcome this obstacle consider the following.

Since the exact form of the error string $\St{z}{p}$ is unknown, and only the endpoints of the string can be detected, the best one could do is to guess a path $\overline{p_g}$ that has the common endpoints with the actually error path $\overline{p}$. Thus, consider some string operator $\St{z}{p_g}$, where the path $\overline{p_g}$ has the same endpoints as the actual error path $\overline{p}$. Recall, that these endpoints are just the locations at which the pair of \cir{$z$} anyons reside. The union of these two paths $\overline{p}$ and $\overline{p_g}$ (denoted by the concatenation $\overline{pp_g}$) forms a closed loop $\overline{L}=\overline{pp_g}$ on the lattice. The union of the two strings can then be written as $\St{z}{L}=\St{z}{p_g}\St{z}{p}\cw$. If the string $\St{z}{p_g}$ is applied to the erred state $\ket{\xi}=\St{z}{p}\cw$, it is transformed to the state
$\ket{\xi'}=\St{z}{p_g}\ket{\xi}=\St{z}{p_g}\St{z}{p}\cw=\St{z}{L}\cw.$

Depending on the structure of the loop $\overline{L}$ it may be the case that $\ket{\xi'}=\cw$ implying that the state is returned to its original encoded state. However, it can also be the case that $\ket{\xi'}=\ket{\psi'}\in\Hil_s$ where $\ket{\psi'}\neq\cw$. In this latter case, the erred state $\ket{\xi}$ is not returned to the original state $\cw\in\Hil_S$. Instead, it is transformed to some other different encoded state $\ket{\psi}\in\Hil_S$ and error recovery fails. When this occurs a logical operation has been performed on the encoded state---an undesired effect when the objective is to merely preserve the state $\cw$.

A loop detour on the torus
This approach of guessing a string $\St{z}{p_g}$ in hopes of correcting some error string $\St{z}{p}$ by forming a loop $\overline{L}=\overline{pp_g}$ succeeds depending on the nature of the loop $\overline{L}$. Keeping in mind that the lattice under considerations is embedded on the surface of a torus, any loop on the lattice come in two varieties. Wether or not the error is corrected depends on which type of loop is formed in $\St{z}{L}$.

In general, a loop in a plane always partitions the planar region into two disjoint parts: an inside and an outside. Such loops can always be contracted to a point on the surface. A loop of this variety will be referred to as a trivial loop. On the surface of a torus, this property of a loop being able to contract to a point does not always hold. For instance, consider a closed loop that wraps around the hole of the torus. It is impossible to contract such a loop to a point on the surface of the torus. A non contractible loop on the torus does not partition the surface of the torus into two disjoint regions, and thus does not have a well defined 'inside' or 'outside'. A loop that cannot be contracted to a single point will be called a nontrivial loop. For a torus, there are three such classes of nontrivial loops: ones that loop around the hole, ones that loop around the equator' of the torus, and ones that loop around both the hole and the equator. Of course, nontrivial loops may loop multiple times around the torus in these various ways.

In the lattice picture with periodic boundary conditions representing the surface of a torus, the nontrivial loops are ones that pass through the periodic boundary on any of the sides. A path on this lattice will form a trivial loop if it never passes through a boundary. If a path does pass through a boundary, it can still form a trivial loop provided that it passes back through that same boundary before joining itself.

Recovering from $\pz$ errors
In regards to error recovery, consider some string loop $\St{z}{L}$ that has been constructed such that $\overline{L}$ is a trivial loop on the torus. In this case, the loop $\overline{L}$ forms the boundary of an inner region as shown in the figure below. In fact, this loop string $\St{z}{L}$ can be expressed completely in terms of certain $B_f$ operators as
$\St{z}{L}=\PROD{f\in inside(\overline{L})}{}B_f,$
where the set $inside(\overline{L})$ consists of all the faces inside of the loop $\overline{L}$. This is true because in such a product of $B_f$ operators, any edge inside of the loop is acted on by two adjacent $B_f$ operators so that the action of both of the two $\pz$ operators on that edge is the identity map. The only participating edges in this product of $B_f$ operators that are acted on nontrivially are precisely those that comprise the loop $\overline{L}$. Now, since every $B_f$ is an element of the stabilizer $S$, the action of $\St{z}{L}$ on any state $\cw\in\Hil_S$  is trivial. Then if some erred state is of the form $\ket{\xi}=\St{z}{p}\cw$ after the encoded state $\cw$ is inflicted with a the string $\St{z}{p}$, and another guessed string $\St{z}{p_g}$ is applied so that $\St{z}{L}$ (where $\overline{L}=\overline{pp_g}$) forms a trivial loop, the erred state $\ket{\xi}$ is transformed as
$\St{z}{p_g}\ket{\xi}=\St{z}{p_g}\St{z}{p}\cw=\St{z}{L}\cw=\PROD{f\in inside(\overline{L})}{}B_f\cw=\cw.$
This shows that error recovery is successful if the error string  is made into a trivial loop.

A trivial loop can be expressed as the product of all face operators $B_f$ corresponding to the faces contained in the loop $\overline{L}$.

On the other hand, in the presence of a $\St{z}{p}$ error string, suppose a string $\St{z}{p_g}$ was guessed so that the union of the two form a loop string $\St{z}{L}$, such that $\overline{L}$  is a nontrivial loop. The loop $\overline{L}$ no longer partitions the surface into two disjoint regions. In this scenario, it is impossible to express $\St{z}{L}$ exclusively in terms of $B_f$ operators as done in the case of a trivial loop. This means that $\St{z}{L}\notin S$, since it cannot be generated by elements of $S$. Yet, $\St{z}{L}$ still commutes with every element of $S$, because the loop $\overline{L}$ has no endpoints by definition. More explicitly, for any vertex $v$ on the loop, the loop will always pass through exactly two edges in $star(v)$ making $A_v$ commute with $\St{z}{L}$. Hence, no element of $S$ is able to detect any of the errors inflicted by $\St{z}{L}$. Therefore, despite attempting to correct the error on the state $\cw\in\Hil_S$, a logical operation is inadvertently applied to the state transforming it to some other $\ket{\psi'}\in\Hil_S$ and error recovery fails.

An elegant interpretation of the error recovery procedure is provided in terms of anyons. When the qubits of the lattice encode some state $\cw\in\Hil_S$ which is error free, no anyons are present. As mentioned previously, the existence of an open error string $\St{z}{p}$ results in a pair of $z$ anyons at the strings endpoints. In creating a loop $\overline{L}=\overline{pp_g}$ by applying another string $\St{z}{p_g}$ that starts at one of the end points (where one of the $z$ anyons is located) and then joining the path to the other endpoint (where the other $z$ anyon is located), the anyon pair can be thought of as fusing or annihilating one another. In a sense, $\sigma^z$ errors manifest themselves as pairs of $z$ anyons that reside on the lattice's vertices, and can be made to move around the lattice by applying strings of $\pz$ operators. The objective of successful error recovery is not only just to bring these pairs of $z$ anyons together so they annihilate and disappear, but to do so in such a way that when they fuse no anyon would have made a non-trivial loop around the torus in order to prevent some logical operation from occurring to the encoded state.

The Dual Lattice

Up until now, the discussion has been mostly focused on $\pz$ errors and how to correct them. The focus will now shift to correcting $\px$ errors. Fortunately, the understanding and intuition developed in the previous sections naturally extend over to this case. This transition will be assisted by considering the dual lattice as an abstract aid to reason about $\px$ errors.

Relative to the actual square lattice under consideration, the dual lattice is the lattice that has vertices at the center of the faces of the main lattice, and has the center of its faces at the locations of the vertices of the main lattice. In the dual lattice, the qubits still reside on the edges and remain in the same location as the main lattice. Naturally, the dual of the dual lattice is just the main lattice again. The main lattice (in solid lines) and the dual lattice (in dashed lines) are depicted together in the  figures shown below.

The utility in considering the dual lattice comes from being able to reason about $\px$ errors analogously to the way $\pz$ errors were analyzed. Just as paths were considered on the main lattice, paths $\overline{p'}$ will be considered on the dual lattice and will be referred to as co-paths. When displaying figures in the rest of this paper the dual lattice will not be depicted, and co-paths will be drawn as dashed lines as shown in the figure above. One useful consequence of considering the dual lattice is that the vertex operators $A_v$ represented in terms of $star(v)$ on the main lattice can now be perceived as face operators on the dual lattice as shown in the figure:

The main lattice and the dual lattice are depicted with the dual lattice as dashed lines. A co-path $\overline{p'}$ of the dual lattice as shown. The vertex operators $A_v$ can be thought of as a face operator on the dual lattice.

A somewhat pointless, yet kind of neat, interpretation of how the lattice relates to its dual is the following. By rotating each edge about its center by an angle of $\pi/2$, the lattice can be transformed into is dual. With this in mind it becomes more clear how a vertex operator on the main lattice becomes a face operator on the dual lattice as animating in the figure below:

The square lattice can be transformed into its dual by rotating each edge about its center by an angle of $\pi/2$. This turns vertex operators on the main lattice into face operators on the dual lattice.

Correcting $\px$ Errors
To represent multiple $\px$ errors that are adjacent to each other, define the string operator
$\St{x}{p'}=\PROD{v\in \overline{p'}}{}A_v,$
where the product ranges over vertices $v$ on the co-path $\overline{p'}$ of the dual lattice. For an open co-path $\overline{p'}$, a string $\St{x}{p'}$ manifests two $x$ anyons at its endpoints which lie on the faces of the main lattice. Similar to the correction of $\pz$ errors via the fusion of $z$ anyons, the objective of error recovery for $\px$ errors will be to fuse pairs of $x$ together so that they only form trivial co-loops on the dual lattice. If two $x$ are fused after a nontrivial co-loop has been travelled, a logical operation will be performed on the encoded state instead.

Any trivial co-loop $\overline{L'}$ can be expressed in terms of $A_v$ operators as
$\St{x}{L'}=\PROD{v\in inside(L')}{}A_v,$
where now the product ranges over all vertices of the main lattice contained inside of the co-loop $\overline{L'}$. Thus, $\St{x}{L'}\in S$ and so acts trivially on any encoded state in $\Hil_S$. Moreover, any nontrivial loop $\overline{L}$ lies outside of the stabilizer and so cannot be expressed in terms of the operators in $S$. However, for a nontrivial loop $\overline{L'}$ the operator $\St{x}{L'}$ commutes with every element of the stabilizer $S$. Hence, an error of this form can be detected by any syndrome measurement. If non-trivial loops of $\px$ operators inflict some encoded state to be protected, a logical operation will inevitably be applied and error recovery fails. The reason why this is all the case follows from analogous arguments described in the previous section.

General Errors

In the previous sections, $\pz$ and $\px$ errors were analyzed seperately in special cases where only a single string of errors if either type were described. Here, we saw that strings of errors manifest themselves as pairs of anyons---$z$ anyons on the vertices of the lattice for $\pz$ errors and pairs of $x$ anyons on the faces of the lattice for $\px$ errors. In the most general setting, it is expected that multiple strings of errors of both types can occur on the lattice at any time. Moreover, a particular qubit of the lattice may suffer from both a $\pz$ and a $\px$ error, in which case a $\py$ error is produced. In this case, a $y$ anyon will be introduced and should be thought of as the quasiparticle associated to the pair of $z$ and $x$ anyons at that site.

When multiple strings of errors of the same type are present on the lattice, there is an inherent ambiguity of how the pairs of anyons should be fused in order to correct the errors since the only information that is provided from a syndrome measurement is the locations of the anyons.  Any such matching of the pairs will result in loops/co-loops (perhaps multiple) on the lattice or dual lattice. Actually, the choice made in this fusion process is somewhat arbitrary. For proper error recovery to take place all that is necessary is for none of the anyons to traverse a nontrivial loop. However, ensuring that error recovery proceeds in this way is still difficult and there is no sure way to guarantee all loops are made trivially.  A configuration of errors illustrating this general setting is shown in the figure below. In addition, two other following figures are shown where guesses are made in an attempt to correct the errors. The lighter paths are meant to denote the actually string of errors that were originally present on the lattice. The darker paths represent the paths that were guessed. In both cases, it can be seen that some of the loops formed are trivial loops in which case those particular errors will be corrected, but there are also some nontrivial loops present which result in logical operations being applied to the encoded state.

In the general case of multiple errors, all that is revealed from the syndrome measurements is the locations os anyon pairs.

A possible correction attempt, where the lighter paths are the actually error strings, and the darker paths are the guessed paths. All errors in the case are corrected, except for the leftmost string of $\pz$ errors where a nontrivial loop has been created.

Another possible correction attempt, where the lighter paths are the actually error strings, and the darker paths are the guessed paths. All $\px$ errors in the case are corrected, but the $\pz$ error strings have been formed into one nontrivial loop.

The problem of being able to correct multiple errors in the toric code thus reduces to another problem: that of matching anyon pairs accordingly as to only form trivial loops. This is essentially a problem that requires additional post-processing utilizing the information given from the syndrome measurements. The most natural strategy is to guess strings that are of minimal length in fusing the anyon pairs. In the literature, such a strategy is referred to as minimal weight matching \cite{Dennis}. One reason why this strategy is justified is because if the probability of a single error occurring on a qubit is small, then it us unlikely that the error strings will be very long. It is more likely that say, $m$, isolated errors occur at different locations of the lattice, than it is for all $m$ errors to occur along a single string. If this is the case, then anyon pairs will tend to stay close to one another. Correcting the errors may then be achieved by fusing anyon pairs that are closest to each other.

For some string of of either $\pz$ or $\px$ errors, define the length of the string to be the number of edges in the path defining the string. Then for a $k\times k$ lattice, if some string were to form a nontrivial loop its length must be at least $k$. This number $k$ is the code distance of the toric code. This means that, at least in principle, any error string of length less than $k$ can be corrected provided that error recovery proceeds in an appropriate fashion. However, for errors of length greater than $k$ it may not be possible to recover from the error and a logical operation being performed on the encoded state may be inevitable. Let $\lfloor c \rfloor$ denotes the floor function defined as the largest integer less than or equal to $c$. If some error string has length $\lfloor \frac{k-1}{2}\rfloor$, then the error can always be corrected by joining the anyon pair through a minimal length path.

Despite the $k \times k$ toric code only ever being able to encode $2$ logical qubits in the code space regardless of the size $k$ of the lattice, the benefit of using a larger lattice is apparent.  If the probability for an error happening on a single qubit is $p$, and different errors remain uncorrelated, then it can be seen that the probability of an error string with length $k$ occurring decreases exponentially. Thus, the larger $k$ is, the more unlikely it is for an error string to form a nontrivial loop.

Logical Operations

In general error correcting schemes, a state $\cw\in\Hil_S$ of the code space is prepared and the main objective is to keep the state invariant. In the presence of errors the state can be mapped outside of the encoded space. This may not always be the case however. It is possible that the original state get mapped to another state $\ket{\psi'}\in\Hil_S$ such that $\cw\neq\ket{\psi'}$. In such an occurrence, it was said the the encoded state $\cw$ experiences a logical operation. In the toric code, these logical operations occurred when a nontrivial loop was executed on the lattice.

To understand what kind of operations these logical operations on the encoded state correspond to, recall that their were two types of nontrivial loops on the surface of the lattice. One of the nontrivial loops corresponded to a loop that wraps around the hole of the torus, and the other corresponded to a loop that traverses the equator' of the torus. In the lattice picture, one of these loops pass through the 'north-south' boundary, and the other through the 'east-west' boundary. Likewise, there were two analogous nontrivial co-loops for the dual lattice.

By representing the encoded state as $\cw=\ket{\overline{00}}\in\Hil_S$, where the label $\overline{00}$ has been used to emphasize that the state encodes two logical qubits, the nontrivial loops can be interpreted as logical $\pz$ and $\px$ operations. For a nontrivial string of $\pz$ operators looping in the `north-south' direction, write $\overline{Z_1}$ to represent a logical $\pz$ operation applied to the first logical qubit of $\cw$. The nontrivial loop in the 'east-west' direction then corresponds to a logical $\pz$ operation applied to the second logical qubit of $\cw$, denoted by $\overline{Z_2}$. Likewise, the two nontrivial loops of $\px$ errors on the dual lattice correspond to logical $\px$ operations denoted by $\overline{X_1}$ and $\overline{X_2}$. It does not matter how any of these nontrivial loops are formed, in the sense that the exact path described by a particular string operators forming the nontrivial loop is irrelevant. All that matters is which topological class the loop falls in. If a certain loop is traversed $n$  times, then the logical operation executed is one of $Z_i^n$ or $X_i^n$ depending on the direction and wether or not the loop was on the lattice or dual lattice, respectively. If a loop traverses multiple topologically distinct nontrivial loops, then the corresponding logical operation that is performed is the composition of the respective logical operations from each loop in the order that the loops were traversed.

In terms of logical operations on the encoded qubits, all that can be performed are logical Pauli operations on the two encoded qubits. Hence, universal quantum computation cannot be performed using only these limited operations, since arbitrary two qubit gates cannot be realized. In particular, any two qubit entangling gate can not be performed on the logical qubits since only tensor products of two Pauli gates can be executed by the logical operations $Z_i$ and $X_i$.

Generalizations and Conclusion
In summary, the $k\times k$ toric code uses $2k^2$ total qubits placed on the edges of the square lattice to effectively encode $2$ logical qubits. Its main function is to serve as a quantum memory that protects the state of two qubits from Pauli errors. Errors on the lattice manifest themselves as pairs of anyon excitations.  The objective of error correction is to fuse the anyons together by forming only trivial loops with the anyons in the process. If nontrivial loops were performed then a logical operation is performed on the encoded state corresponding to $\px$ and $\pz$ operations or combinations thereof. The distance of the code was shown to be $k$, which corresponds to the shortest length path needed to form a non-trivial loop on the lattice. The larger the lattice dimension $k$, the more unlikely it is to form a nontrivial loop, and thus the chances of proper error recovery increase.

It is not necessary that the dimensions of the square lattice be symmetrical. In the case of a $k\times k'$ lattice, with $k\neq k'$, the code distance will correspond to the minimum value of $k$ and $k'$ since this will correspond to the shortest possible length an error string needs to make before it forms a nontrivial loop. The limitation of only being able to encoded two logical qubits can also be lifted if the lattice is embedded on a higher genus surface. For a surface of genus $g$ the number of encoded qubits is given by $4^g$, since each additional hole effectively adds 4 new topological classes of nontrivial loops. It is worth mentioning that it is not absolutely essential to embed the lattice on a non-planar surface with nonzero genus. Remaining on the plane, the toric code can be generalized by redefining the boundaries to have appropriate properties. In this scenario, more logical qubits can be encoded by adding "holes" to the planar region by removing qubits and stabilizers from the region. The holes are present, the more logical qubits can be encoded. Such generalizations are considered in \cite{Dennis}.

In the toric code model introduced here, the permissible logical operations are not rich enough to allow for universal quantum computation. The toric code model is captured more generally in the  quantum double models defined for any finite group $G$. Abstractly, this uses the mathematical theory concerning group representations of quasi-trianglular Hopf algebras to define more general anyon dynamics. The toric code model presented here is just the special case of a quantum double over the cyclic group of order $2$. Generalizations in this regard have been made in the field, and can be found in \cite{Shor}. In order to achieve universal quantum computation the group under consideration must be non-abelian and non-solvable.\cite{Mochon} Even then the complexity of the scenario is increased significantly since the smallest group satisfying this property is the alternating group, $A_5$, consisting of all even permutations on five letters, which has order $60$.