$\mathcal{N}{=}1$ supersymmetric indices and the four-dimensional A-model

We compute the supersymmetric partition function of $\mathcal{N}{=}1$ supersymmetric gauge theories with an $R$-symmetry on $\mathcal{M}_4 \cong \mathcal{M}_{g,p}\times S^1$, a principal elliptic fiber bundle of degree $p$ over a genus-$g$ Riemann surface, $\Sigma_g$. Equivalently, we compute the generalized supersymmetric index $I_{\mathcal{M}_{g,p}}$, with the supersymmetric three-manifold ${\mathcal{M}_{g,p}}$ as the spatial slice. The ordinary $\mathcal{N}{=}1$ supersymmetric index on the round three-sphere is recovered as a special case. We approach this computation from the point of view of a topological $A$-model for the abelianized gauge fields on the base $\Sigma_g$. This $A$-model---or $A$-twisted two-dimensional $\mathcal{N}{=}(2,2)$ gauge theory---encodes all the information about the generalized indices, which are viewed as expectations values of some canonically-defined surface defects wrapped on $T^2$ inside $\Sigma_g \times T^2$. Being defined by compactification on the torus, the $A$-model also enjoys natural modular properties, governed by the four-dimensional 't Hooft anomalies. As an application of our results, we provide new tests of Seiberg duality. We also present a new evaluation formula for the three-sphere index as a sum over two-dimensional vacua.


Introduction
The N = 1 supersymmetric index [1,2] provides us with an invaluable tool in the study of four-dimensional supersymmetric quantum field theories with an exact R-symmetry, U (1) R . It is defined as the Witten index [3] of the theory quantized on S 3 , in presence of various fugacities: with J 3 , J 3 the generators of the Cartan of SO(4) ∼ = SU (2) × SU (2) rotations on S 3 , R the conserved U (1) R charge, and Q α any conserved charges that commute with supersymmetry. 1 If the supersymmetric theory is also conformal, or flows to a non-trivial conformal fixed point in the infrared, the index (1.1) computes the superconformal index [4]-by the state-operator correspondence, it counts certain operators in short representations of the N = 1 superconformal algebra. More generally, the three-sphere index of any R-symmetric N = 1 theory is obtained by quantizing the theory on S 3 ×R with supergravity background fields turned on to preserve at least two supercharges [5,6]. A natural generalization of (1.1) considers any spatial manifold M 3 allowed by supersymmetry. The corresponding "generalized index" takes the form: (1.2) Such an index exists if and only if M 3 is a Seifert manifold [6,7,8]-that is, M 3 is an S 1 bundle over a two-dimensional orbifoldΣ g . The conserved charge J in (1.2) is the generator of the S 1 isometry along the Seifert fiber. Whenever the baseΣ g of the Seifert manifold admits an isometry, we might also introduce an additional fugacity for it, which corresponds to a certain "squashing" of the index (1.2). For instance, the S 3 index (1.1) has two "geometric" fugacities p and q, which correspond to a certain squashing of the three-sphere-see e.g. [9,10]. In this work, we will only consider the "round"-non-squashed-index (1.2). In particular, we will study the S 3 index with the specialization p = q = q. On general grounds, the M 3 index (1.2) with |q| = e −2πβ can be computed as a supersymmetric path integral on M 3 × S 1 , with S 1 a circle of radius β [11]. The path integral and Hamiltonian computations must agree up to scheme-dependent local terms. However, it is sometimes convenient to factor out the contribution of the M 3 vacuum to (1.2), and to define a "normalized index" I M 3 that doesn't include that vacuum contribution. We define: with Z M 3 ×S 1 the supersymmetric partition function. The vacuum-contribution E M 3 is the so-called supersymmetric Casimir energy [12,13,14,15]. With this definition, the normalized index I M 3 has an expansion in q: with the O(q 0 ) vacuum contribution given by the first term. For the standard S 3 index, we have I (0) S 3 = 1-in the superconformal case, it is simply the contribution from the unit operator. For the generalized M 3 index, the first term I (0) M 3 (y) in (1.4) can itself be interpreted as the flavored Witten index [16] of a one-dimensional theory obtained in the q → 0 limit, corresponding to sending the size of M 3 to zero.
In this work, we compute the generalized index (1.2) in the case: where M g,p is a principal U (1) bundle of first Chern class p ∈ Z over the genus-g (closed, orientable) Riemann surface Σ g .
These generalized indices were first studied in [26] using supersymmetric localization and we will expand on those results, albeit using different techniques. The M g,p family includes the two important examples mentioned above: (1.7) We will derive an explicit formula for the M g,p × S 1 supersymmetric partition function, valid for any asymptotically-free gauge theory with a semi-simple, simply-connected gauge group G. This can be done rather elegantly by studying a "four-dimensional A-model" on Σ g × T 2 , following the recent approach of [27]. Note that, while the M g,p manifolds form a small subfamily in the set of all Seifert manifolds, we expect that, using similar methods, one may also consider most allowed "half-BPS" M 3 backgrounds. The A-model approach relates all the M g,p × S 1 partition functions amongst themselves. For instance, we find that the S 3 × S 1 partition function [2,12] can be related to the S 2 × T 2 partition function [17,18] by: (1.8) Here the insertion F in the S 2 × T 2 path integral is a particular surface operator wrapped over T 2 , which we call the fibering operator. Its insertion at any point on S 2 induces a non-trivial fibration of T 2 over S 2 , leading to the S 3 × S 1 topology.

The four-dimensional A-model
Let us consider the compactification of a four-dimensional N = 1 theory on T 2 . Let (z, w) be complex coordinates on R 2 × T 2 . In terms of angular coordinates x 1 , x 2 of period 2π on T 2 , we have w = x 1 + τ x 2 . The parameter τ is the modular parameter of T 2 . Any four-dimensional field has a Kaluza-Klein (KK) expansion on the torus: φ = n,m∈Z ϕ n,m (z,z) e i(nx 1 +mx 2 ) . (1.9) We can view the four-dimensional theory as a two-dimensional theory with N = (2, 2) supersymmetry, with an infinite number of fields due to the KK decomposition. The N = (2, 2) superalgebra allows for two distinct sectors of half-BPS local operators.
The chiral operators commute with the supercharges 2 Q + and Q − . These operators descend from ordinary 4d N = 1 chiral operators. The twisted chiral operators commute with the supercharges Q − and Q + . This condition breaks four-dimensional Lorentz invariance in R 4 . The two-dimensional twisted chiral operators on R 2 descend from half-BPS N = 1 surface operators wrapped over T 2 . These half-BPS operators form a ring-their OPE is non-singular up to Q-exact terms. The structure of the twisted chiral ring-the ring of parallel half-BPS surface operators-can be usefully isolated by the topological A-twist [28]. This corresponds to a supersymmetric compactification of R 2 to Σ g , a genus-g Riemann surface. 3 In the case of an N = 1 gauge theory with gauge group G, the most important degrees of freedom, upon compactification to two dimensions, are the Wilson lines on T 2 . We define the complex fields: A a µ dx µ , a = 1, · · · , rk(G) , (1. 10) for the abelianized gauge field A a µ in the Cartan of G, (1.11) The fields u a are Coulomb branch coordinates in the N = (2, 2) theory. Their higherdimensional origin manifests itself by the periodic identifications: u a ∼ u a + 1 ∼ u a + τ , (1.12) due to large gauge transformations on T 2 . We similarly define the parameters ν α for the flavor group G F , with α = 1, · · · , rk(G F ), corresponding to Wilson lines for U (1) α background gauge fields. Importantly, the fields u a and the background fields ν α are the lowest components of 2d N = (2, 2) twisted chiral multiplets. Consider an N = 1 supersymmetric gauge theory with gauge group G and chiral multiplets Φ i charged under the gauge group. For simplicity, we will assume that G is semi-simple and simply-connected. We define the four-dimensional A-model of this gauge theory as the low-energy effective theory on the Coulomb branch in two dimensions, subjected to the topological A-twist. In favorable circumstances, this effective theory has isolated vacua-in many examples, this will be the case for generic-enough flavor parameters ν α . The four-dimensional A-model is fully determined in terms of two potentials: W(u, ν; τ ) , Ω(u, ν; τ ) , (1.13) locally holomorphic in all variables. The effective twisted superpotential, W, governs the dynamics of the low energy effective theory on R 2 × T 2 , and the effective dilaton, Ω, governs the coupling to curved space [30,31]. The A-model vacua correspond to the solutions of the Bethe equations [32], exp 2πi∂ ua W(u, ν; τ ) = 1 , a = 1, · · · , rk(g) , (1.14) which are not left invariant by the Weyl group. These so-called Bethe vacua, the twodimensional vacua of the theory compactified on T 2 , will play a central role in this work.

Supersymmetric partition function from the A-model
One can build a number of "canonical" A-model operators from W and Ω [31,27]: (1. 15) The operator Π α is the flavor flux operator, which inserts one unit of U (1) α flux for a flavor background gauge field at a point on Σ g . The operator H is the handle-gluing operator, whose insertion at a point is equivalent to changing the topology of Σ g to Σ g+1 . Finally, the fibering operator F introduces a non-trivial fibration of T 2 over Σ g . (More precisely, as we will discuss, there are two distinct fibering operators F 1 and F 2 , related by a modular transformation of T 2 . Here we chose F = F 1 .) All these operators are local operators in the A-model-equivalently, they are half-BPS surface operators in the four dimensional N = 1 theory. By construction, we obtain: for the M g,p × S 1 partition function with background fluxes n α , generalizing (1.8)-the insertion of H g on S 2 changes the topology of the base to Σ g , the fibering operator insertion F p changes the first Chern class of the principal circle bundle from 0 to p, and the flavor flux operators Π nα α introduce background fluxes n α . These operators can be inserted anywhere on S 2 since the A-model is topological in two dimensions.
(1. 17) Here S BE denotes the set of all Bethe vacua. The parameters ν and τ are related to the fugacities y and q in the index (1.2) by: (1.18) One can pull out aû-independent supersymmetric Casimir energy term from (1.17), like in (1.3). This supersymmetric Casimir energy is determined entirely by the various 't Hooft anomalies of the theory, and it is therefore scheme-independent. The supersymmetric partition function (1.17) enjoys natural transformations properties under large transformations ν ∼ ν +1 ∼ ν +τ for the flavor parameters, and under modular transformations of the T 2 fiber. While Z Mg,p×S 1 is not fully invariant under large gauge transformations for flavor background gauge fields, this lack of invariance is naturally expressed in terms of 't Hooft anomalies. Incidentally, the gauge theory itself should, of course, be non-anomalous-all gauge and gauge-flavor anomalies must vanish for the A-model to be well-defined.
We also note that the A-model formalism naturally allows the insertion of more general supersymmetric surface defects supported along the T 2 fiber of M g,p × S 1 . Their expectation value is computed by modifying the sum over Bethe vacua according to: S = û∈S BE F(û, ν; τ ) p H(û, ν; τ ) g−1 α Π α (û, ν; τ ) nα S(û, ν,ν). (1.19) where S(u, ν,ν) is the T 2 partition function, or elliptic genus, of an N = (0, 2) surface defect theory, which may couple to the 4d gauge fields, as well as to a 2d flavor symmetry group with fugacitiesν. We leave a more detailed study of surface defects in 4d N = 1 theories for future work.
A new evaluation formula for the three-sphere index The special case of S 3 ×S 1 is worth discussing in more detail. One important property of the A-model is that the R-charges of all fundamental fields should be integer-quantized. This is so that the fields are well-defined on Σ g with the topological A-twist. From the point of view of curved-space supersymmetry [5], we should view M 4 ∼ = M g,p × S 1 as a complex manifold. The U (1) R background gauge field is then the connection on a complex line bundle L (R) over M 4 [6]. We have: its Z p -valued first Chern class, which generally imposes a Dirac quantization condition on the R-charge. We refer to Appendix A for a detailed exposition of the M g,p × S 1 supersymmetric background. In the special case M 4 ∼ = S 3 × S 1 , however, the R-symmetry gauge field is topologically trivial, so that the R-charges can be taken real, not only integer-valued. More precisely, this is true in a U (1) R gauge for which the R-symmetry gauge fields vanishes along the three-sphere. 4 This so-called "physical gauge" is related to the "A-twist gauge" used in most of this work by a large U (1) R gauge transformation along the Hopf fiber inside the S 3 .
In the physical gauge, the S 3 × S 1 partition function has a well-known expression as an elliptic hypergeometric integral [2,12]: where the integrand is given in terms of elliptic gamma-functions, 5 with the numerator and denominator corresponding to the chiral and vector multiplets, respectively. The factor E S 3 in front of (1.21) is the supersymmetric Casimir energy [14,15]. Note that we suppressed all dependence on the flavor fugacities y α in (1.21), to avoid clutter. Our results lead to an explicit evaluation formula for (1.21) as a sum over the Bethe vacua of the schematic form: completely analogously, and closely related, to (1.17). We will explain the precise meaning of (1.22) in section 4.

A new test of Seiberg duality
Arguably, the most striking application of the supersymmetric index is that it provides highly non-trivial tests of supersymmetric dualities, such as Seiberg duality [33]. This is possible because the index-or the supersymmetric partition function-is renormalization group (RG) invariant. This allows us to easily compute it for any weakly-coupled theory in the ultraviolet (UV) in order to deduce properties of the strongly-coupled infrared (IR). In the case of the S 3 index, Seiberg duality manifests itself as rather formidable identities between elliptic hypergeometric integrals like (1.21) for dual theories [34]. Such identities were discovered by Rains from a purely mathematical perspective [35].
This beautiful result has led to some interesting lines of research linking indices to more formal mathematical constructions-see e.g. [34,36,37,38,39]. The A-model of a given N = 1 gauge theory is a topological field theory, and it is of course RG invariant. Therefore, Seiberg duality-or any N = 1 infrared dualityimplies an isomorphism between the A-models of the dual theories. In particular, the duality implies the existence of a one-to-one duality map: between Bethe vacua in the dual gauge theories. The most elementary observable of the A-model is the number of Bethe vacua, which can be identified with the T 4 partition function, or regularized Witten index. 6 We will compute that index in a few examples. For example, for the N = 1 U Sp(2N c ) gauge theory with 2N f flavors, we find: Similarly, the Witten index of N = 1 SQCD with special unitary gauge group is given by: Similar relations must hold for the flavor flux operators-or for any insertions of mutually dual surface operators. In this work, we check the duality relations (1.26) for Seiberg duality with Sp(2N c ) and SU (N c ) gauge groups [41,33]. This will provide a proof of the equality of the twisted indices Z Σg×T 2 to all order, for these dualities; for p = 0, the equality of partition functions hinges on the first equality in (1.26), which can be checked to hold numerically or in some convenient limits, but would be interesting to prove analytically. For S 3 × S 1 , the equalities (1.26) provide us with a different perspective on the equality of the S 3 supersymmetric index, which might be conceptually simpler than Rains' integral identities. 7 6 That is the Witten index regularized by turning on flavor fugacities on T 4 , which lifts the moduli space of vacua. See [40] for a physical discussion of a related index in three dimensions. The results quoted here are for generic values of the flavor fugacities. 7 On the other hand, recall that we are restricted to the case q = p = q.

Comments and outlook
Let us briefly comment on the relation of our results to previous work. In the case of g = 0 and general p, we compute an index on the lens space L(p, p − 1) ∼ = S 3 /Z p . However, the background we consider here differs from that considered in [42] for p > 2 due to the presence of a non-trivial R-symmetry gauge field. 8 We also expect that our results in the case g = 0 can be related to holomorphic blocks [43,44,45,46], where one also finds that the partition function is expressed as a sum over the supersymmetric Bethe vacuathe relation to our approach likely involves the Ω-deformation-or "quantization"-of the 4d A-model. In the case of N = 2 theories, one may also consider the fully topologically twisted partition function [47], which is naively a different object than the partial twist considered here. More relatedly, partial topological twists of N = 2 theories along a Riemann surface have been considered, e.g., in [48,49,50]. Surface operator expectation values play an important role in our story, since they are the basic observables of the 4d A-model. These have appeared in the context of 4d partition functions in [21,51,52]. We hope to return to a more systematic study of these operators in future investigation, and in particular to relate the A-model formalism to these earlier works. It would also be very interesting to study the generalized index in the large N limit, and in particular to relate our results to the extremization principle of [53].
Finally, we should note that the identification of the A-model partition function (1.17) with the physical path integral over the supersymmetric M g,p × S 1 background is a subtle matter in the presence of 't Hooft anomalies. This is likely related to recent claims of an N = 1 supercurrent anomaly [54,55]. We will come back to this issue in future work. This paper is organized as follows. In Section 2, we study the theory on R 2 ×T 2 through the A-model perspective. In Section 3, we introduce the M g,p × S 1 partition function, explain how it is computed in terms of A-model operators, and discuss some of its properties. In Section 4, we describe in detail cases, such as M 0,1 = S 3 , where the Rsymmetry gauge field is topologically trivial, and one can relax the constraint that the R-charges be integer. In Section 5, we sketch the derivation of the M g,p × S 1 partition function from a localization calculation, giving an alternative integral representation, and we relate our result to previous computations of the S 3 × S 1 partition function that have appeared in the literature. In Section 6, we describe the computation of the M g,p × S 1 partition function for some SQCD-type theories that enjoy Seiberg duality, and we give strong evidence for the equality of the partition functions for dual theories. Several appendices are included with further technical details.
Consider a four-dimensional N = 1 supersymmetric gauge theory on R 2 × T 2 , with a modular parameter τ for the torus. The T 2 compactification allows us to describe the four-dimensional theory in terms of a two-dimensional N = (2, 2) supersymmetric theory with an infinite number of fields corresponding to the Kaluza-Klein modes on T 2 . In particular, the zero-modes of the N = 1 vector multiplet give rise to an N = (2, 2) vector multiplet in R 2 . We will consider four-dimensional supersymmetric backgrounds that preserves the two supercharges Q − and Q + in the two-dimensional N = (2, 2) supersymmetry algebra. We may then write down an A-twisted effective field theory for two-dimensional vector multiplets spanning the classical Coulomb branch.
Given a gauge group G with Lie(G) = g, the two-dimensional vector multiplet contains a complex scalar u, which is also the lowest component of a g-valued twisted Let us denote by a x 1 , a x 2 the holonomies along the torus: for the four-dimensional gauge field A µ , and similarly for background gauge fields A (F ) µ for the flavor symmetries, and define: These fields are dimensionless complex scalars in two dimensions. We pick a basis e a of the Cartan H of G, and a basis e α F of the Cartan of G F , such that: We choose a basis {e a } that generates the coweight lattice Λ cw , so that ρ(e a ) ≡ ρ a ∈ Z for all weights ρ ∈ Λ w . We similarly choose {e α F } such that ω(e α F ) ≡ ω α ∈ Z, where ω denote the flavor weights. We have the identifications: under U (1) a and U (1) α large gauge transformations on T 2 , respectively.
The four-dimensional A-model is fully determined by the following effective action for the twisted chiral multiplets U a , which governs the coupling of the theory to the curved space Σ g × T 2 : Here R is the Ricci scalar of Σ g . The gauge fluxes f 11a are to be summed over, while f 11α denote background flavor fluxes, such that: After the twist, there are also one-form fermions Λ1, Λ 1 that couple as indicated in (2.6), and provide g pairs of fermionic zero-modes on Σ g . The holomorphic function W is the effective twisted superpotential, and Ω is the effective dilation [27]. Both W and Ω are locally holomorphic in u and in the various "mass" parameters ν and τ . In the following, we discuss these functions in detail for any ultraviolet-free fourdimensional gauge theory with a semi-simple gauge group G. For simplicity, we also restrict ourselves to G a simply-connected gauge group. (There can be interesting global issues for G non simply-connected, which we leave for future work.)

The twisted superpotential
The twisted superpotential of a four-dimensional gauge theory only receives contributions from charged chiral multiplets, which obtain two-dimensional effective twisted masses proportional to u a . For G semi-simple, the W -bosons and their superpartners do not contribute.

Chiral multiplet contribution
Consider a four-dimensional chiral multiplet of charge 1 under some U (1) in the Cartan of G, with u the U (1) complexified flat connection. Integrating out all the KK modes, we obtain the formal twisted superpotential: where each KK mode contributes to the effective twisted superpotential as a 2d chiral multiplet [56]. We first perform the sum over n, using the three-dimensional regularization discussed in [27]. This gives: where we defined x = e 2πiu and q = e 2πiτ . This formal sum can be further regularized to: The infinite sum in (2.10) converges absolutely for τ in the upper-half plane. The cubic polynomial encodes certain four-dimensional anomalies, which we will discuss momentarily. The derivation of (2.10) is discussed in Appendix C.1. An equivalent definition of (2.10) can be given in terms of the following function, which we might call the "elliptic dilogarithm": Here we introduced the theta-function: whose properties are discussed in Appendix B. The twisted superpotential (2.10) is equal to: It is easy to see that (2.10) and (2.13) have the same derivative with respect to u; this establishes the identity of the two expressions up to an integration constant, which can be checked numerically. The expression (2.13) is useful in order to study the analytic structure of the twisted superpotential. From its definition, one can see that ψ(u; τ ) has branch points at u = n + mτ , ∀m, n ∈ Z, with jumps by u − n − mτ . This leads to the following branch branch cut ambiguities of (2.13): W Φ ∼ W Φ + n u + mτ + n , n , m, n ∈ Z . (2.14) A pair of massive chiral multiplets. We can easily verify the identity: up to a choice of branch. The left-hand-side of (2.15) corresponds to the contribution of a pair of massive chiral multiplets Φ 1 , Φ 2 with opposite charges ±1 under the background U (1) symmetry. Such a pair can be integrated out with the four-dimensional superpotential W = Φ 1 Φ 2 . We naively expect for such massive chiral multiplets to decouple entirely. Instead, we find the linear term − 1 2 u in (2.15), which leads to subtle signs in the partition function, in the presence of background U (1) fluxes. Note that such signs only appear in the presence of an abelian background gauge field. Massive chiral multiplets that only couple to non-abelian gauge fields will decouple entirely.

W-boson contribution
The W-bosons enter the effective two-dimensional theory like chiral multiplets of gauge charge α a and R-charge 2, with α the roots of g. Due to the pair-wise cancellation between roots α and −α, the effect of the W-bosons on the twisted superpotential is extremely mild. Using the identity (2.15), we find: with ρ W the Weyl vector-the sum is over the positive roots. For G semi-simple, all components ρ a W are integers. Since the twisted superpotential is only defined modulo shifts by n a u a , n a ∈ Z, we can therefore ignore W vec in the following.

General gauge theory
Consider an N = 1 gauge theory for G semi-simple, with chiral multiplets Φ i in representations R i of g. We also turn on generic background parameters ν α for any flavor symmetry G F , with ν i = ω i (ν) and ω i the flavor weight as defined above. We simply obtain: with W Φ given by (2.10). The sum is over all weights ρ i of the representations R i . Importantly, as explained above, the twisted superpotential generally has branch cuts in u a and ν α , where it jumps by: W ∼ W + n a u a + n α ν α + n + mτ , n a , n α , n, m ∈ Z .
(2.18) Therefore, W is only defined up to such shifts. The linear ambiguity in u a reflects the fact that U a is a constrained twisted chiral fields, with the twisted F -term given by the two-dimensional gauge flux [32,43]. While W itself is a multi-valued function of (u a , ν α ), the A-model observables will be well-defined, meromorphic functions of these chemical potentials.

Large gauge transformations, modular transformations, and anomalies
Let us consider a U (1) a , the maximal torus of G × G F , where the index a = (a, α) run over both the gauge and flavor group. Classically, large gauge transformations of the background or dynamical gauge fields along the two torus cycles are symmetries of the action, which leads to the identifications: where u a ≡ (u a , ν α ). The same can be said about modular transformation-large diffeomorphisms of the torus-, with the two generators S and T acting as: Quantum anomalies can spoil these symmetries, however. In any anomaly-free gauge theory, we will see that the identifications u a ∼ u a + 1 ∼ u a + τ for the gauge variables holds exactly, as required by consistency since the gauge fields must be integrated over.
On the other hand, the A-model observables typically transform non-trivially under G F large gauge transformations, and under modular transformations, in a way which is governed by 't Hooft anomalies.

Anomalies
For convenience, and to set our notation, let us briefly review the various anomalies that can affect our four-dimensional gauge theory.
Gauge and flavor anomalies. Let I = (ρ i ) run over all the chiral multiplets (that is, over all weights ρ i for each i). We define the anomaly coefficients: where Q a I is the integer-valued U (1) a charge of Φ I -that is, Q a ρ i = ρ a i and Q α ρ i = ω α i in terms of the weights of the gauge and flavor representations. The anomaly coefficients A abc and A a correspond to the perturbative cubic and mixed gauge-gravitational anomalies, respectively. For the dynamical gauge symmetry G, we must have: The first condition ensures that G is non-anomalous, and the second condition ensures that the flavor symmetry is an actual symmetry in the quantum theory. On the other hand, we generally have non-vanishing 't Hooft anomaly coefficients A αβγ and A α for the flavor symmetry group G F . The coefficients A ab , on the other hand, will correspond to non-perturbative anomalies -also known as global anomalies-for semi-simple gauge groups [57,58,59]. Given (2.22) and the absence of perturbative anomalies, the absence of global anomalies for G requires: A ab ∈ 4Z . (2.23) The simplest example is G = SU (2) with n f doublets, which has A (2) = 2n f -we need n f to be even in order to satisfy (2.23), which is the condition for the absence of the well-known SU (2) global anomaly [57]. 9 More generally, for any simple, simply-connected group G s ⊂ G × G F , the coefficients A ab are given by the quadratic index: with R the (generally reducible) g s representation for the chiral multiplets. For the flavor symmetry group G F , the coefficients A αβ mod 4 may not vanish in general. In the presence of perturbative 't Hooft anomalies, there is no invariant meaning to the coefficients A αβ , whether for abelian or non-abelian flavor symmetries, but it is useful to keep the same notation as a bookkeeping device. We may call A αβ the "pseudoanomaly" coefficients. Finally, note that we have A aβ = 0 for G semi-simple.
Anomalies involving U (1) R . Last but not least, there are various anomalies involving the R-symmetry. The mixed gauge (or flavor)-R anomalies coefficients read: while the cubic and gravitational U (1) R 't Hooft anomalies are given by: For future reference, let us also define the quadratic "pseudo-anomaly" coefficients: By assumption, our theory has a non-anomalous U (1) R , therefore we must have: We also have A aR = 0 for G semi-simple.

Large gauge transformations of the twisted superpotential
The superpotential W(u, ν; τ ) defined above is affected non-trivially by large gauge transformations of its parameters. This non-trivial behavior in turn determines the behavior of many A-model observables, including the supersymmetric partition function, under large gauge transformations. Let us define the finite variations: More generally, a chiral multiplet in the spin j 2 representation of SU (2) contributes 1 3 j(j +1)(j +2) to A (2) . This reproduces the global anomaly in that case [57,60].
for n, m ∈ Z. Similarly, for any function F (u) of multiple variables u a , we define where we shift F (u) along a single u a at the time. The behavior of (2.17) under shifts of u a along the fundamental domain can be determined by direct computation on the building block W Φ for a single chiral multiplet. Using the definition (2.10), one can show that: (2.31) for any n, m ∈ Z. Note that the second line in (2.31) is only determined up to a choice of branch. The anomalous transformations of the full superpotential directly follow: with the anomaly coefficients defined in (2.21). Note that the twisted superpotential would be well-defined in the absence of any anomalies. More precisely, imposing the conditions A abc = A a = 0 and A ab ∈ 4Z ensures that W transforms as ∆W = n a u a + n τ τ + n 0 , with n a , n τ , n 0 ∈ Z, which can be cancelled by a change of branch. In the presence of anomalies, however, the non-trivial transformation of W is physically meaningful.
For non-anomalous four-dimensional theories satisfying eqrefaf cond 1-(2.23), the anomalous transformations (2.32) only depend on the flavor parameters ν α , with coefficients precisely determined by the (pseudo-) 't Hooft anomalies A α , A αβ and A αβγ for G F .

Modular transformations of the twisted superpotential
We should also consider the behavior of W under modular transformations. For a single chiral multiplet, we find: for the S and T generators acting on the superpotential. This is most easily derived using the expression (2.13) and the modular properties of (2.12). The transformations (2.33) satisfy the SL(2, Z) relations S 2 = C and (ST ) 3 = C, where the center C acts as charge conjugation, with C : (u, τ ) → (−u, τ ). The transformation: follows from the identity (2.15). Note that modular transformations and large gauge transformations are interrelated. Namely, a large gauge transformation around a particular one-cycle in T 2 , when composed with a modular transformation, should give the large gauge transformation around the modular-transformed one-cycle. One can check that this is consistent with the above results. For instance, the S transformation in (2.33) implies: This relation is satisfied by the large gauge transformations (2.31). For a general fourdimensional gauge theory, we directly find: (2.36) Therefore, the modular properties of the twisted superpotential are fully determined by the perturbative anomalies.

Flux operators and four-dimensional Bethe equations
Given the twisted superpotential, we may define several A-model operators [27]. The flux operator Π a is a local operator that inserts one unit of U (1) a flux on Σ g . It is given by: For a single chiral multiplet with twisted superpotential (2.10), we have the contribution: with θ 0 (u; τ ) the reduced theta function: We thus obtain: for the gauge and flavor flux operators, respectively. For future reference, it is useful to note that we may write the flux operators as: in terms of θ(u; τ ) defined in (2.12), and of the cubic anomaly coefficients defined in (2.21). In particular, we have: for the gauge flux operators of an anomaly-free theory. The flux operators (2.41) satisfy the relations: where we shift a single u b in Π a (u). This directly follows from (2.32) and from the definition of the flux operator. Note that (−1) A ab = (−1) A aab = (−1) A abb . One can also show that, under a modular transformation S of the torus, the flux operators transform non-trivially, with: The anomaly-free conditions (2.22)-(2.23) imply that the gauge flux operators (2.42) are fully elliptic in all of its parameters: ∀n, m, n , m ∈ Z . The set of Bethe-vacua for a four-dimensional N = 1 supersymmetric gauge theory is given by: with u a subject to the identifications u a ∼ u a + 1 ∼ u a + τ . Here W G denotes the Weyl group of G, and w · u the Weyl group action on {u a }. We are instructed to discard any solution that is not acted on freely by the Weyl group, as the corresponding would-be vacua are supersymmetry-breaking [61,62]. Note that the Bethe equations (2.46) only make sense for a well-defined, anomaly-free gauge theory, for which (2.45) holds true. Finally, we note in passing that the flux operators, which can be interpreted as surface operators supported on a T 2 fiber over Σ g , have the form of the elliptic genus of a 2d N = (0, 2) theory of chiral and Fermi multiplets coupled to the 4d gauge and flavor symmetry, as computed in [21,22].

The T 2 fibering operators
Consider the torus T 2 ∼ = S 1 β 1 × S 1 β 2 , with β 1 , β 2 the radii of the two circles. The twodimensional theory obtained by compactification on T 2 has a distinguished U (1) KK 1 × U (1) KK 2 global symmetry, whose conserved charges are the Kaluza-Klein (KK) momenta along both circles-corresponding to the integers n and m in (2.8).
From the two-dimensional perspective, there must exist distinguished flux operators that insert background fluxes for the KK symmetries, the so-called fibering operators [27]. We denote them by F 1 and F 2 for U (1) KK 1 and U (1) KK 2 , respectively. Like any flux operator, they are fully determined in terms of the effective twisted superpotential. These operators introduce a non-trivial fibration of T 2 over the Riemann surface on which the A-model is defined. From the four-dimensional perspective, the fibering operator is a particular defect surface operator wrapped over With our definition (2.1) for the modular parameter τ and reinstating dimensions, we have: for the two-dimensional twisted masses associated to U (1) KK 1 × U (1) KK 2 . One can then easily show that: for the first fibering operator, and for the second fibering operator. Note that we have been using a "three-dimensional" regularization, wherein we first consider the theory as a three-dimensional theory on R 2 × S 1 β 2 , and then regularize the remaining KK tower from S 1 β 1 . 10 From the point of view of M 3 ∼ = R 2 × S 1 β 2 , the modular parameter τ is the complexified fugacity associated to U (1) KK 1 for S 1 β 1 -an ordinary symmetry from the M 3 point of viewand all dimensions can be absorbed with the radius β 2 , as in (2.47). For this reason, the formula (2.48) takes the same form as the formula (2.37) for an "ordinary" flux operator, and both (2.48) and (2.49) directly follow from the three-dimensional results of [27].
Chiral multiplet contribution to F 1 . The first fibering operator is given in terms of the function: which is a specialization of the elliptic gamma function, Γ 0 (u; τ ) ≡ Γ e (qx; q, q). (See Appendix B.) From the definition (2.48), we find: for the contribution of a single chiral multiplet of unit charge. A useful relation satisfied by (2.51) is: This corresponds to a pair of massive four-dimensional chiral multiplets, which contribute trivially to the fibering operator.
Chiral multiplet contribution to F 2 . To discuss the explicit form of the second fibering operator, it is useful to introduce the function: which is meromorphic in u, with poles of order n at u = −n, n ∈ Z >0 . This is the fibering operator associated to the three-dimensional N = 2 supersymmetric chiral multiplet [27]. It satisfies the identity: For a four-dimensional chiral multiplet of unit U (1) charge, plugging (2.10) into (2.49), we directly obtain: . (2.55) The infinite product in (2.55) is convergent. Using (2.54), we can also show that: similarly to (2.52).
Large gauge transformations. The two fibering operators transform non-trivially under large gauge transformation, as follows from (2.31). One can check that: and for n, m ∈ Z. Note the appearance of the chiral-multiplet flux operator Π Φ when we perform a large gauge transformation along the circle being fibered. On general grounds, the two fibering operators are related by a modular transformation S. Indeed, one can prove that: This directly follows from (2.33). It also follow from mathematical results about the elliptic gamma function [63]. 11 General gauge theory. In the full gauge theory, the fibering operators are simply given by: From (2.59), we have the modular transformation: It is clear that the two fibering operators must be related by an S transformation. As we see, the exact relation involves the cubic anomaly coefficients. In any anomaly-free theory, we simply have: where the exponential prefactor is given in terms of the flavor symmetry 't Hooft anomalies. The fibering operators also transform non-trivially under large gauge transformations. We have: and (2.64) These important difference equations relate the flux and fibering operators. For any anomaly-free theory, the prefactors in (2.63)-(2.64) only involve the 't Hooft anomalies (as well as the "pseudo 't Hooft anomaly" coefficients), and therefore these prefactors only depend on ν α , and are independent of the gauge variables u a . This will be crucial later on.

Effective dilaton and handle-gluing operator
The second function that determines the A-model (2.6) is the effective dilaton Ω. For a four-dimensional gauge theory with matter fields in chiral multiplets Φ i of R-charges r i ∈ Z, we have: such that: (2.66) Here we have the contributions from the chiral and vector multiplets, respectively, which are given in terms of the chiral-multiplet flux operator (2.38). With respect to the three-dimensional case [27], the only new ingredient in (2.66) is the appearance of a contribution η(τ ) −2 for each generator of the Cartan of g, with η(τ ) the Dedekind function-see Appendix B. Using the effective dilaton, one may define the handle-gluing operator [31,27], whose insertion on Σ g has the effect of adding a handle, changing the topology of the base to Σ g+1 . Let us first define the Hessian determinant of the twisted superpotential: Note that H is fully elliptic in all parameters u and ν, as follows from (2.45). On the other hand, it has a non-trivial modular transformation: It is clear from the effective action (2.6) that the insertion of e 2πiΩ corresponds to concentrating the curvature of a single handle to a point. The appearance of the Hessian in (2.69) is due to the gaugino coupling in (2.6), because each handle comes together with two gaugino zero modes Λ, Λ, to be integrated over.
The behavior of the handle-gluing operator under large gauge transformations follows simply from the properties of Π Φ . It is easy to see that: (2.70) Here the anomaly coefficients are the ones defined in (2.25). By assumption, our fourdimensional gauge theory has an anomaly-free R-symmetry, so that (2.28) holds true. This implies that the handle-gluing operator is elliptic in u a , while it retains non-trivial transformation properties under shifts of ν α in the presence of mixed U (1) R -G F 't Hooft anomalies. We can similarly show that H is invariant under modular transformations up to 't Hooft anomalies. One can see that: with A R defined in (2.26). This crucially relies on the contribution of the Cartan vector multiplet contribution in (2.66), whose modular transformation cancels the one from (2.68). Finally, let us note that, upon imposing the anomaly-free constraint (2.28), we may write the handle-gluing operator (2.69) explicitly as: .
This will be useful below.

The M g,p index and its properties
In the previous section, we defined and computed the flux, fibering, and handle-gluing operators: for any well-defined four-dimensional N = 1 supersymmetric gauge theory with a semisimple, simply-connected gauge group G and matter fields in chiral multiplets. The operators (3.1) are local operators in the four-dimensional A-model, which is a twodimensional effective field theory with N = (2, 2) supersymmetry which describes the light degrees of freedom of the four-dimensional gauge theory compactified on T 2 , in the presence of arbitrary "complexified chemical potentials" ν α for the flavor symmetry.
(More precisely, ν α are T 2 flat connections for the Cartan of the flavor group G F .) We can also think of the operators (3.1) as particular half-BPS four-dimensional surface operators wrapped on T 2 . For generic-enough flavor parameters ν α , the four-dimensional A-model is a massive theory with discrete vacua, called the Bethe vacua. These vacua are in one-to-one correspondence with the solutions to the Bethe equations (2.46), as explained above. The Bethe equations are given explicitly by: as equations for the elliptic variables u a (a = 1, · · · , rk(g)), with the additional constraint that a valid solution {û a } rk(g) a=1 must be acted freely on by the Weyl group.

Fibering the four-dimensional A-model
Consider a complex four-manifold M 4 given as a T 2 fibration over Σ g : From the A-model point of view, the non-trivial fibration is realized by inserting the fibering operators F 1 and F 2 at a point on Σ g , thus introducing a non-trivial fibration of S 1 β 1 and S 1 β 2 , respectively, over Σ g . To realize the M 4 background (3.3), we must turn on fluxes: In addition, we may turn on arbitrary background fluxes (2.7), denoted by n α ∈ Z, for the flavor symmetry G F . The partition function of the four-dimensional A-model on Σ g , with those insertions, is then given by: as a sum over the Bethe vacua (2.46). It is important to note that this formula only makes sense if the gauge theory is anomaly-free, with vanishing mixed gauge-flavor and gauge-R anomalies. If and only if those condition are satisfied, the operators (3.1) are truly elliptic in the parameters u a , and therefore the Bethe equations (3.2) and the partition function (3.5) are well-defined. Importantly, we may always perform a modular transformation of T 2 such that: Indeed, the graviphoton fluxes (3.4) have the effect of shifting the twisted spins of the KK modes by δs = mp 1 + np 2 in two dimensions, which can be mapped to δs = m p by a modular transformation. There always exists an SL(2, Z) matrix: such that: denotes the corresponding SL(2, Z) action on the operator O. The proportionality factors in (3.8) are given entirely in terms of 't Hooft anomalies, as we saw explicitly in the previous section in the case A = S. Therefore, in the following and without loss of generality, we mostly consider (3.6). We will further discuss the modular properties of the four-dimensional A-model in subsection 3.6. This general discussion is compatible with the known classification of supersymmetric backgrounds in four dimensions. Four-dimensional N = 1 supersymmetric backgrounds coupling to the R-multiplet 12 are only possible for M 4 a complex manifold [6,7]. Moreover, our two-supercharge background is the pull-back of the twodimensional A-twist through the fibration Σ g in (3.3). This implies that T 2 must be elliptically fibered, and any such elliptic fibration has the topology: More specifically, we are considering principal elliptic bundles, which implies that M 3 ∼ = M g,p . The three-manifold M g,p is itself a principal circle bundle over Σ g [27]. This family of four-dimensional supersymmetric backgrounds was also discussed thoroughly in [26]. An important special case is g = 0 and p = 1, in which case we have M 0,1 ∼ = S 3 and M 4 is a primary Hopf surface M q,q 4 = S 3 × S 1 defined by the quotient: Recall that, in general, the primary Hopf surface M p,q 4 is determined by two complex structure parameters p and q, and the partition function on M p,q 4 computes the index (1.1) [10,12]. In this paper, we have set p = q = q in order to use the A-model point of view, as we explained in the introduction. We are therefore computing the corresponding specialization of the S 3 supersymmetric index.
Incidentally, we should also note that the "S-transformed" S 3 × S 1 background, corresponding to (p 1 , p 2 ) = (0, 1), has appeared before in the literature in the form of the so-called "modified S 3 index" [65]. In our language, this simply corresponds to using the fibering operator F 2 , instead of F 1 , in the construction of the three-sphere index. In the case of conformal theories, related modular properties of partition functions have been discussed in [66].

3.2
The M g,p × S 1 partition function from the A-model Specializing (3.5) to (3.6), we obtain: (3.11) By construction, the A-model partition function (3.11) is locally holomorphic in the flavor parameters ν α , and in the complex structure parameter τ . This is in agreement with general constraints on supersymmetric partition functions [10,67]. The precise identification between the A-model partition function and the "physical" M g,p × S 1 partition function is a non-trivial matter, due in particular to possible anomalous corrections to the naive supersymmetric Ward identities [54]. Nonetheless, the four-dimensional A-model is well-defined by itself for any fourdimensional gauge theory. We claim that (3.11) computes the expected "supersymmetric partition function" (1.3), possibly up to simple anomalous prefactors. In section 4 and 5, we will explain the exact relation between the A-model partition function and the standard supersymmetric index on S 3 . We will also give an alternative derivation of (3.11), for any M g,p , by supersymmetric localization.
Note that the background fluxes n α in (3.11) are actually valued in Z p , a torsion subgroup of H 2 (M g,p , Z). Under large gauge transformations for the flavor group along the T 2 fiber, we have: for any Cartan element U (1) α ⊂ G F . It follows from the general properties of the operators (3.1) that the partition function (3.11) transforms non-trivially under large gauge transformations for the background gauge fields. These transformations properties are determined by the 't Hooft anomalies: as follows from (2.43), (2.63) and (2.70). Note that the prefactor in the last line is a pure sign.

Supersymmetric Casimir energy and the M g,p index
As explained in the introduction, while the supersymmetric partition function should exactly compute the index (1.2), it is sometimes convenient to isolate the vacuum contribution like in (1.3). Consider the M g,p × S 1 partition function (3.11) for a nonanomalous gauge theory. We define the "normalized" M g,p index by: where E Mg,p is defined to be: It is natural to conjecture that (3.15) gives the vacuum expectation value of the Hamiltonian generating the S 1 translation on M g,p × S 1 -on this particular A-twist background (see Appendix A). To verify this conjecture, one should perform the Hamiltonian quantization on M g,p , similarly to the S 3 computation of [13,14]. We leave this for future investigation.
Note that the would-be supersymmetric Casimir energy (3.15) is given entirely in terms of perturbative 't Hooft anomalies. Therefore, it is scheme-independent. In particular, dual field theories on M g,p will have the same value of E Mg,p . The normalized I Mg,p is given by: as a sum over Bethe vacua. Here we defined: (3.17) By construction, the index (3.16) has an expansion in integer powers of q = e 2πiτ and y = e 2πiν . Indeed, the summand is a power series in q, y, and x = e 2πiu , and the solutions of the Bethe equationsx =x(q, y), can be computed order-by-order in q and y, in principle, since the gauge flux operators themselves have a natural expansion in integer powers of q, x and y. Note, however, that (3.17) also contains overall factors of y 1 2 , determined by the quadratic (pseudo-)anomaly coefficients A αR and A αβ , whose physical signification is more mysterious. 13

Small circle limit and Cardy-like formula
Consider any N = 1 supersymmetric background preserving two supercharges with topology M 3 × S 1 , with S 1 a circle of radius β. It has been argued, on general grounds, that the M 3 × S 1 supersymmetric partition function has a small-β limit governed by the mixed flavor-and R-gravitational anomalies [68]. In particular, in the absence of flavor background vector multiplets, we must have the universal contribution:

18)
13 These terms originate from the linear term in the exponential in (2.38).
with Tr(R) = A R . Here L M 3 is a constant depending only on the three-dimensional supersymmetric background M 3 . 14 In the case of our three-manifold M g,p , one can compute: This can be easily obtained from the three-dimensional supersymmetric background studied in [27]. The quantity (3.19) is essentially an "FI term" for the R-symmetry in three dimensions. The A-model partition function (3.11) corresponds to β = β 2 and β = β 1 . This general result is elegantly reproduced by the Bethe-vacua formula (3.11). In our notation, the correct three-dimensional limit is: The second condition ensures that the three-dimensional parameters-the complexified real masses on M g,p -are kept finite as we send β to zero. Using the modular properties of the flux, fibering, and handle-gluing operators, it is easy to prove that: in the limit (3.20). In addition to (3.18), we also have terms involving the gravitationalflavor 't Hooft anomalies, which appear in the presence of background G F vector multiplets. This fully agrees with [68]. Note that (3.21) is invariant under the large gauge transformations (ν α , n α ) ∼ (ν α + τ, n α + p) for the background U (1) α gauge field on M g,p . This is expected from three-dimensional gauge invariance.

Dimensional reduction
Having discussed the leading, divergent contribution in the β → 0 limit, we may also consider the finite piece, which can be obtained by subtracting off the contribution (3.21). In the limit (3.20), one finds: and: for the four-dimensional chiral multiplet. Here f Φ is the function defined in (2.53), and we defined the variables u ≡ u τ and x ≡ e 2πi u , which is the S-transformed u variable kept finite in this limit. 15 The finite terms (3.22)-(3.23) precisely correspond to the contributions of a three-dimensional chiral multiplet to the M g,p partition function, in a regularization that preserves three-dimensional parity at the expense of gauge invariance [27].
From these building blocks, one can deduce that, from a general 4d theory with gauge group G and chiral multiplets Φ i in representations R i of g, one obtains in the β → 0 limit the flux, fibering, and handle-gluing operators for the 3d theory with gauge group G and the same matter content. Since the divergent factors depend only on anomalies, we find that, for the non-anomalous gauge flux operators: 24) with no divergent factor. Thus the 4d Bethe equations descend directly to the 3d Bethe equations. More precisely, the above relation holds when we keep the parameters u finite as β → 0. There may also be solutions to the 4d Bethe equations which do not stay finite in this limit, and so are not captured by the above three-dimensional limit. In a favorable case in which all the four-dimensional Bethe vacua survive in the three-dimensional limit, we directly obtain (suppressing parameter dependence for simplicity): where β is the divergent factor (3.21), which we subtract off, and on the last line we obtain the M g,p partition function of the 3d N = 2 theory with the same gauge group and matter content as the 4d theory we started with. On the other hand, if some of the four-dimensional Bethe vacua are not captured in the above limit, we may find additional terms in the β → 0 limit of the M g,p × S 1 partition function, in addition to the above M g,p partition function of the naive 3d theory. The three-dimensional limit of the supersymmetric index has been discussed in detail by [70,69], where potentially related issues arose. It would be interesting to compare the two approaches further. 15 The variable u in (3.22)-(3.23) should be identified with the three-dimensional u in [27]. This is simply because we constructed M g,p with the first fibering operator F 1 , so that β = β 2 . An identical limit can be obtained in term of u if we consider the limit β 1 → 0 on Π Φ and F Φ 2 , respectively.
Note that the flavor symmetry parameters we obtain in 3d descend from those in 4d, which were constrained to be non-anomalous-A aαβ = A abα = 0 for all flavor indices α, β and gauge indices a, b. In 3d there are no such anomalies, so no a priori reason to make this restriction. However, as discussed in [9], 3d theories obtained from 4d by dimensional reduction generally contain non-perturbative superpotential terms depending on three-dimensional chiral monopole operators, generated by twisted instantons in the 4d theory on a circle, which have the effect of breaking precisely those 3d symmetries which are anomalous in 4d. The more precise statement, therefore, is that the 3d theory whose M g,p partition function we obtain in (3.25) is the theory with these monopole superpotential terms included.
In section 6, we will discuss pairs of 4d dual theories and show that their M g,p × S 1 partition functions agree; then the argument above shows that, by taking the β → 0 limit on both sides, the M g,p partition functions of their reductions agree, providing strong evidence for their duality in 3d, as discussed in the case M g,p = S 3 in [9]. This statement is however subject to the caveat mentioned above.

Modular transformations of the A-model
Since the four-dimensional A-model is defined by compactification on a torus, one expects that is behaves naturally under modular transformations. Let us denote by S and T the generators of the modular group, corresponding to the SL(2, Z) matrices: We have: with C = −1 the central element. The modular group acts on the A-model fields and parameters according to: while C inverts the sign of all chemical potentials, C : (u, τ ) → (−u, τ ). In order to give an explicit presentation of SL(2, Z) on the A-model, it is more convenient to consider the generator: instead of T . This gives an equivalent presentation of SL(2, Z), with The action of S and T on the A-model operators is given by: where all the operators are evaluated at (u, τ ). The S transformations were already discussed in section 2. The T transformations can also be proven by direct computation, using the results of that section. Given (3.31), we can construct the action of any A ∈ SL(2, Z) on the A-model. For instance, we easily check that: for the central element C. Consider the A-model partition function (3.5), which takes the form: where we suppressed the arguments to avoid clutter. As we mentioned in section 3.1, we can use the SL(2, Z) action on the A-model to set (p 1 , p 2 ) = (p, 0). This gives a particular construction of the M g,p × S 1 partition function, with τ a complex structure parameter of the four-manifold. Note that the four-dimensional supersymmetric background breaks SL(2, Z) explicitly unless p = 0. By performing an SL(2, Z) transformation, one simply obtains a different realization of the M g,p ×S 1 partition function. Related modular properties of the S 3 index have been discussed in the literature, in connection with 't Hooft anomalies [71,65]. In our formalism, these modular properties are simply explained in terms of the T 2 compactification necessary to define the four-dimensional A-model. 16 Finally, let us note that the Σ g × T 2 partition function-that is, the special case p = 0-enjoys natural modular properties: which are closely related to the modular transformation properties of the N = (0, 2) elliptic genus [22,23]. Indeed, N = 1 theories on Σ g × T 2 can be related to N = (0, 2) theories on the torus, by dimensional reduction on the Σ g factor [24,25].

Freeing the R-charge on a trivial U (1) R bundle
Our discussion so far described the A-model perspective on supersymmetric partition functions. In that approach, it is important that the R-charges be integer-quantized so that the A-twisted theory can be defined on any closed Riemann surface Σ g . More generally, we should consider R-charges such that r i (g − 1) ∈ Z, at fixed genus g. This Dirac quantization arises because the U (1) R background gauge field has non-trivial flux: across the Riemann surface Σ g on which the A-model is defined. Here, A µ is a connection on L (R) ∼ =K − 1 2 , withK the anti-canonical line bundle over Σ g . In four dimensions, our supersymmetric background is a pull-back of the two-dimensional background. Our choice of supersymmetry imposes a choice of complex structure on the four-dimensional manifold M 4 ∼ = M g,p × S 1 . (We briefly review this in Appendix A.) In particular, the anti-canonical line bundle of M 4 , denotedK as well, is the pull-back of the twodimensional anti-canonical line bundle over Σ g , and similarly for the R-symmetry line bundles.
When T 2 is non-trivially fibered over Σ g -that is, for p = 0-, the R-symmetry line bundle over M 4 , denoted L (R) , is a torsion line bundle, with first Chern class: In particular, whenever: the U (1) R line bundle is topologically trivial, and the R-charges need not be quantized. This is the case we will discuss further in this section. The most important instance of the trivial-bundle condition (4.3) is p = 1, g = 0, corresponding to the Hopf surface M q,q 4 ∼ = S 3 × S 1 .

A tale of two gauges
Even as we consider a background with L (R) topologically trivial, it need not be trivial as a holomorphic line bundle. A holomorphic line bundle L over the complex manifold M 4 ∼ = M g,p × S 1 is determined by the parameters (ν, n), with ν its complex modulus, which is valued in the first Dolbeault cohomology H 0,1 (M 4 , C), and n its first Chern class valued in H 2 (M 4 , Z). The modulus ν corresponds to a choice of flat connection on the T 2 fiber. 17 Let us choose the SL(2, Z) frame in which M g,p × S 1 is constructed using the first fibering operator, F 1 , so that S 1 β 1 is the circle being non-trivially fibered. A large gauge transformations along S 1 β 2 identifies: (ν, n) ∼ (ν + 1, n), while a large gauge transformation along S 1 β 1 identifies: (ν, n) ∼ (ν + τ, n + p) .
When we specify our supersymmetric background, the choice of gauge for the U (1) R line bundle must be specified. In most of this paper, we are choosing the so-called "Atwist gauge", in which: However, if the condition (4.3) is satisfied, we can also take: which is related to (4.5) by a large gauge transformation. For lack of a better term, we call (4.6) the "physical gauge". On the round S 3 , this corresponds to a U (1) R gauge that is trivial along the S 1 and has a fixed holonomy along the S 1 -see Appendix A.
The choice of gauge is important because it determines the R-charge dependence of the supersymmetric partition function [67]. If we choose r i ∈ Z for all the R-charges, either gauge leads to the same partition function (up to some relative sign). On the other hand, the physical gauge allows us to easily obtain the correct result for real R-charges. Consider varying the R-charge by mixing it with some flavor symmetry with t a mixing parameter. In general, we should take t ∈ Z, to preserve the Dirac quantization condition on the R-charge, but in the case that we are considering now, we may take t ∈ R. The mixing (4.7) corresponds to a tensor product of the U (1) F line bundle with the R-symmetry line bundle, L (F ) → L (F ) ⊗ (L (R) ) t . Accordingly, the flavor parameters are shifted according to: In the A-twist gauge (4.5), the flavor modulus ν F stays invariant, and the R-charge only appears through the background fluxes, including (4.1). The shift (4.8) only makes sense for t ∈ Z, because n F is integer-quantized. In the physical gauge (4.6), on the other hand, the flavor fluxes stay constant, and we can take t ∈ R. In this case, the Rcharge dependence of the partition function appears through the holomorphic moduli, through the particular combination: for each chiral multiplet Φ i . This is the case considered in the literature, in the case of the S 3 supersymmetry index, where the R-charges appear through the combination ν i + τ (r i − 1) for each chiral multiplet. Let us also define the integer: for future reference.

Physical-gauge twisted superpotential and flux operators
While we lose the straightforward A-model interpretation in the physical gauge, we may still define an effective two-dimensional theory for the light degrees of freedom. The effective twisted superpotential takes the form: (4.11) Here the function W Φ (u; τ ) is the one defined in (2.10), with its argument shifted according to (4.9). In addition to the chiral multiplet contribution, we have the contribution from the W-bosons on the second line. Finally, the u-independent term W h (ν R ; τ ) in (4.11) is the contribution from the vector multiplets along the Cartan h of g. We have: with the W U (1) (ν R ; τ ) the contribution of a U (1) vector multiplet after removing all its zero-modes. We will come back to this term momentarily. If we set ν R = 0 in (4.11), we recover (2.17) plus the trivial contribution (2.16). Let us use the notation u a = (u a , ν α ), as in previous sections. The physical-gauge flux operators are naturally defined in terms of (4.11), by the formula: (4.13) One directly obtains: (4.14) Note that the W -boson terms in (4.11) do not contribute to the gauge flux operators, because of the simple identity: where ρ W is the Weyl vector, and the last equality is for G semi-simple. The elliptic properties of (4.14) are similar to (2.43). We find: (4.16) Note the appearance of the anomaly coefficient A abR , as defined in (2.25). 18 In particular, in any anomaly-free theory, the gauge flux operators Π phys a are elliptic in all their parameters u a , ν α . It is also modular invariant.
In the special case when the R-charges are all integer, the physical-gauge flux operators (4.14) and A-twist-gauge flux operators (2.40) are identical up to a sign: with l R defined in (4.10). In particular, the two gauge flux operators are exactly identical in that case.

The physical-gauge fibering and handle-gluing operators
We can similarly introduce a generalization of the fibering and handle-gluing operators.
The following results can be derived by considering various one-loop determinants in the physical gauge, as we explain in Appendix C.2.3. In the following, we also restrict ourselves to the modular frame (3.6), for simplicity. This is the frame in which we can most easily compare our results to standard results for the supersymmetric index. The physical-gauge fibering operator is given by: (4.18) The contribution from (4.12), for the Cartan of the gauge group, is given explicitly by: Let us also define the Hessian determinant of the twisted superpotential (4.11): which generalizes (2.67). On the other hand, there is no effective dilaton in the physicalgauge picture, because n R = 0 in (4.6). It will be convenient to consider the combination: with the Hessian (4.20). For integer R-charges, the operator (4.21) is equivalent to the product of the fibering and handle-gluing operators in the A-twist gauge. More precisely, one can check that: Here the relative sign is given in terms of the (pseudo-)anomaly coefficients (2.26)-(2.27).

Supersymmetric partition function, Casimir energy and index
Given the ingredients introduced above, we can easily construct the supersymmetric partition function. Consider the supersymmetric Bethe vacua, defined by: These vacua are completely equivalent to the A-model vacua (2.46). Given a solution {û a } to (2.46), we obtain a solution to (4.23) by the substitution: The "physical" partition function is given by: For integer R-charges and whenever (4.3) holds true, (4.25) is equal to (3.11) up to a sign, as follows from (4.17), (4.22), and from the total ellipticity of the gauge flux operators.
Supersymmetric Casimir energy. One can again consider a factorization of (4.25) into a "normalized index" and a supersymmetric Casimir energy contribution: The supersymmetric Casimir energy is given by: (4.28) The expression E

(G)
Mg,p in (4.28) reproduces exactly the three-sphere supersymmetric Casimir energy [14,15], as one would expect. In particular, if we set the flavor chemical potential to zero and choose the R-charge to the superconformal R-charge in the infrared, we get: with a, c the four-dimensional conformal anomalies. Setting l R = 1, we reproduce the correct result for the round S 3 [14].
The generalized index. Comparing (4.26) and (4.25), we read off the complete expression for the generalized M g,p index in the physical gauge. It is given by: with:

(4.31)
We suppressed some of the τ dependence in (4.31) to avoid clutter. Note the appearance of a subtle phase for each Cartan element, on the second line of (4.31). This follows from the computation of Appendix C.2.3.

A new evaluation formula for the S 3 index.
Let us consider the important special case p = l R = 1, ν R = τ , which corresponds to the round three-sphere background. According to (4.30), the S 3 supersymmetric index can be written as a sum over Bethe vacua: The summand J S 3 can be written suggestively as: , (4.33) where we used the inversion formula Γ 0 (u; τ ) = Γ 0 (−u; τ ) −1 to put the W -boson contribution in the denominator. The summand (4.33) is precisely the integrand of the Romelsberger integral for the S 3 index [2,34], multiplied by (H phys ) −1 .
In the next section, we will prove that Bethe-vacua formula (4.32) for the round three-sphere index precisely agrees with the Romelsberger index (specialized to p = q = q). We will also present a generalization of the integral formula for any M g,p × S 1 partition function.

Integral formulas and Bethe equations
In this section, we present explicit integral formulas for the M g,p ×S 1 partition function. They can be derived by supersymmetric localization, similarly to the three-dimensional case studied in [27]-see also [22,23,17,19,20,27]. We will only sketch this derivation, insisting on the specificities of the four-dimensional case. We will also relate this result to the standard integral formula for the S 3 index.
These integral formulas can argued to be equivalent to the sum-over-Bethe vacua formula of the previous sections, at least formally. The important caveat is that, for genus g larger than zero, the W -bosons introduce additional subtle contributions, which we will not address systematically here. The net effect of these contributions is to restrict the sum over Bethe vacua to the physical abelian vacua, discarding any potential contribution from supersymmetry-breaking non-abelian vacua (that is, the would-be solutions of the Bethe equations that are not acted on freely by the Weyl group). Similar discussions appeared in [19,20].

Localization to a contour integral
The M g,p × S 1 partition function of an N = 1 gauge theory can be computed directly by localization with the UV action, in principle. Let us consider the case p = 0, unless otherwise stated. The case p = 0 was studied in [19]. In this section, we consider the M g,p × S 1 background corresponding to the first fibering operator, F 1 .
To deal with the vector multiplet, we follow the abelianization method of Blau and Thompson [72,73,74]. The gauge field can be localized to flat connections along the T 2 fiber, which can be conjugated to the Cartan torus H ⊂ G: In addition to these, we also have flat connections along the base of the Riemann surface: The one-form w I are pulled-back from the g closed one-forms on Σ g . 19 The parameters α a , α a live on a compact domain. The supersymmetric equations also allows for torsion bundles over M g,p . For p = 0, we should sum over m valued in: This sum over topological sectors is the price to pay for abelianization over M g,p [74]. For p = 0, u a = τ a a 1 − a a 2 take values in the torus T 2rk(g) , due to the identifications a a 1 ∼ a a 1 + 1 and a a 2 ∼ a a 2 ∼ 1. For p = 0, on the other hand, S 1 β 1 is a torsion one-cycle, so that a a 1 takes values in R. More precisely, as we explained in [27], a a 1 receives a topologically non-trivial contribution if A µ is the connection of a torsion bundle L. For any U (1) ⊂ H, have: where m ∈ Z p the first Chern class of L. This implies the identifications: under large gauge transformations along S 1 β 1 × S 1 β 2 , with the complexified flat connections u a valued in C rk(g) , and the integer-valued torsion fluxes m a .
These flat connections have fermionic superpartners, which consist of scalar and one-form zero-modes for the gauginos on the A-twist background. In order to regulate the singularities of the one-loop determinant, we also turn on some constant modes D 0 for the auxiliary field D in the abelianized vector multiplets. After careful integration over the fermionic zero modes and over D 0 , we find the expression: Here the sum is over the topological sectors (5.3), indexed by m. For each m, the integrand reads: in terms of the fibering, handle-gluing, gauge flux and flavor flux operators, and with H the Hessian determinant (2.67). This integrand can also be written as: where Z 1-loop is a one-loop determinant around the supersymmetric background corresponding to (u, m) and (ν, n)-as discussed in Appendix C.2-, while the Hessian to the power g comes from integrating out the g gaugino one-form zero-modes on M g,p × S 1 . The prefactor |W G | in (5.6) is the order of the Weyl group of G.

The Jeffrey-Kirwan contour integral
The remaining ingredient necessary to properly define (5.6) is the integration contour C η , which is a certain middle-dimensional contour inside {u a } ∼ = (C * ) rk(g) . Its precise determination is highly non-trivial. For simplicity, let us focus on the case of a rank-one gauge group, although we expect that a similar story holds more generally.
Following [17,19,20], the contour C η in (5.6) can be related to the Jeffrey-Kirwan (JK) residue integral [75,76]. More precisely, the contribution of the "bulk" singularities-that is, poles of the integrand at finite values of u-, corresponding to the matter chiral multiplets, are captured by JK residues at those singularities, with auxiliary parameter η ∈ ig * . There are also potential singularities at the "boundary" u a → ±τ ∞. We have shown the schematic picture for the rank-one case in Figure 1. We may understand these boundary contributions by cutting off the integral at a 1 = R for some large R ∈ R >0 , which we take to infinity at the end of the calculation. Following the discussion of the three-dimensional case [27], one can show that the regulated contour C η R is given by:  Figure 1: Integration contour C η R for p > 0 in the rank-one case. The contour in the bulk is determined by the JK residue. Two vertical segments represent the potential singularities at u =→ ±τ ∞.
where ∂M R is the contour that encircles all the bulk and boundary singularities. The integrand (5.7) transforms as: under large gauge transformations (5.5) along S 1 β 1 , with Π the gauge flux operator. This directly follows from the properties of the fibering operator F 1 for a non-anomalous gauge theory. Using this relation, we can write: 20 du I m (u, ν) .

(5.11)
Here, we defined C η k the contour C η restricted to the region a 1 ∈ [k, (k + 1)], such that: as depicted in Figure 2. The contour C η 0 in the last expression is the "JK-contour" restricted to the fundamental domain of the torus. Generalizing to higher rank, we expect similar boundary contributions [27], and we conjecture a formula: In the case p = 0, the boundary contributions are trivial, and (5.13) agrees with the formula for the Σ g × T 2 partition function in [19]. More generally, the manipulation (5.11) brings the M g,p × S 1 partition function (5.6) to a form analogous to the p = 0 case, including the sum over all gauge fluxes on Σ g in (5.13). At the level of these integral formulas, this simply corresponds to the relation (1.16) between spaces of different topologies.

The W -boson contribution.
The above analysis holds with one very important caveat. So far, we did not mention the potential singularities of the integrand (5.7) originating from poles in the one-loop determinant for the W -bosons, for any G non-abelian. Such W -bosons singularities exist if and only if g > 1.
A deeper study of this important issue, which would lead to a more rigorous supersymmetric localization argument in the UV, is beyond the scope of this paper. For our purposes, it will be enough to note that the Bethe-vacua result can be obtained by naively summing over topological sectors with a JK residue that includes the matter chiral multiplets singularities only (plus contributions from the boundary), thus obtaining a naive sum over Bethe vacua of the abelianized theory, and then excluding by hand the would-be Bethe vacua not acted on freely by the Weyl group, as in [19].

The unit-circle contour integral
Starting from the formula (5.6) for p = 0, we can also deform the contour C η to a simpler one, which can be related to previous results in the literature [2,12]. Under a certain assumption on the flavor and R-symmetry backgrounds, which we will specify below, and for a suitable choice of η for each k, we claim that: where T xa is the unit circle in the x a -plane, where x a = e 2πiua . This correspond to an integration over flat connections a 2 over the S 1 in M g,p × S 1 . Interestingly, this is also the "naive" localization result one would obtain by imposing the standard reality conditions for the fields, so that we localize on four-dimensional flat connections, F µν = 0-see in particular [12]. For p = 0, such flat connections include the connections of non-trivial flat torsion bundles (5.3), which we sum over.
For the rank-one case, the equivalence (5.14) can be shown by taking: η(k) > 0 for k ≥ 0 , and η(k) < 0 for k < 0. (5.15) Then, as illustrated in Figure 2, all the vertical segments in the bulk cancel each other except for the contour at a 1 = 0. The two boundary segments at either end do not contribute, because the integrand vanishes as we take them to infinity. There remain potential bulk contributions, but we claim that these do not contribute when a certain condition-see (5.25) below-holds. The remaining contour is precisely the unit circle contour (5.14). We claim that the equivalence holds for the higher-rank theories as well. We then have: where we wrote the integrand (5.7) as a function of x a and y α = e 2πiνα . We can also argue for the formula (5.16) by directly relating it to the Bethevacua formula (3.11). This argument is analogous to the one in [27] for the threedimensional M g,p partition function. Let us again consider the rank-one case, for simplicity. Starting from (5.16), we may perform the sum over m explicitly: Here and in the following, Π is the gauge flux operator, while we omitted the flavor flux operators Π α to avoid clutter. Using the difference equation Π u (x, y)F 1 (x, y) = F(q −1 x, y), we can rewrite (5.16) as: where I 0 (x, y) is the integrand (5.7) at m = 0. Here, ∆ is the difference of the contour at |x| = 1 and the contour at |x| = |q| −1 . Here we have used the fact that all factors in the integrand, apart from F(x, y), are invariant under x → qx. As noted above, this relies on the absence of any anomalies for the gauge symmetry.
This contour integral is equal to the sum of the residues of all poles contained in the region 1 < |x| < |q| −1 . These poles may come from the numerator or denominator. However, we claim that, if we assume the relation (5.25) below, there are no poles in this region coming from the numerator. We will argue for this momentarily. Assuming it is true, the only poles in (5.18) that lie inside this region are those at Π(x, y) = 1. These are precisely the solutions to the "naive" Bethe equation (including, potentially, non-abelian vacua that one should discard). We thus find: Using (2.67), one finds the residue of the 1 1−Π factor cancels the factor of H, and therefore: A similar argument holds for higher-rank theories. The acceptable Bethe solutions {x a } to Π a (x, y) = 1 come in Weyl-group orbits of maximal size |W G |, canceling the Weylsymmetry factor in (5.19). The contribution from the non-acceptable solutions, which are not acted on freely by the Weyl group, should be discarded by hand. Reinstating the flavor flux operators, this leaves us with: which is precisely the sum-over-Bethe-vacua formula (3.11).
In this sense, the relation between the integral formula and the Bethe-vacua formula is only formal, as we already anticipated. For g = 0, the contribution from the nonacceptable Bethe vacua vanishes, because H −1 vanishes on such solutions-for g > 1, on the other hand, it would diverge. Since the Bethe-vacua formula has a rather simple derivation and itself passes a number of physical consistency checks, the open challenge would be to specify the exact contour C η in (5.6), valid for any g > 0, that reproduces the Bethe-vacua answer without further assumption. We leave this for future work.
This important remark notwithstanding, it remains to derive the conditions under which there are no poles coming from the numerator in (5.18). Apart from the Hessian factor, a single chiral multiplet of gauge charge Q and R-charge r contributes to this numerator as: , (5.22) in the A-twist gauge-see Appendix C.2. Here, y and n are the net flavor parameters the chiral multiplet couples to. This expression can have a pole when x Q = y −1 q −m for some m ∈ Z. In addition, the chiral multiplet contributes a simple pole at the same points to the Hessian determinant, H(x). Generically, this is the only source of a pole at this point, so the behavior of the numerator I 0 (x) here is given by: Let us fix p > 0, for definiteness. Picking m so that the exponent is negative, one finds that a pole can only arise when: Now, we want to impose that there are no poles of the integrand (5.18) coming from I 0 , in the region 1 < |x| < |q| −1 , for this chiral multiplet. For Q < 0, we should pick the parameters so that the RHS of (5.24) is bounded below by 1. For Q > 0, we would naively bound the RHS below by |q| −Q ; however, since the denominator of (5.18) also blows up at these points, we may actually allow sufficiently mild poles in the numerator, and one finds that RHS need only be bounded below by 1. Summarizing, in either case, we find the condition: If we impose this relation for all the chiral multiplets in the theory, then the numerator contributes no poles at all to (5.18), and this completes the proof. The restriction (5.25) implies that we may only perform this calculation in some subset of parameter space, and this may not be compatible with the physical constraints imposed by the superpotential and anomaly cancellation. However, having performed the computation here, we may then extend it to the rest of parameter space by analytic continuation. Moreover, by starting in such a region of parameter space and continuously varying parameters, one may deform the contour such that it is not crossed by any poles, and one may, in principle, obtain the correct integration contour for any point in parameter space in this way. The argument for higher rank is a straightforward extension [27]. An interesting special case of (5.25) is when we consider real chemical potentials only, so that |y| = 1. In that case, the condition is simply that n + r(g − 1) < 0. In particular, on the three-sphere with n = 0, we simply need all the chiral multiplet R-charges to be positive, r > 0.

The three-sphere supersymmetric index
In the case M g,p = S 3 , we may also work in the physical gauge and at real R-charges, r ∈ R, as explained in section 4. Consider the physical gauge for any M g,p such that (4.3) holds. The chiral multiplet one-loop determinant can have poles at x Q = y −1 q −m−l R (r−1) , with l R defined in (4.10), for m such that pm + n > 0. By the same reasoning as above for p > 0, this leads us to the same condition as in (5.25), with the difference that r can be real. In particular, for S 3 , we should have: for every chiral multiplet Φ i . The integral formula (5.16) then reads: where we have a single topological sector because p = 1. The integrand is the "physical" fibering operator (4.18) for ν R = τ . Once we strip away the supersymmetric Casimir energy term, with E S 3 given by the first equality in (4.28) with ν R = τ , we are left with the index formula: (5.29) with y = e 2πi , q = e 2πiτ . This is the standard expression for the S 3 supersymmetric index [2,34] with p = q = q. From (5.26), we see that this formula is valid, in particular, for real chemical potentials ν i and positive R-charges, r i > 0. The contour integral in (5.29) has a standard interpretation as a projection onto gauge-invariant states. For more general parameters, we can deform the contour appropriately, as mentioned above.
Finally, we note that our simple proof of the equality between the integral formula and the Bethe-vacua formula goes through without problem, so that (5.29) is exactly equal to (4.32).

Supersymmetric dualities
The exact computation of supersymmetric partition functions can provide detailed evidence for supersymmetric dualities. In this section, we compute the M g,p × S 1 partition function for dual pairs of four-dimensional gauge theories, using the Betheequation approach. We focus on Seiberg dualities between N = 1 gauge theories with U Sp(2N c ) and SU (N c ) gauge groups. We verify that the dual partition functions agree. This new test of Seiberg duality can also be viewed as a strong consistency check of our general results.

Generalities: Mapping Bethe vacua and surface operators
Before turning to the examples, let us make a few general comments, closely following the three-dimensional discussion of [27]. Consider some gauge theory T . We know from (3.11) that we may write the M g,p × S 1 partition function as: where ν α and n α are the flavor fugacities and background fluxes, respectively. (The geometric parameter τ is kept implicit.) If the theory has an infrared-dual description as another gauge theory, T D , one may write the dual partition function similarly: Here we assumed that the dual gauge theories have isomorphic flavor symmetries, 21 and we identified the flavor parameters appropriately. To prove the equality of supersymmetric partition functions, on any four-manifold M g,p × S 1 and for any set of flavor symmetry background fluxes, it suffices to exhibit a "duality map" between the two-dimensional Bethe vacua, such that dual operators are equal when evaluated on dual vacua. More precisely, we must find a bijection: such that: for the fibering and handle-gluing operators, and for the flavor flux operators. The matching of these operators in every supersymmetric vacuum immediately implies the equality for the partition function. Note that the duality relation (6.4) for the fibering operator implies (6.5), due to the difference equations (2.63), and the fact that 't Hooft anomalies must match between dual theories. Similarly, the matching of F 1 also implies the matching of the other fibering operator, F 1 (û) = F D 1 (û D ), since the two fibering operators are related by (2.62).
Note the appearance of subtle signs (−1) s(H) and (−1) s(Πα) in the duality relations. They are given explicitly by: with G and G D the gauge groups of the dual theories T and T D , respectively. Here A RR and A αβ are the quadratic "pseudo-anomalies": (6.8) and similarly for A RR D and A αα D in the dual theory. One can show that s(H) and s(Π α ) are integers. The sign (−1) s(Πα) follows from the equality of the dual fibering operators together with the second line in (2.63), and the sign (−1) s(H) can be similarly determined by consistency. We find that the relative sign in (6.6) is given in terms of the quadratic "pseudo-anomalies", but the physical meaning of this observation is unclear. 22 In particular, we should note that trivial modifications of the UV completion of a theory, such as the inclusion of very massive fields charged under the flavor symmetry, can modify the sign of the A-model partition function. We leave a more thorough understanding of this point for future work.
To conclude with our general remarks, we would like to emphasize that the duality map (6.3) allows us to map any pairs of operators in the dual four-dimensional Amodels-in principle. That is, we may consider the expectation values of any half-BPS surface operators S wrapping the torus fiber, which are computed by insertions the corresponding A-model operator S(u, ν) in the sum over Bethe vacua. We have: for the unnormalized expectation value-or correlation functions, since these correlators are independent of the insertion points-, and similarly for surface operators in the dual theory. Thus, if we can find a pair of dual surface operators, which must satisfy: in all Bethe vacua, we may also infer the equality of their expectation values on M g,p × S 1 in the dual theories.
6.2 Example: N = 1 SU (2) gauge theory with N f flavors Before discussing some larger families of dualities, we pause here to describe the computation of the M g,p × S 1 partition function in a simple example. This serves to make some of the abstract considerations above more concrete. The example we consider will be the N = 1 SU (2) gauge theory with N f flavors, i.e. 2N f chiral multiplets in the fundamental representation of SU (2). 23 Let us introduce the parameters u for the Cartan of the SU (2) gauge symmetry, and ν i , i = 1, · · · , 2N f , for that of the SU (2N f ) flavor symmetry, which satisfy The twisted superpotential of this theory reads: As usual, there is no contribution from the W-bosons.
A-model operators and Bethe vacua. From the twisted superpotential, we may construct the gauge flux operators: the flavor flux operators: the fibering operator: (6.14) and the handle-gluing operator: where: . (6.16) 23 Recall there must be an even number of doublets to cancel the global anomaly.
More precisely, each flux operator Π i by itself corresponds to an anomalous symmetry. The non-anomalous SU (2N f ) flux insertions are: Then, Π SU (2N f ) is an elliptic function of u. For the handle-gluing operator, we must pick a non-anomalous R-symmetry by assigning the chiral multipets R-charges r j ∈ Z satisfying the anomaly-free condition: The vacua of the theory are determined by the Bethe equation: As described in more detail in the next subsection, for generic ν i , this has 2N f solutions in a given fundamental domain of the torus: for someû l depending on the ν i 's. A solution corresponding to a valid vacuum must be acted freely by the Weyl symmetry,û → −û, which excludes the first four solutions in (6.20), and solutions are considered up to this symmetry, so the set of Bethe vacua is: In particular, this theory has N f − 2 massive vacua when quantized on a torus with generic flavor fugacities ν. That is, we find the Witten index: Bethe sum formula for the partition function. The M g,p ×S 1 partition function is given by: where the sum runs over the supersymmetric vacua in (6.21), and the dependence on τ is implicit. In practice, it may be difficult to compute (6.23) explicitly since we only know theû l implicitly through (6.19). One way to proceed is by working perturbatively in q = e 2πiτ . We use the exponentiated variables, x = e 2πiu and y i = e 2πiν i , and expand: l + · · · (6.24) Then thex (0) l are given by solutions to the polynomial equation: One can then correct these solutions order by order in q. For example, one finds that the leading correction is given by: 24 One can systematically compute higher order corrections in a similar way; however, this quickly becomes quite cumbersome to do analytically.
The N f = 3 case. For concreteness, let us consider in more detail the case N f = 3. In this case, there is a single Bethe vacuum, up to the Weyl symmetry, and one computes the leading order solution: , One can use (6.26) to compute the solution to the next order in q.
We can use this solution to compute the M g,p × S 1 partition function to leading order in q. Let us assume, for simplicity, that the flavor symmetry fluxes vanish, n i = 0. Then, we simply need evaluate the fibering and handle-gluing operators at the Bethe solution. For general N f (writingẑ =x +x −1 as above, and stripping off the Casimir energy factors for simplicity), we find: with After plugging in the form ofẑ above, one eventually finds a relatively simple results for N f = 3 at first order in q: (6.30) One can verify that these precisely agree with the leading order q-expansions of the fibering and handle-gluing operator for a theory of 15 free chiral multiplets, which can be identified with the mesons, Q i Q j , of the SU (2) N f = 3 theory. This gives a simple example of the duality of [41], with R-charges mapped appropriately across the duality. We will discuss this duality in more generality in the next subsection. The M g,p × S 1 partition function is simply given by: with F 1 and H given, to leading order in q, by (6.30).
Integral formula We may alternatively use the integral formulas in Section 5. Let us consider the case p = 0, so that we may use the formula (5.16), which gives: We have argued in the previous section that this agrees with the known formula for the S 3 × S 1 index in the case g = 0, p = 1, but let us check this explicitly here. In this case, the above becomes: Here, one must take care because the terms in the q-expansion are typically rational functions of x, rather than polynomials as in the superconformal S 3 × S 1 index. 25 To deal with these, we formally make the assumption (5.25), which imposes that the |y i | are small, which determines which poles are enclosed by the unit circle contour. Taking as an explicit example the anomaly-free R-charge assignments {r i } = {0, 0, 0, 0, 1, 1}, we find poles at x = y i ± , i = 1, ..., 4, and taking those poles with the top sign, which lie inside the unit circle, one computes: 33) which one can check agrees with (6.31) in this case.

U Sp(2N c ) duality
Now let us consider the general duality of [41], which relates the following four-dimensional N = 1 gauge theories: 26 • A gauge group U Sp(2N c ), with the vector multiplet coupled to 2N f fundamental chiral multiplets Q i .
, with the vector multiplet coupled to 2N f fundamental chiral multiplets q i . In addition, the theory contains N f (2N f − 1) gauge-singlet chiral multiplets, denoted M ij , 1 ≤ i < j ≤ 2N f , which interact with the charged multiplets through the superpotential W = M ij q i q j .
Both of these theories have an SU (2N f ) flavor symmetry. Note that the number of flavors is even in order to cancel the U Sp(2N c ) global anomaly. The charges of the chiral multiplets are summarized in Table 1. The gauge-singlet "mesons" M ij of the second theory, in the antisymmetric representation of SU (2N f ), are identified with the gauge-invariant mesons Q i Q j in the first theory. The R-charges r i must satisfy: 34) 25 Specifically, in a unitary theory the superconformal R-charges of all chiral multiplets are positive, which lifts any zero modes on S 3 , leading to a finite number of states at each order in q. In our case with integer R-charges, such zero modes may arise, which leads to an infinite number of states, and so such rational functions can appear in the q-expansion. 26 Here, U Sp(2N c ) is the compact symplectic group of rank N c , which has dimension N c (2N c + 1). in order to cancel the U (1) R -(gauge) 2 anomaly. We may choose any r i ∈ Z satisfying (6.34). Let us also introduce ν i and n i the SU (2N f ) flavor chemical potential and fluxes, subject to the traceless condition:

't Hooft anomaly matching and relative signs
One of the earliest, non-trivial test of Seiberg duality was the matching of 't Hooft anomalies [33,41]. For G F = SU (2N f ), we have: in the U Sp(2N c ) theory. It is easy to check that these anomalies are reproduced by the dual U Sp(2N f − 2N c − 4) theory, given the relations (6.34) and (6.35). We can similarly check the matching of A R and A RRR across the duality. One can also check that the quadratic SU (2N f ) pseudo-anomaly vanishes (mod 4) in both theories. On the other hand, we have a non-trivial sign (−1) s(H) as defined by (6.7). One finds: with Π i the SU (2N f ) flux operators.

U Sp(2N c ) Bethe equations and duality map
To check the duality at the level of the A-model, we must first study the set of Bethe vacua in the two theories. Starting with the first theory, let u a , a = 1, · · · , N c , denote the parameters for the Cartan of the gauge symmetry. The twisted superpotential is given by: with W Φ (u) defined in (2.10). The corresponding Bethe equations are: exp 2πi ∂W ∂u a = Π 0 (u a ) = 1 , a = 1, · · · , N c , (6.39) where we defined: Note that Π 0 (u) is an elliptic function of u. (It is also elliptic in the parameters ν i modulo the traceless constraint.) Since Π 0 (u) − 1 has 2N f poles in u, in a given fundamental domain, it must also have 2N f distinct zeros, for generic values of the parameters. Let us denote these "Bethe roots" byũ k , k = 1, · · · , 2N f . A Bethe vacuum is determined by an assignment of the N c eigenvalues u a to these 2N f solutions. However, recall that we exclude solutions which are fixed by any Weyl symmetry generators, which act by either permuting the eigenvalues or exchanging u a with −u a . One can check that u = 0, 1 2 , τ 2 , τ +1 2 , are always solutions to Π 0 (u) = 1. Since these four solutions are fixed by the Weyl symmetry, they are not allowable Bethe roots.
The remaining 2N f − 4 Bethe roots come in pairs, ±û k . We then have: .

(6.41)
A Bethe vacuum is therefore a choice of N c of the N f − 2 Bethe rootsû l , up to the Weyl symmetry. Therefore, the number of vacua is given by: In the dual theory, the vacuum equations are given by in terms of the same elliptic function (6.40). Denoting by u D a ,ā = 1, · · · , N f − N c − 2, the eigenvalues for the dual gauge group, we simply find: The solutions are again given in terms of (6.41). By the same argument as above, one finds: This is equal to the number of Bethe vacua (6.42) in the first theory, which provides a simple new test of the duality. Indeed, the number (6.42) should be understood as a Witten index for the gauge theory with flavors. 27 To perform more refined tests, we must construct the duality map. Let P be the set of N f − 2 pairs of non-trivial solutions, {û l , −û l }. A Bethe vacuum of the first theory corresponds to a subset A ⊆ P of size N c , while a vacuum of the second theory corresponds to a subset A D ⊆ P of size N f − N c − 2. The natural guess for the duality map-which turns out to be correct-is: i.e., the subset A is mapped to its complement A c in P. Given the duality map, we can check the matching of the operators involved in constructing supersymmetric partition functions.

Matching the flux and handle-gluing operators
Let us start with the SU (2N f ) flux operators. The flux operators for the first theory are given by: 28 For the second theory, we have: where the second term is the contribution from the gauge singlets M ij . Duality predicts the relation: for any integers n i such that i n i = 0, and for any pair of dual Bethe vacua {û a } and {û D a }, respectively. It directly follows, using the duality map (6.45), that (6.48) can be massaged into: To prove this relation, consider the identity: 28 Note that this flux operators is related to the general definition (2.41) by a prefactor involving the 't Hooft anomalies (6.36). Since 't Hooft anomalies match independently across the duality, we ignore all such prefactors in the following to avoid clutter.
for a single variable u with the identifications u ∼ u + 1 ∼ u + τ . The relation holds on general grounds, for some u-independent function C(ν, τ ), because both sides are elliptic functions of u with the same poles and zeros. The zeros are at u = u k , with u k the Bethe roots defined above. Using some simple θ-function identities, the identity (6.50) is equivalent to: with C = q − 1 4 C, and theû l as in (6.41). Plugging u = ν i in (6.51), it is easy to prove (6.49). Note that the dependence on the unknown function C(ν, τ ) drops out in (6.49) because of the traceless condition i n i = 0.
By a similar computation involving the identity (6.51) and its first derivative, we can prove the matching of the handle-gluing operators. We find: for any pair of dual vacua, in agreement with expectations. We explain this computation more thoroughly in Appendix D.

Matching the fibering operators
The fibering operator of the first theory reads: 53) and that of the second theory is given by: The matching of the fibering operator, in any pair of dual vacua, is equivalent to the following simple-looking identities for the reduced elliptic gamma-function Γ 0 (u). Given the N f − 2 Bethe roots {û l } defined by (6.41), we must have: We leave a direct analytic proof of this identity for future work. As a consistency check, we can also verify directly that (6.56) implies (6.49), using the elliptic properties of Γ 0 (u); conversely, (6.49) implies that the ratio of the two sides of (6.56) is at most an elliptic function of the ν i . Some indirect evidence also follows from the identity of the dual S 3 supersymmetric indices [34] and from our general relation between the index and the Bethe-equation formula. However, the identity above implies the identity of partition functions on the infinite class of manifolds, M g,p × S 1 , and so is a more powerful statement. In principle, one can also check this, and other M g,p × S 1 partition function identities, perturbatively in q. Specifically, as we saw in the previous subsection, we first expand the Bethe equations (6.40) as a series in q: where we defined x a = e 2πiua , v i = e 2πiν i . The leading piece gives a polynomial equation for x a , which is precisely the Bethe equation for the dimensionally reduced 3d U Sp(2N c ) theory, as discussed in Section 3.5. This has N f − 2 non-trivial pairs of solutions,û l . Then we may correct these solutions order by order in q so that they solve (6.57) at each order, generating perturbative Bethe solutions: l + · · · (6.58) Finally, we expand (6.56) perturbatively in q and substitute these solutions to check that the identity holds. In practice this procedure can be quite cumbersome to perform analytically, as even the leading solutions,û l , are complicated algebraic functions of the flavor parameters. However one may also substitute some generic numerical values and check this identity numerically. We have performed such checks and found that the identity (6.56) holds for the first several orders in q.

SU (N c ) duality
As our second example, we consider the original Seiberg duality for N = 1 SQCD [33]. It relates the following two theories: • A gauge group SU (N c ), with the vector multiplet coupled to N f fundamental and N f anti-fundamental chiral multiplets, Q i andQ j .
• A gauge group SU (N f − N c ), with the vector multiplet coupled to with N f fundamental and N f anti-fundamental chiral multiplets, q i andq j . In addition, the theory contains N f 2 gauge-singlet chiral multiplets, M ij , coupled through the The flavor group is , with the charges shown in the Table 2. Let us denote the gauge symmetry parameters as u a , a = 1, .., N c and u D a ,ā = 1, · · · , N f − N c for the first and second theory, respectively, and the flavor symmetry parameters as ν i , ν j and µ B for SU (N f ) × SU (N f ) × U (1) B , such that: We similarly have i n i = j n j = 0 for the SU (N f ) × SU (N f ) background fluxes. Note that we normalized U (1) B in the standard way, to give charge ±1 to the "baryons" of either theory. The integer-valued R-charges for the chiral multiplets of the first theory are denoted by r i , r j . They must satisfy the anomaly-free condition for U (1) R : In the second theory, the gauge singlets M ij are identified with the mesons Q i Q j of the first theory, which fixes the R-charge of M ij . On the other hand, the R-charges of the dual quarks, (6.61) are fixed by the superpotential and by matching baryons across the duality [33]. We should restrict r i ∈ Z to be such that ∆ ∈ Z, so that all elementary fields have integer R-charges in the second theory. 29

't Hooft anomaly matching and relative signs
The cubic 't Hooft anomalies for the flavor group are encoded in: One can easily check that this is matched by the dual theory, and similarly for all 't Hooft anomalies involving U (1) R . For future reference, we also compute the handlegluing operator relative sign: Alternatively, for choices of r i ∈ Z such that ∆ / ∈ Z, it is still possible to assign the dual quarks integer charges if we mix the R-symmetry with the U (1) N f −Nc−1 maximal torus of the gauge symmetry. This follows because all gauge-invariant chiral operators have integer R-charge. For simplicity, we will restrict to the case of integer ∆ below. The relative signs for the flavor flux operators are trivial.

SU (N c ) Bethe equations and duality map
The twisted superpotential of the first theory is given by: Here, following [61], we have introduced a Lagrange multiplier, λ, which imposes the traceless condition Nc a=1 u a = 0 (6.65) Physically, λ can be thought of as a complexified Fayet-Iliopoulos parameter in the U (N c ) theory, which is taken to be dynamical. For simplicity of notation, it is useful to introduce the parameters: The Bethe equations of the first theory are: where we defined the following elliptic function of v: Note that (6.68) is not invariant under large gauge transformations of ν i or ν j , reflecting the non-zero U (1)-SU (N f ) 2 anomaly for U (1) ⊂ U (N c ). Similarly, the Bethe equation for the SU (N f − N c ) dual theory read: where λ D is again a Lagrange multiplier, which is a priori unrelated to λ. Interestingly, we see that we can write the dual Bethe equations in terms of the same elliptic function (6.68) as in the SU (N c ) theory. The counting of Bethe vacua in the SU (N c ) theory is more involved than in the U Sp(2N c ) case. The first equation in (6.67) has N f solutions in v a for every choice of λ, which we denote by v k , k = 1, · · · , N f . To construct a vacuum, we must assign the eigenvalues, v a , to a size-N c subset of these solutions, and subsequently vary the parameter λ until we are able to satisfy the second condition in (6.67). We must then further divide by the Weyl group S Nc .
It is difficult to count the number of such solutions directly, however, we can indirectly arrive at the answer as follows. We will use the fact that the number of vacua, denoted by N Nc,N f , satisfies the recursion relation: This can be derived by adding a complex mass for one flavor, as we will derive below in Section 6.5, but for now let us assume it is true. Then, we will also need: The first relation follows because for N c = 1 there is no gauge group, and a theory of chiral multiplets always has a single vacuum. The second relation follows because in this case the first condition in (6.67) has fewer solutions than the number of eigenvalues, v a , so it is impossible to take all the v a distinct. And the last relation follows because when N f = N c , we must take the v a to lie among all of the solutions,ṽ k , to the first condition in (6.67). However, using the ellipticity of (6.68), one finds that and thus it is impossible to satisfy the second condition for generic µ B , and thus there are no vacua. Let us also formally define: which one can check is consistent with (6.70). Then, repeatedly applying (6.70), one eventually obtains: However, from (6.71) and (6.73), one sees the only non-zero term occurs at k = N c − 1, with N 1,2 = 1. We thus find: Note that this formula agrees with the U Sp(2) result for N c = 2, as required by the isomorphism SU (2) ∼ = U Sp (2). The existence of a single Bethe vacuum for N f = N c +1 is also consistent with the dual description in terms of a mesons and baryons only. More generally, (6.75) is invariant under N c → N f − N c , as required by Seiberg duality. The duality map for the Bethe vacua can be constructed implicitly, as follows. A vacuum of the first theory corresponds to a choice of λ together with a subset A of size k=1 , for that particular choice of λ. We then claim that the duality map is: Indeed, with λ D = −λ, the first equation in (6.69) has the same solutions as that in (6.67), and we are simply taking the N f − N c eigenvalues of the dual theory to lie in the complement A c of A. To ensure that we indeed have an SU (N f −N c ) vacuum-and not only a would-be U (N f − N c ) vacuum-we must verify that, given the second condition in (6.67), the second condition in (6.69) holds as well. This directly follows from (6.72). Therefore, (6.76) provides a map from the Bethe vacua of the first theory to that of the second, and this map is clearly invertible, so is an isomorphism.

Matching the flux, handle-gluing, and fibering operators
Let us briefly discuss the duality relations for the flux and handle-gluing operators. The argument is analogous to the U Sp(2N c ) case, and we refer to Appendix D.2 for more details. The flux operators for the SU (N f ) × SU (N f ) flavor symmetry appear as: in the first theory, with n i , n j the SU (N f ) × SU (N f ) background fluxes, subject to i n i = 0 and j n j = 0. Similarly, for the second theory, we have: By an argument similar to that in the U Sp(2N c ) case, one can prove that for any pair of dual vacua, with A = {v a } and A c = {v D a }, and for andy λ = −λ D . In particular, this applies to the dual Bethe vacua in (6.76).
Let us next consider the baryonic symmetry. The U (1) B flux operators of the first theory reads: The U (1) B flux operator of the dual theory reads: (6.81) But using the Bethe equations, (6.67) and (6.69), we find 6.82) and so these agree in dual vacua, (6.76), as expected. We can similarly study the handle-gluing operator. We find: as discussed in Appendix D.2. Finally, just as in the U Sp(2N c ) case, the matching of the fibering operators follows, for all N c and Bethe vacua, from the following identity of elliptic gamma functions: whereṽ k runs over the N f solutions to: and λ is arbitrary. We conjecture this as a true identity relating elliptic gamma functions. Although we do not have an analytic proof, we have checked it numerically and perturbatively in q.

Degeneration limits
Seiberg dualities at different values of N f and N c can be related by various decoupling limits. For instance, one can decrease N f by decoupling flavors with superpotential mass terms. In the dual theory, this operation maps to a Higgsing mechanism, triggered by the deformation of the dual superpotential by a linear term in the mesonic singlets [33]. By decoupling enough flavors (but keeping N f > 0, so that we preserve the Rsymmetry), we reach a theory without any supersymmetric vacuum [77]-that is the case for N f < N c + 1 in the U Sp(2N f ) theory, and for N f < N c in the SU (N c ) theory [78,41]. In the limiting case-N f = N c + 1 for U Sp(2N c ) and N f = N c for SU (N c )-, quantum effects lift the origin of the classical moduli space without breaking supersymmetry [78]. In both cases, the Witten index (6.42) or (6.75) vanishes. We should insist, however, that this is the result one obtains for generic values of the flavor fugacities. Here, we note that the index can also (formally) diverge at special values of the flavor parameters-it is thus a sort of δ-function on parameter space. This certainly deserves further investigation. Closely related results have been obtained by studying the S 3 index [79]. 30 Mass deformations. Consider the SU (N c ) theory with N f flavors. In the electric theory, we can decouple a flavor, say Q N f andQ N f , by adding the mass term: This reduces the flavor group from 87) 30 We thank Z. Komargodski for comments about this case. 31 Here we have made a redefinition of µ B to impose the second relation.
instead of (6.59). On this special subspace for the 2N f parameters ν i ,ν i , the Bethe equations degenerate to the Bethe equations of the SU (N c ) theory with N f − 1 flavors. In the dual magnetic theory, we expect this operation to map to a Higgsing of SU (N f −N c ) to SU (N f −N c −1), however, since the Bethe equations of the two theories are the same, naively we obtain the SU (N f − N c ) theory instead. To understand what happens here, it is useful to introduce a small formal parameter, , and replace (6.87) by: Then the Bethe equations, (6.67), can be rewritten: This has two types of solutions: when v a is not close to −ν, we may ignore the first factor, and one finds the Bethe equations for the SU (N c ) theory with N f − 1 flavors, which has N f −1 solutions, as noted above. In addition, there is a solution at v a = −ν+δ for some small δ. Namely, near this point we may approximate (6.89) as: which has a single solution in δ of order for finite λ. Thus when we construct Bethe vacua, there are two classes of vacua: • If we take all the v a to lie among solutions of the first type, then the system of equations we are solving is identical to that of an SU (N c ) theory with N f − 1 flavors.
• Alternatively, we may take one of v a to lie at the special solution at −ν + δ. Then one can check that the remaining eigenvalues solve the same system of equations as an SU (N c − 1) theory with N f − 1 flavors, with a shifted value of µ B .
Since all vacua must lie in one of these two classes, we have shown as claimed in (6.70) above.
If we simply set = 0, as we did above, only the first class of vacua survive, however, for small but non-zero , we find a contribution from both classes. Specifically, one finds, for the electric theory: for vacua in second class (6.92) Thus, for g = 0, the second class of vacua are suppressed, and we indeed find a contribution only from the first class of vacua. On the other hand, for g = 1 we find a contribution from both classes, and for higher g the index diverges as we take → 0.
Note that under the duality map, (6.76), vacua in the first class map to those in the second. Thus, in the g = 0 case, the vacua that survive in the dual theory must come from the second class, and so we indeed obtain the Higgsed SU (N f − N c − 1) theory, as was noted in the case of the S 3 × S 1 index, e.g., in [80]. For higher genus the → 0 limit is more subtle, and one does not see a clean splitting of the Higgsed and un-Higgsed vacua.
The index for SQCD with a deformed moduli space. Consider now U Sp(2N c ) with N f = N c + 1 fundamental chiral multiplets. The low-energy theory is described in terms of the gauge-invariant mesons M ij = Q i Q j subject to the quantum-deformed constraint Pf(M ) = Λ 2Nc+2 [78,41]. We see from (6.42) that Z T 4 = 0 for generic values of the 2N c + 2 flavor parameters ν i . Let us now consider any arbitrary splitting of the ν i 's into two sets of N c + 1 parameters: One can easily check that, on the special locus: µ n + µ n = 0 , ∀n , (6.94) we trivially solve the Bethe equations (6.39) for any u, because: identically. Therefore, in this case, the 4d A-model has a continuum of vacua-a quantum Coulomb branch-on any of the codimension-N c loci defined by (6.94). In such a case, the Witten index would formally diverge, instead of being zero. When studying the S 3 index, the degeneration locus (6.94) has been interpreted in terms of chiral symmetry breaking from SU (2N c + 2), at the origin of the classical moduli space, to U Sp(2N c ) at the points of maximal symmetry on the quantum moduli space [79]. As evidenced by these few examples, degeneration limits on the Bethe equations-and on supersymmetric indices-are rather subtle. This raises interesting questions for future work.
If we further assume that K commutes with its complex conjugate, [K,K] = 0, the manifold must be a torus fibration over a two-dimensional base [6]. We will further restrict ourselves to the case of a principal elliptic fibration over a Riemann surface Σ g , with the T 2 fiber generated by K µ . This is the M g,p × S 1 manifold discussed in the main text.
A.1 Cohomology of M g,p × S 1 and line bundles The cohomology of M 4 ∼ = M g,p × S 1 is easily computed from the Gysin sequence for M g,p and from the Künneth formula. We have: The most important part, for our purposes, is: A few other interesting facts about the topology of M 4 can be found in [26].
All the supersymmetry-preserving line bundles L appearing in this paper are pullbacks of line bundles over Σ g , and are therefore torsion, with their first Chern class valued in (A.5). As a complex line bundle, any such line bundle L comes in families indexed by complex moduli valued in the first Dolbeault cohomology H 0,1 (M 4 , C). By supersymmetry, the single modulus that enter the A-model is the one denoted by ν F in the main text. It corresponds to a flat-connection along the T 2 fiber, for the component Aw of the corresponding gauge connection.

A.2 The supergravity background
Let us discuss the M g,p ×S 1 supergravity background in detail. The following discussion mostly follows from the results of [6].

A.2.1 Real and complex coordinates
Consider M 4 ∼ = M g,p × S 1 with coordinates (ψ, t, z,z) on T 2 × Σ g . Here, ψ ∼ ψ + 2π and t ∼ t + 2π are the angular coordinates on the torus fiber, with T 2 ∼ = S 1 β × S 1 β . We use the notation: for the coordinates and radii of the two circles. In the language of section 3, we constructed M g,p in the modular frame (3.6), using the first fibering operator, F 1 . The ψ coordinate is the coordinate along the circle fiber in M g,p , and the "Euclidean time" coordinate t is the coordinate along the S 1 in M g,p × S 1 . The complex coordinates z,z are local coordinates on Σ g . Let us define: the modular parameter on T 2 . We choose the simple metric: Here, g zz is the Hermitian metric on Σ g , which we normalize to: The one-form C is the connection of a principal circle bundle over Σ, with first Chern class p: It satisfies: Let us choose the complex coordinates (w, z) on M 4 , with: and z the local coordinate on Σ g . Here, the complex function f (z,z) is related to the one-form C by: It follows from (A.11) that Im(f )/p is the Kähler potential on Σ g , for p = 0, with pg zz = ∂ z ∂zIm(f ). The real part of f , Re(f ), is a gauge choice, which should be fixed so that C is well-defined on each patch. 33

A.2.3 Spinors and spinor bilinears
In the canonical complex frame e 1 = β dw + h(z,z)dz , e 2 = 2g zz dz , (A. 23) the Killing spinors are given explicitly by: From these Killing spinors, we can reconstruct the two commuting complex structures: 25) and the Killing vector (A.3). The complex structure J µ ν is the one associated to the coordinates (w, z), while J µ ν corresponds to a choice of holomorphic coordinates (w,z) instead. Another useful bilinear is the anti-holomorphic two-form: By construction, Pwz is a globally-defined, nowhere-vanishing section ofK ⊗ (L (R) ) 2 , which leads to the identification (A.22) [6].
A.3 "A-twist" and "physical" gauge The U (1) R line bundle L (R) has a complex modulus determined by the gauge function s in (A.18), namely: More precisely, this is a flat connection for the component A cw of (A.18). For the Killing spinors (A.24) to be well-defined, we must have: It follows that: The fact that ν R = 0 mod 1, τ is a consequence of supersymmetry. Any other value of ν R would break supersymmetry explicitly, since fermions and bosons would acquire different phases when parallel-transported along T 2 . In most of this work, we choose s = 0, so that ν R = 0. This is what we called the "A-twist gauge" in section 4. In that case, the constant Killing spinors (A.24) are exactly the A-twist Killing spinors on Σ g pulled-back to M 4 . on S 3 × S 1 . For β = 1 and τ 1 = 0, this is the round metric on S 3 in Hopf coordinates.
(The more usual Hopf fiber coordinate, of period 4π, isψ ≡ 2ψ.) The other background fields are: B.1 Eta, theta and elliptic gamma functions η-function: Let us first recall the definition of the Dedekind eta function η(τ ), and the associated Pochhammer symbol (q, q) ∞ , also known as the Euler function φ: The eta function transforms naturally under the modular group: θ-functions: Let us define two closely related theta functions. The "reduced theta function": and the theta function: The theta function (B.6) has more natural elliptic and modular properties than the reduced theta function (B.5), but both appear naturally throughout this work. Importantly, θ(u; τ ) is an odd function of u: Under shifts of u along the torus, u ∼ u + 1 ∼ u + τ , we have: Elliptic Γ-function: The elliptic gamma function Γ e (u; τ, σ) can be defined as the following converging product: with the two periods τ, σ, and q = e 2πiτ , p = e 2πiσ -see [63] and references therein. In this work, we will only discuss the following specialization of (B.10), which we denote by Γ 0 (u; τ ): Γ 0 (u; τ ) ≡ Γ e (u + τ ; τ, τ ) = In section 2, we defined the two functions: with the function f φ (u) defined in (2.53). All these functions are meromorphic on the u plane. Note the reflection formulas: The modular properties of (B.22)-(B.23) are also discussed in the main text. We have: for S and T . All these relations can be proven most easily from the definition of F Φ 1 , F Φ 2 in term of a twisted superpotential, but one can also check them directly from the explicit definition (B.22)-(B.23).

C. Regularized superpotential and one-loop determinants
In this Appendix, we sketch the derivation of various key expressions through ζ-function regularization.

C.1 Twisted superpotential
Consider the twisted superpotential of a single chiral multiplet. The formal expression (2.9) can be massaged to (2.10) by splitting the sum over n ∈ Z in the middle. The second term in (2.10) converges. The cubic polynomial, on the other hand, originates from the formal sum: (C.1) Here we used a dilogarithm identity, and ∈ 2Z + 1 corresponds to a choice of branch. We will set = 0 instead. We further manipulate the second line in (C.1) to: 2) The first term gives 1 24 using ζ(0) = − 1 2 , and the second term is regularized using the Hurwitz zeta function. 35 This directly leads to (2.10).
Let us further comment on the ad-hoc choice = 0 in (C.1). At any fixed n, (C.1) is part of a three-dimensional superpotential, corresponding to three-dimensional Chern-Simons term. As explained in [27], the term linear in u leads to subtle signs in the partition function (through signs in the flux operators), which are necessary to preserve supersymmetry and gauge invariance. Once we sum over n to obtain a fourdimensional theory, it is reasonable to posit that such signs only lead to other signs in four dimensions. This is possible only if we set = 0 by hand.

C.2 One-loop determinants
In this section, we very briefly discuss the derivation of the A-model operators from the path integral on M g,p × S 1 . The one-loop determinants around a general (geometric and gauge) supersymmetric background are the building blocks for the localization computation of section 5. 35 Recall that ζ H (−n, a) = − 1 n+1 B n+1 (a) for n ∈ Z >0 , with B n the n-th Bernoulli polynomial.

C.2.1 Chiral multiplet
Consider a chiral multiplet on M g,p × S 1 , of R-charge r ∈ Z and with charge 1 under a background U (1) gauge field chemical potential and background flux (u, m). By a standard argument-see e.g. [81,82,24], most of the field modes on M 4 are paired by supersymmetry and cancel out between bosons and fermions. In the present case, the modes that contribute non-trivially to the one-loop determinant are in one-to-one correspondence with holomorphic sections on Σ g [83,26,84,27]. Schematically, we have: . (C.5) This infinite product simply corresponds to the product over the full KK tower of Atwisted chiral multiplets on Σ g , which have twisted masses u + mτ + n. More generally, the A-model partition function for Φ reads: Z Φ = n,m∈Z 1 u + mτ + n p 1 m+p 2 n+m+(g−1)(r−1) .
(C. 6) In the A-model language, we have: This gives the following formal expression for the flux operators: Π Φ = n,m∈Z 1 u + mτ + n , (C. 8) and for the fibering operators: (C.9) Formally, all these expressions are gauge-and modular-invariant (more precisely, F 1 and F 2 mix under modular transformation), but the chiral anomaly forbids a regularization that fully preserve these symmetries. By ζ-function regularization, we can derive the expression Π Φ = e − πi τ u 2 θ(u; τ ) −1 from (C.8), and similarly for the fibering operators. This is consistent with the derivation of these operators from the twisted superpotential.

C.2.3 One-loop determinants in the physical gauge
The one-loop determinant (C.5) was computed in the A-twist gauge (4.5). Consider instead an arbitrary gauge for U (1) R , with parameters (ν R , n R ). The chiral determinant one-loop determinant is similarly given by the formal product: . (C.12) Note that, in general, this expression only makes sense for R-charges that respect the Dirac quantization r n R ∈ Z on Σ g . For M 4 such that g − 1 = 0 mod p, we can consider the physical gauge (4.6). This gives: with the "physical" fibering and flux operators: . (C.14) We can similarly consider the one-loop determinant of the vector multiplet in the physical gauge. The contribution from the W-bosons is again the same as from chiral multiplets of R-charge 2 and gauge charges α a . Finally, for every U (1) along the Cartan, we have: similarly to (C.10). To compute this, we consider the limit: 16) of the regularized fibering operator F Φ 1 . Since ν R = l R τ , with l R = 1−g p ∈ Z, this limit diverges (or vanishes), but we can remove the corresponding bosonic (or fermionic) zero-modes by hand. This gives: where the overall factor has been chosen for convenience. Using the limit (B.17), we directly obtain (4.19), namely: This is equivalent to the A-twist gauge result (C.11), except for a sign. This sign contributes to the relative sign in (4.22), and it is therefore interpreted as the result of a U (1) R 't Hooft anomaly contribution when changing gauge.

D. Further details on the duality checks
In this appendix we present some further details of the proofs of matching of M g,p × S 1 partition functions for the dual theories considered in section 6.

D.1 Sp(2N c ) duality
The matching of the flux operators across the U Sp(2N c ) duality was shown in the main text, and follows from the identity (6.51), namely: θ(u +û l )θ(−u +û l ) , (D.1) To derive the matching of handle-gluing operators, we will need another relation which can be obtained by differentiating (D.1) with respect to u: where we defined: The handle-gluing operator of the electric theory is given by:

(D.5)
Similarly, in the magnetic theory we have: The last factor in (D.6) corresponds to the gauge-singlets M ij . The R-charges are mapped under the duality as in Table 1 Here, it is important to impose the anomaly cancellation condition (6.34); in particular, the dependence on the unknown function C(ν, τ ) cancels out because of it. This completes the proof the matching the handle-gluing operators. One can also easily check (D.8) numerically for low values of N f and N c .

D.2 SU (N c ) duality
The arguments here are completely analogous to the U Sp(2N c ) case, so we will be brief. First we have the following analogue of (D.1) for the SU (N c ) case: for some C independent of v, and where v k run over the solutions to the Bethe equation, (6.85). Substituting v = −ν j and v =ν i , we straightforwardly derive (6.79). Note this argument holds for arbitrary λ, and does not rely on imposing the trace condition for SU (N c ). Next, consider the handle-gluing operators. As above, this will require differentiating (D.9), which gives the identity: for every Bethe root v k . Here we defined: The handle-gluing operators for the two theories are given by: and: where r j ,r j are the R-charges of the chirals, which we have mapped under the duality as in Table 2, and ∆ = Evaluating these at dual Bethe vacua, and using (D.9), (D.10), and the Bethe equations, we find: We then use the fact that the non-anomalous R-charges must satisfy: 16) to find: as claimed in the main text.