Towards local testability for quantum coding

We introduce the hemicubic codes, a family of quantum codes obtained by associating qubits with the $p$-faces of the $n$-cube (for $n>p$) and stabilizer constraints with faces of dimension $(p\pm1)$. The quantum code obtained by identifying antipodal faces of the resulting complex encodes one logical qubit into $N = 2^{n-p-1} \tbinom{n}{p}$ physical qubits and displays local testability with a soundness of $\Omega(1/\log(N))$ beating the current state-of-the-art of $1/\log^{2}(N)$ due to Hastings. We exploit this local testability to devise an efficient decoding algorithm that corrects arbitrary errors of size less than the minimum distance, up to polylog factors. We then extend this code family by considering the quotient of the $n$-cube by arbitrary linear classical codes of length $n$. We establish the parameters of these generalized hemicubic codes. Interestingly, if the soundness of the hemicubic code could be shown to be constant, similarly to the ordinary $n$-cube, then the generalized hemicubic codes could yield quantum locally testable codes of length not exceeding an exponential or even polynomial function of the code dimension.


Quantum LDPC codes, local testability and robustness of entanglement
Entanglement is arguably the central concept of quantum theory and despite decades of study, many questions about it remain unsolved today. One particular mystery is the robustness of phases of highly entangled states, such as the ones involved in quantum computation. Given such a state, does it remain entangled in the presence of noise? A closely related question concerns low-energy states of local Hamiltonians: while ground states, i.e., states of minimal energy, are often highly entangled, is it also the case of higher energy states? These questions are related through the concept of quantum error correction: logical information is often encoded in a quantum error correcting code (QECC) in order to be processed during a quantum computation, and the ground space of a local Hamiltonian is nothing but a special case of a QECC called quantum low-density parity-check (LDPC) code.
Physically it indeed makes sense to implement quantum error correction by relying on local interaction, for example by encoding the quantum state in the degenerate ground space of a local Hamiltonian, that is an N -qubit operator H ∝ i Π i , where each Π i is a projector acting nontrivially on a small number q of qubits (we talk of q-local terms). By "small", one usually means constant or sometimes logarithmic in N . A quantum stabilizer code is a subspace of the space (C 2 ) ⊗N of N qubits defined as the common +1 eigenspace of a set {S 1 , . . . , S m } of commuting Pauli operators, that is, the space Such a code is said to be LDPC if all the generators S i act nontrivially on at most q qubits for small q. With this language, a quantum LDPC stabilizer code corresponds to the ground space of the local Hamiltonian H = 1 . Entanglement can be quantified in many ways, but a relevant definition is to say that a quantum state is highly entangled (or displays long-range entanglement) if it cannot be obtained by processing an initial product state via a quantum circuit U circ of constant depth. By contrast, a quantum state that can be obtained that way, and which is therefore of the form U circ ⊗ n i=1 |φ i for some |φ i ∈ C 2 , is said to be trivial. An important property of trivial states is that one can efficiently compute the value of local observables such as Π i for such states: this is because the operator U † circ Π i U circ remains local (since the circuit has constant depth) and its expectation can therefore be computed efficiently for a product state. In particular, such a classical description can serve as a witness that a local Hamiltonian admits a trivial state of low energy. It is well known how to construct N -qubit Hamiltonians with highly entangled ground states, for instance by considering a Hamiltonian associated with a quantum LDPC code with non-constant minimum distance [11], but the question of the existence of local Hamiltonians such that low-energy states are nontrivial remains poorly understood.
The no low-energy trivial state (NLTS) conjecture asks whether there exists a local Hamiltonian such that all states of small enough (normalized) energy are nontrivial [24]. More precisely, is there some H = 1 m m i=1 Π i as above, such that there exists a constant α > 0 such that all states ρ satisfying tr(ρH) ≤ α are nontrivial? What is interesting with the NLTS conjecture is that it is a consequence of the quantum PCP conjecture [2], and therefore corresponds to a possible milestone on the route towards establishing the quantum PCP conjecture. We note that there are several versions of the quantum PCP conjecture in the literature, corresponding to the quantum generalizations of equivalent versions of the classical PCP theorem, but not known to be equivalent in the quantum case, and that the multiprover version was recently established [31]. Here, however, we are concerned with the Hamiltonian version of the quantum PCP which still remains wide open. This conjecture is concerned with the complexity of the Local Hamiltonian problem: given a local Hamiltonian as before, two numbers a < b and the promise that the minimum eigenvalue of the Hamiltonian is either less than a, or greater than b, decide which is the case. The quantum PCP conjecture asserts that this problem is QMA-hard when the gap b − a is constant. This generalizes the PCP theorem that says that the satisfiability problem is NP-hard when the relative gap is constant [14]. Here, QMA is the class of languages generalizing NP (more precisely generalizing MA), where the witness can be a quantum state and the verifier is allowed to use a quantum computer. Assuming that NP ⊆ QMA, we see that Hamiltonians with trivial states of low energy cannot be used to prove the quantum PCP conjecture since the classical description of such states would be a witness that could be checked efficiently by a classical verifier. In other words, if the quantum PCP conjecture is true, it implies that NLTS holds. The converse statement is unknown.
Eldar and Harrow made progress towards the NLTS conjecture by establishing a simpler variant, called NLETS [18], by giving an explicit local Hamiltonian where states close to ground states are shown to be nontrivial. (See also Ref. [32] for an alternate proof exploiting approximate low-weight check codes.) The subtlety here is that closeness isn't defined as "low energy" as in NLTS, but by the existence of a low weight operator mapping the state to a ground state. Viewing the ground space as a quantum LDPC code, [18] shows that states which are δN -close to the code (for some sufficiently small δ > 0) are nontrivial. The NLTS conjecture asks for something stronger: that all states with energy less than a small, constant, fraction of the operator norm of the Hamiltonian are nontrivial. Of course, states close to the codespace have a low (normalized) energy or syndrome weight since each qubit is only involved in a small number of generators, but the converse does not hold in general, and this is what makes the NLTS conjecture difficult to tackle.
One case where the distance to the code is tightly related to the syndrome weight is for locally testable codes (LTC): classical locally testable codes are codes for which one can efficiently decide, with high probability, whether a given word belongs to the code or is far from it, where efficiency is quantified in the number of queries to the coordinates of the word. To see the link between the two notions, the idea is to distinguish between codewords and words far from the code by computing a few elements of the syndrome and deciding that the word belongs to the code if all these elements are zero. An LTC is such that any word at constant relative distance from the code will have a constant fraction of unsatisfied checknodes, that is a syndrome of weight linear in the blocklength. The Hadamard code which maps a k-bit word x to a string of length 2 k corresponding to the evaluations at x of all linear functions provides such an example with the syndrome corresponding to all possible linearity tests between the bits of the word: indeed, any word that satisfies most linearity tests can be shown to be close to the codespace [8].
While LTCs have been extensively studied in the classical literature [22] and provide a crucial ingredient for the proof of the classical PCP theorem, their quantum generalization is relatively new and much less understood. The concept was only recently introduced in a paper by Aharonov and Eldar [1] which showed that the classical approaches to local testability seem to fail in the quantum world: for instance, defining a code on a (hyper)graph with too much expansion seems to be a bad idea. In any case, if quantum LTC with constant minimum distance existed, they would provide a proof of the NLTS conjecture [18], and this motivates trying to understand whether such codes can exist. Let us, however, mention that while classical LTCs are useful in Dinur's combinatorial proof of the classical PCP theorem [14], the same doesn't seem to apply in the quantum regime since it is known that directly quantizing Dinur's combinatorial proof of the PCP theorem is bound to fail [2,10].
An additional difficulty in the quantum case is that good quantum LDPC codes are not even known to exist. While taking a random LDPC code yields a code with linear minimum distance with high probability in the classical case, the same statement is not known to hold in the quantum setting. Even restricting our attention to codes only encoding a constant number of logical qubits, it was surprisingly hard until very recently to find families of codes with minimum distance much larger than √ N : a construction due to Freedman, Meyer and Luo gives a minimum distance Θ(N 1/2 log 1/4 N ) [21] while recent constructions based on high-dimensional expanders yield a polylogarithmic improvement [19,27,28]. (Note that considering subsystem codes [34] or approximate codes [7,13] is helpful to get a large minimum distance [5,9,32].) In 2020, new constructions managed to significantly beat this √ N barrier: the fiber bundle codes achieve N 3/5 , up to polylogarithmic factors [26], and the lifted product codes almost achieve linear minimum distance [33]. For these reasons, while a lot of work on classical LTC is focused on codes with linear minimum distance and aims at minimizing the length of the code, the current goals in the quantum case are much more modest at this point.
A possible formal definition of a quantum LTC was suggested by [18], which we detail now. Recall that the objective is to relate two notions: the distance of a state to the code, and the energy of the state. A quantum code, or equivalently, its associated Hamiltonian, will be locally testable if any word at distance t from the code (or the ground space) has energy Ω(t) and if this energy can be estimated by accessing only a small number of qubits (this is why we insist on having local terms in the Hamiltonian). First, one defines a quantum version of the Hamming distance as follows. Consider the code space C ⊂ (C 2 ) ⊗N and define its t-fattening C t as the span of states at distance at most t from C: where the A i are single-qubit Pauli matrices. States at distance t belong to C t , but not to C t−1 , which we formalize by considering the projector Π Ct onto C t and forming the distance operator Informally, the eigenspace of D C with eigenvalue t corresponds to states which are at distance t from the code. We now define the averaged normalized Hamiltonian H C associated with the quantum code C with q-local projections (Π 1 , . . . , Π m ): The normalization by m ensures that H C ≤ 1. With these notations, we say that a q-local quantum code C ⊆ (C 2 ) ⊗n is an (s, q)-quantum LTC with soundness s where A B means that the operator A − B is positive semidefinite. In words, condition (1) means that any low-energy state is close to the codespace in terms of the quantum Hamming distance, and that simple energy tests allow one to distinguish codewords from states far from the code. More precisely, one can distinguish between a codeword (with energy 0) and a state at distance δN from the code (therefore with energy ≥ sδ) by measuring approximately 1/(sδ) terms of the Hamiltonian. Ideally, one would want the soundness s and the locality q to be constant, so that accessing a constant number of qubits would suffice to distinguish codewords from states at distance greater than δN from the code, for constant δ > 0. Known constructions of quantum LTC are rare. For instance, quantum expander codes almost yield one example of (s, q)-quantum LTC with both s = O(1), q = O(1), but with the major caveat that Eq. (1) doesn't hold in general, but only on the restriction of the Hilbert space consisting of states O( √ N )-close to the codespace [30]. In fact, there exist states at distance Ω( √ N ) violating only a single projection Π i . This means in order for Eqn. (1) to hold, one actually needs to take s = O(1/ √ n). Thus, quantum expander codes cannot be used to establish the NLTS conjecture. By allowing the locality to be logarithmic in the number of qubits instead of constant, that is q = O(log N ), a recent construction of Hastings [25] yields a quantum LTC with soundness s = O 1 log 2 N , without any restriction on the validity of Eq. (1). The construction is a generalization of the toric code where instead of taking the product of two 1-cycles of length p, one rather considers the product of two d-cycles of area p d for the appropriate values of p = ω(1) and d = ω(1).
Our results. In this work, we present a different construction of quantum LTC which shares with Hastings' the property that it is set in a high-dimensional space with d = Θ(log N ) and therefore a similar locality 3 q = Θ(log N ). Our code, however, achieves a slightly better soundness r = Ω 1 log N , and in fact, we were not able to rule out that the soundness isn't constant, which would be optimal. While this hemicube code only encodes a single logical qubit, we can introduce a generalized family of codes with polynomial rate. These codes are obtained starting with the chain complex associated to the n-dimensional Hamming cube, where we identify faces corresponding to the same coset of a classical code of length n. A CSS quantum code is obtained by placing qubits on the p-faces and stabilizers either on (p − 1)-faces or (p + 1)-faces, with constraints given by the incidence relations between the faces in the cube. While this construction is arguably quite natural, computing the parameters (dimension and minimum distance) of this code family turned out to be rather subtle, relying in nontrivial arguments from algebraic topology.

Construction of the hemicubic code
We start with the simplest member of our quantum code family, corresponding to the quotient of the n-cube by the repetition code. It has been known since Kitaev [29] that one can associate a quantum CSS code with any chain complex of binary vector spaces of the form: C 2 where the boundary operators ∂ 2 and ∂ 1 satisfy ∂ 1 ∂ 2 = 0. One first defines two classical codes C X = ker ∂ 1 and C Z = (Im ∂ 2 ) ⊥ = ker ∂ T 2 . These codes satisfy C ⊥ Z ⊆ C X since ∂ 1 ∂ 2 = 0 and the resulting quantum CSS code is the linear span of is the canonical basis of (C 2 ) ⊗N and N is the dimension of the central space C 1 of the chain complex. One obtains in this way a quantum code of length N and dimension dim( Here, |w| stands for the Hamming weight of the word w.
Our construction relies on the n-dimensional hemicube, where a p-face is formed by a pair of antipodal p-dimensional faces of the Hamming cube {0, 1} n . A p-face of the Hamming cube is a string of n-elements from {0, 1, * } where symbol * appears exactly p times. Let us denote by C n p the F 2 -vector space spanned by p-faces of the hemicube.
Boundary ∂ p and coboundary δ p operators are obtained by extending the natural operators for the Hamming cube to the hemicube and are further extended to p-chains by linearity. We reserve the notation + for the standard notation in F 2 and use ⊕ for summing chains. The hemicubic code is then defined as the CSS code obtained from the chain complex Choosing p = αn for 0 < α < 1, the resulting code will be LDPC with generators of logarithmic weight since the boundary and coboundary operators act nontrivially on O(n) = O(log N ) coordinates. The dimension of the hemicubic code corresponds to that of the homology groups H n p = ker ∂ p Im ∂ p+1 . Since the hemicube, viewed as a cellular complex, has the same topology as the real projective plane, its homology groups all have the same dimension equal to 1. We note that the quantum code obtained here can be described with a completely different approach exploiting Khovanov homology [3]. Obtaining the minimum distance of the code requires more care since one needs to find lower bounds on the weight of minimal nontrivial cycles and cocycles in the hemicube. Summarizing, we establish the following result.

Local testability of the hemicubic code
We now turn our attention to the local testability of the hemicubic code. This property results from isoperimetric bounds on the hemicube. This improves over Hastings' construction [25] obtained by taking the product of two n-spheres and which displays soundness s = Θ log −2 (N ) . It would be interesting to understand whether the bounds of Theorem 2 are tight or not. At the moment, we believe it might be possible to get rid of the logarithmic factor and obtain a constant soundness for the hemicubic code. This would then match the soundness of the standard (not projective) Hamming cube, which does not encode any logical qubit since its associated complex has zero homology.
We say that a p-chain X is a filling of Y if ∂X = Y and that a p-cochain X is a cofilling of Y if δX = Y . The main tools to establish the soundness of the hemicubic code are upper bounds on the size of fillings (resp. cofillings) for boundaries (resp. coboundaries) in the cube. Denoting the Hamming weight of chains and cochains by , we have: Then there exists a p-chain F which is a filling of ∂E, satisfying ∂F = ∂E such that Let E be a p-cochain of C n p . Then there exists a p-cochain F which is a cofilling of δE, satisfying δF = δE such that It is straightforward to translate these results in the language of quantum codes. Let us represent an arbitrary Pauli error of the form i∈E X ,j∈E Z where E X is the support of the X-type errors and E Z is the support of the Z-type error.
Interpreting E X as a p-chain and E Z as a p-cochain, we see that the syndrome of E is given by the pair (∂E X , δE Z ). In order to compute the soundness of the quantum code, one needs to lower bound the ratio: where the minimum is computed over all errors with a nonzero syndrome, i.e., for pchains E X which are not a p-cycle and p-cochains E Z which are not a p-cocycle. In these expressions, we denote by [E] the representative of the equivalence class of error E, with the smallest weight. Indeed, recall that two errors differing by a element of the stabilizer group are equivalent. The fact that one considers [E] instead of E makes the analysis significantly subtler in the quantum case than in the classical case. A solution is to work backward (as was also done by Dotterrer in the case of the Hamming cube [16]): start with a syndrome and find a small weight error giving rise to this syndrome. This is essentially how we establish Lemma 3: This implies the soundness in Theorem 2 since n − p, p + 1 = Θ(log N ). While Dotterrer established tight bounds for the size of (co)fillings in the Hamming cube, we don't know whether the bounds of Lemma 3 are tight. Right now, we lose a logarithmic factor in the case of the hemicube, but it is not clear that this should be the case. In fact, it is not even excluded that the hemicube could display a better soundness than the standard cube. We expand on these ideas in Section 5.

An efficient decoding algorithm for the hemicubic code
The existence of the small fillings and cofillings promised by the soundness of the code is particularly interesting in the context of decoding since it guarantees the existence of a low-weight error associated to any low-weight syndrome. To turn this into an efficient decoding algorithm, the main idea is to notice that one can efficiently find the required fillings and cofilings and therefore find Pauli errors giving the observed syndrome. While finding the smallest possible fillings or cofillings does not appear to be easy, finding ones satisfying the bounds of Lemma 3 can be done efficiently.
We note, however, that the decoding algorithm does not seem to perform so well against random errors of linear weight. In particular, arguments from percolation theory that would imply that errors tend to only form small clusters and that therefore it is sufficient to correct these errors (similarly to [20] for instance) will likely fail here because of the logarithmic weight of the generators. Indeed, the factor graph of the code has logarithmic degree and there does not exist a constant threshold for the error probability such that below this threshold, errors appear in clusters of size o(N ). In addition, and more importantly, our decoding algorithm isn't local in the sense that it explores only the neighborhood of some violated constraints to take a local decision, and for this reason, it is not entirely clear whether the algorithm processes disconnected clusters of errors independently. The decoding complexity is quasilinear in the error size and the algorithm can be parallelized to run in logarithmic depth. Finding a filling (or cofilling) can be done recursively by fixing one of the n coordinates and finding fillings in the projective cube of dimension n − 1. While the choice of the special coordinate is not immediately obvious if one wants to find the smallest filling, it is nevertheless possible to make a reasonably good choice efficiently by computing upper bounds on the final filling size for each possible choice of coordinate. We establish Theorem 4 in Section 6.

Generalized hemicubic codes: quotients by arbitrary linear codes
A key remark is that identifying antipodal p-faces of the n-cube is equivalent to considering the cosets of the repetition code {0 n , 1 n } in the cube complex. It is therefore tempting to generalize this approach by identifying the elements of the cosets of arbitrary linear codes C with parameters [n, k, d]. We form in this way a new complex where two p-faces x and y are identified if there exists a codeword c ∈ C such that x = y + c. Recall that addition is coordinate-wise here and that * is an absorbing element.
Deriving the parameters of the quantum CSS code associated to these new complexes has been surprisingly challenging. In particular it does not seem particularly obvious that the quantum parameters, especially the minimum distance, should depend only on the parameters [n, k, d] of the classical code C and not otherwise on its particular structure: it turns out indeed to be the case however. We managed to derive the quantum parameters by exhibiting explicit representatives of the F 2 -homology and cohomology classes, through a double induction on p and the classical code dimension k. We obtain a lower bound on the minimum homologically nontrivial cycle weight by exhibiting a set of representatives of a cohomology class all of which must be orthogonal to the cycle, and in particular intersect it. Since a nontrivial cycle meets this bound it is exact. A similar method is used to derive the minimum nontrivial cocycle weight and we obtain the following theorem. An interesting case is k = 2, which yields a quantum code of exponential length (that is, dimension logarithmic in the code length): We are only able to prove a lower bound on the soundness of the code (for X-errors) of Ω(1/p!). However, a much improved soundness would follow from the conjectured filling and cofilling constants of the original hemicubic complex: generalized hemicubic codes are therefore candidates for quantum locally testable codes of growing dimension, of which no examples are presently known.

Discussion and open questions
In this paper, we have introduced a family of quantum code constructions that live on the quotient of the n-dimensional Hamming cube by classical linear codes. Despite the apparent simplicity of the construction, it does not seem to have appeared before in the literature. Deriving the parameters of these codes turned out to be significantly subtler than expected, and quite surprisingly, the parameters of the quantum code only depend on the parameters of the classical code and not any on additional structure. The simplest member of our quantum code family, the hemicubic code, basically inherits its local testability from the soundness of the Hamming cube, which was established by Dotterrer. In our view, the fact that our code construction relies so much on the Hamming cube may be expected to yield additional advantages, through the import of other interesting properties from the cube, as well as tools from Boolean analysis.
The most pressing question is to understand whether the generalized hemicubic codes also display local testability. At the moment, we can only establish it for the simplest member of the family, which only encodes a single logical qubit. If we could show that the codes corresponding to the quotient of the Hamming cube by arbitrary linear codes of dimension k remain locally testable, then this would provide the first examples of quantum locally testable codes of exponential (if k > 1) or polynomial (if k = Ω(n)) length. As we discuss in Section 5, improving our bound on the soundness of the one-qubit hemicubic code from 1 log N to constant would already prove that the generalized code with k = 2 remains locally testable. An indication that such an improvement might be possible comes from the 0-qubit code defined on the standard hypercube (without identifying antipodal faces) which indeed displays constant soundness [15]. More generally, the question of what parameters are achievable for quantum locally testable codes is essentially completely open at the moment.
Another intriguing question is whether the hemicubic code might help towards establishing the NLTS conjecture (albeit with a quasilocal Hamiltonian with terms of logarithmic weight) or more generally whether it is relevant for many-body physics. As mentioned, any quantum LTC with linear minimum distance would yield such a proof [18]. The hemicubic code, however, is restricted by a O( √ N ) minimum distance, and the argument of [18] doesn't directly apply anymore. This is in particular a line of research followed by Eldar which relies on the hemicubic code and which provides positive partial results [17]. We note that in the physics context of the Local Hamiltonian, it is crucial that every individual quantum system (say, qubit) is acted upon by a small number of terms. In this sense, the problem is somewhat more constrained than in the classical local testability case where one is typically fine if the number of constraints is much larger than the number of qubits. Our quantum codes satisfy this requirement since each qubit is only involved in a logarithmic number of local constraints.
Finally, while classical LTCs have found a number of applications in recent years, notably for constructing PCPs, it is fair to say that not much is presently known about possible applications of quantum LTCs. At the same time, local testability is a notion that makes perfect sense in the quantum regime and it seems reasonable to think that quantum LTCs might also find applications. Finding explicit families encoding a nonconstant number of qubits is a natural first step.

Outline of the manuscript
In Section 2, we introduce the main notions of algebraic topology needed for the description of our codes and review the notion of local testability both in the classical and the quantum settings. In Section 3, we describe the construction of the one-qubit hemicubic code corresponding to the quotient of the n-cube by the repetition code and derive its parameters. We consider the general case of quotients by arbitrary linear codes in Section 4. In Section 5, we establish the local testability of the hemicubic code. Finally, in Section 6, we exploit the local testability of the code to devise an efficient decoding algorithm that runs in quasilinear time, and that can be parallelized to logarithmic depth.

Notions of algebraic topology
We introduce here the notion of chain complex as well as the Long Exact Sequence theorem that will be a crucial tool to study the dimension of the quantum codes we will consider in Section 4.
Possible references for this section are [38] §1.3 p. 10 and [35] Theorem 6.10 p. 333. A very general definition of a chain complex is the following:

Definition 6.
A chain complex C • is a sequence of vector spaces (C p ) p∈Z and of linear maps (∂ p : C p → C p−1 ) p∈Z called differentials such that the composition of any two successive differentials is zero: We will limit ourselves to the case when the vector spaces C p are finite-dimensional vector spaces over the binary field F 2 of the form F Xp 2 for X p some finite set. Elements of X p are called p-cells and elements of C p are called p-chains. Our chain complexes will also be bounded, meaning that only a finite number of spaces C p will be non-zero.
Elements of ker ∂ p are called cycles and elements of Im(∂ p+1 ) are called boundaries. Every boundary is a cycle but the converse is not necessarily true. Homology groups give information about this phenomenon.
One also defines coboundary operators: The p th cohomology group is given by H p = ker δ p /Imδ p−1 . A standard fact is that the p th homology and cohomology groups are isomorphic. Their dimension is called the p th Betti number of the chain complex.
The following definition and theorem will be used in Section 4.

Definition 8.
A chain map f from the chain complex C • to the chain complex D • is a sequence of morphisms f p : C p → D p such that for all p ∈ Z, f p−1 ∂ p = ∂ p f p . By abuse of notation we use the same symbol ∂ p to refer to the distinct differentials ∂ p : is called a short exact sequence, and other exact sequences are traditionally called long.
chain complexes induces the following long exact sequence of homology groups: We refer to [38] or [35] for a proof. However we will make more explicit the induced morphism The homology group morphism It is well defined because f p takes cycles to cycles and boundaries to boundaries. To avoid confusion we will sometimes denote the chain group morphism by f chain,p and the homology group morphism by f hom,p .
We leave it to the reader to prove that a p−1 is a cycle, that its class and that the connecting map actually is a morphism. To avoid confusion we will sometimes denote the chain group differential by ∂ chain,p and the connecting homology group morphism by ∂ hom,p .
In the present work, we will form a chain complex associated with the n-dimensional Hamming cube or with quotients of this cube by linear codes, and the space C p will be the F 2 -space spanned by p-faces of the resulting cube.

CSS codes
A quantum code encoding k logical qubits into N physical qubits is a subspace of (C 2 ) ⊗N of dimension 2 k . A simple way to define such a subspace is via a stabilizer group, that is an abelian group of N -qubit operators (tensor products of single-Pauli operators X = ( 0 1 1 0 ), Z = 1 0 0 −1 , Y = ZX and 1 with an overall phase ±1 or ±i) that does not contain −1. A stabilizer code is then defined as the eigenspace of the stabilizer with eigenvalue +1 [23]. A stabilizer code of dimension k can be described by a set of N −k independent generators of its stabilizer group. Note, however, that in the context of locally testable codes, it will be natural to consider larger sets of generators, to allow for some extra-redundancy. The minimum distance d min of a quantum code is the minimum weight of a nontrivial logical operator, that is an operator that commutes with all the elements of the stabilizer, but does not belong to the stabilizer. A quantum code of length N encoding k qubits with minimum distance d min is denoted N, k, d min .
CSS codes are a special case of stabilizer codes where the generators are either products of Pauli-X and I, or products of Pauli-Z and I [12,36,37]. These families are easier to study because the commutation relations required to make the stabilizer abelian simply need to be checked between X-type and Z-type generators. In particular, such quantum codes can be described by a pair of classical codes.

Definition 10 (CSS code). A quantum CSS code with parameters
The dimension of the code is given by dim( Here, |w| stands for the Hamming weight of the word w. Quantum LDPC codes are stabilizer codes coming with a list of low-weight generators. For instance, a CSS code CSS(C X , C Z ) is said to be LDPC if both C X and C Z are given with sparse parity-check matrices. Here sparse means that the weight of each row (or equivalently the weight of the corresponding generator) is constant or logarithmic in the length N . These codes are particularly interesting because low-weight constraints are more realistic in terms of implementation. Moreover, one can exploit this sparsity to design efficient decoders.
gives rise to a CSS code by considering the classical codes C X = ker ∂ p and C Z = (Im ∂ p+1 ) ⊥ . Indeed, the condition Im ∂ p+1 ⊆ ker ∂ p immediately implies that C ⊥ Z ⊆ C X . In that case, the dimension of the quantum code is simply the p th Betti number of the chain complex.
It will also be convenient to introduce the parity-check matrices H X and H Z of the classical codes C X and C Z , so that C X = ker H X and C Z = ker H Z . With the correspondance between chain complexes and CSS codes outlined above, we get and they satisfy H X · H T Z = 0. An error pattern is defined as a couple (e X , e Z ) where e X and e Z are both binary vectors. The syndrome associated to this error consists in fact of a couple of syndromes A decoder for the code CSS(C X , C Z ) is given the pair (σ X , σ Z ) and decoding succeeds if it outputs a couple of error candidates of the form The presence of (f X , f Z ) is a crucial difference with the classical setting and results from the fact that the associated operators act trivially on the codespace. It will be useful to keep in mind that the boundary and coboundary operators ∂ p and δ p are nothing but the syndrome functions for the associated quantum code.

Local testability
Let us first quickly review the notion of local testability in the classical setting. In this case, the distance dist(w, C) of a word w ∈ F n 2 of a word to a classical code C is defined as expected by: where |x| is the Hamming weight of x, that is the number of non-zero bits of x.
is said to be a (q, s)locally testable code with soundness s > 0 if the rows of H have weight at most q and if holds for any word w ∈ F N 2 . Here, Hw is the syndrome of the word w and dist(w, C) is the distance from w to C, that is, the minimal Hamming distance between w and a codeword c ∈ C.
This definition gives rise to a simple test to distinguish between a codeword and a word at distance at least δN from the code: one simply picks 1/(sδ) rows of the paritycheck matrix uniformly at random and measures the associated 1/(sδ) bits. If the word w is δN away from the code, then Eq. (2) implies that |Hw| m ≥ sδ and therefore testing O( 1 sδ ) random constraints will be sufficient to detect it with high probability. The quantity 1/(sδ) is therefore referred to as query complexity of the code: this is the number of bits from w that should be queried to decide whether w is in the code or far from it.
We see that the defining property of an LTC, and more specifically of its parity-check matrix, is that the weight of the syndrome of a word (akin to its "energy") is lowerbounded by a function of its distance to the code. In particular, we want to avoid errors of large weight with a small syndrome. Many constructions of classical LTC are known, for instance the Hadamard code and the long code. Classically, one important open question concerns the existence of short LTCs which display linear minimum distance, constant soundness and constant rate.
The study of quantum locally testable codes (qLTC) was initiated by Aharonov and Eldar with the motivation that such objects could prove useful in order to attack the quantum PCP conjecture [1]. While defining local testability for general quantum codes appears rather involved, the situation is much nicer for stabilizer codes. The definition is then analogous to the classical case, with the difference that the functions "energy": w → 1 m |Hw| and "distance": w → dist(w, C) need be replaced by Hermitian operators. The quantum observable corresponding to the energy is the Hamiltonian operator. Let C be a stabilizer code with a set of m q-local generators (S 1 , . . . , S m ) of the stabilizer group, meaning that One first forms m projectors Π i = 1 2 (1−S i ) so that the codespace becomes the 0 eigenspace of i Π i . Note that the generators S i of the stabilizer group are products of Pauli operators and therefore admit a spectrum spec(S i ) = {−1, +1}.
The (normalized) Hamiltonian H C associated with the code is defined as This is the straightforward generalization of the notion of syndrome weight to the quantum case. Defining the distance to the code requires more care, however, in the quantum setting. We follow the approach from Ref. [18]. The idea is to define a set of N + 1 subspaces such that C t corresponds to the space of states at distance t from the code. More precisely, C t is the t-fattening of C: which we denote by dist(|ψ , C) ≥ t. We finally define the operator D C that "measures" the distance to the code as In particular, a state is at distance exactly t from the code C if it is an eigenstate of the operator D C with eigenvalue t.
With these notations, we are ready to define the notion of locally testable code in the quantum case.
If C is a (q, s)-LTC, the following lower bound holds: where we optimize over all states at distance at least δN from the code.
Similarly to the classical case, the query complexity of the quantum LTC is given by 1 sδ since it is sufficient to measure this number of qubits to distinguish between a codeword and a state at distance at least δN from the code. In order to prove that a CSS code is LTC, it is sufficient to show that both classical codes C X , C Z are LTC (see [1]).

Lemma 13.
Let C X and C Z be classical (q, s)-locally testable codes with m X and m Z parity-checks, respectively. Then the quantum code CSS( The idea is to consider a common eigenbasis of H C and D C and to prove that Eqn. (3) holds for this basis. One starts with dim(C X /C ⊥ Z ) elements of the form z∈C ⊥ Z |x+ z for x ∈ C X . These are codewords and belong to C 0 = C. Then one completes this family by applying to these states bit-flip errors and phase-flip errors characterized by binary vectors e X , e Z ∈ F N 2 , to get states |ψ e X ,e Z of the form z∈C ⊥ Z (−1) e Z ·(x+e X +z) T |x+e X +z . Alternatively, one can obtain this state by applying the Pauli operator where X i and Z i are the Pauli-X and Pauli-Z operators ( 0 1 1 0 ) and 1 0 0 −1 applied to the i th qubit.
Such a state |ψ e X ,e Z belongs to the eigenspace of H C corresponding to energy 1 m (|H X e X |+ |H Z e Z |), and more precisely to the subspace of states with syndrome (σ X , σ Z ) = (H X e X , H Z e Z ). Note that the states |ψ e X ,e Z define a complete basis of eigenstates of H C . The state also has full support on some C t \ C t−1 for some t that depends on (e X , e Z ). An easy upper bound for t is given by that is, the distance from the state to the code is upper-bounded by the sum of the distance from e X to C x and the distance from e Z to C Z . This is because |ψ e X ,e Z and |ψ e X +c X ,e Z +c Z = X c X Z c Z |ψ e X ,e Z are at the same distance for the quantum code.
Assume now that both C X and C Z are (q, s)-locally testable, then by definition, it holds that where m X and m Z are the number of parity-checks for C X and C Z , respectively, and m = m X + m Z . The energy of |ψ e X ,e Z satisfies: which was to be proven.

The hemicubic code
In this section, we will consider the simplest member of our code family, corresponding to the quotient of the n-cube by the repetition code. Quotients by arbitrary linear codes will be studied in detail in Section 4.

The construction
Let Q n = {0, 1} n be the Hamming cube for n ≥ 2. For p ∈ [n], a p-face (or p-cell) x of Q n in an element of {0, 1, * } n with exactly p indeterminates, denoted with stars, |x| * = p. Let Q n p be the set of the p-faces in the cube. Its cardinality is |Q n p | = 2 n−p n p . We also define the space of p-chains of the cube to be the F 2 -vector space spanned by the p-faces of the cube. We note that the symbols 0 and 1 can appear either as scalars of F 2 or as letters of p-faces. In the text, there shouldn't be any ambiguity between these different uses. We also note that we alternatively use the set notation or chain notation to describe a chain: for instance {00 * * , 0 * 0 * } and 00 * * ⊕ 0 * 0 * represent the same object. We reserve the notation + for the standard addition in F 2 or F n 2 and use ⊕ for summing chains. Boundary ∂ p and coboundary δ p operators can be defined in the usual way for p-faces of the cube: and extended to arbitrary p-chains by linearity.
The hemicube is formed by considering equivalence classes (of p-faces) of Q n for the equivalence relation between p-faces defined as where addition between 0-faces and p-faces is defined pointwise with the convention 0+ * = 1 + * = * .
Let C n p be the F 2 -vector space spanned by p-faces of the hemicube, that is with the identification ∼. Formally, a p-face of the hemicube (Hamming cube with the identification ∼) is a pair of elements {x,x}, but we will often abuse notation and denote it by either x orx when there is no ambiguity. An element of C n p is called a p-chain of the hemicube. The boundary operator ∂ p defined for p-faces can be extended to C n p because it commutes with the + 1 . . . 1 relation that defines elements of C n p : One obtains the following chain complex: where we will often write ∂ instead of ∂ p for simplicity. One can then form the homology groups H n p = ker ∂ p /Im ∂ p+1 . Since the hemicube, viewed as a cellular complex, has the same topology as the real projective plane, its homology groups have the same dimension.  Proof. Topologically, the Hamming cube is equivalent to the n-sphere, and Q n /∼ is equivalent to the projective space RP n . The claim follows from the F 2 homology of RP n : H p (RP n , F 2 ) = F 2 .
We will give a more general proof of this fact in Section 4 where we address the general case of quotients of the cube by arbitrary linear codes.
We denote the associated CSS code by Q n p and the following theorem gives its parameters: We note that the quantum code obtained here can be described with a completely different approach exploiting Khovanov homology [3].
Proof. The length of the code is simply the length of C X , that is the dimension of C n p , which is half the cardinality of Q n p . The number of p-cells in Q n p is the number of choices of p positions for the stars in a string of length n, times 2 n−p possible bit-strings for the remaining coordinates. This yields the result.
Computing the minimum distance is less easy: in Lemma 19, we give explicit representatives of the p th homology and cohomology groups, yielding in particular n p disjoint cohomologically nontrivial cocycles. We argue in addition that any homologically nontrivial cycle necessarily meets all these nontrivial cocycles and is therefore of weight at least n p . A somewhat similar argument shows that the weight of nontrivial cocycle is at least 2 n−p−1 , thus completing the proof.
Let us start by constructing p-cycles, that we will denote by n p recursively. We describe the cycles by giving representative in the original cube complex. We start by defining n 1 and n n : where n 1 is a 1-cycle while n n is only defined formally (since there are no n-cells in the n-dimensional hemicube). For p ≤ n, we further define where 1+(−1) p+1 2 is either 0 or 1 depending on the parity of p, Sα is the chain obtained by concatenating α ∈ {0, 1, * } at the end of each face of the chain S. Lemma 16. The p-chain n p is a representative of a p-cycle of weight n p in the hemicube.
For a set S ∈ Q n p , we define S to be the set obtained by exchanging 0 and 1 in every element of S. In particular, the projections of S and S are identical in the hemicube.
Proof. Let us prove by induction that The base cases ∂ n 1 and ∂ n n are easily verified: where we formally defined n 0 := 00 . . . 0. And Let us establish the induction step: The identification of n p−1 and n p−1 shows that that ∂ n p = 0 in the hemicube, and therefore that n p represents a cycle. In order to compute its cardinality, we also proceed by induction: the base cases are immediate and the induction step follows from the formula for the binomial coefficient: n p = n p−1 + n−1 p−1 .

Lemma 17. The p-chain n p can alternatively be described as the sum of p-faces represented by strings of length n, with all n p possible positions for the p stars, and with the remaining indices filled with 0 and 1 as follows: a 0 when there is an even number of stars on its left and a 1 when there is an odd number of stars on its left.
For instance, we have Proof. The proof is again by induction on n and p: the base cases n 1 and n n are immediate. For the induction step, it is sufficient to see that Eq. (4) holds for the alternate description of Lem. 17: observe that for every p-face of n p , if the last coordinate is not a star, it takes value 0 if p is even and 1 if p is odd. Since p is the number of stars on the left of the last coordinate, the description of Lem. 17 holds for n p assuming that it holds for n p−1 and n−1 p−1 .
For n = 5 and p = 2, a 2-cycle is represented on Figure 1.
In words, S n p represents all the p-faces of the hemicube parallel to * · · · * 0 . . . 0. By parallel we mean that their p stars are at the same positions. Lemma 18. The set S n p represents a p-cocycle in the hemicube, that is, δ p S n p = 0.
Proof. The coboundary of S n p is the (p + 1)-chain: . . a n−p−1 .
We make the further remark that if a nontrivial cycle were orthogonal to a given nontrivial cocycle, then all nontrivial cycles, and hence all cycles must be also be orthogonal to this given cocycle (because the homology of the hemicube has dimension 1). But the orthogonal space of the cycle space is the space of trivial cocycles, a contradiction. Therefore any nontrivial cycle/nontrivial cocycle pair must consist of non-orthogonal vectors.
To establish that n p is a nontrivial cycle of minimum weight, we find n p nontrivial cocycles with disjoint supports. These are obtained similarly to S n p by placing the p stars in all possible n p positions, instead of the first p coordinates. Since a nontrivial cycle must be non-orthogonal to, and therefore intersect, all of them, this proves that its weight is at least n p . The reasoning is almost similar for the minimum nontrivial cocycle weight (and can be seen as an application of Theorem 2.8 in [4]). For x ∈ {0, 1} n , define T x n p to be the cycle that is the translate of n p by the vector x. This means that T x n p is obtained from n p by replacing every p-face y in n p by y + x. Note that any p-face z belongs to exactly 2 p translates T x n p (all such x may differ only in the star coordinates of z). All translates T x n p are nontrivial cycles since they are not orthogonal to the nontrivial cocycle S n p . Indeed they intersect at exactly one p-face since T x n p contains one p-face for each positions of the p stars and S n p contains all the p-faces that have the p stars in the first p positions. Therefore any nontrivial cocycle must be non-orthogonal to, and in particular intersect, all of them. Since any of its p-faces can belongs to exactly 2 p translates T x n p and since the total number of distinct translates T x n p in the hemicube complex is 2 n−1 , because translating by x or x is equivalent, we get that the weight of any nontrivial cocycle is at least 2 n−p−1 . Since this is the weight of S n p , the bound is tight.
We immediately get the value of the minimum distance.

Corollary 20. The minimum distance of the quantum code corresponding to p-chains in the n-dimensional hemicube is
be the binary entropy function where here and throughout, the logarithm is taken in base 2. Let us define α * ≈ 0.227 to be the unique nonzero solution of h(α * ) = 1 − α * . Then choosing p = α * n yields a quantum code where both minimum distances are approximately equal and satisfy: See [3] for a detailed analysis of the constant in this equation. Specifically, Proposition 5.5 of Ref. [3] shows that one can extract a subfamily of codes with d min ≥ We note that this property is welcome in the physics context of the Local Hamiltonian since the relevant Hamiltonians in Nature should be such that every particle is only acted upon by a reasonably small number of local terms, but that it is much easier to obtain local testability when allowing the number of constraints to be larger than the number of (qu)bits. In fact, such redundancy among constraints is even required to get local testability in the classical case [6].

Quotient by general linear codes
The construction of the quantum code associated with the hemicube can be readily generalized by realizing that identifying antipodal points in the hypercube Q n is in fact equivalent to taking the quotient by a repetition code of length n. It becomes then natural to consider quotients by more general classical linear codes, provided that their minimum distance is large enough (it should be larger than p + 2). In particular, the quotient of the cube by a classical code of dimension k will yield a quantum code of dimension k+p−1 p .

Dimension of a hemicubic code: algebraic proof
The n-hemicube is the quotient of the cube by the antipodal map. We have already stated that since the n-hemicube has the topology of the projective n-space, the quantum code obtained from identifying qubits with p-faces of the n-hemicube has as many logical qubits as the rank of H p (RP n , F 2 ): it has one logical qubit for 1 ≤ p ≤ n − 2. In this section, we give a more algebraic proof of this result using the long exact sequence of §2.1. This proof generalizes to other quotients of the n-cube.
There is a natural projection map from p-faces of the cube to p-faces of the hemicube defined by sending a face f p of the n-cube to its equivalence class f p in the hemicube: For example for n = 3 and p = 0, π p (001) = π p (110) = 001 . It is straightforward to extend π p by linearity to π chain,p from C p (Q n ) to C p (Q n /C r ). For example, π chain,p (000 ⊕ 001 ⊕ 010 ⊕ 111) = 001 ⊕ 010 .
Something confusing in our construction is that on the one hand we take quotients of the cube by classical codes and on the other hand homology classes classes are defined as the quotient of a coarse-grained equivalence class (cycles) by a fine-grained equivalence class (boundaries). To minimize confusion between different quotients, we denote classical codes equivalence classes with the floor symbol: f p and homology classes with brackets: where the chain c is a sum of p-faces: c = f p ⊕ g p for instance.
We also define an injective map from the hemicube to the cube. This map is directly defined at the level of chains: We denote by f p + 1 . . . 1 the translate of f p by the non-zero codeword of the repetition code: 1 . . . 1. For example, i chain,p ( 000 ⊕ 001 ⊕ 010 ) = 000⊕111⊕001⊕110⊕010⊕101.

Lemma 21.
Recall from subsection 2.1 that C • (Q n ) and C • (Q n /C r ) denote the chain complexes of the n-cube and the n-hemicube. i complex and π complex are respectively the collection of maps i chain,p and π chain,p . The sequence of chain complexes is a short exact sequence of chain complexes. Proof.
• i chain,p commutes with the boundary operator ∂.
• i chain,p is injective.
• Im i chain,p = ker π chain,p Theorem 9 associates a long exact sequence of homology groups to this short exact sequence of chain complexes: Since H p (Q n ) = 0 for 1 ≤ p ≤ n, the exact sequence breaks into small pieces: H 0 (Q n /C r ) has dimension 1 since the hemicube is path-connected. By immediate induction, H p (Q n /C r ) has dimension 1 for 1 ≤ p ≤ n − 1.
Therefore the quantum code constructed by identifying qubits with p-faces of the hemicube for 1 ≤ p ≤ n − 1 has dimension 1. This completes the algebraic proof of Theorem 14.
In this subsection, we have deduced the homology groups of the hemicube from the homology groups of the cube. In the next sections, we extend by induction this reasoning to more general quotients.

Long exact sequences for a generalized hemicube
To define a generalized hemicubic code we take the quotient of the cube Q n by a classical code C with parameters [n, k, d] with d ≥ p + 2, thus creating the quotient polytope Q n /C where faces of the cube are identified when they are indexed by n-tuples that differ by a codeword of C. The quantum code is then associated to the polytope in the usual way (qubits correspond to p-faces of the quotient.) Lemma 22. Let C k be an [n, k, d k ] classical code and C k+1 be an [n, k + 1, d k+1 ] classical code such that C k+1 contains C k . For p ≤ d k+1 and p − 1 ≥ 0, the following long sequence of homology groups is exact: For p ≥ 0 and p + 1 ≤ d k+1 , the following long sequence of cohomology groups is exact: Proof. For p ≥ 0, we can construct the following short exact sequence of p-chain vector spaces: where, like in subsection 4.1, π chain,p is the linear extension at the level of chains of the projection of p-faces from Q n /C k to Q n /C k+1 and i chain,p lifts each p-face of a p-chain of C p (Q n /C k+1 ) to the sum of the two corresponding p-faces in C p (Q n /C k ). The subscripts chain, complex, hom and cohom indicate that we are considering the corresponding variants of i and π. Like in subsection 4.1, the sequences (5) for p ≥ 0 define a short exact sequence of chain complexes since i chain,p and π chain,p commute with the boundary operator ∂: The associated long exact sequence of homology groups gives the first part of the result.
The derivation of the long exact sequence of cohomology groups is formally identical. Chains and cochains are canonically identified: they both can be considered as subsets of the set of faces. We define i cochain,p to be equal to i chain,p and π cochain,p to be equal to π chain,p . Since i cochain,p and π cochain,p commute with the coboundary operator δ (the transpose of the boundary operator ∂), we have the following short exact sequence of cochain complexes: The associated long exact sequence of cohomology groups gives the second part of the result.
We highlight the fact that even though i chain,p is the same map as i cochain,p , i hom,p can be (and actually is as we will show later) very different from i cohom,p . Similarly π hom,p is very different from π cohom,p .

Cohomology basis and short exact sequence in cohomology for a generalized hemicube
The long exact sequence of cohomology groups is actually easier to manipulate than its homology counterpart. In this subsection we will define a basis of the cohomology group H p (Q n /C k ) with a prefered representative for each element of the basis. We will see the consequences of this basis for the long exact sequence of cohomology groups.
It will prove useful to denote a cohomology class cohom by one of its representative, i. e. by a cocycle cocyc which is not a boundary and which belongs to cohom. In this case we have that cohom = [cocyc]. The additional knowledge of a preferred representative for each element of the cohomology basis will be crucial.  For a p-direction I ⊂ {1, . . . , n} with |I| = p, we call the canonical cocycle of p-direction I the sum of all the p-faces in F p (Q n /C k ) having this p-direction I. We denote it by ζ I,p,k . It is straightforward to verify that it is indeed a cocycle.
Theorem 25. The cohomology group H p (Q n /C k ) has a basis such that each basis element is represented by a canonical cocycle.
Proof. We establish the claim by induction over (p + k). The base case was proved in Lemmas 18 and 19.
Let (c 1 , . . . , c k−1 ) be a basis of C k−1 and c k be such that (c 1 , . . . , c k ) is a basis of C k . We consider a fixed position j ∈ Supp(c k ). Supp(c k ) is the set of positions such that c k has a 1 at this position. We can assume without loss of generality that for 1 By the induction hypothesis, the cohomology group H p (Q n /C k−1 ) has a basis such that each basis element is represented by a canonical cocycle. Since π cochain applied to a canonical cocycle gives the empty cochain ∅, π cohom is zero on H p (Q n /C k−1 ). For the same reason π cohom is zero on H p−1 (Q n /C k−1 ) and the long exact sequence in cohomology breaks into the following short exact sequences: We will use the above short exact sequence and apply the induction hypothesis to the cohomology groups H p (Q n /C k−1 ) and H p−1 (Q n /C k ): Let I ⊂ {1, . . . , n} with |I| = p be a p-direction such that [ζ I,p,k−1 ] is an element of the basis of H p (Q n /C k−1 ). Since i cochain (ζ I,p,k ) = ζ I,p,k−1 , i cohom ([ζ I,p,k ]) = [ζ I,p,k−1 ]. Therefore the basis of cohomology classes of H p (Q n /C k−1 ) represented by canonical cocycles has a free family of preimages by i cohom represented by canonical cocycles of H p (Q n /C k ).
Let I ⊂ {1, . . . , n} with |I| = p − 1 be a (p − 1)-direction such that [ζ I,p−1,k ] is an element of the basis of H p−1 (Q n /C k ). j / ∈ I because ∀x ∈ C k−1 , j / ∈ Supp(x). Also because ∀x ∈ C k−1 , j / ∈ Supp(x), it makes sense to say that the j th coordinate of a pface of ζ I,p−1,k is zero or one. Keeping only the faces of ζ I,p−1,k whose j th coordinate is zero gives a preimage of ζ I,p−1,k by π cochain . Applying δ cochain to this preimage gives i cochain (ζ I∪{j},p,k ). Since δ cohom corresponds to i −1 cochain • δ cochain • π −1 cochain at the level of cochains, we obtain that δ cohom ([ζ I,p−1,k ]) = [ζ I∪{j},p,k ]. Therefore the basis of cohomology classes of H p−1 (Q n /C k ) represented by canonical cocycles is sent by δ cohom to a free family of cohomologically classes represented by canonical cocycles of H p (Q n /C k ).
The exactness of the short exact sequence implies that the concatenation of these two free families forms a basis of H p (Q n /C k ).
As side products, we obtain that π cochain,p,k = 0 and that the long exact sequences in cohomology break into pieces of small exact sequences: We wrote the above short exact sequence in cohomology from right to left to prepare its adjunction property with its homology counterpart.

Adjunction and short exact sequence in homology for a generalized hemicube
The following "quasi-equations" depicted with ≈ summarise how the connecting homology and cohomology morphisms are constructed from applications at the level of chains and cochains: On the right hand side of ≈ are (co)chain morphisms and preimages of chain morphisms.
On the left hand side of ≈ are (co)homology group morphisms. ≈ means that if we consider a (co)chain representing a (co)homology class, any preimage or image by the right hand side (co)chain morphisms yields a representative of the image by the left hand side (co)homology morphism. This is true by construction of the connecting (co)homology morphisms ∂ hom and δ cohom as it was described in subsection 2.1.
Lemma 26. π chain and i cochain are adjoint with respect to , , the standard bilinear form over F 2 (element-wise xor). Since chains and cochains are canonically identified, π cochain and i chain are also adjoint.
Proof. By linearity it is sufficient to prove it for chains made of a single p-face. Two such chains intersect with respect to the standard bilinear form if and only if they are equal. Let f p,k−1 be a p-face of Q n /C k−1 and f p,k be a p-face of Q n /C k .
The inverse direction in the last equivalence comes from the fact that i cochain (f p,k ) is always the sum of a p-face of Q n /C k and its translation by c k .

Lemma 27.
The long exact sequences in homology break into pieces of small exact sequences: Proof. By definition, ∂ chain and δ cochain are adjoint. We also know from standard homology theory that the bilinear form , is well defined at the level of homology and cohomology groups. Using eqs. (6) and (7), we see that the connecting morphisms ∂ hom and δ cohom are adjoint at the level of homology and cohomology groups.
Using Lemma 26, it is straightforward to prove that π hom and i cohom are adjoint because they correspond to π chain and i cochain on representatives. Similarly π cohom and i hom are adjoint.
In subsection §4.3 we have proved that π cohom is zero. Thus its adjoint i hom is also zero and the long exact sequences in homology break into pieces of short exact sequences.
To summarise, we have obtained two short exact sequences adjoint to each other, one in homology and one in cohomology:

Product cycles in a generalized hemicube
For cohomology groups, we were able to define cohomology bases with a preferred representative for each basis element. These preferred representative are canonical cocycles. We would like to do the same with homology groups. The preferred representatives for the elements of a homology basis are the soon to be defined product cycles.
Before we define product cycles, we need to define more formally translations at the level of coordinates, faces and chains in Q n and in Q n /C k . We have already used translations at the level of coordinates and faces but we take the opportunity to be more formal now:

Definition 30 (chain translation).
Let c = f ∈ C p (Q n ) be a p-chain of Q n and y = y(1) . . . y(n) ∈ {0, 1} n be a binary vector. We define c + y, the translate of c by y, by translation of every face of the p-chain: Since the translation by y is compatible with (commutes with) taking the quotient by a classical code C k , we use the same definitions in Q n /C k . In Q n , f I is the standard p-face with p-direction I. In Q n /C k , f I,k , the standard p-face with p-direction I is f I , the image of f I under the projection Π k := π k • . . . • π 1 .

Definition 32 (product chain).
as follows: if it satisfies the following conditions: is the sum of the standard p-faces f I 1 ∪...∪I k over every k-tuple (I 1 , . . . , I k ) satisfying the above conditions. Similarly the chain c k is the sum of the standard p-faces f I 1 ∪...∪I k ,k over every k-tuple (I 1 , . . . , I k ) satisfying the above conditions.
Note that the sum is over k-tuples (I 1 , . . . , I k ) and not over p-directions I 1 ∪ . . . ∪ I k . It means that if a p-direction I admits an even number of adapted partitions (I 1 , . . . , I k ), it actually doesn't belong to c x i p i 1≤i≤k .

Lemma 33. The boundary of a product chain is:
Proof. Taking the boundary of a p-chain amounts to replacing each star of each of its p-faces by either a 0 or a 1. Let I 1 ⊂ Supp(x 1 ), . . . , I k ⊂ Supp(x k ) satisfy |I 1 | = p 1 , . . . , Proof. a classical code with basis (c 1 , . . . , c k−1 ) and C k be a classical code containing C k −1 and with basis (c 1 , . . . , c k ). Let ∂ hom,p,k be the homology group morphism corresponding to the classical codes C k−1 and C k . We have: ]. Proof. ).
We used Lemma 33 to derive line 3.

Homology basis for a generalized hemicube
We are now ready to prove Theorem 36 by induction on (p + k): Theorem 36. Let C k be a classical code with basis (c 1 , . . . , c k ). H p (Q n /C k ) has a basis indexed by k-tuples (p 1 , . . . , p k ) satisfying p 1 +. . .+p k = p and such that each basis element is the homology class represented by the product cycle ζ p,k Proof. The base case is straightforward. We use the following short exact sequence and apply the induction hypothesis to H p (Q n /C k−1 ) and H p−1 (Q n /C k ): Since π chain,k (ζ p,k−1 with p k = 0, the basis of homology classes of H p (Q n /C k−1 ) represented by product cycles is sent by π hom to a free family of homology classes represented by the product cycles of H p (Q n /C k ) satisfying p k = 0. Since ], the basis of homology classes of H p−1 (Q n /C k ) represented by product cycles has a free family of preimages by ∂ hom represented by the product cycles of H p (Q n /C k ) satisfying p k = 0.
The exactness of the short sequence implies that the concatenation of these two free families forms a basis of H p (Q n /C k ). Proof. The translate is a cycle since ∂ chain and translation by y commute.

Cocycle minimum distance in a generalized hemicubic code
To prove that translation doesn't alter the homology class we show that is a boundary. Equivalently we show that it is orthogonal to every cohomology class in It is sufficient to consider the canonical cocycles representing a basis of H p (Q n /C k ). Observing that ζ p,k + y) has exactly 0 or 2 p-faces per p-direction finishes the proof.
Therefore each homology class of the product cycles basis of H p (Q n /C k ) is represented by 2 n−k different cycles corresponding to the 2 n−k different translations y ∈ F n 2 /C k . Each p-face belongs to exactly 0 or 2 p of the 2 n−k different cycles. This observation leads to the following proposition: Proof. Let η p,k be a cohomologically nontrivial (p, k)-cocycle. η p,k is not orthogonal to at least one product cycle representing an element of the basis of H p (Q n /C k ). Therefore η p,k is not orthogonal to any of the 2 n−k different cycles obtained by translating this product cycle. Since each p-face of η p,k belongs to at most 2 p translated product cycles, η p,k contains at least 2 n−k−p p-faces. Moroever the value 2 n−p−k is attained by canonical cocycles.

Cycle minimum distance in a generalized hemicubic code
Proposition 39. The cycle minimum distance D (hom) p,k , i.e. the minimum weight of a homologically nontrivial p-cycle in C p (Q n /C k ) satisfies: Proof. We prove by induction on (p + k) that a homologically nontrivial (p, k)-cycle is not orthogonal to at least d p canonical (p, k)-cocycles. Since canonical cocycles are disjoint, the value of the cycle minimum distance follows immediately.
The base case is straightforward. Let η p,k be a cycle representing a nontrivial homology class h p,k ∈ H p (Q n /C k ): h p,k = η p,k . first case: ∂ hom (h p,k ) = 0 in H p−1 (Q n /C k ) for at least one decomposition Then there exists a nontrivial homology class h p,k−1 ∈ H p (Q n /C k−1 ) such that h p,k = π hom (h p,k−1 ). Let η p,k−1 be a (p, k − 1)-cycle representing h p,k−1 . By the induction hypothesis there are d p canonical (p, k − 1)-cocycles not orthogonal to η p,k−1 . Let ζ p,k−1 be such a canonical cocycle. Since π chain and i cochain are adjoint: Therefore applying i −1 cochain to the d p canonical (p, k − 1)-cocycles not orthogonal to η p,k−1 yields d p canonical (p, k)-cocycles not orthogonal to η p,k . The induction step is proved in this case.
The k th element of the basis of the classical code c k has weight at least d. Let I be the (p − 1)-direction of the canonical cocycle ζ p−1,k . At least (d − p + 1) coordinates are in Supp(c k )\I. Denoting by j one of these (d − p + 1) coordinates, the (p − 1)-cochain obtained by only keeping the (p−1)-faces of ζ p−1,k having a 0 at coordinate j is a preimage of ζ p−1,k by the π cochain associated to a decomposition C k = C k−1 ∪ (C k−1 ⊕ c k ) such that ∀x ∈ C k−1 , x j = 0. Applying δ cochain to this cochain amounts to replacing this 0 at coordinate j of every (p − 1)-face by a * and yields ζ I∪{j},p,k−1 . Applying i −1 cochain gives ζ I∪{j},p,k .
With this procedure each canonical (p, k)-cocycle ζ I∪{j},p,k has been counted at most p times. We have therefore constructed at least d−p+1 p d p−1 = d p distinct canonical (p, k)cocycle orthogonal to η p,k . The induction step is proved in this case too.
Moreover the value d p is attained by the product cycles ζ p,k such that p 1 = p, p i =1 = 0 and c 1 has weight d.
We have thus established:

Local testability
The goal of this section is to study the local testability of hemicubic codes. We first establish in 5.1 that the one-qubit hemicubic code is locally testable, before discussing generalized hemicubic codes in 5.2.

Case of the 1-qubit hemicubic code
We first prove the local testability of the hemicube code. This improves upon Hastings' construction [25] obtained by taking the product of two n-spheres and which displays soundness s = Θ 1 log 2 N . (In Ref. [25], the notion of soundness does not include a normalization by the logarithmic weight of the generators.) We leave it as an important open question whether the bounds of Theorem 2 are tight or not. As far as we know, it may be possible to improve the log N to Θ(1). As we will mention later, this would imply that the generalized hemicubic code obtained as the quotient of the cube by a code of dimension 2 would also display local testability.
In this section, we will work in a symmetrized version of the hemicubic code: instead of describing a p-face of the hemicube by an equivalence class of the form {x,x}, we consider the chain x +x over the Hamming cube. In the language of the previous section, we work with i p (E) rather than directly with a p-chain E. As long as all the considered sets S are symmetric, i.e., are in the image of i p , there should not be any risk of confusion. In particular, any symmetric set S of p-faces in the Hamming cube corresponds to a set of |S|/2 qubits.
The local testability of the hemicubic code is a consequence of Lemmas 40 and 41 that we state now: we use the notation for the Hamming weight, or number of cells in a chain.
We say that a p-chain X is a filling of Y if ∂X = Y . We say that a p-cochain X is a cofilling of Y if δX = Y .  In particular, the following upper bounds hold for c n,p and c n,p (obtained by bounding each term in the sum by the largest term): Lemma 42 ([16]). Let z be a (p − 1)-dimensional F 2 -cycle in the n-dimensional cube Q n .
There exists a p-chain y such that ∂y = z and y ≤ n − p + 1 2p z .
Lemma 43 (Proposition 8.2.1 of [15]). Let z be a (p + 1)-dimensional F 2 -cocycle in the n-dimensional cube Q n . There exists a p-cochain y such that δy = z and y ≤ z .
The constants in Lemmas 42 and 43 are tight [15]. We don't know, however, if it is also the case of the constants in Lemmas 40 and 41: in fact it is not even clear that the constants have to be worse than those of 42 and 43 since the examples saturating these bounds are not allowed in the symmetric (quantum) case. For instance, the cycles of the cube Q n that saturate the bound of Lemma 40 are symmetric, meaning that they disappear in the case of the hemicubic code.
Proof of Lemma 40. We will prove the claim by recurrence over both p and n.
Similarly to Dotterrer in [16], we divide the cube in three parts: we first choose a coordinate that we call the "cut" and partition the faces depending on their value, 0, 1 or * , for the cut. Later, we will perform an optimization over the choice of cut, but in the following, we consider a cut along the first coordinate to fix the notations.
Let us define the chain Z = ∂E and decompose it as where Z 0 , Z 1 are chains of C n−1 p−1 and Z * is a chain of C n−1 p−2 . Since Z is a cycle, we have that ∂Z = 0 which implies We can define the chains E 0 , E 1 and E * in an analogous fashion, via E = 0E 0 ⊕ * E * ⊕ 1E 1 , and from ∂E = Z, we infer in particular that Z * = ∂E * . Applying the induction hypothesis to Z * gives a (p − 1)-chain F * such ∂F * = ∂E * and Observe now that Z 0 ⊕ F * is a cycle: indeed from Eq. (9). Applying Lemma 42 for the standard hypercube, we can find a p-chain F 0 (that may not be symmetric) such that where D n−1,p (Z 0 ) is the cofilling of the cocycle Z 0 obtained by Dotterrer's algorithm (i.e, the cofilling promised by Lemma 43). Here,D n−1,p−1 is the symmetric cofillings with parameters n − 1 and p − 1 given by the induction hypothesis. Exploiting the result of Lemma 43, we obtain that F has size: Averaging over the choice of cut, The recurrence is easily solved: The base case is c n,1 = 1 n . This establishes the claim.

Local testability of generalized hemicubic codes
In this subsection, we show that the same proof strategy as above can be applied to deal with quotients of the cube by linear codes of dimension k = 2. Essentially the only change is that the recurrence now requires a bound on the soundness of the hemicubic code instead of a bound on the soundness of the standard cube. Because our bound on the former is worse by a factor log N , we will not be able to control the soundness of the generalized hemicubic code as much as we would like. We now illustrate this point in the case of cycles and prove the following bound.
Lemma 44. Let C = [n, 2, d] be a linear code of dimension 2. Let E be a p-chain of C n p = C p (Q n /C). Then there exists a p-chain F which is a filling of ∂E, satisfying ∂F = ∂E, such that We assume here that for any coordinate, there exists a codeword of C with bit value 1 on this coordinate. If this is not the case, one can work in a Hamming cube of smaller dimension by forgetting this coordinate.
In the same way as before, we will choose to work in the standard Hamming cube, but restricting ourselves to sets (or chains, or cochains) of the form {x + C, y + C, . . .}, i.e., sets S such that x ∈ S implies x + c ∈ S for any codeword c ∈ C. In other words, we work with sets (or chains) of the form i p (E) = e∈E,c∈C (e + c).
Proof of Lemma 44. Let us consider a (p−1)-chain Z = ∂E corresponding to the boundary of an arbitrary p-chain E, symmetric with respect to the code C. Recall that this means that for any c ∈ C, it holds that E + c = E. Without loss of generality, we can choose some E 0 and E * , which are sets of p and (p − 1)-faces of the (n − 1)-dimensional Hamming cube, such that As before, this describes a partition with respect to the value of the symbol (either an element of F 2 or a star) on the special coordinate called "cut". That we can take E 1 to be empty is without loss of generality since we assumed that there are codewords of C with bit value 1 for the cut. The boundary of E is Z = ∂E and our goal is to find a small symmetric filling F such that ∂F = ∂E. We will prove the result by induction on n and p by showing the existence of a mapD n,p such that ∂(D n,p (∂E)) = ∂E and D n,p (∂E) ≤ c (2) n,p ∂E . Let 1α be a codeword of C with bit value 1 on the cut (α is a word of length n − 1). Again, as before, we pretend that the cut corresponds to the first coordinate to fix the notations. Let A be the subcode of C consisting of all codewords with bit value 0 on the cut. This yields a partition of C as where the set A only contains codewords with bit value 0 on the cut, and A + α codewords with bit value 1. With this notation, we have: In particular, Z * is a boundary symmetric with respect to the shortened code obtained by forgetting the coordinate corresponding to the cut in C and one can apply the induction hypothesis to obtain a small filling F * =D n−1,p−1 (Z * ) of size F * ≤ c (2) n−1,p−1 Z * .
Since it is a cycle, it is a boundary in the quotient of (n − 1)-dimensional Hamming cube code A. Applying the construction of Lemma 40 to this boundary yields a filling F 0 symmetric with respect to A (i.e. F 0 + a = F 0 for any a ∈ A) satisfying: where the factor c n−1,p = n−p+1 2 results from our bound on the size of a symmetric filling with respect to the repetition code. Note that some coordinates are likely stuck with the value 0 in the code A, and one might expect a better factor in that case, but we don't consider this possible improvement in the following. Define F 1 = F 0 + α. It is a filling of Z 1 since Z 1 = Z 0 + α. Moreover, the assumption on the minimum distance of C implies that F 0 = F 1 . We finally define F = 0F 0 ⊕ * F * ⊕ 1F 1 which satisfies ∂F = ∂E by construction.
As before, E Z 0 = n−p+1 2n Z and E Z * = p−1 n Z and therefore, we can take c (2) n,p ≤ 2c n−1,p This is in fact the same recurrence relation as before (in Lemma 40), but with the value of c It is quite striking that the resulting bound on the soundness is much worse when taking the quotient by a classical code of dimension 2 rather than by the repetition code. In particular, the resulting soundness becomes only 1/poly(N ) instead of 1/ log N . The source of this discrepancy is easily located in Eq. (12), where we injected the value of the soundness for the hemicubic code instead of the soundness of the standard cube. In particular, if we could establish that the hemicube code had a similar soundness (or even better) than the standard cube, then the proof above would immediately imply that the generalized hemicube code has soundness 1/polylog(N ). This would provide the first example of quantum code of exponential length displaying local testability.
A similar analysis can be performed for cofillings but again, it only provides a bound for the soundness scaling inverse polynomially with N .
Lemma 45. Let C = [n, 2, d] be a linear code of dimension 2. Let E be a p-cochain of C n p = C p (Q n /C). Then there exists a p-cochain F which is a cofilling of δE, satisfying δF = δE, such that F ≤ c (2) n,p ∂E , with c (2) n,p = O(p!).
Proof of Lemma 41 for arbitrary codes. Using the same notations as in the previous subsection, we start with an arbitrary p-cochain E which we write with respect to an arbitrary cut. Choosing a codeword α with bit value 1 on the cut, and denoting by A the subcode of C consisting of all the words with bit value 0 on the cut, we obtain: E = a∈A 0(E 0 + a) ⊕ 1(E 0 + α + a) ⊕ * (E * + a) ⊕ * (E * + α + a) δE = 0Z 0 + 1Z 1 + * Z * .
We again proceed by induction. Let us denote by D n,p the application promised by Lemma 41 and byD n,p the application promised by the present lemma (yielding a symmetric cofilling), and defined by induction. The latter application preserves the symmetry of the cochain with respect to C, while this is not necessarily the case of D n,p , which only preserves the symmetry with respect to A. We define the symmetric cofilling of δE by One can check that δF = δE and that F is symmetric with respect to code C. Bounding the size of F is similar to the proof in the case of the repetition code. Indeed, recalling that D n−1,p (X) ≤ (p + 1) X for any cocycle X of the hemicube, we obtain F ≤ c n−1,p−1 ((p + 1) Z 0 + (p + 1) Z 1 + Z * ) + (p + 1) Z 0 + (p + 1) Z 1 , which is identical to Eq. (11), except for the extra factors (p + 1). As before, solving the recurrence yields c (2) n,p = O(p!).
Similarly to the case of cycles, if one could shave the log(N ) factor off in the case of the hemicube and prove that it displays the same soundness as the standard cube, we would immediately obtain a 1/polylog(N ) soundness for the generalized hemicube code.

Efficient decoding algorithm for adversarial errors
In this section, we explain how the small fillings and cofillings promised by the results of the previous section can be exploited to give an efficient decoding algorithm with good performance against adversarial errors. The main idea is to notice that one can efficiently find such fillings and cofillings and therefore find Pauli errors giving the observed syndrome.
While finding the smallest possible fillings or cofillings does not appear to be easy, finding ones satisfying the bounds of Lemmas 40 and 41 can be done efficiently.
We note, however, that the decoding algorithm does not seem to perform so well against random errors of linear weight. In particular, any argument based on percolation theory that would say that errors tend to only form small clusters and that therefore it is sufficient to correct these errors (similarly to [20] for instance) fail here because of the logarithmic weight of the generators. Indeed, the factor graph of the code has logarithmic degree and there does not exist a constant threshold for the error probability such that below this threshold, errors appear in clusters of size o(N ). Nevertheless, it seems that a decoding algorithm such as the small set flip algorithm of [30] performs rather well for the hemicubic code.
For simplicity, we restrict our attention to the single-qubit code in the following. where c n,p = (n − p + 1)(n − p) 2p n m=n−p+1 1 m . (16) Again, if we are not interested in the smallest filling, but simply one satisfying the promised bound, it is possible to find it efficiently by choosing a cut minimizing the rhs of Eq. (16). This again has complexity O(n Z ) at a given level. Overall, finding a small symmetric filling has complexity O(n 4 Z ), where we recall that n is logarithmic in the length of the quantum code. Correcting for Z errors is done similarly using the algorithm for cofillings (Lemma 41) instead.
Let us now show that this algorithm recovers the correct error (up to a stabilizer element), and therefore that decoding succeeds. Let Y be the support of a Pauli-X error and denote by Z = ∂Y its syndrome. Note that Z ≤ 2p + 1 Y since the generators have weight 2p. The algorithm described above yields a chain Y such that ∂Y = Y = ∂Y and of size Y ≤ c n,p Z ≤ 2pc n,p Y Observe now that the following inequalities hold: In particular, as long as (1 + 2p(n − p)) Y < n p , the cycle Y + Y cannot yield a logical error and the decoding was successful. Similarly, if Y is the support of a Pauli-Z error, the same reasoning shows that the decoding is successful as long as (1 + 2(n − p)c n,p ) Y < 2 n−p−1 .
Combining both conditions, we obtain that the decoding is successful for any error of weight less than d min 2p(n−p)+1 .