Non-rational Narain CFTs from codes over $F_4$

We construct a map between a class of codes over $F_4$ and a family of non-rational Narain CFTs. This construction is complementary to a recently introduced relation between quantum stabilizer codes and a class of rational Narain theories. From the modular bootstrap point of view we formulate a polynomial ansatz for the partition function which reduces modular invariance to a handful of algebraic easy-to-solve constraints. For certain small values of central charge our construction yields optimal theories, i.e. those with the largest value of the spectral gap.


Introduction
Narain theories, two-dimensional conformal theories of free fields compactified on a multidimensional torus, have enjoyed renewed attention recently. Both in the context of holographic correspondence and the modular bootstrap program, Narain theories play the Goldilocks role of theories rich enough and simple enough to be studied. Holographically, the emphasis is on the bulk description of the ensemble of Narain theories [1][2][3][4][5][6][7][8]. As a parallel development, the spectral gap of Narain theories has being studied numerically using the modular bootstrap approach [1,9,10]. In both cases, the hope is that lessons learned for Narain theories, which exhibit U (1) n ×U (1) n symmetry, will be relevant for the conventional "Virasoro" CFTs without extended symmetries. Two years ago spinless bootstrap constraints for theories with U (1) n × U (1) n symmetry were shown in [9] to reduce to linear programming bounds of Cohen and Elkies on the density of sphere packings [11]. This remarkable result establishes a connection between 2d CFTs and a well-known problem in discrete mathematics. More recently, a certain family of Narain theories was found to be related to quantum stabilizer codes [12,13]. These developments are conceptually similar. First, in both cases a subset of modular bootstrap constraints reduces to a well-known problem, the linear programming bounds of [11] in the case of sphere packings and those of Calderbank et al. in the case of quantum codes [14]. Second, the problems of maximizing the CFT spectral gap, sphere packing density, and code Hamming (or other appropriate) distance are qualitatively similar, which can be utilized e.g. to shed light on holographic properties of Narain theories [14]. We further elucidate this point below.
In the context of classical codes, a central unsolved problem is of finding codes [n, k, d] of fixed length n and rank (encoding code capacity) k with the maximal possible Hamming distance d. Such codes are called optimal. The asymptotic value of maximal d/n for fixed k/n and n → ∞ are not known. Maximal d is constrained by linear programming bounds. If a code saturates a linear programming bound it is called extremal [15]. An extremal code is automatically optimal but not vise versa. Historically in the context of double-even selfdual binary codes, for which k = n/2, extremal codes were defined as those saturating a particular analytic linear programming bound d = 4[n/24] + 4. As the linear programming bounds improved, some authors call the code extremal if it saturates any subset of necessary constraints -the nomenclature we follow. It is an open question if the optimal code(s) for n ≫ 1, say optimal double-even self-dual linear binary code(s) with n = 72, are extremal. A very similar situation and nomenclature applies to quantum codes.
For Narain CFTs, we propose to call a theory optimal if it maximizes the spectral gap for the given central charge c and extremal if it saturates (any subset) of the modular bootstrap constraints. A conjectural list of optimal theories for 1 ≤ c ≤ 8 was given in [1], together with optimal (densest) lattice sphere pickings in 2c dimensions, see table 1. A brief examination reveals that the picture for maximal spectral gap and sphere pickings is similar -for certain small dimensions optimal lattices are related to codes. This is most known for the densest sphere pickings in 8 and 24 dimensions, which are related to E 8 and Leech lattices (Hamming [8,4,4] and Golay [24,12,8] codes) correspondingly. But in fact for other dimensions optimal lattices are related to codes as well 1 [16]. For the Narain case, conjectural optimal theories with c = 3, 4, 5 from the Table 1 are the code CFTs associated with quantum stabilizer codes of [12,13]. Up to T-dualities such codes/CFTs can be parametrized by graphs on c = n nodes. For c = 3, 4, 5 the optimal theories are code CFTs associated with the fully connected graphs. Among them is the c = 4 theory, associated with the E 8 lattice understood as a Narain lattice, which saturates the numerical Virasoro bootstrap constraints and hence it is extremal and optimal among all 2d CFTs [1,9,17].
All optimal theories from table 1 exhibit "quantized" spectrum, i.e. the conformal dimensions of U (1) c × U (1) c primaries are integer in some appropriate units, where ∆ * may be irrational. This hints optimal theories beyond c = 3, 4, 5 might be related to codes as well. In this paper we introduce a novel construction, complementary to the construction of [12,13] which maps a certain class of isodual codes over F 4 , which we call c ∆ 1 theory/lattice Barnes-Wall codes of N-type, to a family of Narain CFTs. We will call these theories code CFTs. The spectrum gap of code CFTs is quantized in the units of ∆ * = 1/ √ 3 which implies that these are non-rational theories [18]. This is quite remarkable given that code CFT partition functions exhibit a simple algebraic structure, hinting at a finite number of "characters." The spectral gap of a code CFT associated with the code C is given by where d is the Hamming distance of C. Using this construction, we will show optimal Narain theories from table 1 with c = 6, 7 are code CFTs.
Similarly to the case of [12,13] where the CFT torus partition function had a closed-form expression in terms of the code's enumerator polynomial, in the present case the partition function can be expressed in terms of extended enumerator polynomial W S , defined in equation (4.16), Here ψ x and ψ xy are particular Seigel theta functions defined in (4.19) and (4.20). Modular invariance of Z is guaranteed by the algebraic properties of W S , outlined in (4.26), (4.31).
In fact any polynomial W S satisfying those properties gives rise to a modular invariant Z, serving as a useful ansatz solving the modular bootstrap constraints. The paper is organized as follows. In section 2 we remind the reader the basics of codes and their relation to lattices. In section 3 we define the codes of N-type and construct an explicit map from these codes to Narain lattices. In section 4 we parametrize all N-type codes and calculate their Seigel theta series in terms of the extended enumerator polynomial W S . We also discuss algebraic symmetries of W S and how they are solved by a ring of invariant polynomials. Section 5 lists explicit examples, and in section 6 we construct the optimal theories for c = 6, 7 using N-type codes. We conclude in section 7.

Background
In this section we review relevant background for codes over F 4 and Narain CFTs. For a more detailed pedagogical introduction see [13].

Codes and lattices
A linear binary code C is a k-dimensional vector space in F n 2 over the field F 2 . The field F 2 = {0, 1} consists of two elements with the conventional operations and 1 + 1 = 0. In other words C is a set of 2 k binary vectors, also called codewords. Elements of codewords c ∈ C are called letters. The vector space F n 2 is equipped with the Hamming norm (weight) w(c) which evaluates the number of non-zero letters of c ∈ C ⊂ F n 2 . The Hamming distance of a code is defined as the minimal Hamming weight of all of its non-trivial codewords, A code C ⊂ F n 2 of size 2 k and Hamming distance d is said to be of type [n, k, d]. We define an inner product (·, ·) B for binary codewords in the obvious way: This allows us define a dual code C * as the vector subspace in F n 2 orthogonal to C, i.e. consisting of the binary codewords which are orthogonal to every codeword of C. A code is self-orthogonal if C * ⊂ C, and self-dual if C * = C. The simplest example of a self-dual code is the [2, 1, 2] "repetition" code consisting of two codewords, the trivial one c 0 = (0, 0) and c 1 = (1, 1).
A mapping from a code to a lattice is called a Construction. The most basic one is called Construction A: for additive codes over F 2 the lattice Λ(C) associated with the code C is given by The normalization by √ 2 is necessary to ensure the lattice of the dual code is just the dual lattice, Certain properties of the code C translate to the properties of the lattice Λ(C). In particular, if C is a self-dual code, then Λ(C) is a self-dual lattice. In addition, if C is an even code, then every vector of Λ(C) has integral norm-squared.
An additive code over F 4 is defined as a k-dimensional vector subspace C ∈ F n 4 . It consists of 2 k codewords and is denoted [n, k, d], where the Hamming distance d is defined as in (2.1) with the Hamming weight w(c) counting the total number of non-zero elements of c ∈ C. There are many different ways to define an inner product on F n 4 . Throught the paper we will use the Hermitian inner product All algebra is understood in the sense of F 4 and therefore (c 1 , c 2 ) is either zero or one. As in the case of binary codes, for codes over F 4 a dual code C * is defined as the vector subspace in F n 4 orthogonal to C with respect to the inner product (2.5). For a [n, k, d] code C, the dual code C * would be [n, 2n − k,d]. The simplest example of a self-dual code would be the [1, 1, 1] code consisting of a trial codeword C 0 = (0) and c 1 = (x) where x is either ω,ω or 1.
The algebraic properties of F 4 become apparent if we identify elements x ∈ F 4 with points on the complex plane. Namely 0, 1 ∈ F 4 are mapped to 0, 1 ∈ C, while ω,ω are mapped to e ±2πi/3 . Upon imposing the equivalence condition 2 x = 0 we obtain F 4 . This simple observation is the idea behind Construction A, which is a mapping from codes over F 4 to lattices. First, any element x ∈ F 4 can be represented as x = a ω + b ω where a, b ∈ Z 2 . This defines an invertible map, called Gray map, from F 4 → F 2 2 and codewords c ∈ C can be represented as binary vectors in F 2n 2 . The lattice associated with C is defined as For a self-dual code C, the corresponding lattice (2.6) is 3-modular [15]. If we further rescale it by 1/3 1/4 , the resulting latticẽ Λ(C) = Λ(C)/3 1/4 (2.7) will be iso-dual, in the sense that the dual lattice is related toΛ(C) by a π/2 rotation in each complex plane of C n [13]. More generally, for an arbitrary code (see appendix A.1 for a proof), and in (2.8) we abuse the notation by denoting both the lattice and its generating matrix by Λ(C). It should be noted that lattice generating matrix is not unique, an action by GL(2n, Z) defines the same lattice. Hence (2.8) could be understood either in the sense of the equivalence under GL(2n, Z) or that one can find representatives Λ * (C) and Λ(C * ) satisfying (2.8) as the matrix identity.
In the rest of the paper we will use somewhat different coordinates to representΛ(C) ⊂ R 2n . The first n coordinates will be the x-coordinates of the n complex planes of (2.6), while the last n coordinates will be the y-coordinates, (2.10)

Narain CFTs
Narain CFTs are theories describing compactificsation of n free scalars on a torus parametrized by a metric G and a B-field. Mathematically, each Narain theory is uniquely specified by a Narain lattice Λ, which is an even self-dual lattice in R n,n . With the conventional metric lattice vectors are usually denoted as (p L , p R ) ∈ Λ. The partition function of a Narain CFT on a Euclidean torus τ is given by It is convenient to introduce coordinates to (α, β) defined by In these coordinates the metric becomes (2.14) It is always possible to apply O(n) × O(n) transformations and choose a lattice generator matrix in the form (here and below we use Λ to denote both the lattice and its generator matrix) where γ * = (γ −1 ) T is the dual lattice to γ. The matrix γ generates the lattice which defines the compactification torus, G = γ T γ while B is an antisymmetric B-field. The form of Λ (2.15) is convenient because it manifests self-duality of Λ; as a matrix Λ ∈ O(n, n) and obeys and so the lattice is self-dual with respect to the metric g.
The central question of the modular bootstrap program is to determine the maximal value of the spectral gap among all theories with a particular value of the central charge c. For Narain theories, the question is about U (1) n × U (1) n primaries, i.e. the length squared of the shortest non-trivial lattice vector which one would like to maximize among all Narain lattices of the same dimension 2n = 2c.
3 Constructing Narain CFTs from codes over F 4 In this section we describe construction N, which maps certain codes over F 4 to Narain CFTs. As discussed in the section above, any code C over F 4 can be mapped to a latticeΛ(C) via (2.7). We might then expect that provided certain conditions on the code C are satisfied, the resulting lattice will be a Narain lattice with respect to a properly defined Lorentizan metric.

General construction
We start by discussing the most general case. Assume C is an additive code over F 4 of length n, and define its conjugate C to be the code C with each letter ω replaced by ω and vice-versa. Also defineΛ(C) ⊂ R 2n to be the lattice obtained via construction A from C and rescaled by 1/3 1/4 (2.10). An important element of the construction will be a permutation of the letters of the code. Define S to be a permutation of the letters which only permutes letters in pairs, S −1 = S. We can think of S as an n × n orthogonal integral matrix, which then obeys S = S T = S −1 . We denote by S(C) the code C where we have permuted the letters of each codeword according to S. We now claim the following.
Evenness. Each letter c i of a codeword c ∈ C can be written as for every c ∈ C, then the latticeΛ(C) is even with respect to the metric g S .
To use these claims to construct a Narain CFT from a code over F 4 it would be enough to show that g s is a Lorentizan metric with the signature (n, n) in R 2n . Indeed, g S is related to (2.14) by a similarity transformation, The lattice OΛ(C) is then even and self-dual with respect to g, and hence defines a Narain CFT.
Construction N specifies a certain class of codes over F 4 satisfying Self-duality and Evenness. We will call such codes "N-type codes", and corresponding CFTs obtained via this construction "code CFTs". Since permutation and conjugations are transformations from the code automorphism group [14], N-type codes are isodual [n, n, d] codes over F 4 . Before we proceed to prove the claims, let us explain why the pairwise permutation S can not be easily generalized to an arbitrary permutation. The condition S 2 = 1 is crucial for the metric (3.1) to satisfy g 2 S = 1, a necessary condition provided g S is related to g by an orthogonal transformation.
Let us prove the claims. We start with Self-duality. Following (2.8), the dual latticeΛ * is related toΛ byΛ 3) We will abuse notation and denote byΛ also the generator matrix for the latticeΛ, in which caseΛ * = (Λ −1 ) T . Then we can interpret (3.3) as matrix multiplication. where Specifically, P (n) performs a conjugation in each complex plane, while σ interchanges n complex planes according to the permutation S. Note that O n π/2 P n = g = 1 n 1 n , (3.6) and that g commutes with S. Then we have found Next we prove Evenness. The norm of a lattice vector v ∈Λ(C) is Vector v can be also written as an n-dimensional complex vector with the coordinates v i = for any codeword c, which is exactly our assumption (3.2).

Simplified construction for self-dual codes
The general construction simplifies for self-dual codes C = C * . Then the condition described above reduces to the following one: the latticeΛ(C) = Λ(C)/3 1/4 is a Narain lattice with respect to the Lorentzian metric g.
The construction N ′ is equivalent to construction N (with a trivial permutation S = 1) when it applies. To prove the claim we first show thatΛ is even. The condition Evenness in this case reduces to for all codewords. Since a i , b i ∈ {0, 1}, we can set (a i ) 2 = a i and similarly for b i . Also note, if the letter c i is equal to 1, it has a i = b i and so it does not contribute to this sum, so that (3.13) can equivalently be reformulated as (3.12). To finish the proof, we must show the lattice is also self-dual with respect to g. Since C is self-dual, to reduce it to Self-duality, it would be enough to show that C = C. Indeed it can be shown that any self-dual code that obeys (3.12) is invariant under conjugation, see appendix A.2.

Universal properties of code CFTs
There are universal properties which are common to all N-type codes and code CFTs obtained via construction N. We describe them below.

The binary subcode
For any code C over F 4 , we can define its binary subcode C B ⊂ C which consists of only those codewords whose letters are either 0 or 1, so that For N-type codes, this will be some linear [n, k, d B ] binary code, for some k, d B ∈ N. This subcode is usually much easier to study than the full code, and so it is useful to discuss its properties in some detail.
As a reminder, we use (·, ·) to denote the standard Hermitian inner product over F 4 in equation (2.5) and (·, ·) B to denote the standard binary inner product over F 2 in equation (2.2). In addition, we will define an additional inner product (·, ·) B,S which denotes the binary inner product combined with the permutation S, i.e. (c 1 , c 2 ) B,S = (c 1 , S(c 2 )) B for binary codewords c 1 , c 2 ⊂ F n 2 . Now consider some N-type code C ⊂ F n 4 , with C B being its binary subcode. Denote by C * B its binary dual with respect to the standard binary inner product (·, ·) B . Then we prove this equation in appendix A.3. It can be also shown C * B is even with respect to the inner product (·, ·) B,S , see appendix A.4.
We can use this result to show that a certain codeword must always be part of C. By rearranging letters in our code we can always bring the pairwise permutation S to the form where σ x = 1 1 . S acts trivially on the first m letters and permutes the last n − m letters in pairs (n − m must be even). Now, consider the codeword β = (1 m , 0 n−m ). Note that since C * B is even with respect to the inner product (·, ·) B,S , this implies (β, c) B ≡ 0 (mod) 2 for every c ∈ C * B . Therefore β ∈ C B ⊂ C, and so β = (1 m , 0 n−m ) must always be a codeword of our code C.
In the simpler case when we use construction N ′ , the code C always contains the codeword b = (1 n ), so that C * B is even. In addition, in this case the dual binary subcode is self-orthogonal with respect to the usual inner product (·, ·) B , so that C * B ⊂ C B ⊂ C.

Bounds on the spectral gap
There are universal bounds on the spectral gap of any lattice obtained via construction N from a code C ⊂ F n 4 . Since the Narain lattice is given by a construction A lattice from some code (up to a rescaling by 3 1/4 ), the spectral gap is always given by (1.1): For example, the lattice always includes the vector (2, 0, ..., 0)/3 1/4 , and so ∆ 1 ≤ 4 2 √ 3 . For codes with large n, it is hard to find the Hamming distance d. However, there are simpler bounds on ∆ 1 which can be obtained. For example, the binary subcode of C is usually much simpler than C itself, and d B = d(C B ) is an upper bound on the hamming distance Similarly, we found above that if the permutation S keeps m > 0 letters invariant, the code includes a codeword with m ones and zeros otherwise. This gives an upper bound on ∆ 1 ≤ m 2 √ 3 . When the code is self-dual the bound is stricter. In this case C * B itself is also a subcode of C, and therefore its Hamming distance also imposes an upper bound on the spectral gap, so that in addition to the bounds discussed above, we also have d(

Generator matrices for code CFTs
First we note that the lattice 3 1/4Λ (C) is the construction A lattice obtained from a code over F 4 , see (2.10). As a result, each vector (3 −1/4 v, 3 1/4 u) ∈Λ(C) must have the following property: u i , v i for each i are simultaneously integer or half-integer. This follows from the image of the elements x ∈ F 4 via Construction A, which maps 0, 1, ω, ω to (u, v) = (0, 0), (1, 0), (−1/2, 1/2), (−1/2, −1/2) respectively. Accordingly, the description of all lattices associated with codes via Construction N is as follows. A Narain lattice with every vector can be unambiguously mapped back to an N-type code. Permutations of letters, at the level of lattices, are the T-duality transformations permuting coordinates u i and v i . There are other T-duality transformations, namely orthogonal transformations O L × O R , which commute with the metric g S and preserve the condition (4.6). In case of [13] all T-dualities, at the level of codes were code equivalences. We leave open the question if this is also the case for the codes/theories of N-type. Furthermore, in the case of binary stabilizer codes, they and corresponding theories can be parameterized by graphs, with the T-duality inducing equivalence conditions on the latter. It would be interesting to develop an analogous formalism for the codes of N-type. We take first steps in this direction below. We show that for N-type codes, the corresponding lattices and hence code theories can be effectively parametrized by a handful of matrices satisfying simple constraints. This is essentially a generalization of the "canonical form" applicable both to codes and associated lattice. To derive it, we start by reminding basic properties of the Narain lattices. Every Narain lattice Λ which is even and self-dual with respect to the metric g admits a generator matrix of the form where γ * = (γ −1 ) T is the dual lattice to γ and B is an antisymmetric matrix. Now, since then if Λ is even and self-dual with respect to g, then Λ ′ = 1 n S Λ 1 n S is even and self-dual with respect to g S , and vice-versa. Thus we learn for every latticeΛ(C) obtained via construction N, the generator matrix can always be brought to the form For convenience, we will redefine γ and B such that the generator matrixΛ(C) takes the form We may now use lattice equivalences to bringΛ(C) to the simplest form possible, by bringing γ * , γ and B to their "canonical" forms. We perform this analysis in appendix B. The result is that the generator matrix Λ for a code theory associated with a given pairwise permutation S can always be brought to the form (4.10), where γ * , γ, S and B are given as follows: • γ * is obtained by taking the generator matrix for the construction A lattice obtained from the binary subcode C B ⊂ C via (2.3), and further multiplying it by √ 2. The binary subcode is an [n, k, d B ] linear code, and so γ * can always be brought to the form for some k × (n − k) matrix b which takes values in {0, 1} and which completely specifies the binary subcode. This means that (4.12) • After putting γ * into this form, S is not necessary in the canonical form (4.3); instead, it is equivalent to the form (4.3) up to permutations of the rows and columns. Thus, S is some matrix whose elements are 0, 1 and which obeys S 2 = 1 and S T = S. We can represent S as a block matrix: where S 11 is an (n − k) × (n − k) matrix, and S 22 is k × k.
In addition, due to the constraint (4.6), we must havẽ This is a complicated constraint in general. But if we focus on the diagonal, we find that sinceB is antisymmetric, this reduces to the constraint that the matrix (1 n−k |b T )S 1 n−k b has 0's on the diagonal. This means that the code C B must be even with respect to the inner product (·, ·) B,S , which was indeed proven to be the case in section 4.1.1.
To summarize, we have found that generating matrices for code CFTs obtained via construction N are completely fixed in terms of the given permutation S (i.e. a matrix whose elements are 0, 1 and which obeys S 2 = S T S = 1), along with a k × (n − k) binary matrix b and an antisymmetric integral (n − k) × (n − k) matrixB defined mod 4 and obeying (4.15). In terms of these matrices, the matrix γ * is given by (4.11), B is given by (4.14), and the full generator matrix is given by (4.10).
We thus have a full classification of all possible generator matrices, and so one can find all code CFTs, up to T-duality, by generating all possible building blocks S, γ * ,B obeying these constraints. Specifically, the procedure is the following. Start by choosing a k × (n − k) matrix b which takes the values 0 or 1, which specifies γ * using (4.11). Next, choose a permutation matrix S. This is an n × n symmetric matrix which obeys S 2 = S T S = 1 and takes the values 0 or 1, such that in every row and column exactly one element is nonzero. This defines a permutation of the bits. Finally, we must choose a matrixB. This is an (n − k) × (n − k) integral antisymmetric matrix defined mod 4. This matrix must also obey the condition (4.15). Since we have already chosen b and S, this constraint can be easily solved, and allows for two choices for the value of each element ofB. Specifically, if the corresponding element is zero mod 2, then the element ofB can be 0 or 2. Otherwise, the element ofB can be 1 or 3. Finally, we discuss the simplifications that occur for the construction N ′ . In this case, S = 1 n and so in equation (4.13) we find S 11 = 1 k , S 22 = 1 n−k and S 12 is the zero matrix. The main simplification is in the constraint (4.15). Using the fact that the dual of the binary subcode C * B is self-orthogonal in this case, the constraint reduces simply to the requirement that the elements ofB must be even. Thus to generate all code theories of this type we choose b as above, and in addition choose an (anti)symmetric (n − k) × (n − k) matrixB which is defined mod 4 and can take only even values.

Partition functions
The partition function of a code CFTs is related to enumerator polynomial of the corresponding code C, similarly to the discussions in [13]. However, our construction relates the partition function to an extended enumerator polynomial W S which depends on the permutation S. W S is defined for a pair: a code and the pairwise permutation S. It is a polynomial in 14 variables: where ′ x,y means that only ordered pairs (x, y) are included in the product. We thus have 4 variables t x and 10 variables t xy (because of symmetry t xy = t yx ). w x (c) counts how many non-permuted letters x ∈ F 4 appear in each codeword c, while w xy (c) counts how many pairs of letters (x, y) are permuted into each other. In the case of a trivial permutation S = 1, w xy = 0 for all codewords, and W S C reduces to the standard full enumerator polynomial W ({t x }).
The partition function (2.12) of a code CFT can be written in terms of W S , where the ψ's are defined as follows. We define k = (k 1 , k 2 ) ∈ Z 2 , and define g(x) for x ∈ F 4 to be the Gray map: In the language of the condition (3.2), we have x = a x ω + b xω and g(x) = (a x , b x ). Then where , and we have written τ = τ 1 + iτ 2 for τ 1 , τ 2 ∈ R. Now we would like to verify modular invariance of the partition function (4.17). First we discuss S-transformation τ → −1/τ . We start with Poisson resummation of a general theta-series of the form where Ω is an N × N matrix Ω and c is an N -dimensional vector. Using (4.22) and the fact that both Ω 2 , Ω 4 obey Ω −1 (τ ) = 4 π 2 Ω(−1/τ ) up to signs which can be removed by redefining some of the integers in the sum, we find transformations of the ψ's. To write them concisely we introduce auxiliary variables as well as (t 00 + t 11 + t ωω + t ωω + 2t ω0 + 2t ω0 + 2t 10 + 2t ω1 + 2t ω1 + 2t ωω ), In terms of these variables the analog of the MacWilliams identity takes the form Note that for S = 1 this reduces to the standard MacWilliams identity for codes over F 4 [15]. For the N-type codes satisfying C * = S(C) this yields We can now write down the transformation of the ψ's under τ → −1/τ . Transformations of ψ x are exactly the same as the transformation t x → t ′ x in (4.23), supplemented by the conjugation ω ↔ω, i.e. the interchange of t ω with tω etc. in the RHS of (4.23), and also multiplied by √ ττ . For example, compare with (4.23), Similarly, ψ xy transforms just like t xy in (4.24), supplemented by the interchange of ω, ω on the RHS and multiplied by τ τ . For example, compare with (4.24), ψ ωω (−1/τ ) = τ τ 4 (ψ 00 + ψ 11 + ψ ωω + ψ ωω + 2ψ ω0 + 2ψ ω0 − 2ψ 10 − 2ψ ω1 + 2ψ ω1 − 2ψ ωω ). (4.28) Due to these transformations, we can immediately check that the partition function is invariant under S-duality. Using the Macwilliams identity (4.26), we find Next, using the fact that W S C = W S S(C) (since a permutation does not change any of the weights w x , w xy ), and C * = S(C) for N-type codes, we find This ensures invariance of the CFT partition function (4.17) under the S-transformation. Next we discuss T-transformation τ → τ + 1. Looking at Ω 2 , Ω 4 , we find it acts on ψ x by introducing a phase, (a, b), and similarly ψ xy → exp(iπ(b x b y − a x a y ))ψ xy . Thus, the contribution from every codeword c corresponds to a phase exp iπ . Due to the evenness condition (3.2), this phase is always 1, and so the partition function is invariant under the T-transformation. This corresponds to the following symmetry of W S :

Classification of Enumerator Polynomials
We now attempt to classify the extended enumerator polynomials of the codes of N-type. In fact, our task is broader, it is to classify all homogeneous polynomials of 14 variables which are invariant under the S-transformation (4.26) and the T-transformation (4.31). In general, the two transformations generate a group G acting on the polynomials of 14 variables, and so we are looking for the ring of polynomials invariant under G. One can write down a generating function describing the dimension of the space of invariant homogeneous polynomials of degree n, called the Molien series Here R G n is the space of all polynomials of degree n invariant under G. Molien's formula (see e.g. [19]) gives a simple expression for this generating function: Here, |G| is the number of elements in G, and g is a 14 × 14 matrix acting on the individual variables. We start by classifying polynomials associated with codes of the simpler construction N ′ . In this case there is no permutation, and so W S reduces to the standard enumerator polynomial of 4 variables, W (t 0 , t 1 , t ω , t ω ) . The symmetry group G is generated by two matrices acting on the vector (t 0 , t 1 , t ω , t ω ) as follows M (r) = 1 (r − 1) 4 (r + 1) 3 (r 6 + 2r 4 + 2r 2 + 1) = 1 + r + 2r 2 + 2r 3 + 4r 4 + 4r 5 + 7r 6 + 7r 7 + ...
(4.37) The Molien series gives the total dimension of the space of invariant polynomials of degree n, yet we are interested in finding the generators of the polynomial ring invariant under G, i.e. those polynomials which cannot be written as a product of the lower-order ones. We denote by m ′ n the the dimension of the space of invariant polynomials of degree n which cannot be written as sums and products of lower-order invariant polynomials. Then m ′ n can be obtained using a recursion formula: Here P k denotes all integer partitions of k, and we are summing over all partitions apart from the trivial partition (k). In addition, w i (p) counts how many times the number i appears in the partition p.
In the case at hand the nonzero values of m ′ k are m ′ 1 , m ′ 2 , m ′ 4 , m ′ 6 , which are all equal to 1. This means the ring of invariant polynomials is generated by four polynomials of dimensions 1, 2, 4, 6. We can find them explicitly, (4.39) To conclude, any full enumerator polynomial of a code over F 4 which obeys the conditions outlined in construction N ′ can be written in terms of the four polynomials above. In particular, each p i corresponds to a specific N-type code, and we explicitly describe the codes for i = 1, 2, 4 in section 5. The code for i = 6 is also known, but not discussed in this paper.
We can now discuss the more general case of isodual N-type codes, for which permutation S is non-trivial. The symmetry group is again generated by two matrices T, S, which are now 14 × 14 matrices, and which again obey T 4 = S 2 = (ST ) 6 = 1. The group again consists of 48 elements, but the Molien series in this case is more complicated: (r − 1) 14 (r + 1) 6 (r 2 + 1) (r 2 + r + 1) 4 1 + 3r 2 + 12r 3 + 26r 4 + 30r 5 + 56r 6 + 58r 7 +60r 8 + 58r 9 + 56r 10 + 30r 11 + 26r 12 + 12r 13 + 3r 14 + r 16 . We emphasize that k here is not the length of the code, but is the order of the polynomial in terms of the variables t x , t xy . For example, at k = 1 this includes the polynomial t 00 , which corresponds to a code with n = 2.
There are two things to note here. First, even at small k there are many generators of this ring. Second and more surprising, there are now also negative values of m ′ k . This means the generators of the ring are not independent, and in fact there are relations between them. To the extent of our knowledge, this is the first example when the ring of invariant polynomials associated with the class of codes is not a freely generated one, but involves non-trivial relations between generators. The first relation occurs at order k = 5 and involves many dozens of polynomials of smaller degree. It is way too cumbersome to be written down here.
To conclude the discussion, we write all independent enumerator polynomials for n = 2 codes (of course the choice of independent polynomials is ambiguous). Without permutation, i.e. with S = 1, there is only one such polynomial, which is just p 2 defined above. Next, we consider the permutation of the two bits. The corresponding polynomial is of degree one, i.e. it has k = 1, and so we must look at m ′ 1 which is equal to 4. This includes all possible polynomials of degree one, including those without a permutation, and so we must subtract polynomials without a permutation, of which there is onep 1 defined above. Thus, there should be three independent invariant polynomials of degree k = 1 involving a permutation of two letters: q 1 =t 00 + t 11 + 2t 01 , q 2 =t 00 + t 11 + 2t ωω , q 3 =t 00 + t 0ω + t 0ω + t ωω .

Simple examples
In this section we describe a number of examples of using the constructions N and N ′ , including an explicit form for the generator matrices for the corresponding Narain CFTs.

Binary codes over F 4
Define the code B n = F n 2 over F 4 , i.e. B n includes all possible codewords whose elements are either 0 or 1 (in particular, B n is equal to its own binary subcode). Its enumerator polynomial is This code is an N-type code for any choice of permutation S, and so for any S we can use Construction N to generate a Narain CFT from it. We note that for any n, B n is the unique N-type code whose letters are all either 0 or 1. 2 The latticeΛ(B n ) obtained via construction N includes all n-dimensional vectors of the We can construct its generator matrix explicitly following section 4.2. There we demonstrated that the generator matrix can be brought to the formΛ with γ * the generator matrix of the construction A lattice of the binary subcode of B n multiplied by an additional factor √ 2. In our case, and we can use T-dualities to set B = 0 by adding columns of γ * 0 with γ * = 1 n to . The generator matrix is thus especially simple and takes the form The spectral gap is always

Codes with n = 1
We now describe all N-type codes with n = 1. There is only one such code, which is the binary code discussed in 5.1: with enumerator polynomial p 1 = t 0 + t 1 and the generator matrix, up to T-dualities, is Corresponding theory is a compact boson at radius R = √ 2 3 1/4 , which is a non-rational theory.

Codes with n = 2
We now describe all N-type codes with n = 2 up to the automorphisms discussed in section 4.3. At n = 2, there are two options for pairwise permutations: no permutation and the permutation interchanging the two letters. We discuss each one separately.

No permutation
If there is no permutation, then there are two N-type codes (and for both we can apply the simple construction N ′ instead of the general one). One is the binary code B 2 defined in 5.1, with enumerator polynomial p 2 1 = (t 0 + t 1 ) 2 . The other code is It has enumerator polynomial This code is self-dual and has w ω (c) = w ω (c) for every codeword c, and so we can apply construction N ′ to construct a Narain latticeΛ(C 2 ) from it. The generator matrix takes the formΛ where γ * is the generator matrix of the construction A lattice of the binary subcode of C 2 times √ 2, γ is given by γ = (γ * −1 ) T , and B takes the form outlined in the equation (4.14) with S = 1. We now construct this generator matrix explicitly.
First we find γ * . The binary subcode of C 2 is {(0, 0), (1, 1)}, and so γ * can be brought to the form In particular, comparing γ * to the canonical form (4.11), we find that b = 1. Next we study the matrix B. Following equation (4.14), it must take the form withB being an antisymmetric 1 × 1 matrix. This meansB = 0, and so the final form of the generator matrix isΛ The spectral gap of this CFT is ∆ 1 = 1 √ 3 .

With a permutation
If we include a permutation of the two letters, there are four N-type codes up to automorphisms: Their extended enumerator polynomials are W S (B 2 ) = q 1 = t 00 + 2t 01 + t 11 , W S (C 2 ) = q 2 = t 00 + t 11 + 2t ωω , W S (C 2 ) = q 3 = t 00 + t 0ω + t 0ω + t ωω , (5.14) We can find the generator matrices of the corresponding Narain lattices: The spectral gaps of these CFTs are respectively 3 .

(5.16)
We would like to note that B 2 in (5.13) is exactly the same as in the section 5.3.1, but its extended enumerator polynomial is different: p 2 1 and q 1 . This is because this code is invariant under permutations and, ammended with different S, gives rise to different CFTs.

Constructing optimal CFTs
In this section we construct the hypothetical optimal Narain CFTs with the central charges c = 6 and c = 7. Both of these were found in [1]. For c = 6, there is an obvious guess for the code associated with it. The corresponding Narain lattice is the Coxeter-Todd lattice understood as a Lorentizan lattice; the latter is known to be related to the hexacode -the unique self-dual [n, k, d] = [6,3,4] code over F 4 . For c = 7 the code we find is less well-known, and we dub it the "septacode." Finally, we discuss optimal CFTs at other values of central charge and their possible relations to codes.

c = 6 and the hexacode
Consider the hexacode H, which is a linear 3 [6, 3, 4] code over F 4 . We can choose the generating matrix to be [16] The hexacode is even and self-dual. Its Hamming distance is d(H) = 4, and its binary subcode is The corresponding construction A lattice Λ(H) is the Coxeter-Todd lattice K 12 [16].
We now show that we can apply construction N to the hexacode with a permutation S that permutes the last two letters, so that the latticeΛ(H) = K 12 /3 1/4 is a Narain lattice. The extended enumerator polynomial of the hexacode with respect to this permutation is 3) The hexacode obtained using the generating matrix (6.1) obeys H = S(H), where S interchanges the last two letters, and so using Self-duality we find thatΛ(H) is self-dual with respect to the metric g S (3.1). One can check explicitly that the hexacode obeys Evenness conditions with the same permutation S, and soΛ(H) is also even with respect to the metric g S . H is thus an N-type code, and so using construction N we find thatΛ(H) is a Narain lattice. The corresponding spectral gap is ∆ 1 = 4/3, which was conjectured in [1] to be the maximal value for Narain CFTs with c = 6. Indeed, the Narain lattice discussed there is just the Coxeter-Todd lattice rescaled by 3 1/4 . We thus have reproduced the optimal Narain CFT at c = 6 using construction N.
Explicitly, the generator matrix of the Narain lattice can be brought to the form (4.10) with (6.5) and where the permutation matrix S is different now, and is given by i.e. it interchanges the fourth and fifth letters. We note that representation of the lattice above is different from that one in [1], but must be related to it by a O(6) × O(6) transformation.

c = 7 and the septacode
The conjectured optimal Narain CFT with c = 7 has spectral gap ∆ 1 = 4/3 [1]. We note there are no n = 7 self-dual codes over F 4 with d = 4, and that the maximal Hamming distance in this case is d = 3 [14]. Should we want to use our construction to obtain optimal c = 7 CFT from a code, we must therefore consider isodual codes, with C * = S(C). It turns out this only requires C * = C, i.e. one can take S = 1.
Consider the n = 7 code C 7 generated over F 2 by the matrix 1 ω 0 0 0 1 0 1 1 ω 0 1 0 0 1 0 0 ω 1 1 1 1 1 0 1 ω 0 1 1 0 1 1 1 ω 0 We will call this code the "Septacode". The septacode is additive but not linear, it has 2 7 elements and its Hamming distance is d = 4. Its enumerator polynomial is Its binary subcode is so C B is just the n = 7 binary repetition code. In addition, the septacode obeys and so in particular it obeys Self-duality with a trivial permutation S = 1. It is also simple to check it obeys the Evenness conditions. It is thus an N-type code, and we can use construction N to obtain a Narain latticeΛ(C 7 ) from it. Let us construct the generator matrix for the Narain lattice explicitly, following section 4.2. The generator matrix is given by the general form (4.10) with S = 1. γ * is the generator matrix for the construction A lattice of the binary subcode C B ⊂ C (times √ 2), so in the case at hand it is γ * = 2Z 7 ∪ 2Z 7 + (1, ..., 1) = 2D * 7 . (6.11) We can bring this to the standard form of As discussed above, B can be brought to the form withB being some integral antisymmetric matrix. In the case at hand we find This is the same lattice as was found in [1], the generator matrices are identical. So we have found that the conjectural optimal Narain CFT with c = 7 and ∆ 1 = 4/3. can be obtained from an N-type code using construction N. We have checked, there are no other [7,7,4] N-type codes besides this one.

Other central charges
Having found that the optimal Narain CFTs for c = 6, 7 are code CFTs, we move on to the case c = 6, 7. As we now explain, we do not expect to be able to obtain an optimal Narain CFTs using construction N for any other values of c.
First we discuss c < 6. The corresponding optimal Narain CFTs were oullined in [1] (see table 1). These CFTs cannot be reproduced from a code using construction N, since the spectral gap for any lattice obtained via construction N must take the form ∆ 1 = n 2 √ 3 for some n ∈ N, and this is not the case for any of the optimal CFTs for c < 8, c = 6, 7. For c > 7, we again do not expect to be able to obtain optimal CFTs due to the bound ∆ 1 ≤ 2/ √ 3. This bound is saturated for c = 6, 7, while for c = 8 the optimal CFT has ∆ 1 > 2/ √ 3. Since we expect ∆ 1 to be an increasing function of c, we conclude it would be impossible to construct any optimal c > 7 CFT using the construction developed in this paper.
However, it is possible that other constructions can reproduce optimal CFTs at other values of c; indeed, the optimal CFTs with c = 3, 4, 5 are related to codes and follow from the construction of [13]. That construction maps codes over F 4 to Narain CFTs, and for c = 3, 4, 5 the optimal Narain lattices have the generator matrix (2.15), with 1 √ 2 γ * = √ 2γ = I and with the B matrix corresponding to a fully connected graph on c nodes, B ij = 1 for i > j. In general, we expect that all CFTs from the table 1 can be reproduced using codes; for example, the c = 8 lattice is the Barnes-Wall lattice, which can be related to a code over F 9 [16].
An important step would be to develop a sequence of constructions which would yield optimal theories for larger values of c. On this path, the first step may not even be the explicit relation to codes, but a new algebraic ansatz for the partition function along the lines of (4.17), amended with the analogs of the algebraic conditions (4.31,4.26), which would ensure modular invariance.

Conclusions
In this paper we constructed a mapping from the family of codes over F 4 which satisfy the conditions of Evenness and Self-duality to the space of Narain theories. We call codes satisfying these conditions N-type and the corresponding CFTs code theories. Starting from an Ntype code we explicitly construct the Narain lattice and evaluate its theta-series, i.e. the corresponding CFT torus partition function, in terms of the code's extended enumerator polynomial, see (4.16) and (4.17). Modular invariance of the partition function reduces to the algebraic identities (4.26) and (4.31), which can be solved in terms of invariant polynomials, as discussed in section 4.3.1. Quite interestingly, the associated ring of invariant polynomials is not freely generated, in contrast to other known examples [15]. All N-type codes can be parametrized by a binary classical code, specified by matrix b, a pairwise permutation matrix S and an antisymmetric matrixB obeying (4.15). As a result we could construct all codes of small length n and found many interesting examples. In particular, we found that the conjecturally optimal Narain theory with c = 6, based on the rescaled Coxeter-Todd lattice, also known as K 12 , understood as a Narain lattice [1] is associated with the Hexacode, the unique [6, 6, 4] self-dual code over F 4 . Furthermore, the conjecturally optimal Narain theory with c = 7 is associated with the "septacode" introduced in section 6.2, the unique [7,7,4] N-type code.
Our construction is similar in spirit to previous works relating classical codes and chiral theories [20][21][22] as well as those relating quantum codes to Narain CFTs [12,13]. At the same time there are important novelties which we would like to emphasize. This is the first construction, to our knowledge, that maps codes to non-chiral non-rational theories. A natural question to ask is how general the relation between codes and CFTs could be. In all known examples of code theories the partition function is a sum of a handful of "characters" suggesting the theories in question are rational. Now we clearly see this is not necessarily the case. It thus remains an open question to chart the space of theories with the code counterparts, see [23], and investigate if this relation can be extended beyond Narain theories.
Among the code theories constructed in this paper are the conjecturally optimal Narain CFTs, i.e. those with the largest value of spectral gap, for c = 6, 7. Together with the construction of [13] we find that the optimal theories for 3 ≤ c ≤ 7 are related to codes. This is likely to be true for c = 1, 2 and c = 8 as well: in the former cases the partition function is a sum of "characters" and in the latter case the lattice is the Barnes-Wall lattice, which can be constructed using a code over F 9 . More generally, any rational Narain CFT can be related to codes [23], and this likely extends to any finite CFT [24]. This observation prompts the question if the optimal theories for larger c could also be related to codes and if perhaps there are appropriate series of constructions which could describe optimal theories with an arbitrarily large central charge. This question can be reformulated in terms of the modular bootstrap program. The present construction, as well as that one of [12,13], reduce the modular bootstrap constraints to algebraic constraints at the space of polynomials. While the present construction is somewhat nontrivial and involves polynomials of 14 variables, the core idea remains the same. The modular bootstrap becomes the question of identifying invariant polynomials and applying straightforward linear algebra. The question we would like to pose is to formulate a continuous or large discrete family of the appropriate Ansätze which would reduce the question of maximizing the spectral gap to the question of identifying the optimal algebraic identity and the "characters" such that the optimal partition functions for various c would be given by some appropriate generalization of (4.17). We hope to address the question of formulating such a meta-bootstrap approach in the future.
A.2 Proof that a self-dual code with w ω (c) − w ω (c) = 0 (mod) 4 is invariant under conjugation We want to prove the following: assume C is a self-dual code over F 4 and ∀c ∈ C, Here w x (c) is the number of letters in c which are equal to x ∈ F 4 . We want to prove that P(C) = C.

A.3 Proof of the expression for the dual binary subcode
Consider an N-type code C with a binary subcode C B . Define where we used the fact that C * = S(C). Then we would like to show that T = C * B , where C * B is the dual of C B with respect to the conventional binary inner product ( , ) B . To show this, we will prove T * = C B . First show T * ⊂ C. Take b ∈ T * ∈ F n 2 , c * ∈ C * , then it is enough to show that (b, c * ) = 0. where we used b = b and the fact that c * + c * ∈ T . So T * ⊂ C. Next we show that all binary codewords in C are also in T * . take binary c ∈ C, and take c * + c * ∈ T for c * ∈ C * . Then since c * ∈ C * . So any binary c ∈ C is also in T * . So we have proven that T * = C B .

A.4 Proof that C * B is even
We now show that C * B is even with respect to the inner product (·, ·) B,S for an N-type code C. Take b ∈ C B , then b = S(c + c) for c ∈ C. Then since C ⊥ = S(C) due to Self-duality, the term (c, S(c)) vanishes. We are left with showing that (c, S(c)) is 0 mod 2. Note that (using the notation around (3.2)), which vanishes due to (3.2), as required.

Appendix B The generator matrix
The generator matrix for the Narain lattice is given by This Λ ′ is self-dual with respect to g ′ . Note that we can also write this as Now we can try to find the minimal form for γ * , B. Note that in (B.2), we can ignore the matrix on the RHS since it is in GL(2n, Z). We will now simplify the matrix by adding certain columns of the matrix to other columns, which amounts to multiplying on the right by elements of GL(2n, Z).
First, since the columns involving γ * correspond to elements of Z[ω] which are only elements of Z, we find that the columns of γ * (mod) 2 correspond to binary codewords. In addition, no other column can correspond to a binary codeword, and so all binary codewords can be generated by the columns of γ * . We thus learn that γ * must be the generator matrix of the construction A lattice of the binary subcode C B ⊂ C. As a result, γ * can be brought to the form where b T is an (n − k) × k matrix. We immediately find (by definition) So the explicit form for the generator matrixΛ is and we get We have thus effectively set B 22 = 0, and we are close to setting B 12 = b T S 22 − S 12 . To finish, write 1 2 (B 11 − B 12 b) − b T Y 2 explicitly: Define the antisymmetric matrix then we find This finally allows us to set B 12 = b T S 22 − S 12 , in which case To summarize, our final result is where B 12 = b T S 22 − S 12 . Comparing to the general form we started with, we find that we can always bring B to the form withB an integral antisymmetric matrix.