Quasi-Jacobi Forms, Elliptic Genera and Strings in Four Dimensions

We investigate the interplay between the enumerative geometry of Calabi-Yau fourfolds with fluxes and the modularity of elliptic genera in four-dimensional string theories. We argue that certain contributions to the elliptic genus are given by derivatives of modular or quasi-modular forms, which encode BPS invariants of Calabi-Yau or non-Calabi-Yau threefolds that are embedded in the given fourfold. As a result, the elliptic genus is only a quasi-Jacobi form, rather than a modular or quasi-modular one in the usual sense. This manifests itself as a holomorphic anomaly of the spectral flow symmetry, and in an elliptic holomorphic anomaly equation that maps between different flux sectors. We support our general considerations by a detailed study of examples, including non-critical strings in four dimensions. For the critical heterotic string, we explain how anomaly cancellation is restored due to the properties of the derivative sector. Essentially, while the modular sector of the elliptic genus takes care of anomaly cancellation involving the universal B-field, the quasi-Jacobi one accounts for additional B-fields that can be present. Thus once again, diverse mathematical ingredients, namely here the algebraic geometry of fourfolds, relative Gromow-Witten theory pertaining to flux backgrounds, and the modular properties of (quasi-)Jacobi forms, conspire in an intriguing manner precisely as required by stringy consistency.


Review of Known Results
An important quantity that captures certain robust features of string theories is the elliptic genus [26][27][28][29], which serves as a loop space extension of the ordinary chiral index in quantum field theories. By turning on background fields, a wealth of exact information about the chiral spectrum and its charges can be extracted. In this paper we will mainly consider elliptic genera for four-dimensional string theories in a U (1) gauge background. More concretely, what we will consider are the partition functions in the Ramond-Ramond sector of superconformal worldsheet theories with right-moving supersymmetry, which in d = 2n + 2 dimensions are defined as (1.1) Here τ denotes the modular parameter of the toroidal worldsheet, and z represents the background gauge field strength, or fugacity, which couples to a left-moving, holomorphic U (1) current, J. In order to obtain a non-vanishing result, the zero modes are saturated by inserting an appropriate power F n R of the right-moving fermion number operator. In the present, four-dimensional, context, we have n = 1 and the worldsheet theory possesses N = (0, 2) supersymmetry.
The elliptic genus (1.1) should be contrasted with the familiar one of N = (2, 2) superconformal theories. For these one can refine the elliptic genus in a canonical way as to keep track of the left-moving U (1) superconformal R-symmetry. On the other hand, the current J in the present context is just the worldsheet incarnation of some four-dimensional gauge symmetry, which for concreteness we have taken to be U (1). 3 This is a generic, model-dependent symmetry which does not pertain to any left-moving N = 2 superconformal algebra.
It is familiar from the earliest works [26][27][28][29] that the elliptic genus (1.1), defined as the RR partition function of a weakly coupled, toroidal worldsheet theory, enjoys distinguished transformation properties under the modular group, SL(2, Z): For a string in d = 2n + 2 dimensions, it transforms with modular weight w = −n. As we will recall later in Section 4, for the special case of a critical heterotic string this has important implications for anomaly cancellation [26,27,30,31] via the Green-Schwarz [32] mechanism.
When the elliptic genus is refined by an extra U (1) gauge background, as considered here, one might expect that it will be promoted to a weak Jacobi form [33][34][35]. This means that Z(q, ξ) = Φ −n,m (τ, z), where Φ w,m denotes a generic weak Jacobi form of modular weight w and index m (the index m is model dependent and specifies the level of the underlying U (1) Kac-Moody algebra, or equivalently, the spacing of the charge lattice). As summarized in Appendix A.1, such Jacobi forms enjoy distinguished modular and shift transformation properties, which play an important rôle for elliptic genera in general (for a review, see e.g. [36]).
While this expectation is indeed realised in six dimensions, we find that the elliptic genus in four-dimensional string theories is not necessarily a modular or quasi-modular weak Jacobi form, but rather what is known as a quasi-Jacobi form (see again Appendix A.1). This is not in conflict with the arguments of [33] which are based on spectral flow [37], as these arguments do not apply to generic U (1) currents in (0, 2) models. Indeed it is known [38] that (left-right asymmetric) spectral flow is not necessarily a symmetry of the theory. In fact the situation is not that bad, in that the elliptic genus will still be closely related to weak Jacobi forms, albeit in a more intricate way: namely, at least in special situations, as a collection of formally six-dimensional elliptic genera in disguise. We will explain these matters, which are among our main findings, in detail in the next subsection. 3 In Section 6.1, we will also discuss a non-abelian extension.
Historically the elliptic genus of critical strings as written in (1.1) refers to a weakly coupled, conformal worldsheet theory and as such it is an intrinsically perturbative, one-loop quantity. However, it was later understood how elliptic genera for critical as well as for non-critical strings can also be defined and computed in non-perturbative settings, by resorting to a variety of methods such as mirror symmetry, the topological vertex, localization, and 2d CFT technology [4,6,[65][66][67][68][69][70][71][72][73]. This has the advantage of being far more general than for perturbative strings based on weakly coupled worldsheet theories, and applies also to non-perturbative heterotic as well as to non-critical strings.
In this paper we will exploit the fact that elliptic genera can be computed geometrically in terms of Gromov-Witten invariants arising in dual string compactifications in M-or Ftheory. Most of the work has been done, so far, for six-dimensional theories. Essentially, the idea is to consider solitonic strings that arise in F-theory from D3-branes wrapping some curve, C b , which lies in the base of an elliptic threefold, Y 3 . In the dual M-theory formulation, the charged excitations of the string wrapped on an extra S 1 correspond to M2-branes on Here E τ is the elliptic fiber of Y 3 and the other fibral curves C f r are associated with the gauge symmetry. The degeneracies that are encoded in the elliptic genus (1.1) then have an interpretation as the genus-zero BPS invariants, N C b (n, r), associated with C. These invariants can be assembled into the following free energy, which is defined relative to C b : Here we assumed just one extra U (1) gauge symmetry. 4 Physically the M2 brane wrapping numbers n and r correspond to levels and charges of excitations of the solitonic string. Via duality the free energy F C b (q, ξ) can be argued to coincide with the elliptic genus 5 (1.1) of the solitonic string, upon identifying the modulus of the elliptic fiber with the modulus of the toroidal worldsheet (and similarly for the U (1) fugacity): where E 0 is the ground state energy of the Ramond sector of the string worldsheet theory. In [6] we have addressed the analogous situation for four-dimensional F-theory compactifications on fourfolds, Y 4 , focussing on geometries that lead to dual heterotic strings. This is much more involved not the least because BPS invariants on fourfolds, N α;C b , depend on extra data. Namely they need to be defined [74][75][76][77] with respect to some basis of cohomology classes, ω α ∈ H 2,2 (Y 4 , R). In physics terms these data correspond to choices for the background fourflux, G = c α ω α . Thus for a given fourfold Y 4 , we have in general a collection of independent elliptic genera labelled by background fluxes, so that the full elliptic genus for a given flux background G is given by a linear combination As far as the modular properties are concerned, it was found in [6] that depending on the flux sectors labelled by α, the various building blocks Z α;C b (q, ξ) behave very differently. To be more specific, let us introduce the following symbolic notation (now labelling by modular weight and index rather than by flux and curve): where the superscripts refer to 6 "modular", "quasi-modular" and "quasi-Jacobi", respectively. We will explain these terms in due course. Note that at this point there is an ambiguity in that any Z QM −1,m is a priori defined only up to a modular piece, and Z QJ −1,m up to modular and quasimodular pieces. The precise alignment between the modular properties and fluxes in H 2,2 (Y 4 ), in relation to the overall geometry of the fourfold Y 4 , will be a main issue in the present paper and will be discussed later in detail.
Let us go through the various components of [Z * −1,m ] and briefly characterize their modular properties. The fully modular piece, Z M −1,m in (1.6) is, by definition, given by some weak Jacobi form [33][34][35] (see Appendix A.1). The quasi-modular piece, Z QM −1,m , is a benign modification, the only difference being that it is a quasi-modular and not fully modular Jacobi form. By this we mean that besides the ordinary modular Eisenstein series E 4 and E 6 , also the quasi-modular series E 2 appears. As is familiar, this mild violation of modularity can be repaired by replacing E 2 by its modular, but non-holomorphic cousin which transforms uniformly with modular weight two. In field theoretic terms, this reflects a regularization ambiguity in the zero mode sector, which is resolved by imposing modular invariance at the expense of holomorphicity. This is just a manifestation of the celebrated holomorphic anomaly [78], which has many manifestations in physics. In the present context (and for genus-zero invariants) it is wellknown [40,50,[79][80][81][82][83] to mean that the base curve C b = C 0 , which corresponds to the heterotic string, splits over certain subloci: C 0 = C 1 E + C 2 E . The curves C i E in turn are associated with non-critical E-strings, and the split just reflects the fact that the heterotic string can fractionate into two E-strings [45]. In the dual heterotic language these correspond to having extra 5-branes in the geometry, which means that the quasi-modular sector of the theory is intrinsically nonperturbative as seen from the heterotic perspective. As we will discuss later in Section 4, this will have also a non-trivial bearing on anomaly cancellation, which is closely tied to the modular properties of the elliptic genus.
Finally, most peculiar and thus most interesting is the last component of the elliptic genus, Z QJ −1,m , in (1.6). It was found in [6] that it cannot be an ordinary modular or quasi-modular Jacobi form, since it does not obey the characteristic transformation properties (A.1) and (A.2). However it was observed that the coefficients of an expansion in powers of z are quasi-modular forms term by term, so that one can at least assign a uniform overall modular weight, w = −1, to it.

Summary of Present Work
The main new result of the present paper is that the component Z QJ −1,m of the ellitpic genus in (1.6) is actually also expressible in terms of the more familiar (quasi)-modular Jacobi forms, though in an intriguing way. Namely, it is given by a derivative of a partition function Z −2,m (q, ξ) of modular weight −2 and index m. Depending on the geometry it can be either a modular or quasi-modular weak Jacobi form. Thus, just like for the (quasi-)modular sector, the extra sector splits into two, namely into a perturbative and a non-perturbative piece, and we can refine the symbolic decomposition (1.6) as follows: (1.9) Accordingly, from now on we will refer to these extra components as the "derivative sector", which by itself can come in a modular and quasi-modular version.
One main concern in the present paper will be to understand the mathematical origin and physical interpretation of this sector in terms of the underlying fourfold geometry and flux background. More concretely we aim to understand how the set of possible four-form fluxes maps into the space (1.9) of elliptic genera, i.e., This question will be addressed in Section 3, with special emphasis on geometries that are dual to heterotic strings in Section 3.2. In this concrete setting we can explicitly match the geometrical data to the decomposition (1.9) of the elliptic genus in terms of modular objects. Specifically, we anticipate, as described in our key equation (3.13), that where the index m is determined by a certain topological intersection product to be explained later. The flux-dependent coefficients, g * , are intersection products as well and are given in eqs. (3.14). The first term in (1.11) represents the fully modular piece of the elliptic genus, while the second constitutes a possible non-perturbative, quasi-modular piece. It originates from a possible blowup of the base threefold, B 3 , which introduces an exceptional divisor, E, and is also associated with non-critical E-strings. As mentioned in the previous section, this generalizes well-known results in six dimensions [50,82,83]. The novel piece in four dimensions is then the derivative piece, which is in general given by a sum of terms, as labelled by i in (1.11). In fact, the derivative structure nicely ties in with statements given in the mathematical literature [24,25]. In particular it was proven in [24] that elliptic genera will in general lie in the ring of quasi-Jacobi forms, which is a broader notion than just Jacobi or quasi-modular Jacobi forms. It is easy to see from the definitions given in Appendix A, that Z QJ −1,m in (1.8) yields a simple and concrete realization of such quasi-Jacobi forms, which explains the superscript. The paper [25] furthermore conjectured that the generating functions of relative BPS invariants in any elliptically fibered variety can generally be expressed in terms of quasi-Jacobi forms. Our results for Calabi-Yau fourfolds were found in an independent manner, and thus provide a nontrivial check of these conjectures.
Given that the derivative terms do not behave well under either SL(2, Z) transformations (A.1) or under shifts (A.2), one might raise the point of consistency of the physical theories. Specifically the shift z → z + λτ , λ ∈ Z, which is a manifestation of spectral flow in the U (1) Figure 1: A sketch of the interplay between elliptic holomorphic anomalies and (almost holomorphic) partition functions,Ẑ w,m (q, ξ), pertaining to the various fluxes as classified in (2.17). HereẐ −1,m (q, ξ) is (the non-holomorphic cousin of ) the elliptic genus in four dimensions. MoreoverẐ −2,m (q, ξ) encodes relative invariants of certain embedded threefolds Y i 3 , which can, at least formally, be associated to elliptic genera in six dimensions.
sector of the theory, would seem to be broken for flux backgrounds that lead to derivative contributions to the elliptic genus. This is analogous to the problem discussed in the previous section, where the quasi-modular Eisenstein series E 2 appears in the component Z QM * , * of the elliptic genus. In that case, the cure for restoring modular invariance was to add a non-holomorphic piece to E 2 , replacing it by the modular, non-holomorphic weight-two Eisenstein seriesÊ 2 as in (1.7). In the present context of quasi-Jacobi forms, we have a similar remedy: we can augment the derivative piece by introducing a non-holomorphic term, and declare the following to be the ("derivative" part of the) physical elliptic genus: 7 This restores not only the modular SL(2, Z) symmetry (A.1), but also invariance under the shifts z → z + λτ , λ ∈ Z, ie., spectral flow. In other words, what we encounter here as a novel phenomenon, on top of the known modular anomaly, is an anomaly of the spectral flow which can be cancelled upon sacrificing holomorphicity. As we will explain in Section 3.4, eq. (1.12) has an interpretation in terms of an elliptic generalization of the holomorphic anomaly equation [40,50,[78][79][80][81][82][83]. It is analogous to the familiar holomorphic anomaly equation, which in essence states that given an almost holomorphic, modular function which depends onÊ 2 , there is a functional identity between the non-holomorphic sector and a derivative with respect to E 2 . More specifically, we trivially infer from (1.12) that The surprising point is that the image of the derivative yields the generating function of BPS invariants related to a different flux sector. Indeed we will find in Section 3.4 that the Z i −2,m (τ, z) coincide with invariants related to certain non-transversal fluxes, even though these have no interpretation in terms of gauge fluxes in four-dimensional F-theory! See Figure 1 for a sketch of the relations between the various flux sectors.
This makes contact with the work of [76,77], where the BPS invariants induced by nontransversal fluxes have been observed to organise into quasi-modular partition functions. Moreover in ref. [77] a holomorphic anomaly equation was found that relates flux sectors associated with modular weights w = 0 and w = −2; the rightmost arrow in Figure 1 refers to this. Our result (1.13) relates the elliptic genus of weight w = −1 to a flux sector associated with modular weight w = −2. In fact, after translating our setup to the formalism [25], equation (1.13) turns out to be a manifestation of the elliptic holomorphic anomaly equation that was introduced in a more abstract form in that reference.
Moreover, we have found another, related interpretation of the Z i −2,m (τ, z): We will see that for certain geometries, the Z i −2,m (τ, z) are literally the elliptic genera of certain six-dimensional string theories. For example, in the context of solitonic heterotic strings, where the base threefold B 3 of the elliptic fourfold Y 4 is itself fibered over some surface, B 2 , the Z i −2,m are labelled by curve classes C i in B 2 . To each of these C i we can associate a certain specific threefold, Y i 3 , which is defined by the restriction of the fourfold to the pullback divisor p * (C i ) as follows: (1.14) Here {C j } denotes the basis of curves dual to the basis {C k } on B 2 . This geometric setup is schematically depicted in Figure 2. As we will argue in Section 3.2, the Z i −2,m just encode the relative BPS invariants of these auxiliary threefolds. This alternative interpretation of the Z i −2,m then provides an intriguing relationship between background fluxes in H 2,2 (−2) and the enumerative geometry of the threefolds Y i 3 . It also gives independent support to some of the conjectures of ref. [25].
In may cases, the embedded threefolds, Y i 3 , can be Calabi-Yau by themselves for an appropriately chosen basis {C i }. Since they are elliptically fibered as well, one can then associate to each of them a chiral, six-dimensional F-theory compactification. We will show that in this situation, the collection of the Z i −2,m that feature in the sum (1.11) are nothing but the elliptic genera associated with these threefolds Y i 3 . This phenomenon generalises also to non-critical strings which will be the subject of section 6.
More generally, however, it turns out that the embedded threefolds Y i 3 are not necessarily Calabi-Yau. We nonetheless conjecture, and support with some arguments, that the Z i −2,m continue to encode BPS invariants of the embedded threefolds, Y i 3 . For these cases, an interpretation in terms of elliptic genera likely persists only as a formal analogy.
To support our considerations, we will present a detailed analysis of several examples. In Section 5.1 we will discuss an example where the derivative sector comprises two embedded threefolds both of which are Calabi-Yau. On the other hand, Section 5.2 shows an example with a single embedded threefold, which has negative anti-canonical bundle; the derivative piece of the elliptic genus can then be associated via duality, in a formal sense, to a certain elliptic surface with 36 singular fibers. Furthermore we see in examples that the derivative structure appears even more broadly, and also applies to elliptic genera of non-critical strings. This suggests, as stated in Conjecture 2, that it is a general feature of elliptic genera in four dimensions. In Section 6 we will see how it applies to what we will call four-dimensional E-strings, 8 as well as to a non-critical string arising from a D3-brane wrapping a curve on B 3 = P 3 . } } } } Figure 2: The derivative contribution to the elliptic genus of a four-dimensional string is captured by the relative BPS invariants of certain threefolds Y i 3 inside the given elliptic fourfold Y 4 . Here we present a sketch of how these threefolds are embedded for the example of a heterotic string. The heterotic string arises in this F-theory geometry from a D3-brane that wraps the rational fiber C 0 in the base threefold, B 3 ⊂ Y 4 . The extra two-form fields B i that are needed for reinstating Green-Schwarz anomaly cancellation arise by expanding the ten-dimensional fourform, C 4 , with respect to the divisor classes From a physics perspective, one may wonder about the Green-Schwarz cancellation of the U (1) gauge anomaly, which is known to be closely tied to the modular properties of the elliptic genus. For the example of a flux background that is dual to the heterotic string, we will show in Section 4 that anomaly cancellation persists also when derivative pieces are present, albeit in a modified way.
As we will recall in Section 4.1, the modular properties of the elliptic genus underlie the standard Green-Schwarz mechanism which involves the universal B-field. The derivative terms in the elliptic genus, Z i −2 , appear precisely when, depending on the geometry and flux, further 2-form fields B i contribute to the Green-Schwarz mechanism [85]. 9 The additional 2-form fields arise from the curve classes C i in the base threefold B 2 , which also determine, as per (1.14), the corresponding elliptic threefolds Y i 3 . To close the circle of ideas, the threefolds in turn encode the BPS invariants pertaining to the i th derivative sector of the elliptic genus, and altogether everything conspires such that anomalies are cancelled.

Geometric Foundations
In Section 2.1 we briefly review the geometric definition of BPS invariants for curves on Calabi-Yau fourfolds and their computation via mirror symmetry. In Section 2.2 we then specialise to the relative BPS invariants on elliptic fibrations in the presence of fluxes. These concepts become particularly important in light of F-theory/heterotic duality, whose salient geometric manifestation we recall in Section 2.3.

BPS Invariants on Calabi-Yau Fourfolds
In this work we investigate the structure of certain integral BPS invariants for Calabi-Yau fourfolds, Y 4 , which are analogous to the familiar integral BPS invariants on Calabi-Yau threefolds. There are two ways to approach the definition of the invariants, either on purely geometric grounds or via mirror symmetry, and we will briefly review both. For more details we refer e.g. to [74][75][76][77] and references therein.
We begin with the geometric approach by first defining the (in general rational) Gromov-Witten invariants of a Calabi-Yau fourfold. Consider a curve class C ∈ H 2 (Y 4 , Z) and the moduli space of stable holomorphic maps from a Riemann surface of genus g to C with s points fixed, denoted as M g,s . This moduli space has expected or virtual (complex) dimension dim vir (M g,s ) = 1 − g + s. For genus g = 0 and s = 1, the virtual dimension of M g,s is two and thus one can define a topological invariant by, loosley speaking, integrating a suitably quantized element G ∈ H 4 (Y 4 , R) over the moduli space. More precisely, following [74] we denote by µ the virtual fundamental class of M 0,1 associated with a curve C (with one point fixed). Then this defines the genus-zero Gromov-Witten invariants n G (C) of C with respect to G as where ev * is the evaluation map applied to G. By holomorphicity, this integral is non-zero only if G ∈ H 2,2 (Y 4 , R). While Gromov-Witten invariants are in general not integral, there exist related integral BPS invariants for fourfolds which are analogues of the integral BPS invariants of threefolds [86][87][88]. This was first conjectured in [75] and proven for g = 0 in [89]. We will denote these integral BPS invariants by N G (C). At genus zero, and as long as we do not consider multiples of curve classes, the two notions of invariants are equivalent; throughout this work we will be in this situation and can hence use both notions of invariants interchangeably. The BPS invariants N G (C) can be computed by mirror symmetry [90,91], by interpreting the Calabi-Yau fourfold Y 4 as the compactification space of Type IIA string theory to two dimensions, and the element G ∈ H 2,2 (Y 4 , R) as a four-form background flux. The space H 2,2 (Y 4 , R) of supersymmetric flux backgrounds admits a decomposition [90,92] where the vertical subspace H 2,2 vert (Y 4 , R) is generated by all products of two elements in H 1,1 (Y 4 ), while the horizontal subspace H 2,2 hor (Y 4 , R) is obtained by the variation of Hodge structure from the unique (4, 0)-form on Y 4 . In a flux background given by G ∈ H 2,2 vert (Y 4 , R), the N = (2, 2) supersymmetric compactification of Type IIA string theory on Y 4 is partially determined by the free energy, F G (t), which depends holomorphically on the Kähler moduli t a , a = 1, . . . , h 1,1 (Y 4 ). The two-point functions for the chiral fields in the effective action associated with the Kähler moduli are then given by [91,93] C The free energy F G (t), which plays the rôle of a superpotential in two dimensions, encodes the genus-zero invariants as follows: Define first the variables q a = e 2πita , a = 1, . . . , and expand a given curve class C β in terms of the basis C a of H 2 (Y 4 ) with complexified volumes t a , C β = β a C a . (2.5) Hence to each curve C β one can associate the product The free energy F G (t) then enjoys a worldsheet instanton expansion of the form where we have suppressed possible classical pieces which are polynomial in t a . The function F G (t), and hence the invariants N G (C β ), can in turn be computed by mirror symmetry: Type IIA string theory on Y 4 with flux G ∈ H 2,2 vert (Y 4 , R) is dual to Type IIA string theory on the mirrorỸ 4 with a dual fluxG ∈ H 2,2 hor (Y 4 , R). Under the mirror map the free energy F G (t) maps to which is a holomorphic function of the complex structure moduli ofỸ 4 . It is, in principle, exactly computable as a period integral, which eventually determines the invariants N G (C β ). For more details see [91,[93][94][95]].

Relative BPS Invariants on Elliptic Calabi-Yau Fourfolds
We now focus on invariants N G (C β ) of those Calabi-Yau fourfolds Y 4 which admit an elliptic fibration of the form The base B 3 of the fibration is a Kähler threefold, which, in order for such a fibration to exist, must have an effective anti-canonical divisor,K B 3 . As we will see, for certain choices of curve class C β and flux G, the genus-zero invariants N G (C β ) admit yet another interpretation in terms of an elliptic genus of a string. To arrive at this interpretation, we view the Kähler threefold B 3 as the compactification space of Ftheory [96] to four dimensions. Compactification of this theory on a further circle, S 1 F , gives rise to a theory in three dimensions, which coincides with M-theory compactified on Y 4 . 10 We will furthermore assume that the gauge group of the four-dimensional F-theory is nontrivial. For any non-abelian factor G of the gauge group, there must be a divisor b G on B 3 which is wrapped by a stack of 7-branes. For the geometry of Y 4 , this implies that the generic elliptic fiber E τ splits into several holomorphic curves over b G . In the dual M-theory picture, M2-branes wrapping these fibral curves give rise to the non-abelian gauge bosons that are not in the Cartan subalgebra of G. The fibral curves may split further over curves on b G , in which case additional matter fields charged under G appear. Even for G = U (1), massless charged matter exists only if the elliptic fiber splits over certain curves on B 3 .
For definiteness we now focus on gauge group G = U (1). Geometrically, in such situation the fourfold Y 4 then exhibits an extra rational section, S, in addition to the zero-section, S 0 . Associated with S is the divisor class which is the image of the Shioda map. It has the defining properties that Here and in what follows we use the notation • for the intersection product on Y 4 , i.e., Given σ we can expand the M-theory 3-form as C 3 = A ∧ σ + . . ., where the 1-form field A becomes the G = U (1) gauge potential in the dual M-theory.
In the language of Type IIB/F-theory, the abelian gauge group is associated with a linear combination of 7-branes, each wrapping a 4-cycle on B 3 . The linear combination of four-cycles associated with the U (1) in this way can be identified with the the so-called height-pairing (2.13) As mentioned before, in addition to the gauge potential there will in general be a collection of massless charged matter fields. In the Type IIB/F-theory picture, massless N = 1 chiral multiplets with U (1) charge Q = r (2.14) arise from open strings stretched between the 7-branes. The open strings give rise to massless states of charge r which are localized on certain (self-)intersecting curves of the 7-branes on B 3 . We will call these "matter curves" and denote them by Σ r . In the M-theory picture, the charged matter fields are obtained by wrapping M2-branes on curves C f r which sit in the fiber of Y 4 over Σ r . Their charges are determined by the intersection product with the Shioda map: Apart from the geometry intrinsic to the fourfold Y 4 , the effective theory also depends on the background flux, which, via the duality to M-theory, is encoded in . Importantly for us, the primary vertical subspace H 2,2 vert (Y 4 , R), as sketched in (2.2), receives additional structure if Y 4 is elliptically fibered. In this case, H 2,2 vert (Y 4 , R) is spanned by three different types of 4-forms which can be characterised as follows: (2.17) Here {w i } is a basis of H 1,1 (B 3 ), S 0 denotes the zero-section and σ(S) the Shioda map image associated with the additional independent section S, as before. Note that not all elements in the set {π * (w i ) ∧ π * (w j )} are linearly independent within H 2,2 vert (Y 4 , R). As will become clear later, the subscript in H 2,2 (w) (Y 4 , R) refers to the modular weight w of the partition function, Z w,m , that is associated with the given flux.
Of special importance for us is the so-called transversal subspace H 2,2 . It is orthogonal to the other two subspaces in (2.17), i.e., a flux G ∈ H 2,2 (−1) (Y 4 , R) by definition satisfies the two conditions The transversality conditions (2.18) ensure that the flux G, which is a priori defined as background in the M-theory compactification on Y 4 , is compatible with the duality to F-theory on B 3 , in the sense of giving rise to a four-dimensional effective theory with full Poincaré invariance in R 1,3 . Such transversal fluxes related to the U (1) symmetry will be denoted by All other elements in H 2,2 vert (Y 4 ), while corresponding to valid flux backgrounds in M-theory or Type IIA string theory, are not liftable to F-theory. In the more general context of Mtheory/Type IIA string theory on Y 4 , one can in any case analyse the BPS invariants of an elliptic fibration in a non-transversal flux background, as pioneered in [76,77].
Let us now recall how the transversal fluxes determine the chiral index of massless charged matter in the context of four-dimensional F-theory compactifications [97]. As noted above, massless matter fields with U (1) charge Q = r are localised on a curve Σ r on the base B 3 . The fiber over Σ r contains the curve C f r , and an M2-brane wrapping C f r gives rise to a BPS particle in the dual M-theory picture. In fact, the fibration of C f r defines a surfaceΣ r , in terms of which the chiral index of massless matter of charge Q = r is computed as The third equality is a consequence of the factorized form (2.19). Furthermore we have introduced, after the last equality, the intersection product on B 3 that we will henceforth denote by a dot. In fact, the integral invariant χ G U (1) ,Q=r is exactly the genus-zero Gromov-Witten invariant for the fibral curve C f r with respect to G U (1) [6], The first equation follows from the geometric definition (2.1) because the moduli space of C f r with one point fixed coincides with the surfaceΣ r . The second equation holds because for the rational curves in the fiber, C f r = rC f r=1 in cohomology; if n G U (1) (C f r ) = 0, there must exist an actual curve in this class in the fiber. Hence the non-vanishing invariants n G U (1) (C f r ) = 0 do not involve multiple wrappings and therefore agree with the BPS invariants N G U (1) (C f r ).
More generally, we are interested in the structure of genus-zero integral BPS invariants for curves of the form with respect to fluxes in H 2,2 vert (Y 4 ) that satisfy (2.18). We denote these invariants as As long as C b is not a multiple of an integral curve class on B 3 , these integral invariants coincide with the Gromov-Witten invariants for the same curve. They are called the relative Gromov-Witten invariants with respect to the elliptic fibration π. These integral invariants can be packaged into a generating function Here we have defined the variables where τ is the Kähler parameter of the generic elliptic fiber E τ and z is the Kähler parameter of the fibral curve C f r=1 . From the perspective of Type IIA string theory on Y 4 , F G,C b contributes to the two-dimensional superpotential F(t), as defined in (2.7).
As stressed above, in the context of F-theory we must insist that G is a transversal flux. Under this proviso, (2.25) coincides with the elliptic genus of a four-dimensional solitonic string (up to a prefactor), as will be explained in Section 3.1. On the other hand, for Type IIA compactifications on fourfolds, there is no restriction to transversal flux backgrounds, and one can consider generating functions (2.25) for the other, non-transversal types of flux as well. As exemplified in [76,77], the partition functions for fluxes in H 2,2 (−2) (Y 4 ) and H 2,2 (0) (Y 4 ) are meromorphic (quasi-)modular forms of weight −2 and 0, respectively.

P 1 -Fibered Base Spaces and F-Theory/Heterotic Duality
As a special case of the structure outlined in the previous section, we now consider the situation where the base space B 3 by itself admits a further, rational fibration with section S − , possibly blown up along one or several curves on the section. The projection of the rational fibration will be denoted by The generic fiber is some rational curve C 0 . Prior to performing any blowup, the fibration can be understood as the projectivised bundle P(O ⊕L), where L is a line bundle on B 2 . This means that the section S − , which is oftentimes referred to as an exceptional section, has self-intersection S − · S − = −S − · p * (c 1 (L)). One can therefore define another section S + := S − + p * c 1 (L) such that S − · S + = S − · (S − + p * c 1 (L)) = 0 . (2.28) We can also perform an optional blowup along some curve Γ a in the base B 2 . After the blow-up, the rational fiber C 0 over the curve Γ a splits into two rational curves, The blowup introduces an exceptional divisor E a , which is itself a P 1 -fibration over Γ a . We label the curves C 1 Ea and C 2 Ea such that C 2 Ea is the fiber of the divisor E a . With this convention the intersection numbers of the exceptional curves C 1,2 Ea with the sections S ± and with E a become This process can of course be repeated for several different curves Γ a and followed up by successive blowups in the fiber. For simplicity of presentation, however, we assume only one such blow-up locus and hence drop the label a.
Whenever the base B 3 is endowed with such a P 1 -fibration, F-theory on B 3 has a clearly identifiable heterotic dual [99]. Viewed from the dual, weakly coupled eigenframe, the heterotic string theory appears as a four-dimensional compactification on a certain Calabi-Yau 3-fold Z 3 . The latter is elliptically fibered over the same base B 2 as before, Apart from the geometry of Z 3 , the dual heterotic theory is determined by a gauge background in form of some polystable E 1 The particular choice of background depends both on the details of the elliptic fibration Y 4 and on the original F-theory background flux, G U (1) .
Moreover, the optional blow-up along the curve Γ on B 2 on the F-theory side translates to heterotic 5-brane that is wrapped on the same curve Γ in B 2 , now viewed as the base of the heterotic 3-fold Z 3 . Such compactifications are inherently non-perturbative from the heterotic perspective.

Elliptic Genera and the Geometry of Modularity
We are now in a position to discuss the identification of the relative BPS invariants, defined in the previous section, with the degeneracies of states contributing to the elliptic genus of four-dimensional solitonic strings. We state this connection in Conjecture 1 of Section 3.1, which is a four-dimensional version of the correspondence between BPS invariants and elliptic genera in six dimensions [4, 39-44, 49, 50, 57, 61-63, 65, 65, 70-73]. In Conjecture 2 of Section 3.2 we present the modular properties of the four-dimensional elliptic genus. In Section 3.3 we point out an intriguing relation between the derivative sector of the elliptic genus and the BPS invariants of certain threefolds embedded in the Calabi-Yau fourfold. In Section 3.4 we explain how these threefold invariants can alternatively be computed from the non-transversal (−2)-fluxes, even though these do not have a direct interpretation in F-theory. This leads to an elliptic holomorphic anomaly equation.

The Elliptic Genus of Solitonic Strings in Four Dimensions
From a physical point of view, the main objective of this paper is to obtain a better understanding of four-dimensional critical and non-critical strings. This crucially rests on the observation, which was already put to use in [6], that the generating function (2.25) for the relative genuszero Gromov-Witten invariants coincides, up to a factor, with the elliptic genus of a solitonic string. The aim of this section is to spell out this relationship in greater detail and formulate it as a general conjecture that, supposedly, applies to all four-dimensional solitonic strings.
Let us first start by discussing how the solitonic strings arise in our context. Consider an F-theory compactification with base space B 3 . A D3-brane wrapped on a curve C b in the base B 3 gives rise to a string in the four-dimensional extended spacetime. The worldsheet theory of this string is an N = (0, 2) supersymmetric field theory [100]. One can now define the elliptic genus, as in (1.1), as a trace in the Ramond-Ramond sector of the N = (0, 2) superconformal worldsheet theory of the solitonic string, or equivalently as a partition function on a torus with modular parameter τ . As before, we consider a configuration with four-dimensional gauge group G = U (1), associated with charge operator J. Then the elliptic genus takes the form (1.1): where F R is the right-moving fermion number. The extra insertion of F R is needed to saturate the fermionic zero modes in the right-moving sector. The elliptic genus does not only depend on the choice of curve wrapped by the D3-brane, but also on the background flux G U (1) of the parent F-theory compactification. In order for an F-theory interpretation to exist, this flux must satisfy the transversality conditions (2.18). As a consequence of the supersymmetry in the right-moving sector, the trace (3.1) is a meromorphic function of q and ξ. In can be expanded as where is the zero point energy of the string on T 2 . As we will discuss in a few moments, the degeneracies N G U (1) ,C b (n, r) at level n and charge r for the flux ackground G U (1) , are conjectured to agree with the relative BPS invariants N G U (1) ,C b (n, r) that we have defined in the previous section. For a general curve C b , the solitonic string that arises from a wrapped D3-brane is generically some strongly coupled, non-critical string in four dimensions [91]. We can distinguish three possible types of strings. First, if C b is a shrinkable curve, we can decouple the dynamics of the string from the fields in the bulk of the base B 3 by taking the volume of B 3 to infinity. In this case we arrive at a four-dimensional superconformal field theory in the limit of decoupled gravity. An example of such a string would be a D3-brane wrapped on an exceptional curve. For instance, this can be of the form Ea as defined in (2.29), with normal bundle Such strings could be viewed as four-dimensional analogs of the familiar E-strings in six dimensions [101][102][103] and will be discussed in Section 6.1.
There are also non-critical strings associated with curves whose volume cannot be taken to zero without shrinking B 3 . Such non-critical strings cannot be decoupled from gravity. An example would be for instance a curve C b = H · H, where H is the hyperplane class on B 3 = P 3 . For this curve the normal bundle is . This example will be investigated in Section 6.2.
Finally, the case where The curve C b must be the fiber, C 0 , of either a rational fibration of the form (2.27) or of an elliptic fibration. In the first case, a D3-brane wrapped on C 0 gives rise to a solitonic, critical heterotic string. 11 In its proper duality eigenframe, this string becomes precisely the fundamental heterotic string compactified on the threefold Z 3 as given in (2.31), additionally equipped with some gauge bundle W . Moreover the elliptic genus (3.1), as defined via the G-flux background in F-theory, turns into the (not necessarily perturbative) chiral partition function of that heterotic string compactification. More precisely, the degeneracy N G;C 0 (n, r) counts (with signs) the excitations in the Ramond sector at excitation level n and charge r.
For the critical heterotic string, the vacuum energy in The mass of the physical states at excitation level n thus is where T is the tension of the heterotic string. This identifies N G U (1) ;C 0 (1, r) as the chiral index over the massless states of charge r. By duality with F-theory, this spectrum must coincide with the physical massless spectrum in the original F-theory compactification on Y 4 , and therefore the index N G U (1) ;C 0 (1, r) must agree with the chiral index (2.21): Furthermore recall from (2.22) that χ G U (1) ,r coincides with the genus-zero Gromov-Witten invariant for the fibral curve C f Q=r , which in turn is the same as the BPS invariant N G U (1) (C f r ). This demonstrates that the degeneracies N G U (1) ,C 0 (n = 1, r) are computable from certain BPS invariants of Y 4 for the special case of C b = C 0 for which N G U (1) ;C 0 (1, r) = N G U (1) (C f r ). With the situation in six dimensions serving as inspiration, it is natural to conjecture a far more general connection. More precisely, we conjecture that up to an overall factor of q E 0 , the elliptic genus (3.1) for any kind of solitonic string agrees with the generating function of relative BPS invariants (2.25) at genus zero:

Conjecture 1
The generating function F G U (1) ,C b for the relative BPS invariants at genus zero associated with the base curve C b , for any four-flux background G U (1) that satisfies the transversality conditions (2.18), is proportional to the elliptic genus (3.1) for the solitonic string obtained by wrapping a D3-brane on C b : In particular the relative BPS invariants for C b , N G U (1) ;C b (n, r), agree with the index-like degeneracies N G U (1) ;C b (n, r) of the excitations of the solitonic string at level n and charge r: This statement is the analogue of the well-tested duality between certain free energies of elliptic Calabi-Yau threefolds and the elliptic genera of solitonic heterotic and non-critical strings in six dimensions. The new ingredient in four dimensions, of course, is the dependence on the F-theory four-form flux G U (1) and its respective manifestation in the dual solitonic string.
As a corollary of this proposed general duality and eq. (3.5), the relative BPS invariants N G U (1) ;C 0 (1, r), where C 0 is the fiber of the P 1 -fibration B 3 , must agree with the chiral index of states of the F-theory compactification, and thus We will demonstrate this identity in the examples of Section 5, via explicit computations in mirror symmetry.

Modular Properties of Four-Dimensional Elliptic Genera
The elliptic genus has supposedly distinguished modular properties, which reflect its definition as a chiral partition function of a string wrapped on a torus T 2 with modular parameter τ . For example, the elliptic genus of a perturbative heterotic string in d = 6 dimensions with a single U (1) gauge group factor is a meromorphic Jacobi form of weight w = −(d − 2)/2 = −2 [26], as recalled in Section 1.1. For more general solitonic strings in six dimensions the elliptic genus is a meromorphic quasi-modular Jacobi form of weight w = −2 (see Appendix A). This applies in particular to solitonic strings that are dual to fundamental heterotic strings in the presence of 5branes [4]. Such modular behaviour is in general agreement with the relation between the elliptic genus and the BPS invariants on elliptic Calabi-Yau threefolds, whose modular properties have been analyzed in [25,82,83,[104][105][106].
One might expect that this simple pattern carries over to the strings obtained by wrapped D3-branes in F-theory compactifications to d = 4 dimensions that we consider here. The expectation would be that the elliptic genus should be a meromorphic quasi-modular Jacobi form of weight w = −(d − 2)/2 = −1.
As noticed in [6] for the special case of a heterotic string, this is not necessarily the case. Rather, for some explicit examples studied in that work, it was found that the elliptic genus (3.1) can in general also receive contributions which are not given by modular or quasi-modular forms. One of the main observations of the present work is that these contributions, while not modular by themselves, can actually be written as derivatives of modular or quasi-modular Jacobi forms; recall the symbolic representation (1.9) given in the Introduction. Such objects are special examples of so-called quasi-Jacobi forms as defined in Appendix A. What we encounter is in fact a concrete realisation of the mathematical conjecture of [25] that relative GW invariants of elliptic fibrations generally assemble into generating functions with values in the ring of quasi-Jacobi forms. In Section 3.3 we will in addition assign a specific geometrical meaning to the (quasi)-modular Jacobi forms whose derivative appears in the elliptic genera, namely in terms of BPS invariants of certain embedded threefolds.
Extrapolating from these observations we make the following general proposal:

Conjecture 2
The four-dimensional, U (1) refined elliptic genus (3.1) can be written as a sum of meromorphic modular and quasi-modular Jacobi forms of weight w = −1 and fugacity index m = 1 2 b · C b , where b is the height-pairing divisor (2.13), plus derivatives of modular and quasimodular Jacobi forms of weight w = −2 and the same fugacity index. More precisely, where g M , g QM , g M ∂ , and g QM ∂ are flux-dependent coefficients and with q = e 2πiτ and ξ = e 2πiz . Here, the numerators Φ M/QM w,m (τ, z) denote generic (quasi-)Jacobiforms of indicated weight and (integer) index given by As mentioned in the Introduction, the novel (quasi-)modular partition functions Z M/QM −2,m of weight w = −2 have the properties characteristic of elliptic genera of chiral, six-dimensional theories. Indeed, we will argue that they encode the relative BPS invariants of certain elliptic three-dimensional sub-manifolds, Y 3 , of Y 4 . In special cases, when the elliptic threefolds Y 3 are themselves Calabi-Yau spaces, this assertion can be verified explicitly by mirror symmetry. More generally, we will provide various general consistency checks which support this claim also when Y 3 is not a Calabi-Yau space. As we will demonstrate in Sections 5 and 6, the general structure we propose can be verified for a variety of examples, in particular for all the three different basic types of base curves, C b , as characterised in Section 3.1.
Let us illustrate at this point the structure for the important example of the solitonic heterotic string. To this end consider a base B 3 of Y 4 which is the blow-up of a rational fibration (2.27), and for simplicity assume that the blow-up has been performed only over a single curve Γ in the base, B 2 , of this rational fibration. Our notation for this type of geometries has been introduced in Section 2.3. Again we take the gauge group to be G = U (1), so that the only fluxes satisfying the transversality condition (2.18) are the U (1) fluxes (2.19) given by In this concrete situation, as exemplified in Section 5, one can write the elliptic genus of the heterotic string in the following geometric, closed form: with flux-dependent coefficients explicitly given by (3.14) Here C 0 and C 1 E denote the curves defined around equation (2.29), the divisor b is the heightpairing as given in (2.13), and the set {C i } is a suitable basis of curves on the base B 2 of B 3 .
The latter point will be explained in more detail in Section 3.3. Mathematical and physical constraints restrict the (quasi-) modular forms in (3.13) as follows: As always, Φ * ,(Q)M w,m denotes a generic weak Jacobi form of specified weight and index, which can be written as a polynomial in the generators of the ring J * ,(Q)M w,m of (quasi-)modular Jacobi forms (see Appendix A.1).
Note that since the weight of the Z * −1,m is odd, these objects are necessarily proportional to the unique odd-weight generator φ −1,2 of the ring of Jacobi forms. Furthermore, since φ −1,2 ∼ z, they vanish identically unless we refine the elliptic genus with regard to at least one U (1) factor. Note also that there cannot be a 1/q pole in Z * −1,m because the left-moving ground state is uncharged and so cannot be multiplied by z. Thus the Z * −1,m are actually holomorphic in q and take a very restricted form, as indicated.
In summary, the relationship (3.13)-(3.15) between flux-dependent geometric intersection data on the one hand, and modular, quasi-modular and derivative sectors on the other, is one of the main results of the present work, and is a concrete manifestation of the map (1.10) mentioned in the Introduction.

Geometric Interpretation of the Derivative Sector of Z −1,m (q, ξ)
We now point out an intriguing interpretation of the derivative contributions, Z i −2,m (q, ξ), to the elliptic genus, namely in terms of BPS invariants of certain threefold geometries, Y 3 , which are embedded in the given elliptic fourfold, Y 4 . For the example of the heterotic string, we will be able to explain this interpretation based on our understanding of the moduli space of at least some of the curves whose BPS invariants enter the elliptic genus. The relation between the derivative contributions and certain threefold invariants is, however, not restricted to heterotic strings, as we will show explicitly in Section 6.
To understand the heterotic setup, let us first assume that the Mori cone of effective curves on B 2 is simplicial and identify its generators with the basis {C i } on which the coefficients in the sum (3.13) depends via (3.14). We will drop the assumption of a simplicial Mori cone at the end of this section. The curve classes b · p * (C i ) in (3.13) can be written as To see this, note that we can parametrise the height pairing divisor as Then (3.16) follows from the fact that S − · p * (C i ) gives back the curve class C i on B 2 , while the intersection of p * (C i ) with the divisors E and p * (C j ) lie entirely in the fiber of the rational fibration B 3 .
Since the curves C i are the generators of the Mori cone of B 2 , the dual curves C i on B 2 are generators of the Kähler cone of B 2 , whose closure is contained in the closure of the cone of effective curves. We assume for simplicity that the C i are integral, leaving the discussion of a much more general setting to the end of this section. They are given by and have the important property, characteristic of generators of the Kähler cone, that . To arrive at integral classes, let us factor out 1/2m and consider the pullback p * (C i ) as a divisor on B 3 . Since each C i moves in a family on B 2 , so does the divisor p * (C i ) on B 3 . We can then define a collection of elliptic threefolds, Y i 3 , by restricting the elliptic fibration of Y 4 to the a generic member of this family of divisors: Any single such threefold is by construction an elliptic fibration with projection In fact, the base p * (C i ) is a P 1 -fibration over C i with generic fiber C 0 (blown up at the intersection of Γ with C i ). See Figure 2 in the Introduction for an illustration.
Depending on whether is either trivial or negative. This follows from the adjunction formula: Even if Y i 3 is by itself not Calabi-Yau, we can consider the relative BPS invariants with respect to C 0 on Y i 3 , denoted by N i C 0 (n, r), and package them into a generating function, F i C 0 (τ, z). We propose that these invariants determine the derivative pieces in the elliptic genus (3.13): The N i C 0 are not to be confused with the invariants N G;C 0 of the fourfold Y 4 discussed before, which were defined relative to a transversal four-form flux G U (1) . Rather, we claim that they are relative BPS invariants of a generic member, Y i 3 , of the family of elliptic threefolds embedded inside Y 4 as in (3.19).
If we assume this, the general considerations of [25] imply that the generating function In physics terms this can be equivalently understood by first assuming that Y i 3 is Calabi-Yau and considering F-theory on Y i 3 as an auxiliary, chiral theory in six dimensions. With our assumption on the nature of the N i C 0 (n, r), the object Z i −2,m (τ, z) is then simply the elliptic genus of the N = (0, 4) supersymmetric string obtained by wrapping a D3- is expected to admit a fibration over the curve C i whose fiber is a generic member of the family Y i 3 . 12 That is, there exists a projection The underlying six-dimensional theory naturally arises in the decompactification of the base curve C i and so is well-defined by itself.
Since the normal bundle to p * (C i ) is in this case non-trivial, even in the decompactification limit we cannot define a bona-fide six-dimensional theory by restricting F-theory to Y i 3 . It is even more intruiging to find that nevertheless Z i −2,m (τ, z) behaves in many respects like the elliptic genus of a sixdimensional string even in this case, as will be discussed further in Section 4. In particular, one can formally associate Z i −2,m (τ, z) to an elliptic surface with (24 + 12n) singular fibers, where n = C i · B 2 C i . An example will be presented in Section 5.2. In the sequel we will formally relate the Z i −2,m (τ, z) to such six-dimensional sectors, with the understanding that a direct interpretation as elliptic genera in six dimensions is possible only if Y i 3 is Calabi-Yau. Let us now turn to the crucial claim that Z i −2,m (τ, z) encodes the BPS invariants N i C 0 (n, r) pertaining to the threefolds Y i 3 as shown in (3.22). In the remainder of this section we will prove this assertion at level n = 1. To this end we interpret the expression (3.13) for the elliptic genus as a statement about the decomposition of the moduli spaces of curve classes C = C 0 +nE τ +C f r into various components. For the special case where n = 1 this will allow us to deduce that the multiplicities N i C 0 (n = 1, r) are indeed BPS invariants on Y i 3 . Extrapolating this observation to all n then leads to (3.22).
To arrive at this picture, we first define the following generating functions associated with the non-derivative contributions to the elliptic genus (3.13): This is analogous to (3.22), but with the important difference that, unlike the invariants N i C 0 (n, r) which appear in (3.22), the invariants N 0 C 0 (n, r) and N E C 0 (n, r) do not correspond to BPS invariants of some auxiliary elliptic threefolds. Expanding both sides of (3.13) order by order in q and ξ then gives a relation between the BPS invariants N G;C 0 (n, r) in Z G;C 0 on the left hand side, and the invariants N 0 C 0 (n, r), N E C 0 (n, r) and N i C 0 (n, r) on the right. Recall next that the quantities on the left hand side, N G;C 0 (n, r), are the flux dependent, relative Gromov-Witten invariants, as defined in (2.1), for the curve C = C 0 + nE τ + C f r . According to (2.1), where we denote byΣ n,r the class of the moduli space of stable holomorphic maps at genus g = 0 and with one point marked associated with C = C 0 + nE τ + C f r . When both sides are expanded in q n ξ r , the relation (3.13) therefore boils down to the statement that where the extra factor of r in front of the N i C 0 (n, r) is caused by the derivative in (3.13). To interpret (3.27) further, we note that while for general n the moduli spacesΣ n,r are difficult to construct, we are in a comfortable situation when n = 1 and C 0 is the rational fiber of B 3 : The moduli spaceΣ 1,r is equal to the moduli space of stable holomorphic maps of genus zero for the purely fibral curve C f r , up to terms orthogonal to any transversal flux satisfying (2.18). This follows from the identity (3.8), which in turn is a consequence of the duality between F-theory and the heterotic string. Since the moduli space for C f r is the surfacê Σ r given in (2.20) with base Σ r , we know that for transversal flux (3.28) Plugging this into (3.27), which must hold for any element F ∈ H 1,1 (B 3 ), yields The point is now that, at least for n = 1, we can understand why the N i C 0 (1, r) are invariants of the embedded threefolds Y i 3 : Suppose first that a given threefold Y i 3 is by itself a Calabi-Yau space. In this case, Y 4 admits a fibration with fiber Y i 3 over the curve C i of the form (3.23), see Figure 3. The invariant N i C 0 (1, r) appearing in (3.29) can thus be interpreted as the multiplicity of the base curve C i of this fibration as a component of the matter curve Σ r . 13 In other words The multiplicity N i C 0 (1, r) in the above decomposition is simply given by the number of points on Y i 3 over which the elliptic fiber degenerates such as to support a state of charge r. Indeed, where we used that p * (C i ) does not intersect with fibral curves and that p * (C i ) · C j = δ i j , which follows from the fact that C i is the curve class dual to Under the present assumption that C i are the generators of the simplicial Mori cone, the intersection number Σ r · p * (C i ) is non-negative and counts the number of points on B i 2 where the degeneration occurs, in codimension-two on B i 2 . This identifies N i C 0 (1, r) with the BPS invariant for the curve C f r viewed as a curve inside the threefold Y i 3 . The same argument leading to (3.8), now applied to threefolds, shows that this in turn agrees with the BPS invariant of the curve C 0 + E τ + C f r as a curve inside Y i 3 . Hence we have shown that the N i C 0 (1, r) are indeed relative BPS invariants of Y i 3 .
13 To see this, note that N i C 0 (1, r) is the multiplicity of the component 1  (3.30), and from the picture we see that it coincides with the number of points on Y i 3 over which the elliptic fiber E τ degenerates. The remaining components of Σ r in the decomposition (3.30) lie within special fibers of the fibration ρ i (3.23) and are not depicted.
These considerations continue to hold if Y i 3 is not a Calabi-Yau space itself, as the argument was purely intersection theoretic. Indeed, the general formalism of [108] implies that the virtual class of the moduli space of curves C 0 + nE τ + C f r on Y i 3 is related to the class of the moduli space on Y 4 by restriction. Our elementary considerations for the special curves above are a manifestation of this.
While it is harder to make this explicit for general wrapping numbers n from first principles, we can at least translate the relation (3.27) into the following geometric statement: Up to terms orthogonal to the transversal subspace of H 2,2 vert (Y 4 ) defined in (2.18),Σ n,r is equivalent to the class of a fibration of C f r over a curve Σ C 0 ,n,r which is given by Indeed, integrating G U (1) = σ ∧ π * (F ) over such a fibration would give a factor of r from the fibral piece along with the class F , precisely as reflected in (3.27). The crucial claim here, proven above only for n = 1, is that the integral numerical coefficients N i C 0 (n, r) are by themselves BPS invariants of the threefolds Y i 3 embedded in Y 4 . This implies that the objects Z i −2,m (τ, z) in (3.22) are modular or quasi-modular Jacobi forms of weight w = −2, while the extra factor of r obtained by integration of G U (1) explains why the Z i −2,m (τ, z) appear with a derivative in (3.13). It would be extremely interesting to establish a geometric proof of this interpretation of the N i C 0 (n, r) also for n > 1. We have been assuming that the basis {C i } corresponds to the generators of the simplicial Mori cone of B 2 , so that they are effective and their dual curves satisfy (3.18). However the results do not depend on this restriction. More generally, it suffices to pick a basis of effective curves C i defining the threefold geometries Y i 3 as in (3.19), and to take C i as the dual basis of 2-cycle classes on B 2 . In general this may imply, first, that not all C i are effective, and second that C i · C i may be negative. The intersection theoretic argument why N i C 0 (1, r) describes BPS invariants on Y i 3 does not hinge upon effectiveness of C i , however, since we can view N i C 0 (1, r) simply as the coefficient in the expansion (3.30) in terms of curve classes. In this more general situation, N i C 0 (1, r) may in particular be negative. This is to be interpreted in such a way that the degeneration locus in Y i 3 where the fiber contains the curve C f r occurs in codimension-one on B i 2 . Note also that if C i · C i < 0, the curve C i is rigid and hence also Y i 3 is rigid as a divisor in Y 4 , but this does not invalidate our arguments either.
The discussion in this section was tailor-made for the special case of heterotic elliptic genera. For non-critical strings the derivative terms in the elliptic genus encode the relative BPS numbers of embedded threefolds sometimes constructed in a slightly different way. For this we refer to Section 6.

Elliptic Holomorphic Anomaly Equation
So far we have focused in this section on the properties of the relative BPS invariants in transversal flux backgrounds, which were defined via eq. (2.18). This is required for having a fourdimensional interpretation within F-theory on Y 4 , and a meaningful elliptic genus in the first place. We have seen that in general derivative contributions to the elliptic genus appear, such as indicated in (3.13). These take the form of derivatives of Jacobi forms, Z i −2,m (q, ξ), which encode relative BPS invariants associated with the embedded threefolds, Y i 3 , of Y 4 . As previewed in Section 1.2, this results not only in a violation of modular invariance (A.1), but also of the invariance under the transformations z → z + λτ in (A.2), which can be interpreted as spectral flow in the U (1) subsector. 14 From the point of view of the four dimensional elliptic genus, the derivative terms inflict an anomaly on these symmetries, and turn it into a quasi-Jacobi form. However, in analogy to the treatment of the quasi-modular form E 2 , one can cancel these anomalies by trading the derivative terms in Z G U (1) ;C b (q, ξ) against non-holomorphic derivatives as in (1.12). This means that we pass from the holomorphic, but non-modular elliptic genus Z G U (1) ;C b (q, ξ) to the almost holomorphic, but modular quantityẐ G U (1) ;C b (q, ξ), for which we replace the derivatives ξ∂ ξ ≡ 1 2πi ∂ z as follows (see Appendix (A.1)): The resulting non-holomorphicity ofẐ G U (1) ;C b (q, ξ) is characterised by the equation where we parametrise the elliptic genus as in (3.9) and have abbreviated g . This equation is a version of the elliptic holomorphic anomaly equation which was introduced in the context of generating functions for relative BPS invariants of elliptic fibrations in [25]. Compared to elliptic genera in six dimensions, which are lacking a derivative contribution, we see that the appearance of such an elliptic holomorphic anomaly equation is a genuinely new feature in four dimensions.
The elliptic holomorphic anomaly equation admits a beautiful geometric interpretation. Recall that the right-hand side of (3.34) consists of the (quasi-)modular objects, Z −2,m (q, ξ), that encode the relative BPS invariants of the threefolds Y 3 . Remarkably, as we explain now, the same threefold invariants appear also as fourfold invariants for a suitable choice of non-transversal background flux G −2 ∈ H 2,2 (−2) (Y 4 , R), as defined in (2.17). We will refer to such non-transversal fluxes as "(−2)-fluxes" for brevity. 15 In fact, it has already been observed in [76,77] that the generating function for certain relative genus-zero BPS invariants in a (−2)-flux background is a meromorphic (quasi-)modular form of weight w = −2. Such invariants are non-vanishing even in absence of a refinement by an extra gauge symmetry (in F-theory language). This is to be contrasted with the relative BPS invariants for the transversal flux backgrounds that were considered in the previous sections. The important point is that the elliptic holomorphic anomaly equation in its form (3.34) admits a representation in terms of the generating function for a specific type of (−2)-flux. More precisely we have Here b is the height pairing associated with the U (1), and, as always, we have defined The specific form of G −2 that appears in (3.35) can be deduced from the general considerations of [25] applied to our situation. Alternatively, we can arrive at the same conclusion via more elementary geometric observations based on the results of Section 3.3, which are supported by our detailed analysis of examples in Sections 5 and 6.
For illustration, consider the relative BPS invariants associated with a curve C 0 with zero self-intersection, which figures as the fiber of some rational fibration, B 3 ⊂ Y 4 , see (2.27); recall that this is the situation where a solitonic heterotic string appears. In this case the elliptic holomorphic anomaly equation for the elliptic genus (3.13) takes the form (3.37). While the first equality follows immediately from (3.13), the second equality is non-trivial and rests on the following geometric considerations: First introduce a convenient basis for the space of non-transveral (−2)-fluxes in H 2,2 (−2) (Y 4 , R): In the notation of Section 2.3, C Γ denotes a curve class on B 2 with C Γ · Γ = 1, and we have picked a pair of dual curves C i 0 and C i 0 on B 2 . The classes G E and G 0 are hence dual to the curves C 2 E and C 0 in the fiber of B 3 , while G i is dual to the curve C i on B 2 . The important claim is that the contributions Z i −2,m (q, ξ) to the elliptic genus (3.13) can be computed as while the remaining two basis elements lead to the following vanishing BPS invariants, We will provide arguments for these assertions below. Assuming (3.40) and (3.41) for now, we proceed by expanding (3.37), viewed as class of the (−2) flux, in the above basis as Hence by linearity of the BPS invariants, together with (3.40) and (3.41), it is obvious that This explains also the second equality in the elliptic holomorphic anomaly equation (3.38). It remains to justify (3.40) and (3.41). While we cannot give formal proofs beyond the non-trivial checks in the examples of Section 5, we provide instead some intuition why (3.40) should hold. To this end, consider the relative BPS invariants N G i ;C 0 (n, r) for n = 0 and r = 0. According to our claim, these invariants should agree with the threefold invariants N i C 0 (n, r) for n = 0 and r = 0 in the expansion (3.22) of Z i −2,m (q, ξ). Our starting point to verify this is the definition of N G i ;C 0 (n, r) as the overlap of the flux G i with the virtual fundamental class of the moduli space of the curve C 0 in Y 4 with one point fixed. Since C 0 is fibered over B 2 , this class can be identified with the class of the surface obtained by fibering C 0 over the canonical divisor K B 2 ; 16 that is, with the class inside Y 4 given by Here S 0 is the zero-section of the fourfold Y 4 . This allows us to compute N G i ;C 0 (0, 0) as where we have used the fact that S 0 is a section on Y 4 and S − is a section on the P 1 -fibration B 3 . The expression for N G i ;C 0 (0, 0) in (3.45), in fact, can be seen to exactly agree with the invariants N i C 0 (n, r) for n = r = 0. To see this, suppose first that the curve C i is a rational curve with C i · B 2 C i = 0. According to the discussion in Section 3.3, in this case the threefold Y i is a Calabi-Yau space which is K3-fibered over C i . The invariant N i C 0 (n, r) for n = r = 0 is then simply the BPS invariant for C 0 within the Calabi-Yau threefold Y i 3 , and hence N i C 0 (n, r) = −2. This is because within Y i 3 , C 0 is fibered over the rational base curve C i and the (signed) Euler character of its moduli space is the integral C i K C i . By the adjunction formula we see that As noted already before, this reflects the fact that, by the results of [108], the virtual class for the moduli space of the curve C 0 on Y i 3 is related to the class of its moduli space on Y 4 by restriction.
In the examples of Sections 5 and 6, we will indeed observe a precise match between the N G i ;C 0 (n, r) and the invariants N i C 0 (n, r) for zero, but also for non-zero, values of n and r. Beyond such explicit examples it is much harder to make a direct argument for general values, based on the moduli space of curves. At any rate, we will explain the analogue of (3.45) for the elliptic genera also for other types than heterotic strings in four dimensions. Furthermore, it is clear that N G 0 ;C 0 (0, 0) = 0 and N G E ;C 0 (0, 0) = 0, because the overlaps in (3.45) vanish geometrically. The vanishing of the invariants at all levels, as claimed by (3.41), will be explicitly verified for the examples further below.

Elliptic Genera, Anomalies and Modularity
The observation of the previous sections was that the four-dimensional elliptic genus need not be modular or quasi-modular in the usual sense. Once applied to heterotic strings, this raises the question how this phenomenon is compatible with the structure of anomaly cancellation. In this section we first review the well-known interplay [26,27] of the elliptic genus of the heterotic string with the structure of 1-loop anomalies and their cancellation by the Green-Schwarz mechanism. We then explain how four-dimensional anomaly cancellation works even when the elliptic genus is not modular but rather has a derivative component, and also discuss the situation when it is quasi-modular rather than fully modular.
In d = 2n + 2 dimensions, the 1-loop gauge and gravitational anomalies are characterized by the anomaly polynomial where we sum over all massless particle species of multiplicity n s (R) in representation R of the gauge group and with spin s. The (d + 2)-form I s (R)| d+2 is formed by products of the gauge field strength F and the curvature 2-form R. For example, a complex chiral Weyl fermion contributes to (4.1) with whereÂ(T ) is the A-roof genus.
In the following we will focus on the gauge anomalies associated with a single U (1) gauge group and define Based on the above expressions, the anomaly coefficients A (d) in d = 6 and d = 4 dimensions are given by: Here we sum over the Weyl fermions of U (1) charge r. In d = 6 dimensions, if we consider a theory with minimal N = (1, 0) supersymmetry, the number of charged Weyl fermions agrees with the number of half-hypermultiplets of corresponding charge. In d = 4 dimensions, the anomaly coefficient involves the chiral index χ r , i.e., the number of chiral minus anti-chiral Weyl fermions of charge r.

Modular Elliptic Genera
We will first review anomaly cancellation in the more familiar case of a modular invariant heterotic string elliptic genus. In the present context, this primarily concerns flux compactifications that are dual to perturbative heterotic strings. Let us recall that the U (1)-refined elliptic genus Z −n,m (q, z) of a perturbative, d = 2n + 2 dimensional heterotic string is expected to be a weak Jacobi form [33] of modular weight w = −n and some index m (in this work, n = 1, 2 will be relevant). As we have seen, this is not necessarily true in d = 4 and so the statements that follow will eventually be adapted to the more general situation. Let us however for the moment assume that Z −n,m (q, z) is a weak Jacobi form, and turn later to the required modifications. See also the remarks in the Introduction and the defining modular transformation properties of Jacobi forms given in (A.1) and (A.2).
From a weak Jacobi form one can always strip off the quasi-modular Eisenstein series E 2 by writing Z so that the remainder,Ž is modular invariant term by term. It involves meromorphic modular forms M 2l of weight 2l which lie in the ring generated by E 4 and E 6 , divided by 1/η 24 . The idea of how this modular structure implies the Green-Schwarz anomaly cancellation goes back to [26,27] and rests on two properties of the elliptic genus: 1) The anomaly coefficient (4.4) is the coefficient ofẑ n+2 of the elliptic genus at q 0 . More precisely: Key is the observation that due to well-known properties of modular forms, M 2 (q) cannot have a constant piece and therefore does not contribute. Thus all contributing terms must involve E 2 's from the exponential, which brings down powers ofẑ 2 ∼ Tr F 2 . This is tantamount to saying that the anomaly polynomial must necessarily factorize. This in turn implies that the anomaly can be cancelled; that is, in familiar terms: 2) The Green-Schwarz anomaly cancelling term is given by S GS ∼ B ∧ X 2n (F ), and its numerical coefficient, is computed as a one-loop amplitude in the heterotic string [30,31]. The integrand is given by the modular invariant coefficient ofẑ n in the elliptic genus. More precisely, what enters is the modified, almost holomorphic elliptic genus,Ẑ −n,m (q,ẑ), for which all occurrences of E 2 's are replaced by their modular invariant, but non-holomorphic version,Ê 2 = E 2 − 3 πImτ . Explicitly: Therefore one finds mA which expresses that the Green-Schwarz term precisely cancels the anomaly. The extra factor of m arises from the Chern-Simons term to which the other leg of the B-field couples, as we will show later. We can be more explicit if we specify the dimension. In d = 6, the scarcity of independent modular forms, plus the requirement that the left-moving ground state be uncharged, implies that the elliptic genus up to orderẑ 4 is fixed up to one model dependent parameter besides m, which we denote by c: This then leads to (4.14) For reference, examples of elliptic genera that we will meet again further below are given by where E w,m = E w,m (q, z) are the Eisenstein-Jacobi forms 17 defined in Appendix A. This bilinear form of elliptic genera naturally appears in perturbative heterotic strings compactified on K3, with bundles switched on such as to leave a single U (1) unbroken. In this case c is fixed such that Analogous statements apply to perturbative heterotic strings in d = 4. Given the various constraints, we find for the modular part of the elliptic genus: up to an overall numerical factor c. The actual elliptic genus is then obtained by multiplying this with g M as in (3.9), which depends on the four-form flux that needs to be switched on. The two overall factors fix the elliptic genus up to orderẑ 3 and we thus have which by virtue of the relations (A.37) is a Jacobi form proportional to φ −1,2 (q,ẑ) and thus a special case of (4.17). Including the flux dependent pre-factor, it leads to A (4) = mA Obviously, if several such terms appear, they can simply be summed over.
The structure of derivatives as exhibited in (4.19) points to a deeper rôle derivatives play for four-dimensional elliptic genera. One can view (4.19) as a special linear combination that happens to be modular, while the other natural combination is precisely of the form of the non-modular, derivative piece of the elliptic genus:  Of course, in the physical partition function one needs to equip this with an additional fluxdependent prefactor, which we denote by g M,∂ . This leads us to discuss the derivative elliptic genera Z (4),∂ −1,m (q,ẑ) more generally, and in particular to the question how anomalies can be cancelled in view of the fact that the Z (4),∂ −1,m (q,ẑ) are not modular invariant, while modular invariance was instrumental in proving anomaly cancellation in the first place.
Note, however, that because of the derivative relationships between the elliptic genus and the anomaly polynomial (4.8) on the one hand, and the anomaly cancelling term (4.10) on the other, it follows that the factorization of the anomaly in 4d is inherited from the six-dimensional one, even though the 4d elliptic genus Z (4),∂ −1,m (q,ẑ) does not transform as a Jacobi form. Neverthless, as already noticed in [6], it has good quasi-modular properties at any given fixed order in thê z-expansion so that a well-defined modular integration, as required in (4.10), can be performed.
More precisely, for a four-dimensional elliptic genus of the derivative form We can understand the relative factor of 4 between A (4),∂ and A (6) diagrammatically, in that it corresponds to the 4 choices of one of the 4 external legs to be given a VEV in the transition from the quartic six-dimensional anomaly to the cubic four-dimensional anomaly. Similarly the factor of 2 relating A (4),∂ GS and A (6) originates in the choice of two external legs in the six-dimensional Green-Schwarz terms, as compared to the single external leg in its four-dimensional analogue.
The mismatch by a factor of two in the derivative sector, indicates that the anomaly is not cancelled by the standard Green-Schwarz term involving the universal B-field. Rather, as we will argue later in Section 4.3, the hidden six-dimensional geometry of the derivative sector will always correlate with the correct number of additional B-fields and their couplings, such that in the end all such anomalies will be cancelled. Before discussing this point, however, we turn to the other subsector of the d = 4 elliptic genus, namely the one for which the elliptic genus is quasi-modular rather than modular.

Quasi-Modular Elliptic Genera
We have indicated before that for certain fluxes "non-perturbative" elliptic genera can arise that are only quasi-modular, which means that E 2 pieces can appear inŽ (d) −n,m (q,ẑ) even after stripping off the exponential prefactor as in (4.6). For these fluxes the arguments about factorization of the anomaly polynomial do not hold. Moreover the one-loop computation of the standard Green-Schwarz term that involves the universal B-field will in general not be applicable, as it can possibly capture only the perturbative piece of the anomaly, and so further Green-Schwarz terms that involve extra B-fields will necessarily come into play.
Let us be more specific and consider first six-dimensional theories for which the non-perturbative, quasi-modular piece of the heterotic elliptic genus has the form: It arises whenever the curve C 0 associated with the heterotic string splits into to two curves C i E , each associated to an E-string. In this case, the U (1) indices m 1 and m 2 are determined geometrically as This is precisely what is reflected by the two factors Z E , each of which can be associated to the partition function of a non-critical E-string [39]. In fact, its form (up to orderẑ 6 ) is completely fixed by the decomposition (4.6) and by requiring that the ground state is uncharged (noẑdependence of the 1/q term): (4.26) As a consequence we can compute the anomaly (4.8) and the putative Green-Schwarz term (4.10) in closed form: Note that the anomaly nicely separates into independent pieces related to the two individual E-strings, and in particular that cross terms of the form (∂ẑ 4−k Z E 4,m 1 )(∂ẑ k Z E 4,m 2 ), k = 1, 2, 3, vanish. This fits the Hořava-Witten picture where the gauge symmetry is localized on two end-of-the-world branes.
More importantly, note that the putative Green-Schwarz term (4.28) does not cancel the anomaly (4.27). Rather, this anomaly is supposedly cancelled by the Chern-Simons terms localized on the heterotic M5-branes that are necessarily present in this situation. Clearly this is a non-perturbative sector of the theory that cannot be captured by any perturbative calculation of the Green-Schwarz term, so that this is entirely as expected.
We now turn to the four-dimensional version of the story. From general properties (such as having no charged ground state) we can infer a priori that the quasi-modular piece of the elliptic genus and must be of the highly restricted form up to an overall numerical factor, c. Again we should here keep in mind that for the actual elliptic genus, this expression needs to be multiplied with a flux factor, g QM . The overall factor ofẑ 3 arises from the Jacobi forms of negative weight. An immediate consequence of this is that the naive, perturbative Green-Schwarz term vanishes identically, because according to (4.10) it is determined by a single derivative with respect toẑ. On the other hand, the cubic anomaly will in general be non-zero: This shows even more clearly than in six dimensions that the quasi-modular part of the anomaly must be cancelled by other, non-perturbative contributions. In a spirit similar to eq. (4.19) for fully modular elliptic genera, we can write Z QM −1,m in a suggestive form which naturally makes contact to the underlying heterotic/E-string geometry: where m = m 1 + m 2 . This being proportional to φ −1,2 φ −2,1 (as per (A.37)) is a special case of (4.29) and leads to A (4),QM = (m 2 − m 1 )g QM . Recall that the m i are determined in terms of intersection numbers of the E-string geometry as shown in (4.25), which we will derive in the next section. By considering the other natural combination of the derivatives, we can capture the quasimodular, derivative sector as well:

Effective Field Theory and Anomaly Cancellation from Flux Geometry
We now match the Green-Schwarz (GS) terms, as computed from the elliptic genus of F-theory compactifications, with the anomaly cancelling terms that arise in the effective field theory from geometry, The point is to understand how the different modular properties of the various contributions to the elliptic genus reflect the different geometrical origins of the anomaly cancelling terms.
For four-dimensional perturbative heterotic string compactifications on smooth Calabi-Yau spaces with general abelian gauge groups, the Green-Schwarz terms have been analyzed in [85] and extended to non-perturbative models with heterotic 5-branes in [109]. The perturbative GS mechanism does not only involve the universal heterotic 2-form field B 0 , but in general also the 2-form fields dual to the axionic scalars that are obtained from B 0 by dimensional reduction. In the presence of heterotic 5-branes, additional counterterms are induced by the self-dual tensor fields coupling to the 5-branes (see [110][111][112] for their M-theory origin). This feature is present already in compactifications to six dimensions [113].
In this sub-section we will analyze the field theoretical realization of these Green-Schwarz terms in terms of the elliptic genera discussed in previous section. Our main results can be summarised as follows. Let us first recall how we have determined, in Section 4.1, the 1-loop anomaly coefficients (4.8) in six and four dimensions, via the elliptic genus of the heterotic string. In general, the anomaly coefficients decompose according to the modular and the quasi-modular contributions to the elliptic genus: is computed from the modular part of the elliptic genus, and in four dimensions we have indicated that there can be an additional derivative part (recall in particular eq. (4.23)). We will find, as expected, that these "modular" Green-Schwarz terms perfectly match the perturbative Green-Schwarz terms in the effective action that involve the universal heterotic B-field and, in four dimensions, also the dual axions which relate to the derivative part. Moreover, a possible deficit between this perturbative Green-Schwarz mechanism and the total anomaly will be attributed to the quasi-modular part of the anomaly, A (d),QM . This deficit needs to be cancelled via non-perturbative Green-Schwarz terms involving the 5-brane tensor fields as discussed in [109,113]. Now let us go into the details. In order to avoid the complication of finding heterotic duals [114][115][116][117] for F-theory models with abelian gauge groups, we will first perform the computation in the Type IIB/F-theory duality frame. In this way we will arrive at an intersection theoretic interpretation of the Green-Schwarz terms that we computed from the elliptic genus in the previous sections. The form of the Green-Schwarz mechanism in this duality frame has been derived in detail in the literature, beginning with [118] and substantially extended in [119][120][121][122][123][124][125]. We can hence be brief and focus on comparing the results of the elliptic genus to the anomaly of the effective action.
In F-theory compactified to d dimensions, the Green-Schwarz counterterms are encoded in the Chern-Simons-type couplings of the Ramond-Ramond 4-form C 4 to the 7-branes, Here we are assuming that a stack of 7-branes wraps a divisor D A on the internal space and carries a gauge group G A . Our conventions for the normalization of the action follows the discussion in [125]. To avoid clutter of notation, we will right away specialise to the situation where the gauge group is given by G = U (1), with field strength F . In this case, the divisor D A is to be identified with the height-pairing b defined in (2.13) on the internal space. We will furthermore focus purely on gauge anomalies, neglecting gravitational ones. The relevant part of the Cherns Simons couplings then reads We will first discuss the implications of this Chern-Simons coupling in comparison with the elliptic genus of the dual heterotic string for compactifications to six dimensions. Most of this material is well known.

GS Mechanism in Six Dimensions in Relation to (Quasi-)Modularity
The compactification space of a Type IIB/F-theory in six dimensions is given by the base, B 2 , of an elliptic Calabi-Yau threefold, Y 3 . Let us fix a basis for its (co-)homology, The intersection form on H 2 (B 2 ) is determined by the inverse matrix, Ω αβ . In terms of the basis of H 2 (B 2 ) we expand the Ramond-Ramond 4-form field as Note that a D3-brane wrapping some curve C I = C I α ω α gives rise to a string that couples locally to the combination By dimensional reduction of the 7-brane Chern-Simons couplings (4.39), we obtain the following Green-Schwarz interactions: where b is the height-pairing associated to the U (1) gauge group. By standard arguments these couplings lead to a gauge variation of the effective action which is encoded in an anomaly eight-form, I eff = A  This tree-level contribution from the exchange of the various B-fields from the effective action is given by We will now separate the different contributions to A (6) eff as based on their respective geometric origin (and later, modularity properties). For this we consider a simplified but prototypical situation that captures all relevant contributions. Following the general philosophy of Section 2.3, we specialise to an F-theory base B 2 which is by itself a P 1 fibration. While every F-theory base with a standard heterotic dual is a blow-up of a rational fibration, the simplification we are going to make is to consider only a single blowup over a point on the base of this fibration; this of course is easily generalised to an arbitrary sequence of blowups. This means that we consider the blowup of a Hirzebruch surface, which we denote by B 2 = Bl 1 F n . For this the homology group of curves is spanned by the classes of the generic fiber f , the exceptional section S − = h and an exceptional curve C 2 E . A consequence of the blowup is that the generic fiber splits over a point into two effective curves: The non-zero intersection numbers between f , h, and C 2 E are: As will become clear momentarily, a convenient choice of basis for H 2 (B 2 ), which is adapted to the duality with the heterotic string, is given by where The intersection form for this basis is (4.51) To understand the significance of this basis, note first that the dual basis of H 2 (B 2 ) is given by {ω α } = {Ω αβ ω β } with Ω αβ Ω βγ = δ γ α . It reads explicitly: The point is now that a D3-brane wrapping the curve class C 0 with C 0 · C 0 = 0 gives rise to a heterotic string, which can become asymptotically tensionless if the volume of C 0 shrinks to zero size. Moreover this curve class can split further into effective classes as C 0 = C 1 E + C 2 E , and a D3-brane wrapping the two classes gives rise to two non-critical E-strings, respectively. If we correspondingly expand the RR 4-form in the dual divisor classes given in (4.52), it follows from the intersection form (4.51) that the 2-form field B 0 couples only to the heterotic string, and is hence identified with the universal perturbative heterotic B-field. On the other hand, the 2-form field B E maps to the anti-self-dual tensor field associated with a heterotic 5-brane that is located at the point on the base of the Hirzebruch surface over which the blowup has been performed. Indeed, we will see that this tensor field couples to Figure 4: Contributions to the Green-Schwarz mechanism of a six-dimensional F-theory compactification on B 2 = Bl 1 F n . Only the leftmost contribution is perturbative from the perspective of the dual heterotic string, and matches the fully modular contribution from the elliptic genus.
the linear combination of E-strings from C E = C 1 E − C 2 E in the right way to be identified with the tensor field on the heterotic 5-brane. While B E is anti-self-dual, the perturbative universal B-field B 0 is neither self-dual nor anti-self-dual but can rather be written as a sum of a self-dual and anti-self-dual tensor field. The fieldB 0 is related to the field dual to B 0 . More precisely, if we were to consider just the Hirzebruch surface B 2 = F n without a blowup, the dual heterotic string compactification would be purely perturbative. The analogue ofC 0 on F n would then bẽ C 0 pert = nf + 2h withC 0 pert ·C 0 pert = 0, and the associated fieldB 0 pert is the dual of B 0 . It is this property that has motivated the choice of basis (4.50).
In terms of the decomposition (4.53), we can now read off the Green-Schwarz couplings defined in (4.44) as follows: Here we have defined with m = m 1 + m 2 . As shown in Figure 4, the couplings θ α give rise to the following tree-level contributions to the anomaly coeffcient (4.46): where On the other hand, recall from the previous section that the anomaly (4.8) as encoded in the elliptic genus can be written as a sum of two pieces which are associated with the modular and the quasi-modular parts of the elliptic genus, respectively. The quasi-modular part of the six-dimensional anomaly has been computed in full generality in (4.27), and is cancelled by the sum AB0 −B 0 + A B E −B E . This then provides the following match between couplings of the effective action and the modular and quasi-modular parts of the elliptic genus: Moreover, from (4.12) we recall that (4.65) By comparison with the above expression for A B 0 −B 0 , this then identifies the field theoretic coupling θ 0 with the modular contribution to the Green-Schwarz term, In turn, these identifications also allow to link the "quasi-modular" pieces of the anomaly, A (6),QM , to the presence of non-perturbative heterotic 5-branes [113] as follows: The Green-Schwarz term θ 0 is, up to overall normalization, the Green-Schwarz term of the perturbative heterotic B-field, as obtained by standard dimensional reduction of the perturbative 10-dimensional Green-Schwarz terms. The analogue of this term is present also in heterotic backgrounds without heterotic 5-branes, and consequently is determined by the purely modular piece of the elliptic genus.
By contrast, the anomaly cancelling contributions AB0 −B 0 + A B E −B E are non-perturbative from the heterotic point of view: The first term, AB0 −B 0 , arises from the exchange of the dual of the heterotic B-field,B 0 . This coupling is absent in the perturbative cousin of this geometry where there is no blowup and the base B 2 is given by the Hirzebruch surface, F n . As noted above, in this case we haveC 0 pert ·C 0 pert = 0 and hence the coupling ofB 0 pert to itself in (4.78) vanishes. Thus the origin of such a term must be attributed to non-perturbative heterotic 5-branes in the dual heterotic picture, as explained in [113].
Similarly, the second term, A B E −B E , must originate from couplings that involve the extra anti-symmetric tensor field B E living in the worldvolume of the 5-brane. The form of these anomalies likewise matches the results in [113].
In summary, eq. (4.64) shows that the two non-perturbative contributions to the anomaly are beautifully matched by the quasi-modular part of the anomaly, precisely as encoded in the elliptic genus. On the other hand, the corresponding Green-Schwarz terms,θ 0 and θ E , are not reproduced by A (6),QM GS from the elliptic genus, as the latter is a one-loop quantity that is agnostic about the non-perturbative sector. Only the perturbative, modular contribution A

GS Mechanism in Four Dimensions versus Modularity and Derivative Terms
After this preparation, we now turn to the Green-Schwarz mechanism in four dimensions. The new ingredient, in line with the main theme of this paper, will be the derivative sector of the elliptic genus. As we will see, it encodes the Green-Schwarz mechanism associated with extra, non-universal 2-form fields B i which arise from the perturbative B-field in ten dimensions by dimensional reduction.
In four dimensions, we reduce the Ramond-Ramond four-form field, C 4 , into 2-form fields B α and their dual, zero-form axions c α by expanding (4.67) Here {ω α } is a basis of H 1,1 (B) and {ω α } the dual basis of H 2,2 (B 3 ), which are defined such that Plugging this expansion into the 7-brane action (4.39), we can read off the Green-Schwarz terms involving the 2-form fields B α and the Chern-Simons terms involving their dual axions c α as follows: The tree-level exchange of the B-and c-fields then gives rise to a gauge variation of the effective action, with anomaly six-form given by As in the six-dimensional setting, we now specialize to a prototypical example that captures all variants of anomaly cancellation. For this we consider a fourfold base, B 3 ⊂ Y 4 , which is by itself a P 1 -fibration over some base space B 2 , and for simplicity of presentation we assume here again that there is only one blow-up divisor, E. We refer to Section 2.3 for our notation for this type of geometries. A basis of H 2 (B 3 ) that is convenient for comparison with the dual heterotic geometry is given by where {C i } is a basis of divisor classes on B 2 . A D3-brane along the rational fiber C 0 of B 3 , or along the exceptional curves C 1,2 E , gives rise to a heterotic string or two copies of E-strings, respectively. The 2-form fields coupling to these strings are obtained by expanding C 4 with respect to the basis of dual divisors: Here, S − is the exceptional section of the P 1 -fibration, E is the blowup divisor, and {C i } is a basis of H 1,1 (B 2 ) related to {C i } via The corresponding expansion then defines the various 2-form fields that are relevant for us. First, the field B 0 maps to the perturbative heterotic B-field in four dimensions. Furthermore B E represents the 2-form field in four dimensions which lives on the worldvolume of the spacetime-filling heterotic 5-brane, which is the geometry that is dual to the blowup on the F-theory side. Finally, the 2-form fields B i correspond to the 2-forms obtained on the heterotic side by expanding the ten-dimensional magnetic dual six-form, B 6 , on 4-forms p * (C i ), which are the pullbacks of the 2-form divisor classes on B 2 . In the basis (4.75), the coefficient of the anomaly (4.72) induced by the Green-Schwarz terms then reads:

Now our task is to compare A
eff with the various modular/quasi-modular/non-modular components of the anomaly A (4) , as encoded in the decomposition (3.13) of the elliptic genus. For this we rewrite the latter in terms of a new basis (signified by a tilde) that is adapted to (4.78). This geometrically motivated basis is however not well aligned with modularity, and thus will generically mix the various components of the elliptic genus. Concretely, in our specific prototypical example, and also in all other examples studied in this work, we find that the elliptic genus can be equivalently written as with the following flux-dependent coefficients: Here,Z 0 −1,m is a modular Jacobi form of weight −1 and index m which is necessarily of the form (4.17), while the remaining contributions mix both modular and quasi-modular pieces. Following our previous notation, we can thus write: After these preparations we can now easily compare the various terms of A (4) eff in (4.78) with the coefficients (4.80) of the elliptic genus, Z G,C 0 , by filtering the individualZ * * ,m through the formula (4.8). This leads to the following decomposition of the total anomaly: Imposing A (4) eff = −A (4) we can thus identify 18 This generic match between geometric, flux dependent quantities pertaining to the effective action on the one hand, and the various contributions to the elliptic genus on the other, is a central point of the present paper. While we have worked it out here for a prototypical situation which is dual to a heterotic string, it applies also to much more general geometries. However it is difficult to refine these statements without specifying more data explicitly, and this is why we will present in Section 5 some detailed computations for explicit examples. Most importantly, we will see directly how the derivative part of the elliptic genus, encoded in theZ i −2,m , relates to the Green-Schwarz mechanism involving the additional four-dimensional 2-form fields B i .
Before concluding this section, let us present some further remarks about the Green-Schwarz terms, which are determined by the 1-loop computation shown in eq. (4.10). Like the anomaly (4.83), also the Green-Schwarz terms receive contributions from both the modular and the quasi-modular parts of the elliptic genus: By (4.12), the Green-Schwarz terms computed from the purely modular contributions are guaranteed to match the field theoretic Green-Schwarz terms, which are perturbative in the sense that they are independent of the heterotic 5-branes. Indeed, in the present context, where Z G,C 0 is written in the special basis (4.80), anomaly cancellation in the perturbative sector takes the form: (4.87) From the perspective of the dual heterotic string, this equation comprises the complete perturbative part of the anomaly cancellation mechanism, involving the universal B-field B 0 in the first term and the additional four-dimensional 2-form fields B i , which are obtained by dimensional reduction of the ten dimensional six-form field, B 6 . Note the factor of 2 in the last expression, which reflects the relation (4.22) for the derivative part of the elliptic genus. Note also that in (4.87) we did not write any modular contributions fromZ E,M −1,m , because they must vanish anyway: This is because a fully modular contribution will always produce both the anomaly and its acompanying Green-Schwarz term at the same time, but the latter cannot arise in perturbation theory from the elliptic genus, since it is localized on the brane and thus cannot be captured by the bulk theory. We will find this general expectation confirmed in the computation of explicit examples, in particular by equation (5.92) below. Similar to the anomalies discussed before, we can also match the Green-Schwarz terms as computed in (4.10) explicitly in terms of the flux geometry, as long as we stay in the fully modular sector. Concretely we find The right-hand side is the coefficient of the standard Green-Schwarz term that involves the universal B 0 -field of the heterotic string. More interesting are the Green-Schwarz terms associated with the derivative, secretly sixdimensional subsector of the theory whose properties are encoded in the embedded threefolds, Y i 3 . These terms, as computed from the elliptic genus, are expected to agree with the actual counterterms in the effective theory, as long asZ i −1,m andZ i −2,m are both fully modular. Following the same line of arguments as before, we find the following identifications between the Green-Schwarz terms as computed from the modular expressions in (4.10) with the intersection numbers of the F-theory flux geometry:g Note that this identification follows from the requirement of anomaly cancellation, i.e., from (4.86) and imposing A (4) eff = −A (4) . It does not prove that the anomalies are actually cancelled. To complete a proof, one would need to show that in general the value for A GS in (4.90) as computed from the elliptic genus does actually come out right such as to match the m (i) as determined in (4.79) from the flux geometry in the effective action. While we do not have a general proof for this, we have checked this to be true for the examples presented in the next section. Turning tables round, assuming anomaly cancellation gives a prediction for the modular part of A GS in terms of the geometric intersection numbers m (i) .
Note that these considerations, and in particular the relation (4.90), do not hold if the elliptic genus has quasi-modular contributions,Z i,QM * ,m = 0: In this case the left-hand side of (4.90), which depends only on the modular parts, is still expected to yield the perturbative Green-Schwarz terms for the fields B i , but there will be in general additional non-perturbative contributions from the heterotic 5-branes.
In this case, the quasi-modular part of the anomaly, A (4),QM , will be non-zero and generically receive two types of contributions: (4.91) The first term encodes the part of the anomaly which is cancelled by the Green-Schwarz mechanism involving the B-field B E from the heterotic 5-branes. From (4.85) we see that the anomaly associated withZ E,QM −1,m is proportional to m 1 − m 2 . This agrees beautifully with the form of the anomaly computed from the elliptic genus in (4.33), providedZ E,QM −1,m is of the form (4.32). In a sense this predicts that it must be possible to writeZ E,QM −1,m must be as in (4.32), as far as its expansion up to orderẑ 3 is concerned.
The second type of contributions in (4.91) must be cancelled by non-perturbative contributions to the Green-Schwarz terms for the additional B i -fields in four dimensions. Note that Z i,QM −1,m andZ i,QM −2,m are non-zero only if the threefold Y i 3 , whose BPS invariants are encoded iñ Z i −2,m , contains the exceptional fibral curves C 1 E and C 2 E . This is the case if the class of the blowup curve Γ, when expanded with respect to a chosen basis {C j }, has a non-trivial contribution from C i . In fact, we may assume without loss of generality that Γ is proportional to C i . By construction this curve maps to the curve wrapped by the NS5-brane on the dual heterotic 3-fold. We can thus conclude a bit more sharply that: where m Γ is a parameter which we cannot determine from the above considerations alone. However it is reassuring that the general structure of these terms indeed matches the architecture of the abelian heterotic Green-Schwarz mechanism in the presence of 5-branes, as was discussed in [109].

Elliptic Genera of 4d Heterotic Strings
So far we have presented generic and prototypical results concerning the modularity of elliptic genera in relation to the background fourfold geometries, Y 4 , and flux configurations, G. This general structure will now be illustrated by detailed computations for a few examples, for which sharper statements can be made, in particular concerning the structure and rôle of the embedded six-dimensional, derivative sector. We begin in this section with the elliptic genus of four-dimensional heterotic strings. In the example of Section 5.1, the embedded threefolds that encode the derivative sector are by themselves Calabi-Yau spaces, while in Section 5.2 we discuss an example where the derivative sector encodes the relative BPS numbers of a non-Calabi-Yau threefold.
We will label the examples by the geometry of the base, B 3 , of a given elliptic fourfold fibration, Y 4 . In order to curb mathematical overload of this section, we have relegated further details about the geometry to Appendix B.
5.1 Example 1: B 3 = dP 2 × P 1 l As our first example we consider F-theory on an elliptic fibration Y 4 whose base B 3 is given by the blow-up of the rational fibration F 1 × P 1 l , where the del Pezzo surface dP 2 is viewed as the blow-up of the Hirzebruch surface F 1 in one point: Since the Hirzebruch surface is a rational fibration with generic fiber C 0 = P 1 f and base P 1 h , we can view B 3 as the blowup of the rational fibration over the base B 2 = P 1 h × P 1 l , where the blowup locus is homologous to P 1 l in B 2 . This type of base spaces fits into the class of geometries described in Section 2.3. In particular, the rational fibration has an exceptional section S − , which embeds B 2 into B 3 and which satisfies the relation As a result of the blow-up inherited from dP 2 , the generic rational fiber C 0 splits into a sum of two exceptional curves C 1 E + C 2 E , where C 1 E and C 2 E are distinguished by their intersection numbers with S − as in (2.30). The splitting occurs over a point on P 1 h within B 2 . The exceptional divisor E associated with this blowup is thus a fibration of C 2 E over P 1 l , and since the rational fibration of B 3 is trivial over P 1 l , it is in fact a direct product: As a convenient basis for H 2 (B 3 ) we pick the curve classes Since we will also need the curve classes dual to C 1 and C 2 on B 2 , note that the only non-zero entries of the intersection form η ij = C i · B 2 C j are η 12 = η 21 = 1, so that the dual curves The choice of basis {C 1 , C 2 } for H 2 (B 2 ) made here corresponds to the generators of the simplicial Mori cone of B 2 , which was advertised as a basis with special properties in Section 3.3; the dual curves, C 1 and C 2 , hence generate the Kähler cone of B 2 . As basis for the divisor group on B 3 we introduce {D α } 4 α=1 , which are defined as In terms of these basis elements D α , the intersection polynomial and the anti-canonical class are Having specified some properties of the base, B 3 = dP 2 × P 1 l , we now turn to the structure of the elliptic fibration Y 4 . It has an additional rational section in addition to the zero-section. As reviewed in Section 2.2, this leads to gauge group G = U (1). Moreover we choose a specific fibration [126,127] for which the height-pairing is given by (5.10) Further details of the fibration are provided in Appendix B. The massless matter spectrum comprises states of charge r = ±1 , which are localised in the fiber along the curve Σ r=1 of class Furthermore we note that the U (1) flux in H 2,2 vert (Y 4 , R) can be expanded into the divisors D α as follows: With respect to this flux, given the matter curve (5.11) the chiral index of massless chiral spectrum evaluates to χ G,r=1 = F · Σ r=1 = 96c 1 + 48c 2 + 84c 3 + 96c 4 . (5.13)

Relative BPS Invariants and Elliptic Genus
As outlined in Section 2.2, we can use mirror symmetry, suitably adapted to fourfolds [90,128,129], to compute a finite number of relative BPS invariants N G;C 0 (n, r). Recall from (5.2) that C 0 is the fiber of B 3 which is wrapped by a D3-brane such as to produce the solitonic heterotic string. These invariants can then be packaged into the elliptic genus and extrapolated to all orders by modular completion. The results of this computation are sketched in Appendix B. We list here just the lowest order in q: where ξ ±n := ξ n − ξ −n . Comparing to (5.13), we confirm the advertised relation (3.8) between the relative BPS invariants at level one, N G;C 0 (1, r), and the chiral index χ G,r=1 . Moreover, following the discussion in Section 3.2, we aim to identify the BPS invariants N G;C 0 (n, r) as expansion coefficients of Jacobi or quasi-modular Jacobi forms (or their derivatives) of U (1) fugacity index Given a sufficient number of known N G;C 0 (n, r), we can uniquely determine the elliptic genus as follows: For the definition of the Eisenstein and the Eisenstein-Jacobi forms, recall Appendix A. Moreover the flux dependent coefficients in (5.16) evaluate to Thus the elliptic genus Z G;C 0 in (5.16) does have the general form as advertised in (3.9), or more specifically in (3.13) and (3.14), with the special feature that for the example at hand there happens to be no four-dimensional quasi-modular term, Z E −1,m . This, in fact, mirrors the absence of a term proportional to C 1 E in (5.11). Let us now take a closer look at the derivative sector, ie., at the Z i −2,2 for i = 1, 2. Acccording to the arguments given in Section 3.2, the Z i −2,2 are generating functions for the relative BPS invariants of certain elliptic threefolds Y i 3 within Y 4 . To verify this in the present example, we follow the general prescription of Section 3.2 and consider the threefolds where, according to (5.6), C 1 = C 2 and C 2 = C 1 . Both threefolds are elliptically fibered with respective base spaces Note that only B 1 2 contains the blowup locus of B 3 , whereas the rational fiber of B 2 2 never splits into two exceptional curves.
Furthermore, the normal bundles of both Y i 3 happen to be trivial: This is a consequence of the fact that the Y i 3 are simply the restriction of the elliptic fibration to p * (C i ), which in turn have vanishing self-intersection on B 3 and hence trivial normal bundle: By the adjunction formula this implies that and therefore both threefolds are themselves Calabi-Yau spaces; we emphasize that this is a special property of the example at hand. Following the discussion in Section 3.3, we can therefore view Y 4 as a fibration in two ways, namely with generic fiber given by either Y i 3 over its respective base C i , for i = 1, 2. Furthermore we can conclude from the adjunction formula that the anti-canonical bundle of the base spaces of Y i 3 is simply the restriction ofK B 3 : The structure of the elliptic fibration of Y i 3 is inherited by restriction from Y 4 . This means that both threefolds are fibrations with an extra section whose height-pairing is simply given by the restriction of b = 2K B 3 to the respective bases. See Appendix B for details.
With this preparation we can now compare the expressions Z i −2,2 given in eqs. (5.18) and (5.19) with the elliptic genera of the heterotic strings that are dual to six-dimensional F-theory compactifications on the Calabi-Yau threefolds Y i 3 . In more detail, the first terms in the expansion of Z i −2,2 are We have checked by direct computation in Appendix B that these expansions perfectly match the low-lying relative BPS invariants for C 0 , for the elliptic Calabi-Yau threefold fibrations Y i terms of two embedded Calabi-Yau geometries that can be independently controlled by dialing the flux background. Alternatively, in terms of the dual heterotic language, one can recognize from (5.18) that Z 2 −2,2 is nothing but the modular, U (1) refined elliptic genus of a perturbative heterotic string compactification on K3 (with some specific bundle background turned on such that only the U (1) gauge symmetry is unbroken). This is most visible when switching off the background gauge field: On the other hand, note that Z 1 −2,2 is only quasi-modular, in agreement with the above observation that Y 1 3 contains the blowup locus. In the dual heterotic language, this corresponds to a non-perturbative background. More precisely, the difference, is suggestive of a transition where a small instanton has been traded against a heterotic NS5brane.
Finally, we note that the decomposition of the matter curve Σ r=1 defined in (5.11) perfectly reproduces the general pattern advertised in eq. (3.29), i.e., 31) with N 1 C 0 (1, 1) = 84 from (5.27), N 2 C 0 (1, 1) = 96 from (5.28) and N 0 C 0 (1, 1) = −84. The latter follows from Z 0 −1,m=2 = 84φ −1,2 = − 1 q N 0 C 0 (n, r)q n ξ r = 84(ξ − ξ −1 ) + . . .. Let us close this part of the discussion by demonstrating the claim of Section 3.4 that the embedded threefold invariants relative to C 0 have another interpretation in terms of non-transversal (−2)-fluxes. This allows us to explicitly verify the special form of the elliptic holomorphic anomaly equation as given in (3.35). Recall that the non-transversal (−2)-fluxes lie in the space H (2,2) (−2) (Y 4 , R) defined in (2.17), and do not lift to fluxes in F-theory. We first need to fix a concrete basis (3.39) for it. Out of the set of all products of elements {S − , E, p * (C 1 ), p * (C 2 )}, the following four non-vanishing fluxes can be taken as a maximal linearly independent set: By performing analogous computations in mirror symmetry as sketched in Appendix B, we can compute the relative BPS invariants with respect to C 0 in each of these backgrounds. The result is where the Z i −2,2 encode the relative BPS invariants for C 0 as a curve within the Calabi-Yau threefolds Y i 3 , as displayed in (5.27) and (5.28). This confirms the claims stated in eq. (3.40) and (3.41). In particular we confirm the relation (3.45) for the lowest degeneracies in Z i −2,2 , because C i · B 2 K B 2 = −2 for both base curves.

Anomalies and Counterterms
We now show explicitly how the general structure of the U (1) gauge anomaly and its counterterms, as laid out in generality in Section 4, works in this example. First we rewrite the elliptic genus in (5.16) in the form (4.80) as where the flux dependent parameters multiply the modular Jacobi forms as defined in (5.19).
In line of what we pointed out before, the inherently four-dimensional contributions to the elliptic genus are all proportional to the modular Jacobi form φ −1,2 . The anomaly and Green-Schwarz term associated with φ −1,2 follow from (4.18) and are given by: Anomaly cancellation, A = mA GS , is of course automatic as a consequence of modularity. Consider next the more interesting derivative contributions to the elliptic genus. We have seen that we can formally associate six-dimensional anomalies and Green-Schwarz terms with them. The contributions to the four-dimensional anomaly and GS terms then follow from these via (4.21) and (4.22).
Specifically, recall that Z 2 −2,2 , associated with the embedded threefold Y 2 3 , is purely modular. Consistent with this, we obtain, by direct evaluation of (4.8) and (4.10), for in agreement with the general formula (4.16). By contrast, Z 1 −2,2 , which is associated with Y 1 3 , receives both a modular and a quasi-modular contribution. The modular part works out along the same lines as for Z 2 −2,2 . The quasi-modular anomaly and Green-Schwarz terms follow from (4.27) and (4.28), and altogether we find: With everything combined and recalling in particular (4.21), the four-dimensional anomaly thus evaluates to In total, when all variables are substituted by their definite expressions, this indeed correctly reproduces the 1-loop anomaly: where χ G,r=1 is given in (5.13).
Let us now have a closer look at the Green-Schwarz terms and check anomaly cancellation in particular for the derivative terms of the elliptic genus. We mentioned already that in the fully modular, non-derivative sector, the Green-Schwarz terms are guaranteed to cancel the perturbative anomaly from the perspective of the heterotic string. Indeed the relation (4.89) is obviously satisfied by means of (5.40): A bit less trivial is the anomaly cancellation in the derivative, but modular subsector. This sector is associated just with Y 2 3 , since Y To compare this to (4.90), which posits that we need to know the parameter m (2) . While we could not offer in Section 4.3.2 an a priori argument why it always takes the correct value, we find here in the current example by direct computation that Hence indeed the anomaly is cancelled as expected. By contrast, for the Green-Schwarz terms derived fromZ 1 −1,m andZ 1 −2,m , which exhibit a quasi-modular contribution, we find, using among others, (4.22), Therefore we get a mismatch as compared to (5.49): which reflects that further Green-Schwarz terms, localized on the heterotic NS5-branes, are needed to fully cancel the anomaly. Nevertheless, the quasi-modular contribution to the anomaly as such, A QM , is of the general form given in (4.92). In our specific example, where m 1 = m 2 = 1, the first term in (4.92) actually vanishes.

Example 2:
As our second example we take the base of the F-theory elliptic fourfold Y 4 to be a blowup of the space H 1 , which is defined as a P 1 -fibration over B 2 = P 2 with twist bundle L = O(p * H).
Here H is the hyperplane class on B 2 . Since this geometry was discussed already in detail in [6], we can be brief in explaining it. The blowup is performed over a curve in the class C 1 = H on B 2 and leads to a splitting of the rational fiber C 0 into two exceptional curves, C 1 E and C 2 E . As in the case study of Section 2.3, the blowup divisor E is given by a fibration of C 2 E over C 1 . For our basis of divisors on B 3 we pick In this basis, the anti-canonical bundle reads 53) and the intersection form becomes The elliptic fibration over the base B 3 is chosen as in the example of Section 5 of [6], to which we refer for further details. It leads to a gauge group G = U (1), and the associated height-pairing where β = 2D 1 + 2D 2 + 4D 3 . Moreover its intersection numbers with the rational fiber and the exceptional curves are as follows: This fibration gives rise to two types of charged massless matter fields, namely of charges r = 1 and r = 2. The matter excitations are localised on two curves on B 3 in the respective ) .

(5.57)
Geometrically, the elliptic fiber over these two curves degenerates such as to contain the rational curves C f r=1 and C f r=2 , respectively. Switching on a general transversal U (1) flux in H 2,2 vert (Y 4 ), produces a chiral spectrum with indices in the respective charge sectors given by 59) χ r=2 = 12c 1 + 12c 2 + 48c 3 .

Relative BPS Invariants and Elliptic Genus
After this preparation we turn to discussing the elliptic genus for the heterotic string that arises from wrapping a D3-brane on C 0 in presence of the U (1) flux, G. The relative BPS invariants N G;C 0 (n, r) for small values of n have already been computed by mirror symmetry in [6]. It was noted there that for the most general choice of U (1) flux, the elliptic genus is neither modular nor a quasi-modular meromorphic form. This observation was in fact the motivation for the present work.
The new ingredient, according to the general discussion in Section 3.2, is that the "nonmodular" component of the elliptic genus is actually a derivative of a quasi-modular form. More specifically, the relative invariants N G;C 0 (n, r), as computed in [6], allow to uniquely determine, by modular completion, the elliptic genus as follows: where the index is, as per (5.56), given by m = 4. Here the flux-dependent coefficients are and the quasi-modular or modular forms are given by As always, ξ ±n := ξ n − ξ −n , ξ ±n := ξ n + ξ −n and the Jacobi forms are defined in Appendix A. The form (5.60) of parametrizing the elliptic genus is tuned to mirror the decomposition (5.57) of the matter curves Σ r=1 and Σ r=2 in terms of C 0 , C 1 E and (b · p * (C 1 )), and follows the general pattern advertised in (3.29). The BPS invariants entering this latter equation are of course defined in terms of the partition functions (5.62), (5.63) and (5.64) via Of particular interest for us is the quasi-Jacobi form Z 1 −2,4 which appears with a derivative in the elliptic genus. In line with our general arguments, we expect that it encodes the relative BPS invariants with respect to C 0 viewed as a curve within an elliptic threefold, Y 1 3 , in Y 4 . Recall from Section 3.3 that this threefold is constructed as the restriction of the elliptic fibration of Y 4 to the divisor p * (C 1 ) = p * (C 1 ) on B 3 , which in the present example is topologically a del Pezzo surface, dP 2 . The threefold is therefore elliptically fibered with base B 1 2 = p * (C 1 ), and we denote the projection by By the adjunction formula we find that Y 1 3 has a non-zero first Chern class: because the divisor p * (C 1 ) has non-vanishing self-intersection on B 3 . From the point of view of the elliptic fibration, this can also be seen as follows. The anticanonical class is related to the pullback of the discriminant of the fibration from the base, ∆ Y 1 3 , via the relation The discriminant ∆ Y 1 3 in turn is inherited from the discriminant of the fibration of the ambient space Y 4 , By the adjunction formula we have . Thus altogether we have rather than just ∆ Y 1 3 = 12π * 1 (c 1 (K B 1 2 )) which would be required for a Calabi-Yau threefold. Even though Y i 3 has a negative anti-canonical bundle, the concept of relative Gromov-Witten invariants still makes sense. Unlike for Calabi-Yau spaces, however, we cannot as easily compute BPS invariants via mirror symmetry and compare them to the invariants N 1 C 0 (n, r) that are encoded in the expansion of Z 1 −2,4 (q, ξ). Despite this technical complication, we can provide some evidence for our conjecture that Z 1 −2,4 encodes the relative invariants for Y i 3 . The following discussion is an illustration of the general arguments in Section 3.3. Recall first that since the elliptic fibration of Y 1 3 is inherited from Y 4 , we know that it exhibits an extra rational section and that the height-pairing associated with this section is the restriction of the height-pairing b to p * (C 1 ). The elliptic fiber of Y 1 degenerates over a number of points on p * (C 1 ) in such a way as to contain rational curves C f r of U (1) charges r = 1 and r = 2. Recall Figure 3 for a visualization. The number of points where this happens equals the number of holomorphic fibral curves in class C f r on Y 1 3 , which in turn is computed by the Gromov-Witten invariants N (C f r ). For Calabi-Yau threefolds whose base is a rational fibration with fiber C 0 , these invariants N (C f r ) agree with the relative BPS invariants at level n = 1 , i.e., This is the threefold analogue of the relation (3.8) and follows from F-theory-heterotic duality. While strictly speaking we cannot invoke this duality for non-Calabi-Yau threefolds, it is reasonable to assert that (5.72) holds more generally whenever the base of the elliptic threefold is a rational fibration. If we assume this, we have a simple means to test the hypothesis that the invariants defined by Z 1 −2,m compute the relative BPS invariants of the non-Calabi-Yau threefold Y 1 3 , at least at level n = 1. This is because the number of degeneration points and hence the BPS invariants N (C f r ) are easy to determine. Concretely, as explained in Section 3.3, the number of degeneration points on Y 1 3 leading to fibral curves C f r is simply given by the number of intersection points between the corresponding degeneration locus of Y 4 on B 3 , i.e., the curves Σ r , and the base of Y 1 3 , i.e., the divisor p * (C 1 ). This yields the BPS invariants These values are in perfect agreement with the relative invariants N 1 C 0 (n = 1, 1) = 180 and N 1 C 0 (n = 1, 2) = 30 which appear in the expansion (5.64) of Z 1 −2,4 . We can also reproduce the remaining invariant, N 1 C 0 (n = 1, r = 0), which according to our conjecture must coincide with the Gromov-Witten invariant for the fibral class E τ . For an elliptic Calabi-Yau threefold, this in turn would be given by the negative of the Euler characteristic of the threefold, i.e. by −χ(CY3) = − CY3 c 3 (CY3) = −2 ch 3 (CY3), where the Chern character is given by ch 3 = 1 2 c 3 − 1 2 c 1 c 2 + 1 6 c 3 1 . For our non-Calabi-Yau threefold Y 1 3 at hand, we find explicity that which indeed matches the index of the uncharged states in (5.64). Thus, all in all we have verified that the identity (5.72) holds for our example, and this lends further support to the conjecture that all invariants in Z 1 −2,4 match the relative BPS invariants of the non-Calabi-Yau threefold, Y 1 3 . Let us present yet another, more speculative perspective on the significance of the partition function Z 1 −2,4 . Recall that the non-Calabi-Yau space Y 1 3 is elliptically fibered over the base B 1 2 = p * (C 1 ), which in turn is the blowup of a Hirzebruch surface F 1 at one point, with its own base C 1 and generic fiber C 0 . This implies that Y 1 3 also admits a K3-fibration over C 1 , whose fiber K3 F is elliptically fibered over C 0 . Let us formulate a Weierstrass model for this fibration, and introduce the notation [a 1 : a 2 ] for the homogenous coordinates on the base C 1 , and [a 1 : a 2 ] for the coordinates on C 0 . Then a Weierstrass model for the elliptic fibration of Y 1 3 can be written, away from the exceptional curve of the blown up Hirzebruch surface, as . The degrees of the discriminant ∆ Y 1 3 on the base and fiber of B 1 2 follow from (5.71) as Taking into account that C 0 is fibered over C 1 with twist 1 (which is the case for the Hirzebruch F 1 ), this means that we can expand f and g as where the subscripts denote the degrees of the polynomials on the fiber coordinates. Let us pause for a moment and consider instead an elliptic fibration over B 1 2 which is Calabi-Yau. For this we would have polynomials given by f 8−k (a 1 , a 2 ) and g 12−k (a 1 , a 2 ), respectively. This Calabi-Yau threefold could serve as a standard F-theory compactifiation space to six dimensions. This theory would in turn have a six-dimensional heterotic dual defined in terms of an elliptic surface, K3 het , with base C 1 . A Weierstrass model for K3 het would then be obtained by keeping the polynomials f 8−k (a 1 , a 2 ) and g 12−k (a 1 , a 2 ) for k = 0 [130,131], i.e., K3 het : y 2 = x 3 + f 8 (a 1 , a 2 )xz 4 + g 12 (a 1 , a 2 )z 6 . (5.81) Now we return to our presently considered geometry, where we deal with the non-Calabi Yau threefold, Y 1 3 . A priori, F-theory on this space is not well-defined. Let us nonetheless formally define a dual heterotic background, by keeping the middle polynomials in analogy to the well-established Calabi-Yau case. This leads to the following Weierstrass model E : y 2 = x 3 + f 12 (a 1 , a 2 )xz 4 + g 18 (a 1 , a 2 )z 6 , (5.82) which is an elliptic fibration with 36, rather than 24 singular fibers. This defines an elliptic surface E withK where E τ is the fiber. It is tempting to interpret Z 1 −2,4 (q, ξ) as a generalized, refined elliptic genus associated with this elliptic surface. More specifically, if we switch off the U (1) background field, we find which is suggestive of a non-perturbative instanton/NS5 brane transition of such a geometry. Let us come back to a more concrete, definite property of Z 1 −2,4 (q, ξ) as given in (5.64). Recall the general relationship between the derivative part of the elliptic genus and the partition functions associated to non-transversal (−2)-fluxes, which was proposed in Section 3.4. If we take as basis for the fluxes in H then the associated BPS invariants assemble into the generating functions Thus we can indeed confirm the purported relationship between the two partition functions, which are associated with transveral U (1) flux and non-transversal (−2) flux, respectively. Moreover, while the vanishing of the last two generating functions is clear on general grounds as for the previous model, it is noteworthy to mention that the lowest BPS number in Z −2,m , as read off from (5.64), perfectly matches the intersection theoretic expression (3.45) because

Anomalies and Green-Schwarz Terms
In order to discuss the anomalies in a U (1) flux background, we rewrite the elliptic genus (5.60) into the form (4.80), which is more suitable for comparison with the Green-Schwarz mechanism in the heterotic duality frame. Concretely, for m = 4, with the flux dependent coefficients: Moreover each term,Z * w,m ≡Z * ,M w,m +Z * ,QM w,m , generically splits into a modular and quasi-modular piece. Explicitly: (5.90) Note that all these partition functions have, depending on their modularity properties, the respective general form as advertised in (3.15).
Let us first discuss the anomalies and Green-Schwarz terms derived from the non-derivative (quasi) modular forms in Z G;C 0 . These receive contributions only from three independent building blocks, which are readily computed following the general prescription outlined in Sections 4.1 and 4.2: Note also in passing that the modular component related to the exceptional curve, and therefore contributes neither to the anomaly nor to the Green-Schwarz term, in line with an argument made after equation (4.88). Now we turn to the derivative sector. FromZ 1 −2,4 we first compute the contributions to the six-dimensional anomaly as follows: Altogether, the complete anomaly becomes and this correctly reproduces the 1-loop anomaly as required: Here χ r refers to the chiral index in the charge sector r as given in (5.59). The structure of the anomaly reflects the Green-Schwarz mechanism in the dual heterotic frame explained in Section 4.3.2. In particular, the purely modular contribution fromZ 0 −1,m , maps to the part of the anomaly that is cancelled by the perturbative universal Green-Schwarz term. Moreover, the quasi-modular contribution to the anomaly, A QM , turns out to be of the expected form (4.92). For the derivative terms, the analogue of this would be the relation (4.90), but this can be checked not to hold due to the quasi-modular contributions, in line with general expectations.

Elliptic Genera of 4d Non-Critical Strings
Our conjecture of Section 3.2 on the form of four-dimensional elliptic genera is supposed to hold not only for heterotic strings, but more generally also for other, in particular non-critical solitonic strings. In this section we illustrate this by presenting the elliptic genus of two different types of non-critical strings in four dimensions. We begin by discussing the four-dimensional E-string in the next section, followed by a non-critical string obtained in F-theory compactified on B 3 = P 3 in Section 6.2.

Four-Dimensional E-Strings
The six-dimensional non-critical E-string [39, 40, 80, 101-103, 132, 133] arises in F-theory by wrapping a D3-brane on a rational curve C E of self-intersection −1 which lies in the base B 2 of some elliptic Calabi-Yau threefold, Y 3 . Such curves have normal bundle N C E /B 2 = O C E (−1) and can arise in two different settings: Either C E is the exceptional section of a Hirzebruch surface B 2 = F 1 , or it appears after blowing up a general Hirzebruch surface at a point. After the blowup the rational fiber over the point in the base splits into two exceptional curves C 1 . We can generalise the notion of an E-string to F-theory compactifications to four dimensions by wrapping a D3-brane on a curve with normal bundle In this paper we will call the strings obtained from D3-branes that wrap such curves fourdimensional E-strings and study their elliptic genera. Aspects of four-dimensional analogues of E-string have previously been considered in [91] (see also [134] and [135]). Clearly such strings are special cases of a multitude of non-critical strings that can arise from much more general types of curves. More recently, the compactification of six-dimensional N = (1, 0) SCFTs on Riemann surfaces with fluxes has been a subject of intense study [84,[136][137][138][139][140][141][142][143][144][145][146][147][148][149][150][151], and it would be worthwhile to relate our setup to the field theoretic approach, though this will not be the focus of this paper. The trivial summand O C E in (6.1) implies that the curve C E is fibered over a distinguished normal direction within B 3 , thereby tracing out a rationally fibered divisor which we call D E . The four-dimensional geometry probed by the E-string is hence a fibration at least locally, where the fiber C E is either the base of a Hirzebruch surface F 1 or one of the blowup curves in a rational fibration. We will exemplify both types of geometries and their associated E-string elliptic genera.
From the perspective of geometry alone, one might think that the properties of the resulting four-dimensional E-string are entirely inherited from the six-dimensional E-string which is locally fibered. According to the logic of this paper, this would mean that the four-dimensional E-string elliptic genus would be a derivative of the six-dimensional E-string elliptic genus. This, however, is in general not the case. The definition of the model requires specifying the background flux, and we will see that the latter can introduce genuinely four-dimensional, non-derivative contributions to the elliptic genus, precisely as expressed in the most general form of Conjecture 2 in Section 3.2. This phenomenon is independent of the geometric realisation of the E-string curve, either as the base of a locally fibered Hirzebruch surface or due to a blowup in the fiber of the rational fibration.

E-Strings of Six-Dimensional Origin
As our first example we consider an F-theory compactification for which the base space, B 3 , is of the type introduced in Section 2.3, namely it is a rational fibration by itself: p : B 3 → B 2 . After we perform a blowup over a curve Γ on the base B 2 , the rational fiber C 0 over Γ splits into two exceptional curves C 1 E and C 2 E . Each of the two C i E is therefore fibered over the curve Γ and the fibration defines two divisors, D i E , of the following form: Note that in Section 2.3 we had called the divisor D 2 E =: E. Furthermore, as long as we perform only one blowup, which is what we assume from now on, we have D 1 E + D 2 E = p * (Γ). For simplicity we now take the gauge group in four dimensions to be U (1) and consider a background with transversal flux, G = G U (1) ∈ H 2,2 vert (Y 4 ). We will discuss an example with nonabelian gauge group later in Section 6.1.2. We claim that for such a setup, the elliptic genus of the E-string associated with either C 1 E or C 2 E can be brought into the following universal form: where Z −2,m i is the elliptic genus [39,40] of a six-dimensional E-string with U (1) fugacity index m i , i.e.: Furthermore, the degeneracies contained in Z −2,m i (q, ξ) are the relative BPS invariants for the curve C i E within an elliptic threefold embedded into Y 4 . Let us illustrate this general formula for the E-strings that arise (besides the heterotic string) in the two examples that were discussed in Sections 5.1 and 5.2. First, consider the base B 3 = dP 2 × P 1 l . In the notation of Section 5.1, the two divisors D i E defined via (6.2) are immediately identified as We recall furthermore that in this geometry the geometric intersection numbers m i = 1 2 b·C i E = 1 for both i = 1, 2.
As detailed in Appendix B, we can compute by mirror symmetry the lowest-lying relative BPS invariants N C i E ;G (n, r) and the associated elliptic genera as follows: These are uniquely completed into the exact expressions: ξ∂ ξ E 4,1 (q, ξ) , (6.9) which are in perfect agreement with general pattern (6.3). The threefold whose relative BPS invariants are contained in Z C i E ;G (q, ξ) is the Calabi-Yau Y 1 3 = Y 4 | p * (C 1 ) introduced already in (5.21). Note that C 1 is the curve dual on B 2 to C 1 , whose class in turn corresponds to the class of the curve Γ over which the E-string curves are fibered as in (6.2). Formula (6.3) is hence very much analogous to the derivative contributions to the heterotic string elliptic genus (5.16) in the same geometry. The difference is that the E-string curves C i E are fibered only over Γ, and hence there appears only a single derivative contribution. For the heterotic string, on the other hand, the curve C 0 is fibered over all of B 2 so that we must sum over several contributions, each corresponding to one basis element C i of H 2 (B 2 ).
As for the example of Section 5.2, we consider the two E-strings in the geometry and The geometric intersection numbers are m 1 = 1 and m 2 = 3. By application of mirror symmetry, we have computed the lowest relative BPS numbers, which assemble into the following expansions: These uniquely determine the elliptic genera as follows: ξ∂ ξ E 4,1 (q, ξ) , (6.14) ξ∂ ξ E 4,3 (q, ξ) , (6.15) which again illustrates the general claim (6.3). We expect that the invariants encoded in Z G;C i E (q, ξ) are the relative BPS invariants with respect to C i E within the non-Calabi-Yau threefold Y 1 3 , which was discussed around eq. (5.66) in the context of the heterotic string.
The two examples discussed so far are special to the extent that the four-dimensional Estring is completely determined by its six-dimensional cousin, as reflected in the purely derivative structure of the elliptic genus. As we will see in the next section, this is no longer the case if the E-string curve lies inside a 7-brane and is threaded by gauge flux.
Before coming to this point, however, we take a brief digression to understand the invariants encoded in Z −2,m i (q, ξ) via (6.3) also in terms of non-transversal (−2) fluxes, analogous to what we found for the heterotic string. Irrespective of the details of B 2 , we can give the general pattern by first considering the relative BPS invariants for the E-string curves C 1 E and C 2 E at n = 0 and r = 0. The curves C 1 E and C 2 E are each fibered over the curve Γ on B 2 . The class of the moduli space of both curves with one point fixed is hence the surface D i E on B 3 traced out by this fibration, i.e.
A non-vanishing BPS number for C i E is only possible in a flux background which intersects this surface. It is easy to see which types of 4-form fluxes on B 3 have this property, because the fibration structure of B 3 implies that the only non-vanishing intersections with D i E are Here C represents some curve class on B 2 , and we used the fact that only C 1 E is intersected by S − . Whenever C intersects Γ transversally, it is natural to infer from the local nature of the fibration that the 4-forms S − · p * (C) and D i E · p * (C) restrict the moduli space of the more . Hence up to normalisation, which is given by the intersection numbers (6.17), we expect to exactly reproduce the BPS numbers as encoded in Z −2,m i (q, ξ).
This general expectation is perfectly confirmed by computation. For the two E-strings of the model with base B 3 = dP 2 × P 1 l of Section 5.1 we find, for the basis (5.32) of non-transversal (−2) fluxes The extra sign in in the expression for Similarly, for B 3 = Bl 1 H 1 of Section 5.2 for the basis (5.85) of non-transversal (−2) fluxes we have and Hence again certain threefold BPS invariants -here of the E-string curves C i E within Y 1 3 -are obtained as fourfold invariants in suitable, non-transversal (−2) flux backgrounds. This does not mean, however, that all relative BPS invariants within a given threefold are generated by one and the same (−2) flux. For instance, the flux G 1 reproduces the relative BPS invariants of C 0 and C 1 E within Y 1 3 , but not of C 2 E , and G E gives the relative BPS invariants for C 1 E and C 2 E in Y 1 3 , but not of C 0 , as comparison with (5.86) and (5.33) shows.

Genuinely Four-Dimensional E-String
While in the previous class of constructions the E-string genera are entirely of six-dimensional origin, we now present an example where one finds in addition a genuinely four-dimensional contribution. The E-string lives inside a stack of 7-branes carrying a gauge sector with G = SU (2). The background geometry, B 3 = F 1 × P 1 , is detailed in Appendix C. The base is rationally fibered with projection p : where C E is the base of F 1 . A D3-brane wrapping C E gives rise to a four-dimensional E-string. The E-string curve is trivially fibered over the extra P 1 , and this fibration traces out the divisor The elliptic fibration Y 4 over B 3 models a stack of 7-branes with gauge group G = SU (2) wrapped on the divisor b = C E × P 1 .

(6.22)
Since the E-string curve C E lies inside the 7-brane divisor b, its intersection number with b is negative, b · C E = −1 .
which corresponds to the Cartan U (1) of SU (2). Here As before, we determine via mirror symmetry a number of relative BPS invariants N C E ;G (n, r) and so obtain the first terms in the expansion of the elliptic genus. While we refer to eq. (C.11) in the Appendix for more data, we present here just the lowest order in q: 19 The noteworthy feature is that at any given order of q there is an infinite series in ξ. This points to the expansion of a ξ-dependent denominator. Such behaviour is expected from experience with non-critical strings of six-dimensional N = (1, 0) SCFT's with nontrivial gauge symmetry [43, 44, 49, 55, 58-60, 65, 67-69, 72], which are obtained when D3-branes wrap a curve that is also wrapped by 7-branes. In six dimensions, such strings are interpreted as instanton strings with respect to the non-abelian gauge group localized on the stack of 7-branes. The point is that for a coincident 7-brane/D3-brane system, the open strings in the 3-7 sector lead to massless charged chiral fields the N = (0, 2) supersymmetric worldsheet theory, and in turn to charged bosonic excitations in spacetime. These are responsible for the appearance of an ξ-dependent denominator in the elliptic genus.
Our goal is to understand the four-dimensional elliptic genus as the derivative of a sixdimensional elliptic genus, possibly augmented by a genuinely four-dimensional piece. To find the six-dimensional contribution, recall that the curve C E is trivially fibered over the P 1 factor in B 3 , thereby tracing out the divisor D E within B 3 . This suggests that we must consider the E-string within a threefold, Y 3 , obtained by restricting Y 4 to the fiber of this fibration. This threefold is simply where the divisor D 3 cuts out the Hirzebruch surface F 1 on B 3 . This threefold happens to be a Calabi-Yau space, and thus we can easily compute the relevant BPS invariants via mirror symmetry. The first terms in the expansion of the elliptic genus for the six-dimensional E-string in Y 3 leads to the BPS numbers presented in (C.13). These BPS numbers can be identified as the expansion coefficients of (6.28) In accord with our expectations, this coincides with the elliptic genus of an instanton string of a six-dimensional N = (1, 0) SCFT with SU (2) gauge symmetry and SO (20) flavor symmetry [58], in the limit where the chemical potentials of its SO(20) flavor symmetry have been switched off and the only nonvanishing chemical potential is the one for the Cartan generator of SU (2). While we expect (6.28) to contribute to the elliptic genus of the four-dimensional E-string with a derivative, it turns out that for general Cartan flux G, the four-dimensional elliptic genus receives in addition a fully modular, non-derivative contribution without a six-dimensional origin. In fact, the elliptic genus of our four-dimensional E-string can be brought into the following form, in full agreement with Conjecture 2 in Section 3.2: where 20 m = b · C E = −1 (6.30) 20 Note that in the definition of m we have not included a factor of 1 2 . This reflects the different normalisation of the U (1) as Cartan subgroup of SU (2), as compared to the non-Cartan U (1)'s studied in the other examples in this work. The value of m defined in this way gives the U (1) fugacity index of the modular forms. Correspondingly, the prefactor of the derivative term in (6.29) is 1 m , rather than 1 2m . and the flux-dependent parameters are Note again that the flux labelled by c 2 does not contribute. The first term, represents a genuinely four-dimensional contribution to the elliptic genus. Evidently, fluxes for which F · C E = 0 affect the spectrum of the solitonic string in a more drastic way if the string lies inside a 7-brane stack, and as a result the four-dimensional E-string can no longer simply be viewed as a fibered version of a six-dimensional E-string. The final expression (6.29) then nicely disentangles via the fluxes the universal six-dimensional contribution and the genuinely four-dimensional contribution to the elliptic genus.
6.2 Four-Dimensional String on B 3 = P 3 As our final example, we present the elliptic genus of a non-critical string that probes a base geometry without any fibration structure. Nonetheless, we will be able to write the elliptic genus in the general form advertised in Section 3.2. We will consider the simplest possible elliptic fourfold fibration, namely where the base is given by B 3 = P 3 . We will focus on the elliptic genus of the non-critical string obtained by wrapping a D3-brane along some curve C b , whose class is given in terms of the hyperplane class by To keep things simple, we engineer a gauge group G = U (1) with associated height-pairing b = 2K B 3 = 8H. The details of the geometry can be found in Appendix D. The transversal U (1) flux is of the form The elliptic genus of the non-critical string is expected to encode the relative BPS invariants N C b ;G (n, r) via where the prefactor q −2 = q −E 0 /2 reflects the vacuum energy E 0 = C b ·K B 3 = 4 on the string. The lowest invariants can be computed by mirror symmetry as discussed in Appendix D. Exploiting modularity, we can completely determine the elliptic genus as where Z −1,m (q, ξ) and Z −2,m (q, ξ) are meromorphic Jacobi forms for which explicit expressions are presented in eqs. (D.11) and (D.12). Moreover, the U (1) fugacity index is given by while Recall that the single flux parameter c is defined in (6.34); since h 1,1 (B 3 ) = 1 there is not enough room for different types of U (1) fluxes to separate out the modular and derivative components, so that just a single linear combination appears. We conclude from this example that the four-dimensional elliptic genus can receive a derivative contribution even if the base, B 3 , is not a fibration. Nonetheless one can consider the divisor H dual to the curve C b on B 3 , which parametrises the direction normal to C b on the base. Restricting Y 4 to the pullback of this divisor cuts out a non-Calabi-Yau elliptic threefold which is an elliptic fibration over The base of this elliptic threefold contains the curve C b , and in line with the general theme of this paper we conjecture that encodes the relative threefold BPS invariants N C b (n, r) of precisely this Y 3 . While we cannot prove this assertion, we close by observing that the same invariants once more appear in the background of a non-transversal (−2) flux. In the present case, the only non-trivial (−2) flux is of the form G H = π * (H) ∧ π * (H) . (6.41) For an elliptic fibration over P 3 without U (1) gauge group, such fluxes were investigated in [76,77]. As we show in Appendix D, the generating function for the BPS invariants in this flux background precisely encodes the invariants contained in Z −2,4 (q, ξ), i.e.
This highly non-trivial match illustrates that the relation between the embedded threefold invariants entering the elliptic genera in the presence of transversal fluxes on the one hand, and of non-transversal (−2) flux invariants on the other, does not depend on any fibration structure on the base B 3 .

Conclusions and Outlook
In this work we have investigated the rich interplay between the modular properties of elliptic genera, the enumerative geometry of genus zero relative BPS invariants on elliptic fourfolds with background fluxes, and the structure of U (1) anomalies for effective field theories in four dimensions. Our analysis has been distilled to Conjecture 2 in Section 3.2, which disentangles the flux-induced elliptic genus in four dimensions into a sum of modular Jacobi forms, quasimodular Jacobi forms, and derivatives thereof. Our conjecture applies in particular to critical heterotic strings and to non-critical solitonic strings in four dimensions with N = (0, 2) worldsheet supersymmetry. Such theories can be engineered in F-theory as worldvolume theories of D3-branes compactified on curves which lie in the base, B 3 , of an elliptic fourfold Y 4 .
That the elliptic genus in four dimensions is not necessarily a (quasi-)modular Jacobi form per se had been explicitly observed already in [6], and is in agreement with the general results of [24] and with the conjecture [25] that the generating functions of BPS invariants of elliptic fibrations are captured in terms of quasi-Jacobi forms. According to Conjecture 2 of the present paper, the non-(quasi-)modular components of the elliptic genus are, in fact, of a simple derivative form. Apart from breaking modular invariance, they also break the elliptic shift symmetriy which corresponds to spectral flow in the U (1) current algebra. These anomalies can be remedied at the cost of introducing a non-holomorphic derivative as in (1.12). This results in eq. (1.13), which can be seen as a concrete realization of the elliptic holomorphic anomaly equation that was proposed in [25], thereby giving further support of it.
Our arguments are based on a central observation of this paper, namely that the derivative contributions to the elliptic genus in the presence of transversal flux can be obtained in two a priori independent ways: First, they arise from the partition function of BPS invariants in the background of non-transversal fluxes. This is in accordance with the elliptic holomorphic anomaly equation that was introduced in [25]. A main result in our work concerns a second, novel interpretation of these invariants, namely as BPS invariants of certain threefolds Y i 3 that are embedded in Y 4 . Taking the second point of view in fact allowed us to independently derive the elliptic holomorphic anomaly equation.
In special cases, the threefolds Y i 3 are themselves Calabi-Yau manifolds and their BPS invariants can easily be computed by means of mirror symmetry. By analysing a variety of examples, we find that these BPS invariants indeed match the derivative sector of elliptic genera. This lends strong support to our claims. More generally, the concept of relative BPS invariants is well-defined also for non-Calabi-Yau geometries, and we gather circumstantial evidence that the observed pattern persists for such Y i 3 . It would be intriguing to develop techniques to compute these invariants more directly, from first principles, in order to compare them with our predictions.
In the special case of a heterotic string, we have been able to prove the geometric interpretation of the BPS invariants in the derivative sector, at least at the first energy level n = 1 of the elliptic genus. This rests on the geometric interpretation of the fourfold BPS invariants in terms of the moduli space of curves in the fourfold. It would be desirable to extend this proof to all levels n. This would open up the fascinating possibility of using mirror symmetry on Calabi-Yau fourfolds to determine relative BPS invariants of non-Calabi-Yau threefolds.
From a physics perspective, the embedded threefolds Y i 3 can be thought of as formally defining six-dimensional sectors in the following sense. If the Y i 3 are Calabi-Yau manifolds, the derivative part of the elliptic genus can be literally interpreted as a collection of six-dimensional elliptic genera. For instance, for the case of a heterotic solitonic string, we can go to the dual weakly coupled eigenframe which describes a compactification on a K3 surface with gauge bundle. In this case the six-dimensional elliptic genus we talk about is precisely the elliptic genus of such a compactification. We have also discussed the more generic situation where Y i 3 is not Calabi-Yau: while the arguments are not as sharp, we can still make a formal analogy and consider a dual heterotic geometry associated with some elliptic surface, which however is not a K3 surface any longer.
We have illustrated Conjecture 2 by a number of examples covering a variety of fourdimensional, critical as well as non-critical strings, and their elliptic genera. For the special case of the critical heterotic string, the modular properties of the elliptic genus reflect the intricacies of the Green-Schwarz anomaly cancelling mechanism in four dimensions. As described, contrary to what happens in six dimensions, the elliptic genus in four dimensions is not ne-cessarily a (quasi-)modular Jacobi form, and we show in detail how this ties in with anomaly cancellation involving extra B-fields. Specifically, the modular part of the elliptic genus is linked to the universal B-field, while the other sectors reflect the presence of further B-fields, in general of both perturbative and non-perturbative nature.
We have furthermore analysed two types of examples of non-critical strings in four dimensions. The first is a generalisation of the concept of an E-string to four dimensions: Its elliptic genus is generally the sum of a derivative piece (which is related to the familiar six-dimensional E-string), plus a genuinely four-dimensional contribution, whose details depend on the flux background. While the E-strings are special in that they can be decoupled from gravity in four dimensions, we have tested Conjecture 2 also for a non-critical string which is associated with a non-shrinkable curve in P 3 , so that gravity cannot be decoupled. Clearly the handful of prototypical examples provided in this work only form the beginning of a much more systematic study of elliptic genera of strings in four dimensions.
One furthermore defines a weakly (or nearly) holomorphic Jacobi form by requiring c(n, r) = 0 unless n ≥ n 0 for a negative integer n 0 .
Jacobi forms form a bi-graded ring which we denote by For even weight and integer index, J 2k,m is freely generated by φ 0,1 and φ −2,1 with coefficients given by polynomials in the Eisenstein series E 4 and E 6 . The Eisenstein series, as well as the generators φ 0,1 and φ −2,1 , can be expressed in terms of the Dedekind function η(τ ) = q 1 24 ∞ n=1 (1 − q n ) and the familiar Jacobi theta functions as follows: 21 For odd weight and integer index, J 2k+1,m has a single extra generator which implies that any odd-weight Jacobi form of integer index must be proportional to φ −1,2 . This is of great significance in the present work, since the relevant elliptic genus of fourdimensional theories has weight w = −1 and integer m. Note that the odd generator obeys the relation so that effectively it appears at most linearly. So altogether the ring of weak Jacobi forms is generated by J * , * : modulo the relation (A.10). For reference, we define q = e 2πiτ , ξ = e 2πiz , ξ ±n = ξ n + ξ −n , ξ ±n = ξ n − ξ −n , andẑ = 2πiz, and list the following expansions: where ∆ = η 24 = 1 1728 (E 3 4 − E 2 6 ). As is well-known, it is not fully modular but transforms with an extra piece is almost holomorphic while modular with weight w + 1 under the transformations (A.1) and (A.2). This follows from the transformation property of α ≡ Imz Imτ : It then follows that by definition ∂ z Φ w,m ∈ J QJ w+1,m . Analogous arguments apply if Φ w,m ∈ J QM w,m .

A.2 Eisenstein-Jacobi Forms
In this section we identify a set of Jacobi forms which are closely related to the Eisenstein series E 4 (τ ) and E 6 (τ ). This parametrization of the ring of Jacobi forms, J * , * , is naturally adapted to the geometries we consider, and makes certain properties more manifest. Specifically, we are interested in holomorphic Jacobi forms Φ w,m (q, ξ) = Φ w,m (τ, z), of weight w = 4 or 6 and index m characterized by the following properties: • Φ w,m (q, ξ) = n≥0 r∈Z c(n, r)q n ξ r , where c(n, r) ∈ Z and c(0, r) = δ 0,r .
In the main text of the paper we argue that the derivative part of the elliptic genera is given by a formally six-dimensional structure, which manifests itself in terms of the threefolds π i : Y i 3 → B i 2 , i = 1, 2 , (B.23) whose two-fold bases are given by B i 2 = p * (C i ) .

(B.24)
Here we will provide some relevant details of these, for the sample geometry we consider. Concretely, we have C 1 = C 2 and C 2 = C 1 and the respective bases are thus given by where, in the second step, we have used b = 2K B 3 and N B i 2 /B 3 = O B i 2 . As both of the induced fibrations, Y 1 3 and Y 2 3 , are torically constructed, they admit a description in terms of an abelian GLSM, analogous as for Y 4 in Table B.1. The most general such descriptions for the bases (B.25) and (B.26) can be found, for instance, in [4] (see Table  4.2, as well as Table 4.1 with a = 0); for the specific fibrations Y 1 3 and Y 2 3 under scrutiny, we set (x, y 1 , y 2 ) = (6, 2, 2) in the former case and (x, y) = (4, 4) in the latter. By determining their Mori cones and intersection rings, we can calculate the BPS invariants, N i C b (n, r), for the curve classes of the form (B.11) on Y i 3 , just like it was done for the fourfold Y 4 . As result we present these invariants via their generating functions of the form,   (2)-enhanced E-string model on F 1 × P 1 l .
(C. 13) This can be recognised as the series expansion in q = e 2πiτ and ξ = e 2πiz of the following meromorphic Jacobi form of weight w = −2 and U (1) fugacity index m = −1: (C.14) As discussed in Section 6.1.2, this has the interpretation as the elliptic genus of an instanton string of the six-dimensional SCFT with SU (2) gauge symmetry.
D Non-Critical String for B 3 = P 3 In this Appendix we provide some of the technical details that underlie the example of Section 6.2. It is devoted to a non-critical string obtained by wrapping a D3-brane on the curve C b = H · H on the base B 3 = P 3 of an elliptic fibration. The model without U (1) gauge symmetry has been discussed in much detail in [75][76][77]. Here we consider an extension of this model in order to support a transversal flux in conjunction with a chiral U (1) gauge symmetry, which allows for a nontrivial elliptic genus. For this we implement the gauge symmetry associated with the height-pairing given by b = 2K B 3 = 8H. The fourfold Y 4 we thus consider is characterized by the Mori vectors l (1) = ( −1, −1, 0, 0, 0, 0, 0, 1, 1), l (2) = ( −2, 2, 1, 0, 0, 0, 0, 0, −1), l (3) = ( 0, 0, 0, 1, 1, 1, 1, 0, −4) . (D.1) The intersection polynomial, in terms of the dual basis of Kähler cone generators, reads Moreover we define the following curve classes and determine the BPS invariants, N G;C b (n, r), for the curves of the form with respect to fluxes G ∈ H 2,2 vert (Y 4 ). As a basis of fluxes we pick G U (1) = σ ∧ π * (F ) with F = c H , We now perform a standard mirror symmetry computation to obtain the Gromov-Witten invariants and assemble them, for each of the above fluxes, into the following partition function 23 Z G;C b (q, ξ) := − 1 q 2 N G;C b (n, r)q n ξ r . (D.7) The fluxes G H and G 0 are the fluxes considered in [76,77] and are associated with meromorphic modular forms of weight w = −2 and w = 0, respectively. These are non-transversal fluxes which do not admit a lift to four-dimensional F-theory. On the other hand, the transversal flux G U (1) leads to the U (1)-refined elliptic genus we are interested in, with modular weight w = −1.
Matching against Ansaetze of Jacobi forms yields an overdetermined system of equations, and in this way we find the following closed expression for the weight w = −2 flux: