Fiber-base duality from the algebraic perspective

Quiver 5D $\mathcal{N}=1$ gauge theories describe the low-energy dynamics on webs of $(p,q)$-branes in type IIB string theory. S-duality exchanges NS5 and D5 branes, mapping $(p,q)$-branes to branes of charge $(-q,p)$, and, in this way, induces several dualities between 5D gauge theories. On the other hand, these theories can also be obtained from the compactification of topological strings on a Calabi-Yau manifold, for which the S-duality is realized as a fiber-base duality. Recently, a third point of view has emerged in which 5D gauge theories are engineered using algebraic objects from the Ding-Iohara-Miki (DIM) algebra. Specifically, the instanton partition function is obtained as the vacuum expectation value of an operator $\mathcal{T}$ constructed by gluing the algebra's intertwiners (the equivalent of topological vertices) following the rules of the toric diagram/brane web. Intertwiners and $\mathcal{T}$-operators are deeply connected to the co-algebraic structure of the DIM algebra. We show here that S-duality can be realized as the twist of this structure by Miki's automorphism.


Introduction
The most remarkable achievement of string theory is arguably the derivation of non-perturbative dualities between quantum field theories. The network of dualities obtained in this way is particularly rich among four dimensional (class S) N = 2 super Yang-Mills (SYM) theories, and their five dimensional N = 1 uplifts. Indeed, these theories sustain correspondences with both classical and quantum integrable systems [1][2][3], but also with 2D Liouville/Toda conformal field theories (or q-deformed conformal blocks in the 5D scenario) through the celebrated AGT conjecture [4][5][6]. Furthermore, these supersymmetric gauge theories can be realized as the low-energy limit of brane dynamics, and the application of (type IIB strings theory) S-duality on this construction generates dualities among them [7][8][9]. From the 5D gauge theory perspective, S-duality implies an enhancement of global symmetries at the UV fixed points [10], a fact that was first predicted by Seiberg in [11] (and generalized further in [12,13]). This enhancement has been explicitly observed by computation of BPS quantities (conformal index in [14], Nekrasov partition functions in [10]).
This paper explores the realization of S-duality, also called fiber-base duality (see below), among 5D N = 1 quiver gauge theories using an algebraic formalism developed recently in the series of papers [15][16][17][18][19][20][21], and based on the Ding-Iohara-Miki (DIM) algebra [22,23]. This formalism, referred here as algebraic engineering, highlights the integrable properties of the gauge theories' BPS sector, and, at the same time, expresses in a very elegant manner the covariance properties under the (q-deformed) W-algebra at the root of AGT correspondence. In fact, we have two main motivations for our study. The first one is the perspective to export the S-duality tool to integrable systems and 2D conformal field theories (CFTs). In this way, a systematic derivation of spectral dualities between integrable systems (such as the one observed in [24][25][26][27]), as well as non-trivial relations between 2D conformal blocks [10,28], could be obtained. Our second motivation is the possibility to exploit the algebraic formalism to write the proofs of the non-trivial (and non-perturbative) relations that S-duality implies among gauge theories quantities (partition functions, BPS Wilson loops,...). Here, we propose to address these two issues using an automorphism of the DIM algebra, namely Miki's automorphism [23], to twist the coalgebraic structure responsible for integrability. 1 In order to understand better the role of Miki's automorphism, it is necessary to review first the (p, q)-brane construction of these gauge theories [8,30]. In type IIB string theory, a (p, q)-brane is a bound state of p D5 and q NS5-branes. It is a 5-brane that fills the dimensions 0-4 (where the gauge theory background lies) and forms a segment in the 56-plane oriented along the direction of angle θ 56 ∼ arctan(p/q). Hence, with this convention, pure NS5-branes are drawn horizontally (in the '5' direction) and pure D5-branes vertically. The brane-web represents the configuration of (p, q)-branes in the 56-plane, and characterizes the underlying N = 1 theory. To be specific, we consider here 5D N = 1 theories on the Omega-deformed background R 2 1 × R 2 2 × S 1 R . The corresponding partition functions are one-loop exact, but contain a tower of non-perturbative (instanton) corrections that have been computed by localization in [31]. Alternatively, the partition function can also be derived as a topological string amplitude [32]. Away from the self-dual case 1 + 2 = 0, it is necessary to employ the refined version of the topological vertex introduced in [33][34][35]. The topological string is compactified on a certain Calabi-Yau threefold for which the toric skeleton (or, simply, toric diagram) coincides with the (p, q)-brane web [36]. As a result, the brane-web provides the gluing rules for the topological vertices associated to each (p, q)-brane junction.
In the (p, q)-brane web construction, the action of S-duality exchanges D5 and NS5-branes, and more generally acts on the branes' charges by sending (p, q) to (q, −p). This operation effectively rotates the (p, q)-branes web by 90 • , and thereby induces a duality between the gauge theories associated to the two brane webs, the original and the rotated ones. In the topological strings setup, the rotation of the toric diagram exchanges fiber and base for the Calabi-Yau, which coined the term fiber-base duality [37].
The algebraic engineering of the gauge theory is based on a realization by Awata, Feigin and Shiraishi [38] of the (refined) topological vertex as an intertwiner of the DIM algebra. 2 This algebra depends on two parameters q 1 and q 2 that encode the dependence on the background parameters: q 1 = e R 1 and q 2 = e R 2 . The algebraic engineering is, in fact, a reformulation of the (p, q)-brane construction in algebraic terms: to each brane of charge (p, q) corresponds a representation characterized by the two levels ( ,¯ ) = (q, p), and to each (trivalent) brane junction, or topological vertex, is associated an operator intertwining between three representations. The gluing rules of intertwiners also follow the brane-web picture, the gluing being simply realized as a product of operators in the shared representation. In this way, it is possible to associate to each brane-web an operator T acting on a tensor product of representations. This operator is the essential object of the construction. Its vacuum expectation value (v.e.v.) reproduces the instanton partition function of the gauge theory [20,21]. Besides, it can further be used to compute other BPS quantities (like the qq-characters [20]).
In [23], Miki describes an automorphism of the DIM algebra that acts on the two central charges (c,c) by sending them to (−c, c). As a result, a representation ρ with levels (ρ(c), ρ(c)) = ( ,¯ ) composed with this automorphism becomes a representation ρ of different levels (ρ (c), ρ (c)) = (−¯ , ). Since the two levels encode the branes charges, the composition by Miki's automorphism renders the S-duality transformation in the algebraic formalism [17]. 3 Building on this fact, we investigate here the transformation of intertwiners, and their composite objects (T -operators, Lax matrices). 4 In this process, a twist of the coproduct by Miki's automorphism appears naturally, an the S-duality is reformulated as an equivalence between quantities derived from the two different coalgebraic structures. Note that this approach is essentially different from the one employed by Awata and Kanno in [40], and in which S-duality relations follow from a change of the preferred direction for the topological vertex. In our case, the preferred direction is fixed, it corresponds to the vertical representation and it is associated to D5-branes once and for all. In practice, the main difference is that, in addition to changing the way topological vertices are coupled, we also need to implement the rotation of the vertices, and thus introduce new types of intertwiners associated to the rotated representations.
This paper is organized as follows. In the section two, we introduce the DIM algebra, describe the vertical (D5) and horizontal (NS5, NS5+D5) representations, and discuss the action of Miki's automorphism. The notion of intertwiner is reviewed in the third section, their transformation properties are investigated at a general level, and many new types of intertwiners are constructed. These results are used in the section four and five to analyze the S-transformation of Lax matrices and T -operators (respectively). Three important examples will be provided: the (resolved) conifold, and the pure U (1) and U (2) gauge theories. In each example, the S-duality relation appearing in gauge theory follows from the equality between the v.e.v. of algebraic quantities derived from the two coalgebraic structures. The transformation of the vacuum state is a key point in this derivation, and must be studied case by case. The technical parts of the discussions have been gathered in the appendices. The appendix A presents advanced properties of Miki's automorphism, it includes expressions for the S-dual generators, discusses their action in the vertical module, and investigate the possibility to refine the definition of Miki's automorphism using grading operators. The second appendix is a simple reminder on the building blocks entering in the construction of Nekrasov partition functions. Appendix C shows the construction of a new type of intertwiners, but also introduces new operators in the Cartan sector, and defines a set of coherent state for the Fock modules of horizontal representations. Finally, the appendix D contains the calculations relevant to the S-transformation of vacua.

(2.2)
In this formulation, κ is a C-number and g(z) a function that can be expressed in terms of the three complex parameters q 1 , q 2 , q 3 constraint under the relation q 1 q 2 q 3 = 1, 3) The function g(z) obeys the 'unitarity' property g(z)g(1/z) = 1 necessary to the consistency of the relations 2.2. The form of this algebra directly follows from the gauge theory background R 2 1 × R 2 2 × S 1 R , and the parameters are identified as (q 1 , q 2 ) = (e R 1 , e R 2 ). Deformations of this algebra have been introduced to treat different backgrounds: an elliptic deformation for 6D gauge theories [41], a higher rank version (quantum toroidal gl n ) for the 5D background with orbifold [42], and a degenerate version for 4D N = 2 gauge theories [43].
The DIM algebra possesses two central charges denoted c andc. The first one corresponds to the central element γ that can be writtenγ = γ c with the shortcut notation γ = q 1/2 3 . The second one is associated to the zero modes ψ ± 0 of the currents ψ ± (z): these two modes are also central, and can be written ψ ± 0 = γ ∓c . 5 Hence, representations are labeled by two (integer) levels ( ,¯ ) corresponding to the value of the central elements Vector spaces equipped with a representation ρ ( ,¯ ) v of levels ( ,¯ ) and weight v will be denoted ( ,¯ ) v . Weights will later be associated to the (exponentiated) positions of the branes.
The subalgebra generated by the elements ψ ± ±k and the central elementγ can be seen as the analogue of the Cartan subalgebra of standard Lie algebras. It is sometimes useful to express the Cartan generators ψ ± ±k in terms of the modes a k of an Heisenberg subalgebra [23], Then, the relations ψψ, ψx, and [x, x] given in 2.2 take a simpler form: (2.6) 5 The requirement ψ + 0 = (ψ − 0 ) −1 fixes partially the invariance of the algebra under a rescaling of the generators. The remaining invariance x ± (z) → ω ±1 x ± (z) is associated to an automorphism generated by a grading element, it will be discussed below. On the other hand, the q-commutation relations x ± x ± remain fairly complicated. The coefficients c k in the r.h.s. of the commutators arise from the expansion of the function g(z) in 2.2: Here [g(z)] + refers to the expansion of the function g(z) at infinity, while [g(z)] − denotes its expansion in a neighborhood of zero. It follows from the unitarity property of g(z) that the coefficients c k obey c k = c −k . In addition, it is possible to associate two different degrees to the generators of the DIM algebra using the grading operators d andd obeying the commutation relations These relations assign the degrees (d, −d) ∼ (±1, k) and (d, −d) ∼ (0, ±k) respectively to the modes x ± k and ψ ± ±k , while central elements are of degrees (0, 0). Operators of higher degree underd are obtained from the commutation of the modes x ± k . Thus, DIM operators can be classified according to their degrees (d, −d) ∈ Z × Z, and the generators have been represented in figure 1. Furthermore, the grading operators can be used to define two different automorphisms, for any element e of the DIM algebra A DIM . These automorphisms act on the modes of the Drinfeld currents as follows: (2.10) In effect, τ ω describes the freedom of rescaling the variable z of the currents, whileτω generates a rescaling of the currents x ± (z). These two automorphisms are discussed in greater details in the appendix (section A.3). In string theory, automorphisms of the DIM algebra correspond to geometric transformations of the (56)-plane (see for instance [20], section 2.6). It is shown in appendix that the action of τ ω corresponds to an overall translation along the NS5-direction, while the action ofτω encodes the translation along the perpendicular direction (D5-branes).

Miki's automorphism
The automorphism S discovered by Miki in [23] is fully determined by its action on the central charges (c,c) → (−c, c) and on the four generators It is readily seen that this automorphism is of degree four (i.e. S 4 = 1). Formulas for the transformation of the generators x ± k , ψ ± ±k are provided in appendix A. However, since they involve repeated commutations, they quickly become cumbersome to use. Apart from the modes a ±1 and x ± 0 appearing in 2.11, the four modes x ± 1 and x ± −1 are the only ones that are mapped to modes of the Drinfeld currents 2.1: Miki's automorphism also acts on the grading operators, sending (d,d) to (−d, d). This transformation follows from the requirement of keeping the commutation relations 2.8 invariant. As a consequence, an element e ∈ A DIM of degrees (d e ,d e ) is mapped to another element with degrees (d e , −d e ). It results that the automorphism S acts as a clockwise rotation of angle 90 • on the representation of the generators (c.f. figure 1).
As we mentioned in the introduction, it is possible to define a new representation by the composition ρ • S. For short, we will call it the S-dual representation. Due to the transformation property of central charges, this representation has levels (−¯ , ). In string theory, the (p, q)-branes are uniquely characterized by their charges (and position), and so we expect that the representations associated to them will also be fully characterized by their levels (and weight). Thus, from the physics perspective, we expect that the S-dual representation ρ , up to a possible change of basis: (2.13) In this relation, the image of the element e ∈ A DIM under the automorphism S has been denoted S · e, and M ( ,¯ ) S is an infinite (yet graded) matrix. Note also that while transformation of levels is known, on the contrary the transformation of the weights, formally denoted hereṽ = S · v, depends on the explicit form of the representation and has to be resolved case by case. Mathematically, the assumption 2.13 is rather challenging, and needs to be properly established. We will see below that the matrices M (2.14)

Twisted coproducts 2.3.1 Twist by an automorphism
The DIM algebra has the structure of a Hopf algebra with the Drinfeld coproduct defined as We denoted hereγ (1) =γ ⊗ 1 andγ (2) = 1 ⊗γ. The coalgebraic structure also contains an antipode and a co-unit but since we do not need them in this paper, we will not give their expression. This Hopf algebra is quasi-triangular, which implies the existence of a universal R-matrix R that intertwines ∆ with the opposite coproduct ∆ obtained by permutation (∆ = P∆P with P(a ⊗ b) = (b ⊗ a)P, P 2 = 1): (2.16) Unfortunately, no explicit expression of the universal R-matrix is known (for generic c andc), but partial/implicit expressions are discussed in [17,19,[44][45][46]. Miki's automorphism preserves both the linear and multiplicative structure of the algebra, therefore it can be used to twist the co-algebraic structure [47]. The twisted coproduct 6 defines a new quasi-triangular Hopf algebra with the universal R-matrix R S = (S −1 ⊗ S −1 )R and a twisted antipode. The coproduct ∆ S appears naturally in the transformation of trivalent intertwiners (a.k.a. topological vertices). Indeed, the intertwining property involves a representation ρ obtained from two other representations ρ 1 and ρ 2 by coproduct, that is ρ = (ρ 1 ⊗ ρ 2 )∆. Then, the S-dual representation ρ = ρ • S can be written in terms of ρ i = ρ i • S (i = 1, 2) using the twisted coproduct ρ = (ρ 1 ⊗ ρ 2 )∆ S . We can define in a similar way a twisted coproduct ∆ S k for any power S k of Miki's automorphism. The action of S 2 on the Drinfeld currents 2.1 takes a simple form: As a result, it is possible to write down explicitly the action of the twisted coproduct ∆ S 2 on these generators. Remarkably, this twisted coproduct coincides with the opposite coproduct ∆ involved in the definition of the universal R-matrix. This leads to interpret the automorphism S as a sort of square root of the R-matrix. This result should have tremendous consequences for integrable systems built upon DIM algebra [48][49][50]. We hope to come back to this important issue in a future publication.

Twist by a two-tensor
The so-called Drinfeld twist provides another way to deform a coalgebraic structure [47,51]. In this case, the coproduct is twisted by an invertible two-tensor F that should satisfy the following properties: Here we used the standard notation F ij for the action of F in ith and jth tensor space and ε denotes the co-unit. The twisted coproduct F∆F −1 defines a new quasi-triangular Hopf algebra with universal R-matrix F * RF −1 , F * = F 21 denoting the permutation of the two-tensor, i.e. PF P. Although a general statement does not seem to exist, it has been observed in some cases that the twisting by an automorphism can also be realized as a two-tensor twist. For instance, this is the case for Lusztig's automorphism of U q (g) where g is a simple, finite-dimensional, Lie algebra [47]. This is also the case for the twist by the automorphism S 2 , since ∆ S 2 identifies with the opposite coproduct, and the corresponding two-tensor F S 2 is simply the universal R-matrix R. In fact, the existence of the two tensor F S has been prooved in [49] (lemma A.5) in the restricted case c = 0. In this paper, it will be convenient, although not essential, to assume that the S−twisted coproduct ∆ S defined in 2.18 can also be obtained by a Drinfeld twist with the two-tensor F S : where F * S = F S21 is the permutation of F S . This assumption will provide us a general intuition on the transformation of algebraic objects. However, strictly speaking, we do not need the existence of the universal object F S , but 6 This coproduct ∆S differs from ∆ as it is possible to compute, for instance, 17) only its realization in specific representations. The latter will be constructed explicitly below, up to a normalization factor, using a product of intertwiners. Several interesting properties follow from our assumption 2.21. First, the opposite coproduct ∆ can be twisted in the same manner, Moreover, since S 4 = 1, we notice that ∆ S = ∆ S 3 = ∆ S −1 , which implies the existence of the two tensor F S −1 = F * S R associated with the twist by the automorphism S −1 , and the corresponding twisted R-matrix is Finally, inverting these relations, it is possible to express the universal R-matrices solely in terms of F S and F S −1 (and their permutation), and re-interpret them as factors in a certain decomposition,

Representations
In the algebraic engineering, vertical representations are associated to (multiple) D5-branes, and horizontal representations to NS5-branes (possibly dressed by extra D5-branes). These representations have already been presented in several papers, we reproduce them here for consistency and follow the conventions employed in [21]. Then, we investigate the S-dual representations and derive the expression of several matrices M ( ,¯ ) S .

Vertical representations
The modules of vertical representations, denoted here (0, m) v were introduced in [52]. They are infinite dimensional vector spaces with a basis of states | v, λ parameterized by an m-tuple Young diagram λ = (λ (1) , · · · , λ (m) ), and on which the Drinfeld currents act as follows: (2.24) These representations have levels ( ,¯ ) = (0, m), they are lowest weight representations, with the vacuum | v, ∅ corresponding to empty Young diagrams, and the lowest weights given by the vector v = (v 1 , · · · , v m ). They are associated to m parallel D5-branes, with (exponentiated) positions v 1 , · · · , v m along the axis '5' of the 56plane. In the gauge theory, the level m coincides with the rank of the gauge group U (m), and the weight with the exponentiated Coulomb branch v.e.v.. The modes of the currents x ± (z) behave as instantons creation/annihilation operators, and their action involves a summation over the sets of boxes A( λ) (resp. R( λ)) that can be added to λ (or removed from λ). To each box x = (l, i, j) in λ with coordinates (i, j) in the lth Young diagram, has been associated the complex parameter The vertical action 2.24 has been written using the functions . (2.25) These two functions possess an alternative expression as a product over the box content of each Young diagram: (2.26) The function S(z) is related to the function g(z) defined in 2.3, and involved in the definition of the algebra, through the relation g(z) = S(z)/S(z −1 ). It obeys the functional identity S(q 3 z) = S(z −1 ).
By expanding the functions Ψ λ (z) both around z = ∞ and z = 0, it is possible to deduce the representation of the modes a k describing the Cartan sector: This expression involves the coefficients c k defined in 2.7 from the two expansions of the function g(z). It is also necessary to introduce a dual basis v, λ| for the vertical modules, which is orthogonal (but not orthonormal) to the basis of states | v, λ : The scalar product involves the quantity Z vect. ( v, λ) that coincides with the vector multiplet contribution to the Nekrasov instanton partition function. A brief reminder on the various building blocks for these partition functions can be found in appendix B. Note that in the case of m = 1, the (inverse) norms a λ are in fact independent of the weight v of the representation. The non-trivial norm is introduced here in order to simplify the expression of the contragredient representationρ that acts on the dual basis in such a way that With our choice of normalization, the action ofρ reads just like 2.24, but with x ± (z) replaced by −x ∓ (z). Vertical representations of levels ( ,¯ ) = (0, −m) can be defined using the automorphism S 2 . The corresponding modules are isomorphic to (0, m) v , and the action of the Drinfeld currents on the basis takes the form is actually trivial here, and (p, q)-branes of charges (0, m) and (0, −m) can be formally identified.

Horizontal representations
Representations with level ∈ Z \ {0} are called horizontal representations, they are obtained as a tensor product of | | q-bosonic Fock modules. In this paper, we restrict ourselves to the case of a single q-boson, i.e. | | = 1. Then, all the modules (±1, n) u with n ∈ Z are isomorphic to the Fock space defined over the q-bosonic modes α k with the commutation relations Positive modes annihilate the Fock vacuum |∅ , while negative modes create excitations. We further introduce the dual state ∅|, annihilated by negative modes, and the normal ordering : · · · : is defined by moving the positive modes to the right. The horizontal representation will be defined using the vertex operators In representation of levels (±1, n) and weight u, the DIM algebra acts on the Fock modules as follows [53]: 7 As the levels indicate, these representations are associated to a bound state of a single NS5-brane and |n| D5-branes. The weight u encodes the position of the (p, q)-brane along the axis '6' of the 56-plane. Due to the property ρ are trivial, and the weight u remains invariant under S 2 . As a result, (p, q)-branes of charges (1, n) and (−1, −n) can also be identified.

Action of Miki's automorphism on the representations
In this paper, we restrict ourselves to representations with levels ,¯ ∈ {−1, 0, 1} that define a closed subset under the action of Miki's automorphism. To study this action, we need to introduce a new basis in the horizontal Fock space, in addition to the usual PBW basis. This is achieved using an isomorphism sending horizontal representations into representations acting on Macdonald symmetric polynomials P λ with the parameters q = q 2 and t = q −1 1 [53]. Under this isomorphism, the vacuum state |∅ coincides with the constant 1, and the oscillator modes are written in terms of the power sum symmetric polynomials p k : Under this identification, the zero mode of the vertex operator η + (z) reproduces the Macdonald operator. The latter is diagonalized by the Macdonald polynomials P λ . It leads us to introduce the corresponding states |P λ in the Fock modules as an eigenbasis of the operator η + 0 with the non-degenerate eigenvalues E λ : 8 (2.36) 7 In contrast with the convention used in [20], here we have rescaled the weights of representations (±1, n) by sending u → ±uγ ∓n . 8 The two possible expressions for the function Y λ (z) (given 2.25 and 2.26) induce at the asymptotics z → ∞ the relation which provides an alternative expression for E λ .
However, this eigenvalue equation does not fix the normalization of the states. Instead of taking the standard norm of Macdonald polynomials, here we adjust it in such a way that the Pieiri rule with the elementary symmetric polynomial e 1 = p 1 coincides precisely with the vertical action of x + 0 : 9 In the same spirit, we also modified the norm of dual Macdonald polynomial Q λ , and introduced the dual basis P λ | such that P λ | P µ = a −1 λ δ λ,µ with the coefficients a λ given in 2.28. This choice of normalization for the vertical and horizontal basis corresponds to a choice of framing factors for the topological vertex [35].
In order to compare with vertical representations, we also need the action of η − 0 on the Macdonald states |P λ . It can be obtained using the isomorphism σ V that sends the DIM algebra with parameters q 1 , q 2 , q 3 to the DIM algebra with inverse parameters q −1 1 , q −1 2 , q −1 3 . This isomorphism encodes the vertical reflection in the 56 plane [21]. It sends the mode x + 0 to x − 0 , and as a consequence, Finally, the action of α 1 follows from the Pieiri rules applied to the dual Macdonald polynomial with our specific choice of normalization it gives We now compare horizontal and vertical modules. It is seen in appendix A that the DIM algebra is in fact generated by only four modes: a ±1 and x ± 0 . Hence, it is sufficient to examine the action of these four modes in order to show the isomorphism 2.13 between vertical and horizontal modules. Comparing ρ Under this transformation, the vertical weights v are mapped to horizontal weights u = −γv, The original Pieiri rule for e1 with the standard norm of Macdonald polynomials [54] can be written as where the ordering on the boxes x = (i, j) ∈ λ is defined such that x < x iff i < i or i = i and j < j . However, here instead of the normalization P λ = m λ + · · · (with m λ the monomial symmetric function), we use P λ = n λ m λ + · · · with We would have chosen the standard norm instead, the coefficients n λ would have appeared as the values of the matrices M The presence of this extra factor is a matter of conventions, it is related to the fact that the weights of the vertical representation are usually defined as (minus) the roots of the Drinfeld polynomial that really correspond to −γv l ( = 1, · · · , m).
Finally, we would like to consider the S-transformation of horizontal representations (1, ±1) and (−1, ±1). Using the properties it is easy to show that, the modules beeing isomorphic, if the matrices M (±1,1) S and M (1,±1) S exist, they must be diagonal in the basis |P λ . Moreover, the identities M (and similarly for the four other matrices) impose some relations among the eigenvalues of the different matrices M S . At this stage, we can write down following the Ansatz: , since the other matrices can be treated in the same way. The DIM algebra is generated by only four modes that we can choose to be a ±1 and x ± ±1 . The previous arguments can be applied to both x ± ±1 using the isomorphism σ V . Thus, it only remains to treat the case of a ±1 ∝ S · x ∓ 0 , for which we need to show that For this purpose, we consider the commutator in the Macdonald basis |P λ . We will focus here on η + 1 , the treatment of η − −1 being similar. Comparing with the action 2.41 of α 1 , we deduce that the constraint 2.46 on η + 1 is satisfied provided that the diagonal elements of the matrix M The analysis of the constraint coming from η − −1 in 2.46 gives the same value for d λ . The choice of d ∅ is let free, we set d ∅ = 1 so that M (1,1) S maps the vacuum state |∅ to itself.

Definition of intertwiners and twisting
Trivalent intertwiners are the building blocks of the algebraic engineering of 5D N = 1 gauge theories for which they play the role of the refined topological vertex. However, in contrast with topological strings, there exists several types of intertwiners in the DIM algebra, each parameterized by the level of the representations involved. In this way, it is possible to associate certain 'higher rank' intertwiners to brane-webs involving more than one topological vertex (see [20]), leading to a more efficient method to compute topological strings amplitudes. In addition, it is also necessary to distinguish between the intertwiner Φ, and the dual one Φ * . Indeed, the web of intertwiners should be oriented, the orientation corresponding to the mapping from one module to another. Intertwiners Φ and Φ * correspond respectively to vertices with one and two outgoing arrows (see figure 2). Notice that Φ * can be obtained from Φ by a reflection along the diagonal x 5 + x 6 = 0 in the 56 plane (flipping also the arrows).
Algebraically, intertwiners are defined as the solution to the following equations: (3.1) These equations do not determine the intertwiners uniquely, as it is still possible multiply them by a factor depending on the levels and weights (for instance). Whenever it is possible, this ambiguous factor will be set to one. Once this ambiguity is fixed, we expect that intertwiners involved in the correspondence with topological strings become unique. The relations 3.1 applied to the central charges c andc imply the conservation of the levels = 1 + 2 and =¯ 1 +¯ 2 , corresponding to the charge conservation of the branes. Thus, intertwiners can be labeled by only two sets of levels ( 1 ,¯ 1 ) and ( 2 ,¯ 2 ). Obviously, intertwiners also depend on the weights of the representations, however we will not indicate them in order to lighten the notation. A constraint on these weights is also observed, it takes the form with the representation-dependent functions of the weights ω ( ,¯ ) (v). Explicit calculations give the values ω (±1,n) (u) = u for horizontal representations, and ω (0,±m) ( v) = m l=1 (−γv l ) for vertical representations.
There are two (somewhat equivalent) ways of defining the action of S-duality on intertwiners: either replacing the representations by the S-dual ones, or replacing the coproduct by its twisted version. The first point of view is relevant to string theory, since S-duality implies the rotation of (p, q)-branes that effectively replace representations by the dual ones. We will call rotated intertwiner the intertwiner Φ −¯ 1 1 −¯ 2 2 describing the topological vertex after rotation of the brane web. On the other hand, the replacement of the coproduct by its twisted version is more interesting from the integrability perspective. We will call S-dual intertwiner the corresponding intertwiner, and denote it Φ S . This object is defined as the solution of the equations 3.1 with ∆ replaced by ∆ S :

(3.2)
The relation between rotated and S-dual intertwiners involves the matrices M S , it will be given below.

Action of S 2 and inversion of intertwiners
Before looking at the action of S, it is instructive to consider first S 2 . There are two different ways to solve the equations 3.1 for Φ S 2 and Φ * S 2 (i.e. with ∆ and ∆ exchanged since ∆ S 2 = ∆ and S 4 = 1). The first possibility is to use the intertwining property of the universal R-matrix and replace ∆ with R∆R −1 . As a result, we find the solutions where we have introduced the Lax matrix A second solution can be found by introducing the matrices M S 2 using the property 2.13. A simple calculation gives This solution relates the two definitions of S 2 -dual intertwiners. However, the main subtlety here is that this second solution may not coincide with the previous one, although we expect that they differ only by a normalization factor. In the following, as a point of reference for normalization factors, we consider 3.5 as the genuine solution.
Then, it is important to observe the following fact. Considering the two following products of intertwiners (taken in both intermediate modules it is possible to show using the properties 3.1 that they commute with the action of the DIM algebra in the representation ( ,¯ ) v . In the case of interest, namely vertical (0, ±m) and horizontal (±1, n) representations, this property implies that N and N * are constants (of course, depending on levels and weights). When these constants are finite, the dual intertwiner Φ * S 2 provides the right inverse of Φ, and similarly Φ S 2 gives the left inverse of Φ * . We would like to emphasize that these considerations, although very general, can also be used in practice to write down the inverse of an intertwiner using the solution 3.5 found previously. We will give below an explicit verification of the two identities 3.6 in certain representations.
We would like to conclude this paragraph on the action of S 2 with a side remark. In fact, there is a third way to find a solution for Φ S 2 and Φ * S 2 , in which we introduce the permutation operator P(a ⊗ b) = (b ⊗ a)P. In this way, we find:

S-transformation of intertwiners
Just like in the case of Φ S 2 , there exists several ways of solving the twisted intertwining relations 3.2. The simplest way, assuming the existence of the two-tensor F S , is to replace In this case, we find This solution is not very useful since no expression is known for F S in general. Yet, it could be employed in a reverse way to find an expression for the specialization F S 1¯ 1 2¯ 2 from the knowledge of Φ S and Φ.
The second method employs the property 2.13, it provides a relation between the S-dual intertwiner Φ S and the rotated one, Note however that in this formula, the rotation of intertwiners Φ and Φ * is performed in the opposite direction, so that it corresponds the action of S −1 on the representations.
Using the formula for the inversion of intertwiners 3.6, combined with the solution 3.5 for Φ S 2 , the rotated intertwiner can be expressed in terms of the original one, In contrast with the transformation two-tensors F S 1¯ 1 2¯ 2 with which they are affiliated, the expression for the two- can be written down explicitly, and we will provide several examples later on. Assuming that the solutions Φ S obtained with the different methods are proportional, the two-tensors can be related as follows: In fact, even though it can be made explicit, the exact expression for the two-tensorsF S will remain rather complicated. On the other hand, they satisfy simple covariance properties under the action of DIM algebra that can (and will) be exploited:

Example of intertwiners
In this subsection, we provide the explicit expression for several types of intertwiners. These expressions will be used to check some of the identities obtained previously using Miki's automorphism. Moreover, they will also be employed in the next sections to investigate the action of S-duality on particular brane webs.

Generalized AFS intertwiners
The first intertwiners for the DIM algebra were introduced by Awata, Feigin and Shiraishi in [38], they correspond in our notation to Φ[ 0 1 1 n ] and Φ * [ 0 1 1 n ]. They are associated to the genuine refined topological vertex [33,34] and describe the junction of a D5-brane and a NS5-brane, dressed by n-D5 brane, forming a bound state of one NS5brane and n + 1 D5-branes. These intertwiners were later generalized in [20] to vertical representations of higher level m > 0 using a fusion technique. The new intertwiners involve the representations (1, n + m) u , (0, m) v and (1, n) u , and describe m topological vertices with parallel preferred direction, and successively glued along a nonpreferred direction. In this way, they represent a NS5-brane, dressed by n D5-brane, meeting a stack of m D5-brane (not necessarily overlayed), to form a bound state of one NS5-brane dressed by n + m D5-branes.
The generalized AFS intertwiners are conveniently presented as vectors of the vertical modules, with coefficients being vertex operators mapping the Fock spaces of the horizontal modules: where t λ and t * λ denote the normalization coefficients The vertical components associated to the vacuum involve the operators Φ ∅ (v) and Φ * ∅ (v) that defines a sort of Fermi sea. They can be built using a product over the boxes of an infinite, fully filled, with the coefficients σ k given in 2.31.

New intertwiners V × H ↔ H
In fact, the generalized AFS intertwiner Φ presented above belong to a set of eight intertwiners obtained either by flipping the signs of the levels (1, n) → (−1, n), or (0, m) → (0, −m), or exchanging the representations (0, ±m) ↔ (±1, n). By convention, we denote the weight of representations (±1, n) as u, (0, ±m) as v, and (±1, n + m) as u . These intertwiners can also be decomposed over their vertical components, as in 3.16, and the corresponding coefficients read and (3.20) Note that the vertical coefficients of the intertwiner with opposite levels ( ,¯ ) → (− , −¯ ) can be obtained from the original ones by sending η ± (z) → η ∓ (z) −1 , and u → uγ ±m . In fact, this property follows from the action 2.19 of the automorphism S 2 .
In the same way, it is possible to define eight dual intertwiners, including the one given in 3.18, and

(3.22)
Action of S 2 These exact expressions give us the opportunity to verify some of the relations obtained using the action of S 2 . For instance, combining the expressions of Φ S 2 given either in terms of the permutation operator 3.7, or in terms of the matrices M S 2 3.5, we deduce the relations where P is the permutation operator in the appropriate representations, for instance Projecting the relations 3.23 on the vertical components, and taking into account that the matrices M S 2 are trivial with our definition of horizontal and vertical representations, these relations indeed reduce to the following equalities between intertwiners' components, which can also be observed directly (similar equalities can be written for Φ * ): Inversion of intertwiners It is also possible to check the inversion formula 3.6 for intertwiners, using again the expression 3.5 of Φ S 2 involving the matrices M S 2 . For instance, we find for N : (3.26) In the present case, the matrices M S 2 are trivial, and Since the product of intertwiners is done in both vertical and horizontal channels, the weights u, u and v must be the same for Φ and Φ * in these formulas. However, due to the infinite dimensional nature of representations, it is necessary to introduce a regulator µ such that u = µu * where u is the weight of representations (±1, n) coupled to Φ and u * the weight of representations (±1, −n) coupled to Φ * . Once normal-ordered, the product of vertical components, which is a priori a vertex operator, reduces to a simple constant. Observing further cancellations between this constant and the expression of the inverse norms a λ , we end up with where φ(z) is the Euler function, φ(z) −1 = λ z |λ| .
Conjugation We would like to conclude the analysis of this set of intertwiners with a short remark. It is possible to relate further the vertical components of intertwiners using the conjugation operation † defined on Fock space operators by (α k ) † = α −k , In the first identity, we have assumed that the weights transforms as (u ) † = u −1 , and u † = (u ) −1 in the second one. This operation of conjugation exchanges the two horizontal spaces (±1, n) u ↔ (±1, n + m) u , while also flipping the sign of the vertical level (0, m) → (0, −m). It can be seen as flipping the horizontal (and oblique) arrows associated to the (D5-dressed) NS5-branes in the representation of figure 2, at the cost of replacing the vertical representation by its S 2 -dual.

New intertwiners H × H ↔ V
Until now, we have only discussed a certain type of intertwiners that couples a horizontal representation to the tensor product of a horizontal and a vertical representation. However, another type of intertwiners appears in the study of Lax matrices presented in the next section. These intertwiners couple a vertical representation to a tensor product of two horizontal representations. They can be constructed following two different methods. In appendix C, they have been obtained by solving directly the intertwining relations 3.1. Since this method is rather technical, we present here another derivation based on the reflector state (and its dual) belonging to the tensor product of two Fock modules, Such states were introduced in [21] under the name horizontal reflection states, their essential property is the 'reflection' of the action of q-oscillator modes: The construction of the dual intertwiner is slightly easier. For definiteness, the first horizontal representation will carry the levels (−1, n) and weight u, while the second horizontal representation will bear the levels (1, m) and weight u . They form a vertical representation of levels (0, m + n) (with m + n > 0 for simplicity) and weight v such that uu = l (−γv l ), This intertwiner can be obtained as the reflection of a generalized AFS intertwiner acting in the first and third tensor space, Note that the weight in the left horizontal space for the auxiliary intertwiner has been inverted, in agreement with the weights conservation relation. Decomposing on the vertical components, we find This expression indeed coincides with the one obtained in appendix C, the coefficient t λ 0 m+n 1 −n reproducing the norm n * λ of the states | v, λ ⊗ . Geometrically, the reflector |Ω ⊗ effectively reverse the arrow on the leg corresponding to the representation (1, −n), and flip the sign of the levels to produce the representation (−1, n) u .
The same construction holds for the intertwiner using the dual reflector and an auxiliary intertwiner Φ * , The vertical decomposition reads it reproduces the expression found in appendix C with t * λ 0 m+n 1 −n identified with the norm n λ .

S-transformation of Lax matrices 4.1 Lax matrices
Coupling intertwiners is simply realized by taking a product, either a product of operators for horizontal representations, or a scalar product for vertical representations. In effect, intertwiners Φ and Φ * can be coupled in three different ways, depending on the choice of the common leg/representation, which leads to different algebraic objects.
In this section, we discuss only the case of a coupling along the common representation ( ,¯ ), Couplings along the other two legs is the subject of the next section. Moreover, for simplicity, we restrict ourselves to the case ( i ,¯ i ) = ( * i ,¯ * i ) (i = 1, 2), and denote Due to the intertwining properties 3.1 of Φ and Φ * , the operator L intertwines between the coproduct ∆ and its opposite ∆ , ρ 3) The rotation property of intertwiners 3.12 implies a similar property for L: The property 4.3 is also satisfied by the Lax matrix R 1¯ 1 2¯ 2 which is, by definition, the evaluation of the universal R-matrix in the representations ( 1 ,¯ 1 ) v 1 ⊗ ( 2 ,¯ 2 ) v 2 . However, this intertwining property alone does not fully determine the Lax matrix, since the universal R-matrix is further constraint to obey two extra relations in 2. 16.
In fact, the solution of the universal equation ∆ = R∆R −1 is unique, up to a factor A belonging to the centralizer of ∆(A DIM ) in A DIM ⊗ A DIM [55]. In practice, it has been observed that L is indeed proportional to R, with a factor depending on levels and weights: This factor is responsible for the anomaly term observed in [19] for the Yang-Baxter equation. Its expressions is known in a number of cases, for instance A[ 0 m 1 n ] = Z 1-loop ( v) −1 within our conventions [56]. With a slight abuse of terminology, we will also refer to L as an (ill-normalized) Lax matrix.
The same formulas can be written for the S-twisted coproduct, thus defining the quantities L S and A S . Using the formula 3.11 to express the S-dual intertwiners in terms of rotated intertwiners, we find the relation Assuming a proper mapping of the vacuum states, this relation, together with the rotation property 4.4, implies the equality between the vacuum expectation values of the Lax matrices: This is the equality that we will check on the two examples below. We shall see that they reproduce the S-duality relations observed among the instanton partition functions. The key to show this equality is the study of the vacuum transformation. Unfortunately, this task turned out too difficult for the transformationsF S andF * S in 4.4, and we will have to rely on some indirect arguments.

Example I: resolved conifold
Our first example is the toric diagram corresponding to the resolved conifold, it is represented on figure 3. The diagram on the left defines the Lax matrix which are, in turn, expressed as vertex operators in the Fock space: (4.11) The expression for the Nekrasov factors N (λ 1 , λ 2 |r) and the function G(z) can be found in appendix B. Projecting on the vacuum states, we deduce the respective v.e.v.
The two v.e.v. are equal, provided that the ratios v 2 /v 1 andṽ 1 /ṽ 2 coincide. We will see below that this is indeed the case. Note that the anomaly factor is irrelevant here since A[ (4.14) The factor N [ 0 1 1 0 ] appearing in this formula is independent of the weights and can be neglected. In general, such factors depend only on half of the weights (say u 2 , v 2 , ... but not u 1 , v 1 , ...), and cannot generate a non-trivial dependence in the gauge theory parameters that would correspond to ratios of opposite weights (e.g. u 1 /u 2 , or v 1 /v 2 ). Thus, the two tensorF We would like to identify this state with |v 2 , ∅ ⊗|∅ in the module (0, 1) v 2 ⊗(1, 0) u 2 . Unfortunately, this expression seems too complicated for a direct approach, and we will rely on an indirect argument. Our argument follows from the comparison of the states' transformation properties under the action of the DIM algebra. To lighten the notations, the index 2 for the weights will be dropped in this calculation. Taking the coproduct 2.15 of Drinfeld currents in the proper representations, it is possible to show that 10

(4.16)
We recognize here the transformation properties of the coherent state |v, ∅ A constructed in the Fock module in appendix C. In fact, these properties characterize the state uniquely, up to an overall normalization factor. Indeed, the action of a k>0 corresponds in the module (1, 1) u 1 to the action of the positive modes α k . This permits to identify states up to a possible shift of the vacuum state |∅ (i.e. the unique state annihilated by all the modes α k>0 ). This degree of freedom is further fixed by the action of x − 0 , leaving only the possibility of a different norm. Note that this identification also determines the relation between the weights, since which implies u = −γuv as required by the weights conservation relation. 11 On the other hand, the characterization of the state |SI∅ follows indirectly from the covariance property 3.15 ofF (I) S . This property implies that, for any element e ∈ A DIM , As a result, if the state |∅ ⊗ |ṽ, ∅ in the module (−1, 0)ũ × (0, 1)ṽ is annihilated by ∆(e) for some operator e, the state |SI∅ will be annihilated by ∆(S · e). Similarly, if |∅ ⊗ |ṽ, ∅ is an eigenstate of ∆(e), so is the state |SI∅ for ∆(S · e), with the same eigenvalue. Using the characterization of the state |∅ ⊗ |ṽ, ∅ obtained in appendix D.1, it is possible to show that 12 (4.20) Comparing this result with the characterization 4.16 of |v, ∅ ⊗ |∅ , we deduce that the two states coincide, up to their norm. Unfortunately, the determination of the relative norm remains difficult, since the projection is hard to evaluate. Yet, just like the coefficients N , this normalization coefficient can only depend on the weights u 1 , v 1 andũ 1 ,ṽ 1 , and do not produce any dependence on the gauge theory parameters that correspond to u 1 /u 2 and v 1 /v 2 .
Weights The comparison between actions of DIM algebra on the two states provides also the relationship between the weightsũ i = −γ 3/2 v i andṽ i = −γ −3/2 u i . Surprising, it does not coincide with the transformation of the weights for vertical (0, 1) and horizontal (1, 0) representations taken separately, in which case we would havẽ u i = −γv i andṽ i = −γ −1 u i . It is thus essential to consider the S-transformation of the whole tensor product (0, 1) ⊗ (1, 0) to find the proper weight mapping. 13 Note that in both cases, the weights of the representation in the intermediate channel u = −γu i v i becomesũ = −γṽ iũi , in agreement with the S-transformation of module (1, 1) u . Physically speaking, it seems that the presence of the extra branes requires to adjust the position of the branes after rotation with an extra shift of ±( 1 + 2 )/4 in order to observe the invariance of the amplitude. It would be interesting to investigate this phenomenon with more care, for instance by studying the effect of the branes on the graviphoton field responsible for the Omega-background. Eventually, the exact exponent of the factor γ in the weights transformation is not relevant for the gauge theory quantity that depends only on the ratio v 2 /v 1 . Since, according to this transformation, v 2 /v 1 =ũ 2 /ũ 1 =ṽ 1 /ṽ 2 , the v.e.v. of the Lax matrices L (I) and L (SI) do coincide.

Example II: pure U (1) gauge theory
We would like to repeat the previous analysis in the case of the brane-web describing the pure U (1) gauge theory (see figure 4). In fact, this diagram has already been considered from the algebraic point of view by Awata and Kanno in [40]. In their paper, they investigated the invariance of the partition function under the choice of preferred direction. Changing the preferred direction effectively rotates the brane-web, although there is an important difference between their computation and ours: in our case, topological vertices are also rotated, which requires the use of a different intertwiner.
We introduce again a shortcut notation for the Lax matrices L (II) = L 0 1 1 −1 , L (SII) = L −1 0 1 1 and their associated intertwiners Φ (II) = Φ 0 1 1 −1 , Φ (II * ) = Φ * 0 1 1 −1 and Φ (SII) = Φ −1 0 1 1 , Φ (SII * ) = Φ * −1 0 1 1 . The 12 The action of a k follows from the re-expansion of the current ψ + (z), for which the modes act as   On the other hand, the Lax matrix L (SII) is purely horizontal: with the weights satisfying the relationsṽ i = −γ −1ũ iũ i andṽ 1 =ṽ 2 =ṽ. The computation of the v.e.v. follows from the normal-ordering of operators, (4.26) We will show below that the weights transformation implies that q =ũ 1 /(γũ 2 ) = v 2 /(γv 1 ). Thus, the equality between the v.e.v. of the Lax matrices becomes 27) which is indeed the identity arising from the application of S-duality to the U (1) gauge theory. It is derived in [40] using a change of preferred direction, and a proof can be found in [54,57] (see also [58]). is similar, and we will discuss only the first one. The expression of this two-tensor follows from 3.13: 14

Transformation of the vacuum
(4. 28) Unfortunately, its action on the vacuum state remains fairly complicated, (4.29) and we need to employ again an indirect method. Note however that, this time, the coefficient N can be fixed by computing the overlap Hence, we need to compare the action of the DIM algebra on the states |v, ∅ ⊗ |∅ and |SII∅ . The characterization of the first one is easily deduced using the coproduct taken in the appropriate representations: The results obtained for the state |∅ ⊗ |∅ in the appendix D.2 imply It is readily observed that the states are characterized by the same action for the elements x − k and a k (with k > 0) of the DIM algebra. The intertwiner is again invertible and defines an isomorphism between the tensor module (0, 1) v ⊗ (1, −1) u and the module (1, 0) u in the intermediate channel. In this module, states are uniquely characterized by the action of a k and x − k for k > 0, up to a possible normalization factor. Thus, the vacuum state is indeed mapped to the vacuum state underF . Note also that we have dropped the index '2' for the weights to lighten the notations.
5 T -operators and the U (2) self-dual diagram 5

.1 T -operators
In this section, we discuss yet another type of algebraic object, obtained by coupling the intertwiner Φ 1¯ 1 through the legs bearing the representation ( i ,¯ i ) = ( * i ,¯ * i ) with either i = 1 or i = 2. We call this type of objects T -operators in reference to those constructed from linear quiver gauge theories and identified with the Baxter T -operator of an underlying integrable system [17,20]. 15 These operators will be denoted T (i) = Φ · i Φ * where the index i in the product · i refers to the coupling channel.
Since the two representations ( 1 ,¯ 1 ) and ( 2 ,¯ 2 ) now play a different role, the covariance property under the action of the DIM algebra might seem to be lost. Yet, the co-associativity of the coproduct, namely the property (∆ ⊗ 1)∆ = (1 ⊗ ∆)∆, ensures that the operators T (i) obey the following properties: . The same kind of operators can be constructed using the S-dual intertwiners associated to the twisted coproduct. They obey the covariance properties 5.1 with ∆, ∆ replaced by ∆ S , ∆ S , and will be denoted T (i)

S . The relation 3.11 between S-dual and rotated intertwiners extends to T -operators in the form
The main difficulty, working with T -operators instead of Lax matrices, is the lack of a rotation formula like 4.4 relating the rotated T -operators to the original ones by a two-tensor transformation. Yet, we would like to give here an argument to justify the existence of such tensors. In the next subsection, we will provide a concrete example for which the vacuum properties support our proposal. This argument is based on the fact that after, multiplication by a permutation, the T -operators satisfy the covariance property 4.3 of a Lax matrix. As a result, we expect that these permuted objects coincide with a Lax matrix up to a normalization (or anomaly) factor, i.e.
This motivates the introduction of the two-tensorsF (i) andF (i) * , presumably differing fromF andF * only by a permutation and a normalization, and such that We will not use any explicit formula for these tensors, but only their covariance property that should follow from the 15 Actually, this term is slightly abused here, since the underlying integrable system is a chain of length two, with boundary operators applied on each site. Yet, it makes perfect sense for linear quivers of higher rank [20]. ones obeyed byF andF * in 3.15. For instance, in the case of T (1) , we expect that 16 (5.6) These covariance properties are in agreement with the characterization 5.1 of the T -operator T (1) . They imply certain relations between the vacuum and its rotation that will be checked below by direct computation on a specific example.

Example: pure U (2) gauge theory
We would like to treat the T -operator associated to the pure U (2) gauge theory as an example. Including the anomaly factors, this operator is given by where intertwiners are internally coupled through the vertical representation (0, 2) v (see figure 6 left). Since we restricted ourselves to levels ±1 in this paper, we need to decompose the T -operator in terms of four intertwiners instead of two, exploiting in reverse the fusion method developed in [20]. As a result, the operator T is written in terms of four generalized AFS intertwiners following the gluing rules of the brane-web for pure U (2) N = 1 SYM, It turns out that these intertwiners coincide with those employed in the two previous examples, and that we denoted with the shortcut notations Φ (I) , Φ (II) ,... The weights associated to each representation are indicated on the figure 5: each intertwiner Φ i depends on the weights u i , v i and u i constraint by the conservation relation u i = −γu i v i (for i = 1 · · · 4). In addition, the two vertical couplings impose the relations v 1 = v 4 and v 2 = v 3 , and the two horizontal couplings the relations u 1 = u 2 and u 3 = u 4 . Introducing the expressions of intertwiners found previously, and 16 We have used the AnsatzF normal-ordering the vertex operators in the two horizontal channels, the T -operator takes the explicit form 17 10) with v = (v 1 , v 2 ) and λ = (λ 1 , λ 2 ). As already mentionned, the v.e.v. of this operator reproduces the instanton partition function of the gauge theory. The latter depends on the gauge coupling q = u 1 /u 3 and the ratio r = v 2 /v 1 of (exponentiated) Coulomb branch v.e.v., The formula 5.2 relates the S-dual T -operators (associated to the S-twisted coproduct) with the rotated ones. Since the matrices M In addition, horizontal and vertical couplings imposeũ 1 =ũ 4 ,ũ 2 =ũ 3 ,ṽ 1 =ṽ 2 andṽ 3 =ṽ 4 . These coupled intertwiners produce the operator 18 By definition, T S ∝ T (1) −2 0 1 1 , up to a normalization factor. Using the expression of the intertwiners obtained previously, and exploiting the reflection property of the state |Ω ⊗ , this operator writes with ṽ = (ṽ 1 ,ṽ 3 ) (the weightṽ 3 being associated to the second Young diagram λ 2 ). Once again, the v.e.v. reproduces the instanton partition function of the gauge theory, 19 17 We have also used the property a λ a λ 1 a λ 2 = (−γv1) −|λ 2 | (−γv2) −|λ 1 | x∈ λ χx N (λ1, λ2|v1/v2)N (λ2, λ1|v2/v1) . (5.9) 18 Here we have introduced the permutation in order to produce an operator T S : (1, 1)ũ 2 × (−1, 1)ũ 3 → (−1, 1)ũ 1 × (1, 1)ũ 4 in agreement with the brane-web diagram and the covariance property of T -operators. 19 Note that Zvect. ((v1, v2), (λ1, λ2)) = Zvect. ((v2, v1), (λ2, λ1)), and the instanton part is invariant under the replacementr →r −1 . However, the gauge coupling now corresponds toq =ũ 3 /ũ 1 and the ratio of Coulomb branch v.e.v. is given bỹ r =ṽ 1 /ṽ 3 . We will see in the next paragraph that the transformation of weights givesq = q −1 and (presumably) r = qr. The invariance of the U (2) partition function under this replacement of the parameters (q, r) → (q −1 , qr) is called slicing invariance, it is a consequence of the fiber-base duality for the toric diagram [10,59]. From the gauge theory point of view, this invariance follows from the Weyl reflection of the enhanced global E 1 symmetry at the UV fixed point. As we have seen here, it arises in our formalism as the equality between the v.e.v. of T -operators associated to the two coalgebraic structures.
S-transformation of the vacuum In the previous subsection, we have assumed that the rotated T -operator T S can be obtained from T using the two-tensors If so, the equality between the v.e.v. of T -operators can be seen as a consequence of the mapping byF (1) S of the vacuum state |0 = |∅ ⊗ |∅ for T S to the vacuum state for T which turns out to be also |0 , and a similar mapping for the dual vacuum 0| = ∅| ⊗ ∅| underF (1) * S . In order to test this hypothesis, we will compare the action of several DIM algebra elements on the vacuum states and on the transformed states belonging to the modules (1, −1) u 2 ⊗ (1, 1) u 3 and (1, 1) u 1 ⊗ (1, −1) u 4 respectively. The action on the vacuum can be obtained by a direct calculation, it reads On the other hand, the action of these elements on the states 5.18 follows once again from the covariance property of the two-tensors, for e ∈ A DIM . Using the results obtained in appendix D.3, we find the same action on the states |S∅ and S∅| for the modes x ± k>0 and ψ + k (resp. x ± k<0 and ψ − −k ) as in 5.19, provided that we identify the weights as follows: This remarkable agreement between the action of DIM on the different states support the rotation formula for the Toperators. Moreover, the weights identification impliesq = q −1 , which is indeed required for the slicing invariance. Unfortunately this identification is not sufficient to deduce the relation between the two other gauge parameters r andr. However, we expect that the transformation of the module (0, 2) v in the intermediate channel relates the vertical and horizontal weights asũ 1 = γ α v 1 andũ 2 = γ α v 2 for some power α depending on the surrounding branes configuration. This unknown factor would cancel in the ratio r = v 2 /v 1 =ũ 2 /ũ 1 , hence reproducing the relationr = qr.

Gaiotto states
We would like to conclude this study of the U (2) gauge theory with a short remark on Gaitto states. These states were originally defined as Whittaker states for the Virasoro algebra [60][61][62][63], but this definition can be extended to q-Virasoro and q-W m algebras [6,[64][65][66][67]. In fact, they can also be defined in the vertical modules (0, m) of the DIM algebra, seen as a product of q-W m with a q-Heisenberg algebra. Defined in this way, these states coincide with the horizontal v.e.v. of generalized AFS intertwiners [20]. In the case m = 2 relevant to U (2) gauge theories and q-Virasoro algebra, they read As can be seen by comparing with expression 5.8 of the T -operator, the scalar product of two Gaiotto states reproduces the instanton partition function of the underlying gauge theory, i.e. T = G| G . In terms of brane-web diagram, these states can be represented as a cutting of the U (2) diagram in half along a horizontal line, and vacuum states inserted at the endpoint (see figure 7 left). It was shown in [68] that the q-Virasoro Whittaker condition follows from the intertwiners covariance properties under the action of the DIM algebra, that imposes and a similar relation for x + k and G|. Incidentally, this condition also implies the following relations for the S-dual modes y ± k = S · x ± k and b k = S · a k : The 90 • rotation of the brane-web diagrams associated to Gaiotto states are represented on figure 7 (right). In the algebraic language, they define the states |GS ⊗ and ⊗ GS| belonging to the tensor product of two Fock modules (−1, 0), (5.25) Using the known expression for these intertwiners, and the reflection property of the state |Ω ⊗ , we can write these states as where O † λ is the conjugation of the following operator acting on the tensor product of two Fock spaces: The scalar product of these states reproduces the v.e.v. of the rotated Lax matrix, namely T S = ⊗ GS| |GS ⊗ . 20 We would like to compare our rotated Gaiotto states with the states introduced by Kimura and Pestun in their formalism of quiver W-algebra [69,70]. In fact, our problem contains two different q-W 2 algebra. The first one comes from the vertical module (0, 2), it is associated to the two D5-branes in the intermediate channel, and is involved in the q-AGT correspondence [4,6,64]. This is the q-W 2 algebra acting on the genuine Gaiotto states |G and G|. The second q-W 2 algebra comes from the horizontal modules (−1, 1) ⊗ (1, 1) or (−1, 0) ⊗ (−1, 0), it is associated to the two NS5-branes, and acts on the rotated states |GS ⊗ and ⊗ GS|. This is the algebra corresponding to Kimura&Pestun's quiver W-algebra. Indeed, following [15,20], we can rewrite the operators acting on the product of two Fock spaces in terms of the modes The modes β k = ρ ∆(a −k ) describe the Cartan sector of the horizontal representation (−2, 0). By definition, they form a q-Heisenberg subalgebra. On the other hand, the modes s k define the q-Virasoro stress energy 20 To show this fact, we can use the normal-ordering property for operators O † λ : 28) tensor in [71] (with q = q 2 and t = q −1 1 here), they obey the commutation relations Since the modes β k and s k commute, Heisenberg and q-Virasoro components can be decoupled. The operators O λ can be written in terms of the vertex operator S(z) (introduced in [69]) by exploiting the property where the normal ordering of the modes α k naturally extends to s k . We have The Kimura-Pestun construction of the partition function proceeds from another decomposition, namely Z = 0 |Z with In the second line, the ordered product produces the extra factors of G and Z vect. of the first line upon normal ordering, provided we introduce also the proper zero modes in S(z) [69]. Finally, note that since the rotated state |GS ⊗ is constructed upon the modes s k , it is annihilated by the positive modes β k>0 , i.e. by the action of the Cartan modes a −k = S −1 · b −k , which can be seen as part of a S-dual Whittaker condition 5.24.

Perspectives
As we have seen in the three examples treated in this paper, the S-duality relations between N = 1 gauge theories can be understood at the algebraic level in terms of twisted co-algebraic structure. The key ingredient is the equivalence 2.13 between the action of Miki's automorphism, and the replacement of representations ( ,¯ ) → (−¯ , ) that renders the rotation of branes. Despite the lack of a general statement, we were able to show this relation in the cases we needed to treat our three examples. A second important ingredient was the existence of two-tensors that translates the rotation of topological vertices in the language of intertwiners. This rotation map by two-tensors was then naturally extended to Lax matrices, and used to show the equality between their v.e.v. by studying the vacuum transformation. Unfortunately, a similar transformation for T-matrices could only be conjectured, but it was seen to provide the correct vacuum transformation property in the example of pure U (2) gauge theory. In all these examples, the equality between the v.e.v. of operators associated to the two coproducts ∆ and ∆ S reproduced the known Sduality relation for the underlying gauge theory. This is a strong indication that the formalism we introduced here is correct, even though several mathematical development would be required to make it fully rigorous. Eventually, it seems that a general proof of S-duality relations could be achieved by this method.
One of the strength of the algebraic engineering of 5D N = 1 gauge theories is the possibility to extend the results to higher rank gauge groups, and higher rank (linear) quivers, without much effort. This kind of generalization seems also feasible here, but it would require a deeper study of horizontal representations (m, 0) with higher level |m| > 1, supposedly S-dual to vertical representations (0, m). The construction of new intertwiners coupled to these higher representations would also be needed. This is certainly the next natural step for this study. Another important, yet relatively easy, application for our formalism is the treatment of gauge theories with fundamental flavors. In fact, the simplest examples of U (2) gauge theories with such matter fields can already be treated using the intertwiners constructed in this paper.
The application of this method to D-type quivers is a more challenging problem. The algebraic engineering of these gauge theories has been presented in [21], it involves the introduction of reflection states in vertical modules. By the studying the action of Miki's automorphism on these states, one should be able to obtain the algebraic realization of the S-dual theory, a gauge theory with gauge group of type SO. Very interestingly, this approach could solve the longstanding problem of finding a expansion formula for the instanton partition function of these gauge theories with Young diagrams replaced by a more general combinatorial structure [72][73][74].
The S-duality transformation of qq-characters is another interesting open problem. These objects are generating functions of Wilson loops [75], they encode a set of constraints on the partition function called nonperturbative Schwinger-Dyson equations [76][77][78][79][80]. These constraints can be understood in terms of the action of DIM algebra [68,81], and the qq-character obtained by insertion of an algebra element in the v.e.v. of Toperators, i.e. formally χ(z) ∼ (ρ ⊗ ρ ∆(x + (z)))T . It seems natural to expect that this object is transformed into (ρ ⊗ ρ ∆ S (x + (z)))T S under the action of Miki's automorphism. Yet, the proper transformation still remains to be worked out in details. Besides, the S-transformation of Wilson loops obtained in [82] should also be reproduced. We hope to address this issue in the near future.
Very recently, the algebraic engineering has been extended to 4D N = 2 quiver gauge theories in [43]. At first sight, the automorphism S seems to be lost in the degenerate version of DIM algebra used in the 4D case. However, a more involved realization of S-duality might still be found. This is actually suggested by the correspondence observed in [28] between the conformal blocks of the ordinary Virasoro algebra and the d-Virasoro algebra (a.k.a. a degenerate limit of q-Virasoro). Indeed, the former appears in the vertical representation of the degenerate DIM algebra (in the case of U (2) gauge groups), while the former has been identified with the degenerate version of Kimura-Pestun's quiver W-algebra (in the A 1 case) obtained from the horizontal representation. Thus, a relation seems to exist between vertical and horizontal representations of the degenerate DIM algebra, but this problem certainly deserves a deeper study.
Finally, integrable aspects have not been discussed in this paper. Quantum integrable systems are usually built upon a quantum group symmetry algebra, but this construction also applies to quantum toroidal algebra (that are affine quantum groups) [48][49][50]. In this way, it is possible to build a quantum integrable system using one of the universal R-matrices, either R or R S , of the DIM algebra. The presence of Miki's automorphism is a new feature of these integrable models, it should generate some important dualities among such systems. Moreover, the R-matrix is interpreted as a scattering factor in 2D integrable quantum field theories [83], and it would be interesting to develop a similar interpretation for the two-tensor F S associated to Miki's automorphism twist. At a general level, combining S-duality and integrability is an enthralling perspective, and we hope to be able to push forward this discussion in a near future.

A More on Miki's automorphism
This appendix presents a detailed discussion of Miki's automorphism. Specifically, we first derive the transformation of the Drinfeld currents' modes following [23]. Then, we examine the action of these modes in the vertical representation (0, 1), and observe that their action defines a horizontal representation, leading to an equivalence between the two. Finally, we study the action of grading elements, and how they interplay with Miki's automorphism.
The first step is to introduce some notation. We denote by y ± (z) = S · x ± (z) and ξ ± (z) = S · ψ ± (z) the image of the Drinfeld currents under Miki's automorphism. Just like the original currents in 2.6, the S-dual currents can be decomposed in terms of modes with y ± k = S · x ± k , b k = S · a k and ξ ± ±k = S · ψ ± ±k . Note also that, due to the property 2.19, the action of Miki's automorphism on these modes reads S · y ± k = −x ∓ −k , S · b k = −a −k and S · ξ ± ±k = ψ ∓ ∓k . Finally, since S is an automorphism, these new modes satisfy the q-commutation relations of the DIM algebra, and in particular the relations 2.6 that reads here

A.1 Derivation of Miki's transformation
The expression for the S-dual modes y ± k , ξ ± ±k in terms of the original ones can be obtained from the transformation 2.11 of the four modes a ±1 , x ± 0 (and the two central charges c andc) using the algebraic relations 2.6. This construction is based on the observation that the second commutation relation in 2.6 allows us to reconstruct recursively the modes x ± k from x ± 0 : where ad X Y = [X, Y ] denotes the adjoint action, and c 1 , σ 1 are the specialization of the coefficients c k , σ k defined in 2.7 and 2.33 at k = 1. Note that c k /σ k = (γ k − γ −k )/k 2 and κ = σ 2 1 /c 1 . Once the modes x ± k are known, it is possible to find the modes ψ ± ±k using the third relation in 2.6, We will start by deriving the expression of the modes y ± k . Applying Miki's automorphism to the relations A.3, we find: The modes a ±1 can be eliminated using the commutation relation 2.6 once again, and we end up with This is indeed the expression given by Miki in [23]. It is readily observed that the generators y ± k have degrees (d, −d) = (k, ∓1) (for k ∈ Z).
The modes ξ ± ±k can be obtained by applying Miki's automorphism to the relation A.4, using the expressions of the modes y ± k obtained previously (here k > 1), which coincide again with Miki's expressions [23]. The modes ξ ± ±k have degrees (d, −d) = (±k, 0).
Remark An alternative expression for the modes y ± k and ξ ± ±k can be obtained from the Baker-Campbell-Hausdorff formula, Dictionary with Miki's notations In order to compare with the results of Miki [23], it is necessary to translate the notations as follows (from 'Miki'→'Ours'): (A.9)

A.2 Choice of preferred direction
We consider here a vertical representation of levels (0, 1) and examine the action of the dual modes b k , y ± k and ξ ± k . First, we observe that the modes b k form an Heisenberg sub-algebra, (A. 10) In fact, the commutation relations between the modes y ± k and b k reproduce those of the modes x ± k and a k in a horizontal representation (−1, 0). As a consequence, it is possible to express them in terms of the q-oscillator modes α k satisfying 2.33, (A.11) Thus, we have found a hidden horizontal representation inside the vertical one, but it remains to identify the 'horizontal states' in the vertical module. Let's start with the Fock vacuum |∅ , by definition it is annihilated by the positive modes α k>0 , or, equivalently, by the modes ρ . In Miki's relations A.7, these modes are expressed in terms of x − k , and therefore they annihilate the vertical vacuum |v, ∅ . The same argument shows that ρ (0,1) v (y ± −k<0 ) also annihilates the state |v, ∅ , which is consistent with the Fock representation of the currents y ± (z): Indeed, the r.h.s. contains only negative powers of z, which implies that the action of negative modes does vanish. Thus, we can identify the Fock vacuum with the vertical vacuum, up to a normalization factor that will be fixed later.
In order to identify the other states in the Fock space, we consider the S-duality relations 2.11, and more precisely a 1 = −(γ − γ −1 )y − 0 and b 1 = (γ − γ −1 )x + 0 . Comparing the vertical action of these modes, with the action of oscillators in the Macdonald basis, 13) we observe that states can be simply identified as |v, λ ∼ |P λ (since |P λ is defined as the non-degenerate eigenbasis of η + 0 ), and that the horizontal weight is given by u = −γv. The comparison of the actions of b 1 and x + 0 further fixes the normalization factor to one. Generalizing our argument, we establish that the representations (0, ±1) and (∓1, 0) are in fact equivalent, up to a rotation of the generators sending x ± (z), ψ ± (z) to y ± (z), ξ ± (z). Somehow, this choice of the Drinfeld currents can also be seen as a choice of preferred direction for the topological vertex.
In addition, Fock modules also contain a set of coherent states | w, µ A , | w, µ B that will be constructed in appendix C (note that we have labeled these states with the m-tuple Young diagrams µ and the weight vector w here to avoid confusions). For instance, the states | w, µ B are characterized by the relation (A.14) In particular, since ξ − −1 ∝ x − 0 , they are eigenstates of x − 0 in the vertical representation, They can be seen as a sort of Gaiotto states for a vertical module of lower level [68].

A.3 Gradings and uniqueness of Miki's automorphism
It turns out that Miki's automorphism is not unique due to the presence of two other automorphisms. These automorphisms, denoted τ ω andτω, have been defined in 2.9 using the grading operators d andd. Their string theory realization can be understood by examination of their composition with representations. Indeed, comparing 2.10 with the explicit form of vertical/horizontal representations, we realize that the composed representations can be obtained alternatively from a simple shift of the weights: ρ ω ∓n u (up to a rescaling of the q-bosonic modes α k ). Since the weights encode the position of the branes, we deduce that the action of τ ω corresponds to an overall translation along the NS5-direction (thus shifting the D5-positions corresponding to vertical weights). Similarly, the composition withτω leaves vertical representations invariant (up to a rescaling of the states, i.e. a change of basis) ρ We deduce that this automorphism encodes the translation along the D5-direction, shifting NS5-branes positions. Note also that the two automorphisms τ ω andτω commute, as translations should do.
In this subsection, we investigate the interplay between these translations and the rotations of the brane-web realized by Miki's automorphism S. The S-transformation of the gradings follows from the invariance requirement of the commutation relations 2.8 defining their action on Drinfeld currents: (d,d) → (−d, d). As a result, if an element e has gradings (d e ,d e ) under (d,d), then the rotated element has the gradings (d e , −d e ). In fact, we have already observed this behavior for the modes x ± k , ψ ± k and y ± k , ξ ± k above. We also deduce the following properties: We recover here the fact that the translation axis is rotated by S, so that the translationτ ω along the NS5-direction becomes a translation along (minus) the D5-directionτ (S·ω) −1 , and the translation along the D5-direction becomes a translation along the NS5-direction. Note that here we consider a case slightly more general, allowing the shift parameters ω andω to be functions of the central charges (c,c), so that the translation may now depend on the branes charges. This extra freedom is important in order to explore the possibility to twist Miki's automorphism. We define the twisted Miki's automorphism by composition with the grading automorphisms, S ωω = S • τ ω •τω. The requirement that S ωω is of order four imposes a restriction on the parameters ω andω: ω(S 2 · ω) −1 = (S 3 ·ω)(S ·ω) −1 .

B Building blocks of instanton partition functions
We present in this section a short reminder on the various building blocks used to construct instanton partition functions of 5D N = 1 gauge theories. These building blocks are associated to the field content of the theory, with contributions coming from (anti)-fundamental matter fields, Chern-Simons terms, vector gauge multiplets and bifundamental fields: N (v l , λ (l) , µv l , λ (l ) ). (B.1) The last two building blocks are themselves written using the Nekrasov factor with the function S(z) defined in 2.26. In addition, perturbative (one-loop) contributions involve the function G(z) defined for |q 1 |, |q 2 | < 1 as and further (C.12) Note that the action of algebra elements on the states | v, λ A involves operators expanded as series in z −1 (in agreement with the radial ordering that assumes |z| > |χ x |), so that the function in the r.h.s. must also be expanded in inverse powers of z, which justifies the notation [· · · ] + employed. Similarly, the action on the states | v, λ A involves operators expanded as series in z, and the r.h.s. involves [· · · ] − (in agreement with |z −1 | > |χ −1 x |). Dual states can also be introduced, (C.13) they obey the relations 22 A v, λ| ϕ − (γ −1/2 z) = γ −2(n+m) Ψ λ (z) − A v, λ| ,

(C.15)
Note also the remarkable inner product: .

D Vacuum S-transformation
In this appendix, we determine the action on the vacuum of some of the S-dual modes y ± k , ξ ± ±k using Miki's relations A.6 and A.7.

D.1 Example I
First, we introduce a shortcut notation for the following states in the tensor product (−1, 0) ⊗ (0, 1): |0 = |∅ ⊗ |v, ∅ , |1 = α −1 |∅ ⊗ |v, ∅ . (D.1) Expanding the action of the coproduct of DIM generators, we obtain the following characterizations: These properties leads to identify the state |0 with the state |v, ∅ B in the Fock module with representation (−1, 1) u =−γuv (up to a norm). In order to obtain the action of the S-dual modes, we use Miki's relations A.6 and A.7 to show that: 3) The derivation of the first identity is straightforward, but the second one requires some extra explanation in the case of modes with index k > 1. Starting from Miki's formula A.7 and noticing that ∆(x − −1 ) annihilates |0 , we find which gives, using the Baker-Campbell-Hausdorff formula A.8, This shows D.4, and thus the second identity in D.3. Note that in the application to the first example, u and v becomẽ u 2 andṽ 2 .

D.2 Example II
We start again by introducing the shortcut notations: we deduce by expansion that: (k = 0) −uγ −5/2 |1 (k = 1) · · · (k > 1) The action of ξ − −k is more complicated to evaluate. First, we need the action of x − 0 and x − −1 on the state |1 that can be obtained using a similar method as before: Note that the calculation for the mode k = 1 must be performed separately. In the application to the transformation of the Lax matrix in the second example, u and u becomeũ 2 andũ 2 .