Narain CFTs and Quantum Codes at Higher Genus

Code CFTs are 2d conformal field theories defined by error-correcting codes. Recently, Dymarsky and Shapere generalized the construction of code CFTs to include quantum error-correcting codes. In this paper, we explore this connection at higher genus. We prove that the higher-genus partition functions take the form of polynomials of higher-weight theta functions, and that the higher-genus modular group acts as simple linear transformations on these polynomials. We explain how to solve the modular constraints explicitly, which we do for genus 2. The result is that modular invariance at genus 1 and genus 2 is much more constraining than genus 1 alone. This allows us to drastically reduce the space of possible code CFTs. We also consider a number of examples of"isospectral theories"-- CFTs with the same genus 1 partition function -- and we find that they have different genus 2 partition functions. Finally, we make connection to some 2d CFTs known from the modular bootstrap. The $n = 4$ theory conjectured to have the largest possible gap, the $SO(8)$ WZW model, is a code CFT, allowing us to give an expression for its genus 2 partition function. We also find some other known CFTs which are not code theories but whose partition functions satisfy the same simple polynomial ansatz as the code theories. This leads us to speculate about the usefulness of the code polynomial form beyond the study of code CFTs.


Introduction
There is a fascinating relationship between error-correcting codes (ECCs) and two-dimensional conformal field theories. This relationship was first explored in the context of classical binary codes -codes over F 2 -which are related to chiral meromorphic CFTs. Any doublyeven self-dual code defines an even self-dual lattice by "Construction A" of Leech and Sloane [1], and such a lattice can be used to define a free meromorphic CFT by the work of Dolan, Goddard and Montague [2][3][4]. In this relation, also reviewed in [5], a code of length n provides an n-dimensional lattice, which gives rise to a meromorphic CFT of central charge c = n. The construction makes it extremely easy to compute the partition function of the resulting CFT. It takes the form (1.1) Here q = e 2πiτ for the modular parameter τ , η(τ ) is the Dedekind eta function and θ i (q 2 ) are Jacobi theta functions. The function W (x 0 , x 1 ) is the so-called enumerator polynomial, a central object of this paper. It is trivially computable given the codewords defining the code. The conditions required for the partition function to be modular invariant (up to phases) follow immediately from simple properties of the code. These are the so-called MacWilliams identities [6] 1 (1. 2) The construction above is naturally extended to higher genus, where the generalized Mac-Williams identities acting on the higher-weight enumerator polynomial in 2 g variables guarantee genus g modular invariance of the corresponding partition function [7]. The upshot is two-fold: firstly, since the enumerator polynomial is directly computable from the code, one gets immediate access to higher-genus partition functions of code CFTs; secondly, since the classification of the involved entities -codes, lattices and CFTs -is incomplete, 2 the enumerator polynomial form provides a simple way to analyze modular invariance as linear relations. 1 Technically the MacWilliams identity of [6] refers to only the second transformation, while the first one follows from doubly-evenness. For convenience, we use the term "MacWilliams identities" to refer to both conditions. 2 The codes involved in the construction -binary double-even self-dual codes, also known as type II codes -have length n divisible by 8 and have been classified for n 40 [8]. The corresponding lattices (even self-dual lattices) and CFTs (meromorphic CFTs) have been classified for n = c 24 by [9] and [10] respectively.
Solving the constraints from higher-genus modular invariance amounts to characterizing the ring of invariant polynomials, which for genus g 3 determines the space of partition functions for meromorphic chiral CFTs via the theory of Siegel modular forms. 3 In [7], we showed that by imposing higher-genus modular invariance, the number of possible genus 1 partition functions of code CFT is greatly reduced. We also noted that there exist conformal field theories that do not derive from codes, but which still admit the "code enumerator form" of (1.1), however with non-negative and non-integer coefficients. This holds for instance for all of the 71 meromorphic CFTs at c = 24 classified by Schellekens [10].
In this paper, we turn to an interesting generalization of the above relation, namely between quantum error-correcting codes and non-chiral CFTs. This relation was spelled out in detail in [5]. The starting point is a class of quantum error-correcting codes known as stabilizer codes. These have an equivalent description in terms of classical codes over the finite field F 4 . In general, one can consider codes defined over any finite field F , and it has been shown recently that ternary codes, defined over F = F 3 , define N = 1 supersymmetric 2d CFTs [11]. Other work on the relation between error-correcting codes and conformal field theories include [12][13][14][15][16][17]. Interestingly, by the Gray map F 4 can be related to F 2 ⊕ F 2 , which is the first case of a series of constructions of Narain CFTs from codes over F p ⊕ F p for p prime [18].
Via the "New Construction A," a code over F 4 defines a Lorentzian lattice, on which a 2d non-chiral ("full") CFT can be defined by the construction of Narain [19,20]. Compared to the chiral case discussed above, there are now several differences. In the New Construction A, the central charge n = c =c can take any positive integer value, and the phases showing up in the modular constraints always cancel, rendering completely modular invariant partition functions of the form Z C (q,q) = W C (θ 3 (q)θ 3 (q) + θ 4 (q)θ 4 (q), θ 3 (q)θ 3 (q) − θ 4 (q)θ 4 (q), θ 2 (q)θ 2 (q)) 2 n |η(τ )| 2n , (1.3) where q = e 2iπτ andq = e −2iπτ . W C (x 0 , x 1 , x 2 ) is called the refined enumerator polynomial, to be defined below. On the other hand, this construction gives rise to a discrete set of CFTs, which lies inside but is not dense in the continuous Narain moduli space. For instance, in the simplest case of central charge n = 1, the unique equivalence class of quantum codes gives rise to the Narain CFT of the compact boson at the radius 1, whereas at c = 1, Narain CFTs can be defined for any compactification radius.
As in the chiral case, the partition function will be constructed by a sum over vectors in a lattice defined by the code, and it will be described in terms of higher-genus theta functions with known modular properties. The theory of such functions is less developed compared the chiral case, where indeed the theory of Siegel modular forms has led to strong constraints on meromorphic CFTs at low c [21][22][23][24][25]. Nevertheless, we shall see that the set of partition functions in the form dictated by (1.3) does capture some interesting theories also outside the class of code CFTs, 4 to be discussed more in section 5.3, which may hint at the possibility to develop a theory of non-chiral modular forms.
The main novelty of this paper is to generalize the relation between quantum ECCs and full CFTs to higher-genus partition functions. This amounts to writing down higher-weight enumerator polynomials suitable for codes over general fields. In general, for a field F , there is a natural construction of a weight-g enumerator polynomial in |F | g variables as a sum over g-tuples of codewords, see (3.28) below. For the case at hand, where F = F 4 , the genus 1 version was called the complete enumerator polynomial in [5]. However, we will see that the identical vanishing of some modular functions -at genus 1 manifested by θ 1 (q) = 0suggests the use of a refined enumerator polynomial in 2 g−1 (2 g +1) = 3, 10, 36, . . . variables. (In fact, the counting is the same as the number of even spin structures in the Riemann surface, familiar from higher-loop superstring computations.) We will give a complete description of this construction, and give many details at genus 2.

A puzzle with fake partition functions
One of our motivations to study the relation between quantum ECCs and full CFTs, was to resolve the following puzzle that emerged from the considerations at genus 1 in [5]. At genus 1, the refined enumerator polynomial for a code C is homogeneous degree n, in three variables, and can be written as a sum over all codewords (1. 4) where we think of the codewords c ∈ C as vectors with entries in the set {1, X, Y, Z}, and w t (c) counts the number of entries c i = t. 5 For codes to define CFTs, the enumerator polynomial defined in (1.4) must satisfy the generalized MacWilliams identities [6,[26][27][28][29], which is to say that W C (x 0 , x 1 , x 2 ) is invariant under and The work of [5] proposed to study solutions W (x 0 , x 1 , x 2 ) of (1.5)-(1.6) without explicitly constructing any quantum code. Combining these equations with the assumption that W (x 0 , x 1 , x 2 ) has non-negative integer coefficients, which must be the case for code CFTs, one finds a discrete set of solutions for each degree n. Only some of these solutions correspond to known codes. The simplest non-trivial example is at n = 3. In this case, [5] found (1.10) The six remaining polynomials also give rise to seemingly consistent partition functions with n = 3, which we denote as "fake partition functions." 6 These fake partition functions have enumerator polynomials in x i with non-negative integer coefficients and could therefore correspond to code enumerator polynomials. Furthermore, they have character decompositions with non-negative integer coefficients -both in Virasoro characters and U (1) c × U (1) c characters. For example, the latter decomposition takes the form (1.11) For instance, consider one of the fake theories, The first few degeneracies of U (1) c × U (1) c primaries for W fake read  This fake theory, like all fake theories found by examining solutions to the Macwilliams identities, have all non-negative integer degeneracies, so we cannot prove that they do not correspond to CFTs by genus 1 considerations alone. In this paper, we find that by considering the constraints from genus 2 modular invariance on code CFT partition functions, we can prove that a number of fake partition functions cannot be defined by errorcorrecting codes through New Construction A. This includes all six fake theories at n = 3.
Continuing to higher values of central charge n, we find that the higher-genus constraints will not rule out all fake partition functions, but drastically reduce their number.

Structure of this paper
The rest of this paper is structured as follows. In section 2, we review the construction of 2d CFTs from quantum error-correcting codes. This includes a number of elements. First we review classical codes over general fields, and how they can be used to define lattices and enumerator polynomials. Then we present the generalization to quantum codes. After giving a description of quantum error-correcting codes and an explanation of how error 6 In fact, all of these fake partition functions can be constructed from linear combinations of the real theories. Specifically, all partition functions are non-negative linear combinations of the ones deriving from W 3 1 . W3 andW3, see figure 2 below.
correction is achieved, we show how quantum ECCs define Lorentzian lattices and therefore Narain CFTs. A brief overview and a explicit example of the construction are given in section 2.4. Section 3 is where we explain how this construction may be extended to higher genus. This is essentially the main result of the paper. We show how higher-genus partition functions are related to the so-called higher-weight enumerator polynomials of the codes. These need to be evaluated with higher-weight Jacobi theta functions as arguments. We determine how modular invariance acts on these higher-weight enumerator polynomials.
We use these observations to aid the classification of code CFTs. In section 4, we describe how to characterize the ring of polynomials defined by invariance under highergenus modular transformations. This allows us to count the number of potentially valid genus 1 and genus 2 partition functions explicitly for n 6. We show that only a fraction of the valid genus 1 partition functions arise as the factorization limit of valid genus 2 partition functions, which underlies our claim that genus 2 modular invariance is a strong constraint on the space of theories. We also discuss how we can resolve several sets of isospectral theories -such theories have the same genus 1 partition function, but we find different genus 2 partition functions. Finally, in section 5 we point out the "enumerator polynomial form" is a useful ansatz for the partition function that applies to many non-code theories as well. We use it to construct modular invariant functions with a large gap in primaries.

Quantum codes and Narain CFTs
The purpose of this section is to review the construction of CFTs from error-correcting codes. The original construction, due to [2,3], associates chiral CFTs to binary codes. In this paper, we will be primarily interested in the more recent construction, due to [5,12], which associates non-chiral CFTs to classical codes over F 4 , or equivalently, quantum stabilizer codes. None of the material presented in this section is new: it is merely meant as a review of this work. A large part of the discussion also follows [30] -see that textbook for a more thorough introduction.
We have included a much briefer version of this discussion in section 2.4. The reader who wants to proceed more quickly towards the results of this paper may prefer to start there.

Classical codes over general fields
Error-correcting codes are designed to encode information redundantly to protect against corruption. The classical example is the repetition code, where 0 is encoded as 000 and 1 is encoded as 111. In the information-theoretic context then, error-correcting codes should be thought of as a map from length-k vectors to length-n vectors, where n > k. However for our purposes, we shall simply think of them as a collection of codewords, i.e. as the image of this map. For classical codes, these elements may be vectors over F 2 (for the common case of binary codes) or any other finite field F . For quantum codes, the elements are spins, or qubits. Before turning to quantum codes, let us briefly review some facts about codes. These ideas are also reviewed in [31,32], and more recently for a physics audience by [5,7].
Additive codes are those where the sum of any two codewords is a codeword. These may be easily specified by a generator matrix G: Here we use C to denote the code and c to denote its element codewords. It is clear then that G must be an n × k matrix, and that there are |F | k codewords. Alternatively, a code may be specified by its parity check matrix H, defined to satisfy The parity check matrix is an (n − k) × n matrix, and also satisfies HG = 0. The parity check matrix is directly useful in error correction. If a codeword is corrupted, c → c = c+e, this can be easily detected by applying the parity check We shall see that this step has a direct analogue when we discuss the case of quantum error-correcting codes. The error-correction ability of a code is directly related to how far apart its codewords are, which is measured by the Hamming distance. The Hamming distance d(c 1 , c 2 ) for two codewords is defined as the 0 norm, or the number of entries which are different. The Hamming distance for a code is defined as the minimum distance between any two codewords. An error-correcting code with length n, |F | k elements, and Hamming distance d is denoted as an [n, k, d] code.
Enumerator polynomials A coarse description of a code is provided by its enumerator polynomial, which counts the degeneracy of codewords. The most general such object is the complete enumerator polynomial, defined by This is a function of |F | variables, x 0 , . . . , x |F |−1 . The coefficient of each monomial x n 0 0 x n 1 1 , . . . is the number of codewords with n 0 0s, n 1 copies of the first non-zero element of F , and so on. Here we imagine x 0 to correspond to 0 ∈ F , and the other x i to the other elements of F in a fixed but otherwise arbitrary order.
For codes over F 2 , the enumerator polynomial simply counts the non-zero elements in each codeword. The number of non-zero elements is called the Hamming weight, defined by w(c) = d(c, 0). In this case, we can write the enumerator polynomial as (2.5) Error-correcting codes can be used to define lattices by embedding them into a bigger vector space, and identifying lattice vectors as living in cosets defined by each codeword.
The classic example of this is Construction A of Leech and Sloane [1], which associates lattices in R n to binary codes via This identification leads to a relationship between the code enumerator polynomial and lattice theta function: 7 i.e. the lattice theta function can be found by substituting the polynomial variables x 0 , . . . with Jacobi theta functions. This formula has generalizations for other fields, including the one relevant for our purposes: F 4 . It has elements 0, 1 , ω , ω 2 which satisfy We may think of ω as being a third-root of unity (in which case the last requirement, x + x = 0, must be input by hand). We shall primarily be interested in self-dual codes, since these will lead to modularinvariant partition functions. The dual of a code over a field F is given by Here the algebra is over F . For fields with characteristic 2, such as F 2 or F 4 , this amounts to the requirement that (a, c) = 0 (mod 2). The definition of duality depends on the definition of the inner product ( . ) used. We will be interested in the inner-product defined by whereā is the complex conjugate of a when viewing ω as a third root of unity. For a general field, code-duality acts on the Hamming enumerator polynomial by [6] Self-dual codes are for which C = C ⊥ . As a result, their enumerator polynomials are unchanged duality and W C (x 0 , Example: extended Hamming [8,4,4] code The extended Hamming [8,4,4] code is a classical binary code defined by the generator matrix This code has 2 4 = 16 codewords, which are the length 8 vectors defined by multiplying all 16 of the length 4 binary vectors by G. The Hamming code is the unique doubly-even self-dual binary code of length 8. Its enumerator polynomial is were we used the formula (2.5).

Quantum codes
In direct analog to classical codes, quantum error-correcting codes are designed to protect quantum information, denoted by the state |ψ , from corruption. Errors in quantum computation can take the form of an operator E acting on the |ψ . These errors are taken to be in the Pauli group P n . The n-qubit Pauli group consists of tensor products of I, X, Y and Z (these are the usual Pauli operators, also known by I, σ x , σ y , σ z ) and an overall phase of ±i or ± 1. Let E denote the linear space of errors acting on the Hilbert space. A subspace C of the n-qubit Hilbert space is said to form a code iff for all E ∈ E where c (E) does not depend on the state |ψ . This is referred to as the Knill-Laflamme condition [33].
Example: three qubit flip code Let us consider a very simplified example where the only possible errors are acting by X which flips the states |0 (spin up) and |1 (spin down). We can protect against such errors by by encoding The space of states spanned by |000 and |111 is called the code subspace, a subspace of the bigger three qubit Hilbert space. Now we transmit the message, and want to be able to correct any bit flips that may have happened. This process has two steps: 1) syndrome diagnosis, where we determine the errors, and 2) recovery, where we return the system to its initial state. Syndrome diagnosis is done via measurements of the four projection operators: If no bit is flipped, then measuring P 0 will give 1. If only the i th bit is flipped, then only P i will give 1. This code is constructed to detect and correct a maximum of 1 error on any qubit and will fail if there are two or three errors. Importantly, measuring these operators does not change the state (which is required for us to perform all four measurements).
The second step is recovery. In this case it is very simple -if a bit has been flipped, we apply X to that bit to flip it back.
These steps are directly analogous to the classical case: syndrome diagnosis for classical codes is performed by applying the parity check matrix H, and recovery is simply the step of interpreting the message as the closest codeword. This example was rather artificial, because we only allowed for particular kinds of errors, but it illustrates the error-detection and recovery steps. In particular, it shows that there are methods of detecting and correcting errors without destroying the state. Next we shall discuss a broader class of codes, which will be relevant to our interest in CFTs.

Stabilizer codes
A simple way to specify the code subspace is to specify a set of operators which stabilize that subspace. For example, the state is stabilized by the operators Z 1 Z 2 and X 1 X 2 , because these do not change |ψ . In fact, up to a phase, |ψ is the unique such state. Therefore specifying the stabilizer, in this case, completely specifies the state |ψ . There are two basic requirements for a group to stabilize a non-trivial set of states: 1) that it does not include the element −I (which obviously cannot stabilize any state) and 2) that all the elements commute. The latter follows because operators in G n either commute or anti-commute. If g 1 and g 2 anti-commute, then any element |ψ which is stabilized by g 1 g 2 cannot be stabilized by g 2 g 1 . Now consider an operator S which is in the stabilizer of the code subspace -it has an eigenvalue +1 for any state |ψ . Then measuring S will detect any errors E which anticommute with S, because SE|ψ = −E|ψ . Each set of errors E will anti-commute with a set of operators S, and this set of operators S defines a stabilizer code. If S is an Abelian subgroup of order k of the Pauli group P n and −I / ∈ S, then the space of states stabilized by all elements of S is an [[n, n − k, d]] quantum stabilizer code. Here, d is the quantum Hamming distance of the code and is defined as the minimum weight of an operator which commutes with S but is not in S. The weight of an operator is the number of Xs, Y s, and Zs comprising it.
Stabilizer codes are related to classical codes over F 4 , discovered by Calderbank, Rains, Shor, and Sloane [34]. The key to this relation is the Gray map between F 4 and F 2 2 , which associates It is a F 2 -linear map that also relates the inner product (2.10) to the symplectic inner product This map can be used to relate classical codes over F 4 with quantum stabilizer codes in the following way. Consider a classical code C over F 4 . Then c ∈ C is a length-n vector whose entries are 0, 1, ω, ω 2 . Through the Gray map, this can be related to a pair of vectors, α and β, with entries in F 2 .
c ↔ (α, β) . (2.20) The result is that each codeword c ∈ C can be used to specify a stabilizer in the related quantum code, C * through the relation (2.21) We have specified each generator by the position of its Xs and Zs, which are packaged into the binary vectors α and β. The relationship goes both ways and a set of stabilizers can be used to specify a set of codewords in (F 4 ) n , or equivalently elements of (F 2 ) 2n .
Representing each generator as a pair of (row) vectors lets us represent the full set as the matrix H = [α|β]. This is broken into two n × (n − k) submatrices: A "1" in α ij means that generator g i includes X j . A "1" in β ij means that the generator g i includes Z j . The presence of a Y j is indicated by a "1" in both α and β.
Example: Steane [7,1,3] code This is entirely specified by the stabilizer group generated by (2.23) Clearly H is the quantum version of the classical parity check matrix. The condition that the stabilizers form an Abelian subgroup equivalent to This equation is equivalent to The second line here amounts to the requirement that the code over F 4 is self-orthogonal, meaning C ⊂ C ⊥ . Self-duality (C = C ⊥ ) is a stronger requirement. A vector in F n 4 can be thought of as having real dimension 2n through the Gray map. Therefore if C is an [n, m, d] code, then its dual will be an [n, 2n − m, d] code. As a result, self-dual codes over F 4 must be [n, n, d] codes. In fact, classical [n, m, d] codes define quantum [[n, n − m,d]] codes, so we see that self-dual codes over F 4 define quantum codes which cannot actual transmit any information. 8 From here on out, we will consider k to define the size of the quantum The codewords are the vectors stabilized by the generators defined by H, and the space of all linear combinations of codewords is called the "code subspace." Just as in the classical case, the codewords are given by the kernel of H, with multiplication defined in (2.19).
To make this more precise, we can define a binary "generator matrix" G of dimension 2n × (n + k) whose columns form a basis of codewords. It must be defined to satisfy for all g. G can be chosen so that its first n − k rows coincide with those of H. The remaining rows, spanning logical operations on the code subspace, will not matter for our purposes because we have k = 0.
For the Steane code, the logical operators (operators which commute with the stabilizers but are not in the code subspace) are (2.29) The logical states or eigenstates of these logical operators are The Steane code is an example of Calderbank-Shor-Steane (CSS) codes. These codes will be interesting to us because they may be constructed from classical codes. In particular, consider two classical binary codes, an [n, k 1 ] code C 1 , and an [n, k 2 ] code C 2 , and which satisfy C 2 ⊆ C 1 . Then we can form an [n, k 1 −k 2 ] code, denoted CSS(C 1 , C 2 ) in the following way: For a given codeword of x ∈ C 1 , we define If we do this for each codeword, we will end up with k 1 codewords in the quantum code. But many of these may be the same -this will happen for two codewords x and x ∈ C 1 whenever x − x ∈ C 2 . So in fact, the code C 1 breaks into cosets determined by the structure of C 2 , and the resulting code has 2 k 1 −k 2 unique codewords. The Steane code is able to correct "arbitrary single-qubit errors." This includes a phase flip (applying Z to a single bit) and a single bit flip (applying X to a single bit). We will define e 1 to be a vector with a single 1, which denotes the position of the phase flip, and a similar vector e 2 to denote the position of the bit flip.
Detecting the phase flip errors is almost identical, after using a trick: a phase flip, which acts by |0 → |0 , |1 → −|1 , acts the same as a bit flip in the basis |+ = |0 + |1 , |− = |0 − |1 . So we change basis (formally, apply a Hadamard gate) and then we see that we can detect this error using the same procedure as for the bit flip errors.

Enumerator polynomials for quantum codes
Using the Gray map, we can define various types of enumerator polynomials for quantum codes. For classical codes, the enumerator polynomial will count the number of 0s, 1s, ωs, and ω 2 s, of each codeword. For the quantum code, this corresponds to counting the number of Is, Y s, Xs, and Zs in each stabilizer. Therefore we define the weights As a result, the complete enumerator polynomial can be written However we will not need this. By an argument from [5], which we will revisit in section 3, it is convenient to instead study the refined enumerator polynomial, It is a non-trivial fact that the transformation |x |0 aux → |x |Hx aux can always be accomplished using a quantum circuit composed of CNOT gates.
Self-duality, on the level of the refined enumerator polynomial, takes the form of the re- We need another criterion beyond self-duality: a stabilizer code is called real if the stabilizers are all real, i.e. the number of Y s in each stabilizer is even. This requires w y (c) to be an even number, which means that real codes are invariant under (2.37)

CFTs from quantum codes
Having reviewed most of the required elements, we are now ready to explain the so-called New Construction A, due to Dymarsky and Shapere, which is a construction of non-chiral, "full," CFTs from stabilizer codes, or equivalently from codes over F 4 . The central point is that each code defines a lattice through To define a CFT, we would like to think of this as a Lorentzian lattice. This can be done by embedding , which is the same as the c ↔ (α, β) basis for the codewords, then we use the symplectic metric leading to |v| 2 = 2a · b. This can be transformed to coordinates where we have the usual Lorentzian metric, |v| 2 = p 2 L − p 2 R , by defining When considered as a Lorentzian lattice, the following result [5] follows: • The lattice defined by a code will be self-dual if and only if the code is self-dual.
• A lattice defined by a code will be even if and only if the code is real.
Lattices may be characterized by their theta functions, which for a Lorentzian lattice takes the form 11 (2.41) 10 This follows from a general identity for the complete enumerator polynomial [26] (Theorem 10 of chapter 5), see also [27], Theorem 8. 11 Here we define the theta function the following way. For a Lorentzian lattice in (n, n) signature, move to coordinates where the metric is of the form g = In,×n ⊕ (−In×,n), so that any lattice vector can be written v = ( , r). Then the lattice theta function is defined as ΘΛ = v∈Λ q 2 /2qr 2 /2 .
Just as in the case of Euclidean lattices, the theta function for a Lorentzian lattice is related to the enumerator polynomial of its defining code. In this case, the relationship takes the form [5]: . We will give the derivation of this formula in section 3.2 as a special case of the general-genus result.

Narain CFTs
Consider now the theory of n free bosons compactified on a lattice Γ [19,20], i.e. moving freely in R n /Γ. This theory is described by the action The antisymmetric field B is required to construct the most general theory of this type. Consider now the case where spacetime is also a 2d torus. Then periodicity requires that Φ(t, σ) ∼ Φ(t, σ + 2π). But the lattice compactification implies we have also identified where λ is zero or any other element of Γ. Now consider the following solution to the equations of motion: Thus if the periodicity condition of (2.44) is to be satisfied, we must have Furthermore, compactification on the lattice Γ implies that the momenta P is in the dual lattice Γ * . By computing the canonical momentum, we find that V is defined as the coefficient multiplying t in the solution Φ(t, σ). From (2.46), it must be Solving for p L and p R , we simply find The set of all ( p L , p L ) in this parametrization forms the lattice Λ. From here on, we will set α = 2 to keep p L and p R dimensionless, as they are in the previous subsection. The Narain theories have a U (1) n × U (1) n symmetry, corresponding to moving Φ L or Φ R around the compact directions. The primary operators with respect to this symmetry are (2.52) Since the elements of the v ∈ Λ lattice are labeled by p L and p R , we see that we have a single primary for each lattice vector. The weights of these primaries are simply The final result is the partition function, which equals The numerator of this sum is precisely the lattice theta function introduced in (2.41).
Combining this with the result (2.42) yields a formula for the genus 1 partition function: for the CFT defined by the code. The numerator in this expression is simply the refined enumerator polynomial, evaluated at combinations of the Jacobi theta functions in the notation Θ m (τ,τ ) = θ m (e 2πiτ )θ m (e −2πiτ ).

Code theories
We have now reviewed how a code C defines a Lorentzian lattice Λ(C), via (2.38), and how a lattice Λ defines a CFT, essentially through the definition of the vertex operators (2.52), where ( p L , p R ) ∈ Λ. Thus it is clear how to associate a CFT to a code. In practice, however, different codes may define the same theory, and it may be useful to have a way of classifying all distinct theories. There is a large group of code equivalences, which are transformations between codes which define the same theory. They include permuting the components of codewords and swapping X i and Z i for any i. These lead to different lattices which are related by T-dualities, so the corresponding CFT will ultimately be the same. In fact, all T-dualities which relate two code theories are of this form, i.e. permutations of components and swaps of X and Z [5].
Recall now that self-dual real codes can be specified by n pairs of (row) vectors (α i , β i ), which define the code's generator matrix: One of the main results of [5] is that, due to code equivalences, every code theory defined from New Construction A can be described by a code whose generator matrix has the form where B is an antisymmetric binary matrix. Codes in this form are called B-form codes. Therefore the result can be stated in the following way: any real self-dual code is equivalent to a B-form code. The generators for a B-form code take the form One way to organize the set of possible matrices B is through graphs. A graph can be defined by an adjacency matrix M where the entry M ij contains information about the link between node i to node j. B is a binary antisymmetric matrix, which is equivalent (mod 2) to a symmetric matrix with zeroes on the diagonal. Hence the resulting graph is undirected and has no self-links. The end result is that, due to code equivalences, each code theory can be represented by a binary n × n matrix B or by an undirected graph with n nodes. We shall use both throughout this paper. 12

Recap and overview
Since this section includes a number of diverse elements, we will conclude with an executive summary.
Codes A stabilizer code is defined by its codewords, which take the form Here n is the dimension of the code space. The number of generators is k, so there are 2 k codewords. The set of codewords can then be specified by the length-n binary vectors α and β. There is one pair (α, β) for each codeword. The Gray map (2.18) associates tuples in F 2 with elements of F 4 . This allows a pair (α, β) of binary vectors to be combined into a vector over F 4 , which we denote c. We then think of the collection of cs as elements of a code over F 4 . 12 The B-form, and related graph, are not necessarily unique. This is due to the existence of certain T-dualities that relate two different B-form codes. These act on the graphs. This issue is important for the classification of code theories in [5].
Enumerator polynomials There is a natural definition of enumerator polynomials for codes over general fields, so the Gray map allows us to define an enumerator polynomial for our quantum codes. First we define the weights (2.60) The enumerator polynomial of interest for us is the refined enumerator polynomial (2.61) The abelian group structure of the stabilizer codes already ensures that all F 4 codes defined this way are additive and self-orthogonal (C ⊂ C ⊥ ). The F 4 code will be even provided that the quantum codes are real, meaning all generators g in the form (2.59) are real. Self-duality is equivalent to the requirement that the code is self-orthogonal, which is automatically satisfied, plus the requirement that |C| = |C ⊥ |. This means that the F 4 code is an [n, n, d] code, so the quantum code has n generators. The enumerator polynomials of such codes are invariant under the transformations and Lattices Codes over F 4 define lattices via It follows from the definition that the lattice will be self-dual if the code is self-dual (with respect to the symplectic metric), and it will be even if the code is real. Lattices are characterized by their theta functions, defined in (2.41). The lattice theta function can be directly computed from the error-correcting code via the formula .

CFT partition function
The code CFT is defined as the Narain theory associated to the lattice, for the U (1) n × U (1) n characters (2.53). Via the lattice construction, we related this to the enumerator polynomial, and arrived at the expression for the CFT defined by the code. The numerator in this expression is simply given by the refined enumerator polynomial; the denominator is a universal factor, corresponding to a one-loop determinant. The conformal weights in (2.66) are given by where λ and P take all values in the integer lattice Z n . A parametrization in terms of the codewords c ↔ (α, β) (using the Gray map), is B-form codes There are a number of code equivalences which relate different codes to the same theory. These equivalences act as T-dualities at the level of the CFT. The result is that all real self-dual codes are equivalent to a code with the form where B is an antisymmetric binary matrix. The generators (2.59) of codes in this form are simply given by Therefore every code theory can be specified by (at least) one binary antisymmetric n × n matrix B. Such matrices can be used to define undirected graphs with n nodes and no self-links Example: n = 3 code Let us illustrate these elements with a simple example. Take This corresponds to the graph complete graph on 3 vertices (see figure 1). We can use this to compute the generators: The full set of elements is then G = {I, g 1 , g 2 , g 3 , g 1 g 2 , g 1 g 3 , g 2 g 3 , g 1 g 2 g 3 }. This allows us to compute the refined enumerator polynomial using (2.61). The result is This agrees with equation (6.21) of [5], and is equal to theW 3 used in the introduction.
Here the tilde denotes that this is the extremal code at n = 3. We will return to this topic in section 4.

Narain lattices and code theories at higher genus
The goal of this section is to spell out the relation between quantum error-correcting codes and CFT partition functions at higher genus. Recall that a quantum error-correcting code can be specified by a collection of generators g which satisfies certain properties. Each codeword is essentially a string of Pauli matrices, described by the symbols 1, X, Y, Z, which can also be specified by a pair of binary vectors (α, β). By relating the Pauli matrices to the elements of F 4 = {0, ω, 1, ω 2 } via the Gray map, there is a relation to classical codes over F 4 . In this section we will give a construction at higher-genus that is the exact counterpart of (2.67). This will give a genus g partition function of the form Here Ω is the period matrix of the genus-g Riemann surface, which is the direct higher-genus analog of the complex structure parameter τ . Φ g generalizes the contribution of 2 n |η(τ )| 2n in the genus 1 case and takes into account the contribution to the partition function due to oscillator modes. Formally, Φ g = det ∂ , which corresponds to the determinant of the Laplacian operator∂ on the genus-g Riemann surface with zero modes removed [35]. This does not depend on the choice of Narain Lattice so it will not factor into our discussion.
Finally, f n is a degree n homogeneous polynomial in 2 g−1 (2 g + 1) theta functions Θ m . In this paper, we will relate f n (Θ m ) to the refined higher-weight enumerator polynomial, which we will define below.

Higher-weight theta functions
Given a Euclidean lattice Λ, it is natural to define the higher-weight lattice theta series which is an analytic function of the Siegel upper half plane H g , defined by with known modular transformation properties. In general, Θ Λ will evaluate to a combination of higher-weight theta functions, see [36][37][38], [39], or [40]. Their general definition is through the sum where all quantities in bold font are length-g (column) vectors. The theta functions (3.4) have well-known transformation properties under the genus g modular maps, which will be discussed in detail in section 3.3. A number of the theta functions will be zero, generalizing the statement that θ 1 (q) = 0 in the genus 1 case. To see this at higher genus, we first introduce the notation Θ m (Ω,Ω) = θ m (Ω)θ m (Ω), m ∈ even g . (3.5) For Θ m in (3.5) to be non-zero, m ranges over the set of genus-g even characteristics -the subset of {1, 2, 3, 4} g that contains an even number of "1"s. There are 2 g−1 (2 g + 1) such even characteristics. For example, at genus 1 and 2, the theta functions are indexed by The holomorphic function θ m (Ω) in (3.5) is defined by where a(m) and b(m) have entries according to For instance, at genus 1, we have which are the usual Jacobi theta functions.
Factorization limit In the analysis of higher-genus partition functions we will make use of the "factorization limit," where a genus g Riemann surface degenerates into two parts of genus g − h and h respectively, connected by an infinitely long thin tube. In this limit, Ω becomes block-diagonal, and it is easy to verify that

From code to lattice theta series
The lattice theta series is a function of the period matrices. At genus g = 1, there is a definition of a theta function on a Lorentzian lattice Λ, defined by With this definition, the generalization of to genus 2 is (3.14) Here q, r, and s are defined by q = e 2iπΩ 11 , r = e 2iπΩ 12 , s = e 2iπΩ 22 ,q = e −2iπΩ 11 ,r = e −2iπΩ 12 ,s = e −2iπΩ 22 . . (3.16) We will now write it in a different form, which is suitable for generalizations both to arbitrary fields and to higher genus, The first of these equivalences correspond to relating the quantum code to a classical code over F 4 . The second corresponds to using the Gray map, and is what will be used when relating the quantum error-correcting code to the theta function of a Lorentzian lattice. We write The genus 1 theta series of the Lorentzian lattice Λ(C) associated to the code C by (2.38), is given by where we substituted (2.40) into (3.13).
Let us study the contribution in (3.20) from a given c in the outermost sum and a given i in the product. This corresponds to determining (3.21) We would like to simplify (3.21) so that it splits into two terms, such that in each term the two infinite sums separate. This is achieved by introducing the summation variables Now we can see why we introduced the refined enumerator polynomial with ) by the vanishing of θ 1 (q).

Derivation at higher genus
It is natural to consider the higher-genus enumerator polynomial of a code over F , This is a polynomial in |F | g variables x [A] , where A ∈ F g . Here the sum is over all possible g-tuples of codewords, packaged into the n × g matrix M.
Having worked out the derivation of the genus 1 lattice theta series from a code, the generalization to higher-genus is straightforward.
The higher-weight enumerator polynomial (3.28) is a sum over g-tuples of codewords, where each summand is a product over the entries indexed by i. We will now study each factor in such a product, i.e. for a fixed set of codewords c (1) , . . . c (g) and index i. Define c i with components (c (1),i , . . . , c (g)i ), and further c i ∼ (α i , β i ) by (3.19). Then (3.29) Now let µ = a + b and ν = a − b, and write the sum as It is now clear that the resulting expression, will be a linear combination of the Θ m (Ω,Ω) defined in (3.5) above. In general, the variable where the sum over r h is determined by the following

Explicit formulas at genus 2
Like the case at genus 1, some of the variables in the complete enumerator polynomial map to identical theta functions. At genus two, there are ten non-zero theta functions Θ m , while six theta functions identically vanish: Θ 12 = Θ 13 = Θ 14 = Θ 21 = Θ 31 = Θ 41 = 0. Taking this into account, we find that y 0 := x [11] → Θ 33 + Θ 34 + Θ 43 + Θ 44 , (3.37) We see that compared to the original 16 code variables x [c i c i ] , we are now considering a subspace spanned by ten variables y i . This is the genus 2 version of going from the complete enumerator polynomial to the refined enumerator polynomial. One may also write an expression that gives the genus two enumerator polynomial directly in terms of the y i , but the resulting formula is not particularly illuminating: where ∧ denotes the component-wise "and" operator.
We are also interested in the factorization limit (3.12) in terms of code variables. For the case of genus 2, it takes the form where the x i refer to variables on the left genus 1 Riemann surface and x i to the variables on the right genus 1 Riemann surface.

From theta relations to polynomial relations
The goal now will be to study the transformation properties of the higher-weight theta functions in order to determine how they lift to transformations of the enumerator polynomials.
The modular transformations are The corresponding transformations of the higher-genus theta functions is given by [36] (see also e.g. [39]) and M diag denotes the diagonal entries of a matrix M , seen as a column vector. In our construction, the theta functions always come in pairs θ(Ω)θ(Ω), so any phases appearing from the modular transformations will cancel between the holomorphic and antiholomorphic parts. Furthermore, under the modular transformations 3.49, the denominator |Φ g | transforms covariantly with modular weights ( c 2 , c 2 ). This is required to cancel the square-root factor in (3.50).
Consider now the set of Sp(2g, Z) transformation acting on the theta functions Θ m . Up to the weights imposed by the square-root factor in (3.50), such transformations amount to mapping the Θ m among each other. We now wish to lift these relations to the polynomial variables. It is clear that we only need to exhibit this lift for the generators of Sp(2g, Z).
As a warm-up, consider the case g = 1. We can take as generators The corresponding transformations of the Jacobi theta functions induce T : , (3.53) These relations lift to T : which are exactly the MacWilliams identities (2.36) and (2.37) given in section 2.

Partition functions for code theories
In the previous section, we have described how code CFTs are constrained by modular invariance for general genus, and by factorization limits, which relate different genera. Now we shall explicitly demonstrate how to use these requirements to constrain the space of possible code theories. This is essentially a primitive example of the modular bootstrap -because modular invariance is so simple for the code theories, we can enumerate all of its possible solutions. Genus 1 modular invariance completely determines all of the n = 1 and n = 2 code theories. We shall see that genus 2 considerations are enough to fix the space of n = 3 code theories, so this will be our primary example, given in section 4.1. At n > 3, genus 2 constraints greatly reduce the space of theories but do not entirely fix them.
We will summarize the classification of invariant polynomials for general n in section 4.2, and for n 6 we will compare the number of valid (modular invariant polynomial with positive integer coefficients) genus 1 partition functions, genus 2 partition functions, and actual code theories in section 4.3.

Finding invariant polynomials: example at n = 3
Let us start by presenting the case n = 3 in full detail. For genus 1, the most general homogeneous degree 3 polynomial is which has 10 terms in total. Now recall that for genus 1, modular invariance implies that the polynomial is invariant under T :

(4.2)
This fixes all but two of the undetermined coefficients, so we are left with Requiring that all of these coefficients are positive leads to the inequalities 0 ≤ a 0,2,1 ≤ 3, 1 ≤ a 0,0,3 ≤ 4 − a 0,2,1 , (4.4) which can be displayed as the two-dimensional region shown in figure 2(a). Finally, we require that each of these coefficients is an integer, which leads to 10 solutions, the dots in figure 2(a). Now consider genus two. We again write the most general polynomial and then impose modular invariance. The result is a large polynomial P (2) inv [3] = y 3 0 + a 0,0,0,0,0,0,0,1,1,1 y 3 y 7 y 8 + . . . , (4.5) which has a total of 48 terms and 3 undetermined parameters. Requiring positivity of all coefficients again gives a finite region, which we have displayed in figure 2 (b). If we require that the coefficients are all integers, we find 11 solutions. So there are 11 potential genus 2 partition functions. However code theories must have genus 2 partition functions which factorize into genus 1 partition functions in the limit where the genus 2 Riemann surface becomes degenerate. Recall that this limit gives  This is the general procedure we will follow for n = 3, 4, 5, 6 in the later sections. Actually, the case of n = 3 is a little special. We could have determined all real theories by only requiring factorization, without positivity at genus 1 or genus 2. We believe this is related to the fact that at n = 3, genus 2 is enough to eliminate all fake theories -essentially, it fully fixes the partition function (given the assumption that it has enumerator polynomial form). We conclude that at n = 3, there are no non-code theories with EP form because only the four code theories are consistent with factorization at genus 2.
At n = 4, where genus 2 does not remove all of the fake theories, factorization without positivity is not enough to find all of the modular invariant polynomials. Furthermore, just like n = 3 at genus 1, the real n = 4 theories do not all lie at the vertices of the genus 1 and genus 2 polytopes; some lie on the edges, faces, and in the bulk. Thus we find two special properties obeyed by n = 3 at genus 2: 1) the set of real theories is fixed only by factorization, and 2) the real theories lie on the corners of the polytope. As such, it would be very interesting to push our calculation to genus 3, to see if these two patterns persist, but we leave this for future work.

Invariant polynomial ring
Now let us be more general, and describe the method of classifying invariant polynomials, valid for any n. We will be interested in the ring R g of polynomials invariant under the genus g modular relations. R g admits a grading by degree where dim R [n] g can be computed by Molien's formula, which we will now review (see e.g. [42]). For a matrix group G acting on n variables x 0 , . . . x n−1 , Molien's formula gives the dimension of the space R where |G| is the number of (distinct) elements in G, and g are the individual matrices in the representation in question.
Genus 1: Recall that invariance under the modular group SL(2, Z) = SP (2, Z) acting on the three-dimensional vector space of {x 0 , x 1 , x 2 }, is given by equation (4.2). Using (4.8), we find that Molien series for this group acting on 3 variables is given by = 1 + r + 2r 2 + 3r 3 + 4r 4 + 5r 5 + 7r 6 + 8r 7 + . . . . (4.9) The number of solutions to the transformations (4.2) for general degree-n homogeneous polynomials is given by the r n coefficient in the Molien series in (4.9). This lets us infer the number of new generators at each order. The whole ring R 1 is generated by three polynomials p (g=1) n (x 0 , x 1 , x 2 ), of degree n for n = 1, 2, 3 [12].
Genus 2: At genus 2, we have a 10-dimensional representation of SP (4, Z) furnished by the 10 y-variables. The transformations are given in (3.57)-(3.58) and we find that |G| = 720. This allows us to calculate the Molien series where f (r) = 1 + r + r 4 + r 5 + 3r 6 + 2r 7 + 3r 8 + 3r 9 + 5r 10 + 3r 11 + 10r 12 + 6r 13 + 9r 14 + 7r 15 + 4r 16 + 2r 17 + r 19 . (4.11) The number of generators is calculated using the Molien series 4.10. In principle, there could appear non-trivial relations between the generators. We find that there are no nontrivial relations among the terms constructed from generators at lower degree. Therefore, the generators organize as given in table 1.  There are new generators only up to n = 11. A general method to completely specify this full set is to use enumerator polynomials of actual code theories as a set of generators. At each n from n = 1 to n = 11 one can choose the new generators arising at each n in Table 1 to be those from actual (inequivalent) code theories.

Finding invariant polynomials: results for various n
Now let us describe the results of counting invariant polynomial for general values of n. There are too many genus 2 solutions to count above n = 6, but in principle our method will work for any order n.
It is straightforward to check that the the most general invariant polynomial can be written as a linear combination of W 3 ,W 3 , W 2 W 1 , and W . For convenience, these are collected in appendix B. This procedure of using explicit codes to construct generators is carried on to n = 11 to obtain the full set. These are given in graph form in appendix A. We are unable to count the number of genus 2 polynomials. There are 218 polynomials from actual codes.

Isospectral CFTs differ at genus 2
The partition function is a coarse observable. At genus 1, it only contains information about the spectrum of the theory, and it is possible that different theories may have the same genus 1 partition function. 13 Higher-genus partition functions contain information about averages of OPE coefficients. In principle increasing the genus increases the amount of information extractable, though it is hoped [43] that with enough partition functions, the theory will be completely specified. A more precise understanding of this idea is one of the primary motivations of the present work. For chiral CFTs, a demonstration is provided by Milnor's example of isospectral lattices. These correspond to chiral CFTs defined by compactification on the isospectral d 16 and E 2 8 lattices. It has been known since [44] that these two theories can actually be distinguished by going to genus 5, i.e. the partition functions are the same for g 4.
Likewise, W can be constructed from B 1 and B 2 using 3.47. We will not record them here since they are quite lengthy expressions, but they are distinct. One can further check that under factorization, both W 2 factorize to (W ) 2 . Holomorphic modular forms at higher genus that degenerate in the factorization limit are referred to as cusp forms. The non-chiral analogs of such cusp forms would be W 2 . At c = 8, the situation is more interesting as there are 61 pairs of isospectral theories and 5 isospectral triples. We find that the genus 2 partition functions are different for all pairs of isospectral theories. We also find that the genus 2 partition functions are different for all 5 isospectral triples. 13 Such theories can also be differentiated by introducing chemical potentials for the U (1) n ×U (1) n currents [12].

Beyond code theories
Throughout this paper, we have used the enumerator polynomial to simplify the form of the partition function. The primary benefit of this is that the constraints of modular invariance become very simple, allowing us to solve them exactly, i.e. to write the most general partition function (in enumerator polynomial form) which satisfies the constraints.
In our previous work [7], we pointed out that in fact, the partition function of every meromorphic CFT should have enumerator polynomial form, albeit with potentially negative or fractional coefficients. This follows directly from the fact that the (numerator of the) partition functions must be linear combinations of Siegel modular forms, combined with standard results relating these modular forms to code enumerator polynomials (e.g. [45]). Non-chiral CFTs are much richer however, and to our knowledge, it is not known what subset of these CFTs might have partition functions with enumerator polynomial form. Let us explore a few examples.

Minimal models
The first example is the 2D Ising CFT, which has the following genus 1 partition function: The Ising CFT has c = 1/2, so we see that 3) The Ising model can be written as a sum of square roots of the code variables. It is easy to verify that the S transformation merely cycles these terms. One might hope that this extends to other minimal models as well, but it appears that it does not. Consider for instance the Lee-Yang CFT, a non-unitary minimal model with c = −22/5. The genus 1 partition function is known, 14 The functions G(q) and H(q) are the Rogers-Ramanujan functions, defined by This is not equal to 4 i=2 |θ i (q)/η(τ )| c/2 , as the naive pattern would suggest. It remains possible that some non-trivial identity relates this partition function to Jacobi theta 14 See also [46], which includes a calculation of the genus 2 partition function functions, but we were not able to find it. As far as we can tell, the "enumerator polynomial form" displayed by the Ising CFT is an accident. Or perhaps it is related to the fact that the theory can be realized as a single free fermion. Perhaps the other minimal models are obtainable from a suitable generalization of New Construction A, such as the one of [18]. It would be interesting to understand this better in the future.

Chiral CFTs revisited
As a motivating example, let us consider a simple case of meromorphic, or chiral CFTs. We use "meromorphic" in the sense of [10], where it is taken to mean theories where Z = χ(τ )χ(τ ), with χ(τ ) = χ(−1/τ ). This is a strong constraint on the form of the partition function, and it leads to the requirement that c be a multiple of 8. Furthermore, if c is a multiple of 24, then χ(τ ) will be individually modular invariant and therefore can be the full partition function of a chiral CFT.
The connection between ECCs and chiral CFTs was considered in [7], where it was observed that every meromorphic CFT should have a partition function with enumerator polynomial form. This simply follows from the requirement that every chiral character χ(τ ) must be a modular form. For g < 4, the ring of modular forms is completely captured by the ring of invariant polynomials after the standard substitutions x i → θ i (q) [45,47].
Let us now see some concrete examples of these observations. One interesting set of examples are the three "extremal c = 24 theories." The first is the theory coming from the "Golay code:" The Golay code is the classical binary length 24 code which maximizes the Hamming distance. Relatedly, its enumerator polynomial has the largest gap between consecutive powers of x 0 (i.e. there is no x 20 0 term). The next example is the Leech lattice, with This theory does not derive from a code through Construction A. However, it is related to the Golay code by the twisting procedure [2,3], reviewed in [5], which relates a self-dual even lattice to a new self-dual even lattice. The Leech lattice is "extremal" in the sense that it is known to provide the densest possible sphere packing in 24 dimensions [48]. The final interesting example is the Monster CFT, the theory whose automorphism group is the Monster group. Its partition function is given in enumerator polynomial form by The Monster is the CFT which maximizes the spectral gap -the gap in Virasoro primaries -for c = 24. It is neither a code nor a lattice theory, but it is related to the Leech lattice by Z 2 orbifolding. So we see that these three theories are related.
The extremality of the Leech lattice can also be phrased in CFT language -it is the CFT which maximizes the gap in U (1) c primaries. This remarkable connection was explored in [49], where it was used to provide exact analytic functionals for the modular bootstrap. In fact, it turns out that the extremality of the Golay code theory also has a CFT interpretation as the maximization of the gap in SU (2) c characters. This will be explored in a future paper [50].
We can push this further. For the Monster theory, the extremal theory (the theory with the maximium gap in Virasoro primaries) at c = 24, we have constructed the genus 2 and genus 3 partition function. We can also construct the genus 1 and genus 2 partition functions of the conjectured extremal c = 48 theory, analogous to the Monster. We have collected a few of these lengthy expressions in appendix B.

Non-chiral CFTs and the maximal gap
Next let us consider the more general, non-chiral case. The general strategy will be to still assume enumerator polynomial form for the partition function, but to go beyond code theories by allowing negative polynomial coefficients. The goal will be to identify interesting theories, such as the "extremal theories" which maximize the gap in Virasoro primaries ∆ gap . We will do this by considering first the most general (modular invariant) enumerator polynomial, and then simply choosing the coefficients a i,j,k to maximize the gap. We will focus on the genus 1 partition function but in a few cases with low central charge n, we will be able to provide genus 2 expressions as well. n = 1 In this case, W 1 = x 0 + x 2 is the only invariant polynomial. Its gap is ∆ gap = 1/4 n = 2 Now we have a one parameter family of solutions. The gap is maximized by W 2 = x 2 0 + x 2 1 + 2x 2 2 , which has ∆ gap = 1/2 n = 3 In this case, the maximal gap is ∆ gap = 3/4, coming from the polynomial We can recognize that this is the enumerator polynomial of (2.76), which came from the B-form code corresponding to the complete graph K 3 , the fully-connected graph with three nodes.
(5.10) n = 4 Here we find the same thing: the extremal theory, which now has ∆ gap = 1, also corresponds to a code theory. It has This theory, also realizable as the SO(8) WZW with level 1, or the theory of 8 free fermions with diagonal GSO projection, was shown to saturate the modular bootstrap constraints at n = 4 [51]. So in this case the extremal theory with enumerator polynomial form is the same as the most general extremal theory (in contrast to the cases of n = 1, 2, and 3, where the bounds of [51] are not saturated by our EP-form partition functions).W 4 is the B-form code deriving from the complete graph K 4 . So in both of these cases, the extremal theories are given by the complete graphs. Again, we can fix the genus 2 partition function from this:
(5.12) n = 5 Here something new happens. From the Molien series, the general n = 5 polynomial has 4 undetermined coefficients, but if we use this to cancel out the maximum number of states, the resulting "extremal theory" has negative degeneracies. Instead, we may only cancel 3, rather than 4 undetermined degeneracies. This results a function with ∆ gap = 1, and 1 remaining undetermined coefficient, If we demand that the remaining degeneracies are positive integers, we find that a 0,0,5 must be an integer satisfying 0 ≤ a 0,0,5 ≤ 16. If we set a 0,0,5 = 16, we recover the code theory corresponding to the complete graph K 5 . None of the other values of a 0,0,5 can derive from a code via New Construction A due to the signs in (5.13) n = 8 Noting that n = 6 and n = 7 are similar to n = 5, we proceed to n = 8. In this case, we find that we can cancel enough states to make ∆ gap = 7/4, leading to a partition function with negative integer degeneracies. If we require non-negative degeneracies, 15 the maximum gap is ∆ gap = 5/4. This does not saturate the bound ∆ gap = c/8 + 1/2 of [51]. Alternatively, we may try to only cancel scalar degeneracies. If we try to cancel the maximum number, we find ∆ s=0 gap = 5/2, but then a number of other states have negative degeneracies. More interestingly, if we cancel the maximum number while requiring unitarity, we find a unique theory with ∆ s=0 gap = 2. This theory is described by the enumerator polynomial (5.14) Current modular bootstrap bounds require that ∆ s=0 gap < 2 for n < 8, with a kink at ∆ s=0 gap = 2 for n = 8 which is conjectured to be saturated by the E 8 WZW model at level 1 [51]. This theory holomorphically factorizes, Z(q,q) = Z E 8 (q)Z E 8 (q) into two copies of 15 We have only checked that all Virasoro degeneracies are positive up to ∆ = 10, since we do not know a way to enforce it for all degeneracies in practice. the chiral theory which results from from compactifying 8 chiral bosons on the E 8 lattice. This theory is also related to the Hamming code via Construction A.
This gives another example for which a theory which is extremal in some sense can be written in EP form but does not arise from a code. That it does not derive from a code is obvious because of the negative coefficients appearing in (5.14). This may be thought of as analogous to the enumerator-polynomial form representation of the Leech lattice and Monster partition functions.
A third interesting example exists for n = 8 -the theory described in [52] with O + 10 (2).2 automorphism group. This theory is completely fixed from the general invariant EP form by requiring that our partition functions have only integer scaling dimensions, and that the degeneracy of scalars at ∆ = 1 is 496. The resulting enumerator polynomial is In principle, it should be possible to check if these genus 1 partition functions correspond to a single genus 2 partition function. Since these theories do not derive from codes, it may be that their genus 1 partition functions have EP form but their genus 2 partition functions do not -we do not know if this is possible. For the chiral CFTs, we found that extremal genus 2 partition functions at c = 24 is entirely fixed by factorization, so it would be interesting to try that here. However, the most general genus 2 polynomial is beyond what we are able to do with our desktop computers right now, so we will have to leave exploring them to the future. n = 24 In this case, by allowing for negative degeneracies we can construct a modular invariant function with ∆ gap = 5. As an interesting side note, it is possible to identify the theory Z = Z Monster (q)Z Monster (q) by setting quarter integer degeneracies to 0 and requiring a gap. However, this modular-invariant partition function has negative degeneracies from the point of view of a non-chiral CFT because the 1−q in the vacuum character of Z Monster (q) has a minus sign, which multiplies all of the characters in Z Monster (q), and vice-versa.

Asymptotics at large c
Finally, let us make a few comments about theories in the limit of large central charge.

Complete graphs
The complete graphs provide a special class of code theories, which includes every positive integer n. We can study them by explicitly constructing their enumerator polynomials from their B-matrices, which have a 1 in every entry except on the diagonal. For c 4, the gap of very complete-graph theory has ∆ gap = 1. In fact, this is the upper bound on the gap of any code theory [5].
As we noted before, the n = 4 deriving from the complete graph K 4 is equivalent to the SO(8) WZW model. It appears that this pattern continues beyond n = 4. We have checked for n up to 15 that the number of currents is always given by N n = n(2n − 1). Extra currents require extra symmetries, and n(2n − 1) is the number of currents one would find in the presence of symmetry enhancement to SO(2n). In fact, for large enough n, no other rank n Lie group contains this many currents, so SO(2n) is the only possibility. As a result, we conjecture that the complete graph codes give a family of CFTs with symmetry enhancement to SO(2n). It would be interesting to study these theories further, to try to prove this conjecture or understand their holographic duals, in the future.

Estimate for non-unitarity theories
It is also possible to provide an estimate of the maximal gap possible by comparing the number of degeneracies we need to cancel with the number of coefficients we can choose. That is, if we have k coefficients, then we should be able to set k degeneracies to zero. 16 First we consider the number of possible operators up to a given scaling dimension. Because these theories have quarter-integer scaling dimensions, the maximal number of possible operators up to ∆ given by (k + 1) = 2(∆ + 2)(∆ + 1) . (5.16) So to create a gap ∆, one must cancel 2(∆ + 2)(∆ + 1) theories. Next we determine the number of coefficients which we can pick to cancel degeneracies. This is given by the coefficients appearing in the Molien series. The n th such coefficient is given by ω(n) = 1 72 47 + 9(−1) n + 6n(6 + n) + 16 cos 2nπ 3 . (5.17) At large n, ω(n) ∼ n 2 /12 and ρ(∆) ∼ 2∆ 2 . Thus we can create a gap up to ∆ at central charge c = n as long as ω(n) = ρ(∆), leading to the estimate This is a huge gap, and is inconsistent with the strongest current asymptotic bounds given in [53]. However, those bounds require unitarity. So we expect that if such large gaps are possible then they must come from modular invariant functions with negative degeneracies of Virasoro characters. This is exactly what we find for n = 24. In that case, ∆ gap = 5 but the function with that gap has negative degeneracies. Thus our estimate on gap avoids the bootstrap bounds because the modular invariant functions satisfying it will be non-unitarity.

Discussion
This paper is an invitation to study the consequences of higher-genus modular invariance, using the example of theories defined from quantum error-correcting codes through the New Construction A of [5]. The guiding idea is that higher-genus modular invariance should be more constraining than genus 1. Error-correcting code theories provide a simple playground to explore this because their partition functions conform to the polynomial ansatz central to this paper. In this simple "enumerator-polynomial form," the action of the modular group SP (2g, Z) becomes a set of simple linear transformations on the polynomial variables. This allows for a simple algorithm to solve the constraints and list every partition function which could possibly derive from a code. This also requires that we impose (1) that all polynomial coefficients are positive integers, as they should derive from degeneracies of codewords, and (2) that the higher-genus partition functions factorize into lower-genus partition functions in the limit where Riemann surface they live on becomes singular. We find that higher-genus modular invariance is very constraining. Specifically, there are a large number of genus 1 expressions which look like consistent partition functions. We have proven that such partition functions cannot arise, via factorization, from genus 2 partition functions with enumerator polynomial form. This means that they cannot be code theories, but, importantly, it does not imply that they cannot be CFTs at all. Since the number of actual B-form codes is known, we can compare our results to the true set of code theories. We find that for n = 3, genus 2 modular invariance rules out all polynomials which do not derive from codes. For n > 3, the number of fake polynomials is greatly reduced by genus 2 considerations, and presumably pushing our algorithm to higher genus would be required to remove all fake polynomials. It would be interesting to understand exactly what genus is required for a given n. 17 In [5], a number of isospectral code CFTs were discovered -theories which are known to be different, but which have the same genus 1 partition function and thus the same spectrum. Such theories are non-chiral analogs of Milnor's example isospectral Euclidean lattices in 16 dimensions, which define isospectral chiral CFTs. We find that all of the examples given in [5] of isospectral theories up to n = 8 can be distinguished by their genus 2 partition functions. This is similar to how Milnor's example can be distinguished by their genus 5 partition functions [44].
One of the main lessons of this paper is that the enumerator polynomial ansatz for the partition function greatly simplifies a number of questions. One direction we have investigated is the maximum gap of theories with enumerator polynomial form. Theories deriving from actual codes have a maximal gap of 1. In the case of n = 4, ∆ gap = 1 is the actual upper bound on the gap [51], and the theory saturating it, the SO(8) WZW model, is known to be a code theory [5]. However it is possible that there are non-code theories with enumerator polynomial form, which occurs for chiral CFTs, for instance, in the case of the Monster CFT. For n > 4, we found that a larger gap is consistent with enumerator polynomial form. If we allow for negative Virasoro degeneracies, we can construct very large gaps (ex. ∆ gap = 5 for n = 24). For the more interesting case of unitary theories, we were not able to say as much. This is because we do not have a simple way to impose positivity over all Virasoro primaries, as they are not related to the code variables in a simple way. If such a method could be found, we believe it could be very interesting to investigate the maximum gap of theories with enumerator polynomial form.
We found a few other examples of known theories with enumerator polynomial form. Two n = 8 theories saturating various bootstrap bounds were shown to be non-code theories whose partition functions have enumerator polynomial form. It is notable that such theories only appear at n = 4 and n = 8. There are known theories saturating the bounds of [51,52] at other values of c -in particular, these include a number of other WZW models. These cannot have enumerator polynomial form because their scaling dimensions are not all quarter-integers. It would be very interesting to try to see if such theories might derive from some generalization of the New Construction A. An important step in this direction was taken in [18], where a construction was given for error-correcting codes over fields F p for any prime p. See also [54].
In principle, it should be possible to extract information about OPE coefficients from the higher-genus partition function -see [23] for an example where this is done for chiral theories. We think it would be very interesting to try to do this for the theories considered in this paper. This could lead to a better understanding of the relation between highergenus constraints and the constraints coming from the standard conformal bootstrap of sphere four-point functions. Ultimately, the goal of pursuing this direction would be to understand if the higher-genus partition functions give enough information to fully specify the CFT, in the spirit of [43].
Another potential direction would be to study the relation between the partition functions of code theories, and the set of modular forms. In the chiral case, where we consider only holomorphic modular forms, it is known that enumerator polynomials, with Jacobithetas for arguments, give the full set of modular forms for g < 5. To our knowledge, the relationship for non-chiral CFTs and modular functions of two variables is completely unknown. As a result, we do not know anything about the relation between the set of enumerator polynomial theories, and the full set of 2d CFTs. Understanding this further could be a useful step in classifying 2d CFTs.
Finally, it would be interesting to use our work to address quantum gravity. AdS 3 /CFT 2 is one of the most useful testing grounds for new ideas about holography. Recently, this has included new insights about the significance of averaging over the moduli space of CFTs to define a particular bulk theory [55,56]. In a future work [50] we will apply some of these insights to the case of chiral CFTs. In [5], a formula for the average over B-form codes was given, and the holographic interpretation was discussed in [14]. It would be interesting to try to discover the genus 2 average for B-form codes, and understand its holographic implications. 1 (left), Q [2] 2 (middle), and Q  A Generators for invariant ring at genus 2 In section 4 we analyzed the generators for ring R g of invariant genus 2 polynomials. It is convenient to organize the generators by degree. Consider the set Q [2] n of generators of degree n, then the ring is given by 2 ∪ · · · ∪ Q [2] 11 . (A.1) We represent each generator by an undirected graph, and show the generators in figures 3-11.

B Genus 2 partition functions in enumerator polynomial form
Here we include a few expressions too big to conveniently include in the main text.

B.2 Chiral theories
The genus 1 partition function for the extremal n = 24 chiral theory, also known as the Monster CFT, is 24 (x 0 , x 1 , x 2 , x 3 ) =