Modular and duality properties of surface operators in N=2* gauge theories

We calculate the instanton partition function of the four-dimensional N=2* SU(N) gauge theory in the presence of a generic surface operator, using equivariant localization. By analyzing the constraints that arise from S-duality, we show that the effective twisted superpotential, which governs the infrared dynamics of the two-dimensional theory on the surface operator, satisfies a modular anomaly equation. Exploiting the localization results, we solve this equation in terms of elliptic and quasi-modular forms which resum all non-perturbative corrections. We also show that our results, derived for monodromy defects in the four-dimensional theory, match the effective twisted superpotential describing the infrared properties of certain two-dimensional sigma models coupled either to pure N=2 or to N=2* gauge theories.


Introduction
The study of how a quantum field theory responds to the presence of defects is a very important subject, which has received much attention in recent years especially in the context of supersymmetric gauge theories. In this paper we study a class of two-dimensional defects, also known as surface operators, on the Coulomb branch of the N = 2 SU(N ) gauge theory in four dimensions 1 . Such surface operators can be introduced and analyzed in different ways. They can be defined by the transverse singularities they induce in the four-dimensional fields [2,3], or can be characterized by the two-dimensional theory they support on their world-volume [4,5].
A convenient way to describe four-dimensional gauge theories with N = 2 supersymmetry is to consider M5 branes wrapped on a punctured Riemann surface [6,7]. From the point of view of the six-dimensional (2, 0) theory on the M5 branes, surface operators can be realized by means of either M5 or M2 branes giving rise, respectively, to codimension-2 and codimension-4 defects. While a codimension-2 operator extends over the Riemann surface wrapped by the M5 brane realizing the gauge theory, a codimension-4 operator intersects the Riemann surface at a point. Codimension-2 surface operators were systematically studied in [8] where, in the context of the of the 4d/2d correspondence [9], the instanton partition functions of N = 2 SU(2) super-conformal quiver theories with surface operators were mapped to the conformal blocks of a two-dimensional conformal field theory with an affine sl (2) symmetry. These studies were later extended to SU(N ) quiver theories whose instanton partition functions in the presence of surface operators were related to conformal field theories with an affine sl(N ) symmetry [10]. The study of codimension-4 surface operators was pioneered in [11] where the instanton partition function of the conformal SU(2) theory with a surface operator was mapped to the Virasoro blocks of the Liouville theory, augmented by the insertion of a degenerate primary field. Many generalizations and extensions of this have been considered in the last few years [12][13][14][15][16][17][18][19].
Here we study N = 2 theories in the presence of surface operators. The low-energy effective dynamics of the bulk four-dimensional theory is completely encoded in the holomorphic prepotential which at the non-perturbative level can be very efficiently determined using localization [20] along with the constraints that arise from S-duality. The latter turn out to imply [21,22] a modular anomaly equation [23] for the prepotential, which is intimately related to the holomorphic anomaly equation occurring in topological string theories on local Calabi-Yau manifolds [24][25][26][27] 2 . Working perturbatively in the mass of the adjoint hypermultiplet, the modular anomaly equation allows one to resum all instanton corrections to the prepotential into (quasi)-modular forms, and to write the dependence on the Coulomb branch parameters in terms of particular sums over the roots of the gauge group, thus making it possible to treat any semi-simple algebra [41,42].
which governs the infrared dynamics on the world-volume of the two-dimensional surface operator in the N = 2 theory. For simplicity, we limit ourselves to SU(N ) gauge groups and consider half-BPS surface defects that, from the six-dimensional point of view, are codimension-2 operators. These defects introduce singularities characterized by the pattern of gauge symmetry breaking, i.e. by a Levi decomposition of SU(N ), and also by a set of continuous (complex) parameters. In [45] it has been shown that the effect of these surface operators on the instanton moduli action is equivalent to a suitable orbifold projection which produces structures known as ramified instantons [45][46][47]. Actually, the moduli spaces of these ramified instantons were already studied in [48] from a mathematical point of view in terms of representations of a quiver that can be obtained by performing an orbifold projection of the usual ADHM moduli space of the standard instantons. In Section 2 we explicitly implement such an orbifold procedure on the non-perturbative sectors of the theory realized by means of systems of D3 and D(−1) branes [49,50]. In Section 3 we carry out the integration on the ramified instanton moduli via equivariant localization. The logarithm of the resulting partition function exhibits both a 4d and a 2d singularity in the limit of vanishing Ω deformations 3 . The corresponding residues are regular in this limit and encode, respectively, the prepotential F and the twisted superpotential W. The latter depends, in addition to the Coulomb vacuum expectation values and the adjoint mass, on the continuous parameters of the defect.
In Section 4 we show that, as it happens for the prepotential, the constraints arising from S-duality lead to a modular anomaly equation for W. In Section 5, we solve this equation explicitly for the SU(2) theory and prove that the resulting W agrees with the twisted superpotential obtained in [35] in the framework of the 4d/2d correspondence with the insertion of a degenerate field in the Liouville theory. Since this procedure is appropriate for codimension-4 defects [11], the agreement we find supports the proposal of a duality between the two classes of defects recently put forward in [52]. In Section 6, we turn our attention to generic surface operators in the SU(N ) theory and again, order by order in the adjoint mass, solve the modular anomaly equations in terms of quasi-modular elliptic functions and sums over the root lattice.
We also consider the relation between our findings and what is known for surface defects defined through the two-dimensional theory they support on their world-volume. In [5] the coupling of the sigma-models defined on such defects to a large class of fourdimensional gauge theories was investigated and the twisted superpotential governing their dynamics was obtained. Simple examples for pure N = 2 SU(N ) gauge theory include the linear sigma-model on CP N −1 , that corresponds to the so-called simple defects with Levi decomposition of type {1, N − 1}, and sigma-models on Grassmannian manifolds corresponding to defects of type {p, N −p}. The main result of [5] is that the Seiberg-Witten geometry of the four-dimensional theory can be recovered by analyzing how the vacuum structure of these sigma-models is fibered over the Coulomb moduli space. Independent analyses based on the 4d/2d correspondence also show that the twisted superpotential for the simple surface operator is related to the line integral of the Seiberg-Witten differential over the punctured Riemann surface [11]. In Section 7, we test this claim in detail by considering first the pure N = 2 gauge theory. Since this theory can be recovered upon decoupling the massive adjoint hypermultiplet, we take the decoupling limit on our N = 2 results for W and precisely reproduce those findings. Furthermore, we show that for simple surface defects the relation between the twisted superpotential and the line integral of the Seiberg-Witten differential holds prior to the decoupling limit, i.e. in the N = 2 theory itself. The agreement we find provides evidence for the proposed duality between the two types of descriptions of the surface operators.
Finally, in Section 8 we present our conclusions and discuss possible future perspectives. Some useful technical details are provided in four appendices.
2 Instantons and surface operators in N = 2 SU(N ) gauge theories The N = 2 theory is a four-dimensional gauge theory with N = 2 supersymmetry that describes the dynamics of a vector multiplet and a massive hypermultiplet in the adjoint representation. It interpolates between the N = 4 super Yang-Mills theory, to which it reduces in the massless limit, and the pure N = 2 theory, which is recovered by decoupling the matter hypermultiplet. In this paper, we will consider for simplicity only special unitary gauge groups SU(N ). As is customary, we combine the Yang-Mills coupling constant g and the vacuum angle θ into the complex coupling on which the modular group SL(2, Z) acts in the standard fashion: with a, b, c, d ∈ Z and ad − bc = 1. In particular under S-duality we have The Coulomb branch of the theory is parametrized by the vacuum expectation value of the adjoint scalar field φ in the vector multiplet, which we take to be of the form The low-energy effective dynamics on the Coulomb branch is entirely described by a single holomorphic function F, called the prepotential, which contains a classical term, a perturbative 1-loop contribution and a tail of instanton corrections. The latter can be obtained from the instanton partition function and Z k is the partition function in the k-instanton sector that can be explicitly computed using localization methods 4 . For later purposes, it is useful to recall that the weight q k in (2.5) originates from the classical instanton action where in the last step we used the fact that the second Chern class of the gauge field strength F equals the instanton charge k. Hence, the weight q k is simply e −S inst . Let us now introduce a surface operator which we view as a non-local defect D supported on a two-dimensional plane inside the four-dimensional (Euclidean) space-time (see Appendix B for more details). In particular, we parametrize R 4 C 2 by two complex variables (z 1 , z 2 ), and place D at z 2 = 0, filling the z 1 -plane. The presence of the surface operator induces a singular behavior in the gauge connection A, which has the following generic form [8,45]: as r → 0. Here (r, θ) denotes the set of polar coordinates in the z 2 -plane, and the γ I 's are constant parameters, where I = 1, · · · , M . The M integers n I satisfy and define a vector n that identifies the type of the surface operator. This vector is related to the breaking pattern of the gauge group (or Levi decomposition) felt on the two-dimensional defect D, namely SU(N ) → S U(n 1 ) × U(n 2 ) × · · · × U(n M ) . (2.10) The type n = {1, 1, · · · , 1} corresponds to what are called full surface operators, originally considered in [8]. The type n = {1, N − 1} corresponds to simple surface operators, while the type n = {N } corresponds to no surface operators and hence will not be considered.
In the presence of a surface operator, one can turn on magnetic fluxes for each factor of the gauge group (2.10) and thus the instanton action can receive contributions also from the corresponding first Chern classes. This means that (2.7) is replaced by [2,8,11,45] where η I are constant parameters. As shown in detail in Appendix B, given the behavior (2.8) of the gauge connection near the surface operator, one has with m I ∈ Z. As is clear from the second line in the above equation, each m I represents the flux of the U(1) factor in each subgroup U(n I ) in the Levi decomposition (2.10); furthermore, these fluxes satisfy the constraint Using (2.12), we easily find where in the last step we have combined the electric and magnetic parameters (η I , γ I ) to form the M -dimensional vector This combination has simple duality transformation properties under SL(2, Z). Indeed, as shown in [2], given an element M of the modular group the electro-magnetic parameters transform as Combining this with the modular transformation (2.2) of the coupling constant, it is easy to show that t I → t I cτ + d . (2.17) In particular under S-duality we have (2.18) Using (2.14), we deduce that the weight of an instanton configuration in the presence of a surface operator of type n is so that the instanton partition function can be written as (2.20) In the next section, we will describe the computation of Z k, m [ n] using equivariant localization.

Partition functions for ramified instantons
As discussed in [45], the N = 2 * theory with a surface defect of type n = {n 1 , · · · , n M }, which has a six-dimensional representation as a codimension-2 surface operator, can be realized with a system of D3-branes in the orbifold background with coordinates (z 1 , z 2 , z 3 , z 4 , v) on which the Z M -orbifold acts as Like in the previous section, the complex coordinates z 1 and z 2 span the four-dimensional space-time where the gauge theory is defined (namely the world-volume of the D3-branes), while the z 1 -plane is the world-sheet of the surface operator D that sits at the orbifold fixed point z 2 = 0. The (massive) deformation which leads from the N = 4 to the N = 2 * theory takes place in the (z 3 , z 4 )-directions. Finally, the v-plane corresponds to the Coulomb moduli space of the gauge theory. Without the Z M -orbifold projection, the isometry group of the ten-dimensional background is SO(4)×SO(4)×U(1), since the D3-branes are extended in the first four directions and are moved in the last two when the vacuum expectation values (2.4) are turned on. In the presence of the surface operator and hence of the Z M -orbifold in the (z 2 , z 3 )-directions, this group is broken to In the following we will focus only on the first four U(1) factors, since it is in the first four complex directions that we will introduce equivariant deformations to apply localization methods. We parameterize a transformation of this U(1) 4 group by the vector where the 1/M rescalings in the second and third entry, suggested by the orbifold projection, are made for later convenience. If we denote by the weight vector of a given state of the theory, then under U(1) 4 such a state transforms with a phase given by e 2πi l· , while the Z M -action produces a phase ω l 2 −l 3 . On top of this, we also have to consider the action of the orbifold group on the Chan-Paton factors carried by the open string states stretching between the D-branes. There are different types of D-branes depending on the irreducible representation of Z M in which this action takes place. Since there are M such representations, we have M types of D-branes, which we label with the index I already used before. On a D-brane of type I, the generator of Z M acts as ω I , and thus the Chan-Paton factor of a string stretching between a D-brane of type I and a D-brane of type J transforms with a phase ω I−J under the action of the orbifold generator.
In order to realize the split of the gauge group in (2.10), we consider M stacks of n I D3-branes of type I, and in order to introduce non-perturbative effects we add on top of the D3's M stacks of d I D-instantons of type I. The latter support an auxiliary ADHM group which is In the resulting D3/D(−1)-brane systems there are many different sectors of open strings depending on the different types of branes to which they are attached. Here we focus only on the states of open strings with at least one end-point on the D-instantons, because they represent the instanton moduli [49,50] on which one eventually has to integrate in order to obtain the instanton partition function. Let us first consider the neutral states, corresponding to strings stretched between two D-instantons. In the bosonic Neveu-Schwarz sector one finds states with U(1) 4 weight vectors where the subscripts denote the charge under the last U(1) factor of (3.3). They correspond to space-time vectors along the directions z 1 , z 2 , z 3 , z 4 and v, respectively. In the fermionic Ramond sector one finds states with weight vectors with a total odd number of minus signs due to the GSO projection. They correspond to anti-chiral space-time spinors 5 . It is clear from (3.7) and (3.8) that the orbifold phase ω l 2 −l 3 takes the values ω 0 , ω +1 or ω −1 and can be compensated only if one considers strings of type I-I, I-(I + 1) or (I + 1)-I, respectively. Therefore, the Z M -invariant neutral moduli carry Chan-Paton factors that transform in the (d I ,d I ), (d I ,d I+1 ) or (d I+1 ,d I ) representations of the ADHM group (3.6).
Let us now consider the colored states, corresponding to strings stretched between a D-instanton and a D3-brane or vice versa. Due to the twisted boundary conditions in the first two complex space-time directions, the weight vectors of the bosonic states in the Neveu-Schwarz sector are while those of the fermionic states in the Ramond sector are (3.10) Assigning a negative intrinsic parity to the twisted vacuum, both in (3.9) and in (3.10) the GSO-projection selects only those vectors with an even number of minus signs. Moreover, since the orbifold acts on two of the twisted directions, the vacuum carries also an intrinsic Z M -weight. We take this to be ω − 1 2 when the strings are stretched between a D3-brane and a D-instanton, and ω + 1 2 for strings with opposite orientation. Then, with this choice we find Z M -invariant bosonic and fermionic states either from the 3/(−1) strings of type I-I, whose Chan-Paton factors transform in the (n I ,d I ) representation of the gauge and ADHM groups, or from the (−1)/3 strings of type I-(I + 1), whose Chan-Paton factors transform in the (d I ,n I+1 ) representation, plus of course the corresponding states arising from the strings with opposite orientation.
In Appendix C we provide a detailed account of all moduli, both neutral and colored, and of their properties in the various sectors. It turns out that the moduli action, which can be derived from the interactions of the moduli on disks with at least a part of their boundary attached to the D-instantons [50], is exact with respect to the supersymmetry charge Q of weight Therefore Q can be used as the equivariant BRST-charge to localize the integral over the moduli space provided one considers U(1) 4 transformations under which it is invariant. This corresponds to requiring that Thus we are left with three equivariant parameters, say 1 ,ˆ 2 and 4 ; as we will see, the latter is related to the (equivariant) mass m of the adjoint hypermultiplet of N = 2 * theory. As shown in Appendix C, all instanton moduli can be paired in Q-doublets of the type (ϕ α , ψ α ) such that where λ α are the eigenvalues of Q 2 , determined by the action of the Cartan subgroup of the full symmetry group of the theory, namely the gauge group (2.10), the ADHM group (3.6), and the residual isometry group U(1) 4 with parameters satisfying (3.12) in such a way that the invariant points in the moduli space are finite and isolated. The only exception to this structure of Q-doublets is represented by the neutral bosonic moduli with weight {0, 0, 0, 0} −1 (3.14) transforming in the adjoint representation (d I ,d I ) of the ADHM group U(d I ), which remain unpaired. We denote them as χ I , and in order to obtain the instanton partition function we must integrate over them. In doing so, we can exploit the U(d I ) symmetry to rotate χ I into the maximal torus and write it in terms of the eigenvalues χ I,σ , with σ = 1, · · · , d I , which represent the positions of the D-instantons of type I in the v-plane.
In this way we are left with the integration over all the χ I,σ 's and a Cauchy-Vandermonde determinant (χ I,σ − χ I,τ + δ στ ) . More precisely, the instanton partition function in the presence of a surface operator of type n is defined by where z {d I } is the result of the integration over all Q-doublets which localizes on the fixed points of Q 2 , and q I is the counting parameter associated to the D-instantons of type I. With the convention that z {d I =0} = 1, we find , (3.17) where the index α labels the Q-doublets and λ α denotes the corresponding eigenvalue of Q 2 . This contribution goes to the denominator or to the numerator depending upon the bosonic or fermionic statistics (F α = 0 or 1, respectively) of the first component of the doublet. Explicitly, using the data in Tab. 1 of Appendix C and the determinant (3.15), we find where d M +1 = d 1 , n M +1 = n 1 and a M +1,t = a 1,t . The integrations in (3.16) must be suitably defined and regularized. The standard prescription [41,42,53] is to consider a I,s to be real and close the contours in the upper-half χ I,σ -planes with the choice Im 4 Imˆ 3 Imˆ 2 Im 1 > 0 , (3.19) and enforce (3.12) at the very end of the calculations. In this way one finds that these integrals receive contributions from the poles of z {d I } , which are in fact the critical points of Q 2 . Such poles can be put in one-to-one correspondence with a set of N Young tableaux Y = {Y I,s }, with I = 1, · · · , M and s = 1, · · · n I , in the sense that the box in the i-th row and j-th column of the tableau Y I,s represents one component of the critical value: Note that in this correspondence, a single tableau accounts for d I ! equivalent ways of relabeling χ I,σ .

Summing over fixed points and characters
Summing over the Young tableaux collections Y we get all the non-trivial critical points corresponding to all possible values of {d I }. Eq. (3.20) tells us that we get a distinct χ I,σ for each box in the j-th column of the tableau Y I+1−j mod M,s . Relabeling the index j as I,s denotes the height of the j-th column of the tableau Y I,s , and the subscript index The instanton partition function (3.16) can thus be rewritten as a sum over Young tableaux as follows where Z(Y ) is the residue of z {d I } at the critical point Y . This is obtained by deleting in (3.18) the denominator factors that yield the identifications (3.20), and performing these identifications in the other factors. In other terms, where V(Y ) and λ α (Y ) are the Vandermonde determinant and the eigenvalues of Q 2 evaluated on (3.20). A more efficient way to encode the eigenvalues λ α (Y ) is to employ the character of the action of Q 2 , which is defined as follows (3.25) If we introduce and we can write the contributions to the character from the various Q-doublets as in the last column of Tab. 1 in Appendix C. Then, by summing over all doublets and adding also the contribution of the Vandermonde determinant, we obtain (3.28) As we have seen before, through (3.22) and (3.20) each set Y determines both the dimensions d I (Y ) and the eigenvalues λ α (Y ). Thus, the character X(Y ) associated to a set of Young tableaux is obtained from X {d I } by substituting (3.20) into the definitions of V I , namely By analyzing X(Y ) obtained in this way we can extract the explicit expression for the eigenvalues λ s (Y ) and finally write the instanton partition function. This procedure is easily implemented in a computer program, and yields the results we will use in the next sections. In Appendix (C.1), as an example, we illustrate these computations for the SU(2) gauge theory. In our analysis we worked with the moduli action that describes D-branes probing the orbifold geometry. An alternative approach works with the resolution of the orbifold geometry [54,55]. This involves analyzing a gauged linear sigma-model that describes a system of D1 and D5-branes in the background C × C/Z M × T S 2 × R 2 . One then uses the localization formulas for supersymmetric field theories defined on the 2-sphere [56,57] to obtain exact results. This is a very powerful approach since it also includes inherently stringy corrections to the partition function arising from world-sheet instantons [54]. The results for the instanton partition function of the N = 2 theory in the presence of surface operators obtained in [55] are equivalent to our results in (3.18).

Map between parameters
One of the key points that needs to be clarified is the map between the microscopic counting parameters q I which appear in (3.23), and the parameters (q, t I ) which were introduced in Section 2 in discussing SU(N ) gauge theories with surface operators. To describe this map, we start by rewriting the partition function (3.16) in terms of the total instanton number k and the magnetic fluxes m I of the gauge groups on the surface operator which are related to the parameters d I as follows [8,45]: Therefore, instead of summing over {d I } we can sum over k and m and find Furthermore, if we set we easily get where in the last step we introduced m 1 such that that I m I = 0 (see (2.13)) in order to write the result in a symmetric form. This is precisely the expected expression of the partition function in the presence of a surface operator as shown in (2.20) and justifies the map (3.32) between the parameters of the two descriptions. From (3.33) we see that only differences of the parameters t I appear in the partition function so that it may be convenient to use as independent parameters q and the (M − 1) variables This is indeed what we are going to see in the next sections where we will show how to extract relevant information from the the instanton partition functions described above.

Extracting the prepotential and the twisted superpotential
The effective dynamics on the Coulomb branch of the four-dimensional N = 2 gauge theory is described by the prepotential F, while the infrared physics of the two-dimensional theory defined on the world-sheet of the surface operator is governed by the twisted superpotential W. The non-perturbative terms of both F and W can be derived from the instanton partition function previously discussed, by considering its behavior for small deformation parameters 1 and 2 and, in particular, in the so-called Nekrasov-Shatashvili (NS) limit [51].
To make precise contact with the gauge theory quantities, we set where m is the mass of the adjoint hypermultiplet, and then take the limit for small 1 and 2 . In this way we find [8]: The two leading singular contributions arise, respectively, from the (regularized) equivariant volume parts coming from the four-dimensional gauge theory and from the twodimensional degrees of freedom supported on the surface defect D. This can be understood from the fact that, in the Ω-deformed theory, the respective super-volumes are finite and given by [1,58]: The non-trivial result is that the functions F inst and W inst defined in this way are analytic in the neighborhood of 1 = 0. As an illustrative example, we now describe in some detail the SU(2) theory.

SU(2)
When the gauge group is SU(2), the only surface operators are of type n = {1, 1}, the Coulomb branch is parameterized by 38) and the map (3.32) can be written as where, for later convenience, we have defined z = (t 2 − t 1 ). Using the results presented in Appendix C.1 and their extension to higher orders, it is possible to check that the instanton prepotential arising from (3.36), namely is, as expected, a function only of the instanton counting parameter q and not of x. Expanding in inverse powers of a, we have where f ∼ a 2− . The first few coefficients of this expansion are (3.42) One can check that this precisely agrees with the NS limit of the prepotential derived for example in [21,22]. This complete match is a strong and non-trivial check on the correctness and consistency of the whole construction.
Let us now consider the non-perturbative superpotential, which according to (3.36) is Differently from the prepotential, W inst is, as expected, a function both of q and x. If we expand it as with w inst ∼ a 1− , using the results of Appendix C.1 we find and so on. For later convenience we explicitly write down the logarithmic derivatives with respect to x, namely where w := x ∂ ∂x w inst . In the coming sections we will show that these expressions are the weak-coupling expansions of combinations of elliptic and quasi-modular forms of the modular group SL(2, Z).

Modular anomaly equation for the twisted superpotential
In [21,22] it has been shown for the N = 2 SU(2) theory that the instanton expansions of the prepotential coefficients (3.42) can be resummed in terms of (quasi-) modular forms of the duality group SL(2, Z) and that the behavior under S-duality severely constrains the prepotential F which must satisfy a modular anomaly equation. This analysis has been later extended to N = 2 theories with arbitrary classical or exceptional gauge groups [34,41,42], and also to N = 2 SQCD theories with fundamental matter [38,39]. In this section we use a similar approach to study how S-duality constrains the form of the twisted superpotential W.
For simplicity and without loss of generality, in the following we consider a full surface operator of type n = {1, 1, · · · , 1} with electro-magnetic parameters t = {t 1 , t 2 , · · · , t N }. Indeed, surface operators of other type correspond to the case in which these parameters are not all different from each other and form M distinct sets, namely (4.1) Thus they can be simply recovered from the full ones with suitable identifications. Before analyzing the S-duality constraints it is necessary to take into account the classical and the perturbative 1-loop contributions to the prepotential and the superpotential.

The classical contribution
Introducing the notation a = {a 1 , a 2 , · · · , a N } for the vacuum expectation values, the classical contributions to the prepotential and the superpotential are given respectively by and Note that if we use the tracelessness condition (2.4), W class can be rewritten as where z I is as defined in (3.34). These classical contributions have very simple behavior under S-duality. Indeed To show these relations one has to use the S-duality rules (2.3) and (2.18), and recall that S a = a D := 1 2πi which for the classical prepotential simply yield S( a) = τ a.

The 1-loop contribution
The 1-loop contribution to the partition function of the Ω-deformed gauge theory in the presence of a full surface operator of type {1, 1, · · · , 1} can be written in terms of the function where Γ 2 is the Barnes double Γ-function and Λ an arbitrary scale. Indeed, as shown for example in [55], the perturbative contribution is where a uv = a u − a v , and the ceiling function y denotes the smallest integer greater than or equal to y. The first term in (4.8) represents the contribution of the vector multiplet, while the second term is the contribution of the massive hypermultiplet. Expanding (4.8) for small 1,2 and using the same definitions (3.36) used for the instanton part, we obtain the perturbative contributions to the prepotential and the superpotential in the NS limit: Exploiting the series expansion of the γ-function, one can explicitly compute these expressions and show that F pert precisely matches the perturbative prepotential in the NS limit obtained in [34,41], while the contribution to the superpotential is novel. For example, in the case of the SU(2) theory we obtain (4.10b) Note that, unlike the prepotential, the twisted superpotential has no logarithmic term 6 . Furthermore, it is interesting to observe that (4.11)

S-duality constraints
We are now in a position to discuss the constraints on the twisted superpotential arising from S-duality. Adding the classical, the perturbative and the instanton terms described in the previous sections, we write the complete prepotential and superpotential in the NS 6 This fact is due to the superconformal invariance, and is no longer true in the pure N = 2 SU(2) gauge theory, for which we find limit as where for later convenience, we have kept the classical terms separate. The quantum coefficients f and w scale as a 2− and a 1− , respectively, and account for the perturbative and instanton contributions. While f depend on the coupling constant τ , the superpotential coefficients w are also functions of the surface operator variables z I , as we have explicitly seen in the SU(2) theory considered in the previous section. The coefficients f have been explicitly calculated in terms of quasi-modular forms in [34,41] and we list the first few of them in Appendix D. Their relevant properties can be summarized as follows: • All f with odd vanish, while those with even are homogeneous functions of a and satisfy the scaling relation 7 Since the prepotential has mass-dimension two, the f 2 are homogeneous polynomials of degree 2 , in m and 1 .
• The coefficients f 2 depend on the coupling constant τ only through the Eisenstein series E 2 (τ ), E 4 (τ ) and E 6 (τ ), and are quasi-modular forms of SL(2,Z) of weight 2 − 2, such that where δ = 6 πiτ . The shift δ in E 2 is due to the fact that the second Eisenstein series is a quasi-modular form with an anomalous modular transformation (see (A.4)).
• The coefficients f 2 satisfy a modular anomaly equation which can be solved iteratively.
Using the above properties, it is possible to show that S-duality acts on the prepotential F in the NS limit as a Legendre transform [41,42].
Let us now turn to the twisted superpotential W. As we have seen in (4.5), S-duality acts very simply at the classical level but some subtleties arise in the quantum theory. We now make a few important points, anticipating some results of the next sections. It turns out that W receives contributions so that the coefficients w do not have a well-defined modular weight. However, these anomalous terms depend only on the coupling constant τ 7 To be precise, one should also scale Λ → λΛ in the logarithmic term of f2. and the vacuum expectation values a. In particular, they are independent of the continuous parameters z I that characterize the surface operator. For this reason it is convenient to consider the z I derivatives of the superpotential: where, of course, w (I) := 1 2πi ∂w ∂z I . Combining intuition from the classical S-duality transformation (4.5b) with the fact that the z I -derivative increases the modular weight by one, and introduces an extra factor of (−τ ) under S-duality, we are naturally led to propose that S W (I) = τ W (I) . (4.17) This constraint can be solved if we assume that the coefficients w (I) satisfy the following properties (which are simple generalizations of those satisfied by f ): • They are homogeneous functions of a and satisfy the scaling relation Given that the twisted superpotential has mass-dimension one, it follows that w (I) must be homogeneous polynomials of degree in m and 1 .
• The dependence of w (I) on τ and z I is only through linear combinations of quasimodular forms made up with the Eisenstein series and elliptic functions with total weight , such that We are now ready to discuss how S-duality acts on the superpotential coefficients w (I) .
Recalling that where in the last step we exploited the scaling behavior (4.18) together with (4.20). Using this result in (4.16) and formally expanding in δ, we obtain The constraint (4.17) is satisfied if which also implies the vanishing of all terms of higher order in δ. This modular anomaly equation can be equivalently written as where we have defined w (I) 0 = a I . In the next sections we will solve this modular anomaly equation and determine the superpotential coefficients w (I) in terms of Eisenstein series and elliptic functions; we will also show that by considering the expansion of these quasi-modular functions we recover precisely all instanton contributions computed using localization, thus providing a very strong and highly non-trivial consistency check on our proposal (4.17) and on our entire construction. Since the explicit results are quite involved in the general case, we will start by discussing the SU(2) theory.

Surface operators in N = 2 SU(2) theory
We now consider the simplest N = 2 theory with gauge group SU(2) and solve in this case the modular anomaly equation (4.24). A slight modification from the earlier discussion is needed since for SU (2)  with the initial condition w 0 = −a. The coefficient w 1 and its z-derivative w 1 do not depend on a and are therefore irrelevant for the IR dynamics on the surface operator. Moreover, w 1 drops out of the anomaly equation and plays no role in determining w for higher values of . Nevertheless, for completeness, we observe that if we use the elliptic function where θ 1 (z|τ ) is the first Jacobi θ-function, and exploit the expansion reported in (A. 16), comparing with the instanton expansion (3.46a) obtained from localization, we are immediately led to, By expanding h 1 to higher orders one can "predict" all higher instanton contributions to w 1 . We have checked that these predictions perfectly match the explicit results obtained from localization methods involving Young tableaux with up to six boxes. The first case in which the modular anomaly equation (5.2) shows its power is the case = 2. Recalling that the prepotential coefficients f n with n odd vanish, we have Using the initial condition w 0 = −a, substituting the exact expression for f 2 given in (D.1) and then integrating, we get At this juncture, it is important to observe that the elliptic and modular forms of SL(2, Z), which are allowed to appear in the superpotential coefficients, are polynomials in the ring generated by the Weierstraß function ℘(z|τ ) and its z-derivative ℘ (z|τ ), and by the Eisenstein series E 4 and E 6 . These basis elements have weights 2, 3, 4 and 6 respectively. We refer to Appendix A for a collection of useful formulas for these elliptic and modular forms and for their perturbative expansions. Since w 2 must have weight 2, the modular term in (5.6) is restricted to be proportional to the Weierstraß function, namely where α is a constant. Therefore our proposal works only if by fixing a single parameter α we can match all the microscopic contributions to w 2 computed in the previous sections. Given the many constraints that this requirement puts, it is not at all obvious that it works. But actually it does! Indeed, using the expansions of E 2 and ℘ = ℘ 4π 2 given in (A.2) and (A.17) respectively, and comparing with (3.46b), one finds a perfect match if α = 12. Thus, the exact expression of w 2 is We have checked up to order six that the all instanton corrections predicted by this formula completely agree with the microscopic results obtained from localization. Let us now consider the modular anomaly equation (5.2) for = 3. In this case since w 1 is a-independent and the coefficients f n with n odd vanish, we simply have According to our proposal, w 3 must be an elliptic function with modular weight 3, and in view of (5.9), the only candidate is the derivative of the Weierstraß function ℘ . By comparing the expansion (A.18) with the semi-classical results (3.46c) we find a perfect match and obtain Again we have checked that the higher order instanton corrections predicted by this formula agree with the localization results up to order six. A similar analysis can done for higher values of without difficulty. Obtaining the anomalous behavior by integrating the modular anomaly equation, and fixing the coefficients of the modular terms by comparing with the localization results, after a bit of elementary algebra, we get and so on. The complete agreement with the microscopic localization results of the above expressions provides very strong and highly non-trivial evidence for the validity of the modular anomaly equation and the S-duality properties of the superpotential, and hence of our entire construction. Exploiting the properties of the function h 1 defined in (5.3) and its relation with the Weierstraß function (see Appendix A), it is possible to rewrite the above expressions as total z-derivatives. Indeed, we find We have checked that the same is also true for w 6 (and for a few higher coefficients as well), which however we do not write explicitly for brevity. Of course this is to be expected since they are the coefficients of the expansion of the derivative of the superpotential. The latter can then be simply obtained by integrating with respect to z and fixing the integration constants by comparing with the explicit localization results. In this way we obtain 8 14) and so on. Note that, as anticipated in the previous section, the coefficients w n do not have a homogeneous modular weight.

Relation to CFT results
So far we have studied the twisted superpotential and its z-derivative as semi-classical expansions for large a. However, we can also arrange these expansions in terms of the deformation parameter 1 . For example, using the results in (5.8), (5.10) and (5.11), we obtain and so on. Quite remarkably, up to a sign flip a → −a, these expressions precisely coincide with the results obtained in [35] from the null-vector decoupling equation for the toroidal 1-point conformal block in the Liouville theory.
We would like to elaborate a bit on this match. Let us first recall that in the so-called AGT correspondence [9] the toroidal 1-point conformal block of a Virasoro primary field V in the Liouville theory is related to the Nekrasov partition function of the N = 2 SU(2) gauge theory. In [11] it was shown that the insertion of the degenerate null-vector V 2,1 in the Liouville conformal block corresponds to the partition function of the SU(2) theory in the presence of a surface operator. In the semi-classical limit of the Liouville theory (which corresponds to the NS limit 2 → 0), one has [11,35] where N is a suitable normalization factor. In [35] the null-vector decoupling equation satisfied by the degenerate conformal block was used to explicitly calculate the prepotential F and the z-derivative of the twisted effective superpotential W for the N = 2 SU(2) theory, which fully agrees with the one we have obtained using the modular anomaly equation and localization methods. It is important to keep in mind that the insertion of the degenerate field V 2,1 in the Liouville theory corresponds to the insertion of a surface operator of codimension-4 in the six-dimensional (2, 0) theory. In the brane picture, this defect corresponds to an M2 brane ending on the M5 branes that wrap a Riemann surface and support the gauge theory in four dimensions. On the other hand, as explained in the introduction, the results we have obtained using the orbifold construction and localization pertain to a surface operator of codimension-2 in the six dimensional theory, corresponding to an M5 intersecting the original M5 branes. The equality between our results and those of [35] supports the proposal of a duality between the two types of surface operators in [52]. This also supports the conjecture of [59], based on [10,60,61], that in the presence of simple surface operators the instanton partition function is insensitive to whether they are realized as codimension-2 or codimension-4 operators. In Section 7.1 we will comment on such relations in the case of higher rank gauge groups and will also make contact with the results for the twisted chiral rings when the surface defect is realized by coupling two-dimensional sigma-models to pure N = 2 SU(N) gauge theory.

Surface operators in N = 2 SU(N ) theories
We now generalize the previous analysis to SU(N ) gauge groups. As discussed in Section 2, in the higher rank cases there are many types of surface operators corresponding to the different partitions of N . We start our discussion from simple surface operators of type {1, (N − 1)}.

Simple surface operators
In the case of the simple partition {1, (N − 1)}, the vector t of the electro-magnetic parameters characterizing the surface operator takes the form Correspondingly, the classical contribution to the twisted effective superpotential becomes where we have used the tracelessness condition on the vacuum expectation values and, according to (3.34), have defined z = t 2 − t 1 . When quantum corrections are included, one finds that the coefficients w of the zderivative of the superpotential satisfy the modular anomaly equation (4.24). The solution of this equation proceeds along the same lines as in the SU(2) case, although new structures, involving the differences a ij = a i − a j , appear. We omit details of the calculations and merely present the results. As for the SU(2) theory, the coefficients can be compactly written in terms of modular and elliptic functions, particularly the second Eisenstein series and the function h 1 defined in (5.3). For clarity, and also for later convenience, we indicate the dependence on z but understand the dependence on τ in h 1 . The first few coefficients w are and so on. We have explicitly checked the above formulas against localization results up to SU(7) finding complete agreement. It is easy to realize that for N = 2 only the highest order poles contribute and the corresponding expressions precisely coincide with the results in the previous section. In the higher rank cases, there are also contributions from structures with lesser order poles that are made possible because of the larger number of Coulomb parameters. Furthermore, we observe that there is no pole when a j approaches a k with j, k = 2, · · ·, N . It is interesting to observe that the above expressions can be rewritten in a suggestive form using the root system Φ of SU(N ). The key observation is that using the vector t defined in (6.1) we can select a subset of roots Ψ ⊂ Φ such that their scalar products with the vector a of the vacuum expectation values produce exactly all the factors of a 1j in the denominators of (6.3). Defining one can verify that for any α ∈ Ψ, the scalar product α · a is of the form a 1j . Therefore, w 2 in (6.3a) can be written as where in the last step we used the fact that h 1 is an even function. Similarly the other coefficients in (6.3) can also be rewritten using the roots of SU(N ). Indeed, introducing the subsets of Ψ defined as 9 we find that w 3 in (6.3b) becomes , (6.7) while w 4 in (6.3c) is .

(6.8)
We observe that the two sums in the last two lines of (6.8) are actually equal to each other and exactly reproduce the last line of (6.3c). However, for different sets of roots the two sums are different and lead to different structures. Thus, for reasons that will soon become clear, we have kept them separate even in this case.

Surface operators of type {p, N − p}
We now discuss a generalization of the simple surface operator in which we still have a single complex variable z as before, but the type is given by the following vector In this case, using the tracelessness condition on the vacuum expectation values, the classical contribution to the superpotential is where again we have defined z = t 2 − t 1 . It turns out that the quantum corrections to the z-derivatives of the superpotential are given exactly by the same formulas (6.5), (6.7) and (6.8) in which the only difference is in the subsets of the root system Φ that have to be considered in the lattice sums. These subsets are still defined as in (6.4) and (6.6) but with the vector t given by (6.9). We observe that in this case the two last sums in (6.8) are different. We have verified these formulas against the localization results up to SU(7) finding perfect agreement. The fact that the superpotential coefficients can be formally written in the same way for all unitary groups and for all types with two entries, suggests that probably universal formulas should exist for surface operators with more than two distinct entries in the t-vector. This is indeed what happens as we will show in the next subsection.

Surface operators of general type
A surface operator of general type corresponds to splitting the SU(N ) gauge group as in (2.10) which leads to the following partition of the Coulomb parameters a = n 1 a 1 , · · · a n 1 , n 2 a n 1 +1 , · · · a n 1 +n 2 , · · · , n M a N −n M +1 , . . . a N , (6.11) and to the following t-vector t = n 1 t 1 , · · · , t 1 , In this case we therefore have several variables z I defined as in (3.34), and several combinations of elliptic functions evaluated at different points. However, if we use the root system Φ of SU(N ) the structure of the superpotential coefficients is very similar to what we have seen before in the simplest cases. To see this, let us first define the following subsets 10 of Φ: which are obvious generalizations of the definitions (6.4) and (6.6). Then, writing for I = 2, · · · , M , we find that the first few coefficients w (I) are given by where the summation indices J, K, · · · , take integer values from 1 to M . One can explicitly check that these formulas reduce to those of the previous subsections if M = 2 and that no singularity arises when two a's belonging to the same subgroup in (6.11) approach each other. We have verified these expressions in many cases up to SU(7), always finding agreement with the explicit localization results. Of course it is possible to write down similar expressions for the higher coefficients w (I) , which however become more and more cumbersome as increases. Given the group theoretic structure of these formulas, it is tempting to speculate that they may be valid for the other simply laced groups of the ADE series as well, similarly to what happens for the analogous expressions of the prepotential coefficients [41]. It would be interesting to verify whether this happens or not.

Duality between surface operators
In this section we establish a relation between our localization results and those obtained when the surface defect is realized by coupling two-dimensional sigma-models to the four dimensional gauge theory. When the surface operators are realized in this way, the twisted chiral ring has been independently obtained by studying the two-dimensional (2, 2) theories [62,63] and related to the Seiberg-Witten geometry of the four dimensional gauge theory [4,5]. Building on these general results, we extract the semi-classical limit and compare it with the localization answer, finding agreement. In order to be explicit, we will consider only gauge theories without Ω-deformation, and begin our analysis by first discussing the pure N = 2 theory with gauge group SU(N ); in the end we will return to the N = 2 theory.

The pure N = 2 SU(N ) theory
The pure N = 2 theory can be obtained by decoupling the adjoint hypermultiplet of the N = 2 model. More precisely, this decoupling is carried out by taking the following limit (see for example [34]) m → ∞ and q → 0 such that q m 2N = (−1) N Λ 2N is finite, (7.1) where Λ is the strong coupling scale of the pure N = 2 theory. In presence of a surface operator, this limit must be combined with a scaling prescription for the continuous variables that characterize the defect. For surface operators of type {p, N − p}, which possess only one parameter x = e 2πi z , this scaling is Here x 0 = e 2πi z 0 is the parameter that labels the surface operator in the pure theoryà la Gukov-Witten [2][3][4][5].
Performing the limits (7.1) and (7.2) on the localization results described in the previous sections, we obtain We have explicitly verified this expression in all cases up to SU (7), and for the low rank groups we have also computed the higher instanton corrections 11 . With some simple algebra one can check that, up to the order we have worked, W is not singular for a i → a j when both i and j are ≤ p or > p. Furthermore, one can verify that as a consequence of the tracelessness condition on the vacuum expectation values. We now show that this result is completely consistent with the exact twisted chiral ring relation obtained in [5]. For the pure N = 2 SU(N ) theory with a surface operator parameterized by x 0 , the twisted chiral ring relation takes the form [5] where e i are the quantum corrected expectation values of the adjoint scalar. They reduce to a i in the classical limit Λ → 0 and parameterize the quantum moduli space of the theory. The e i , which satisfy the tracelessness condition were explicitly computed long ago in the 1-instanton approximation in [64,65] by evaluating the period integrals of the Seiberg-Witten differential and read The higher instanton corrections can be efficiently computed using localization methods [66][67][68][69], but their expressions will not be needed in the following. Inserting (7.9) into (7.7) and systematically working order by order in Λ N , it is possible to show that the N roots of the chiral ring equation (7.6) are For example, for SU(2) and p = 1 we find where a = a1.
for i = 1, · · · , N . Comparing with (7.4), we see that, up to an overall sign, y i coincide with the derivatives of the superpotential W i we obtained from localization. Therefore, we can rewrite the left hand side of (7.6) in a factorized form and get This shows a perfect match between our localization results and the semi-classical expansion of the chiral ring relation of [5], and provides further non-trivial evidence for the equivalence of the two descriptions. Let us elaborate a bit more on this. According to [5], a surface operator of type {p, N − p} has a dual description as a Grassmannian sigma-model coupled to the SU(N ) gauge theory, and all information about the twisted chiral ring of the sigmamodel is contained in two monic polynomials, Q and Q of degree p and (N −p) respectively, given by Here, X are the twisted chiral ring elements of the Grassmannian sigma-model, and in particular where W is the superpotential of the surface operator of type {p, N − p}. The polynomial Q encodes the auxiliary information about the "dual" surface operator obtained by sending p → (N −p). The crucial point is that, according to the proposal of [5], the two polynomials Q and Q satisfy the relation Q(y) Q(y) − P N (y) + Λ N x 0 + 1 x 0 = 0 . (7.14) Comparing with (7.11), we are immediately led to the following identifications 12 Thus, using (7.13) and (7.3), we find 1 2πi This equality shows that our localization results for the superpotential of the surface operator of type {p, N − p} in the pure SU(N ) theory perfectly consistent with the proposal of [5], thus proving the duality between the two descriptions. All this is also a remarkable consistency check of the way in which we have extracted the semi-classical results for the twisted chiral ring of the Grassmannian sigma-model and of the twisted superpotential we have computed.

The N = 2 SU(N ) theory
Inspired by the previous outcome, we now analyze the twisted chiral ring relation for simple operators in N = 2 theories using the Seiberg-Witten curve and compare it with our localization results for the undeformed theory. To this aim, let us first recall from Section 6.1 (see in particular (6.3) with 1 = 0) that for a simple surface operator corresponding to the following partition of the Coulomb parameters the z-derivative of the superpotential is Let us now see how this information can be retrieved from the Seiberg-Witten curve of the N = 2 theories. As is well known, in this case there are two possible descriptions (see [44] for a review). The first one, which we call the Donagi-Witten curve [70], is written naturally in terms of the modular covariant coordinates on moduli space, while the second, which we call the d'Hoker-Phong curve [71], is written naturally in terms of the quantum corrected coordinates on moduli space. As shown in [44], these two descriptions are linearly related to each other with coefficients depending on the second Eisenstein series E 2 . Since our semi-classical results have been resummed into elliptic and quasi-modular forms, we use the Donagi-Witten curve, which for the SU(N ) gauge theory is an N -fold cover of an elliptic curve. It is described by the pair of equations: The first equation describes an elliptic curve and thus we can identify (X, Y ) with the Weierstraß function and its derivative (see (A.11)). More precisely we have The second equation in (7.19) contains a polynomial in y of degree N which encodes the modular covariant coordinates A k on the Coulomb moduli space of the gauge theory: where P k are the modified Donagi-Witten polynomials introduced in [44]. The first few of them are 13 : P 0 = 1 , P 1 = y , On the other hand, the first few modular covariant coordinates A k are (see [44]): and so on. We now have all the necessary ingredients to proceed. First of all, using the above expressions and performing the decoupling limits (7.1) and (7.2), one can check that the Donagi-Witten equation F N = 0 reduces to the twisted chiral ring relation (7.6) of the pure theory. Of course this is not a mere coincidence; on the contrary it supports the idea that the Donagi-Witten equation actually encodes also the twisted chiral ring relation of the simple codimension-4 surface operators of the N = 2 theories. Secondly, working order by order in the hypermultiplet mass m, one can verify that the N roots of the Donagi-Witten equation are given by Remarkably, this precisely matches, up to an overall sign, the answer (7.18) for the simple codimension-2 surface operator we have obtained using localization. Once again, we have exhibited the equivalence of twisted chiral rings calculated for the two kinds of surface operators. Furthermore, we can rewrite the Donagi-Witten equation in a factorized form as follows which is the N = 2 equivalent of the pure theory relation (7.11).
At this point one is tempted to proceed as in the pure theory and try to deduce also the superpotential for surface operators of type {p, N − p}. However, from our explicit localization results we know that in this case W is not simply the sum of the superpotentials of type {1, N − 1}, differently from what happens in the pure theory (see (7.3)). Thus, a naive extension to the N = 2 of the proposal of [5] to describe the coupling of a two dimensional Grassmannian sigma-model to the four dimensional gauge theory can not work in this case. This problem as well as the coupling of a flag variety to the N = 2 theory, which is relevant for surface operators of general type, remains an open question which we leave to future investigations.

Some remarks on the results
The result we obtained from the twisted superpotential in the case of simple operators is totally consistent with the proposal given in the literature for simple codimension-4 surface operators labeled by a single continuous parameter z, whose superpotential has been identified with the line integral of the Seiberg-Witten differential of the four-dimensional gauge theory along an open path [11]: where z * is an arbitrary reference point. Indeed, in the Donagi-Witten variables, the differential is simply λ SW (z) = y(z) dz. Given that the Donagi-Witten curve is an N -fold cover of the torus, the twisted superpotential with the classical contribution proportional to a i can be obtained by solving for y(z) and writing out the solution on the ith branch.
As we have seen in the previous subsection, the general identification in (7.26) works also in the pure N = 2 theory, once the parameters in the Seiberg-Witten differential are rescaled by a factor of Λ N [5]. This rescaling can be interpreted as a renormalization of the continuous parameter that labels the surface operator [72].
The agreement we find gives further evidence of the duality between defects realized as codimension-2 and codimension-4 operators that we have already discussed in Section 5.1, where we showed the equality of the twisted effective superpotential computed in the two approaches for simple defects in the SU(2) theory. We have extended these checks to defects of type {p, N − p} in pure N = 2 theories, and to simple defects in N = 2 theories with higher rank gauge groups. All these checks support the proposal of [52] based on a "separation of variables" relation.

Conclusions
In this paper we have studied the properties of surface operators on the Coulomb branch of the four dimensional N = 2 theory with gauge group SU(N ) focusing on the superpotential W. This superpotential, describing the effective two-dimensional dynamics on the defect world-sheet, receives non-perturbative contributions, which we calculated using equivariant localization. Furthermore, exploiting the constraints arising from the non-perturbative SL(2, Z) symmetry, we showed that in a semi-classical regime in which the mass of the adjoint hypermultiplet is much smaller than the classical Coulomb branch parameters, the twisted superpotential satisfies a modular anomaly equation that we solved order by order in the mass expansion.
We would like to remark some interesting properties of our results. If we focus on the derivatives of the superpotential, the coefficients of the various terms in the mass expansion are linear combination of elliptic and quasi-modular forms with a given weight. The explicit expression for the twisted superpotential can be written in a very general and compact form in terms of suitable restricted sums over the root lattice of the gauge algebra.
The match of our localization results with the ones obtained in [5] by studying the coupling with two-dimensional sigma models is a non-trivial check of our methods and provides evidence for the duality between the codimension-2 and codimension-4 surface operators proposed in [52]. Further evidence is given by the match of the twisted superpotentials in the N = 2 theory, which we proved for the simple surface operators using the Donagi-Witten curve of the model. A key input for this match is the exact quantum expression of the chiral ring elements calculated using localization [44,69]. It would be really important to extend the discussion of this duality to more general surface operators described by a generic Levi decomposition.
There are several possible extensions of our work. A very direct one would be to check that the general expression given for the twisted superpotential is actually valid for all simply laced groups, in analogy to what happens for the four-dimensional prepotential. A technically more challenging extension would be to study surface operators for theories with non-simply laced gauge groups. The prepotential in these cases has been calculated in [42] using localization methods and expressed in terms of modular forms of suitable congruence subgroups of SL(2,Z), and it would be very interesting to similarly calculate the twisted superpotential in a semi-classical expansion.
Another interesting direction would be to study surface operators in SQCD theories. For SU(N ) gauge groups, the prepotential as well as the action of S-duality on the infrared variables have been calculated in a special locus of the Coulomb moduli space that has a Z N symmetry [38,39]. Of special importance was the generalized Hecke groups acting on the period integrals and the period matrix of the Seiberg-Witten curve. It would be worthwhile to explore if such groups continue to play a role in determining the twisted superpotential as well.
A related development would be to analyze the higher order terms in the 2 expansion of the partition function (see (3.36)) and check whether or not they also obey a modular anomaly equation like the prepotential and the superpotential do. This would help us in clarifying the properties of the partition function in the presence of a surface operator in a general Ω background.
There has been a lot of progress in understanding M2 brane surface operators via the 4d/2d correspondence. For higher rank theories, explicit results for such surface defects have been obtained in various works including [73][74][75][76][77]. In particular in [75], the partition functions of theories with N 2 f free hypermultiplets on the deformed 4-sphere in the presence of surface defects have been related to specific conformal blocks in Toda conformal field theories. This has been extended in [76,77] to study gauge theory partition functions in the presence of intersecting surface defects. It would be interesting to study such configurations directly using localization methods.

A Useful formulas for modular forms and elliptic functions
In this appendix we collect some formulas about quasi-modular forms and elliptic functions that are useful to check the statements of the main text.

Eisenstein series
We begin with the Eisenstein series E 2n , which admit a Fourier expansion in terms of q = e 2πiτ of the form where σ p (k) is the sum of the p-th powers of the divisors of k. More explicitly we have Under a modular transformation τ → aτ +b cτ +d , with a, b, c, d ∈ Z and ad − bc = 1, the Eisenstein series transform as In particular, under S-duality we have where δ = 6 πiτ .

Elliptic functions
The elliptic functions that are relevant for this paper can all be obtained from the Jacobi θ-function where x = e 2πiz . From θ 1 , we first define the function and the Weierstraß ℘-function In most of our formulas the following rescaled ℘-function appears: which we can write also as Another relevant elliptic function is the derivative of the Weierstraß function, namely The Weierstraß function and its derivative satisfy the equation of an elliptic curve, given by By differentiating this equation, we obtain which, using (A.9) and (A.10), we can rewrite as The function h 1 , ℘ and ℘ have well-known expansions near the point z = 0. However, a different expansion is needed for our purposes, namely the expansion for small q and x. To find such an expansion we observe that q and x variables must be rescaled differently, as is clear from the map (3.32) between the gauge theory parameters and the microscopic counting parameters. In particular for M = 2 this map reads (see also (3.39)) so that if the microscopic parameters are all scaled equally as q i −→ λq i , then the gauge theory parameters scale as With this in mind, we now expand the elliptic functions for small λ and set λ = 1 in the end, since this is the relevant expansion needed to compare with the instanton calculations. Proceeding in this way, we find 14 As a consistency check it is possible to verify that, using these expansions and those of the Eisenstein series in (A.2), the elliptic curve equation (A.11) is identically satisfied order by order in λ.
As we have seen in Section 2, the modular group acts on (z|τ ) as follows: with a, b, c, d ∈ Z and ad − bc = 1. Under such transformations the Weierstraß function and its derivative have, respectively, weight 2 and 3, namely (A.20) Of course, similar relations hold for the rescaled functions ℘ and ℘ . In particular, under S-duality we have (A.21)

B Generalized instanton number in the presence of fluxes
In this Appendix we calculate the second Chern class of the gauge field in the presence of a surface operator for a generic Lie algebra g.

Surface operator Ansatz
A surface operator creates a singularity in the gauge field A. As discussed in the main text, we parametrize the space-time R 4 C 2 by two complex variables (z 1 = ρ e iφ , z 2 = r e iθ ), and consider a two-dimensional defect D located at z 2 = 0 and filling the z 1 -plane. In this set-up, we make the following Ansatz [8]: where A is regular all over R 4 and g(r) is a g-valued function regular when r → 0. The corresponding field strength is then From this expression we obtain The last term vanishes due to the Bianchi identity, and thus we are left with We now assume that the function g(r) has components only along the Cartan directions of g, labeled by an index i, such that lim r→0 g i (r) = −γ i and lim r→∞ g i (r) = 0 . (B.5) This means that near the defect the gauge connection behaves as for r → 0. Using this in (B.4), we have Notice that in the last term we can replace F i with F i because the difference lies entirely in the transverse directions of the surface operator and thus does not contribute in the wedge product with dθ. Since the defect D effectively acts as a boundary in R 4 located at r = 0, integrating (B.7) over R 4 we have Here we have denoted by k the instanton number of the smooth connection A and taken into account a factor of 2π originating from the integration over θ. Finally, we have defined These quantities, which we call fluxes, must satisfy a quantization condition that can be understood as follows. All fields of the gauge theory are organized in representations 15 of g and, in particular, can be chosen to be eigenstates of the Cartan generators H i with eigenvalues λ i . These eigenvalues define a vector λ = {λ i }, which is an element of the weight lattice Λ W of g. Let us now consider a gauge transformation in the Cartan subgroup with parameters ω = {ω i }. On a field with weight λ, this transformation simply acts by a phase factor exp i ω · λ . From the point of view of the two-dimensional theory on the defect, the Cartan gauge fields A i must approach a pure-gauge configuration at infinity so that with ω i being a function of φ, the polar angle in the z 1 -plane. In this situation, for the corresponding gauge transformation to be single-valued, one finds with integer n. In other words ω · λ must be a map from the circle at infinity S ∞ 1 into S 1 with integer winding number n. Given this, we have (B.12) 15 Here for simplicity we consider the gauge group G to be the universal covering group of g; in particular for g = AN−1, we take G = SU (N ).
Then, using (B.11), we immediately deduce that For the group SU(N ) this condition amounts to say that m must belong to the dual of the weight lattice: m ∈ (Λ W ) * . (B.14) The SU(N ) case For U(N ) the Cartan generators H i can be taken as the diagonal (N × N ) matrices with just a single non-zero entry equal to 1 in the i-th place (i = 1, · · · , N ). The restriction to SU(N ) can be obtained by choosing a basis of (N − 1) traceless generators, for instance In terms of the standard orthonormal basis { e i } of R N , the (N −1) simple roots of SU(N ) are then {( e 1 − e 2 ), ( e 2 − e 3 ), · · · } and the root lattice Λ R is the Z-span of these simple roots. Note that Λ R lies in a codimension-1 subspace orthogonal to i e i , and that the integrality condition for the weights is simply α · λ ∈ Z for any root α. This shows that the weight lattice is the dual of the root lattice, or equivalently that the dual of the weight lattice is the root lattice: (Λ W ) * = Λ R . Therefore, the condition (B.14) implies that the flux vector m must be of the form The fact that the fluxes m i are integers (adding up to zero) has been used in the main text.

Generic surface operator
The case in which all the γ i 's defined in (B.5) are distinct, corresponds to the surface operator of type [1, 1, . . . , 1], also called full surface operator. If instead some of the γ i 's coincide, the surface operator has a more generic form. Let us consider for example the case in which the SU(N ) gauge field at the defect takes the form (see (2.8)): γ 1 , · · · , γ 1 , n 2 γ 2 , · · · , γ 2 , · · · , n M γ M , · · · , γ M dθ , (B.17) for r → 0, which corresponds to splitting the gauge group according to SU(N ) → S U(n 1 ) × U(n 2 ) × · · · × U(n M ) .  Here we see that it is the magnetic flux associated with the U(1) factor in each subgroup U(n I ) that appears in the expression for the generalized instanton number in the presence of magnetic fluxes.

C Ramified instanton moduli and their properties
In this appendix we describe the instanton moduli in the various sectors. Our results are summarized in Tab. 1. Let us first consider the neutral states of the strings stretching between two Dinstantons.
• (−1)/(−1) strings of type I-I: All moduli of this type transform in the adjoint representation (d I ,d I ) of U(d I ). A special role is played by the bosonic states created in the Neveu-Schwarz (NS) sector of such strings by the complex oscillator ψ v in the last complex space-time direction, which is neutral with respect to the orbifold. We denote them by χ I . They are characterized by a U(1) 4 weight {0, 0, 0, 0} and a charge (+1) with • (−1)/3 strings of type I-(I + 1): These open strings have mixed Dirichlet-Neumann boundary conditions along the (z 1 , z 2 )-directions and transform in the bi-fundamental representation (d I ×n I+1 ) of the gauge and ADHM groups. As compared to the previous case, the states in this sector are characterized by the action of an anti-twist operator∆ which carries an orbifold parity ω + 1 2 . Thus the Z M -invariant configurations must have again weights with l 2 − l 3 = 1/2 in order to compensate for the ω −1 factor carried by the Chan-Paton indices. Taking this into account, we find two complex doublets: (ŵ I ,μ I ) where the NS componentŵ I has weight + 1 2 , + 1 2 , 0, 0 and charge 0, and the R component µ I has weight 0, 0, − 1 2 , − 1 2 and charge (+ 1 2 ), and (μ I ,ĥ I ) whereμ I is associated to the R ground state with weight 0, 0, − 1 2 , + 1 2 and charge (− 1 2 ), whileĥ I is an auxiliary field. Also the complex conjugate doublets, associated to the 3/(−1) strings of type (I + 1)-I, are present in the spectrum.
Notice that no states from the 3/(−1) strings of type I-(I + 1) or from the (−1)/3 strings of type (I + 1)-I survive the orbifold projection. Indeed, in the first case the phases ω − 1 2 and ω −1 from the twist operator ∆ and the Chan-Paton factors cannot be compensated by the NS or R weights; while in the second case the phases ω + 1 2 and ω +1 from the anti-twist operator∆ and the Chan-Paton factors cannot be canceled.
All the above results are summarized in Tab. 1, which contains also other relevant information about the moduli. As an illustrative example, we now consider in detail the SU(2) theory.

C.1 SU(2)
In this case we have M = 2, and thus necessarily n 1 = n 2 = 1. Therefore, in the SU(2) theory we have only simple surface operators. Furthermore, since the index s takes only one value, we can simplify the notation and suppress this index in the following.

(C.5)
In the case of two boxes, we have five different pairs of tableaux that can contribute. Multiplying all contributions with the appropriate weight factor and summing over them, we obtain the instanton partition function for the SU(2) gauge theory in the presence of the surface operator: Z inst [1, 1] = 1 + q 1 ( 1 + 4 ) (4a + 2 1 + 2 + 2 4 ) σ 1 (k) k q k = − 1 24 log q + log η (D. 5) with η being the Dedekind η-function. Finally, the root lattice sums are defined by C n;m 1 ,m 2 ,··· ,m k = α∈Φ β 1 = β 2 =··· = β k ∈Φ( α) 1 ( α · a) n ( β 1 · a) m 1 ( β 2 · a) m 1 · · · ( β k · a) m k (D. 6) where Φ is the root system of SU(N ) and We refer to [41] for the details and the derivation of these results. Notice, however, that we have slightly changed our notation, since f here 2 = f there . By expanding the modular functions in powers of q and selecting SU(2) as gauge group, it is easy to show that the above formulas reproduce both the perturbative part and the instanton contributions, reported respectively in (4.10a) and (3.42) of the main text.