Instantons, Topological Strings and Enumerative Geometry

We review and elaborate on certain aspects of the connections between instanton counting in maximally supersymmetric gauge theories and the computation of enumerative invariants of smooth varieties. We study in detail three instances of gauge theories in six, four and two dimensions which naturally arise in the context of topological string theory on certain non-compact threefolds. We describe how the instanton counting in these gauge theories are related to the computation of the entropy of supersymmetric black holes, and how these results are related to wall-crossing properties of enumerative invariants such as Donaldson-Thomas and Gromov-Witten invariants. Some features of moduli spaces of torsion-free sheaves and the computation of their Euler characteristics are also elucidated.


Introduction
Topological theories in physics usually relate BPS quantities to geometrical invariants of the underlying manifolds on which the physical theory is defined. For the purposes of the present article, we shall focus on two particular and well-known instances of this. The first is instanton counting in supersymmetric gauge theories in four dimensions, which gives the Seiberg-Witten and Donaldson-Witten invariants of four-manifolds. The second is topological string theory, which is related to the enumerative geometry of Calabi-Yau three-folds and computes, for example, Gromov-Witten invariants, Donaldson-Thomas invariants, Gopakumar-Vafa BPS invariants, and key aspects of Kontsevich's homological mirror symmetry conjecture.
From a physical perspective, these topological models are not simply of academic interest, but they also serve as exactly solvable systems which capture the physical content of certain sectors of more elaborate systems with local propagating degrees of freedom. Such is the case for the models we will consider in this paper, which are obtained as topological twists of a given physical theory. The topologically twisted theories describe the BPS sectors of physical models, and compute nonperturbative effects therein. For example, for certain supersymmetric charged black holes, the microscopic Bekenstein-Hawking-Wald entropy is computed by the Witten index of the relevant supersymmetric gauge theory. This is equivalent to the counting of stable BPS bound states of D-branes in the pertinent geometry, and is related to invariants of threefolds via the OSV conjecture [70].
From a mathematical perspective, we are interested in counting invariants associated to moduli spaces of coherent sheaves on a smooth complex projective variety X. To define such invariants, we need moduli spaces that are varieties rather than algebraic stacks. The standard method is to choose a polarization on X and restrict attention to semistable sheaves. If X is a Kähler manifold, then a natural choice of polarization is provided by a fixed Kähler two-form on X. Geometric invariant theory then constructs a projective variety which is a coarse moduli space for semistable sheaves of fixed Chern character. In this paper we will be interested in the computation of suitably defined Euler characteristics of certain moduli spaces, which are the basic enumerative invariants. We shall also compute more sophisticated holomorphic curve counting invariants of a Calabi-Yau threefold X, which can be defined using virtual cycles of the pertinent moduli spaces and are invariant under deformations of X. In some instances the two types of invariants coincide.
An alternative approach to constructing moduli varieties is through framed sheaves. Then there is a projective Quot scheme which is a fine moduli space for sheaves with a given framing. A framed sheaf can be regarded as a geometric realization of an instanton in a noncommutative gauge theory on X [28,46,75] which asymptotes to a fixed connection at infinity. The noncommutative gauge theory in question arises as the worldvolume field theory on a suitable arrangement of D-branes in the geometry. In Nekrasov's approach [66], the set of observables that enter in the instanton counting are captured by the infrared dynamics of the topologically twisted gauge theory, and they compute the intersection theory of the (compactified) moduli spaces. The purpose of this paper is to overview the enumeration of such noncommutative instantons and its relation to the standard counting invariants of X.
In the following we will describe the computation of BPS indices of stable D-brane states via instanton counting in certain noncommutative and q-deformations of gauge theories on branes in various dimensions. We will pay particular attention to three non-compact examples which each arise in the context of Type IIA string theory: (1) D6-D2-D0 bound states in D6-brane gauge theory -These compute Donaldson-Thomas invariants and describe atomic configurations in a melting crystal model [69]. This also provides a solid example of a (topological) gauge theory/string theory duality. The counting of noncommutative instantons in the pertinent topological gauge theory is described in detail in ref. [20].
(2) D4-D2-D0 bound states in D4-brane gauge theory -These count black hole microstates and allow us to probe the OSV conjecture. Their generating functions also appear to be intimately related to two-dimensional rational conformal field theory.
(3) D2-D0 bound states in D2-brane gauge theory -These compute Gromov-Witten invariants of local curves. Instanton counting in the two-dimensional gauge theory on the base of the fibration is intimately related to instanton counting in the four-dimensional gauge theory obtained by wrapping supersymmetric D4-branes around certain non-compact four-cycles C, and also to the enumeration of flat connections in Chern-Simons theory on the boundary of C. These interrelationships are explored in detail in refs. [15,16,17,39].
These counting problems provide a beautiful hierarchy of relationships between topological string theory/gauge theory in six dimensions, four-dimensional supersymmetric gauge theories, Chern-Simons theory in three dimensions, and a certain q-deformation of two-dimensional Yang-Mills theory. They are also intimately related to two-dimensional conformal field theory.

Topological string theory
The basic setting in which to describe all gauge theories that we will analyse in this paper within a unified framework is through topological string theory, although many aspects of these models are independent of their connection to topological strings. In this section we briefly discuss some physical and mathematical aspects of topological string theory, and how they naturally relate to the gauge theories that we are ultimately interested in. Further details about topological string theory can be found in e.g. ref. [54], or in ref. [78] which includes a more general introduction. Introductory and advanced aspects of toric geometry are treated in the classic text [31] and in the reviews [22]. The standard reference for the sheaf theory that we use is the book [42], while a more physicist-geared introduction with applications to string theory can be found in the review [5].

Topological strings and Gromov-Witten theory
Topological string theory may be regarded as a theory whose state space is a "subspace" of that of the full physical Type II string theory. It is designed so that it can resolve the mathematical problem of counting maps f : Σ g −→ X (2.1) from a closed oriented Riemann surface Σ g of genus g into some target space X. In the physical Type II theory, any harmonic map f , with respect to chosen metrics on Σ g and X, are allowed. They are described by solutions to second order partial differential equations, the Euler-Lagrange equations obtained from a variational principle based on a sigma-model. The simplification supplied by topological strings is that one replaces this sigma-model on the worldsheet Σ g by a two-dimensional topological field theory, which can be realized as a topological twist of the original N = 2 superconformal field theory. In this reduction, the state space descends to its BRST cohomology defined with respect to the N = 2 supercharges, which naturally carries a Frobenius algebra structure. This defines a consistent quantum theory if and only if the target space X is a Calabi-Yau threefold, i.e. a complex Kähler manifold of dimension dim C (X) = 3 with trivial canonical holomorphic line bundle K X , or equivalently trivial first Chern class c 1 (X) := c 1 (K X ) = 0. We fix a closed nondegenerate Kähler (1, 1)-form ω on X.
The corresponding topological string amplitudes F g have interpretations in compactifications of Type II string theory on the product of the target space X with four-dimensional Minkowski space R 3,1 . For instance, at genus zero the amplitude F 0 is the prepotential for vector multiplets of N = 2 supergravity in four dimensions. The higher genus contributions F g , g ≥ 1 correspond to higher derivative corrections of the schematic form R 2 T 2g−2 , where R is the curvature and T is the graviphoton field strength. We will now explain how to compute the amplitudes F g . There are two types of topological string theories that we consider in turn.

A-model
The A-model topological string theory isolates symplectic structure aspects of the Calabi-Yau threefold X. It is built on holomorphically embedded curves (2.1). The holomorphic string maps f in this case are called worldsheet instantons. They are classified topologically by their homology classes β = f * [Σ g ] ∈ H 2 (X, Z) .
With respect to a basis S i of two-cycles on X, one can write where the Betti number b 2 (X) is the rank of the second homology group H 2 (X, Z), and n i ∈ Z.
Due to the topological nature of the sigma-model, the string theory functional integral localizes equivariantly (with respect to the BRST cohomology) onto contributions from worldsheet instantons.
The sum over all maps can be encoded in a generating function F X top (g s , Q) which depends on the string coupling g s and a vector of variables Q = (Q 1 , . . . , Q b 2 (X) ) defined as follows. Let t i = S i ω be the complex Kähler parameters of X with respect to the basis S i . They appear in the values of the sigma-model action evaluated on a worldsheet instanton. For an instanton in curve class (2.2), the corresponding Boltzmann weight is Then the quantum string theory is described by a genus expansion of the free energy weighted by the Euler characteristic χ(Σ g ) = 2 − 2g of Σ g , where the genus g contribution to the statistical sum is given by F g (Q) = β∈H 2 (X,Z) N g,β (X) Q β , and in this formula the classes β = 0 correspond to worldsheets of genus g. The numbers N g,β (X) are called the Gromov-Witten invariants of X and they "count", in an appropriate sense, the number of worldsheet instantons (holomorphic curves) of genus g in the two-homology class β. They can be defined as follows.
A worldsheet instanton (2.1) is said to be stable if the automorphism group Aut(Σ g , f ) is finite. Let M g (X, β) be the (compactified) moduli space of isomorphism classes of stable holomorphic maps (2.1) from connected genus g curves to X representing β. This is the instanton moduli space onto which the path integral of topological string theory localizes. It is a proper Deligne-Mumford stack over C which generalizes the moduli space M g of "stable" curves of genus g. While the dimension of M g is 3g − 3, the moduli space M g (X, β) is in general reducible and of impure dimension, as all possible stable maps occur. However, there is a perfect obstruction theory [38] which generically has virtual dimension When X is a Calabi-Yau threefold, this integer vanishes and there is a virtual fundamental class [38] M g (X, β) vir ∈ CH 0 M g (X, β) in the degree zero Chow group. In this case we define and so the Gromov-Witten invariants give the "virtual numbers" of worldsheet instantons. One generically has N g,β (X) ∈ Q due to the orbifold nature of the moduli stack M g (X, β). One can also define invariants by integrating the Euler class of an obstruction bundle over M g (X, β). There are precise recipes for computing the Gromov-Witten invariants N g,β (X) for toric varieties X.

B-model
The B-model topological string theory isolates complex structure aspects of the Calabi-Yau threefold X. It enumerates the constant string maps which send the entire surface Σ g to a fixed point in X, and hence have trivial curve class β = 0. The Gromov-Witten invariants in this case are completely understood. There is a natural isomorphism M g (X, 0) ∼ = M g × X , and the degree zero Gromov-Witten invariants N g,0 (X) involve only the classical cohomology ring H • (X, Q) and "Hodge integrals" over the moduli spaces of Riemann surfaces M g defined as follows.
There is a canonical stack line bundle L → M g with fibre T * Σg over the moduli point [Σ g ], the cotangent space of Σ g at some fixed point. We define the tautological class ψ to be the first Chern class of L, ψ := c 1 (L) ∈ H 2 (M g , Q). The Hodge bundle E → M g is the complex vector bundle of rank g whose fibre over a point Σ g is the space H 0 (Σ g , K Σg ) of holomorphic sections of the canonical line bundle K Σg → Σ g . Let λ j := c j (E) ∈ H 2j (M g , Q). A Hodge integral over M g is an integral of products of the classes ψ and λ j .
Explicit expressions for N g,0 (X) for generic threefolds X are then obtained as follows. Let {γ a } a∈A be a basis for H • (X, Z) (modulo torsion), and let D 2 ⊂ A index the generators of degree two. Then one has where the Hodge integral can be expressed in terms of Bernoulli numbers as Note that c 1 (X) = 0 above when X is Calabi-Yau.
Thus we know how to compute everything in the B-model, and it is completely under control. Our main interest is thus in extending these computations to the A-model. In analogy with the above considerations, one can note that there is a natural forgetful map and then reduce any integral over M g (X, β) to M g using the corresponding Gysin push-forward map π ! . However, this is difficult to do explicitly in most cases. The Gromov-Witten theory of X is the study of tautological intersections in the moduli spaces M g (X, β). There is a string duality between the A-model and the B-model which is related to homological mirror symmetry.

Open topological strings
An open topological string in X is described by a holomorphic embedding f : Σ g,h → X of a curve Σ g,h of genus g with h holes. A D-brane in X is a choice of Dirichlet boundary condition on these string maps, which ensures that the Cauchy problem for the Euler-Lagrange equations on Σ g,h locally has a unique solution. They correspond to Lagrangian submanifolds L of the Calabi-Yau threefold X, i.e. ω| L = 0. If ∂Σ g,h = σ 1 ∪ · · · ∪ σ h , then we consider holomorphic maps such that This defines open string instantons, which are labelled by their relative homology classes If we assume that b 1 (L) = 1, so that H 1 (L, Z) is generated by a single non-trivial one-cycle γ, then where w i ∈ Z, i = 1, . . . , h are the winding numbers of the boundary maps f | σ i .
The free energy of the A-model open topological string theory at genus g is given by where w = (w 1 , . . . , w h ) and the numbers N w,g,β (X) are called relative Gromov-Witten invariants.
To incorporate all topological sectors, in addition to the string coupling g s weighting the Euler characteristics χ(Σ g,h ) = 2 − 2g − h, we introduce an N × N Hermitean matrix V to weight the different winding numbers. This matrix is associated to the holonomy of a gauge connection (Wilson line) on the D-brane. Then, taking into account that the holes are indistinguishable, the complete genus expansion of the generating function is The traces are computed by formally taking the limit N → ∞ and expanding in irreducible representations R of the D-brane gauge group U (∞).

Black hole microstates and D-brane gauge theory
When X is a Calabi-Yau threefold, certain BPS black holes on X × R 3,1 can be constructed by D-brane engineering. D-branes in X correspond to submanifolds of X equipped with vector bundles with connection, the Chan-Paton gauge bundles, and they carry charges associated with the Chern characters of these bundles. This data defines a class in the differential K-theory of X, which provides a topological classification of D-branes in X.
The microscopic black hole entropy can be computed by counting stable bound states of D0-D2-D4-D6 branes wrapping holomorphic cycles of X with the following configurations: • D6-brane charge Q 6 ; • D4-branes wrapping an ample divisor with respect to a basis of four-cycles C i , i = 1, . . . , b 4 (X) = b 2 (X), of X; • D2-branes wrapping a two-cycle These D-brane charges give the black hole its charge quantum numbers. If we consider large enough numbers of D-branes in this system, then they form bound states which become large black holes with smooth event horizons, that can be counted and therefore account for the microscopic black hole entropy. In this scenario p I = (Q 6 , Q i 4 ) are interpreted as magnetic charges, and q I = (Q 0 , Q i 2 ) as electric charges. The thermal partition function defined via a canonical ensemble for the D0 and D2 branes with chemical potentials µ I = (φ 0 , φ 2 i ), and a microcanonical ensemble for the D4 and D6 branes, is given by where Ω is the degeneracy of BPS states with the given D-brane charges.
As we mentioned in Section 2.1., the closed topological string amplitudes F g are related to supergravity quantities on Minkowski spacetime R 3,1 . The fact that the genus zero free energy F 0 for topological strings on X is a prepotential for BPS black hole charges in N = 2 supergravity determines the entropy S BH (p, q) of an extremal black hole as a Legendre transformation of F 0 , provided that one fixes the charge moduli by the attractor mechanism. The genus zero topological string amplitude F 0 is a homogeneous function of degree two in the N = 2 vector multiplet fields X I . The black hole entropy in the supergravity approximation is then where the chemical potentials µ I are determined by the charges p I and q I by solving the equation Further analyses of the entropy of N = 2 BPS black holes on R 3,1 have been extended to higher genus and suggest the relationship between the black hole partition function (2.4) and the topological string partition function where the moduli on both sides of this equation are related by their fixing at the attractor point The remarkable relationship (2.5) is called the OSV conjecture [70]. It provides a means of using the perturbation expansion of topological strings and Gromov-Witten theory to compute black hole entropy to all orders. Alternatively, although the evidence for this proposal is derived for large black hole charge, the left-hand side of the expression (2.5) makes sense for finite charges and in some cases is explicitly computable in closed form. It can thus be used to define non-perturbative topological string amplitudes, and hence a non-perturbative completion of a string theory.
In the following we will focus on the computation of the black hole partition function (2.4). The fact that this partition function is computable in a D-brane gauge theory will then give a physical interpretation of the enumerative invariants of X in terms of black hole entropy. Suppose that we have a collection of Dp-branes wrapping a submanifold M p+1 ⊂ X, with dim R (M p+1 ) = p + 1 and Chan-Paton gauge field strength F . D-branes are charged with respect to supergravity differential form fields, the Ramond-Ramond fields, which are also classified topologically by differential Ktheory. Recall that such an array couples to all n-form Ramond-Ramond fields C (n) through anomalous Chern-Simons couplings where √ α ′ is the string length. In particular, these couplings contain all terms and so the topological charge ch m (E) of a Chan-Paton gauge bundle E → M p+1 on a Dp-brane is equivalent to D(p − 2m)-brane charge. A prominent example of this, which will be considered in detail later on, is the coupling M p+1 C (p−3) ∧ Tr F ∧ F . For p = 3, this shows that the counting of D4-D0 brane bound states is equivalent to the enumeration of instantons on the four-dimensional part of the D4-brane in X. The remaining sections of this paper look at these relationships from the point of view of various BPS configurations of these D-branes. We will study the enumeration problems from the point of view of gauge theories on the D-branes in order of decreasing dimensionality, stressing the analogies between each description.

D6-brane gauge theory and Donaldson-Thomas invariants
In this section we will look at a single D6-brane (Q 6 = 1) and turn off all D4-brane charges (Q i 4 = 0). We will discuss various physical theories which are modelled by the D6-brane gauge theory in this case, but otherwise have no a priori relation to string theory. These will include a tractable model for quantum gravity and the statistical mechanics of certain atomic crystal configurations. From the perspective of enumerative geometry, these partition functions will compute the Donaldson-Thomas theory of X.

Kähler quantum gravity
We will construct a model of quantum gravity on any Kähler threefold X, which will motivate the sorts of counting problems that we consider in this section. The partition function is defined by The sum is over "quantized" Kähler two-forms on X, in the following sense. We decompose the "macroscopic" form ω into a fixed "background" Kähler two-form ω 0 on X and the curvature F of a holomorphic line bundle L over X as To satisfy the requirement that there are no D4-branes in X, we impose the fluctuation condition for all two-cycles β ∈ H 2 (X, Z).

Substituting (3.3) together with (3.4) into (3.2) gives the action
The statistical sum (3.1) thus becomes (dropping an irrelevant constant term) where q = − e −gs , Q i = e −t i , and ch m (L) denotes the m-th Chern character of the given line bundle L → X. Note the formal similarity with the A-model topological string partition function constructed in Section 2.1. However, there is a problem with the way in which we have thus far set up this model. The fluctuation condition (3.4) on F implies ch 2 (L) = ch 3 (L) = 0. Hence only trivial line bundles can contribute to the sum (3.6), and the partition function is trivial.
The resolution to this problem is to enlarge the range of summation in (3.6) to include singular gauge fields and ideal sheaves. Namely, we take F to correspond to a singular U (1) gauge field A on X. This can be realized in two (related) possible ways: (1) We can make a singular gauge field A non-singular on the blow-up X −→ X of the target space, obtained by blowing up the singular points of A on X into copies of the complex projective plane P 2 . This means that the quantum gravitational path integral induces a topology change of the target space X. This is refered to as "quantum foam" in refs. [11,43]; or (2) We can relax the notion of line bundle to ideal sheaf. Ideal sheaves lift to line bundles on X.
However, there are "more" sheaves on X than blow-ups X of X.
In this paper we will take the second point of view. Recall that torsion free sheaves E on X can be defined by the property that they sit inside short exact sequences of sheaves of the form where F is a holomorphic vector bundle on X, and S Z is a coherent sheaf supported at the singular points Z ⊂ X of a gauge connection A of F. Applying the Chern character to (3.7) and using its additivity on exact sequences gives for each m. Thus torsion free sheaves E fail to be vector bundles at singular points of gauge fields, and including the singular locus can reinstate the non-trivial topological quantum numbers that we desired above.
As we will discuss in detail in this section, this construction is realized explicitly by considering a noncommutative gauge theory on the target space X = C 3 . We shall see that the instanton solutions of gauge theory on a noncommutative deformation C 3 θ are described in terms of ideals I in the polynomial ring C[z 1 , z 2 , z 3 ]. For generic X, the global object that corresponds locally to an ideal is an ideal sheaf, which in each coordinate patch U α ⊂ X is described as an ideal I Uα in the ring O Uα of holomorphic functions on U α . More abstractly, an ideal sheaf is a rank one torsion free sheaf E with c 1 (E) = 0. This is a purely commutative description, since the holomorphic functions on C 3 form a commutative subalgebra of C 3 θ for the Moyal deformation that we will consider. Thus the desired singular gauge field configurations will be realized explicitly in terms of noncommutative instantons [11,43].

Crystal melting and random plane partitions
As we will see, the counting of ideal sheaves is in fact equivalent to a combinatorial problem, which provides an intriguing connection between the Kähler quantum gravity model of Section 3.1. and a particular statistical mechanics model [69]. Consider a cubic crystal located on the lattice Z 3 ≥0 ⊂ R 3 . Suppose that we start heating the crystal at its outermost right corner. As the crystal melts, we remove atoms, depicted symbolically here by boxes, and arrange them into stacks of boxes in the positive octant. Owing to the rules for arranging the boxes according to the order in which they melt, this configuration defines a plane partition or a three-dimensional Young diagram Removing each atom from the corner of the crystal contributes a factor q = e −µ/T to the Boltzmann weight, where µ is the chemical potential and T is the temperature.
such that π i,j ≥ π i+1,j , π i,j ≥ π i,j+1 for all i, j ≥ 1. We may regard a partition π as a threedimensional Young diagram, in which we pile π i,j cubes vertically at the (i, j)-th position in the plane as depicted above. The volume of a plane partition is the total number of cubes. The diagonal slices of π are the partitions (π i,i+m ) i≥1 , m ≥ 0 obtained by cutting the three-dimensional Young diagram with planes, and they represent a sequence of ordinary partitions (Young tableaux) λ = (λ 1 , λ 2 , . . . ), with λ i ≥ λ i+1 for all i ≥ 1. Here λ i ≥ 0 is the length of the i-th row of the Young diagram, viewed as a collection of unit squares, and only finitely many λ i are non-zero.
The counting problem for random plane partitions can be solved explicitly in closed form. For this, we consider the statistical mechanics in a canonical ensemble in which each plane partition π has energy proportional to its volume |π|. The corresponding partition function then gives the generating function for plane partitions where pp(N ) is the number of plane partitions π with |π| = N boxes. The function M (q) is called the MacMahon function.

Six-dimensional cohomological gauge theory
We will now describe a U (1) gauge theory formulation of the above statistical models [43,20]. If we gauge fix the residual symmetry of the quantized Kähler gravity action (3.5), we obtain the action is the gauge covariant derivative acting on the complex scalar field Φ, ⋆ denotes the Hodge operator with respect to the Kähler metric of X, and F = dA is the curvature two-form which has the Kähler decomposition F = F 2,0 + F 1,1 + F 0,2 . The field theory defined by this action arises in three (related) instances as: (1) A topological twist of maximally supersymmetric Yang-Mills theory in six dimensions; (2) The dimensional reduction of supersymmetric Yang-Mills theory in ten dimensions on X; and (3) The low-energy effective field theory on a D6-brane wrapping X in Type IIA string theory, with D2 and D0 brane sources.
The gauge theory has a BRST symmetry [7,40] and its partition function localizes at the BRST fixed points described by the equations (3.10) These equations also describe three (related) quantities: • The Donaldson-Uhlenbeck-Yau (DUY) equations expressing Mumford-Takemoto slope stability of holomorphic vector bundles over X with finite characteristic classes; • BPS solutions in the gauge theory which correspond to (generalized) instantons; and • Bound states of D0-D2 branes in a single D6-brane wrapping X.
Recall that the equations (3.10) and (3.11) are a special instance of the Hermitean Yang-Mills equations in which a constant λ is added to the right-hand side of (3.11). These equations arise in compactifications of heterotic string theory. The condition that the compactification preserves at least one unbroken supersymmetry requires λ = 0. These are the natural BPS conditions on a Kähler manifold (X, ω 0 ) which generalize the usual self-duality equations in four dimensions.
The localization of the gauge theory partition function Z onto the corresponding instanton moduli space M X can be written symbolically as [40,43] where e(N X ) is the Euler class of the obstruction bundle N X whose fibres are spanned by the zero modes of the antighost fields. The zero modes of the fermion fields in the full supersymmetric extension of (3.9) [7,40] are in correspondence with elements in the cohomology groups of the twisted Dolbeault complex Ω 0,0 (X, ad P) with ad P the adjoint gauge bundle over X. By incorporating the gauge fields one can rewrite this complex in the form [43] Ω 0,0 (X, ad P) / / Ω 0,1 (X, ad P) ⊕ Ω 0,3 (X, ad P) / / Ω 0,2 (X, ad P) , which describes solutions of the DUY equations up to linearized complex gauge transformations. The morphism Ω 0,3 (X, ad P) → Ω 0,2 (X, ad P) here is responsible for the appearence of the obstruction bundle in (3.13) [40,43].
In order for the integral (3.13) to be well-defined, we need to choose a compactification of M X . In light of our earlier discussion, we will take this to be the Gieseker compactification, i.e. the moduli space of ideal sheaves on X. The corresponding variety M X stratifies into components Hilb n,β (X) given by the Hilbert scheme of points and curves in X, parametrizing isomorphism classes of ideal sheaves E with ch 1 (E) = c 1 (E) = 0, ch 2 (E) = −β, and ch 3 (E) = −n. The partition function (3.13) is the generating function for the number of D0-D2 brane bound states in the D6brane wrapping X. Mathematically, these are the Donaldson-Thomas invariants of X. We will define this moduli space integration, and hence these invariants, more precisely in Section 3.9.

Localization in toric geometry
Toric varieties provide a large class of algebraic varieties in which difficult problems in algebraic geometry can be reduced to combinatorics. Much of this paper will be concerned with these geometries as they possess symmetries which facilitate computations, particularly those involving moduli space integrations. Let us start by recalling some basic notions from toric geometry. Below we give the pertinent definitions specifically in the case of varieties of complex dimension three, the case of immediate interest to us, but they extend to arbitrary dimensions in the obvious ways.
A smooth complex threefold X is called a toric manifold if it densely contains a (complex algebraic) torus T 3 and the natural action of T 3 on itself (by translations) extends to the whole of X. Basic examples are the torus T 3 itself, the affine space C 3 , and the complex projective space P 3 . If in addition X is Calabi-Yau, then X is necessarily non-compact.
One of the great virtues of working with toric varieties X is that their geometry can be completely described by combinatorial data encoded in a toric diagram. The toric diagram is a graph consisting of the following ingredients: • A set of vertices f which are the fixed points of the T 3 -action on X, such that X can be covered by T 3 -invariant open charts homeomorphic to C 3 ; • A set of edges e which are T 3 -invariant projective lines P 1 ⊂ X joining particular pairs of fixed points f 1 , f 2 ; and • A set of "gluing rules" for assembling the C 3 patches together to reconstruct the variety X.
In a neighbourhood of each edge e, X looks like the normal bundle over the corresponding P 1 . Since this normal bundle is a holomorphic bundle of rank two and every bundle over P 1 is a sum of line bundles (by the Grothendieck-Birkhoff theorem), it is of the form for some integers m 1 , m 2 . The normal bundle in this way determines the local geometry of X near the edge e via the transition function between the corresponding affine patches (going from the north pole to the south pole of the associated P 1 ). In the Calabi-Yau case, the Chern numbers c 1 (X) = 0 and c 1 (P 1 ) = 2 imply the condition m 1 + m 2 = 2.
For an open toric manifold X, we can exploit the toric symmetries to regularize the infrared singularities on the instanton moduli space M X by "undoing" the T 3 -rotations by gauge transformations [66]. In this way we will compute our moduli space integrals by using techniques from equivariant localization, which in the present context will be refered to as toric localization. Recall that the bosonic sector of the topologically twisted theory comprises a gauge connection A i and a complex Higgs field Φ. In particular, the supercharges contain a scalar Q and a vector Q i . Generically, only Q is conserved and can be used to define the topological twist of the gauge theory. If the threefold X has symmetries then one can also use Q i . In the generic formulation of the theory, one only considers the scalar topological charge Q and restricts attention to gauge-invariant observables. But in the present case one can also use the linear combination where ǫ a are the parameters of the isometric action of T 3 ⊂ U (3) on the Kähler space C 3 , and Ω a = Ω a ij x j ∂ ∂x i are vector fields which generate SO(6) rotations of C 3 ∼ = R 6 . In this case we also consider observables which are only gauge-invariant up to a rotation. This means that the new observables are equivariant differential forms and the BRST charge Q Ω can be interpreted as an equivariant differential d + ı Ω on the space of field configurations, where ı Ω acts by contraction with the vector field Ω.
This procedure modifies the action and the equations of motion by mixing gauge invariance with rotations. This set of modifications can sometimes be obtained by defining the gauge theory on an appropriate supergravity background called the "Ω-background". In particular, the fixed point equation (3.12) is modified to 14) The set of equations (3.10), (3.11) and (3.14) minimizes the action of the cohomological gauge theory in the Ω-background, and describes T 3 -invariant instantons (or, as we shall see, ideal sheaves). In particular, there is a natural lift of the toric action to the instanton moduli space M X . We will henceforth study the gauge theory equivariantly, and interpret the truncation of the partition function (3.13) as an equivariant integral over M X . This will always mean that we work solely in the Coulomb branch of the gauge theory. Due to the equivariant deformation of the BRST charge, these moduli space integrals can be computed via equivariant localization.

Equivariant integration over moduli spaces
We now explain the localization formulas that will be used to compute partition functions throughout this paper. Let M be a smooth algebraic variety. Then we can define theT -equivariant coho-  (1)). The Atiyah-Bott localization formula in equivariant cohomology states that where the complex vector bundle N → MT is the normal bundle over the (compact) fixed point submanifold in M. When MT consists of finitely many isolated points f , this formula simplifies to Each term in this sum takes values in the polynomial ring in the generators ofT = U (1) N × T k . When the manifold M is non-compact, integration along the fibre is not a well-defined Q-linear map. Nevertheless, when MT is compact, we can formally define the equivariant integral M α by the right-hand side of the formula (3.15).
Going back to our example, when X = C 3 , one has ch 2 (E) = 0 and the partition function Z is saturated by contributions from isolated, pointlike instantons (D0-branes) by a formal application of the localization formula (3.16). However, these expressions are all rather symbolic, as we are not guaranteed that the algebraic scheme M X is a smooth variety, i.e. that the instanton moduli space has a well-defined stable tangent bundle with tangent spaces all of the same dimension. However, the variety M X is generically smooth and there is a well-defined virtual tangent bundle. The moduli space integration (3.16) can then be formally defined by virtual localization in equivariant Chow theory. As discussed in ref. [56], the (stratified components of the) instanton moduli space M X carries a canonical perfect obstruction theory in the sense of ref. [38]. In obstruction theory, the virtual tangent space at a point [E] ∈ M X is given by . Its dimension is given by the difference of Euler characteristics In this case, one may construct a virtual fundamental class [M] vir and apply a virtual localization formula. The general theory is developed in ref. [38] and requires a T k -equivariant embedding of M in a smooth variety Y. The existence of such an embedding in the present case follows from the stratification of M X into Hilbert schemes of points and curves. Then one can deduce the localization formula over M from the known ambient localization formula over the smooth variety Y, as above. In this paper we shall only need a special case of this general framework, the virtual Bott residue formula.
We can decompose E i into T k -eigenbundles. The scheme theoretic fixed point locus M T k is the maximal T k -fixed closed subscheme of M. It carries a canonical perfect obstruction theory, defined by the T k -fixed part of the restriction of the complex E • to M T k , which may be used to define a virtual structure on M T k . The sum of the non-zero T k -weight spaces of E • M T k defines the virtual normal bundle N vir to M T k . Define the Euler class of a virtual bundle A = A 1 ⊖ A 2 using formal multiplicativity, i.e. as the ratio of the Euler classes of the two bundles, e(A) = e(A 1 )/e(A 2 ). Then the virtual Bott localization formula for the Euler class of a bundle A of rank equal to the virtual dimension of M reads [38] [M] vir where the integration is again defined via pushforward maps. The equivariant Euler classes on the right-hand side of this formula are invertible in the localized equivariant Chow ring of the scheme M given by If M is smooth, then M T k is the non-singular set theoretic fixed point locus, consisting here of finitely many points [E]. However, in general the formula (3.17) must be understood scheme theoretically, here as a sum over T k -fixed closed subschemes of M supported at the points , i = 1, 2 denoting the induced torus actions on the tangent and obstruction bundles on M, one generically has decompositions The right-hand side of this formula again takes values in the polynomial ring ∈ M X , the moduli space M X is a smooth algebraic variety with the trivial perfect obstruction theory and this equation reduces immediately to the standard localization formula in equivariant cohomology given above. In this paper we will make the natural choice for the bundle A, the virtual tangent bundle T vir M itself.

Noncommutative gauge theory
To compute the instanton contributions (3.13) to the partition function of the cohomological gauge theory, we have to resolve the small instanton ultraviolet singularities of M X . This can be achieved by replacing the space X = C 3 ∼ = R 6 with its noncommutative deformation R 6 θ defined by letting the coordinate generators x i , i = 1, . . . , 6 satisfy the commutation relations of the Weyl algebra is a constant 6 × 6 skew-symmetric matrix which we take in Jordan canonical form without loss of generality (by a suitable linear transformation of R 6 if necessary). We will assume that θ 1 , θ 2 , θ 3 > 0 for simplicity. The noncommutative polynomial algebra is regarded as the "algebra of functions" on the noncommutative space R 6 θ . We can represent the algebra A on the standard Fock module C|i, j, k , (3.19) where the orthonormal basis states |i, j, k are connected by the action of creation and annihilation operators α † a and α a , a = 1, 2, 3. They obey α a |0, 0, 0 = 0 and In the Weyl operator realization with the complex combinations of operators for a = 1, 2, 3, derivatives of fields are replaced by the inner automorphisms while spacetime averages are replaced by traces over H according to In the noncommutative gauge theory, we introduce the covariant coordinates and their complex combinations for a = 1, 2, 3. Then the (1, 1) and (2, 0) components of the curvature two-form can be respectively expressed as while the covariant derivatives of the Higgs field becomes The instanton equations (3.10), (3.11) and (3.14) then become algebraic equations These equations describe BPS bound states of the D0-D6 system in a B-field background, which is necessary for reinstating supersymmetry [59,79]. In addition, T 3 -invariance of the (unique) holomorphic three-form on X imposes the Calabi-Yau condition

Instanton moduli space
A major technical advantage of introducing the noncommutative deformation is that the instanton moduli space can be constructed explicitly, by solving the noncommutative instanton equations (3.20)-(3.22). First we construct the vacuum solution of the noncommutative gauge theory, with F = 0. It is obtained by setting A = 0 and is given explicitly by harmonic oscillator algebra Other solutions are found via the solution generating technique described in e.g. refs. [48,65]. For the general solution, fix an integer n ≥ 1 and let U n be a partial isometry on the Hilbert space H which projects out all states |i, j, k with i + j + k < n. Such an operator satisfies the equations is a Hermitean projection operator onto a finite-dimensional subspace of H. Then we make the ansatz where f is a real function of the number operator Using standard harmonic oscillator algebra, we can write the DUY equations (3.20)-(3.22) as This recursion relation has a unique solution with the initial conditions f (i) = 0, i = 0, 1, . . . , n − 1, and the finite energy condition f (r) → 1 as r → ∞. It is given by [72] f The topological charge of the corresponding noncommutative instanton is Thus the instanton number is the number of states in H with N < n, i.e. the number of vectors removed by U n , or equivalently the rank of the projector Π n .
The partial isometry U n identifies the full Fock space The instanton moduli space can thus be identified as the Hilbert scheme of ℓ points in X = C 3 . The Hilbert-Chow morphism identifies the Hilbert scheme of points as a crepant resolution of the (coincident point) singularities of the ℓ-th symmetric product orbifold of X. The ideal I defines a plane partition π with |π| = ℓ boxes given by Heuristically, this configuration represents instantons which sit on top of each other at the origin of C 3 , and along its coordinate axes where they asymptote to four-dimensional noncommutative instantons at infinity described by ordinary Young tableaux λ.

Donaldson-Thomas theory
We can finally compute the instanton contributions to the partition function of the cohomological gauge theory on any toric Calabi-Yau threefold X [43,20]. Let us start with the case X = C 3 . Using (3.25), the contribution of an instanton corresponding to a plane partition π contributes a factor exp − i g s 48π 3 Tr to the Boltzmann weight appearing in the functional integral. There is also a measure factor which comes from integrating out the bosonic and fermionic fields in the supersymmetric gauge theory. This yields a ratio of fluctuation determinants with the normalized character where we have used the solution for Φ in (3.24). Using the Calabi-Yau condition ǫ 1 + ǫ 2 + ǫ 3 = 0, it is easy to see that these determinants cancel up to a sign.
After some computation, one can explicitly determine this sign to get The contribution Z ∅ from the empty partition is the one-loop perturbative contribution to the functional integral, and hence will be dropped. Then the instanton sum for the partition function is given by which is just the MacMahon function M (q) with q = − e −gs . This is the known formula for the Donaldson-Thomas partition function on C 3 .
For later use, let us note a convenient resummation formula for this partition function [69]. Using interlacing relations, the sum over plane partitions π can be converted into a triple sum over the Young tableaux obtained from the main diagonal slice λ = (π i,i ) i≥1 , together with a sum over pairs of semi-standard tableaux of shape λ obtained by putting m + 1 of them in boxes of the skew diagram associated to the m-th diagonal slice for each m ≥ 0. The partial sum over each semi-standard tableaux coincides with the combinatorial definition of the Schur functions at a particular value, which can be expressed through the hook formula where n(λ) = i (i − 1) λ i , and h(i, j) is the hook length of the box located at position (i, j) in the Young tableau λ ⊂ Z 2 ≥0 . Then the partition function can be rewritten as a sum over ordinary partitions This construction can be generalized to arbitrary toric Calabi-Yau threefolds X by using the gluing rules of toric geometry. The two simplest such varieties are described by the toric diagrams conifold C 3 with a single vertex representing X = C 3 , whose partition function was computed above and is the basic building block for the generating functions on more complicated geometries, and a single line joining two vertices representing the resolved conifold X = O P 1 (−1) ⊕ O P 1 (−1), where the P 1 contribute to the F ∧ F ∧ ω 0 term of the gauge theory action (3.9). The T 3 -invariant noncommutative U (1) instantons on X correspond to ideal sheaves E and are described by the following combinatorial data: (2) Two-dimensional partitions λ e at each edge e of the toric diagram, representing the fourdimensional instanton asymptotics of π f . This description requires generalizing the calculation on X = C 3 above to compute the perpendicular partition function P λ,µ,ν (q) [69], which is defined to be the generating function for threedimensional partitions with fixed asymptotics λ, µ, and ν in the three coordinate directions. Such partitions correspond to instantons on C 3 θ with non-trivial boundary conditions at infinity along each of the coordinate axes. It can be expressed in terms of skew Schur functions, with For the example of the resolved conifold, using the gluing rules one easily computes More generally, with these rules one finds that the instanton partition function is the generating function for the Donaldson-Thomas invariants I n,β (X) ∈ Z, which are defined as follows. The moduli variety Hilb n,β (X) of ideal sheaves on X is a projective scheme with a perfect obstruction theory. For general threefolds X, it has virtual dimension [57, which coincides with that of M g (X, β) from Section 2.1. In the Calabi-Yau case, the virtual dimension is zero, and the corresponding virtual cycle is Hilb n,β (X) vir ∈ CH 0 Hilb n,β (X) .
Then the Donaldson-Thomas invariants count the virtual numbers of ideal sheaves on X with the given Chern character. The right-hand side is defined via equivariant integration, as explained in Section 3.5. The torus action on X lifts to the moduli scheme Hilb n,β (X). TheT -fixed locus Hilb n,β (X)T has aT -equivariant virtual theory with cycle [Hilb n,β (X)T ] vir ∈ CH 0 (Hilb n,β (X)T ) and virtual normal bundle N vir X in the equivariant K-theory K 0 T (Hilb n,β (X)T ). This construction gives precise meaning to the moduli space integral (3.13) via application of the virtual localization formula in equivariant Chow theory, described in Section 3.5.

Wall-crossing formulas
We will now make contact with Section 2. For the present class of threefolds X, there is a gauge theory/string theory duality [56]. This follows from the fact that the perpendicular partition function P λ,µ,ν (q) is related to the Calabi-Yau crystal formulation of the topological vertex i , which are the building blocks for the computation of the generating function for Gromov-Witten invariants using rules analogous to those described in Section 3.8. [54] Using these relations one can show that the six-dimensional cohomological gauge theory is S-dual to the A-model topological string theory. The respective partition functions are related by where the Euler characteristic χ(X) of X is the number of vertices in its toric diagram. For the conifold example, the gluing rules for the topological vertex yield [54] Z conifold which should be compared with (3.26). This Gromov-Witten/Donaldson-Thomas correspondence is known to hold for arbitrary toric threefolds [58]. The relationship (3.27) can be thought of as a wall-crossing formula, as we now explain.
The relationship (3.27) is in apparent contradiction with the OSV conjecture (2.5), if we wish to interpret the right-hand side as the generating function Z BH (1, 0, φ 2 , φ 0 ) of a suitable index for black hole microstates. However, the conjectural relations (2.5) and (3.27) hold in different regimes of validity. The number of BPS particles in four dimensions formed by wrapping supersymmetric bound states of D-branes around holomorphic cycles of X depends on the choice of a stability condition, and the BPS countings for different stability conditions are related by wall-crossing formulas. For example, stability of black holes requires that their chemical potentials µ I lie in the On the other hand, the validity of (3.27) is related to the existence of BPS invariants B g,β (X) ∈ Z such that the topological string amplitudes have an expansion given by [37] of which the conifold partition function (3.26) is an explicit case. These are partition functions of D6-D2-D0 brane bound states only for certain Kähler moduli. Analyses of Calabi-Yau compactifications of Type II string theory show that the Hilbert spaces of BPS states jump discontinuously across real codimension one walls in the moduli space of vacua, known as walls of marginal stability. The noncommutative instantons do not account for walls of marginal stability extending to infinity. One should instead apply some sort of stability condition (such as Π-stability) to elements of the bounded derived category of coherent sheaves D b (coh(X)) of the given charge, which gives a topological classification of A-model D-branes on X. These issues are discussed in more detail in refs. [44,18,2].
From a mathematical perspective, we can study this phenomenon by looking at framed moduli spaces, which consist of instantons that are trivial "at infinity". More precisely, we can consider a toric compactification of X obtained by adding a compactification divisor D ∞ , and consider sheaves F with a fixed trivialization on D ∞ . The Kähler polarization defined by ω 0 allows us to define the moduli space M ω 0 X = M X of stable sheaves. Then the symbolic definition of the gauge theory partition function (3.13) as a particular Euler characteristic can be made precise in the more local definition of Donaldson-Thomas invariants given by ref. [8].
As a scheme with a perfect obstruction theory, the instanton moduli space M X can be viewed locally as the scheme theoretic critical locus of a holomorphic function, the superpotential W , on a compact manifold X with the action of a gauge group G. M X has virtual dimension zero, and at non-singular points the obstruction sheaf N X on M X coincides with the cotangent bundle. Hence if M X were everywhere non-singular, then the partition function (3.13) would just compute the signed Euler characteristic (−1) dim C (M X ) χ(M X ). At singular points, however, the invariants differ from these characteristics.
There is a constructible function ν : M X → Z which can be used to define the weighted Euler characteristic For sheaves of fixed Chern character, this coincides with the curve-counting invariants I n,β (X). At non-singular points, ν = (−1) dim C (M X ) , while at singular points it is the more complicated function given by where MF W (E) is the Milnor fibre of the superpotential W at the point corresponding to E. The weighted Euler characteristic is a deformation invariant of X.
In this approach, one can use topological Euler characteristics to define I n,β (X) as invariants associated to moduli varieties of framed sheaves. Fixing β ∈ H 2 (X, Z) and n ∈ Z, the variety Hilb n,β (X) equivalently parametrizes isomorphism classes of the following objects: The equivalences between these three descriptions is described explicitly for X = C 3 in ref. [20].
As we vary the polarization ω 0 , the moduli spaces M ω 0 X (X) change and so do the associated counting invariants, leading to a wall-and-chamber structure. The wall-crossing behaviour of the enumerative invariants is studied in refs. [45,47]. The analog of varying ω 0 for framed sheaves is to consider quotients of the structure sheaf O X in different abelian subcategories of the bounded derived category D b (coh(X)) of coherent sheaves on X. The analog of wall-crossing gives the Pandharipande-Thomas theory of stable pairs [71] and the BPS invariants above. For this, the quotients of O X are the stable pairs (E, α), where E is a coherent O X -module of pure dimension one with ch 2 (E) = −β and χ(E) = −n, and α : O X → E is a non-zero sheaf map such that coker(α) is of pure dimension zero, together with le Poitier's δ-stability condition for coherent systems. In this case the change of Donaldson-Thomas invariants is described by the Kontsevich-Soibelman wall-crossing formula [47].
To cast these constructions into the language of noncommutative instantons, a proper definition of noncommutative toric manifolds is desired, beyond the heuristic approach presented above whereby only open C 3 patches are deformed. Isospectral type deformations of toric geometry, and instantons therein, are investigated in ref. [21]. It may also aid in the classification of U (N ) noncommutative instantons on C 3 for rank N > 1, along the lines of what was done in Section 3.7.
(See ref. [20] for some explicit examples.) This appears to be related to the problem of defining a non-abelian version of Donaldson-Thomas theory which counts higher-rank torsion-free sheaves, for which no general, appropriate notion of stability is yet known.

D4-brane gauge theory and Euler characteristics
In this section we will take Q 6 = 0 (no D6-branes), and consider N D4-branes wrapping a four-cycle C ⊂ X. In this case the worldvolume gauge theory on the D4-branes is the N = 4 Vafa-Witten topologically twisted U (N ) Yang-Mills theory on C, where the topological twist is generically required in order to realize covariantly constant spinors on a curved geometry. When the gauge theory is formulated on an arbitrary toric singularity C in four dimensions, we may regard C as a four-cycle inside the Calabi-Yau threefold X = K C , and we will obtain an explicit description of the instanton moduli spaces and their Euler characteristics. The precise forms of the partition functions will be amenable to checks of the OSV conjecture (2.5), and hence a description of wall-crossing phenomena.

N = 4 supersymmetric Yang-Mills theory on Kähler surfaces
Vafa and Witten [77] introduced a topologically twisted version of N = 4 supersymmetric Yang-Mills theory in four dimensions. The twisting procedure modifies the quantum numbers of the fields in the physical theory in such a way that a particular linear combination of the supercharges becomes a scalar. This scalar supercharge is used to define the cohomological field theory and its observables on an arbitrary four-manifold C. In the following we will only consider the case where C is a connected smooth Kähler manifold with Kähler two-form k 0 . When certain conditions are met the partition function of the twisted gauge theory computes the Euler characteristic of the instanton moduli space.
Let g ij be the Kähler metric of (C, k 0 ). Then the twisted gauge theory corresponds to the moduli problem associated with the equations is the self-dual part of the curvature two-form with respect to the Kähler metric. The field space W is spanned by a connection A i on a principal G-bundle P → C, a scalar field Φ, and a self-dual two-form B + ij , so that where A P denotes the space of connections on P and ad P is the adjoint bundle of P. Their superpartners ψ i , ζ, andψ + ij live in the tangent space to W. Associated with the equations of motion are two multiplets (χ + ij , H + ij ) and (χ i ,H i ) which are sections of the bundle F = Ω 2,+ (C, ad P) ⊕ Ω 1 (C, ad P) .
Schematically, the action of the topological gauge theory is of the form where Q is the scalar supercharge singled out by the twisting procedure. The gauge fermion Ψ is a suitable functional of the fields which contains the term that makes the gauge theory localize onto the solutions of the equations (4.1).
Geometrically, the partition function can be interpreted as a Mathai-Quillen representative of the Thom class of the bundle V = W× G F, where G = Aut(P) is the group of gauge transformations. Its pullback via the sections in (4.1) gives the Euler class of V. Under favourable circumstances, appropriate vanishing theorems hold [77] which ensure that each solution of the system (4.1) has Φ = B + = 0 and corresponds to an instanton, i.e. a solution to the self-duality equations F + = 0. In this case the gauge theory localizes onto the instanton moduli space M C and the Boltzmann weight gives a representative of the Euler class of the tangent bundle T M C . Therefore the partition function computes moduli space integrals of the form which gives the Euler characteristic of the instanton moduli space. Since the instanton moduli space is not generally a smooth variety, most of the quantities introduced above can only be defined formally. We will discuss how to define these integrations more precisely later on. In particular, we will allow for non-trivial vacuum expectation values for the Higgs field Φ, in order to define the partition function in the Ω-background as before. We will assume that the vanishing theorems can be extended to this case as well, by replacing the instanton moduli space with its compactification obtained by adding torsion-free sheaves on C as before.
The Euler characteristic of instanton moduli space can be computed through the index of the deformation complex associated with N = 4 topological Yang-Mills theory via the equations (4.1).
It has the form [51] Ω 0 (C, ad P) ⊕ Ω 0 (C, ad P) ⊕ Ω 2,+ (C, ad P) s / / Ω 2,+ (C, ad P) ⊕ Ω 1 (C, ad P) where the first morphism is an infinitesimal gauge transformation while the second morphism corresponds to the linearization of the sections (σ ij , κ i ) given by with p + giving the projection of a two-form onto its self-dual part. Under the assumption that all solutions of the original system of equations (4.1) have Φ = B + = 0, the complex (4.3) splits into the Atiyah-Hitchin-Singer instanton deformation complex plus Ω 0 (C, ad P) ⊕ Ω 2,+ (C, ad P) which is again the instanton deformation complex. One can compute the index of the original complex (4.3) (assuming the Vafa-Witten vanishing theorems) by computing the index of the two complexes above. However, these are equal and contribute with opposite signs. This means that the Euler characteristic of instanton moduli space receives contributions only from isolated points and simply counts the number of such points. On a toric surface C, this is anticipated from the toric localization formula (3.16) and will be made explicit below.
In the applications to black hole microstate counting, we will consider gauge group G = U (N ). The chemical potential C C (2) ∧ Tr (F ) for the D2-branes requires taking the Ramond-Ramond field C (2) proportional to the two-forms k i on C which are dual to the basis two-cycles S i , in order to get the correct charges. In this case the D0-brane charges correspond to the instanton numbers of the gauge bundle P, while the D2-brane charges correspond to non-trivial magnetic fluxes c 1 (P) = 0 through S i . To compute the macroscopic black hole entropy from the counting of the corresponding BPS states in the gauge theory, we introduce observables associated to these sources and compute their gauge theory expectation values using the localization arguments above to get where Ω(Q 0 , Q 2 ; N ) is the Witten index which computes the Euler characteristic of the moduli space M N,Q 2 ,Q 0 (C) of U (N ) instantons on C with Chern invariants c 1 (P) = Q 2 ∈ H 2 (X, Z) and −ch 2 (P) = Q 0 ν ∈ H 4 (X, Z). Here ν is the generator of H 4 (X, Z) ∼ = Z which is Poincaré dual to a point in X.

Toric localization and the instanton moduli space
Instantons on C = C 2 can be described as follows. Consider the quiver with the single relation r specified by the linear combination of paths This is called the ADHM quiver Q ADHM . The ADHM construction establishes a one-to-one correspondence between stable framed representations of the quiver Q ADHM in the category Vect C of finite-dimensional complex vector spaces and framed torsion free sheaves on the projective plane P 2 . In the rank one case, these are equivalent to ideal sheaves on C 2 , and the correspondence gives an isomorphism with the Hilbert schemes of points on C 2 .
Let V and W be inner product spaces of complex dimensions k = Q 0 and N , respectively. The instanton moduli space M N,k (C 2 ) can be realized as a hyperKähler quotient by the natural action of U (k) on the variety consisting of linear operators constrained by the ADHM equations On C 2 one can obtain a better compactification of this moduli space by deforming the gauge theory to a noncommutative field theory, as before [68,46,28]. This is equivalent to a modification of the hyperKähler quotient that defines the instanton moduli space, obtained by changing the images of the moment maps of (4.5) to where ζ = θ 1 + θ 2 . This quotient gives a compactification of the instanton moduli space M N,k (C 2 ) obtained by blowing up its singularities.
The classification of toric fixed points is given in ref. [62], by identifying the instanton moduli space M 1,k (C 2 ) with the Hilbert scheme of points (C 2 ) [k] . The fixed points are point-like instantons which are in one-to-one correspondence with Young tableaux λ having |λ| = k boxes. In the more general case of a U (N ) gauge theory in the Coulomb branch, one takes N copies of the U (1) theory and the fixed points are classified in terms of N -tuples of Young diagrams λ = (λ 1 , . . . , λ N ), called N -coloured Young diagrams. One can show that the fixed points are isolated.
One can describe the local structure of the instanton moduli space by using the ADHM construction at the fixed points of theT = U (1) N × T 2 action. Following ref. [62] one introduces a two-dimensional T 2 -module Q to keep track of the toric action. The operators (B 1 , B 2 , I, J) corresponding to a fixed point configuration are elements of theT -modules Then the local structure of the instanton moduli space is described by the complex which is just a finite-dimensional version of the Atiyah-Hitchin-Singer instanton deformation complex (4.4). The map σ corresponds to infinitesimal (complex) gauge transformations while τ is the linearization of the ADHM constraint µ c = 0. In general, the complex (4.6) has three nonvanishing cohomology groups. In our case we can safely assume that H 0 and H 2 vanish. The only nonvanishing cohomology H 1 describes field configurations that obey the linearized ADHM constraint µ c = 0 but are not gauge variations. It is thus a local model for the tangent space to the instanton moduli space at eachT -fixed point. Later on we will compute weights of the toric action on the tangent space modelled on (4.6).
The partition function of the U (1) topologically twisted gauge theory on X = C 2 is easily computed. The only non-trivial topological charge is the instanton number k = − X F ∧ F and therefore the partition function has the form The expansion parameter can be identified in terms of gauge theory variables q := e 2π i τ with the complexified gauge coupling, which is related to topological string variables g s = g 2 YM /2 at the attractor point. At a toric fixed point, k is identified as the number of boxes in a partition λ. The Euler classes exactly cancel in the localization formula (3.16), and one is left with the sum over fixed points [13] χ M 1,k (C 2 ) = λ : |λ|=k 1 .
This construction can be easily generalized to the nonabelian case. The fixed points are now N -coloured Young tableaux λ = (λ 1 , . . . , λ N ) corresponding to a partition of the instanton number k = (k 1 , . . . , k N ). The instanton action is again equal to k, where the additional factor of N arising from the sum over colours l = 1, . . . , N cancels with the normalization of the F ∧ F term which carries a factor 1 N (the inverse of the dual Coxeter number of the gauge group G = U (N )). The Euler characteristic of instanton moduli space is now with | λ| := l |λ l |. The U (N ) partition function reduces to N copies of the U (1) partition function, This factorization follows from the fact that after toric localization, the gauge symmetry U (N ) → U (1) N is broken to the maximal torus. The Coulomb phase corresponds to well separated D4branes, but the topological nature of the gauge theory ensures that the partition function is independent of the Higgs moduli representing the lengths of open strings stretching between D-branes.
In the rest of this section we will extend these constructions to generic toric surfaces X.

Hirzebruch-Jung spaces
Our main example will be the most general toric singularity in four dimensions, which defines a class of toric Calabi-Yau (hence open) surfaces known as Hirzebruch-Jung spaces C = C(p, n). They are determined by two relatively prime positive integers p and n with p > n. Consider the quotient singularity C 2 /Γ (p,n) , with the generator of the cyclic group Γ (p,n) ∼ = Z p acting on (z, w) ∈ C 2 as z , w −→ e 2π i n/p z , e 2π i /p w .
This orbifold has an A p,n singularity at the origin of C 2 . Then C(p, n) is defined to be the minimal resolution of the A p,n singularity by a chain of ℓ exceptional divisors S i ∼ = P 1 whose intersection numbers are summarized in the intersection matrix which is called a generalized Cartan matrix. The divisors thus only intersect transversally with their nearest neighbours in the chain. The self-intersection numbers e i ≥ 2 of the spheres P 1 of the blow-up are determined from the continued fraction expansion Let us consider two particular well-known instances of these spaces.
Local P 1 Setting n = 1, the space C(p, 1) can be identified with the total space of the holomorphic line bundle O P 1 (−p) over P 1 of degree −p, with ℓ = 1 and e 1 = p. In this case S = P 1 is the zero section divisor. In the context of topological string theory, such four-cycles appear in the "local" Calabi-Yau threefolds X which are regarded as neighbourhoods of a holomorphically embedded rational curve in a compact Calabi-Yau threefold, i.e. as the normal bundle N → P 1 . Since N is a holomorphic vector bundle of rank two over P 1 and the Calabi-Yau condition implies c 1 (N ) = −χ(P 1 ) = −2, it follows that X is the total space of a bundle of the form O P 1 (−p)⊕O P 1 (p−2) → P 1 .
The complex surface C = C(p, p − 1) is an example of an asymptotically locally Euclidean (ALE) space. This means that C carries a scalar flat Kähler metric g such that (C, g) is complete, and there exists a compact set K such that C \K ∼ = (R 4 \B R )/Z p . Here Z p ⊂ O(4) acts freely on R 4 \B R and the metric g approximates the flat Euclidean metric on R 4 . Such a coordinate system is called a coordinate system at infinity. We regard Z p ⊂ U (2) acting on (z, w) ∈ C 2 ∼ = R 4 as described above (with n = p − 1), and the complex structure I on C approximates that on C 2 = R 4 . As the resolution of the Klein singularity C 2 /Z p , C(p, p − 1) contains a chain of ℓ = p − 1 projective lines P 1 , each with self-intersection number e i = 2. In this case, the intersection matrix C coincides with the Cartan matrix of the A p−1 Dynkin diagram.

Instantons on ALE spaces
We begin by describing in some detail the instanton moduli space in the case of the A p−1 ALE spaces, for which a rigorous construction is known. U (N ) instantons on ALE spaces are given by the ADHM construction. Since the topological gauge theory is invariant under blow-ups of the surface (using blow-up formulas), one can do the instanton computation on the orbifold C 2 /Γ where Γ = Γ (p,p−1) ∼ = Z p . This result is at the heart of the McKay correspondence which provides a oneto-one correspondence between irreducible representations of the orbifold group Γ and tautological bundles over the exceptional divisors of the minimal resolution C = C(p, p − 1).
Since C is non-compact, the instanton moduli space M C must be defined with respect to connections which have appropriate asymptotic decay at infinity. We will describe this in more generality later on in terms of framed moduli spaces of torsion free sheaves. These connections correspond to instantons of finite energy, and are asymptotic to flat connections with F = 0. In particular, there are solutions which have fractional first Chern class and are related to instantons that asymptote to flat connections with non-trivial holonomy at the boundary of C, which is topologically the Lens space L(p, p−1) = S 3 /Γ. The flat connections are classified by homomorphisms ρ : π 1 (C) → U (N ), where π 1 (C) = Γ ∼ = Z p . The asymptotic connection at infinity is thus labelled by irreducible representations (k 0 , k 1 , . . . , k p−1 ) of the orbifold group Z p , with i k i = N , and are given explicitly by ρ k e 2π i /p = e 2π i k/p where k = 0, 1, . . . , p − 1.
Starting from the ADHM construction on C 2 outlined in Section 4.2., one constructs its Γinvariant decomposition. Consider the universal scheme Z ⊂ C × C 2 given by the correspondence The tautological bundle on C is defined by Under the action of Γ on Z, R transforms in the regular representation and can thus be decomposed into irreducible representations By the McKay correspondence, the bundles R 0 = O C , R 1 , . . . , R p−1 form the canonical integral basis of the K-theory group K 0 (C) constructed in ref. [36].
In this case we take Q ∼ = C 2 to be a module on which the regular representation of Γ acts. We also take Γ ⊂ SU (2) so that the determinant representation is trivial as a Γ-module, i.e.
2 Q ⊗ Γ R ∼ = R. The two vector spaces V and W which feature in the ADHM construction have a natural grading under the action of the orbifold group Γ given by The modification of (4.6) is given by [49] Hom Γ (R * , V ) and the condition that the sequence (4.7) is a complex is equivalent to the (generalized) ADHM equations. After imposing a certain stability condition, this construction realizes the instanton moduli space as a quiver variety M(V, W ).
This construction identifies two distinct types of instanton contributions to the ALE partition function, which we consider in turn. As before, after toric localization the gauge symmetry breaks as U (N ) → U (1) N and the U (N ) partition function factorizes as It therefore suffices to focus on the U (1) case in the following.

Regular instantons
Regular instantons on A p−1 live in the regular representation k 0 = k 1 = · · · = k p−1 = k of the orbifold group Γ = Z p . They correspond to D0-branes moving freely on C with p orbifold images away from the orbifold point. For gauge group U (1), the moduli space is given by specifying K = k p points on C up to permutations. Hence the moduli space M U (1) reg (C) of regular U (1) instantons on C is isomorphic to the Hilbert scheme C [K] . The generating function for the Euler numbers of the instanton moduli spaces can then be computed explicitly by applying Göttsche's formula to get The U (N ) partition function is the N -th power of this quantity. Heuristically, we may think of this formula as originating by covering C with p = χ(C) open charts to get p copies of U (N ) instantons on C 2 , each contributing η(q) −N . This can be demonstrated rigorously on any toric surface C by a localization computation [29,19].

Fractional instantons
To each irreducible representation (k 0 , k 1 , . . . , k p−1 ) of the orbifold group Z p there corresponds a fractional instanton which is stuck at the orbifold points. It has no moduli (or orbifold images), and can be regarded as a state in which open strings ending on the same D0-brane are projected out by the action of the orbifold group. They carry magnetic fluxes through the P 1 's of the minimal resolution, and correspond to self-dual U (1) gauge connections with curvatures The corresponding intersection numbers are given by Since C is non-compact, the intersection matrix C is not necessarily unimodular, and the corresponding instanton charges can be fractional. The contribution of fractional instantons to the supersymmetric Yang-Mills action with observables is thus given by Setting u := (u 1 , . . . , u p−1 ) and identifying Q i = e −z i using the attractor mechanism, we find that the contribution of U (1) fractional instantons to the full partition function is given by a theta-function

Instantons on local P 1
Let us now discuss what is known beyond the ALE case, in the instance that C is the total space of the holomorphic line bundle O P 1 (−p) [63]. In this case an ADHM construction is not available. Nevertheless, much of the construction in the ALE case carries through, and by introducing weighted Sobolev norms, one shows that M C is a smooth Kähler manifold with torsion-free homology groups which vanish in odd degrees. Let us consider some explicit examples.
The zero section of O P 1 (−p), considered as a divisor S = P 1 of C, produces a line bundle L → C such that c 1 (L) is the generator of H 2 (C, Z) = Z. It has a unique self-dual connection asymptotic to the trivial connection. Let C = C × C be the trivial line bundle over C. Set E = C ⊕ L, and let M(E) be the moduli space of self-dual connections on E which are asymptotic to the trivial connection at infinity. Then dim R (M(E)) = 2p. Since H 1 (C, R) = 0, using Morse theory one can show that the only non-vanishing homology groups of the instanton moduli space Alternatively, set E = L ⊕ L ∨ , and let M (k) (E), k = 0, 1, . . . , p − 1 be the moduli space of selfdual connections asymptotic to ρ k ⊕ ρ * k . Then for any p > 2, dim R (M (k) (E)) = 2, while for p = 2 (whereby O P 1 (−2) coincides with the A 1 ALE space) one has dim R (M (k) (E)) = 4. In particular, Instantons on local P 1 will be studied in more generality later on in terms of moduli spaces of framed torsion-free sheaves.

Wall-crossing formulas
In ref. [30] it was suggested that the structure of the instanton partition function on ALE spaces can be extrapolated to give a general result valid for all Hirzebruch-Jung surfaces C = C(p, n). Thus one postulates the form of the U (N ) partition function In the ALE case, one has χ(A p−1 ) = p and b 2 (A p−1 ) = p − 1. The evidence for this formula is supported by calculations in the reduction to q-deformed two-dimensional Yang-Mills theory [39,10], which captures the contributions from fractional instantons on the exceptional divisors. It was even conjectured to hold in the case when C is a compact toric surface, at least in the region of moduli space where the instanton charges are large. Though the regular and fractional instantons are always readily constructed exactly as in the ALE case, the issue is whether or not this formula takes into account all of the instanton contributions, and in which regions of moduli space the factorization into U (1) partition functions hold. Later on we will give more precise meanings to these "asymptotic charge regions" in terms of moduli spaces of torsion free sheaves.
Curiously, the formula (4.9) coincides with the chiral torus partition function of a conformal field theory in two dimensions with central charge c = N χ(C), i.e. of N χ(C) free bosons, with N b 2 (C) of them compact. The compact degrees of freedom live in a torus determined by the lattice H 2 (C, Z) with the bilinear form C. The appearence of this two-dimensional field theory can be understood in M-theory, wherein the D4-D2-D0 brane quantum mechanics lifts to a (4, 0) two-dimensional superconformal field theory on an M5-brane worldvolume [53]. This is reminescent of the recent conjectural relations between four-dimensional superconformal gauge theories and two-dimensional Liouville conformal field theories [3,80]. When C is an A p−1 ALE space and the gauge group is SU (N ), there is yet another conformal field theoretic interpretation [63,77,27,26]. In this case, the level N affine su(p) Lie algebra acts on the cohomology ring of the instanton moduli space, and the partition function (with appropriate local curvature and signature corrections inserted) coincides with the character of the affine Kac-Moody algebra given by where u = c 1 (P), n = c 2 (P) = k + 1 2 u · Cu, and Ω(n, u) are the degeneracies of BPS states with the specified quantum numbers. Here H is the Hilbert space on which the chiral algebra acts, which can be represented in terms of free fermion or boson conformal field theories with extended symmetry generators J 0 [27]. The U (1) partition function is also expressed as a u(1) 1 character in refs. [27,26].
Let us now compare the instanton partition function (4.9) with the black hole partition function. Microscopic black hole entropy formulas for BPS bound states of D0-D2-D4 branes in Type IIA supergravity are readily available on compact Calabi-Yau threefolds X [53], in the large volume limit and when contributions from worldsheet instantons are negligible. In this limit we can expand the cycle [C] as in (2.3). Let α i , i = 1, . . . , b 2 (X) be an integral basis of two-cocycles for H 2 (X, Z) dual to the four-cycles [C i ] with the intersection numbers and let D ij be the matrix inverse of D ij = D ijk Q k 4 . The genus zero topological string amplitude F 0 can be expressed as With Q 0 = 1 8π 2 C F ∧ F and Q i = Q i 2 = C −1 ij u j , the black hole entropy is given by [53] S BH (Q 0 , Q, We would now like to interpret the gauge theory partition function (4.9) as the corresponding black hole partition function Z BH (Q 4 , φ 2 , φ 0 ). For this, we expand it as Then Cardy's formula gives the black hole entropy as This expression agrees [30] with the macroscopic supergravity result (4.11) for the Bekenstein-Hawking-Wald entropy in the large Q 0 limit. Wall-crossing issues in a similar context are discussed in more detail in refs. [24,25,23,4,32].
In parallel to what we did in Section 3.9., in order to explore the pertinent wall-crossing formulas in this instance we will now consider moduli spaces which parametrize isomorphism classes of the following objects: In contrast to the six-dimensional situation, in four dimensions the connections between these three classes of objects is somewhat more subtle. We shall examine each of them in turn and how they compare with the gauge theory results we have thus far obtained.

Moduli spaces of framed instantons
We begin with Point (a) at the end of Section 4.6. Let C be a smooth, quasi-projective, open, toric surface. We will assume that C admits a projective compactification C , i.e. C is a smooth, compact, projective, toric surface with a smooth divisor ℓ ∞ ⊂ C (called the "line at infinity") which is a T 2 -invariant P 1 in C , and such that C = C \ ℓ ∞ . We will also require that ℓ ∞ · ℓ ∞ > 0, in addition to ℓ ∞ ∼ = P 1 . The difference between the counting of framed instantons on the compact toric surface C (with boundary condition at "infinity") and of unframed instantons on the open toric surface C is a universal perturbative contribution, which will be dropped here. Since C is compact, these calculations will only capture the contributions from instantons with integer charges on C. We will mention later on how to incorporate the contributions from fractional instantons on C.
Let us fix two numbers N ∈ N and k ∈ Q, and an integer cohomology class d ∈ H 2 ( C , Z). Let M N,d,k (C) be the framed moduli space consisting of isomorphism classes [E] of torsion-free sheaves E on C such that: (1) E has the following topological Chern invariants: (2) E is locally-free in a neighbourhood of ℓ ∞ , and there is an isomorphism E ℓ∞ ∼ = O ⊕N ℓ∞ called the "framing at infinity".
These topological conditions imply that the moduli space M N,d,k (C) is non-empty only when so that d defines a class d ∈ H 2 cpt (C, Z) in the compactly supported cohomology of C. Furthermore, from ch 2 (E) = −c 2 (E) + 1 2 c 1 (E) ∧ c 1 (E) the last relation in (4.12) can be written as (4.14) Framed sheaves yield stable pairs [41], analogous to those described in Section 3.9., after suitable choices of polarization on C and stability parameter.
We (E, E(−ℓ ∞ )). The cohomology of the instanton deformation complex is greatly simplified by the fact that in this case [33] Ext 0 Using (4.15) and the Riemann-Roch theorem, one shows [33] that the moduli space M N,d,k (C) is a smooth quasi-projective variety of (complex) dimension 2N k + d 2 , where d 2 := C d ∧ d, whose tangent space at a point [E] is isomorphic to the vector space Ext 1 We will now describe a natural torus invariant subspace of the instanton moduli space. The T 2invariance of ℓ ∞ implies that the pullback of the T 2 -action on C defines an action on M N,d,k (C). There is also an action of the diagonal maximal torus T N of GL(N, C) on the framing. Altogether we get an action of the complex algebraic torusT = T 2 × T N on M N,d,k (C) [33]. We are interested in the fixed point set M N,d,k (C)T of this torus action.
An isomorphism class [E] ∈ M N,d,k (C) is fixed by the T N -action if and only if it decomposes as such that E l ℓ∞ is mapped to the l-th factor O ℓ∞ of O ⊕N ℓ∞ under the framing isomorphism. Since the double dual E ∨∨ l is a line bundle which is trivial on ℓ ∞ , it is equal to O C (D l ) for some divisor , the sheaf E l is thus equal to I l (D l ) = I l ⊗ O C (D l ) for some ideal sheaf I l of a zero-dimensional subscheme Z l ⊂ C , also disjoint from ℓ ∞ . If E is also fixed by the T 2 -action, then so are D l , I l and Z l .
The supports of the T 2 -invariant subschemes Z l and D l can be represented explicitly in terms of the toric geometry of C. Recall that this is described in terms of an underlying toric graph ∆(C) whose vertices are in bijective correspondence with the T 2 -fixed points in C, and two vertices are joined by an edge e if and only if the corresponding fixed points are connected by a T 2 -invariant P 1 . Let V (C) and E(C) respectively denote the set of vertices and edges of ∆(C). Then since ∆(C) is a chain, one has |E(C)| = |V (C)| − 1. The number of vertices n = |V (C)| is also the number of two-cones in the toric fan of C and it is related to the Euler characteristic χ(C) of the surface as We denote by p f the T 2 -invariant point in C corresponding to the vertex f ∈ V (C), and by ℓ e the T 2 -invariant line P 1 corresponding to the edge e ∈ E(C).
Since the zero-cycles Z l are not supported on ℓ ∞ , they must be contained in the fixed point set V (C) in C. Thus each Z l is a union of subschemes Z f l , f ∈ V (C) supported at the T 2 -fixed points p f ∈ C. If we choose a local coordinate system (x, y) ∈ C 2 in a patch U f around p f , then the T 2 -invariant ideal of Z f l in the coordinate ring C[x, y] of U f ∼ = C 2 is generated by the T 2eigenfunctions with non-trivial characters, which are monomials x i y j , and hence Z f l corresponds to a Young diagram λ f l with λ f l boxes (with monomial x i y j placed at (i + 1, j + 1)). The ideal is spanned by monomials outside the Young diagram. Likewise, since the T 2 -invariant two-cycles D l are disjoint from the line at infinity, they are supported along the edges ℓ e ∼ = P 1 , e ∈ E(C). is a vector of Young tableaux with λ l := f ∈V (C) λ f l boxes. The Young tableaux parametrize the contributions from regular pointlike D0-brane instantons (freely moving inside C). The divisors parametrize the contributions from D2-brane instantons (wrapping D l with appropriate units of magnetic flux). We will see that these two types of contributions factorize completely. We can write the topological invariants of a generic element (4.17) in M N,d,k (C)T in terms of this combinatorial data. Since c 1 (I l ) = 0, the constraint d = c 1 (E) can be written as whereas (4.14) becomes The Young diagram box sum in (4.20) gives the length of the singularity set of the sheaf (4.16).
To make contact with our previous formulas, let us rewrite these constraints in a more explicit parametrization. Define the invertible, symmetric, integer-valued intersection matrix C = (C e,e ′ ) e,e ′ ∈E(C) between lines of the toric graph ∆(C) as C e,e ′ := ℓ e · ℓ e ′ .
Each divisor ℓ e is canonically associated to a Combined with (4.20) and using (4.21) this gives The Vafa-Witten-Nekrasov partition function on the toric surface C is now defined as thẽ T -equivariant index where as before q = e 2π i τ with τ the complexified gauge coupling constant and for a collection of formal variables Q e , e ∈ E(C) and a given cohomology class d ∈ H 2 cpt (C, Z). From the localization formula (3.15) we see that theT -equivariant Euler class cancels in (3.16) at the fixed points. This cancellation in the fluctuation determinants is a consequence of (4.15) which implies that the obstruction bundle is trivial, and there is an isomorphism between the tangent and normal bundles over the fixed point set M N,d,k (C)T in the instanton moduli space. Because of this cancellation, we see that the contribution from each critical point of the gauge theory is independent of the equivariant parameters ǫ i and a l . In the sum over critical points, we can replace the sum over k ∈ Q using (4.23) by sums over Young diagrams λ and over the integers u = (u 1 , . . . , u N ), u l = (u e l ) e∈E(C) ∈ Z n−1 representing magnetic fluxes through ℓ e on D2-branes wrapping the divisors D l . The sum over d ∈ H 2 cpt (C, Z) may then be saturated using (4.22). Putting everything together, and using (4.22) and (4.21) to write the partition function (4.24) thereby becomes where we have used (4.10). The sums over Young tableaux decouple, and for each vertex f ∈ V (C) and each l = 1, . . . , N they produce a factor of the Euler function η(q) −1 . Then we can bring (4.25) into the final form where we recall that χ(C) = |V (C)| = n and b 2 (C) = |E(C)| = n − 1.
This formula differs from (4.9) in that only integral values of the first Chern class are permitted in (4.26). In the case of an A p−1 singularity, fractional first Chern classes can be incorporated by constructing instead the moduli space of torsion free sheaves on the orbifold compactification C orb = C ∪l ∞ of the hyperKähler ALE space C, wherel ∞ = P 1 /Γ [49,60,61,63]. In a neighbourhood of infinity we can approximate C by P 2 /Γ with the singularity at the origin resolved. More precisely, we obtain the divisorl ∞ by gluing together the trivial bundle O C on C with the line bundle O P 2 /Γ (1) on P 2 /Γ. The latter bundle has a Γ-equivariant structure such that the map O C → O P 2 /Γ (1) is Γ-equivariant. Let us examine some examples which are covered by the analysis above.
Local P 1 Let C = C p , p > 0 be the total space of the holomorphic line bundle O P 1 (−p) of degree −p over and ℓ ∞ = P(O P 1 (−p) ⊕ 0) ∼ = P 1 . Then ℓ 0 · ℓ 0 = −p < 0, ℓ ∞ · ℓ ∞ = p > 0, and ℓ 0 · ℓ ∞ = 0 so that the line ℓ 0 does not pass through the "line at infinity". From the constraint (4.13) and the second Betti number b 2 (C p ) = 1, it follows that d = m c 1 (O Cp (ℓ 0 )) for some m ∈ Z. In this case, the instanton moduli space M N,m,k (C p ) is a smooth variety of complex dimension 2N k − p m 2 . The positivity of this dimension is a constraint on the integral classes which ensures that the moduli space is non-empty. One has χ(F p ) = 1 + 2 + 1 = 4, and hence n = χ(F p ) − 2 = 2. The partition function (4.26) in this case becomes Like the ALE spaces, one can work instead with a stack compactification C orb of the total space of the bundle O P 1 (−p) obtained by adding a divisorl ∞ ∼ = ℓ ∞ /Γ. The resulting variety is a toric Deligne-Mumford stack whose coarse space is the Hirzebruch surface F p [12]. With this compactification one produces framed sheaves with fractional first Chern classes d = m p c 1 (O Cp (ℓ 0 )), m ∈ Z, and in this case the partition function takes the form [12] anticipated by refs. [30,39], where q = e 2π i τ , Q = e 2π i v and θ 3 (v|τ ) = n∈Z q 1 2 n 2 Q n is a Jacobi elliptic function.
On these spaces one also has a version of the Hitchin-Kobayashi correspondence which makes contact with the realization of instantons as self-dual connections. Namely, SU (N )-instantons on C p are in one-to-one correspondence with holomorphic bundles E of rank N on C p with c 1 (E) = 0 together with a framing at infinity [34]. When p = 2 these spaces coincide with the A 1 ALE space.

Compact surfaces
We will now examine situations under which the formula (4.26) holds in the case of compact surfaces, providing rigorous justification for some of the conjectural formulas of ref. [30]. Let C be a compact, smooth, projective toric surface. Let c ∞ be a generic point in C which is disjoint from the torus invariant lines ℓ e , e ∈ E(C) of C. Let M N,d,k (C, c ∞ ) be the moduli space of isomorphism classes [E] of torsion free coherent sheaves E on C with topological Chern invariants as in (4.12), together with a "framing" at the point c ∞ . When E is locally free, this framing means a choice of basis for the fibre space E c∞ ∼ = C N . When E is not locally free, the framing is defined with respect to a locally free resolution E • → E → 0.
Let σ : ( C, ℓ ∞ ) → (C, c ∞ ) be the blow-up of C at c ∞ . Then C is also a compact, smooth, projective toric surface. We will suppose that the exceptional divisor ℓ ∞ = σ −1 (c ∞ ) ∼ = P 1 has positive self-intersection ℓ ∞ · ℓ ∞ > 0. Let M fr N,d,k ( C ) be the moduli space of isomorphism classes E of torsion-free sheaves E on C which are framed on the line ℓ ∞ as above.
Using the isomorphism (4.28), the instanton partition function on C can be computed from the blow-up formula where the right-hand side is given by the formula (4.26).

Stability
Next we address Point (b) at the end of Section 4.6. If one wishes to relax the requirement of framing, then one must carefully analyse stability issues in order to obtain well-defined instanton moduli spaces. Let C be a smooth, quasi-projective toric surface. Again we fix invariants N ∈ N, k ∈ Q and d ∈ H 2 cpt (C, Z). Let M N,d,k (C) be the unframed moduli space consisting of isomorphism classes [E] of semistable torsion-free coherent sheaves E on C such that E has topological Chern invariants The notion of "semistability" considers sheaves with fixed Hilbert polynomial. In this case, a general result of Maruyama [55] constructs the algebraic scheme M N,d,k (C) and shows that it is projective. In particular, it admits aT -equivariant embedding into a smooth variety. In the case that C is a polarized surface, i.e. it admits a smooth distribution in its tangent bundle T C which is integrable and Lagrangian (in an appropriate sense), we can formulate the notion of semistability in terms of the more familiar slope semistability following ref. [35]. Let L be a fixed ample line bundle on C. For a coherent torsion-free sheaf E on C, define the polynomial for all n ≫ 0 whenever F is a coherent subsheaf of E. In this case, Gieseker [35] constructs M N,d,k (C) as a projective Quot scheme. The slope of E is the rational number where the degree of E is defined using the polarization as An application of the Riemann-Roch theorem shows [35] ρ It follows that ρ E (n) ≥ ρ F (n) for n ≫ 0 if and only if µ(E) ≥ µ(F), and hence L-semistability is equivalent to the usual quasi-BPS instanton equations in this case. In physics applications one is interested in instances where C is a Kähler surface. In this case one can use the Kähler polarization and take c 1 (L) to be the Kähler two-form k 0 in (4.32).
The following result computes the expected dimension of the instanton moduli space in this case.
is the holomorphic Euler characteristic of C.
Proof. As discussed in Section 3.5., the dimension of the virtual tangent space T vir . The latter quantity may be computed for E locally free by using the Hirzebruch-Riemann-Roch theorem to write (4.34) Let ν be the generator of H 4 (C, Z) ∼ = Z which is Poincaré dual to a point in C. Then using (4.31) one computes the Chern character The Todd characteristic class of the tangent bundle of C is given in terms of Chern classes of T C as Td(C) = 1 + 1 2 c 1 (C) + 1 12 c 1 (C) ∧ c 1 (C) + c 2 (C) . We may thus write (4.34) as From the Hirzebruch-Riemann-Roch formula and ch(O C ) = 1, one has 4.36) and the result follows when E is a bundle. When E is not locally free, we use a locally free resolution E • → E → 0 along with additivity of the Chern character.
This result shows that the expected dimension of the instanton moduli space for N = 1 coincides with the dimension of the framed moduli space M 1,d,k (C) of Section 4.7. Indeed, torsion free sheaves of rank one are always stable in the sense explained above. Since any torsion free sheaf decomposes as the product E = I ⊗ L of an ideal sheaf of a zero-dimensional subscheme and a line bundle, the moduli space factorizes into a product is the Hilbert scheme of K points on C which is a smooth variety of dimension 2K, and the (zero-dimensional) Picard group M 1,d,−d 2 /2 (C) ∼ = Pic d (C) parametrizes fractional instantons. The factorization of the U (1) gauge theory partition function into contributions from regular and fractional instantons then follows from the multiplicativity of the Euler class under tensor product of (tangent) bundles. For compact toric surfaces C, it is given by the formula (4.26) with N = 1. In the case of Hirzebruch-Jung surfaces, the contributions of fractional charges in this case is shown in ref. [19] to arise from the non-compact prime divisors of C via linear equivalences. It amounts to identifying the generators c 1 (R i ) of the Kähler cone in CH 1 (C) ⊗ Q with the duals to the exceptional divisors D i which generate the Mori cone in CH cpt 1 (C) ⊗ Q. For the ALE spaces, the moduli space M 1,0,k+d 2 /2 (C) coincides with the quiver variety of the ADHM construction (with suitable stability conditions) [50].
The situation for higher rank N > 1 is much more complicated. In this case, slope-stability does not seem to properly account for walls of marginal stability extending to infinity which describe wallcrossing behaviour of the partition functions counting D4-D2-D0 brane bound states on Calabi-Yau manifolds X with h 1,1 (X) > 1 [25]. As discussed in Section 3.9., the physical theory is described by moduli spaces of stable objects in the derived category D b (coh(X)), as the observed D-brane decays are impossible in the abelian category coh(X) of coherent sheaves on X.

Perpendicular partition functions and universal sheaves
Finally, we come to the last Point (c) at the end of Section 4.6. For U (1) gauge theory this relationship is analysed in detail in ref. [19]. In this case a four-dimensional analog of the topological vertex formalism can be developed. On the gauge theory side, the vertex contributions should be computed by a version of the perpendicular partition function of Section 3.8., i.e. the generating function P m 1 ,m 2 U (N ) (q) for instantons on C = C 2 with fixed asymptotics such that Z C 2 U (N ) (q) = P 0,0 U (N ) (q), while the edge contributions should be read off from the character of the corresponding universal sheaf. In the remainder of this section we will describe in detail the instanton moduli space with boundary conditions specified by integers m 1 , m 2 , and show that the fixed point loci of the induced T -action are enumerated by two-dimensional Young diagrams with asymptotics m 1 , m 2 . This gives the four-dimensional version of the gauge theory gluing rules of Section 3.8. and also a first principles derivation of the empirical vertex rules of ref. [19,Sec. 4.3].
Instanton moduli spaces on F 0 We will first describe how to generate instantons with non-trivial first Chern class using our previous formalism. For this, rather than working with the projective plane C = P 2 , it is more convenient to work with the "two-point compactification" of C = C 2 given by a product of two projective lines F 0 = P 1 z × P 1 w , where the labels will be used to keep track of each of the two factors. This variety can be identified as the zeroth Hirzebruch surface F 0 = P(O P 1 ⊕ O P 1 ), i.e. the projective compactification of the trivial line bundle O P 1 = C × P 1 , which is again a toric surface. For (t z , t w ) ∈ T 2 , the toric action is described by the automorphism F tz ,tw of F 0 defined by (4.37) Let p z : F 0 → P 1 z and p w : F 0 → P 1 w be the canonical projections, and i z : P 1 z ∼ = P 1 z × pt ֒→ F 0 and i w : P 1 w ∼ = pt × P 1 w ֒→ F 0 the natural inclusions. There are now two independent distinguished lines at infinity fixed by this T 2 action, given by the pushforwards ℓ z = (i z ) * P 1 z and ℓ w = (i w ) * P 1 w , for which the respective factors of the action of T 2 = C * × C * reduce to the standard C * -action on ℓ z , ℓ w ∼ = P 1 . These two divisors have intersection products ℓ z · ℓ z = ℓ w · ℓ w = 0 and ℓ z · ℓ w = 1, and the canonical divisor is K F 0 = −2ℓ z − 2ℓ w . They generate the Picard group of F 0 , and hence induce a bigrading on line bundles over F 0 . For m z , m w ∈ Z, we write By Künneth's theorem, the non-trivial cohomology groups of F 0 are given by (1)). Let M N ;(mz ,mw);k (F 0 ) be the moduli space of isomorphism classes [E] of torsion-free sheaves E on F 0 with topological Chern invariants as in (4.12), where d = m z ξ z + m w ξ w , and non-trivial framings along the two independent "directions at infinity" prescribed by two fixed isomorphisms where W is a fixed N -dimensional complex vector space. We will say that such a sheaf is "trivialized at infinity" if it is equipped with two The moduli space of trivialized sheaves is denoted M N,k (F 0 ) := M N ;(0,0);k (F 0 ). These moduli spaces carry an obvious induced action of the torusT = T 2 × T N , and the following formal arguments show that the instanton counting in these moduli spaces is the same as before. Proof. Represent F 0 as a divisor in P 2 × P 1 via the embedding P 1 z ֒→ P 2 , [z 0 , z 1 ] → [z 0 , z 1 , z 1 ]. Let P 2 be the surface obtained as the blowup p of a pair of points on the line at infinity ℓ ∞ ⊂ P 2 (see Section 4.7.). Note that ℓ ∞ is disjoint from the image of the line ℓ z . Then there is a correspondence diagram where q is the blowup of the intersection point ℓ z · ℓ w on F 0 = P 1 z × P 1 w . The corresponding Fourier-Mukai functors q * p * and p * q * determine equivalences on the categories of coherent sheaves over P 2 and F 0 , and hence induce mutually inverse rational maps between the corresponding sets of isomorphism classes of trivially framed torsion free sheaves. By (4.12) (with d = 0), one has ch(E) = N − k ξ z ∧ ξ w , (4.43) and using multiplicativity of the Chern character we compute The bijection of Proposition 4.39 is not necessarily a diffeomorphism. In fact, we have not yet shown that M N,k (F 0 ) is a smooth variety. Naively, one may try to argue this by using the formalism of ref. [33], as our sheaves are trivialized on the divisor ℓ ∞ = ℓ z + ℓ w which has positive self-intersection ℓ ∞ ·ℓ ∞ = 2, and F 0 \ℓ ∞ ∼ = C 2 . However, this divisor is not irreducible, in particular it is not a P 1 . Note that formally applying the arguments which led to (4.27) in the limit p = 0 would produce the partition function as the Hirzebruch surface has n = χ(F 0 ) − 2 = 2. Although the generating function (4.45) is "doubled", the instanton counting problems on F 0 and on C 2 are nevertheless identical. A rigorous derivation of the formula (4.45) using the techniques of Section 4.7. follows once we establish that the equivalence of Proposition 4.39 is an isomorphism of underlying smooth varieties. Recall from Section 4.7. that the complex dimension of the instanton moduli space M N,k (C 2 ) is 2N k. Proof. As usual, the trivialization condition at infinity guarantees Gieseker semistability and hence quasi-projectivity, as discussed in Section 4.8. Using the divisor ℓ ∞ = ℓ z + ℓ w of F 0 , one constructs the framed moduli space M N,k (F 0 ) as in ref. [41] with tangent spaces Ext 1 obstruction spaces given by Ext 2 and hence M N,k (F 0 ) is smooth. The dimension of the tangent spaces is thus equal to minus the Euler characteristic −χ(E, E(−1, −1)), which for E locally free may be calculated by using the Hirzebruch-Riemann-Roch theorem to write Using (4.43) and (4.44) one computes the Chern character The Todd characteristic class and holomorphic Euler characteristic are given by (4.35) and (4.36) with C = F 0 , and we may thus write (4.47) as , with ℓ z , ℓ w ∼ = P 1 and ℓ z · ℓ z = ℓ w · ℓ w = 0, the remaining integral in (4.48) may be computed as where in the last step we used the fact that the holomorphic tangent bundle of P 1 can be identified with O P 1 (2). Putting everything together we find χ E , E(−1, −1) = −2N k and the result follows when E is a bundle. If E is not locally free, then we simply consider a locally free resolution E • → E → 0 and use additivity of the Chern characteristic class.
In a similar vein, the equivalence established in Proposition 4.40 as it stands is only a bijective correspondence. The moduli space for non-trivial asymptotics is an example of the moduli spaces of "decorated sheaves" described in ref. [42,Sec. 4.B], with the (m z , m w )-framed sheaves on F 0 providing examples of semistable framed modules. The moduli space M N ;(N mz ,N mw);k(mz ,mw) (F 0 ) is thus a projective scheme with a universal family, i.e. it is fine, and so possesses a universal sheaf. We will now argue that the moduli spaces M N ;(N mz,N mw);k(mz,mw) (F 0 ) are smooth and diffeomorphic to one another for all m z , m w ∈ Z. Then the computations of Section 4.7. can be repeated by integrating over M N ;(N mz,N mw);k(mz,mw) (F 0 ) using (4.41) and Göttsche's formula to get the desired perpendicular partition function For N = 1, this yields a rigorous derivation of the vertex rules of ref. [19].
LetM(F 0 ) be the moduli space of isomorphism classes of pairsẼ = (E, α), where E is an (m z , m w )-framed torsion free sheaf on F 0 and α : O F 0 (m z , m w ) ⊕N → E is the surjective morphism induced by the framing. Consider the family of pairsF = (F, β) consisting of a coherent sheaf F on F 0 together with a homomorphism β : O F 0 (m z , m w ) ⊕r → F for some r ∈ N. These pairs define objects of an abelian category coh f (F 0 ) with the obvious morphisms between pairs induced by morphisms of coherent sheaves. Any (m z , m w )-framed torsion free sheaf E on F 0 clearly defines an object of coh f (F 0 ), with r = N and ch(F) = ch(E).
Given the abelian category coh f (F 0 ), one can derive functors, and hence compute sheaf cohomology in coh f (F 0 ). We denote the corresponding Ext-functors by Ext i f . Then Ext 2 f (Ẽ,Ẽ) is the obstruction space forM(F 0 ) atẼ, while Ext 1 f (Ẽ,Ẽ) is the tangent space toM(F 0 ) atẼ. Generally, for any two objectsF,G of coh f (F 0 ), the group Ext 1 f (F ,G) can be computed in a purely algebraic way in terms of equivalence classes of extensions The line bundle O F 0 (m z , m w ) is a projective O F 0 -module and is therefore flat, whence the tensor product map defined by (4.42) preserves exact sequences such as (4.50). It follows that the tangent spaces Ext 1 f (Ẽ,Ẽ) are the same for all m z , m w ∈ Z. Thus by Proposition 4.46, the moduli spacesM(F 0 ) are all smooth and diffeomorphic to one another. This is consistent with the fact that stability (either slope stability of torsion free sheaves [35] or stability of framed modules [42,Sec. 4.B]) is preserved by twisting with the line bundles O F 0 (m z , m w ).

Universal sheaves
We now construct the universal sheaf for the standard framing on F 0 , and compute itsT -equivariant character. Since the moduli space M N,k (F 0 ) is fine [41], there exists a universal sheaf E → F 0 × M N,k (F 0 ), i.e. a torsion-free sheaf E such that E F 0 ×[E] ∼ = E for every point [E] ∈ M N,k (F 0 ), unique up to tensor product with a (unique) line bundle. There are two natural vector bundles over M N,k (F 0 ) associated to a universal sheaf E. Firstly, there is the framing bundle W = H 0 (F 0 , E| ℓ∞ ) of rank N given by the fibre at infinity. Secondly, there is the bundle V of "Dirac zero modes", whose fibre at a given locally free sheaf [E] ∈ M N,k (F 0 ) restricted to R 4 ∼ = C 2 ∼ = F 0 \ ℓ ∞ is the space of L 2 -solutions to the Dirac equation on R 4 in the background of the fundamental representation of the instanton gauge field corresponding to [E] C 2 . It is constructed explicitly as follows. Let π 1 and π 2 be the canonical projections of F 0 × M N,k (F 0 ) onto the first and second factors, respectively. Then the Dirac bundle is , where R 1 π 2 * is the first right derived functor of the pushforward functor π 2 * . Its fibre over a point  where e l = e a l . Let us now describe how the ADHM construction is modified in this case. This has been worked out in ref. [6,Sec. 5]. The linear algebraic data is formally the same as for the analysis of framed instantons on P 2 [62], defined by linear operators B z ∈ Hom(V, V ) , B w ∈ Hom(V, V ) , I ∈ Hom(W, V ) and J ∈ Hom(V, W ) .
Then any framed torsion free sheaf [E] ∈ M N,k (F 0 ) can be represented as the middle cohomology group of the complex which is exact at the first and last terms, where The virtualT -equivariant bundle defined by the cohomology of the complex (4.53) gives a representative of the isomorphism class of the universal sheaf E in theT -equivariant K-theory group K 0 T (F 0 × M N,k (F 0 )) as where areT -equivariant bundles over F 0 which, after tensoring with a line bundle of degree one, restrict to the usual positive/negative chirality spinor bundles over R 4 ∼ = C 2 ∼ = F 0 \ ℓ ∞ . In the topologically twisted gauge theory, fermion fields become differential forms and these bundles are identified with the bundles of even/odd holomorphic forms over F 0 [9]. By (4.37), the holomorphic line bundles (4.38) haveT -equivariant characters and consequently chT S + = 1 + t z t w and chT S − = t z + t w . (4.55) Using (4.52) and (4.55), we may thus compute the character of the universal sheaf (4.54) at a fixed point in the instanton moduli space as which coincides with the standard expression for instantons on R 4 [64].
For completeness, let us record here theT -equivariant Chern character of the tangent bundle T M N,k (F 0 ) over the instanton moduli space at the torus fixed points. As the only non-vanishing cohomology group of (4.6) is a model of the tangent space, it can be computed as the equivariant index of this complex. For this, let us recall some combinatorial definitions. Let λ be a Young diagram. Define the arm and leg lengths of a box (i, j) ∈ λ respectively by where ̺ i is the length of the i-th column of λ and ̺ t j is the length of the j-th row of λ. At a fixed point λ, the character can then be expressed after some algebra in terms of the characters of the representation as Again this coincides with the standard result [13,64,74]. As in ref. [52], after toric localization one has at theT -fixed points λ, up to a universal perturbative contribution (the character of W ⊗ W * ). This expression formally generalizes to generic toric surfaces [67], and is used to construct vertex gluing rules below. From the top Chern class one can also straightforwardly extract the equivariant Euler classes where n λ l,m (ǫ z , ǫ w , a) = is a universal sheaf on F 0 × M N ;(N mz,N mw);k(mz ,mw) (F 0 ). The equivariant character of E(m z , m w ) at the fixed points of the toric action modifies the decompositions (4.52) to allow for "propagators" which appear along the edges P 1 of the toric diagram ∆(C) of a generic toric surface C. These modifications of theT -equivariant character of the universal sheaf corresponding to the instanton sheaves (4.42) are determined via shifts by the C * -equivariant character of modules of solutions to the Dirac equation on P 1 . We will now describe these modules explicitly. As we have seen, the bundle O P 1 (m) of degree m ∈ Z over the Riemann sphere P 1 is the crucial ingredient in generating instantons with non-trivial framings. After choosing a hermitean metric on the fibres of O P 1 (m), it is the holomorphic line bundle underlying the standard Dirac monopole line bundle of topological charge m. The form of the Dirac operator D / m in the background of the corresponding monopole gauge potential is well-known and can be conveniently described following ref. [72].
Given homogeneous coordinates [z 0 , z 1 ] on P 1 , let y = z 1 /z 0 denote stereographic coordinates on the northern hemisphere. Then the twisted Dirac operator in the monopole background of magnetic charge m ∈ Z is given by These operators act on sections of the chiral/antichiral spinor line bundles associated to the twisted holomorphic spinor bundles O P 1 (± 1) ⊗ O P 1 (m). We are interested in the subspaces of zero modes The action of t ∈ C * is implemented by the automorphism F t of P 1 defined by The irreducible representations T i ∼ = C of C * are labelled by their weights i ∈ Z and are defined by z → t · z = t i z for t ∈ C * and z ∈ C. The corresponding C * -eigenspace decomposition of the modules (4.57) can be described for all m ∈ Z as follows.
Theorem 4.59. The isotopical decompositions of the spinor modules S ± m over P 1 , as C * -modules, are given by T −(i−1) and S + m = {0} for m > 0 . for the spinors ψ ± m ∈ ker D / ± m . The line bundle O P 1 (m) has holomorphic transition function y m transforming sections from the northern hemisphere to the southern hemisphere of P 1 , which after unitary reduction to a hermitean line bundle becomes (y/ȳ) m/2 . By using these transition functions, it is easy to see that the only solutions of the equations (4.61) which are regular on both the northern and southern hemispheres are of the form The result now follows from (4.58).
We can use Theorem 4.59 to compute the C * -equivariant characters of the spinor modules (4.57). One finds for m > 0, while for m < 0. In the non-equivariant limit t → 1, the characters This completes the derivation of the gluing rules of ref. [19,Sec. 4.3].

D2-brane gauge theory and Gromov-Witten invariants
In this final section we study the reduction of the four-dimensional gauge theories of Section 4 on local curves, and examine in detail the example of local P 1 which has been extensively described from the point of view of Vafa-Witten theory. We begin with a somewhat heuristic description of how these two-dimensional supersymmetric gauge theories are induced. Then we proceed to a more formal topological field theory formalism which systematically computes topological string amplitudes and Gromov-Witten invariants. Finally, we briefly address wall-crossing issues once again from a physical standpoint.

q-deformed two-dimensional Yang-Mills theory
One of the simplest classes of examples are the non-compact local Calabi-Yau threefolds which are fibred over curves. If Σ g → X is a holomorphically embedded curve of genus g in a Calabi-Yau threefold, then the holomorphic tangent bundle restricts to Σ g as T Σ g ⊕ N Σg , where the normal bundle N Σg is a holomorphic bundle of rank two over Σ g . By the Calabi-Yau condition c 1 (X) = 0, one has c 1 (N Σg ) = −χ(Σ g ) = 2g − 2. Thus in a neighbourhood of Σ g , the manifold X looks like the total space of a holomorphic bundle N → Σ g of rank two with c 1 (N ) = 2g − 2. Hence we consider the total space of the bundle is a holomorphic line bundle over Σ g of degree p, one has c 1 (X p ) = (p + 2g − 2) + (−p) = 2g − 2 as required. For genus g = 0, this is just the example of local P 1 which was introduced in Section 4.3.
In our applications to black hole microstate counting, we count bound states of D4-D2-D0 branes in X p with N D4-branes wrapping the four-cycle C p which is the total space of the line bundle O Σg (−p) → Σ g , together with D2-branes wrapping the base Riemann surface Σ g (embedded in C and X p as the zero section). One can then localize the path integral of the N = 4 topological gauge theory on C p to the C * -invariant modes along the fibre of O Σg (−p). The result is an effective U (N ) gauge theory on Σ g whose action is given by [ where ϑ = g s φ 2 /2π and the last term is a mass deformation which originates in four dimensions due to the non-triviality of the bundle O Σg (−p) [76]. The scalar field Φ is given by the holonomy of the four-dimensional gauge connection at infinity where z ∈ Σ g and u ∈ O Σg (−p).
The action (5.1) is just the BF-theory representation of two-dimensional Yang-Mills theory, with the usual F 2 -term coming from performing the gaussian integral over Φ in the functional integral. If Φ were arbitrary, then we could use diagonalization techniques to reduce the partition function to the usual heat kernel expansion of two-dimensional Yang-Mills theory. However, the identification of Φ as a holonomy means that it should be treated as a periodic field, and the change from a Lie algebra valued variable to a group-like variable affects the Jacobian of the path integral measure that arises from diagonalization. This modifies the usual Migdal expansion of two-dimensional gauge theory to give the partition function where q = e −gs as before and Q = e i ϑ . The sum runs over unitary irreducible representations R = (R 1 , . . . , R N ) of the gauge group U (N ) with weights R i , first and second Casimir invariants C 1 (R) = i R i and C 2 (R) = i R 2 i , and quantum dimension where the q-number is defined by [n] q := q n/2 − q −n/2 q 1/2 − q −1/2 with [n] q = n + O(q − 1) for q → 1. This reduced two-dimensional gauge theory is a q-deformation of ordinary Yang-Mills theory.

Topological field theory
We will now give a more precise definition of this gauge theory using techniques of two-dimensional topological field theory. This formalism can then be used to compute topological string amplitudes. The idea is that the cutting and pasting of base Riemann surfaces is equivalent to the cutting and pasting of the corresponding local Calabi-Yau threefolds, by either adding or cancelling off Dbranes corresponding to the boundaries in the topological vertex formalism [14,1]. The operations of gluing manifolds satisfy all axioms of a two-dimensional topological field theory. By computing the open string topological A-model amplitudes on a few Calabi-Yau manifolds, we then get all others by gluing. In the following we focus on the genus zero case Σ 0 = P 1 for simplicity and illustrative purposes.
When the base of the fibration is the sphere, we will only need the basic Calabi-Yau cap amplitude corresponding to a disk D, represented symbolically as For the gluing rules, we sew two open Riemann surfaces Σ L and Σ R together along their common boundary to get the Riemann surface Σ L∪R . For this, the orientations of the corresponding boundary circles must be opposite. Reversing the orientation acts on the boundary holonomy as U → U −1 , and hence the gluing rules read where dU is the bi-invariant Haar measure and the integrals can be evaluated explicitly by using the orthogonality relations for characters SU (∞) dU ch R 1 (U ) ch R 2 (U −1 ) = δ R 1 ,R 2 .
We will also need the the Calabi-Yau trinion (or "pants") amplitudes Let us point out two particularly noteworthy aspects of this construction thus far. Firstly, the construction defines a functor of tensor categories where Rep is the representation category of SU (∞) and S L 1 ,L 2 is the geometric tensor category defined as follows. The objects of S L 1 ,L 2 are compact oriented one-manifolds Y , i.e. disjoint unions of oriented circles. A morphism Y 1 → Y 2 between two objects of S L 1 ,L 2 is a triple (W, Y 1 , Y 2 ), where W is an oriented cobordism between Y 1 and Y 2 , i.e. a smooth oriented two-manifold with boundary ∂W = Y 1 ∐ (−Y 2 ), and the complex line bundles L 1 , L 2 over W are trivialized on ∂W . This is analogous to the Baum-Douglas description of D-branes in K-homology [73]. There is a natural notion of equivalence provided by boundary preserving, oriented diffeomorphisms f : W → W ′ with L i ∼ = f * L ′ i , i = 1, 2. Composition of morphisms is given by concatenation of cobordism and gluing of bundles along the concatenation using the trivializations. For a connected cobordism W , we can label the isomorphism classes of a pair of line bundles (L 1 , L 2 ) by the levels (k 1 , k 2 ), where k i = e(L i ) ∈ H 2 (W, ∂W ). Under concatenation, these levels add.
Secondly, the C * -action on P 1 lifts to an action of the torus T = (C * ) 2 on X p , via the natural scaling action on the fibres. The Gromov-Witten invariants in this case are defined via the virtual localization formula as a residue integral over the T -fixed point locus, along the lines explained in Section 3.5. A stable map to X p which is T -invariant factors through the zero section. It follows that there is a natural isomorphism of moduli spaces M g (X p , β) T = M g (P 1 , β), with β = d ∈ Z, and consequently M g (X p , d) T vir = M g (P 1 , d) vir .
This equality of virtual fundamental cycles implies that the invariants constructed by integrating over each moduli space coincide. It means that topological string theory on X p is equivalent to a field theory on P 1 , which is just the reduction we argued in Section 5.1. In this case the Gromov-Witten invariants of X p correspond to degree d Hurwitz numbers of P 1 .
Returning to our computations, we get the annulus (or tube) amplitude by contracting the cap and trinion amplitudes to get Finally, we compute the amplitude of the fibration X p → P 1 by using (5.3) and the gluing rules. In order to get the appropriate bundle degrees (p − 2, −p), we glue p tubes between two caps to get Z(X p ) = Z  For p = 1, the threefold X 1 ∼ = K 1/2 P 1 ⊕ K 1/2 P 1 is the resolved conifold and this formula is a qdeformation of the classical Hurwitz formula counting unramified covers of the Riemann sphere P 1 .
In fact, the quantity d q (R) is analogously the N → ∞ limit of the quantum dimension dim q (R) of the U (N ) representation with the same Young tableau. This follows by Schur-Weyl reciprocity which writes SU (N ) representations in terms of representations of the symmetric group S N . Let R be a representation corresponding to a Young diagram λ with row lengths λ i , i = 1, . . . , d(λ), where λ 1 ≥ λ 2 ≥ . . . and d(λ) is the number of rows in λ. Set µ = q N , and define another q-number by [n] µ = µ 1/2 q n/2 − µ −1/2 q −n/2 q 1/2 − q −1/2 .
Then the quantum dimension of R can be written as This is a Laurent polynomial in µ ± 1/2 whose coefficients are rational functions of q ± 1/2 . The leading power of µ is |λ| 2 , and the coefficient of this power is the rational function of q ± 1/2 given by As before, this is just the topological vertex amplitude C R,∅,∅ (q). The limit q → 1 gives the ordinary dimension of the representation R.
Generalizing the generating function (5.4) thereby gives where now the sum runs over irreducible representations R of U (N ) and C 2 (R) = k R + N (R) is the second Casimir invariant of R. By the attractor mechanism, the Kähler modulus of P 1 is given by t = N 2 (p − 2) g s . In the limit q → 1, this two-dimensional field theory coincides with ordinary Yang-Mills theory on the sphere P 1 . Note that this is a weak-coupling limit g s → 0, with p g s = g 2 YM A and A the area of P 1 . Using similar constructions as above, it is possible to formulate this gauge theory directly as a two-dimensional topological field theory, without any reference to the extrinsic bundle structure of the local threefold X p . Explicit computations of the corresponding Gromov-Witten invariants of X p can be found in refs. [15,16].

Wall-crossing formulas
Finally, let us briefly comment on the relationship to black hole entropy counting. Reinstating the ϑ-angle as in (5.2), the attractor mechanism fixes the Kähler modulus of Σ 0 = P 1 as The large N limit of the partition function (5.2) should possess this modulus. The modulus squared structure anticipated by the OSV relation (2.5) is given in this limit by [1] Z qYM P 1 = r∈Z R 1 ,R 2 Z qYM+ R 1 ,R 2 (t + p g s r) Z qYM− R 1 ,R 2 ( t + p g s r) , where the sum over r runs through U (1) charges in the local decomposition U (N ) ∼ U (1) × SU (N ) of the gauge group, the second sum runs through pairs of irreducible SU (N ) representations R 1 , R 2 , and Z qYM+ R 1 ,R 2 (t) is the perturbative topological string amplitude on X p with two stacks of D-branes in the fibre. The conjugate amplitude is Z qYM− R 1 ,R 2 (t) = (−1) C 1 (R 1 )+C 1 (R 2 ) Z qYM+ R t 1 ,R t 2 (t). Thus in this case the OSV relation (2.5) is modified to the symbolic form where the first sum runs over Ramond-Ramond fluxes r through the base Riemann surface Σ g , while the second sum is over fibre D-branes which carry additional moduli t measuring their distances from the base Σ g along the non-compact fibre directions.
Further analysis of the relationships with N = 4 Yang-Mills theory on C p are studied in refs. [15,17,39,10], where it is observed that the instanton expansions of the two-dimensional and four-dimensional gauge theory partition functions differ by perturbative contributions. These extra factors arise from the non-compactness of the surface C p . When C p is the resolution of an A p,n singularity, its boundary is the three-dimensional Lens space L(p, n) = S 3 /Γ (p,n) . The perturbative factors can then be identified as the partition function of Chern-Simons gauge theory on the boundary, and arise as a consequence of the fact that the two-dimensional gauge theory implicitly integrates over all boundary conditions. Once these boundary contributions are stripped, the enumeration of instantons in the two-dimensional and four-dimensional gauge theories coincide [39].