Comments on twisted indices in 3d supersymmetric gauge theories

We study three-dimensional ${\mathcal N}=2$ supersymmetric gauge theories on ${\Sigma_g \times S^1}$ with a topological twist along $\Sigma_g$, a genus-$g$ Riemann surface. The twisted supersymmetric index at genus $g$ and the correlation functions of half-BPS loop operators on $S^1$ can be computed exactly by supersymmetric localization. For $g=1$, this gives a simple UV computation of the 3d Witten index. Twisted indices provide us with a clean derivation of the quantum algebra of supersymmetric Wilson loops, for any Yang-Mills-Chern-Simons-matter theory, in terms of the associated Bethe equations for the theory on ${\mathbb R}^2 \times S^1$. This also provides a powerful and simple tool to study 3d ${\mathcal N}=2$ Seiberg dualities. Finally, we study A- and B-twisted indices for ${\mathcal N}=4$ supersymmetric gauge theories, which turns out to be very useful for quantitative studies of three-dimensional mirror symmetry. We also briefly comment on a relation between the $S^2 \times S^1$ twisted indices and the Hilbert series of ${\mathcal N}=4$ moduli spaces.


Introduction
Supersymmetric indices [1] are simple yet powerful tools for studying supersymmetric field theories [2,3,4,5,6,7]. In this paper, we consider the twisted index of threedimensional N = 2 supersymmetric theories with an R-symmetry on a closed orientable Riemann surface Σ g of genus g: The theory is topologically twisted along Σ g by the U (1) R symmetry in order to preserve two supercharges, and one can introduce complexified fugacities y i and quantized background fluxes n i for any continuous global symmetries with conserved charges Q i commuting with supersymmetry. This index was recently computed by supersymmetric localization for any N = 2 (ultraviolet-free) gauge theory in the g = 0 case [8]. In this paper, we discuss the generalization to higher-genus Riemann surfaces. We also use the index, and similar localization results for line operators, to study infrared dualities for theories with N = 2 and N = 4 supersymmetry.
Twisted index, localization and Bethe equations. The quantity (1.1) was first computed in [9] in the context of the Bethe/gauge correspondence [10,11], using slightly different topological field theory methods. In this work, we recompute the twisted index for generic N = 2 supersymmetric Yang-Mills-Chern-Simons (YM-CS) gauge theories with matter, using supersymmetric localization on the classical Coulomb branch [8,12]. The index is equal to the supersymmetric partition function of the N = 2 theory on Σ g × S 1 , which can be computed as: schematically. Here the sum is over GNO-quantized fluxes m for the gauge group G, and the integral is a Jeffrey-Kirwan residue at the singularities of the classical Coulomb branch M ∼ = (C * ) rk(G) /Weyl(G), including singularities 'at infinity' associated to semiclassical monopole operators. The integrand Z m (x, y) contains classical and one-loop contributions. The derivation of (1.2) closely follows previous localization computations in related contexts [13,14,15,6,7,8,12,16]. By summing over the fluxes m in (1.2), one recovers the result of [9]: where H is the so-called handle-gluing operator. 1 The sum in (1.3) is over solutions to the Bethe equations of the N = 2 theory on R 2 × S 1 , which are essentially the saddle equations for the two-dimensional twisted superpotential W(x; y) of the theory compactified on a finite-size circle. It is clear from (1.3) that much of the physics of the twisted indices is encoded in the twisted superpotential. 2 N = 2 theories on Σ g have also been studied recently in [20,21].
The 3d Witten index. In the special case g = 1 and n i = 0, the index (1.1) specializes to the Witten index on the torus: Note that no twisting is necessary in this case. While the standard Witten index is generally not defined for the theories of interest, which have interesting vacuum moduli spaces in flat space, it turns out to be well-defined in the presence of general real masses m i [22], which enter the index through the complexified fugacities y i with |y i | = e −2πβ m i . For any generic-enough choice of m i so that all the vacua are isolated, the index counts the total number of massive and topological vacua, which does not change as we cross codimension-one walls in parameter space. We will compute the Witten index of a large class of abelian and non-abelian theories, generalizing previous results [2,23,22]. Note that the localization computation is an ultraviolet computation, complementary to the infrared analysis of [22]. Whenever it is well-defined, the Witten index of an N = 2 YM-CS-matter theory is the number of gauge-invariant solutions to the Bethe equations [10,9], as we can see from (1.3). The Witten index can also be computed from (1.2) truncated to m = 0, because the terms with m = 0 do not contribute to (1.4).
Dualities and Wilson loop algebras. The twisted index on Σ g × S 1 is a powerful tool to study infrared dualities, since the twisted indices of dual theories must agree. 3 One of the most interesting such dualities is the Aharony duality between a U (N c ) Yang-Mills theory with N f flavor and a dual U (N f − N c ) gauge theory [24]. More generally, we will consider a general three-dimensional U (N c ) k YM-CS-matter theories with N f fundamental and N a antifundamental chiral multiplets, which we can call SQCD[k, N c , N f , N a ]. This three-dimensional N = 2 SQCD enjoys an intricate pattern of Seiberg dualities [25] depending on k and k c = 1 2 (N f − N a ) [26,27,28], which can be precisely recovered by manipulating the twisted index. This provides a new powerful check of all of these dualities.
We will also study half-BPS Wilson loop operators wrapped on the S 1 for any N = 2 YM-CS-matter theory. The quantum algebra of Wilson loops is encoded in the twisted superpotential W and corresponds to the S 1 uplift of the two-dimensional twisted chiral ring [29,30]. In particular, we will give an explicit description of the quantum algebra of supersymmetric Wilson loops in SQCD[k, N c , N f , N a ], generalizing the results of [30]. N = 4 mirror symmetry Another useful application for the twisted index is to three-dimensional N = 4 gauge theories and mirror symmetry. We consider the twisted index with a topological twist by either factor of the SU (2) H ×SU (2) C R-symmetry [31]. More precisely, we shall consider the N = 2 subalgebra with either U (1) R = 2U (1) H or U (1) R = 2U (1) C . The corresponding N = 2 twists along Σ g are called the Aor B-twist, respectively. Let H and C denote the generators of U (1) H ⊂ SU (2) H and U (1) C ⊂ SU (2) C , respectively. We define the A-and B-twist (integer-valued) R-charges: Either twist on Σ g preserves two supercharges commuting with H−C. We can introduce a fugacity t for U (1) t ≡ 2 [U (1) H − U (1) C ], and consider the twisted index: (1. 6) for either choice (1.5) of U (1) R . Here all the background fluxes n i , n t are left implicit. The fugacity t = 1 breaks N = 4 supersymmetry to N = 2 * , and is necessary in order to apply the localization formula. Three-dimensional N = 4 mirror symmetry [32] is an infrared duality of 3d N = 4 theories, composed with an exchange of SU (2) H and SU (2) C . The latter operation maps any supermultiplet of N = 4 supersymmetry to the corresponding 'twisted' supermultiplet. Consequently, the A-twisted index of a theory T must equal the Btwisted index of its mirrorŤ according to: g, A (y, t) = I [Ť ] g, B (y, t −1 ) (1.7) where y andy are the flavor fugacities and their mirror-for instance, real masses are exchanged with Fayet-Iliopoulos (FI) parameters. Similarly, we can study the mapping of half-BPS line operators wrapped on the S 1 under mirror symmetry. We will verify in a simple but non-trivial example that half-BPS Wilson loops in the B-twisted theory are mirror to half-BPS vortex loops in the A-twisted theory, as recently studied in [33]. Finally, we will argue that the genus-zero A-and B-twisted indices-the A-and Btwisted S 2 × S 1 partition functions [8]-with vanishing background fluxes are equal to the Coulomb and Higgs branch Hilbert series, respectively 4 [35,36,37,38,39,40]. It is relatively easy to show, for a large class of theories, that the B-twisted S 2 ×S 1 partition function only receives contribution from the m = 0 flux sector in (1.2) and is indeed equal to the Higgs branch Hilbert series. Similarly, we conjecture that the A-twisted S 2 ×S 1 partition function, which generally receives contribution from an infinite number of flux sectors, is equal to the Coulomb branch Hilbert series [38]. (Naturally, this would follow from mirror symmetry (1.7) when a mirror theory exists.) We will show in some examples that the A-twisted index reproduces the Coulomb branch monopole formula of [38]. It would be very interesting to study this correspondence further.
Note added: During the final stage of writing, we became aware of another closely related work by F. Benini and A. Zaffaroni [41]. We are grateful to them for giving us a few more days to finish writing our paper, and for coordinating the arXiv submission. This paper is organized as follows. In section 2, we study 3d N = 2 theories on Σ g × S 1 preserving two supercharges and we present the N = 2 localization formula (1.2) and explain some of its key properties. We also discuss the quantum algebra of Wilson loops. Much of the details of the derivation of (1.2) are relegated to Appendix B. In sections 3 and 4 we consider the twisted index of some of the simplest U (1) and U (N ) theories, respectively. We also briefly discuss how (1.3) reproduces the SU (N ) Verlinde formula. In section 5 we discuss 3d N = 2 SQCD in great details, including an explicit description of its Wilson loop algebra. In section 6, we study N = 4 theories and the index (1.6). We also consider mirror symmetry for line operators, and the relation between the genus-zero twisted index and Hilbert series. Various appendices summarize our conventions and contain useful complementary material.
2. Three-dimensional N = 2 gauge theories on Σ g × S 1 In this section, we summarize some useful results about supersymmetric field theories on Σ g ×S 1 , and we present the explicit formula for the twisted index and for correlation functions of supersymmetric Wilson loops wrapped on S 1 in the case of N = 2 Yang-Mills-Chern-Simons-matter theories.
(2.1) with t ∼ t + 2π the circle coordinate, and z,z the local complex coordinates on Σ g with Hermitian metric g zz . We also choose a canonical frame (e 0 , e 1 , e1). (See Appendix A for our conventions.) One can preserve two supercharges on M 3 = Σ g × S 1 , corresponding to the uplift of the topological A-twist on Σ g . In the formalism of [42], this corresponds to choosing a transversely holomomorphic foliation (THF) of M 3 along the circle: The full supergravity background is given by: 3) The last equation in (2.3) determines the R-symmetry gauge field A (R) µ up to flat connections, which must vanish to preserve supersymmetry. In other words, A (R) µ is taken to vanish along S 1 and is equal to 1 2 ω (2d) µ along Σ g , with ω (2d) µ the two-dimensional spin connection. Due to the A (R) µ flux: the R-charges are quantized in units of 1 g−1 . This background preserves two covariantlyconstant Killing spinors ζ and ζ of R-charge ±1, respectively: In the canonical frame, the Killing spinors are given by: The real Killing vector K = ζγ µ ζ∂ µ constructed out of (2.6) is equal to (2.2).

Supersymmetry algebra and supersymmetry transformations
Let us denote by δ and δ the action of the two supercharges on fields. We have the supersymmetry algebra: with Z the real central charge of the N = 2 superalgebra in flat space, and L K the Lie derivative along K. For a vector multiplet V in Wess-Zumino (WZ) gauge, the real scalar component σ also enters (2.7) as Z = Z 0 − σ, where Z 0 is the actual central charge and σ is valued in the appropriate gauge representation. All supersymmetry transformations and supersymmetric Lagrangians are easily obtained by specializing the results of [42]. We will use a convenient "A-twisted" notations for all the fields [12]. Let G and g = Lie(G) denote a compact Lie group and its Lie algebra, respectively. In WZ gauge, a g-valued vector multiplet V has components: V = a µ , σ , Λ µ , Λ µ , D . (2.8) The A-twisted fermions Λ µ are holomorphic and anti-holomorphic one-forms with respect to the THF (2.2), 5 which means that: Λ µ dx µ = Λ t dt + Λ z dz = Λ 0 e 0 + Λ 1 e 1 , Λ µ dx µ = Λ t dt + Λzdz = Λ 0 e 0 + Λ1e1 . (2.9) We mostly use the frame e 0 , e 1 , e1 in the following. Let us define the field strength (2.10) We denote by D µ the covariant and gauge-covariant derivative. The supersymmetry transformations of (2.8) are (2.11) The explicit form of the super-Yang-Mills Lagrangian L Y M can be inferred from [42] and will not be needed in the following. The important fact for our purposes is that the YM action is Q-exact, like all D-terms. The Chern-Simons (CS) term is given by: for any gauge group G. 6 In the presence of an abelian sector, we can also have mixed CS terms between U (1) I and U (1) J , with I = J: 1 . Matter fields enter as chiral multiplets coupled to the vector multiplet V. Consider a chiral multiplet Φ of R-charge r, transforming in a representation R of g. In A-twisted notation [12], we denote the components of Φ by The supersymmetry transformations are: where D µ is appropriately gauge-covariant and σ and Λz act in the representation R.
Similarly, the charge-conjugate antichiral multiplet Φ of R-charge −r in the represen-tationR has components Using the vector multiplet transformation rules (2.11), one can check that (2.16)-(2.18) realize the supersymmetry algebra K is the gauge-covariant Lie derivative, and σ acts in the appropriate representation of the gauge group. The standard kinetic term for the chiral multiplet reads: (2.20) The trace over gauge indices is implicit. This Lagrangian is δ-exact:

YM-CS-matter theories, twisted superpotential and localization
Consider a generic N = 2 YM-CS theory coupled to matter fields in chiral multiplets. The theory contains a vector multiplet V for the gauge group G with Lie algebra g, and some matter multiplets in chiral multiplets Φ i transforming in representations R i of g and with R-charges r i . We can also have a superpotential W (Φ) of R-charge 2.
The UV description of the theory includes Yang-Mills terms with dimensionful gauge couplings, as well as arbitrary Chern-Simons terms. For definiteness, consider a gauge group possibly up to discrete identifications, where G γ are simple Lie groups. For each G γ , we have a Chern-Simons level k γ , while we can have arbitrary mixed CS levels k IJ = k JI in the abelian sector. In addition to these CS interactions for the gauge fields, we must also specify "global" CS levels for all the global symmetries of the theory, including the R-symmetry [44]. This might include mixed CS terms between the abelian gauge and global symmetries. All the CS levels are either integer or half-integer, depending on parity anomalies. For future reference, let us introduce the Cartan subgroup rk(G) a=1 U (1), and the corresponding symmetric matrix of CS levels k ab , which is given by on each semi-simple factor, with h ab | γ the Killing form of g γ , and by k ab = k IJ (a = I, b = J) in the abelian sector. (Moreover, k ab = 0 for a ∈ γ and b = I.) It is natural to couple the theory to an arbitrary supersymmetric background vector multiplet for any global symmetry U (1) F . This includes a background flux n F over Σ g as well as the real mass σ F = m F paired together with a background U (1) F flat connections along S 1 into a complex parameter ν F . In particular, for any U (1) I gauge group there exists a topological symmetry U (1) T I . The corresponding background real mass corresponds to a Fayet-Iliopoulos (FI) parameter for the abelian gauge group U (1) I , provided we turn on a unit mixed CS level between U (1) I and U (1) T I : using a convenient normalization for the FI parameters:

Classical Coulomb branch
The 'classical Coulomb branch' of any YM-CS-matter theory on R 3 is spanned by the constant expectation values of the real field σ, such that: and of the dual photons ϕ a of the effective a U (1) a abelian theory, modulo the Weyl group W G . The fields σ a and ϕ a are paired into chiral 'bare' monopole operators, which take the form: 27) semi-classically, with e 2 the Yang-Mills coupling and T + a T − a = 1, ∀a. Here φ a is the lowest-component of a chiral multiplet Φ a related to the field-strength linear multiplet by Σ a = − e 2 4π (Φ a + Φ a ). In particular, the dual photon is defined by: Since the dual photons are periodic, the classical Coulomb branch has the topology of (C * ) rk(G) /W G , a cylinder quotiented by the Weyl group. Consider instead the same theory compactified on a circle S 1 of radius β. In this case, one can turn on flat connections a 0 for the gauge field along S 1 , and the Coulomb branch coordinates (2.26) have a natural complexification: (2.29) Due to the periodicity a 0,a ∼ a 0,a +β −1 under large U (1) a gauge transformations around S 1 , it is natural to define the complexified fugacities: x a = e 2πiua . (2.30) Similarly, for any global symmetry U (1) F we can turn on some background flat connections and background real field σ F , and we denote the corresponding fugacity by y F = e 2πiν F . Under the supersymmetry (2.11), we have: Note that u transforms as the lowest component of a twisted chiral multiplet of twodimensional N = (2, 2) supersymmetry on Σ g with the A-twist. Let us denote by the covering space of the complexified classical Coulomb branch M ∼ = M/W G , spanned by the u a 's. This classical moduli space has the same topology as the one spanned by the chiral monopole operators (2.27). This is no coincidence, as the two descriptions are essentially related by a T-duality transformation [45,22], mapping chiral multiplets (of lowest component φ a ) to twisted chiral multiplets (of lowest component u a ) in the two-dimensional description. The 'holomorphic' properties of the low-energy theory on M are determined by the effective twisted superpotential, which can be obtained by integrating out all the massive fields at generic values of u a , including all the Kaluza-Klein (KK) modes on S 1 [10,46]. One finds: (2.33) Here the last sum is over the positive roots of g, and we introduced fugacities for the flavor symmetries, with ν i = ν F [Φ i ] and y i = e 2πiν i . The mixed gauge-flavor CS levels are denoted schematically by k aF g-f , which includes the FI terms according to (2.24). We also introduced the convenient notation x ρ i = a x ρ a i a = e 2πiρ i (u) . The physically meaningful quantities are the first derivatives: Note that this is invariant under large gauge transformations u a ∼ u a + 1 (and ν F ∼ ν F + 1 for background gauge fields) if and only if the CS levels are properly quantized (that is, integer or half-integer depending on the parity anomalies). We shall also need the Hessian matrix of W: Much of physics of the supersymmetric indices, and of correlation functions of supersymmetric Wilson loops, is encoded in this twisted superpotential.

Localization, fugacities and classical actions
The path integral of any N = 2 YM-CS-matter theory on Σ g × S 1 can be localized onto the simplest supersymmetric configurations for the vector multiplet. Since the YMs action is Q-exact, we can take the e → 0 limit so that the vector multiplet localizes to [47,14,8]: We can diagonalize the background field σ as in (2.26), which Higgses the gauge group to the Cartan subgroup H ∼ = a U (1) a at generic values of σ a . As discussed in [48,49], there is an obstruction to diagonalizing the vector multiplet globally on Σ g × S 1 due to the presence of non-trivial principal H-bundles (even for a trivial G bundle, for instance if G is simple), and we must therefore sum over all such non-trivial H-bundles. For G Abelian, we just have a standard sum over topological sectors. As a result, the localization locus is divided into topological sectors indexed by GNO-quantized fluxes over Σ g : The fluxes take value in the magnetic lattice Γ G ∨ ∼ = Z rk(G) , which can be obtained from Γ G , the weight lattice of electric charges of G within ih * by [50,51] We denote by (m a ) the projection of m onto the magnetic flux lattice Z rk(G) of the Cartan subgroup a U (1) a . Note that (2.37) implies that the dual photon appearing in (2.28) is constant. In other words, we are localizing onto the classical Coulomb branch using the 'T-dual' variables (2.29), in every topological sector. The U (1) a flat connections along S 1 , 40) are included into the complex variables (2.29). One must also sum over arbitrary flat connections on Σ g , but we will see that they have little impact on the final answer.
(Similarly, the final answer cannot depend on flat connections along Σ g for background vector multiplets [43], therefore we set these to zero from the start.) For future reference, it is interesting to evaluate the classical action onto the supersymmetric locus (2.37). We will also turn on general background fluxes, real masses and Wilson lines for flavor symmetries. For any U (1) F global symmetry (which might be part of the Cartan of a non-abelian group) with background vector multiplet V F , we have: The only terms in the action that contributes on the supersymmetric locus are the Chern-Simons levels for gauge and global symmetries (including the FI terms), which are not Q-exact. In a given topological sector, (2.42) The gauge CS terms reads: Similarly, for the mixed flavor-gauged and flavor CS terms: where the indices m, n run over the flavor group, including the topological symmetries. For each topological symmetry U (1) T I , we introduce the fluxes n T I and the fugacities: where θ I , the U (1) T I Wilson line, is also a two-dimensional θ-angle. The last two terms in (2.42) are mixed CS terms between abelian vector multiplets and the R-symmetry gauge field in the new-minimal supergravity multiplet [44,42], which is given by on the background (2.3). This gives: with g the genus of Σ g , where I runs over the abelian part of G (2.22) and M runs over the abelian part of the flavor group. Finally, we note that the purely gravitational CS terms of [44] evaluate to zero on our Σ g × S 1 background. This implies that the overall phase of the twisted index is unambiguous (except possibly for a sign ambiguity to be discussed below), unlike for instance the phase of the S 3 partition function [52].

Induced charges of the monopole operators
Consider the 'bare' monopole operators T ± a in the abelianized a U (1) a theory. Each operator T ± a carries charges under any abelian (gauge or global) symmetry which can mix with the gauge symmetry U (1) a , either classically through Chern-Simons interactions, or at one-loop in the presence of matter fields [53,54,55,56]. These charges are: under the gauge and flavor symmetries, where Q F i is the charge of the chiral multiplet Φ i under a flavor symmetry U (1) F . The monopole operators also acquire an induced R-charge (see e.g. [57,58,59,60]) given by: with r i the R-charge of Φ i . The last term in (2.49) is the contribution from the gaugini (which carry R-charge 1). For a generic value of σ a on the Coulomb branch, we can also compute the effective CS levels by integrating out the massive fields: We directly see that and similarly for the induced R-charge (2.49). Equivalently, the charges (2.52) can be extracted from the twisted superpotential: It is therefore natural to associate the asymptotics of the Coulomb branch with the monopole operators T ± a [53,22].

The algebra of Wilson loops
In any YM-CS-matter theory with N = 2 supersymmetry on R 2 × S 1 , one can define half-BPS Wilson loop operators wrapped over the circle. For a Wilson loop in the representation R of G, we have 7 which preserves half of the supersymmetry. Such operators also preserve the A-twist supersymmetry on Σ g ×S 1 , as one can see using (2.11). When evaluated on the Coulomb branch covering space M, the Wilson loop (2.54) becomes a Laurent polynomial in x, corresponding to the character of the representation R: More generally, we can consider any insertion of Wilson loops wrapping S 1 at distinct points on Σ g . Any such insertion corresponds to a Weyl-invariant Laurent polynomial in x: While the classical algebra of Wilson loops is infinite dimensional, corresponding to the algebra of representations of G, the quantum algebra of supersymmetric Wilson loops of an N = 2 YM-CS-matter theory is generally finite dimensional, with relations encoded in the twisted superpotential (2.33). The quantum algebra relations are the relations satisfied by the solutions to: exp (2πi ∂ ua W) = 1 , a = 1, · · · , rk(G) , with the second condition imposing that we stay away from the Weyl chambers walls in M. These equations are known as the Bethe equations of the theory compactified on S 1 [10]. The quantum algebra takes the form: with the ideal I W generated by the relations determined from (2.57). We will derive these relations directly by localization on Σ g × S 1 , and we will give an explicit presentation of (2.58) in some interesting examples. Note that the quantum algebra generally depends on all the fugacities for the global symmetries of the theory. Closely related discussions have appeared previously in [29,30]. Note that the Verlinde algebra [62,63] of Wilson loops in pure Chern-Simons theory with gauge group G at levelk is a special case of (2.58). It can be obtained by considering an N = 2 supersymmetric Chern-Simons theory with gauge group G and CS level k, withk = k−h sign(k) and h the dual Coxeter number of G. 8 In the absence of matter fields, the ordinary Wilson loops are equivalent to the supersymmetric Wilson loops (2.54) because σ = 0 on-shell.

The localization formula on
One can use supersymmetric localization to compute the Σ g × S 1 partition function of a generic N = 2 YM-CM-matter theory. More generally, we can consider a correlation function of Wilson loops along S 1 , collectively denoted by W as in (2.56). The localization formula reads: in terms of a Jeffrey-Kirwan (JK) residue on the differential form: on M ∼ = (C * ) rk(G) , in each topological sector m. The first factor is the classical contribution Z classical (u) given by (2.42). The second factor is the product of the one-loop determinants for chiral multiplets Φ i in the representation R i of g, of R-charge r i , and with the appropriate fugacities y i and background fluxes n i for the global symmetries. The third factor is the one-loop determinant for the W -bosons and their superpartners, with α the simple roots of g. These one-loop determinants were computed in [8]. Finally, the function H(u) appearing in (2.60) is the Hessian of the effective twisted superpotential W as defined in (2.36), that is: while W (x) is a Laurent polynomial in x corresponding to the Wilson loop insertion (2.56). The contribution H(u) g in (2.60), which arises because of additional gaugino zero-modes on Σ g , is the main new ingredient with respect to the S 2 × S 1 computation of [8].

Singular hyperplanes and JK residue
There are three types of singularities of the integrand (2.60) on the classical Coulomb branch covering space M: Matter field singularities. Whenever x ρ i y i = 1, the one-loop determinant (2.61) may develop a pole (depending on the flux sector m). For any field component ρ i of a chiral multiplet Φ i , we define the hyperplanes: These singularities signal the presence of massless modes associated to vortices, which can appear at these loci. See for instance [22] for a detailed discussion of BPS vortices.
Monopole operator singularities. The singularities of the second type are located at x a = ∞ and x a = 0 (that is, at σ a = ∓∞) and correspond to the monopole operators T + a and T − a , respectively, which can condense in those limits: It is useful to think of M as a (CP 1 ) rk(G) by including these hyperplanes at infinity. The integrand (2.60) has singularities of the form for any simple root α. These hyperplanes are the walls of the Weyl chambers in the covering space M, where part of the non-abelian symmetry is restored. Poles including this hyperplane need a special treatment in the path integral. Indeed one can easily check that singularities involving H α are always non-projective (see below for a definition) so that the JK-residue operation is ill-defined. We claim that we should simply exclude these poles from the residue integral. We checked in many examples that this prescription gives the expected answer. This is consistent with discussions in previous literature, in particular with the study of CS theory [64,65,20] and twodimensional theories [66].
Consider the Coulomb branch covering space compactified as M ∼ = (CP 1 ) rk(G) , with the hyperplanes at infinity included as the poles of each (CP 1 ) a . In each topological sector, we denote by M m sing the set of codimension-rk(G) singularities coming from the intersection of s ≥ rk(G) hyperplanes (2.64) and/or (2.65), and such that they are not located on the hyperplanes (2.67).
The localization formula in (2.59) is given by a contour integral on M in each topological sector. The contour of integration is determined by the Jeffrey-Kirwan residue prescription [67,68,69] around each singularity u * ∈ M m sing . Consider any singular point u * at the intersection of s singular hyperplanes H Q 1 , · · · , H Qs , whose directions and orientations are determined by the charge vectors in the electric weight lattice. These charge vectors Q j are either weights ρ i from matter field singularities, or induced charges Q a± from monopole operator singularities. For the JK residue to exist, we assume that all the relevant singularities are projective. This means that, for any u * , the s charges (2.68) are contained within a half-space of ih * . A singularity with s = rk(G) is said to be non-degenerate. For completeness, we briefly review the definition of the JK residue. (We refer to [6,7,8,12] for further discussions.) We consider the case u * = 0, while the general case can be obtained by translation. Let us denote by Q S any subset of rk(G) distinct charges in Q(σ * ), and let us define: the corresponding singular holomorphic rk(G)-form. The JK residue on ω S is defined by in terms of an auxilliary vector η ∈ h * , which we can choose at our convenience as long as it is not parallel to any of the charge vectors. For degenerate singularities where more than rk(G) hyperplane meets, we refer to the prescription in [68,69,6] for an algorithmic determination of the JK contour. The definition (2.70) is often sufficient to determine the JK contour in practice.

Relation to the Bethe equations and to the Wilson loop algebra
Note that all the factors in (2.60) that depend on the gauge flux m organize themselves into the twisted superpotential: reproducing (2.34). We can formally perform the sum over fluxes (see [12] for a similar discussion) to obtain: where we pick the Grothendieck residues at x =x ∈ S BE , with S BE the set of distinct solutions (up to Weyl equivalences) of the Bethe equations (2.57). Here we defined: and (2.74) We assume that the two-dimensional theory is fully massive, such that H(x) = 0, ∀x ∈ S BE . This leads to: This result was first obtained in [9] in the case U = 1-that is, for vanishing background fluxes. The quantity H(x) is the three-dimensional handle-gluing operator [9], allowing us to write down genus-g correlation functions in terms of the genus-zero result: According to (2.75), the Witten index (1.4) is given by the number of distinct solutions to the Bethe equations: (2.77) As we will see in the examples, this directly reproduces the results of [2,23,22]. This simply reflects the one-to-one correspondence between three-dimensional vacua in the presence of generic real masses and two-dimensional vacua of the theory compactified on a circle of finite size [22]. The formula (2.72) directly implies the quantum algebra (2.58) of Wilson loops. By definition of the ideal I W in (2.58), any insertion of an element Z of this ideal has vanishing correlation function with any other Wilson loop: Conversely, if W Z g = 0 for every possible insertion W , it implies that Z(x)| x=x = 0, ∀x, so that Z(x) ∈ I W .

Sign ambiguities of the twisted index and dualities
We just explained how to compute the twisted index (1.1) as a path integral on Σ g ×S 1 : The overall sign of the 3d partition function seems ambiguous, although we have chosen it such that the Witten index (2.77) is a non-negative integer. Whenever the gauge group G contains abelian factors U (1) I , the index suffers from a sign ambiguity in the sum over topological sectors, corresponding to shifting the fugacities q I for the topological symmetries U (1) T I by arbitrary signs [70,8], q I → (−1) n I q I with n I ∈ Z. This can be thought of as a shift of the two-dimensional θ-angles by multiples of π. These sign ambiguities lead to a possible ambiguity when checking dualities, and generally we will find that, for any pair of dual theories T and T D , we have 9 for some theory-dependent integers n r , n i . In principle, any such ambiguity should be accounted for by an appropriate supersymmetric counterterm [52,44] but the precise mechanism in this case is unclear to us at this point. 10 An interesting special case of (2.80) is for a theory of two chiral multiplets Φ 1 , Φ 2 with R-charges r and 2 − r, gauge charge Q and −Q under a flavor U (1) with fugacity y and background flux n, and a superpotential W = Φ 1 Φ 2 . This theory is infrared "dual" to an empty theory, but the partition function reads: We leave a more precise understanding of these signs as an interesting question for future work.

N = 2 U (1) theories and elementary dualities
In this section, we study N = 2 CS-matter theories with a gauge group G = U (1). These theories were recently studied extensively in [22]. This will serve as an interesting warm-up to the non-abelian theories of the next sections.

U (1) k CS-matter theory
Consider a U (1) theory with CS level k > 0 and charged chiral multiplets Q i and Q j , of gauge charge n i and − n j , respectively, with n i > 0 and n j > 0. 11 It is useful to define: Without loss of generality, we assume that k c ≥ 0. The theory has a large flavor symmetry, depending the choice of n i , n j , but we can focus on the axial symmetry U (1) A defined in Table 1. Let us denote by y −1 i and y j the flavor fugacities for Q i and Q j , respectively. If we are only interested in U (1) A , then y i = y −n i A and y j = y n j A . To cancel a potential parity anomaly for U (1) A , we also turn on the mixed flavor-CS term k gA = −k c . We also redefine q → (−1) i n 2 i q for convenience. The Bethe equation (2.57) for this theory reads: Table 1: Gauge, axial, topological and R-charges of the matter fields in the U (1) k CS-matter theory.
The twisted index is easily evaluated using the general results of the previous section.
In particular, it follows from (2.77) that the Witten index of this theory is equal to the degree of the polynomial P (x): This reproduces the Witten index computed in [22] by a careful analysis of the vacuum structure of the theory.

SQED/XY Z-model duality
As an interesting special case, consider three-dimensional SQED, a U (1) gauge theory without CS interaction and with two charged scalar multiplets Q, Q of charges ±1 and R-charge r. The theory has an axial symmetry U (1) A and a topological symmetry U (1) T , with associated fugacities y A and q (and background fluxes n A and n T ), respectively, and we have an FI parameter turned on according to (2.24).
The twisted index (2.59) for SQED reads: Note that we introduced a convenient sign in front of q. With η > 0, the JK residue picks the pole at . There is no contribution from infinity on M because the monopole operators T ± are gauge invariant. Following [8], we can perform the sum over m first, which gives: is the solution to the Bethe equation: The expression (3.5) gives: with r T = −r + 1. Up to a sign (−1) n T , this is simply the twisted index of three chiral multiplets (X, Y, Z) = (M, T + , T − ) with charges: These charges are compatible with the cubic superpotential W = M T + T − . This is expected since 3d N = 2 SQED is dual to the XY Z model [53].
with a single chiral multiplet Consider a U (1) theory with a Chern-Simons level k = 1 2 and a single chiral multiplet Q of gauge charge 1. We also choose Q to have R-charge r, and we turn on a mixed gauge-R CS level k gR = − 1 2 (r − 1), although the R-charge can be set to any value by mixing with the gauge symmetry. This theory has a flavor symmetry U (1) T , the topological symmetry of the U (1) gauge group. It is dual to a single free chiral multiplet T + of U (1) T charge 1, corresponding to the lowest gauge-invariant monopole operator for the 'half' Coulomb branch of the gauge theory [72,28]. Importantly, the dual free theory also contains the flavor CS terms: This is a special case of a more general Seiberg duality [28], that we shall discuss in more details in section 5.6 below (and in Appendix C). The twisted index of the U (1)1 2 theory reads: where we redefined q → −q for convenience. Note that the monopole operators T ± of this theory have gauge charges 0 and −1, respectively. If we take η > 0, the JK residue has contributions from Q only, at x = 1. If we take η < 0 instead, we pick the poles at x = 0. Either way, we can perform the sum over the fluxes as above, to obtain: with the CS levels ∆k T T , ∆k T R given in (3.9), in perfect agreement with the duality.

Chern-Simons theories and the Verlinde formula
In this section, we consider a supersymmetric Chern-Simons theory without matter. Consider the N = 2 Chern-Simons theory with gauge group G at level k > 0. As we recalled at the end of section 2.4, that theory is IR-equivalent to an ordinary CS theory at level: with h the dual Coxeter number of G. The genus-g supersymmetric index should give the dimension of the Hilbert space of a Gk CS theory on Σ g : which is famously given by the Verlinde formula [62,64]. This provides an nice consistency check of our localization formula at higher genus. Here we shall focus on G = U (N ) and G = SU (N ), for simplicity.

U (N ) N = 2 supersymmetric CS theory
Consider the N = 2 U (N ) vector multiplet with Chern-Simons interaction at level k > 0. Due to the U (1) factor, the theory has a topological symmetry U (1) T , and we can turn on the associated fugacity q and background flux n T . The twisted index reads: 12 The factor of k gN is the contribution from H = k N for a U (N ) CS theory. The monopole operators T ± a have gauge charges Q a± b = ±δ a b k. If we take η = (1, · · · , 1) in the JK residue, we only have contributions from x a = ∞. After performing the sum over the fluxes explicitly, the pole at x a = ∞ are all relocated to the solutions of the Bethe equations: (One can check that the solutions to the Bethe equations go to x a → ∞ as q → 0.) Using the fact that: for any fixed integer M , we find: where the integral becomes a sum of iterated residues at x a =x α witĥ the roots of P (x). The partition function thus reduces to a sum over choices of N distinct integers among {α} = {1, · · · , k}. Let C k N denotes the set of all choices of N distinct integers among {α}, and let I = {α 1 , · · · , α N } be any element of C k N . We have: In particular, Z As a small consistency check, we note that (4.8) implies the Witten index: in agreement with [23]. In the case n T = 0, the dependence on q drops out from (4.8) and it turns out that the resulting numbers Z Σg×S 1 for k ≥ N are positive integers, consistent with the interpretation (4.2).
The U (N ) k supersymmetric CS theory enjoys level rank duality: The duality also exchanges the sign of the topological current. We can show that: The factor q −n T is interpreted as a relative CS level ∆k T T = −1 for the U (1) T background gauge field. This duality is a special case of a more general three-dimensional Seiberg duality [26,28], which we shall study thoroughly in section 5. To prove (4.11), we write down the twisted index as: following the notation of section 2.6. We can easily show that, forx = {x a } N a=1 ⊂ {x α } k α=1 a set of N distinct roots of P (x), andx D = {xā} k−N a=1 its complement, we have: where are the quantities (4.13) in the dual U (k − N ) −k theory. The duality relation (4.11) follows by exchanging any set I ∈ C k N with its complement I c in {α}. One can similarly study Wilson loop correlation functions and verify that they satisfy the Verlinde algebra [30,8]. (See section 5.7 below for a general discussion in 3d N = 2 SQCD.)

The SU (N ) Verlinde formula
It was noted in [8] that the S 2 × S 1 twisted index for an U (N ) theory with matter fields neutral under its center is equivalent to the S 2 × S 1 twisted index for the corresponding SU (N ) theory (if n T = 0). On Σ g × S 1 , we can similarly show that: (4.16) From (4.8), we directly find: In particular, this reproduces the correct Witten index [2,23]: One can check that (4.17) agrees precisely with the Verlinde formula for SU (N ) k−N pure CS theory on Σ g . In particular, it is easy to show that in the special case N = 2, withk = k − 2. One can also check level-rank duality like in [73].

The equivariant Verlinde formula
Another interesting theory is the N = 2 Chern-Simons theory at level k with an adjoint chiral multiplet Φ of real mass m > 0 and R-charge r. For r = 2, the Σ g × S 1 twisted index computes the "equivariant Verlinde formula" introduced in [20]. That formula was also computed in [20] using the results of [9], therefore it is obvious from the general discussion in section 2.6 that we should reproduce this result as well. We briefly show this here. Consider G = U (N ) at CS level k > 0. Let U (1) t be the symmetry that rotates the chiral multiplet Φ with charge 1, and let us introduce the corresponding fugacity t and background flux n t . (We have |t| = e −2πβm with m the real mass.) To make contact with [20], we choose to turn on a mixed U (1) t -R CS level: We also allow for an arbitary gauge-R CS level k gR for the U (1) ⊂ U (N ) gauge group. The twisted index reads: where we defined: .
The Bethe equations of this theory are: By resumming the fluxes and using the property: satisfied by the solutions to the Bethe equations, we indeed find: (4.25) The sum is over the distinct solutionsx to the Bethe equations (4.23), and each residue is taken at the isolated singularity x =x. (More precisely, at each x =x we have a local Grothendieck residue for the ideal {P a } Nc a=1 in C[x a ].) This gives: Table 2: Charges of the chiral multiplets of 3d N = 2 SQCD. We also indicated the charges of the bare monopole operators T ± . with: x a t 1 2 This formula precisely agrees 13 with [20] in the case n T = n t = 0 and q = 1, provided that we choose k gR = −(N − 1)r.

N = 2 U (N c ) k YM-CS-matter theories and Seiberg dualities
In this section, we study the three-dimensional N = 2 supersymmetric version of SQCD on Σ g × S 1 . This theory consists of a U (N c ) vector multiplet with a Yang-Mills kinetic term and an overall Chern-Simons level k, coupled to N f chiral multiplets Q i (i = 1, · · · , N f ) in the fundamental representation of the gauge group and to N a chiral multiplets Q j (j = 1, · · · , N a ) in the antifundamental representation. The global symmetry group is: Both Q i and Q j are taken to have R-charge r ∈ Z, and the superpotential vanishes. To cancel the parity anomaly for the gauge symmetry, we must have: In order to cancel potential parity anomalies for the flavor symmetry, we turn on some mixed CS terms: between the U (1) ⊂ U (N c ) factor of the gauge group and the U (1) A and U (1) R symmetry, respectively. Note that the choice of mixed CS levels (5.3) is an important part of the definition of the theory. In particular, it affects the quantum numbers of the monopole operators. We will make a convenient choice in the next subsection. Finally, we also need to specify the global CS levels for (5.1). 14 As we will show momentarily, the Witten index of three-dimensional N = 2 SQCD is given by: For N c = 1, this was computed in [22]. When n > N c , there exists a Seiberg-dual description of the theory [24,26,28] with dual gauge group U (n − N c ) at CS level −k, leaving the Witten index invariant. The details of the Seiberg dual theory depend on the relative values of k and k c in an interesting way. The matching of the twisted indices on Σ g between dual theories provides a powerful and intricate test of these dualities, including the matching of contact terms for the global symmetries, which necessitates turning on certain background CS terms [74,28,44,8].
For future reference, let us comment on the monopole operators of the U (N c ) theory. We denote by T ± the bare monopole operators of charge ±1 under U (1) T . Their induced charges under U (1) A and U (1) R are: The monopole operators also have induced gauge charges, as indicated in Table 2. In particular, T ± is gauge invariant if and only if k = ±k c . In that case, the Seiberg-dual theory contains one extra singlet (or two extra singlets if k = 0) with the same quantum numbers as T ± , which couples to a monopole operator of the dual gauge group through the superpotential [24,28].
Consider N = 2 SQCD as defined above. Let us introduce generic fugacities y i , y j (with i = 1, · · · , N f and j = 1, · · · , N a ) for the SU such that: with y A the U (1) A fugacity. We also introduce background fluxes n i , n j subject to with n A the U (1) A flux. We denote by q and n T the fugacity and background flux for the topological symmetry U (1) T . The twisted index of N = 2 SQCD reads: where the sum is over the fluxes m a ∈ Z, a = 1, · · · , N c . The integrand contains the classical piece: which includes the mixed gauge-U (1) A and gauge-R Chern-Simons terms (5.3). Any other flavor CS term factorizes out of the index and can be ignored for our purposes. Note that we introduced a sign (−1) (N f +Nc−1) a ma in (5.9) for later convenience. The other factors in the integrand are the one-loop determinants: (5.10) and the Hessian of the twisted superpotential W: Note that the index (5.8) depends on the choice of R-charge r through the combination n A + (g − 1)(r − 1) only, therefore we could set r = 1 without loss of generality. Nonetheless, we find it instructive to present the final formulas for an arbitrary r.
Since the gauge charges of the monopole operators T ± a are given by: different singularities contribute to the JK residue (5.8) depending on the relative values of k and k c . Without loss of generality, we can consider k ≥ 0, k c ≥ 0. There are four distinct cases: • If k = k c = 0, we have a U (N c ) gauge theory with N f = N c and no Chern-Simons term. The theory has a quantum Coulomb branch spanned by the gauge-invariant monopole operators T ± . Aharony duality [24] provides a dual description with a U (N f − N c ) gauge group.
• If k > k c ≥ 0, the CS interactions lifts the Coulomb branch. The dual theory with gauge group U (k + N f − k c − N c ) is known as Giveon-Kutasov duality when k c = 0 [26].
• If k c > k ≥ 0, there is no quantum Coulomb branch and the dual theory has a U (N f − N c ) gauge group [28].
• If k = k c > 0, the theory has "half" a quantum Coulomb branch, spanned by T + .
The dualities with k c = 0 were introduced in [28]. All the dualities of [26,28] for YM-CS-matter theories with unitary gauge groups can be derived from the Aharony duality through real mass deformations. Nonetheless, it will be instructive to compute the twisted index in every case, especially because it is rather subtle to take the necessary decoupling limits between different values of [k, N c , N f , N a ] at the level of the index. For completeness, we consider those real mass deformations-in flat space-in Appendix C, where we also re-derive the relative global CS levels that are crucial for precise checks of these dualities [28,44]. For definiteness, we choose the mixed CS levels (5.3) to be: There are the levels obtained by real mass deformations from SQCD[0, N c , n f , n f ] at k gA = k gR = 0 (see Appendix C).

The Bethe equations of 3d N = 2 SQCD and Seiberg duality
Assuming k c ≥ 0, k ≥ 0, let us define the 'characteristic polynomial': of degree: It is easy to verify that the Bethe equations of SQCD[k, N c , N f , N a ] are given by: Let {x α } n α=1 be the set of roots of (5.14), which are distinct for generic values of the parameters. The set S BE of distinct solutions to the Bethe equations is the set of all unordered subsets {x a } Nc a=1 ⊂ {x α } of N c elements. We can easily perform the sum over gauge fluxes in (5.8). For definiteness, let us choose η = (1, · · · , 1) in the JK residue. The contributing poles are at x a = y i and x a = ∞, where the latter singularities contribute only if k > k c . We first perform the sum over the fluxes m a ≥ M , with M ∈ Z some fixed integer depending on the background fluxes, which cancels out of the computation. The geometric series for each m a reproduces the characteristic polynomial (5.14): 17) and the resulting contour integral has contributions from the poles at the roots of P (x). One can check that these roots go tox α → y i andx α → ∞ in the limit q → 0. Using the identity: for any rootx α of P (x), we can rewrite the twisted index as: as anticipated in section 2.6. This directly implies the formula (5.4) for the Witten index. Here we have: Table 3: Charges of the chiral multiplets for the Seiberg dual of 3d N = 2 SQCD. There is also one extra singlet T ± if k = ±k c (or both, if k = k c = 0), corresponding to the Coulomb branch operator of the 'electric' theory.
with Q A − and r − defined in (5.5). Note that we used (5.18) to massage H(x) in (5.21). The expression (5.19) is the most convenient to study Seiberg dualities. The dual theory has a gauge group U (n − N c ) with dual matter fields as indicated in Table 3. Let xā (ā = 1, · · · , n − N c ) denote the gauge fugacities for the dual gauge group. The corresponding Bethe equations take the form: We directly see that P (x) and P D (x) have the same roots {x α } n α=1 if q D = q −1 . Indeed, the duality identifies the topological currents of the U (N c ) and U (N f −N c ) gauge groups, with a relative sign. If we denote by U (1) T D the topological current of U (N f − N c ), we have T D = −T , and therefore: for the fugacities and background fluxes, respectively. We denote by S D BE the set of distinct solutions to the dual Bethe equations (5.22), which is the set of all unordered subsets {xā} n−Nc a=1 ⊂ {x α } of n − N c elements. The twisted index of the dual theory takes the form: The first factor is the contribution from the relative flavor CS terms, which are discussed in more details below and in Appendix C. The second factor Z singlets Σg×S 1 is the contribution from the gauge-singlet fields that are part of the dual theory. This includes the contribution from the 'mesonic' gauge-singlet fields M j i , which reads: where we defined: (5.27) We have Z singlets we must also include the contribution from an extra singlet T + (or two extra singlets T ± , respectively). The last factor in (5.25) is the contribution from the dual gauge group U (n − N c ) with its charged matter fields. Note the exchange of the fugacities y and y in (5.25).
By a similar reasoning as above, we can show that the gauge contribution in (5.25) can be expressed as a sum over the solutions to the dual Bethe equations: This can be obtained from (5.20)-(5.21) by exchanging i and j indices together with the substitutions: and similarly for the background fluxes. The identity of twisted indices across Seiberg duality can be shown by replacing the set of N c rootsx = {x a } Nc a=1 of P (x) by its complementx D = {xā} n−Nc a=1 ⊂ {x α }. In Appendix D, we prove that: for any partition {x α } =x ∪x D of the roots of P (x). The quantities u and h only depend on the fugacities (and fluxes) for the global symmetries, and are such that: with an extra (ambiguous) sign included in the definition of Z CS Σg×S 1 . The exact expression for u and h are given in Appendix D. The relations (5.32)-(5.33) directly imply the equality of twisted indices for the dual theories: These results also imply the equality of Wilson loop correlators. For any Wilson loop W of the U (N c ) theory, there exists a dual Wilson loop W D such that: wherex andx D of P (x) are complementary sets of roots defined as above. Using the expression (2.75), we easily see that the dual correlation functions on Σ g × S 1 must coincide: We will discuss this duality map in more details in subsection 5.7 below.

Aharony duality (k
Consider SQCD with k = k c = 0. This is a U (N c ) YM theory with N f pairs of fundamental and antifundamental chiral multiplets Q i , Q j and a vanishing superpotential. We choose the mixed gauge-flavor CS terms k gA = k gR = 0 according to (5.13). We also set all the global (flavor and U (1) R ) CS levels to zero. The dual theory is a U (N f − N c ) YM theory with N f fundamental and antifundamental chiral multiplets q j , q i , , and two extra singlets T ± charged under the topological symmetry U (1) T . These fields interact through the superpotential (C.4) given in Appendix C.1. All the gauge and global CS levels vanish as well. The gauge and global charges of all the dual matter fields are summarized in Table 4. The singlets M j i and T ± are identified with the gauge-invariant mesons Q j Q i and with the lowest gauge invariant monopole operators of U (N c ), respectively.
The Σ g × S 1 partition function of the electric theory is given by: a special case of the SQCD index (5.8). The partition function of the magnetic theory is given by: with the singlet contribution:

Duality for
We choose the mixed CS levels k gA , k gR according to (5.13). The dual gauge theory has a gauge group U (k + 1 2 (N f + N a ) − N c ) at CS level −k, with mixed gauge-U (1) A and gauge-R CS levels: The dual matter sector consists of the dual charged chiral multiplets q j , q i and the N f N a gauge-singlet mesons M j i , with the standard Seiberg dual superpotential W = qM q. The gauge and global charges are summarized in Table 3 above.
To fully state the duality, we need to specify the relative CS levels for the global symmetry group (5.1). In Appendix C, we show that: and Here we omited ∆k RR because it does not enter the Σ g × S 1 partition function. Assembling all the pieces, the twisted index of the Seiberg dual theory is given by: with Z M Σg×S 1 defined in (5.26), and: The dual matter sector is like in the last subsection, as summarized in Table 3 above. The relative CS levels for this duality are: as we explain in Appendix C. The dual twisted index reads: with Z M Σg×S 1 defined in (5.26), and: with the relative CS levels (5.47), while (−1) n * is another unimportant sign. One can check that (5.33) holds in this case as well.

Duality for
The final case to consider is SQCD[k c , N c , N f , N a ] with CS level k = k c > 0, the limiting case between subsections 5.4 and 5.5. The dual gauge group is a U (N f − N c ) gauge group at CS level −k and mixed CS levels (5.46). In addition to the dual charged multiplets and mesons M j i , there is an extra singlet T + and a superpotential (C.17). The relative CS levels for this duality are: (5.50) The dual twisted index reads: The singlet contribution includes the contribution from T + : with r + = − k + 1 2 (N f + N a ) − N c + 1 the R-charge of T + in this case. The factor Z CS Σg×S 1 in (5.51) is given by (5.49) with relative CS levels (5.50). One can check that (5.33) holds here as well, which completes the proof of (5.34).

Wilson loop algebra and the duality map
As an illustration of the general discussion of section 2.4, let us consider the quantum algebra of Wilson loops in SQCD[k, N c , N f , N a ]. A particularly interesting case is for k = k c = 0, which we consider in some more details below. The Wilson loop algebra for SQCD was studied previously in [30] by considering the theory on S 3 , and we follow a similar logic on Σ g × S 1 . As we emphasized in section 2.4, the Wilson loop algebra is always encoded in the Bethe equations of the theory on R 2 × S 1 .

Wilson loops and Seiberg duality
Wilson loops in a U (N c ) theory are in one-to-one correspondence with symmetric Laurent polynomials in the coordinates x a : which are in one-to-one correspondence with Young tableaux graded by the U (1) ⊂ U (N c ) charge q ∈ Z. For instance, Wilson loops in the fundamental and antifundamental representations correspond to: Products of Wilson loops are given by the corresponding tensor products of U (N c ) representations. Consider first the representations R with q ≥ 0, corresponding to all the symmetric polynomials W (x) ∈ C[x 1 , · · · , x Nc ] S Nc , which form a subalgebra. They are generated by the elementary symmetric polynomials: Let us define the generating function: where we identify any irreducible Wilson loop W (x) with its corresponding Young tableau.
The quantum Wilson loop algebra is governed by the Bethe equations (5.16), which are given in terms of the polynomial P (x) of degree n (5.14). The quantum algebra relations f = 0 are the relations satisfied by any solution to the Bethe equations-that is, we have f (x) = 0 for any setx = {x a } Nc a=1 of N c distinct roots of P (x). These relations can be conveniently written in a gauge-invariant form [75,76] as: where we defined: and we have 1 for {x a } any solution to the Bethe equations. Therefore these elements x −1 a are not independent in the quotient ring, and the quantum algebra (2.58) is the ring of U (N c ) representations with q ≥ 0-labelled by Young tableaux of maximum N c rows-quotiented by the relations encoded in (5.58). The quotient ring is finite-dimensional, consisting of Young tableaux with a maximum of N c rows and n − N c columns.
The relations (5.58) also encode the duality map (5.35) between the Wilson loops W of U (N c ) and the Wilson loops W D of the dual theory. Seiberg duality then acts as an isomorphism of the quantum Wilson loop algebra [30], which is rendered manifest in (5.58).

Wilson loops in Aharony duality
To illustrate the above considerations, let us consider U (N c ) with k = 0 and N f = N a in more details. The characteristic polynomial in this case reads: We have the quantum relations (5.58) with C(q) = 1 − qy −N f A . Note that we have: where we defined: the elementary symmetric polynomials in the fugacities y i and y j for the SU (N f ) × SU (N f ) × U (1) A flavor group. We can think of these quantities as 'flavor Wilson loops' for the background gauge fields. It follows that the quantum ring relations are given explicitly by: Here it is understood that s Nc l (x) = 0 for l > N c and s For instance, the first relation reads: This is the relation between the Wilson loop W in the fundamental representation of U (N c ) and the dual Wilson loop in the fundamental representation of U (N f − N c ). The relations (5.68) have an interesting property in the limit y i = y j (i = j), when we have : The number of summands in x, x D or y is equal on either side; if we set x a = xā = y i = 1, we have a relation between dimensions of gauge and flavor representations.
Example: U (3) with N f = 5. To illustrate the above, let us work out the case N c = 3 and N f = 5. We take y i = y j = 1 for simplicity. In that case, the equations (5.68) read:

Wilson loops in Giveon-Kutasov duality
As another example, consider the case k > 0 and k c = 0, corresponding to Giveon-Kutasov duality [26]. The characteristic polynomial is given by: From (5.58), we easily derive the k + N f quantum algebra relations: for m = 1, · · · , k + N f , similarly to subsection 5.7.2. Here it is understood that s F m = 0 if m < 0. This case was studied previously in [30], where the Bethe equations P (x a ) = 0 appeared as relations satisfied by BPS Wilson loops on S 3 .
Example: U (3) with k = 2 and N f = 2. The dual theory is a U (1) theory with CS level −2. If we consider y i = y j = 1 for simplicity, the relations (5.75) give:

N = 4 gauge theories and mirror symmetry
Three-dimensional N = 4 supersymmetric gauge theories are particularly interesting because they admit different choices of topological twisting [31,77,21], which are often related to each other by three-dimensional mirror symmetry [32]. In this section, we define the A-and B-twists of N = 4 theories on S 1 × Σ g -and a certain N = 2 * deformation thereof. We study the corresponding twisted indices and their behavior under mirror symmetry. We also briefly discuss the mirror map between Wilson loop and vortex loop operators following [33].

The A-and B-twist of 3d N = 4 gauge theories
The 3d N = 4 supersymmetry algebra in flat Euclidean space-time reads: The eight supercharges Q AĀ α transform as (2, 2) under the R-symmetry group SU (2) H × SU (2) C , and we introduced the indices A, B = 1, 2 for SU (2) H andĀ,B =1,2 for SU (2) C . We can preserve half of the supercharges on any three-manifold by twisting the SU (2) L Lorentz group with either SU (2) H or SU (2) C [31]. Let us denote by U (1) H × U (1) C the Cartan subgroup of SU (2) H × SU (2) C , and by H and C the corresponding charges. We define the integer-valued R-charges: For a theory on Σ g × S 1 , we can identify either R A or R B as the U (1) R symmetry of an N = 2 subalgebra, and proceed as in section 2.
The SU (2) C twist is known as the Rozansky-Witten twist [31]. It preserves four scalar supercharges on any three-manifold: On Σ g × S 1 , we preserve the supersymmetry algebra: where E is the generator of translation along S 1 . This is the algebra of an N = 4 supersymmetric quantum mechanics (QM) with U (1) C × SU (2) H R-symmetry [7]. We call this Σ g × S 1 background the B-twist. It corresponds to a topological twist along Σ g by the R-charge R B in (6.2). Similarly, the SU (2) H twist preserves the four scalar supercharges: and preserves the algebra: on Σ g × S 1 , which is the algebra of an N = 4 supersymmetric quantum mechanics with U (1) H × SU (2) C R-symmetry. We call this Σ g × S 1 background the A-twist, corresponding to a topological twist along Σ g by R A in (6.2). Both twists preserve the two supercharges Q 11 + and Q 22 − , which satisfy the N = 2 supersymmetric quantum mechanics algebra: These are the two supercharges that we use for supersymmetric localization. Importantly, they commute with the flavor symmetry U (1) t ≡ 2 [U (1) H − U (1) C ], with conserved charge: We can therefore turn on a fugacity t for U (1) t , which breaks N = 4 supersymmetry to N = 2 * . Let us define the A-twisted index: Table 5: Charges of the components fields of an N = 4 vector multiplet. Here U (1) L is the spin along Σ g , and the combinations S A = L + H and S B = L + C are the A-twisted and B-twisted spins, respectively. Here we used the notation λ AĀ α for the gaugini, while the auxiliary fields (D 0 , D ∓ ) are in the 3 of SU (2) H .
with the U (1) R charge R = R A , and the B-twisted index: with R = R B . The fugacity t will play a crucial role in our computation, since we generally need t = 1 for the localization formula of section 2 to be well-defined. 16

3d N = 4 supermultiplets and mirror symmetry
We consider N = 4 gauge theories built out of N = 4 vector multiplets and hypermultiplets. The N = 4 vector multiplet for a gauge group G with Lie algebra g consists of an N = 2 vector multiplet V and a chiral multiplet Φ, valued in the adjoint representation of g. An N = 4 hypermultiplet charged under G consists of two N = 2 chiral multiplet (Q 1 ,Q 2 ) in a representation (R,R) of g, together with the charge conjugate anti-chiral multiplets. In N = 2 language, the coupling of the hypermultiplet to the vector multiplet includes the superpotential: The non-abelian R-charges are assigned in the UV and do not change under RG flow. We summarized the field content and the charges of a g-valued vector multiplet in Table  5, while the hypermultiplet field content is given in Table 6. Under the B-twist, the Table 6: Charges of the components fields of an hypermultiplet. Here q 1 and q 2 are the lowest components of the 3d N = 2 chiral multiplets Q 1 and Q 2 , respectively, andq 1 ,q 2 are their charge conjugates. become scalars, with (σ, φ,φ) transforming as a triplet under SU (2) C . The resulting one-dimensional gauge theory is an N = (2, 2) supersymmetric quantum mechanics. 17 Some other useful representations of N = 4 supersymmetry are the twisted vector multiplet and the twisted hypermultiplet. 18 For any 'ordinary' N = 4 supermultiplet one can construct a 'twisted' representation of supersymmetry by exchanging SU (2) H and SU (2) C . This 'mirror automorphism' of the supersymmetry algebra is a trivial statement, in the sense that a gauge theory containing only vector multiplets and hypermultiplets is isomorphic to the same theory with twisted vector multiplets and twisted hypermultiplets, by a simple relabelling of the R-symmetry representations. The mirror automorphism naturally exchanges the A-and B-twists.
On the other hand, N = 4 mirror symmetry is a non-trivial infrared duality of two distinct gauge theories (of vector and hypermultiplets) [32] composed with the mirror automorphism of N = 4 representations. Mirror symmetry therefore implies that the A-twisted index (6.9) of a theory T must agree with the B-twisted index (6.10) of its mirrorŤ : g, B y, t −1 , (6.14) and similarly with A-and B-twists exchanged. Here, y i are the fugacities for the flavor symmetries of T andy i are the mirror fugacities ofŤ -as we will review in the examples below, mirror symmetry exchanges Coulomb branch parameters (FI parameters) with Higgs branch parameters (real masses).

The Wilson loop and vortex loop operators
Three-dimensional N = 4 gauge theories contain very interesting half-BPS loop operators. The half-BPS Wilson loop on a closed loop γ can be thought of as a 1d N = (0, 4) quantum mechanics living on γ [33]. On Σ g × S 1 , such Wilson loops can be studied by wrapping them over S 1 . We have the Wilson loop W R given by (2.54) for any representation R of G. This amounts to inserting a factor W (x) = Tr R (x) (6.15) in the path integral localized on the classical Coulomb branch, as discussed in details in section 2.4. Such Wilson loops preserve the four supercharges (6.3) of the B-twist on Σ B g × S 1 , while they only preserve two supercharges in the A-twisted theory. Consequently, we can study half-BPS Wilson loops in the B-twisted theory, or more generally quarter-BPS Wilson loops in the A-twisted theory. In this work, we will focus on the half-BPS loop Wilson loop operators in the B-twisted theory.
The half-BPS loop operator which preserves the full N = (2, 2) one-dimensional algebra (6.6) of the A-twisted theory is the vortex loop V along S 1 . This loop operator can be realized in the UV as a 1d N = (2, 2) supersymmetric quantum mechanics living on the loop, coupled non-trivially to the bulk three-dimensional theory by gauging a 1d global symmetry with 3d gauge fields [33]. The insertion of such a vortex loop amounts to inserting an N = (2, 2) QM index inside the localized path integral on Σ A g × S 1 . For any one-dimensional GLSM coupled to the 3d gauge field, we insert: into the Σ A g × S 1 localization formula. The quantum mechanical index (6.16) is written in terms of a JK residue integral over u 1d according to the results of [7]. Here the u 1d 's are the complexified flat connections of the 1d gauge theory, x stands for the 3d gauge fugacities, and y stands for the other flavor fugacities. The fugacity t is a fugacity for the R A − R B fugacity of the one-dimensional N = (2, 2) algebra. Since the vortex operator preserves the full supersymmetry algebra of the A-twisted theory, this can be identified with the Q t flavor symmetry (6.8) of the three-dimensional theory.
It is clear from symmetry considerations that half-BPS Wilson loops W should be mapped to half-BPS vortex loops under mirror symmetry: 17) The precise mirror symmetry map between a Wilson loop W and a vortex loop V has been thoroughly studied in [33], and we summarize some of these results in Appendix E. In section 6.5 below, we will verify the relation (6.17) for loop operators on Σ g × S 1 in an interesting example. We leave a more systematic study of (6.17) using twisted indices for future work.

The N = 4 localization formula on Σ g × S 1
We can easily compute the twisted indices (6.9) and (6.10), and the corresponding expectation values of half-BPS loop operators, as a special case of the N = 2 localization formula of section 2.5. Consider an N = 4 gauge theory with gauge group G and charged hypermultiplets (Q 1,i , Q 2,i ) in representations R i of g, with fugacities and background fluxes y i , n i .

The A-twisted index
The A-twisted index takes the form: The factor q m in (6.18) denotes the FI term contributions from the free subgroup We could also turn on a background flux n T I for the topological symmetry U (1) T I , which would contribute an extra classical factor to (6.18) like in previous sections, but we will mostly set n T I = 0 in the following. 19 The one-loop determinants are given by: 20) 19 These terms preserve N = 4 supersymmetry. The correct mixed-CS term (also called BF term) involves the N = 4 vector multiplet (V, Φ) and a background twisted vector multiplet (V t , Φ t ) coupling to the topological conserved current of V [78,79]. In N = 2 language, this includes the superpotential W = ΦΦ t . and the Hessian determinant H(x) reads: while the one-loop determinants (6.20) stay finite in that limit. It implies that the contributions from the residue integral at x = 0 and x = ∞ must vanish, meaning that there is no wall-crossing [7] as we vary the parameter η of the JK residue integral. This allows us to choose a convenient η for each m. Consider the case G = U (1) for simplicity. For non-zero flux m, we choose η = −m such that for m > 0, so we have to pick the contributions from negatively charged fields. These fields contribute poles only when 0 < m < g, therefore there is no contribution for m ≥ g. Similarly, if m < 0 we have a contribution from the positively-charged fields, which contribute only when −g < m. To summarize, for G = U (1) the A-twisted index with g > 0 and n t = 0 receives contributions from a finite number of flux sectors −g < m < g. Similar considerations apply for any G. In particular, the Witten index (g = 1) only receives contributions from the vanishing flux sector on T 2 .

The B-twisted index
The B-twisted index reads: where H(x) is the same as in (6.21), and the one-loop determinants are: In contrast to the A-twisted index, the B-twisted theory with n t = 0 at g = 0 or g = 1 gets contribution from the m = 0 sector only, because the residue at infinity vanishes. (See section 6.6.1.) This implies that those indices are independent of the fugacities q I associated to the FI parameters. On the other hand, when g > 1 the one-loop determinants (6.25) in general have poles with non-vanishing residue at infinity on the classical Coulomb branch, and an infinite number of flux sectors generally contribute.

The simplest abelian mirror symmetry
The simplest 3d mirror symmetry is between N = 4 SQED with one flavor and a free hypermultiplet. Consider first a free hypermultiplet with fugacities y, t and background fluxes n, n t for the U (1) × U (1) t flavor symmetry. Its A-twisted index is given by: (6.26) and its B-twisted index reads: . (6.27) Consider next N = 4 SQED1, a U (1) theory with a single hypermultiplet. In N = 2 notation, the field content can be summarized by: Here U (1) T is the topological symmetry. The two last lines in (6.28) stand for the two gauge-invariant monopoles operators of the theory. We see that (T + , T − ) sits in the twisted hypermultiplet representation of N = 4 supersymmetry. In fact, N = 4 SQED1 is infrared dual to this free twisted hypermultiplet, or equivalently, it is mirror to a free hypermultiplet [32].
The twisted index provides a nice check of this duality. Let us introduce the quantities: , (6.29) and .
We also introduce the fugacity q and background flux n T for U (1) T . The A-twisted index of SQED1 reads: defined in (6.26), and similarly for the B-twist. We also introduced a convenient sign for q → −q. Using the same methods as in previous sections, it is easy to show that: It was shown in [32] that this mirror symmetry is formally a Fourier transform of the free hypermultiplet path integral [32]. The relation (6.32) is the concrete realization of this fact on Σ g × S 1 . A similar computation was done on S 3 in [81].

Other examples
In this subsection, we evaluate the A-and B-twisted indices of several interesting examples. For simplicity, we will set all background fluxes to zero, n i = n T = n t = 0, in the remainder of this section.

The free hypermultiplet
Consider the free hypermultiplet. We see from (6.26) that Z hyper g,A (y, t) = 1 , (6.33) in the absence of background fluxes. On the other hand, the hypermultiplet B-twisted index reads: (6.34)

G = U (1) with N f flavors
Let us consider N = 4 SQED-a U (1) vector multiplet coupled to N f hypermultiplets (Q i , Q i ) (i = 1, · · · , N f ) of charge 1. We introduce the fugacities y −1 i such that i y i = 1 for the SU (N f ) flavor group.
A-twisted N = 4 SQED. The A-twisted index reads: We also introduced a sign q → (−1) N f q for convenience, similarly to the N = 2 case in section 5. For η > 0, the JK residue picks the poles at x = y i t −1 . The sum over fluxes m can be performed like in previous examples. The Bethe equation for this theory is given by: We can then rewrite the index (6.35) as: which is identified with the B-twisted hypermultiplet (6.34) according to (6.32). At genus zero, we can evaluate (6.35) for any N f as we shall explain in subsection 6.6.2 below. We find: which is independent of y i . This happens to coincide with the Coulomb branch Hilbert series (HS) of N = 4 SQCD [38]. 20 20 More precisely, we have that Z At genus one, we have the Witten index: The N = 4 SQED with N f = 2 case is particularly interesting, since it realizes the self-mirror T [SU (2)] theory of Gaiotto-Witten [82]. For g = 2 we can write down an explicit formula: where we defined a = y 1 y 2 . In the limit t → 1, we find a simple result at any genus: with H(x) given in (6.36). By the same reasoning as above, this can be massaged into: as expected from the mirror symmetry relation (6.32). For N f = 2 and g = 0, we find: , (6.48) which can be identified with the Higgs branch HS of T [SU (2)] up to a factor of −t −1 . This is a special case of a general relation that we discuss in section 6.6.1 below. For g = 2, we have:  (2)]. Mirror symmetry exchanges q and a, and sends t to t −1 , so that: This is indeed satisfied by the formulas above, and can be checked for any t at higher genus as well.

Linear quiver gauge theory
We can generalize the computation of the last subsection to the more general linear quiver theory in Figure 1, with gauge group The mirror properties of this class of theories are well understood from D-brane constructions [83,82].
A-twisted A L quiver. Following (6.18), the integral expression of the A-twisted index reads: with: (6.54) and where R = (r, a) with a = 1, · · · , N r and S = (s, b) with b = 1, · · · , N s (and s, r = 1, · · · , L). Let us first consider the abelian A L quiver theory with (N 1 , · · · , N L ) = (1, · · · , 1) and (M 1 , · · · , M L ) = (1, 0, · · · , 0, 1), for which rk(G) = L. This theory is mirror to N = 4 SQED with N f = L + 1 flavors. In this case, the one-loop determinants (6.54) simplify to: with the understanding that x (0) = x (L+1) = y 1 and m (0) = m (L+1) = 0. As we will explain momentarily, we can choose η = (1, · · · , 1) and sum over the flux sectors m (s) > M for all s, for some integer M . This gives The Bethe equations of the abelian quiver are: Since the original JK residue selects only a subset of poles of the integrand, we need to show that all the selected poles are mapped to the solutions of (6.58). 21 In order to show this, we note that, in the large FI parameter limit (q s → 0), the solution to the equations P (s) = 0 is continuously mapped to a particular pole of the original integrand before the flux summation, which enables us to track the displacement of the poles.
(The trivial solutions which involve x (s) = x (s+1) = 0 should be excluded since they are always located outside of the contour.) Taking this limit, one can see that non-trivial solutions of the equations lim qs→0 P (s) = 0 for all s = 1, · · · , L are simply classified by the L-tuple of charge sets such that, for every component s, there exists at least one charge vector whose s-th component is positive. This is nothing but the charge sets selected by the JK residue prescription. Hence we can write the A-twisted index in terms of the sum over the Bethe roots: These considerations can be straightforwardly generalized to the non-abelian A L quiver. We obtain: H(x) , (6.60) with the Bethe equations: P (s),a (x) = 0 , s = 1, · · · , L, a = 1, · · · , N s , Note that we should exclude the solutions with x (s) for a = b, as well as the trivial solutions of P (s),a (x) = 0. These equations are the Bethe equations of the XXZ SU (L) spin chain. The correspondence between quantum integrable models and 3d N = 4 gauge theories has been studied extensively in the literature [9,70].
For this theory, the Witten index is most easily computed by considering the flux zero sector of (6.53), which also gives the number of gauge-inequivalent solutions to the Bethe equations. 22 We have: is a sum over simple poles with residue ±1 (for 'negatively' and 'positively' charged field components, respectively), this quantity counts the number of poles that passe the JK condition (including the exclusion of poles on the Weyl chamber walls), and the final answer is independent of the fugacities. For instance, for U (N c ) gauge theory with N f hypermultiplets (that is, L = 1, N 1 = N c and M 1 = N f ), one can explicitly check that only the charge sets consisting of the positively charged part of the hypermultiplets only (for η > 0) contribute non-trivially to the JK residue. Hence we have which is the number of massive vacua of that theory.
B-twisted A L quiver. The B-twisted index can be described similarly to (6.53) using the general expression (6.24). By the same reasoning as above, we find:  (0,4) can be written as: This quantity coincides with the one-loop determinant of a one-dimensional N = (0, 4) supersymmetric theory for the same quiver [7]. The mirror symmetry relation (6.14) for twisted indices implies: possibly up to a sign, and similarly for A-and B-twists exchanged. From the perspective of the Bethe-gauge correspondence [9], mirror symmetry between a pair of 3d N = 2 * theories is equivalent to a so-called bispectral duality between the corresponding integrable models [70]. It was argued in [70] that the solutions of the Bethe equations P (s),a (x) = 0 of two mirror quivers are in one-to-one correspondence. The relation (6.65) further implies that the handle-gluing operators H

[T ]
A and H

[Ť ]
B coincide when evaluated on pairs of mirror solutions (x T ,xŤ ) to the Bethe equations. This can be checked explicitly for T [SU (2)], that we consider in the next subsection.

Half-BPS line operators for T [SU (2)]
In this subsection we briefly discuss the matching between half-BPS Wilson loops and vortex loops in the case of the T [SU (2)] self-mirror theory. As in other cases, much of this theory is governed by the Bethe equation. In the description in terms of N = 4 SQED[2] of section 6.4.2, we have: The mirror Bethe equationP (x) = 0 is obtained from (6.66) by the substitution a ↔ q and t → t −1 .
6.5.1 Wilson loops on Σ B g × S 1 As discussed in section 6.1.2, the B-twisted theory admits half-BPS Wilson line operators. The expectation value of the Wilson line operator W (x) can be written as: with The quantum algebra of Wilson loops is therefore given by In particular, W 1 (x) = x is the only independent Wilson loop. All other operators W k (x) = x k , k = 0, 1, can be written in terms W 1 using the relation P (x) = 0. For instance, we find: at genus zero.

The expectation value of an half-BPS vortex loop in the A-twisted T [SU (2)] is given by:
with The vortex loop V (x) mirror to the B-twisted Wilson loop of charge k, W k (x) = x k , can be realized by coupling a certain one-dimensional N = (2, 2) supersymmetric QM to the A-twisted theory [33]. In the UV, the coupling of a 1d GLSM defines a singularity for the 3d gauge field as where e is 3d gauge coupling and µ 1d is a moment map for 1d flavor symmetry. The precise field contents of the 1d GLSM dual to a given Wilson loop was studied in [33] by realizing the mirror symmetry as an S-duality on a system of D-branes. We briefly review the relevant results in Appendix E. The one-dimensional quiver theory mirror to the W k Wilson loop is summarized in Figure 2. It consists of a 1d U (k) theory with N = (2, 2) supersymmetry coupled to one fundamental, one anti-fundamental and one adjoint chiral multiplet. Due to the presence of a cubic superpotential coupling the 1d fundamental, anti-fundamental and the 3d fundamental multiplets, we assign the Q t ≡ 2(H − C) charge to be Q t = 0 for the 1d fundamental and Q t = 1 to the antifundamental. Since the 1d adjoint field is not charged under any of the global symmetry in this case, is has Q adj t = 0. 23 The vortex loop of Figure 2 contributes: Note that we added a factor q − k 2 in front of the integral, which takes into account the flavor Wilson line associated to the 'left NS5 branes' of [33]. Among the poles selected by the JK residue for ξ 1d > 0, only one of the rank-k singularities gives a non-vanishing residue (up to the Weyl symmetry S k ). The residue integral yields (6.75) In other words, ifx is a root of the polynomial P (x) defined in (6.66), then is a root of the mirror polynomial obtained by substituting a ↔ q, t → t −1 . Therefore, the mirror symmetry relations: (a, q, t −1 ) (6.77) directly follow from the statement of the mirror symmetry (at each vacuum) without the defects. The vortex loop defined as above is known to be invariant under the so-called hopping duality [5,33] described in Figure 3. In the A-twisted index, this follows directly from the Bethe equation. We have as expected.

Genus-zero twisted indices and Hilbert series
We observed in a few examples in section 6.4 that the genus-zero A-and B-twisted indices reproduce the Coulomb branch Hilbert series and the Higgs branch Hilbert series, respectively. This is not a coincidence, but can be shown to be true for more general good and ugly N = 4 theories, in the sense of [82]. In this section, we trade the the N = 2 * deformation parameter t with to match with more usual conventions in the HS literature [35,36,37,38,39,40].
Since the Hilbert series can also be obtained from certain limits of the superconformal index [84], it follows that the twisted partition function on S 2 A × S 1 or S 2 B × S 1 can be obtained from the "untwisted" S 2 × S 1 partition function in the same limit. It would be worthwile to study this correspondence more thoroughly.

The B-twisted index and the Higgs branch Hilbert series
The equivalence of the B-twisted index (6.24) with the Higgs branch Hilbert series can be easily shown whenever the contribution from infinity vanishes in the B-twisted index. In such cases, only the zero flux sector contributes. We then have: with .
The result of the JK residue integral can be shown to be equivalent to a 'unit contour' integral |x a | = 1 for a large class of theories (for conveniently chosen fugacities such that all the poles from 'positive' charged field components, and no 'negative' pole, lie inside the unit circle). If that is the case, the twisted index (6.81) becomes the 'Molien formula' for the Higgs branch HS [35,84]: up to a power of y that could be cancelled by turning on a bare CS level for the N = 2 * flavor symmetry U (1) t .
As an example, consider the A L quiver theory of subsection 6.4.3. In order to show that only the m = 0 flux sector contributes to the g = 0 B-twisted index, we need to prove that the residues at x (s) a = 0 and x (s) a = ∞ vanish for every flux sector. Let us first examine the limit x (s) a → 0. The integrand scales as: in that limit, which converges when This is precisely the condition for the quiver to be 'good' or 'ugly' in the classification of [82]. In these cases, there is no singularity at x For the T [SU (N )] theory (the case N = (1, 2, · · · , N − 1) and M = (0, · · · , 0, N )), we can show that the unit circle integral defined by |x a | = 1 is indeed equivalent to the JK residue integral. First of all, we choose η = (1, · · · , 1) and fix y > 1. Let us start with the condition for the first node. From the JK condition, the charge set should contain one of the poles defined by i | = 1 for s = 1, these are all the singularities inside the unit circle |x 1 | = 1. The same argument holds for the second node. We need at least one positively charged chiral fields in a form 1−x (2) i (x j y 1/2 = 0, by the same reasoning as above, the residues are zero due to the vector multiplet. This continues to the (n − 1)-th node of the quiver, which completes the proof of the equivalence between the two prescriptions.

The A-twisted index and the Coulomb branch Hilbert series
The relation (6.83) combined with mirror symmetry implies that the Z S 2 B ×S 1 parition function is similarly related to the Coulomb branch Hilbert series first constructed in [38]. Since the genus-zero A-twisted index receives contributions from an infinite number of flux sectors, a direct proof of this equivalence is expected to be rather more complicated. Here and in Appendix F, we check that relation in some of the simplest examples. We leave a more general study for future work.
For N = 4 SQED with N f hypermultiplets, the genus-zero A-twisted index (6.35) can be evaluated by trading the residues over the fundamental chiral multiplets, which are picked by the JK residue prescription for η > 0, with the residues at infinity on M ∼ = C * . For η > 0, only the flux sectors m > 0 contribute. The poles of the integrand of (6.35) (for g = 0) are located at x = 0, x = ∞, and x = y i y 1 2 , using the notation (6.80). We have: This reproduces (6.40) and the Coulomb branch series of [38] as advertised. Similar manipulations can be performed for higher-rank gauge groups, as demonstrated for U (2) in Appendix F.

A. Conventions: geometry and quasi-topological twisting
We follow the conventions of [42,43,12] for geometry, spinors and supersymmetry multiplets. We consider a compact Euclidean space-time M 3 = Σ g × S 1 with Riemannian metric: Here t ∼ t + 2π is the coordinate on S 1 and z,z are local complex coordinates on the Riemann surface Σ g . We have the standard spin connection: in terms of the Levi-Civita connection ∇ µ . We generally denote by D µ the covariant derivatives on spinors and tensors in the frame basis. The Riemann tensor is defined in the standard way. 24 We use the canonical frame e a = e a µ dx µ with: Here a = 0, 1,1 are the frame indices in complex coordinates; they are lowered using δ ab with δ 00 = 1 and δ 11 = 1 2 . We also chose the orientation such that 011 = −2i. The γ-matrices in this frame are: Three-dimensional Dirac spinors are denoted by: Dirac indices can be raised and lowered with αβ , αβ with −+ = +− = 1. When reducing to two dimensions along ∂ t , the spinor components ψ ∓ become kinematically independent Weyl spinors of spin ± 1 2 , respectively. The covariant derivative on a Dirac spinor is given by: In section 2, we generally use explicit frame indices for all quantities including derivatives.
The coordinates (t, z,z) are adapted to a choice of transverse holomorphic foliation (THF) on M 3 as explained in [42,43]. Let us define η µ a nowhere-vanishing vector such that η µ η µ = 1 .
We can define: The THF can be characterized by such an η µ 25 satisfying the integrability condition: The object Φ µ ν reduces to a complex structure on the normal bundle of the foliation (i.e. for vectors orthogonal to η µ ). In our case, this is just the complex structure on the Riemann surface Σ g . We then have natural three-dimensional notions of holomorphic vectors and one-forms [43].

A.1 Quasi-topological twisting
The quasi-topological twisting that we use in this paper is best understood in the context of curved-space rigid supersymmetry [85,86]. In section 2, we used a 'twisted field' notation for all the fields. This corresponds to a field redefinition of the fermionic and bosonic fields, where the "A-twisted fields" are obtained by various contractions with the Killing spinors (2.6). On Σ g × S 1 , we can label the fields by their U (1) L spin L on Σ g . The quasi-topological twisting is equivalent to the standard topological A-twist on Σ g , which assigns to all the fields a twisted spin: with R the U (1) R N = 2 R-charge. We refer to the Appendix of [12] for a more thorough discussion in two-dimensions. As an example, consider the N = 2 vector multiplet V. In the standard notation of [42], it has components: Using the Killing spinors ζ, ζ on Σ g × S 1 , we defined the 'twisted' gaugini: They are holomorphic and anti-holomorphic one-forms with respect to the THF, as can be shown from the Killing spinor equations or by explicit computation in components. This gives (2.9). The A-twist of the chiral multiplets discussed in [12] can also be given a three-dimensional uplift along the lines of [86].

B. Localization of N = 2 YM-CS-matter theories
In this Appendix, we derive the main localization formula (2.59) for the twisted index of N = 2 gauge theories. The main technical difficulty lies in the treatment of the fermionic zero modes, and we can mostly follow the previous literature on the subject [15,6,7,8,12]. The new ingredient is the integration of the g additional one-forms gaugini and flat connections present due to the non-trivial topology of Σ g . They correspond to holomorphic sections of K r 2 ⊗L Q (of total degree d = r(g −1)+Qm) on Σ g , with L the U (1) line bundle. The fermionic zero modes correspond to modes of the fermionic field C such that: corresponding to holomorphic sections of K 2−r 2 ⊗L −Q . Let n B and n C denote the number of bosonic and fermionic zero-modes, respectively. By the Riemann-Roch theorem: Resumming the KK tower from the S 1 , we find the one-loop determinant [8]: so thatD = 0 on the supersymmetric locus. A general supersymmetric configuration also includes flat connections along Σ g : .
There are also fermionic zero-modes: Here Λ 0 , Λ 0 are constant and the one-form-valued gaugini satisfy D1Λ 1 = 0, D 1 Λ 1 = 0. All these constant modes organize themselves into supersymmetry multiplets: V 0 = (σ , a 0 , λ , λ ,D) , V I = (α I , α I , Λ I , Λ I ) , I = 1, · · · , g . (B.9) Consider the chiral multiplet Φ with Q = 1, in the background (B.9). We have: in terms of the kinetic Lagrangian (2.20), which can be used for localization since it is Q-exact: Integrating out all the massive fields in the Coulomb branch background (B.9), we obtain a complicated supersymmetric matrix model for the constant modes (B.9). Schematically, we find: where the limit in front is a particular scaling that we will discuss in a moment. Here we defined the measure: 26 At this point, for future convenience, we perform a change of variable u → u and Λ 0 → Λ 0 , according to the relation for a small positive number k 2 , leaving u unchanged. Note that the measure in (B.12) is invariant under this change of variable. The purpose of this rescaling will become clear momentarily.
Since the one-loop determinant contributions to Z m potentially have singularities at points where chiral multiplets become massless, let us examine these dangerous regions of the integrand before performing the path integral, following [15]. Near a singular point region u = 0 (any other singularity of the form u = u * in the bulk can be considered similarly by translation) the bosonic part of the chiral multiplet reads: where N is the number of chiral multiplets which become massless at u = 0. Note that the point {u = 0} ∈ M is singular when we take the localization limit e → 0. This singularity can be regularized by keeping e finite until we perform the u integrals. Then the integral is bounded by where C is a numerical factor which is independent of e. Given this, we divide the integral (B.12) into two pieces: where ∆ is the epsilon neighborhood of the singular region defined by u u ≤ 2 . When e is small but finite, the second factor is bounded by Cπ 2 /e 2N , which vanishes after we take the limit → 0 first. Then we are left with the contribution from the first term, given that the condition e N 1 is satisfied. This is the scaling limit implied in (B.12). Now, let us first perform the integral over the scalar gaugino zero-modes Λ 0 , Λ 0 . Due to the residual supersymmetry, the integrand of (B.12) satisfies: We can use this relations to perform the integral over Λ 0 , since: We have the sum of two total derivatives. The integration over the Σ g flat connections α I is a compact domain and the integrand has no singularities as long as > 0, therefore the total derivatives ∂ α in (B.19) do not contribute to the path integral. We are left with: which reduces the integral over M to an integral over the boundary ∂∆ , by Stokes theorem.
Next, let us evaluate Z m . In addition to the classical contribution, the important contributions are the one-loop superdeterminant (B.10) at Λ 0 = Λ 0 = 0, for every chiral multiplets in the theory. To compute (B.10), we first expand any three-dimensional field in Fourier modes on S 1 : It is convenient to define the two-dimensional variables: Note that we are using the rescaled variable u . Let us also denote by {λ} the spectrum of the twisted Laplacian on Σ g : We then have: The first factor in (B.24) is the contribution from the chiral multiplet zero-modes at Λ 0 = Λ 0 = 0: (B.25) At D = 0, this gives (B.4) after regularizing the product over n: 27 The second factor in (B.24) is the contribution from all the other modes: (B.27) Note the appearance of the gaugino zero-modes, with the short-hand notation: We first perform theD-integrals in (B.20). This is essentially the same the discussion in the previous literatures [7,8]. Let ∆ be the union of small circular neighborhoods of radius 2 around the potential singularities on the classical Coulomb branch M ∼ = C * at: corresponding to matter field and monopole operator singularities, respectively. To each potential singularity, we associate its charge, as explained in the main text: are the monopole operator gauge charges. In each flux sector m, only some of the potential singularities are actual singularities. We have a singularity at H i if Q i m + 27 Note that the regularized product is not invariant under large gauge transformations u → u + 1. This is a manifestation of the so-called parity anomaly [87]. In a physical theory, this lack of gauge invariance for an odd number of Dirac fermions must be compensated by an half-integer CS level. ,m are modified to that ofD = 0 and a contour that passes negative imaginary axis, where the latter contribution can be deformed away to give a vanishing contribution. For ∆ (−) ,m , the contour can be deformed away to infinity. We set β = 1 for simplicity. n i + (g − 1)(r i − 1) > 0 and a singularity at H ± if Q ± m + Q F ± n F + (g − 1)r ± ≥ 0see equation (2.66). We denote by M m sing the union of all the singularities in a given flux sector. As alluded to in the main text, we have to assume that each singularity is projective, meaning that to each singular point we only associate either positive or negative charges. A non-projective singularity can often be rendered projective by turning on generic fugacities. We denote by ∆ ,m the circular neighborhood of the singularities in a given flux sector. Since every singularity is projective by assumption, ∆ ,m is the union of 'positive' and 'negative' singularities: The integration contour ofD is taken along the real direction with a slight shift along the imaginary axis: The auxiliary parameter η in the JK residue (2.59) is such that ηδ > 0. Let us choose η > 0 for definiteness. Then, for the contour ∂∆ ,m , the singularities in theD plane are depicted on the leftmost figure in Figure 4. Note that, as long as |δ| > 0, the integrand is bounded. TheD contour can be deformed to the one shown in the middle of Figure 4, which consists of a small contour aroundD = 0 and of a contour in the lower-half plane. The latter contribution can be deformed away along the negative imaginary axis. Since the integrand evaluated on this latter contour is finite, the contour integral around ∂∆  Figure 4, which can be similarly deformed away to give a vanishing answer. To summarize, at the singularity defined by the hyperplane H i , we get in the case η > 0. Similarly, in the case η < 0 one can show that Z i = 0 if Q i > 0 while we pick minus theD = 0 pole if Q i < 0. We will come back to the contributions of the 'monopole singularities' u = ∓i∞ in a moment, but for the time being we can note that they can be treated essentially like in [8,12]. Note that, until this point, Z m | Λ 0 = Λ 0 =0 still has a dependence on the Λ 1 , Λ1 zero modes and on the Σ g flat connections, which must be integrated over. In order to integrate out these zero-modes, let us define We can now use the fact that we have introduced a rescaled variable u = u /k 2 with a positive number k 2 . Note that we are free to choose k to our convenience in order to compute f (λ, n), since all the contributions from the one-loop determinants, from the classical action and from the measure are independent of u after theD integral. We will take k arbitrarily small (which is equivalent to a large σ n limit), so that only the small t expansion of the heat kernel: contributes to (B.40). The first few coefficients a 0 , a 1 , · · · of (B.41) are known to be spectral invariants [88,89]. In particular, we have: which is also known as Weyl's law. Performing the t integral in (B.40), we obtain: (B.43) First, let us consider contributions from s = 1. On the contour ∂∆ where σ n σ n = 2 , the l ≥ 1 terms are bounded by the expression which vanishes if we take the limit k . When a contour is defined for the boundary component u u → ∞, the first term dominates as well. Therefore, only the first term remains: To summarize, the dependence on Λ 1 and Λ1 can be written as 28 Here a, b labels the gauge group indices for any higher-rank G. where Note that it can be written in terms of the three-dimensional twisted effective superpotential W matter : in general. As an important consistency check, consider the classical Chern-Simons action (2.13) on this background (with Λ 0 = Λ 0 = D = 0): The classical and one-loop terms come with the correct relative coefficients to reproduce the full twisted superpotential. This one-loop contribution and the contributions from the classical action are independent of α I , α I , and they have a simple dependence in the gaugini Λ I , Λ I . This allows us to perform the integral over these zero modes explicitly, which leads to the insertion of the Hessian determinant of the twisted superpotential: (B.52) Note that all the contributions are holomorphic in u after theD integral and after taking the k → 0 limit. This allows us to tune → 0, while the result of the u-plane residue integral does not change. 29 The monopole singularities H ± at u = ∓i∞ can be discussed in the similar way as in [8,12], which we briefly summarize below. For this purpose, we need to compute the dependence ofD linear part in the ln Z massive in the limit u = ∓i∞. It reads in large Im(u). This can be evaluated from the observation 29 We encountered several order of limits that we should be careful about. To summarize, the correct prescription is the following: 1) perform theD-integral; 2) take k → 0; 3) take → 0; 4) take e → 0.
with H ab defined in (B.48). Integrating back, we find 30 From here and onwards, we will set vol(Σ g ) = 1. Taking the limit Im(u) → ∓∞, we get theD dependence at infinity which is where Q ± is defined in (2.53). It is convenient to work with the rescaled variablê D = e 2D . We have For the singularity at infinity, we can take e → 0 before doing theD integral since the matter integrals are regulated with infinite mass. We take the limit e → 0 at the same time as taking |u| → ∞ in such a way that e 2 |u| → a for some finite number a > 0. Then we have Suppose that we have aD integral defined at Γ + with positive δ as in Figure 4. Then theD contour integral can be done as follow. When Im(u) → −∞, we have On the other hand, when Im(u) → ∞, we have If we choose η < 0, the poles associated to Q ± < 0 contribute instead. Finally, let us consider theories with k eff = 0 (at either infinity). In this case, we can turn on an auxiliary (Q-exact) FI parameter ξ/e 2 which only couples toD. Then the integral at infinity reads: Since the choice of η is arbitrary, we can set η = ξ such that there is never any contribution from the singularities at infinity. Since the 3d theory does not suffer from wall-crossing phenomena, the answer should not depend on the choice of auxiliary FI parameter ξ = η. The integration over Λ I , ΛĪ and α I , α I can be done in exactly same way as in the bulk singularities discussed above, resulting in a H(u) g insertion to the path integral.

B.3 The general case
The generalization to the higher rank G involves technical difficulties due to the nontrivial topology of the M\ M m sing . However, given the detailed discussion of rank one theory, the generalization to the higher rank G follows directly from the discussions in the previous literatures [6,7,8,12]. The additional ingredient is the insertion of the H(u) g , resulting from the one-form gaugino zero modes. The final answer can be written as a Jeffrey-Kirwan residue: where M m sing contains all the singularities from H i and H ± . This formula is discussed in details in section 2.5.

C. Decoupling limits for 3d N = 2 SQCD in flat space
In this Appendix, we briefly review Seiberg dualities for the three-dimensional N = 2 supersymmetric SQCD[k, N c , N f , N a ] of section 5. Starting from Aharony duality [24] for SQCD[0, N c , N f , N f ], we derive all the other Seiberg dualities [26,28] by real mass deformations. 31 31 We follow the analysis of [28] but choose somewhat better conventions. Thus the results of this Appendix for the relative flavor CS terms across dualities look a bit different from the ones of [28]. (In [28], the U (1) A and U (1) R symmetries were mixed with the gauge symmetry, corresponding to setting k gR = k gA = 0. For that reason, the R-and flavor charges of the monopole operators in that reference were not necessarily integer-quantized.) In three dimensions, the two-point function of conserved currents contains an interesting conformally-invariant contact term, whose corresponding local term is a Chern-Simons functional for background gauge fields [90,28,44]. Whenever the CS levels are quantized-that is, if the corresponding symmetry group is compact, these contact terms are physical up to integer shifts of the 'global' CS levels [44]. While the global CS levels of a given theory can be specified arbitrarily, their relative values might differ across dualities. As part of the description of the duality, we need to specify the relative CS levels: where k F , k D F are the global CS levels in the original theory and in the dual theory, respectively.

C.1 Aharony duality and real mass deformations
Consider a U (N c ) YM theory with vanishing CS level, with N f pair of fundamental and anti-fundamental chiral multiplets Q i (i = 1, · · · , N f ) and Q j (j = 1, · · · , N f ), and a vanishing superpotential. The theory has a flavor symmetry group SU (N f ) × SU (N f ) × U (1) A × U (1) T and a R-symmetry U (1) R , under which the matter fields have charges: Most of the classical U (N c ) Coulomb branch of this theory is lifted by an instantongenerated superpotential [53,54], but the overall U (1) direction remains, parameterized with the two monopole operators T ± with charge ±1 under the topological symmetry U (1) T . (The operator T ± (x) inserts a magnetic flux (±1, 0, · · · , 0) at x ∈ R 3 .) The two operators T ± have induced U (1) A and R-charges given by: Let M j i = Q j Q i be the gauge-invariant 'mesons', which parameterize the Higgs branch. We consider the case N f ≥ N c , which preserves both the R-charge and supersymmetry. For N f = N c , the IR theory can be described as a σ-model for the mesons and for two additional chiral multiplets T ± identified with the monopole operators, interacting through the superpotential [53]: A particular instance is for N f = N c = 1, which is the SQED/XY Z-model duality considered in section 3.2. For N f > N c , there is a dual description in terms of an U (N f − N c ) gauge group with N f fundamental and antifundamental chiral multiplets q i , q j and the gauge singlets M j i , T + and T − , with superpotential: where t ± are the monopole operators of the dual gauge group [24]. The quantum numbers of the dual matter fields are summarized in Table 4 on page 38. Finally, all the relative flavor CS levels (C.1) vanish for this duality. Starting from this duality, we derive the Seiberg-like dualities of the other N = 2 U (N c ) YM-CS-matter theories with fundamental and antifundamental matter, which we dubbed SQCD[k, N c , N f , N a ] in section 5. If we turn on a large real mass m 0 for a global symmetry U (1) 0 , we generate the CS levels: for all abelian symmetries U (1) I , U (1) J and U (1) R , and similarly for any non-abelian symmetry. Here the sum runs over all chiral multiplet field components with charges Q I i and R-charge r i . by integrating out k − k c fundamental chiral multiplets Q α with positive real mass and k + k c antifundamental chiral multiplets Q β with positive real mass, while the remaining N f fundamental chiral multiplets Q i and N a antifundamental chiral multiplets Q j remain light. The corresponding real mass m 0 > 0 is such that: in the limit m 0 → ∞. We also need to scale the FI term as: Table 7: Charges of the matter fields in the U (n − N c ) Aharony dual theory used to derive the Seiberg dual of SQCD with k > k c ≥ 0. Here r T = −n(r − 1) − N c + 1.
in order for the effective FI parameter ξ eff = ξ − k c |m 0 | to remain finite. This means that the symmetry U (1) 0 contains a mixing with U (1) T . The charges of the 'electric' theory U (N c ) with n f flavors are: Here the U (1) 0 charge is indicated in the last column. Sending m 0 → ∞, we integrate out Q α and Q β and obtain the CS levels: for the gauge CS levels. We also generate the following flavor CS levels: We also generate a level k RR , which we will ignore throughout because such terms do not play any role on Σ g × S 1 . All other flavor CS levels vanish. We can follow the same RG flow in the Aharony dual U (n − N c ) theory. The dual matter fields are summarized in Table 7. Integrating out all the fields with Q 0 = 0, we generate the gauge CS levels: and the flavor CS levels: and all other mixed CS levels vanishing. From (C.10) and (C.12), we find the relative global CS levels (5.42)-(5.43).
with CS level k > 0 and k c > k. This theory can be obtained from SQCD[0, N c , N f , N f ] by integrating out k c +k antifundamental multiplets Q β with positive real mass and k c − k antifundamental multiplets Q γ with negative real mass. The relevant real mass m 0 is such that: in the limit m 0 → ∞. We also need to scale the FI term as: 14) The charges of the fields in the 'electric' theory with N f flavors are: Integrating out the massive fields generates the gauge CS levels: 15) and the global CS levels: The charges of the fields in the dual field theory in the UV are given in Table 8. Integrating out the massive fields, we obtain a U (N f − N c ) theory at CS level −k with the mixed CS levels (5.46). We easily verify that the relative CS levels are given by (5.47).  The limiting case k = k c is obtained by the same reasoning as in the previous subsection.
The only difference is that the singlet T + in the Aharony dual remains massless-see Table 8.
In this case, the singlet T + is dual to the 'half' Coulomb branch that survives in the U (N c ) kc theory. The U (N f − N c ) dual theory also contain a superpotential W = q j M j i q i + T + t + , (C. 17) coupling T + to a monopole of the dual gauge group. In the particular case N c = N f , the gauge theory is dual to a free theory of N f N a + 1 chiral multiplets M j i and T + . The case with N c = N f = 1 and N a = 0 was considered in section 3.3.

D. Proving the equality of Seiberg-dual indices
In this Appendix, we briefly explain how to prove the equality of the twisted indices between the Seiberg dual theories considered in section 5.2. Consider SQCD[k, N c , N f , N a ] with k ≥ 0 and k c ≥ 0, which is governed by the characteristic polynomial of degree n: Identities satisfied by P (x). From the factorization: we obtain a useful identity for the product of all the roots: where we defined:p Note that we used (5.13) in the above equations. Similarly, we find: (y i − y j ) .
Explicit form of u and h. By direct computation, we can show that: Here u M and h M are the contributions of the mesons M j i defined in (5.27). We also introduced the quantities The remaining factors in (D.8) read: with Q A ± and r − given by (5.5) and (5.13). One can evaluate these terms in the four cases k = k c = 0, k > k c ≥ 0, k c > k ≥ 0 and k = k c > 0, to complete the proof the equality of the twisted indices across the corresponding Seiberg dualities.

E. Vortex-Wilson loop duality in N = 4 theories
In this section, we briefly review some of the results of [33], where the duality mapping between half-BPS Wilson loops and vortex loops under 3d N = 4 mirror symmetry was studied. For N = 4 quiver theories engineered in type IIB string theory, it was shown that the vortex loop mirror to a Wilson loop in a given representation R of G can be described by a 1d supersymmetric quantum mechanics, which can be read off from the brane configuration. On general ground, such 1d GLSMs coupled to the three-dimensional theory provide a useful UV descriptions of vortex loop operators.
For example, the charge k Wilson loop in T [SU (2)] has a brane construction in terms of k fundamental strings, shown on the left in Figure 5. In the S-dual brane configuration, the k D1-branes can be moved along the D3-brane, so that they end up on top of the left NS5-brane or if the right NS5-brane. The field content of the 1d worldvolume theory on the D1-brane can be read off in either case as a quiver shown in Figure 6. The two quiver descriptions are two distinct but IR-equivalent realizations of the vortex loop, which is known as hopping duality [33].  One can construct the dual vortex loops for more general non-abelian theories using a similar argument. These results have been also confirmed via the S 3 partition function [33]. Let us consider a U (N 1 ) gauge theory coupled to N 2 + N 3 fundamental hypermultiplets, which we split into two groups N 2 , N 3 (splitting the stacks of D5branes in two, in the analog of Figure 5). For simplicity, we consider a Wilson loop in the k-symmetric representation of U (N 1 ), corresponding to k stretched F-strings. The 1d theory which is dual to that Wilson loop can be obtained from the quiver in Figure 7.
When considering vortex loops in the twisted theory on Σ g (as compared to vortex loops in flat space-time), we have to be careful about the R-charge assignment. The cubic superpotential among 3d fundamental (Q), 1d fundamental (q) and 1d antifundamental ( q) requires that the sum of U (1) H charges to be 1. Finally, the 1d the adjoint multiplet (A) is not charged under the R-symmetries. Hence the R-charge assignment reads: Therefore, the QM index of the 1d theory reads: V k(±) (x, a, t) = −y p t −1/2 + u i t 1/2 y p t 1/2 − u i t −1/2 .

(E.2)
Here R adj is a regulator, to be sent to zero at the end of the computation. Note that the D1-branes in between two left (or right) NS5 branes induce an additional flavor Wilson line factor in (E.2). When the defect is attached to the left (right) NS5-brane, we have the flavor Wilson loop factor q |R| L = q −k/2 or q |R| R = q k/2 , respectively [33]. Let us focus on the D1-branes attached to the left NS5-brane. The set of poles selected by the JK residue and with non-vanishing residue are given as follows. The contributing poles are classified by the integer set {k a ≥ 0, a = 1, · · · , N 1 }, which satisfies k = N 1 a=1 k a . For each set, the positions of the poles are at {u i=1,··· ,k } = {x a , x a t 2R , x a t 4R , · · · , x a t (ka−1)R , for a = 1, · · · , N 1 } .
(E.3) Different mappings of u i 's to elements of the RHS give the same residue due to the Weyl symmetry, which cancels the factor 1 k! of (E.2). Evaluating the residue and taking the limit R adj → 0, we end up with Suppose that there exists another 3d node with rank N 3 which is connected to the N 1 node by a 3d bifundamental. Then, applying the three-dimensional Bethe equation for the U (N 1 ) theory to each term of (E.4), we obtain an alternative expression: This is simply the expression for V k(+) (x), the vortex loop which is attached to the right NS5-brane in the brane construction. The existence of two distinct UV descriptions of an IR vortex loop is known as "hopping duality" [5,33].

F. Coulomb branch Hilbert series for an N = 4 U (2) theory
In this appendix, we show that the A-twisted index for an N = 4 U (2) gauge theory with n fundamental hypermultiplets reproduces the monopole formula [38] of the Coulomb branch Hilbert series.
Consider the expression (6.53) with G = U (2). In order to perform the integral at each flux sector, we pick the η = (1, 1). In this case, the sum over the flux sectors for the twisted index can be decomposed into the following expression Note that the charge sets involving x 1 = x 2 y −1 do not contribute even though they pass the JK condition. The hyperplane equation x 1 = x 2 y −1 evaluated at x 2 = a q y 1/2 imposes the condition x 1 = a q y −1/2 , where we have a zero of order m 1 . Since the order of the pole is (1 + m 1 − m 2 ) + m 2 , this singularity always has a vanishing residue. Since the only poles on the x 1 plane are x 1 = 0, ∞, y p y 1/2 , x 1 = x 2 y −1 , the residue integral on the x 1 plane can be converted into: = res The last equation follows from the fact that after taking residues at x 1 = 0, ∞, the only remaining poles on the x 2 plane are x 2 = y q y 1/2 and x = 0, ∞. 32  Then we can evaluate the residue integral explicitly, which yields ∞ m 1 =1 x α − 1 x α y 1/2 − y −1/2 δm 1 ,m 2 which reproduces the monopole formula of the N = 4 U (2) gauge theory with n fundamental hypermultiplets, up to prefactor which can be defined away by turning on a background CS level for U (1) t . Note that the integral in the last factor is a unit circle contour integral, which includes the residue at x 1 = x 2 y and x 1 = 0. This factor can be evaluated as 1 2 where the second factor in the RHS corresponds to the Casimir invariant for the U (2) gauge group.