Quantum Error Correction with the Semion Code

We present a full quantum error correcting procedure with the semion code: an off-shell extension of the double semion model. We construct open strings operators that recover the quantum memory from arbitrary errors and closed string operators that implement the basic logical operations for information processing. Physically, the new open string operators provide a detailed microscopic description of the creation of semions at their endpoints. Remarkably, topological properties of the string operators are determined using fundamental properties of the Hamiltonian, namely the fact that it is composed of commuting local terms squaring to the identity. In all, the semion code is a topological code that, unlike previously studied topological codes, it is of non-CSS type and fits into the stabilizer formalism. This is in sharp contrast with previous attempts yielding non-commutative codes.

The Kitaev code is the simplest topological code yielding a quantum memory [1]. It can be thought of as a simple two-dimensional lattice gauge theory with gauge group G 2  = . In D=2 spatial dimensions, there is another lattice gauge theory with the same gauge group but different topological properties: the double semion (DS) model [16][17][18][22][23][24][25]. Although the Kitaev and the DS models are lattice gauge theories sharing the same gauge group, G 2  = , the braiding properties of their quasiparticle excitations are radically different. For example, whereas braiding two elementary quasiparticle excitations (either an electric or a magnetic charge) gives a +1 phase in the Kitaev code, doing so in the DS model yields ±i phase factors.
The DS model was introduced in the context of the search of new topological orders in strongly correlated systems, gapped, non-chiral and based on string-net mechanisms in D=2 dimensions [16,17]. Generalizations of the DS model to D=3 and to higher dimensions have appeared recently [18]. While the properties of the Kitaev code has been extensively studied in quantum computation and condensed matter, barely nothing is known about the quantum error correcting properties of the DS model despite recent efforts towards realizing such models [19][20][21]. In this work we remedy this situation by introducing a new formulation of the DS model that is suitable for a complete treatment as a quantum memory with topological properties.
The first obstacle to tackle the DS model as a quantum memory is the original formulation as a string-net model [16]. In this formulation, the Hamiltonian is only Hermitian and exactly solvable in a particular subspace, where plaquette operators are Hermitian and commute. Only linear combinations of closed-string configurations, implying the absence of vertex excitations, are allowed in this subspace [16,26,27]. The microscopic formulation of the original DS model starts with a hexagonal lattice Λ with qubits placed at links e. Vertex operators Q v are attached to the three links meeting at a vertex väΛ. Plaquette operators B p are attached to hexagons päΛ with the novel feature that their outer links carry additional phase factors that are missing in the corresponding Kitaev model. Explicitly with i, j , k, being the three qubits belonging to vertex v (see figure 1(a)) and where ∂p are the six links of the hexagon and o(p) is the set of six edges outgoing from each plaquette p, as it is shown in figure 1(b). Unlike the Kitaev code, these plaquette operators B p are Hermitian and commute among themselves only in a subspace of the whole Hilbert space, defined by the so-called zero-flux rule [16,26,27]. This is given by a vertex-free condition on states

≔˜( )
Due to the involved structure of phases that plaquette operators in equation (2) have, it was aforementioned that these operators do not commute out of the vertex-free subspace. This implies that the model is only well-defined when there are no vertex excitations. Therefore, in order to treat the DS model as a quantum error correcting code [11,[28][29][30][31], it is necessary to have a formulation of the model that is valid in the whole Hilbert space and not just for the vertex-free subspace (3), since generic noise processes will make the system leave the mentioned subspace. To this end, we introduce an off-shell DS model that we call the semion code. This new model is achieved by making a deformation of the original plaquette operators (2) such that they become commuting and Hermitian operators without imposing the vertex-free condition [27]. In addition, we are able to develop the complete program of quantum error correction with the semion code.

Summary of main results
In order to summarize the main contributions that we present in this paper, we hereby advance a list of some of our most relevant results.
(i) We perform a thorough analysis of a formulation of the plaquette operators which commute in the whole Hilbert space [27]. This construction consists in adding extra phases to the plaquette operators, which depend on the configuration of the three edges at each vertex. When the vertex-free condition is imposed, we recover the standard definition of the DS model.
(ii) We give an explicit construction for string operators along arbitrary paths. They are complete in the sense that any operator acting on the system can be decomposed as a linear superposition of such operators. Additionally, the string operators can be constructed efficiently despite the complex structure of the plaquette operators. Remarkably, a microscopic formulation to create semions was not proven until now.
(iii) We analytically show that the excitations of the system behave as semions, via the detailed study of the constructed string operators, which allows us to explicitly calculate the topological S-matrix. Interestingly enough, most of the string operator properties rely on very generic arguments about the structure of the local operators making up the Hamiltonian, namely that they commute and square to the identity.
(iv) Closed-string operators are constructed, which allow us to perform logical operations on the quantum memory built from the semion code. Logical operators are closed-string operators whose paths are homologically non-trivial and act non-trivially on the degenerate ground space.
(v) Given the above properties, we define a topological quantum error correcting code based on a non-trivial extension of the DS model. We build a code, which is characterized by the following key properties: is topological, satisfies the stabilizer formalism, is non-CSS, non-Pauli and additive.
The topological nature of the code becomes apparent through the fact that global degrees of freedom are used to encode information and only local interactions are considered [1,4]. Another remarkable feature of the semion code is that is of non-CSS type since in the plaquette operators both Pauli X and Z operators enter in the definition [9,28]. Consequently, errors in an uncorrelated error model such as independent bit-flip and phaseflip errors cannot be treated separately. However, they can be decomposed as a linear superpositions of fundamental anyonic errors (string operators creating pairs of anyons) with a known effect on the Hilbert space. Moreover, the semion code is not a subgroup of the Pauli group since the complex phases entering its definition (see equation (2)) makes impossible to express its generators in terms of tensor products of Pauli matrices [32,33]. Nevertheless, the semion code is still an additive code: the sum of quantum codewords is also a codeword [34]. This last fact is intimitely related to the abelian nature of the semionic excitations [35,36].

Outline
The article is organized as follows. In section 2 we introduce the off-shell DS model, which is suitable for quantum error correction. In section 3 we build string operators creating vertex excitations at their endpoints. Section 4 is devoted to logical operators and quantum error correction. We conclude in section 5. Appendices deserve special attention since they contain the detailed explanations of all the constructions used throughout the text. Specifically, appendix A presents an explicit example of a string operator, appendix B gives the detailed proof of theorem 1, which presents a systematic way to construct string operators, as well as several key properties of the string operators and finally appendix C is devoted to the proof of theorem 2, which gives the commutation relations among string operators.

Off-shell DS: microscopic model
We begin by considering a microscopic description of the DS model on the entire Hilbert space of states, since it is much better suited for quantum error correction. We call this an off-shell DS code by borrowing the terminology from quantum field theory and other instances in physics where a shell condition amounts to a constraint on the phase space of a system. For instance, the equation of motion is a shell condition for quantum particles but the phase space is more general. In our case, the shell condition is the vertex-free subspace or zeroflux rule introduced in equation (3).

DS model in the vertex-free subspace
Let us start by introducing the DS model in a new presentation that is more suitable for building an off-shell formulation of it. We consider the same hexagonal lattice Λ with qubits attached to the edges eäΛ. The vertex operators Q v will remain the same as in equation (1), but the plaquette operators in the zero-flux subspace can be rewritten in an equivalent form to that shown in equation (2), i.e.
)is the projector on the state 0ñ | (n + ) or 1ñ | (n -) of qubit i, qubits are labeled as shown in figure 1 and we use the convention that n 0  refers to qubit '6' for simplicity. Remarkably, this expression avoids any reference to the outgoing links of hexagonal plaquettes p. One readily sees that the vertex operators fulfill the following relations: ¢ Î L. As for the plaquette operators B p , they also satisfy ¢ Î L, but only in the vertex-free subspace (3). Furthermore, the product of all the vertex and plaquette operators is the identity. A simple counting argument reveals that the ground space is 4 g degenerate 1 , which g being the genus of the orientable compact surface onto which the lattice is placed.
An explicit unnormalized wavefunction belonging to the ground space is obtained in the following way: we start from the vacuum, i.e. 0 N ñ Ä | , which has +1 eigenvalue for all vertex operators. Then, plaquette operators are used to build projectors and apply them onto the vacuum It is straightforward to check that this state fulfills the lowest energy condition for the Hamiltonian (4) within the vertex-free subspace. Expanding the product in equation (8), one can see that the ground state is a superposition of closed loops configurations. Due to the condition B 1 p =for the ground state, the coefficients of this superposition of closed loops alternate sign. Thus, we can write the ground state in a different way: where i  is a bitstring representing a qubit configuration and C S conf.
{ -}is the set of all possible closed-string configurations. Each configuration in this set has a certain number of closed loops, N i L  ( ), whose parity determines the sign of the coefficient in the ground state superposition.
Of course the above construction only gives rise to one of the ground states. To find the other ones, the starting configuration can simply be replaced by a configuration containing an homologically non-trivial closed loop (which necessarily belongs to the vertex-free subspace), and proceed with the same construction. Every different homological class for the closed loop corresponds to a different ground state.
Applying the B p operator on a specific loop configuration flips the string occupancy of the interior edges of plaquette p while acquiring a phase that depends on the specific configuration under consideration. Applying B p on the vacuum simply adds a closed loop around plaquette p, while applying B p next to a closed loop either enlarges (or shrinks) the existing loop to include (exclude) plaquette p, while multiplying the wave function by −1 factor (see figure 2).
Due to the lack of commutativity of the plaquette operators and the fact that they are not Hermitian, the original DS model is only well-defined when there are no vertex excitations. Moreover, the strings creating vertex excitations are not properly defined either. A naive attempt to construct these strings as a chain of σ x operators, following the similarities with the Kitaev code, resoundingly fails. As a consequence of the phases on the external legs of plaquette operators, σ x operators create vertex excitations but also plaquette excitations. In order to get a string that creates only two vertex excitations at the endpoints but commutes with all the plaquette operators along the path , it is necessary to add some extra phases to the chain of σ x on the outer legs. An approach to this problem is described in [27] but it is not successfully solved since the strings are only welldefined in the vertex-free subspace.
The DS model gives rise to quasiparticle excitations behaving like anyons. They are called semions, due to the fact that their topological charge is 'half' of that of a fermion, i.e. ±i. There exist two types of semions in the model, one corresponding to a vertex excitation, while the other corresponds to both vertex and adjacent plaquettes excitations. From now on, we name these two different possibilities as chiralities, positive chirality for the former kind, and negative chirality for the latter one. We warn the reader that this choice has been made arbitrarily, and does not necessarily reflect the topological charge of a given specie. Taking into account all these caveats, we present in the following a formulation of the DS model which gives a microscopic approach to this interesting topological order, fulfilling all the necessary properties in the whole Hilbert space.

Exactly solvable model in the whole Hilbert space
If we want to consider encoding quantum information in the degenerate ground-state manifold of the standard (on-shell) DS model in equation (4), we immediately run into major problems: X Pauli errors make the state of the system leave the vertex-free subspace. The non-commutativity of the B p operators poses difficulties when interpreting the DS model as a stabilizer code.
To avoid such difficulties, we consider a modified version of the plaquette operators in equation (2), which we call the off-shell DS model or semion code where the generalized plaquette operator B p is a modification of B p obtained by multiplying it by a phase factor that depends on the configuration on which it is applied. More specifically, we have where the sum runs over all possible configurations of edges 1 through 12 shown in figure 1 b ( ) is a function of the string configuration of edges i, j and k connected to vertex v(i, j, k). The specific values for each factor β (i, j, k) are shown graphically in figure 3. Note that their specific form differ depending on their position on the plaquette.
For future reference, notice that the generalized plaquette operator B p can be written as where we use the notation j ä ∂p to indicate the qubit associated to edge j in plaquette p. v ä p identify the vertices belonging to plaquette p. Notice that this last expression clearly shows that the phase factor appearing in B p is a product of phases, β v , depending on the string configuration of the three edges connected to each vertex of plaquette p. The complete algebraic expression of the product of all β v in a plaquette p is [27] i i n n n n n n n n n n n n n n n n n n n n n n n n n n n n n n 12 We can easily check that in the zero-flux rule the factors in equation (15) reduce to 1, recovering expression (5) for the plaquette operators. The crucial point now is that the new generalized plaquette operators, B p , satisfy the desired properties needed by the stabilizer formalism of quantum error correction. Namely, ¢ Î L regardless of the vertex-free condition (3). The study of H DS is rendered much simpler than that of H DS on the whole Hilbert space of the qubits by the fact that the new plaquette operators commute.

String operators
We seek open-string operators creating excitations at their endpoints without affecting the rest of vertex and plaquette operators, as well as closed-string operators that commute with vertex and plaquette operators. In our case, excited states correspond to states in a −1 eigenstate for a vertex operator or a +1 eigenstate of a plaquette operator. We say that an excitation is present at vertex v (plaquette p) if the state of the system is in a −1 (+1) , excitations are always created in pairs. In order to find such string operators, it is convenient to reexpress the generalized plaquette operators as where p denotes the interior edges of a plaquette (edges 1 through 6 in figure 1) and the string configurations in the sum are taken on edges 1 through 12. b i p  ( ) denotes the complex phase picked up when applying operator B p to the configuration i |differs from the product of the β p ʼs in the −1 factors appearing in equation (14).
|includes the −1 factors as well as the product of β v . Given two string configurations i  and a  on a set of edges, it is useful to define the string configuration i a Å   to be the configuration i ¢  where the edges occupied in configuration a  has been flipped. It is equivalent to sum (mod 2) the two bitstrings. Additionally, we define the configuration p a  of plaquette p as the string configuration which is empty everywhere except for the six edges in the interior of plaquette p, corresponding to edges 1 through 6 in figure 1. Likewise,  a  , will be the configuration which is only occupied for edges of path .
Given a path , we construct string operators S  + creating vertex excitations at its endpoints and commuting with every other operators in Hamiltonian (10). Negative chirality strings are defined as S S S z ¢ is a product of z s operators forming a path dual  ¢ in the dual lattice which is contained in the support of S  + .
If  is open, S z dual ¢ creates excitations at plaquettes containing the vertices at the endpoints of  and opposite to the first and last edges of  (p 1 and p 9 in figure 4), while if  is closed, S z dual ¢ forms a closed path in the same homological class as . Note that for a given path , various paths dual  ¢ are possible, and each one gives rise to a different string operator S  -.

An algorithm to generate string operators
In order to find these string operators, we consider the following ansatz: It is also useful to define the set of plaquettes which is the set of plaquettes that have at least one of their interior edges contained in Conn (). Equivalently, one can define   to be the set of plaquettes such that for at least one string configuration figure 4. Note that depending on the context, a configuration i  is either understood to be on the full system, or is the configuration restricted to Conn  ( ). The specific case considered is explicitly stated in each case.
Operators satisfying (i) and (ii) are called string operators. Additionally, we may be interested in the properties: Squares to the identity. Hermitian.
If these are satisfied, they will be called canonical string operators. Properties (iii) and (iv) are satisfied (see lemmas 5 and 6 in appendix B) if Since we want S  + to commute with all plaquettes in   (for the rest of plaquettes, it commutes by construction), we impose that the commutator vanishes, S B , 0 ] , which yields the equation It is useful to define the function We can generalize equation (22) and function i p , )for an arbitrary number of plaquettes, namely , , , , 23 Note that while we use the same symbol for the configurations i  in  q and in F  , the one in  q is over the whole system in order for equation (24) to be well-defined. The specific way that the configuration i  is extended over the whole system (i.e. which configuration on the rest of the system is appended to it) does not matter, since as a consequence of the structure of the plaquette operators, it does not affect the value of  q . As a consequence of the fact that plaquette operators commute, the order of the plaquettes p 1 , ..., p m in i p p , , , m ) relates the value of F  for configuration i  to that of configuration i ...  i j j i : where the configurations are restricted to Conn  ( ). These configurations can be regarded as the set of configurations related to i  by adding loops associated with plaquettes in   , only in the region where S  + acts non-trivially. Taking all this into account, one can obtain an algorithm to compute the phases F  + of the ansatz in equation (18). This is given by algorithm 1.
( ) are initial phases that can take any value.
for every configuration class   do Pick a class representative i Algorithm 1 begins by picking up a configuration i  , which we call its class representative, and by setting its value to an arbitrary phase e i if  ( ) . Any phase picked up by the algorithm yields a valid string operator. Once the value for the class representative i  is fixed, the algorithm assigns values to the rest of the configurations in the same configuration class by making use of equation (23). Afterwards, a configuration, belonging to a different configuration class, where the values have not yet been fixed, is chosen and the same procedure is repeated until F  has been fixed for all possible configurations. An explicit example of this can be seen in appendix A.
As it is shown in appendix B, it is always possible to determine F  using algorithm 1 such that the resulting S  + is a string operator. Furthermore, it is also possible to enforce the constraint given in equation (21) such that we obtain canonical string operators. Those important results are summarized in the following theorem: Furthermore, it is possible to choose the phases e if such that the string operator is canonical.
Note that the open-string operators generated by algorithm 1, S  + , have positive chirality, because they anticommute with vertex operators at the endpoints of  and commute with every other vertex and plaquette operators, satisfying property (i). However, the same does not apply to closed-string operators, since closed strings do not have endpoints. Algorithm 1 produces, in general, closed-string operators without a definite chirality.

Concatenation of open-string operators
It is very useful to build strings as a concatenation of smaller strings. This is specially relevant for constructing non-trivial closed strings, since, as it was mentioned before, algorithm 1 yields, in general, closed strings which have no definite chirality. By building these closed strings out of a multiplication of open strings, which have definite chirality, we obtain positive-and negative-chirality closed strings. Observe that given two paths, 1  and 2  , meeting at one endpoint or forming a closed path, the multiplication of both S S S operator satisfying properties (i) and (ii). In this way we can build long string operators by concatenating short ones.

Crossing string operators
In order to understand the algebra of the string operators of the semion code that we build in section 4.1, it is essential to know the commutation relations between them acting on different paths.
The notion of crossing paths need to be precisely defined since the region on which the string operators act non-trivially, Conn  ( ), has a finite thickness. Heuristically, in order to consider that two paths are crossing, the commun edges to both paths must not contain the first nor last vertex of neither of the paths. Note that two paths can cross more than once.
We further need to define the notions of self-crossing and self-overlapping paths. Essentially, a path is selfcrossing if an observer moving on the path passes more than once on any given edge. A path is said to be selfoverlapping if some regions of the support of the string operator but not the path itself overlap and connect some distant parts of the paths. Figure 5 illustrates the previous concepts. We refer the reader to appendix C for rigorous definitions, as well as the proof of theorem 2. This theorem summarizes the commutation relations among the string operators.  Given the definition of negative chirality string operators, and using the above results, we find that S S , 0 Interpreting a vertex (in the case of S  + ) or the combination of a vertex and plaquette excitations (in the case as the presence of a quasiparticle labeled by s + and s − respectively, the topological S matrix [35], written in the basis s s s s 1, , , ) where 1 denotes the vacuum, i.e. the absence of excitation, and s s +the composite object excitation, is found to be S 1 2 We can thus interpret the string operators S  + and S  as creating pairs of semions of different chirality at their endpoints.

The need for path concatenation
Notice that theorem 2 does not state anything about closed paths (homologically trivial or not) which are composed of a single path. One can check that when such a path crosses another one, in general they do not commute nor anti-commute. Such paths thus cannot be considered as 'fundamental' string operators in the sense that they do not possess a definite chirality. Algorithm 1 enforces that the , which is also a valid output of algorithm 1. In fact, such a S z dual ¢ operator can be added selectively to only a subset of configuration classes, causing a 'mixing' of the chiralities. This is explained in detail in appendix C.3.
By producing closed paths starting from smaller open paths as their basic constituents, one can enforce the production of strings of a definite chirality. This is caused by the fact that the individual components cannot carry flux excitations by construction, and so neither can their concatenation. The physical intuition is that each small open string operator creates a pair of semions of positive chirality at their endpoints. Since the created semions are their own anti-particles, they subsequently all fuse to the vacuum, returning the system to the ground space.

Completeness of the string operators
In this section, we seek to decompose a string of σ x operators into the strings operators defined in our model, S + and S z .
We first note that any matrix ρ of size 2 n ×2 n can be written as a linear combination of Pauli operators, i.e.
c P P P P , , P P x z x z , Figure 5. Examples of (a) a self-crossing path  and of (b) a self-overlapping path . The dashed blue edges indicate the links where the string  self-overlaps, since some distant parts of the path are connected.
where P x (P z ) are Pauli operators acting on n qubits and formed of products of identities and σ x (σ z ) operators only and where c (P x , P z ) are non-zero complex numbers. Given the matrix ρ, one can recover the coefficients c(P x , P z ) using the formula c P P P P , 1 2 Tr . 29 x z n In our case, a chain of σ x operators on path , denoted by X  , can be written as where P z are Pauli operators containing only identities and σ z and where we write P Conn z  Î ( )in an abuse of notation to signify that P z acts non-trivially only on the qubits in Conn  ( ). The coefficients c P z ( ) are given by where Conn  | ( )|is the number of edges in Conn  ( ). Chains of σ z operators form valid string operators S z , which create flux excitations at their endpoints. This clearly shows that any Pauli operator acting on the system can be written in terms of string operators. Since any operator acting on the system can be decomposed as a linear combination of Pauli operators, we find that the string operators are complete in the sense that any operator can be expressed in terms of them.

The semion code
The tools we have developed in previous sections can be used to build a quantum error correction code using as code space the ground space of the off-shell DS model, given by Hamiltonian (4). The information encoded is topologically protected since we are using global degrees of freedom that cannot be affected by local errors. Additionally, we perform quantum error correction using the DS model as a stabilizer code, where plaquette and vertex operators are our stabilizers.

Logical operators
Recalling that a surface of genus g can be seen as the connected sum of g tori [37], we can define two pairs of anticommutating logical operators for every torus in the connected sum [38]. One pair consists of string operators  Figure 6 illustrates two such pairs for a genus 1 torus.

Quantum error correction
The stabilizer operators, vertices and plaquette defined in equations (1) and (11), can be periodically measured to detect any errors occurring in the system. Once the syndrome pattern is obtained, assuming a given noise model, it is fed into a decoder. It outputs a recovery operation using the string operators developed in this work in order to bring the system back to the encoded subspace, where the probability of applying a non-trivial logical operation is minimized. While we leave the development of decoders specifically designed for the semion code for future work, one could imagine adapting some of the various existing decoders developed for topological codes [2,. Table 1 shows the probabilities of measuring a given flux configurations after applying a single σ x on the ground state for the three possible edge orientations shown in figure 7. Note that as equations (30) and (31) suggest, the probabilities in table 1 do not depend of the phases used to initialize the F {e} function in algorithm 1. More details giving a deeper understanding on the structure of the string operators S  + can be found in appendix B.3. A distinctive feature of the probability distributions in table 1 is that there is a directionality in the error pattern. A σ x error affecting a vertical edge (orientation (b)) is much more likely to leave flux excitations behind than for the other two orientations. This is clearly due to the specific structure of the plaquette operators, and could be used advantageously when dealing with asymmetric noise [62,63]. Another major difference with the toric code is the fact that chains of σ x errors are likely to leave flux excitations along their path. This additional information could be used by the decoder and may lead to a higher threshold value.

Conclusions and outlook
One of the key features of the off-shell DS model developed here for error correction is that it is a non-CSS code [64,65]. This is not novel in the theory of quantum error correcting codes. In fact, the answer to the important question of what is the minimal complete error correction code that is able to encode one logical qubit and correct for an arbitrary error was precisely a non-CSS code of five qubits [64,65]. This is consistent with the quantum Hamming bound [32], and is in sharp contrast with the classical case where the solution is the repetition code of three bits. However, what is peculiar of the off-shell DS code is that, to our knowledge, this is Arrows indicate identified boundaries. Table 1. The various probabilities of getting a given flux excitation configuration after the application of the operator x s on a qubit, for the three possible orientations. The plaquettes label correspond to the ones in figure 7.  the first non-CSS topological quantum memory that being a stabilizer code, it is also a topological code throughout the whole Hilbert space. In a sense, this was a missing link in the theory of topological quantum error correction codes and we have filled this gap with the tools introduced in our work.
We notice that a previous study [33] attempted to construct a quantum error correction code using the DS model as the starting point. The main difference with our work is that they construct a non-commuting quantum correcting code, whereas we have succeeded in constructing an extension that belongs to the stabilizer formalism. As a consequence of this, the whole error correction procedure of the off-shell DS code is topological. On the contrary, the topological nature of the non-commuting code in [33] is unproven. Both constructions share the feature of using non-Pauli operators to construct the basic string operators of the model.
The outcome of our work is a complete characterization of the error correction procedure for a quantum memory based on a topological non-CSS stabilizer code. This is a major step for the reason explained above. However, a fully-fledged quantum computer will demand more, namely, a universal gate set and a fault-tolerant procedure to battle errors dynamically [66]. With the tools deployed here, it is conceivable that this goal will be achieved elsewhere.
A new way of constructing quantum codes opens up with this work. The tools introduced here for models like the DS based on Abelian lattice gauge theories can be generalized to other Levin-Wen models [16,67,68], like doubled Fibonacci models, or twisted versions of fracton models [69]. This is the subject of further study.

Appendix A. Example of an open-string operator
It is instructive to illustrate the workings of algorithm 1 to find string operators S  + in order to gain a more . Noting that e  { } contains the 4 plaquettes identified as p, q, r and s in figure A1, we find the following values for F e + { } : Again, two class of configurations are fixed due to the fact that the string is canonical. We keep doing this till all configuration classes have been fixed. As a result, we obtain S e + { } , which commutes with the four neighboring plaquette operators B p , B q , B r and B s shown in figure A1, as well as all the other plaquette operators which are farther away.
Appendix B. Proofs regarding string operators produced by algorithm 1 In order to prove theorem 1, we begin by stating several technical results in the following section.
Proof. According to equation (24), we have that where we used the fact that X  commutes with the plaquette operators B r l , since the plaquettes in r r , , s 1 ¼ { } are not in Conn  ( ). X  is the string of x s corresponding to the string operator defined on . , Lemma 3. The functions F  constructed by algorithm 1 are well-defined.
Proof. First note that lemma 1 states that the order in which the plaquettes p p , , n 1 ¼ { } appear in a specific subset of   and the order into which the subsets are chosen do not affect its value.
Next, we show that if there are two different sets of plaquettes p p , , m ) , and of the way that the F  functions are built; Lemma 4. Let F  be a function determined by algorithm 1. Then F  simultaneously satisfies all the constraints (22).
Proof. Consider an arbitrary configuration i  for which the value of F i   ( ) has been determined using algorithm 1. Two possible cases need to be analyzed: 1. If i  is one of the configuration picked to set an unknown value of F i   ( ), then we find that for any plaquette p, We thus have that in both cases, all the constraints (22) are satisfied. ,  String conf.
, then for any set of plaquettes q q , , k Proof. By hypothesis, we have that where we took advantage of the fact that i q i q , , , as is clear from equation (21).
Since F  lies on the unit circle, we find that The same reasoning can be recursively employed to show that , then F  simultaneously satisfies all the constraints in equation (21).
Proof. As it was done before, two possible cases are considered.
Using algorithm 1, we find that Since all the conditions of lemma 7 are satisfied, we have that

B.2. Proof of theorem 1
Given all the previous technical results, it is straightforward to give the proof of theorem 1, which we restate here for ease of reading: Theorem 1. Let  be a path. Any function F  defined by algorithm 1 is such that S   is a string operator.
Furthermore, it is possible to choose the phases e i if ( ) such that the string operator is canonical.
Proof. First note that according to lemma 3, F  is well-defined. By construction, F  has non-trivial support only in Conn  ( ),thus any operator S   built from it satisfies condition (ii). Furthermore,lemma 4 states that S  + satisfies conditions (22). We thus have that condition (i) is satisfied as well,proving that S   is a string operator.
In order to show that it is always possible to choose the phases e i In both cases, we can use lemma 8 to find that all constraints of equation (21) are fulfilled and therefore, conditions (iii) and (iv) are also satisfied. ,

B.3. Consistency of the probability of measuring an excitation configuration
The decomposition of X  in terms of string operators given by equation (31) is not unique given that in algorithm 1, we are free to choose different initial phases for the various class representatives. However, we show here that the probabilities associated with finding a given excitation pattern after the application X  are insensitive to those initial phases. For simplicity, we assume that  is a single non-overlapping and non-crossing open path. The arguments below generalize in a straightforward manner to the case where we need to consider ... m is the representative of the configuration class into which i  belongs, and j j  ( ) is the phase difference used between F  and F  to initialize algorithm 1.
We define the orthonormal basis L C , ñ {| }where C labels the vertex and flux excitations configuration while L is a label for the 4 g degenerate states corresponding to a given configuration. The probability of the transition L C L C , , ñ  ¢ ¢ñ | | caused by the application of X  is given by Clearly, P z and P z ¢ share the same endpoints and belong to the same homological class, i.e. P P z z ¢ form a trivial closed loop. Given the decomposition in equation (B14), we find that for j j To see this, we rewrite equation (B16) as where Q n { } denotes the set of all subsets of products of charge operators associated with the vertices in path . Noting that since i  and i ¢  belongs to different configuration classes, there exists a vertex n¢ such that c i Using this last fact, we get which clearly equals 0.
The probability transition is thus given by which is independent of the phases e j ij  ( ) .

Appendix C. Topological properties of strings operators
Before presenting various technical results, we begin by precisely defining what we mean by crossing paths.
} , then  is said to be self-crossing. If there exists a plaquette containing two or more vertices of v  that cannot form a single consecutive sequence, then path  is said to be self overlapping -. Note that the notions of self-overlapping and self-crossing do not imply each other (see figure 5).

Definition 2. Consider two paths
e e , , n Consider a sequence of edges in common of both paths  and , and consider the largest (possibly empty) such sequence (supposing for now that it is unique), E e e e e , , Consider the following properties: If condition (i) is satisfied, we say that paths  and  cross over the edges E ,   . Note that for the case of two closed paths, we always say that they cross. If condition (ii) is not satisfied (including the case where E ,   is the empty set), we say that  and  cross 0 times, otherwise we say that paths  and  cross once. Finally, if there is more than one pair of sequences E i ,   and i ,   L where i runs from 1 through m which all satisfy conditions (i), we say that paths  and  cross. For all the regions E E , , , we say that paths  and  cross over the relevant region, and we additionally say that paths  and  cross m¢ times. See figure C1 for explicit examples.
Note that in the previous definition, paths  and  can be formed of smaller paths, i.e. ... m Notice that when  and  cross, we may define a reference frame such that one of the paths plays the role of the horizontal and the other the vertical. In the following, we consider that path  is the horizontal and  the vertical.
It is useful to define Note that we implicitly used the fact that paths  and  cross, are open, and that they are not selfoverlapping nor self-crossing in the above definition. If it were not the case, then it would not be possible to find a set of plaquettes such that the associated configuration corresponds to the configuration of the other path on its connected region.
Furthermore, for a general path ... m 1    = # # with every path i  { } open, not self-crossing nor selfoverlapping, but for which it is not necessarily true for the whole path , and for a path  such that  and  are crossing, it is always possible to similarly define ,left right where the product over the small strings are taken in the reverse order, and where the string configurations are considered over the whole system. Similarly computing the product of the string operators in the reverse order, we get Considering equations (C1) and (C2), we define the quantity  is independent on the specific string configuration i  , which is shown in lemmas 9 and 10, and that it does not depend on the specific way that the paths  and  are partitioned in the smaller paths i  { } and j  { }, as long as those are not self-crossing nor self-overlapping. It can also be shown that if paths  and  are transformed to paths ¢ and ¢ using a series of elongations, reductions and valid deformations such that none of the elementary step makes a path crossing an endpoint of the other path, then we find , ,       = ¢ ¢ . This is done in lemmas 11 through 15 as well as in corollary 1. If paths  and  cross an odd number of times, one can then proceed to transforms paths  and  to minimal configurations min  and min  such that , , min min       = (see figure C4). Explicitly computing this last quantity for a given string configuration yields 1 ,    = -. If, on the other hand,  and  cross an even number of times, one can consider the deformed paths 0  and 0  such that , and such that 0  and 0  supports are disjoint, showing that 1 ,    = + . Remarkably, all those previous results are essentially due to the fact that the plaquette operators commute and square to the identity.

C.1. Useful technical lemmas
Lemmas mentioned before are introduced here. They are necessary to show theorem 2.
We begin by considering the quantity Using the structure of the F i  as defined by algorithm 1, we find that there exists a configuration i ¢  and a set of plaquettes p p , , m

We can thus write
where we made use of equation (24). Note that using lemma 2, we are free to choose the values for a i = left/right and b j = up/down, as we please. This will turn out to be very useful later on. Using equation (24), we find A similar reasoning holding for the quantity Proof. Consider an arbitrary edge e and its associated canonical string operator S e + , which we can always find according to theorem 1. Further let p p , , , and which we are always free to choose according to lemma 2. Using lemma 9 and the fact that S e + is canonical and therefore squares to one, the quantity i Carefully looking at the right-hand side of the equality, we find that Note that it is always possible to choose the a i ʼs and the b j ʼs so that, in case of need, we can add some additional plaquettes in We thus get As in the reasoning of the proof of lemma 10, we used our freedom to add some plaquettes to Proof. To see that equation (C18) holds, it suffices to use the same reasoning than in lemma 11, this time for the appropriate path x  . , Given the fact that the quantity ... , ...
is insensitive to the specific decomposition of the paths  and  as long as they are composed of simple paths which are not self-crossing nor self-overlapping, from now on we will simply write ,    .
Using the structure of S 0  + , we find that and since paths  and  are crossing, we find that for any string Furthermore, using lemma 10, we see that    Figure C3. This illustration shows a specific example on path deformation. Three distinct paths ( , , ) two paths as close as possible in order to minimize the length of the paths. We thus find that computing ,    reduces to computing this quantity for a single minimal path configurations min  and min  illustrated in figure C4. Explicit calculations using equation (C3) for a single underlying string configuration (lemma 10 ensures that its value is independent of the configuration), gives that 1 , min min    = -. ,

C.2. Proof of theorem 2
Having introduced all previous technical lemmas, we are in a position to complete the demonstration of theorem 2.   . This can simply be achieved by taking individual paths of lenght 1 in the decomposition of path . We thus find that To complete the proof, it suffices to notice that we can now apply the reasoning of the first two paragraphs of this proof. , C.3.1. Closed-string operators. If we consider now a closed path, , and we use algorithm 1 to find a closedstring operator, we will not find in general a positive-chirality nor a negative-chirality string, but some mixing of both. Physically, this is caused by the fact that for a closed string there is no difference in the pattern of plaquette violations between positive-and negative-chirality strings, since there are no endpoints. From equation (C41) we can see that starting from a positive-chirality string, S  + , it is possible to add S z operators forming a loop which cannot be expressed as the product of vertex operators (which we call a non trivial loop in the remainder of the section) to the linear superposition. Once this is done, the resulting operator, S  , does not have a welldefined chirality. Remember, that for an open string, we may obtain the negative-chirality string by multiplying it by an open string S z , violating the plaquettes at the endpoints. For closed strings we may proceed analogously to obtain the opposite chirality by multiplying by a non-trivial closed string S z ¢ . Since we are multiplying S  + by a linear combination of trivial and non-trivial loops of S z , the chirality of S  is no longer positive nor negative. Thus, we drop the '+' superscript in S  . The mixing of chiralities becomes apparent when computing the commutator between a closed string, S  , and a positive-chirality open string, S  + , where paths  and  cross once (see figure C5):