Optimal Narain CFTs from Codes

Recently established connection between additive codes and Narain CFTs provides a new tool to construct theories with special properties and solve modular bootstrap constraints by reducing them to algebraic identities. We generalize previous constructions to include many new theories, in particular we show that all known optimal Narain theories, i.e. those maximizing the value of spectral gap, can be constructed from codes. For asymptotically large central charge $c$ we show there are code theories with the spectral gap growing linearly with $c$, with the coefficient saturating the conjectural upper bound. We therefore conjecture that optimal Narain theories for any value of $c$ can be obtained from codes.


Introduction
Conformal modular bootstrap program aims to establish universal constraints on two-dimensional CFTs and elucidate properties of those special theories which saturate these constraints. One of the central goals of the modular bootstrap is to study theories maximizing the value of spectral gap for given fixed value of central charge [1], as these theories for large central charge are expected to be dual to weakly coupled gravity [2]. To simplify this obviously challenging task one can restrict attention to a class of Narain theories, i.e. CFTs exhibiting U (1) c × U (1) c symmetry. In this case large spectral gap theories are not sparse (in the sense of [2]), and their holographic description is less clear [3]. Nevertheless study of such theories is well motivated by both holography and the modular bootstrap, with the latter relating solutions of spinless bootstrap constraints to densest sphere packings [4]. 1 Narain theories were studied in [6] and [7] using spinless and full modular bootstrap, with the hypothetical optimal theories being identified for c ≤ 8. Here, following [8] we say optimal to denote CFTs maximizing spectral gap for given c.
A relation between quantum codes and Narain CFTs, proposed in [9], generalizes chiral constructions of [10]. Starting from a code it constructs corresponding Narain lattice and expresses CFT torus partition function in terms of the code enumerator polynomial (for higher genus generalization see [11,12]). In this way constraints of modular invariance reduce to two algebraic constrains at the level of enumerator polynomial. The relation to quantum codes was recently extended and interpreted in terms of CFT Hilbert space in [13]. There are also "bottom-up" generalizations when the connection with codes is perceived as a tool to solve modular bootstrap constraints and construct interesting CFTs [14,15], also see [16,17] for the subsequent developments. In this paper we use this approach and introduce the umbrella construction which generalizes and encompasses the constructions of [14,15]. In particular we show that all (conjecturally) optimal Narain theories for c ≤ 8 identified in [7] are in fact code theories, by providing an explicit way to construct these theories from codes.
Our construction should be understood as an infinite family of similar but distinct constructions. We consider codes over abelian groups G = Z p × Z q equipped with particular scalar product and map even self-dual codes C ⊂ G c to Narain lattices using a suitable generalization of the Construction A of [18]. The same group G might be mapped into lattices in several different ways, each way defining a particular construction. Then an appropriate generalization of the code Hamming distance (we explain what this is latter in the text), modulo certain subtleties, defines CFT spectral gap ∆ * such that "better" codes with larger Hamming distance corresponds to larger ∆ * . In each case, the resulting Narain lattice necessarily has vectors of particular length which is independent of c. Hence any given construction can only yield CFTs with bounded spectral gap that doesn't grow with c. Nevertheless by considering a sequence of constructions parametrized by c one can obtain a family of Narain theories with the spectral gap growing linearly with c. For c 1 finding optimal codes, i.e. those maximizing corresponding Hamming distance, is a chal-lenging task, but one can average over a family of codes with the given c. From here we find that random code CFT, drawn from a particular ensemble, has spectral gap which was conjectured in [3] to be asymptotically largest possible value. Thus, we conclude that certain code CFT are optimal for c 1 or at least give spectral gap with the conjectured maximal asymptotic value of ∆ * /c.
The paper is organized as follows. In section 2 we outline our main construction mapping codes to Narain CFTs and then express their partition functions in terms of enumerator polynomials in section 3. We then use these results to construct optimal theories for c ≤ 8 in section 4. We proceed by considering the case of asymptotically large c and a family of associated constructions in section 5. We conclude in section 6.
Note: recently a paper [16] appeared which has an overlap with the square lattice construction discussed in sections 2.3, 3.2.

Additive codes and Lorentzian lattices
The main ingredient of our construction is a 2-dimensional even lattice Λ ∈ R 1,1 , which we call a glue lattice. Starting from such a lattice, we define an additive group G, which serves as the alphabet of the code. Then standard Construction A maps a code C ⊂ G c into a lattice (2.1) When C satisfies additional conditions, the lattice Λ C is even and self-dual, thus defining a Narain theory.

Even lattices in R 1,1
We equip R 2 with a Lorentzian metric A lattice called even if v T gv ∈ 2Z for any v ∈ Λ. Any even lattice is automatically integral. It is convenient to parametrize a lattice by a generating matrix Λ, such that v = Λn, n ∈ Z 2 generates all lattice vectors. Here we abuse the notations by using Λ to denote both the lattice and its generating matrix. The generating matrix is not unique, obviously Λ and ΛS for S ∈ SL(2, Z) generate the same lattice. So far we are only interested in the scalar product defined by (2.2), we can identify all lattices related by O(1, 1), Λ ∼ OΛ for O ∈ O(1, 1).
By dual lattice Λ ⊥ we understand all vectors v ∈ Λ ⊥ ⊂ R 1,1 such that v T gu ∈ Z for any vector u ∈ Λ. At the level of generating matrix Λ ⊥ = g(Λ −1 ) T .
We can parametrize all even lattices in R 1,1 as follows. In full generality assuming det(Λ) = √ k 2 − 4mn > 0. Then using SL(2, Z) we can bring n, m, k to satisfy (see chapter 15 of [18]) unless k 2 − 4nm is a full square, in which case one can choose new n, m, k such that With the help of an appropriate O(1, 1) transformation the corresponding generating matrix can be brought to the form Since Λ is integral, it is contained in its dual Λ ⊥ ⊇ Λ. We call the following quotient the "glue group" Here p = gcd(2n, 2m, k), q = |G|/p, (2.8) where |G| is the order of the group. This follows from the invariant factor decomposition of finitely generated abelian groups.
One possible parametrization of the elements of G is as pairs g = (a, b) of integer numbers 0 ≤ a < p, 0 ≤ b < q. Another useful parametrization is as integer vectors (g) ∈ Z 2 modulo columns of g Λ . An explicit map between these two parametrizations may be nontrivial. The metric on R 1,1 induces a scalar product on G, which we denote by η. It is defined up to shifts by integer numbers, which reflects different choices of representatives in the quotient Λ ⊥ /Λ. One can consider codes over G, namely additive linear subspaces C ⊂ G c . A code would be called even if the norm of each element defined with η is even Despite that η is defined only up to certain integer shifts, whether η(g, g) is even does not depend on the representative of g. With help of η one can also define dual code C ⊥ , as the group of all elements c 1 ∈ C ⊥ ⊂ G c satisfying η(c 1 , c 2 ) ∈ Z for any c 2 ∈ C. A code is called self-dual when C = C ⊥ .

Construction A
Starting from a code C ⊂ G c , Construction A associates to it the lattice Λ C , defined as the set of vectors in Λ ⊥ ⊕ · · · ⊕ Λ ⊥ mapped into C ⊂ G c under (2.7). Then it is straightforward to see that an even C would give rise to an even lattice Λ C and a self-dual C to a self-dual Λ C , both understood with respect to Lorentzian scalar product g L = g ⊕ · · · ⊕ g in R c,c .
To define a Narain theory, besides Lorentzian scalar product, even self-dual lattice should also be equipped with the Euclidean scalar product. For each Λ defined in previous section there is O(1, 1) ambiguity how it can be embedded in R 2 . Thus, very explicitly we can write where in (2.12) we parametrize elements of G = Z 2 /g Λ by vectors . Matrix O is an arbitrary element from O(1, 1). In principle we can introduce c different transformations O i ∈ O(1, 1) acting in each R 2 plane. In this case most of the construction remains intact, but the permutation of factors of G in C ⊂ G c , which is conventionally considered to be a code equivalence, would no longer yield physically equivalent lattices. In what follows we assume that all factors O are the same.
The main result of this section is as follows. For any glue group G defined via (2.7) with the help of an appropriate even lattice Λ ⊂ R 1,1 , any even self-dual code C ⊂ G c via Construction A defines Narain lattice Λ C (2.12) and hence a Narain CFT. We will call such CFTs code theories.

Example: square glue lattice
Consider the following glue lattice generating matrix The dual lattice is generated by Λ ⊥ = I/ √ p. Clearly this is the case of n = m = 0, k = p and the glue group G = Z p × Z p is parametrized by g = (a, b) ∈ G, 0 ≤ a, b < p and (2.14) It is convenient to write codewords c = (g 1 , . . . , g c ) ∈ C ⊂ G c as A code can be defined with a 2c × d generating matrix G C such that where d depends on p. For prime p generating matrix is 2c×c and using permutations can always be brought to the form where B is an integer values antisymmetric c × c matrix defined mod p, and B ii = 0. Applying Construction A to such codes leads to Narain lattices generated by associated with the Lorentzian scalar product g L . Here I c is a c-dimensional identity matrix. The form of Λ C provides a clear interpretation -corresponding Narain theory describes c scalars compactified on a c-dimensional cube of size 1/ √ p in presence of B-field B. The construction described above is a straightforward generalization of the original construction of [14,9], which considered the case of p = 2. It has been recently introduced independently in [16].

Generalization: isodual codes
is the simplest example of code equivalences, defined as a linear transformation S : G c → G c which preserves scalar product η. Provided dual code is equivalent to the original one such a code is called isodual. From this follows S 2 = 1, i.e. when S is a permutation, it is a pair-wise permutation, with the corresponding matrix satisfying S T = S. We can introduce evenness as the condition for all codeword (g 1 , . . . , g c ) ∈ C ⊂ G c to have even scalar product with its permuted self, (2.22) An even, isodual code C with respect to some pairwise permutation S, via Construction A (2.12) gives rise to an even lattice, which is self-dual with respect to Lorentzian scalar product (2.23) In this way isodual codes also can be used to define Narain lattices and code CFTs.

CFT spectral gap and code modified Hamming distance
The capacity of a code to preserve information is rooted in the ability to unambiguously restore c ∈ C in case it got corrupted during transmission process. Speaking colloquially, the code is better (stronger), provided all codewords are maximally distinct from each other. To quantify that coding theory uses Hamming distance d(c, c ), defined as the number of different components of c, c . For the binary linear code, when the components of c are either zero or one, d(c, c ) = |c − c | 1 = |c − c | 2 2 . When the code is not binary, there could be various generalizations of Hamming distance, relevant for different practical scenarios. Thus, if the transmission error changes a codeword component's value randomly, with the new value being unrelated to the original one, then Hamming distance defined as the number of distinct components is still relevant. Yet, in many practical settings the nature of errors are such that the new values tend to be closer to old ones, which suggest using various metrics. In particular in case of codes over Z p one often defines For a linear code, the code distance is The value w(c) := d(0, c) is usually called the weight of c. Construction A (2.12) relates each codeword c ∈ C to a family of vectors v(c). We define the weight of c to be the minimal length square among all such v, The weight w(d) is closely related to the norm of c calculated with the scalar product η inherited from R 1,1 on G.
Clearly, from this definition follows that code theory spectral gap ∆ * , defined as the length-squared of the shortest non-zero vector divided by two, is simply related to code's generalized Hamming distance ∆ * = d(C) 2 . This relation is transparent, but there is one caveat: zero codeword c = 0 is mapped into the origin of Λ C , as well as many vectors of the form Λ(k 1 , . . . , k c ). The origin is excluded from the consideration, while minimizing over k i yields shortest vector of Λ. We thus have where by |v Λ | we denoted the length of shortest non-trivial vector of Λ. This length depends non-trivially on the choice of n, m, k and the O(1, 1) factor (which we absorbed into the definition of Λ), but an upper bound (2.31) is readily available, see below.
For the square lattice of subsection 2.3 we find that d(c, c ) is given by (2.24) where by |a − a | 2 with 0 ≤ a, a < p we understand |a − a | 2 := min k∈Z (a − a + pk) 2 , (2.29) and |v Λ | 2 = p.
To obtain the upper bound on the length, in the sense of Euclidean norm, of the shortest vector v Λ belonging to (2.12) we consider all i = 0, arbitrary k 1 and k i = 0 for i > 1. Then the Euclidean norm of corresponding two-dimensional vectors is which defines a positive-definite scalar product in R 2 . The shortest vector will necessarily be shorter than |v Λ | 2 ≤ 2|G| 1/2 / √ 3, see Appendix A, and therefore corresponding code CFT would have the spectral gap not exceeding This is a standard weakness of the Construction A lattices; they always include short vectors of a certain length, which does not increase with c. Therefore to construct large spectral gap CFTs with ∆ * scaling linearly with c we would need to consider a cascade of different constructions by adjusting k, n, m together with c.
3. Torus partition function of code theories 3.1 Enumerator polynomial and theta-series One of the central properties of code theories which make them interesting is that their torus partition function can be expressed in a compact way in terms of the so-called code enumerator polynomial which characterizes the corresponding code. Generalization of this result to higher genus partition function is also possible [19,20]. We first define the full enumerator polynomial of a code C as a vehicle to count how many times each element g ∈ G appears in each codeword of C, This is a degree n homogeneous polynomial of |G| variables x g . The polynomial of the dual code C ⊥ is related to the polynomial of C by the MacWilliams identity In particular, this means that the enumerator polynomial of a self-dual code is invariant under the above transformation. The torus partition function of a code CFT, associated with Λ C obtained by Construction A, is given in terms of P C , is the torus modular parameter and in (3.5) we parametrize elements of G with help of vectors ∈ Z 2 /g Λ . We also absorbed O ∈ O(1, 1) into the definition of Λ.

Example: theta series for square glue lattice
For the lattice (2.13) functions ψ g defined in (3.5) read where (a, b) ∈ G = Z p × Z p . This can be written as follows where (3.13) These functions are the chiral algebra characters of free boson compactified at radius R = √ 2k. Note, if we perform O(1, 1) rotation on the lattice Λ, functions ψ ab will change. Let (3.14) Then For λ = √ q with q ∈ N, we can again decompose ψ ab as follows where the functions Θ m,pq above are now characters of compactified boson at radius R = √ 2pq. Finally, if λ = q/r with q, r are co-prime, we can again perform the same decomposition to obtain a more general result Θ q(a+pv 1 )+r(b+pv 2 ),pqrΘq(a+pv 1 )−r(b+pv 2 ),pqr + Θ q(a+pv 1 )+r(b+pv 2 )−pqr,pqrΘq(a+pv 1 )−r(b+pv 2 )−pqr,pqr , (3.17) where the functions Θ m,pqr above are characters of compactified boson at radius R = √ 2pqr.

Partition function in case of isodual codes
In case of isodual codes satisfying (2.21) with pairwise permutation S, the codeword c = (g 1 , . . . , g c ) ∈ C should be understood as consisting of r pairs (g i , g j ) with S mapping i ↔ j, while the remaining c − 2r "letters" remain intact. It is convenient to introduce new notation for c which is related to the previous one by permutation, c = ((g i 1 , g j 1 ), . . . , (g ir , g jr ), g 2r+1 , . . . , g c ) ∈ C. (3.18) With this notation we define an extended enumerator polynomial, which will depend on both C and S. It is a function of |G| 2 variables y g 1 g 2 and |G| variables x g , 1 ,g j 1 ),...,(g ir ,g jr ),g 2r+1 ,...,gc)∈C r k=1 The CFT partition function is given by where Under modular transformations T : τ → τ + 1 and S : τ → −1/τ , this function changes as follows and Clearly when C is even in the sense of (2.22) and isodual in the sense of (2.21), the identities (3.25,3.26) respectively ensure modular invariance of (3.20).

Examples: optimal Narain theories for small c
In this section we consider a number of explicit examples of code theories. In particular we discuss optimal theories, i.e. those with the largest spectral gap, for c ≤ 8 identified in [7], and show they all are codes theories, in the sense defined in this paper.

c = 1
We first consider the simplest case of n = m = 0, when In this case the group G = Z k × Z k is parametrized by vectors = (a, b) for 0 ≤ a, b < k. Let's consider a self-dual code C = C ⊥ and demand it to be even and selfdual. When k is prime the only such two codes consist or vectors (a, 0) and (0, a) for 0 ≤ a < k correspondingly. Using appropriate O(1, 1) transformation we can bring corresponding Narain lattice to the form At this point we recognize Narain lattice of a compact boson of radius R 2 = 2k. Choosing k = 1 will yield boson at self-dual radius, which has largest possible spectral gap The corresponding enumerator polynomial is simply P = x 00 , giving rise to torus partition function via Clearly, an appropriate O(1, 1) transformation will turn Λ C to any other Narain lattice in R 1,1 , or, equivalently, change the compact boson radius R to any desired value. In other words, together with the O(1, 1) factor our code construction is versatile enough such that any c = 1 Narain theory is a code theory. This emphasizes the bottom-up nature of our approach. While codes are expected to reflect some algebraic properties of the underlying CFTs in the top-down constructions [13], in our construction certain non-rational CFTs without obvious algebraic properties which would make them "finite" also can be obtained from codes.

c = 2
We start with m = 2, n = −1, k = 2, which satisfies (2.4) and the glue lattice generated by From the Euclidean point of view this is a hexagonal (triangular) lattice with the lattice vectors of length 2, rotated by π/2. Using equivalence transformation we can bring g Λ = Λ T gΛ to the diagonal form which makes decomposition G = Z 2 × Z 6 manifest, with the map We consider a code C generated by the following three codewords in the notations c = (g 1 , g 2 ) = ((a 1 , b 1 ), (a 2 , b 2 )). This codes is iso-dual, C ⊥ = S(C), where S is the permutation of two elements. Corresponding lattice Λ C obtained via (2.12) In this expression above we should understand codewords c i as regular vectors in Z 4 . This lattice is a Narain lattice with respect to the Lorentzian metric (2.23) By an orthogonal transformation g L can be brought to conventional form such that Λ C becomes equivalent to the Narain lattice Λ c=2 defining SU (3) 1 WZW theory The code enumerator polynomial of C is P S C = y 00,00 + y 00,02 + y 00,04 + y 10,01 + y 10,03 + y 10,05 + y 03,10 + y 03,12 + y 03,14 + y 13,11 + y 13,13 + y 13,15 , which yields partition function via (3.20). Shortest lattice vector with T = c 2 or T = c 3 and k i = 0 has length |v| 2 = 4/3, hence corresponding CFT has spectral gap ∆ * = 2/3.

c = 3, 4, 5
Optimal theories for c = 3, 4, 5 were constructed from codes in [14]. They correspond to k = 2 and n, m = 0 with In this case G = Z 2 × Z 2 which as an additive group is equivalent to F 4 . As discussed in section 2.3 these codes are parametrized by B-matrix controlling the B-field of the Narain compactification, B T = B mod 2, see (2.19). The case of k = 2 is special because antisymmetric B T = −B mod 2 and symmetric matrices B are equivalent.
For the optimal theories with c = 3, 4, 5 the symmetric B-matrices, which can be interpreted as graph adjacency matrix , describes the maximally connected graph (4.14) Their enumerator polynomials and partition functions can be found in [14]. Here we only point out that for p = 2 and 0 ≤ a, b < p ψ a,b = 1 |η| 2 n,m∈Z in full agreement with [14]. The spectral gaps are ∆ * = 3/4, 1, 1 for c = 3, 4, 5 correspondingly.

c = 6, 7
Optimal theories for c = 6, 7 were found in [15] to be related to codes, where a construction, different from [14,9], relating codes over F 4 to CFTs was introduced.
Here we show this construction is a particular case of a more general construction introduced in this work. Let us consider the glue matrix This corresponds to m = −1, n = 1, k = 0 case as follows from Clearly G = Z 2 × Z 2 which can be parametrized by T = (a, b), 0 ≤ a, b < 2. As in the previous section we can identify G with F 4 via the Gray map The scalar product inherited from on G from (2.2) reads Since the scalar product is defined up to integer shits, orthogonality with respect to η is equivalent to orthogonality with respect to a 1 a 2 + b 1 b 2 mod 2 = c 1 c 2 +c 1c2 , (4.23) where the right-hand-side uses notations (4.21). This is different from the conventional Hermitian scalar product on F 4 (c 1 , c 2 ) = c 1c2 +c 1 c 2 , (4.24) by an additional conjugation. Thus a code C ∈ G c iso-dual with respect to scalar product on G inherited from (2.2) and pairwise permutation S, C ⊥ = S(C), will be isodual to its conjugate, C ⊥ = S(C), with respect to Hermitian scalar product (4.24). This is exactly the isoduality condition outlined in [15]. Similarly, the evenness condition (2.22), written in coordinates matches precisely with the evenness condition of [15].
To complete the comparison with [15] we note that under Construction A (2.12) group elements T = (a, b) will be mapped to which is exactly the map from c = aω + bω ∈ F 4 to R 2 used in [15]. In other words, we have shown that the construction of [15] is exactly the construction of this paper with the glue matrix taken to be (4.19).
We notice the choice m = −1, n = 1, k = 0 is not the canonical one. By an appropriate GL(2, Z) transformation we can bring it to m = 1, n = 0, k = 2, satisfying (2.5). The new form of the glue lattice generating matrix is then which is a hexagonal (triangular) lattice with the basic vector length 2/3 1/4 . The codes leading to optimal c = 6 and c = 7 theories, the hexacode and the "septacode" are rather bulky and we do not repeat them here. Let us just mention that in both cases the resulting spectral gap is ∆ * = 4/3.  In this case G = Z 4 × Z 4 parametrized by g = (a, b), 0 ≤ a, b < 4 and T = (a, b). Let us consider the code C ∈ G 8 generated by rows of the following matrix in the notations c = (a 1 , . . . , a 8 |b 1 , . . . , b 8 ) ∈ C. This code is even and self-dual with respect to Accordingly the lattice is a Narain lattice with respect to The lattice shortest vector has length |v| 2 = 2 √ 2 yielding ∆ * = √ 2. This follows from the lattice theta series, which can be readily obtained from the code enumerator polynomial. The code in question has 2 16 codewords and enumerator polynomial P C (x ab ) is too large to be written explicitly here. Upon substituting x ab → ψ ab where (this definition is different from (3.5) in two ways: i) there is no |η(τ )| in the denominator because we are interested in the lattice theta-function rather than the CFT partition function ii) ψ ab depends on q but notq as we are interested in the Euclidean structure only), we obtain P C (ψ ab ) = 1 + 4320t 2 + 61440t 3 + 522720t 4 + 2211840t 5 + O t 6 , t = q 2 −1/2 , which is exactly the theta-function of the Barnes-Wall lattice. This is in agreement with [21] who identified optimal c = 8 theory to be based on a rescaled Barnes-Wall lattice, equipped with the Lorentzian metric and understood as a Narain lattice.

Asymptotically large c
When c 1 asymptotic behavior of spectral gap is not known. Spinless modular bootstrap bounds ∆ * /c to be less than or equal to 1/π 2 (with this value being obtained numerically) [6], while the full set of bootstrap constraints is likely to significantly decrease this value. Averaging over the whole moduli space of Narain theories provides a lower bound on ∆ * /c to be 1/(2πe) [21]. Ref. [3] conjectured this value to be asymptotically saturated, .
For this to be true, i.e. for the mean value to (asymptotically) be the largest possible value, the distribution of spectral gaps on the Narain moduli space for large c must be very sharply peaked around the mean without outliers. Thus, for consistency, as a necessary condition, variance should be very small. Using the ensemble of code CFTs, as well as chiral cousins of Narain theories, ref. [3] has shown the variance of density of states distribution to be exponentially suppressed ∼ e −O(c) , the conclusion consequently confirmed for the Narain theories in [22]. This does not constitute a proof of (5.1) as variance is not sensitive to possible outliers. The conjecture of [3] is based on similarity between the ensemble of codes, ensemble of sphere packings, and the ensemble (space) of CFTs, and the problems of maximizing code Hamming distance, density of sphere packing and CFT spectral gap. Specifically for codes, there is an expectation that the Gilbert-Varshamov bound (the value resulting from averaging over all codes) would asymptotically yield the best value of Hamming distance to code size ratio [23,24]. Similar expectation holds for the maximal density of lattice sphere packing: the densest packing to asymptotically saturate the Minkowski bound, which is simply averaged value over all possible lattices. (For sphere packings of general kind stronger asymptotic value is expected [25].) While we leave validity of (5.1) for future studies, here we show there are codes theories achieving this value of ∆ * for large c.
The Construction A used in this paper has a fundamental limitation: the corresponding lattices have vectors of certain length no matter how big the dimension c is. This is formalized in equation (2.31), which provides an upper bound on ∆ * . Thus, to obtain ∆ * scaling linearly with c one has to adjust n, m, k together with c such that |G| grows as or faster than c. Here for simplicity we focus on the square gluing lattice n = m = 0, with prime k = p, discussed in sections 2.3, 3.2. The spectral gap is given by (2.28) with |v Λ | = √ p, The best (maximal) generalized Hamming distance d beyond small c values is not known. One nevertheless can bound d from below by consider ensemble averaging, the so-called Gilbert-Varshamov bound. Then, similarly to the case of binary linear codes one may expect best d/c to asymptotically approach the bound when c → ∞. By averaged polynomialP ({x ab }) we mean enumerator polynomial averaged over all p c(c−1)/2 possible codes parametrized by B, see (2.17). From the CFT point of view this is the calculation of averaged torus partition function. So far we are interested only in d, or alternatively only in mass but not spin of the lightest non-trivial state, we can consider torus parameter to be purely imaginary τ = iτ 2 . Then function (3.2) factorizes Going back to enumerator polynomial, instead of variables x ab we use where the last property reflects ψ a = ψ −a . We conjecture the form of corresponding averaged enumerator polynomial based on invariance under MacWilliams identity and explicit checks for sufficiently small n and prime p, for which direct evaluation ofP ({t a t b }) using computer algebra is feasible, Interpreted as sum over lattice points, the numerator is simply the sum over 2cdimensional square lattice of size 1/ √ p. On the length scales of ∼ 1/ √ p or larger this is just the homogeneous distribution of points with the averaged density 1/(1/ √ p 2c ) = p c . This factor exactly cancels p c in the denominator of (5.6) and we find density of states valid on scales ∆ 1/ √ p. This is exactly the density of states of "U (1)-gravity" -Narain theory averaged over the whole moduli space. Accordingly, the threshold for the density to become of order one is ∆ = c/(2πe), which is our Gilbert-Varshamov bound. For this result to be valid we must require p/2 > c/(2πe), otherwise shortest vector of Λ C would have length √ p.
To conclude, for sufficiently large p we find that the averaged density of states (with zero chemical potential for spin) of n = m = 0, and prime k = p code theories is the same as the averaged density of states for all Narain theories. In particular in the limit c → ∞, for p > c/(πe) there are code theories with ∆ * /c = 1/(2πe). Provided the conjecture of [3] is correct, it would mean similar conjecture applies to n = m = 0, prime k = p codes, in the sense that their averaged Hamming distance is asymptotically the best one.

Discussion
In this paper we proposed a family of constructions mapping additive codes over abelian groups G = Z p × Z q to Narain lattices and hence Narain CFTs. Each construction is parametrized by a triple of integer numbers n, m, k and an element from O(1, 1) parameterizing an even "glue" lattice Λ ⊂ R 1,1 . The resulting Narain lattice Λ C associated with a code C ⊂ G c obeys We call this glue construction following [18]. This construction generalizes and encompasses those of [14,9], [15] and [16]. We call the CFTs obtained from codes "code theories." Their torus partition functions Z C are given in terms of the so-called code enumerator polynomials, which are multi-variable polynomials satisfying certain algebraic identities, which guarantee modular invariance of Z C . In this way one can construct many new solutions to modular bootstrap constraints.
We have shown that all conjectural optimal Narain theories for c ≤ 8 identified in [7], meaning those with the largest spectral gap of U (1) c × U (1) c primaries are code theories. Furthermore we have shown there are code theories with the spectral gap ∆ * scaling linearly with c 1, ∆ * ∝ c/(2πe), with the coefficient which has been conjectured in [3] to be maximal possible. The message of our work is clear: we conjecture that optimal Narain theories for any c are code theories, either following from the constructions outlined in this paper, or their possible generalizations.
Speaking of the latter, one can straightforwardly generalize our construction by starting with a glue lattice Λ ⊂ R 3,3 or in fact Λ ⊂ R r,r for any r ≥ 2. Another important direction would be to connect the bottom-up approach of this paper with the top-down approach of [13] where quantum codes were given an interpretation in terms of CFT Hilbert space extended by defect operators. Finally, given our conjecture that optimal theories are code theories, it would be interesting to develop our approach into a practical way of constructing optimal theories with c > 8, thus complementing conventional modular bootstrap. This would be an important but challenging task because there is no known efficient methods to construct "good" codes with largest or even large (generalized) Hamming distance. And though there is a finite number of codes for any given G and c, their number grows exponentially with c. Furthermore, there is an infinite number of constructions, i.e. infinite number of different G and Λ, making the problem seemingly incomprehensible. This pessimistic assessment could be too naive, we expect only finite number of constructions to be relevant for any given c. The inequality (2.31) as well as the results of section 5 clearly indicate |G| can not be too small, |G| 1/2 ≥ ac, for c 1 with some positive constant a. We also strongly suspect large generalized Hamming distance, for given c, would require |G| not be too large. We conjecture this may come from the linear programming constraints stemming from the algebraic identities satisfied by code enumerator polynomial (the MacWilliam identity and the condition due to code evenness), i.e. generalization of Delsarte's bounds [26] to the types of codes of interest. For c 1 we expect the bound to have the form |G| 1/2 ≤ bc with some b > a. Thus for large but finite c we expect large but finite number of glue groups satisfying bc ≥ |G| 1/2 ≥ ac. This form of the bound on |G| is merely a guess; the important point here is the expectation that the problem of identifying the code with largest generalized Hamming distance can be reduced to an optimization problem over a finite set. Of course even for moderate c naive brute-force approaches such as going through all possible codes very quickly becomes unfeasible. The resulting optimization problem over a discrete set would be NP-hard, but novel quantum platforms promise an exciting hope of solving medium-sized discrete optimization problems in real time, the avenue we hope to pursue in the future [27].
To conclude, we would like to point out another very important direction for future work -to extend the connection between codes and CFTs beyond the Narain theories. and α is some scalar factor. Using GL(2, Z) transformations, together with an appropriate rotation and rescaling, we can bring τ to belong to fundamental domain |τ 1 | ≤ 1/2, τ 2 ≥ 0, |τ | ≥ 1. (1.2) In this case the shortest vector is α(1, 0) T and its norm is α 2 . From (1.1) we find α 4 = detg 2 /τ 2 2 and from (1.2) we know τ 2 2 ≥ 3/4. We therefore find the bound which in many cases is conservative. Applying that to (2.30) we obtain (2.31).