Global Symmetries, Counterterms, and Duality in Chern-Simons Matter Theories with Orthogonal Gauge Groups

We study three-dimensional gauge theories based on orthogonal groups. Depending on the global form of the group these theories admit discrete $\theta$-parameters, which control the weights in the sum over topologically distinct gauge bundles. We derive level-rank duality for these topological field theories. Our results may also be viewed as level-rank duality for $SO(N)_{K}$ Chern-Simons theory in the presence of background fields for discrete global symmetries. In particular, we include the required counterterms and analysis of the anomalies. We couple our theories to charged matter and determine how these counterterms are shifted by integrating out massive fermions. By gauging discrete global symmetries we derive new boson-fermion dualities for vector matter, and present the phase diagram of theories with two-index tensor fermions, thus extending previous results for $SO(N)$ to other global forms of the gauge group.


Introduction
In this paper we study various gauge theories with a gauge group based on the Lie algebra so(N ). These include SO(N ), Spin(N ), O(N ), and P in ± (N ) gauge theories. (There are also other such groups that we will not study here; e.g. SO(N )/Z 2 .) Depending on the gauge group the Lagrangians of these theories can include various Chern-Simons couplings and discrete θ-parameters, which can also be viewed as more subtle Chern-Simons terms. We will discuss them and show how they affect the behavior of the theory. We will also couple these gauge theories to bosonic or fermionic matter fields in various representations.
The novelty in our analysis will be the careful attention to the global aspects of the gauge group and the dependence on these discrete θ-parameters. This understanding will lead to a rich spectrum of dualities including level-rank dualities between topological quantum field theories (TQFTs), and various dualities between Chern-Simons-Matter (CSM) theories.
Beyond the intrinsic interest in these theories, there are several motivations for our investigations.
Consider for example the Spin(N ) gauge theory with matter fields in the vector representation. This theory has a Z 2 one-form global symmetry [1,2] associated with the center of the gauge group. This means that we can explore the behavior of Wilson loops in a spinor representation of Spin(N ) and learn about confinement. This has been done in many papers and our discussion here will follow the line of investigation of [1][2][3] in 4d and of [4][5][6] in 3d. Specifically, we will focus on the one-form global symmetry as a clear diagnostic of confinement.
Our second motivation is associated with the role of global symmetries. Consider for example the SO(N ) theories. They have a Z 2 charge conjugation symmetry C and a Z 2 magnetic symmetry M, which we will discuss in detail below. In addition, depending on the matter fields, the Chern-Simons couplings and the value of N they can have time-reversal symmetry and one-form global symmetry. (More subtle phenomena associated with timereversal symmetry will be discussed in [7].) We will couple these global symmetries to background gauge fields and analyze their t' Hooft anomalies, and Chern-Simons counterterms [8,9]. Once these counterterms are understood, it is straightforward to gauge these symmetries, i.e. to promote the background fields to dynamical fields.
Another motivation for studying these theories is the presence of discrete θ-parameters.
It is often the case that the configuration space of a gauge theory breaks into distinct sectors labelled by ν with a well defined partition function in each sector Z ν . The total partition function Z = ν a ν Z ν (1.1) depends on the coefficients a ν . These can be viewed as partition functions of some other theory that couples to our gauge theory. In the special case where all the coefficients a ν are phases, a ν are the partition functions of invertible topological quantum field theories [10]. But we can also have situations where some of the coefficients a ν vanish; i.e. some sectors are absent in the sum. Examples of that were presented in [11,12]. Here we will see more examples of this phenomenon.
As is clear from these points, these systems are concrete examples of the interplay between topology and symmetries. The recent interest in this interplay was formalized in [13,14]. Our systems are an explicit laboratory allowing exploration of these phenomena.
We will start our discussion with a review of known facts about the various groups that we will study, SO(N ), Spin(N ), O(N ), and P in ± (N ). We will also review how gauge theories based on these groups are constructed. We will be particularly interested in three cases.
Spin(N ) gauge theories are special because they do not involve a sum over topological sectors as in (1.1). In the other extreme, O(N ) gauge theories include all the bundles of interest to us. In addition to the regular Chern-Simons level K ∈ Z, these theories are labeled by discrete parameters associated with distinct consistent ways to sum over these bundles as in (1.1). We will denote them as O(N ) r K,L with r = 0, 1 and L = 0, 1, ..., 7. (The label r = 0, 1 was denoted as O(N ) ± in [4].) SO(N ) gauge theories are the ones with the largest (zero-form) discrete symmetry. They have a charge conjugation Z 2 and a magnetic Z 2 symmetries. We will couple them to background gauge fields B C and B M . When these gauge fields are made dynamical the SO(N ) gauge theory becomes the gauge theory of a different group.
We will then turn to a careful analysis of level-rank duality in topological field theories based on Chern-Simons theories of these gauge groups. For unitary gauge groups the levelrank duality relations are [15][16][17][18][19][20] 1 Throughout most of this paper we label TQFTs by the corresponding Chern-Simons gauge group and its level. A quotient as in this expression is interpreted from the 2d RCFT as an extension of the chiral algebra [21] and from the 3d Chern-Simons theory as a quotient of the gauge group [22]. More abstractly, it can be interpreted as gauging a one-form global symmetry of the TQFT [1,2]. This quotient is referred to in the condensed matter literature as "anyon condensation" [23]. Occasionally we will meet a TQFT that is easier to describe not by the Chern-Simons gauge group, but by starting with another TQFT and performing such a quotient by a "magnetic one-form symmetry." Such TQFTs can be described by a Chern-Simons group, but that description is more complicated. We will alert the reader whenever we use this more abstract notation. 2 In some cases a duality of spin TQFTs can be promoted to a related duality of non-spin TQFTs. 3 There are two different conventions for Z n gauge fields. The first is where they are viewed as Z n connections with periods 0, · · · n − 1. The second is where they are viewed as constrained U (1) gauge fields with periods 0, 2π/n, · · · , 2π(n − 1)/n. In general, we use the first convention unless otherwise explicitly indicated.
gauge field constrained to satisfy w 1 = B C . (See more details below.) f [B] is a specific counterterm for a Z 2 gauge field B, which is related to the η invariant of a massive fermion coupled to B. Its coefficient is an integer modulo 8. We will discuss f [B] in detail below. Note that the background fields B C , B M are exchanged under the duality. This reflects the fact that the duality exchanges the global symmetries C ←→ M [26].
The result (1.4) makes the duality relation more complete. It also enables us to derive many other dualities by gauging the Z 2 × Z 2 symmetry (or a subgroup of it); i.e. by making B C , or B M , or B C + B M , or both of them dynamical. For example, we will derive 4 where the additional superscript and subscript of the orthogonal groups are specific terms in the Lagrangian, which we will discuss in detail below. (The integer L ∼ L + 8 is arbitrary.) 5 An important special case that will be used repeatedly throughout the following is N = 1 which yields 6 (Z 2 ) K ←→ Spin(K) −1 . (1.7) The Z 2 level K appearing above is an integer defined modulo eight. (See appendix B for a detailed discussion.) In particular, the theory (Z 2 ) 1 is the (time-reversal of) the Ising TQFT.
Our conventions are such that SO(2) K ∼ = U (1) K and Spin(2) K ∼ = U (1) 4K . Therefore, we find from (1.3) and (1.5) the interesting special cases which simplify for K = 2 to 4 It is straightforward to use our techniques to find many additional dualities, for instance, involving P in ± (N ) gauge groups or O(N ) theories with other levels. The resulting dual theories are more complicated and we will not discuss them here. 5 Note as a particular consequence that the theories O(N ) The special case O(2) 2,1 is equivalent to the T-Pfaffian spin-TQFT [29,30]. See appendix H for details. 6 For O(N ) with N ≤ 2 the level encoded by the superscript does not exist and hence we drop it from our notation throughout [31,32]. Armed with this understanding of the background fields and their counterterms we can reexamine the CSM dualities of [26,33] between bosons and fermions in the vector representation. As in the discussion of dualities of TQFTs above, we couple them to the background fields B C and B M (which means, e.g. that the gauge fields are constrained O(N ) fields).
It is important to clarify the treatment of the fermions. They are coupled to O(N ) gauge fields and integrating over them leads to a phase involving the η-invariant (see below). When the fermions are given positive or negative masses this phase becomes a local functional of the gauge fields, but when the fermions are massless the phase of the functional integral is typically non-local. As is customary, we label the massless theory by the "effective level," which is the average of the integral levels for positive and negative fermion masses. This effective level can be fractional.
Taking into account the above discussion, we fix conventions such that if no bare counterterm is present in the Lagrangian, the theory of N f vector fermions is denoted as (1.10) Note, this does not mean that we have a term with a fractional coefficient in the Lagrangian. Then we can add to this theory additional, properly-quantized, bare Chern-Simons terms for the dynamical and classical gauge fields.
Using these conventions we determine the necessary counterterms in the SO(N ) bosonfermion duality: Here the scalars have a φ 4 interaction and the duality is valid only in the infrared.
In addition to making this duality more precise, we can now make the background fields dynamical; i.e. gauge them, and find new dualities. Some examples are In the above, N f is required to satisfy the following constraint for the duality to describe a transition point [26]: Figure 1: The phase diagram of Spin(N ) gauge theory coupled to fermions in the vector representation. For large |m ψ | the infrared is a topological field theory, which is visible semiclassically. For small |m ψ | the theory spontaneously breaks the flavor symmetry and is described by a sigma model with Grassmannian target. There is a Wess-Zumino term, and stable strings, signaling confinement. The transition from the semiclassical phase to the quantum phase is weakly coupled in the dual bosonic variables (φ or φ). This diagram completes the discussion in [5] by specifying the discrete θ-parameters needed in the various gauge theories, and provides a non-trivial consistency check on that proposal. K > 2. For other values of N f below some theory-dependent number N the dualities are conjectured to be valid near different phase transition points with a symmetry-breaking phase in between [5] (see figure 1).
Some interesting special cases of these dualities are highlighted in section 4.2.1 below. For instance with K = 3 and N f = 1 we can use Spin(3) ∼ = SU (2) to find 13) which was used in [6], with particular interest in N = 1 and N = 2.
Essential to our discussion of the dualities (1.12) is the fact that the discrete θ-parameters can be changed by integrating out massive fermions. For a single Majorana fermion λ coupled to a Z 2 gauge field, the level L for the gauge field is shifted by one as we transition from negative to positive mass. This means that we can describe the massless theory as in the discussion above (1.10) by saying that the effective level is one-half as shown below. (1.14) This is the notation adopted in (1.12) for expressing the second subscript level of O(N ) r K,L , where we view the first Stiefel-Whitney class w 1 as a Z 2 gauge field.
Next we will move to an analysis of the suggested phase diagram of orthogonal gauge groups with fermions in symmetric and anti-symmetric tensor representations [6]. We add to the discussion in [6] the necessary background fields and their counterterms in each phase. This leads to highly non-trivial tests of the proposal. Again a crucial role is played by the shifts in the counterterms generated by integrating out massive fermions. In addition to the shifts described by (1.14), we also find that the C charge of monopole operators in the SO(N ) theory changes when we transition a two-index tensor fermion from negative to positive mass. This also means that in the O(N ) theory, the superscript level (controlling the discrete theta term exp(iπ X w 1 ∪ w 2 )) jumps by one across such a transition.
As in all our other cases, once these counterterms are set we can easily turn the background fields in the SO(N ) phase diagram into dynamical fields and make similar predictions for Spin(N ) and O(N ) gauge theories. It is important that these are not logically independent proposals. They follow from the suggested phase diagram of SO(N ) theories. 7 Therefore, in addition to being interesting in their own right, their consistency also gives further evidence to the original suggestion. An example phase diagram that we find is shown in figure 2.
In section 2 we review some facts about Chern-Simons theory with Lie algebra so(N ). In section 3 and appendix E we derive the level-rank dualities for SO Chern-Simons theories coupled to the gauge fields for the Z 2 symmetries. In section 4 we discuss Chern-Simons matter dualities and the phase diagram of QCD with tensor fermion, and conjecture new Figure 2: The phase diagram of Spin(N ) gauge theory coupled to an adjoint fermion. The infrared TQFTs, together with relevant level-rank duals are shown along the bottom. The blue dots indicate transitions from the semiclassical phase to a quantum phase. Each transition is weakly coupled in a dual theory, which covers part of the phase diagram. The dual theory has symmetric tensor fermions (S and S). Across these transitions the superscript level of the TQFT jumps, i.e. O(N ) 0 and O(N ) 1 are exchanged. The fractional levels represent the effective contributions from the massless fermions. At a special value of the mass in the quantum phase, the ultraviolet theory is supersymmetric. This symmetry is spontaneously broken leading to a massless Goldstino [37]. This phase diagram is obtained from that of the SO(N ) theory proposed in [6], by tracking the global symmetries and counterterms and then gauging.
There are several appendices. In appendix A we summarize some facts about the representation theory of so(N ). In appendix B we discuss the spin topological Z 2 gauge theories and their classification, as well as the generalization to other unitary symmetry groups. In appendix C we give more detail about the relations between P in − (N ), O(N ) 1 and SO(N ) gauge theories. In appendix D we derive the relation between the O(N ) and SO(N ) Chern-Simons actions for odd N . In appendix F we present explicit examples of extended and orbifold chiral algebras. In appendix G we give examples of Wilson lines in Chern-Simons theory that transform in projective representations of the global symmetry. In appendix H we discuss the relationship between O(2) 2,L and Pfaffian theories. In appendix I we present dualities of Chern-Simons theory related to the one-form symmetry.
2 Chern-Simons Theories with Lie Algebra so(N )

Groups, Bundles, and Lagrangians
In this section we review aspects of these Chern-Simons theories. A discussion of the relevant group theory may be found in [38][39][40][41][42], while aspects of their bundles are described in [38,39].

Gauge Groups
The various global forms of the gauge group can be understood starting from SO(N ), the smallest group of interest, and performing extensions by elements of order two. 8 One possible extension is to include reflections, leading to the orthogonal group O(N ). Another extension allows a 2π rotation to act non-trivially thus permitting spinor representations. This leads to the group Spin(N ).
The two extensions may be combined leading to the two groups P in ± (N ). Both groups are simply connected and contain as their identity component the subgroup Spin(N ). The difference between them is whether the reflection r along a single axis squares to the identity or to 2π rotation s: The groups P in ± (N ) may thus be presented explicitly as semidirect products of Spin(N ) 8 For even N one may also consider the group SO(N )/Z 2 , which we do not discuss here.
with cyclic groups generated by r A summary of these extensions is illustrated in the diagram below, where each row and column is exact.
When N is odd, a simultaneous reflection along all axes commutes with SO(N ) and we can further simplify O(N ) ∼ = SO(N ) × Z 2 . The analogous relation for the groups P in ± (N ) is [41] where the signs are correlated in each line above. Note that in contrast to (2.2), the cyclic factors in the products above are generated by reflection along all axes. For N even, there are no analogous simplifications in the groups.
For even N, the reflection that extends SO(N ) to O(N ) may be understood as an outer automorphism of SO(N ), and may be seen from the symmetry of the Dynkin diagram. We refer to this Z 2 symmetry as charge conjugation C. It acts on the representations of SO(N ) by exchanging the Dynkin labels associated with the two permuted nodes. 9 Later, we will see that this outer automorphism gives rise to a global symmetry of the related quantum field theories.

Bundles
Next let us discuss the possible topological types of gauge bundles that exist for the various gauge groups defined above. The topology of the bundles may be parameterized in terms of the Stiefel-Whitney characteristic classes w i ∈ H i (X, Z 2 ), where X is the spacetime threemanifold and i = 1, 2. The allowed classes of bundles for each possible gauge group are indicated in table 1 below [38,39]. Note that the group O(N ) has the largest set of possible gauge bundles, while for other groups the topology of the bundles are restricted. bundles, the classes w i may be defined as follows: • w 1 is a Z 2 gauge field for the subgroup of O(N ) that reflects a single axis. It is the obstruction to restricting the structure group of the bundle to SO(N ).
• w 2 is the obstruction to lifting the structure group of the O(N ) bundle to a P in + (N ) bundle.
When N is odd, the product structure O(N ) ∼ = SO(N ) × Z 2 implies that every O(N ) bundle defines an SO(N ) bundle. The Stiefel-Whitney class w 2 (SO(N )) is the obstruction to lifting this SO(N ) bundle to a Spin(N ) bundle. 10 Using the formula (2.4) one may determine that where we have used the fact that w 1 ∪ w 1 is the obstruction to lifting w 1 to a Z 4 cohomology class. 11 When N is even there is no analogous formula since in that case an O(N ) bundle does not in general define an SO(N ) bundle. For uniformity throughout the following we use the Stiefel-Whitney classes of O(N ) bundles unless otherwise explicitly indicated.

Lagrangians
We now turn to a discussion of the possible Lagrangians for Chern-Simons theories based on the gauge groups discussed above.
In each possible theory there is a continuous field variable A that is a connection valued in the Lie algebra so(N ). We may include in the action a Chern-Simons term CS(A) with 10 Here and below we denote by w i (G) is the i-th Stiefel-Whitney class of a principle bundle with structure group G. 11 A simple way to see the necessity of this condition is to note that for any degree one cohomology classes x, y we have x ∪ y = −y ∪ x. Thus, if x = y this vanishes unless the coefficients are Z 2 . A more detailed discussion may be found in [43,44].
where in the above the trace is defined in the vector representation. Our normalization is such that the level must be quantized in integral units, K ∈ Z. If the level K is odd, then the action (2.6) depends on a choice of spin structure on X. If K is even, no spin structure is required. For any gauge group G, we denote the Chern-Simons theory with level K by G K .
In Chern-Simons gauge theory we perform a path integral over the connection A and the Chern-Simons action exp(iKCS(A)) tells us the weight assigned to each field configuration. In addition we must also sum over the possible topological types of bundles allowed for the gauge groups, and there are choices for how to weight the various bundles in the sum. The additional coupling constants that parameterize the possible weights are sometimes referred to as discrete θ-parameters. As we describe below, they may also be thought of as Chern-Simons interactions for discrete groups.
It is clearest to present the discussion starting from the gauge group O(N ) which admits bundles with all possible Stiefel-Whitney classes. There are two distinct discrete θ-parameters to specify.
• There is a possible weight exp(iπ X w 1 ∪ w 2 ). Since the characteristic classes are Z 2valued this evaluates to ±1 for each possible bundle. 12 We may introduce a Z 2 -valued level p that specifies whether this interaction is present (p = 1) or absent (p = 0). 13 We indicate its value in a superscript O(N ) p .
• Another possible coupling depends only on the characteristic class w 1 . Viewing w 1 as a Z 2 gauge field, the possible additional couplings arise from local effective actions depending on this gauge field. Since we are interested in spin TQFTs we permit these actions to depend on the spin structure of the underlying three-manifold X. Such local actions have been completely determined [45][46][47][48], and admit a Z 8 classification.
We indicate the minimal local action by f [B] where B is any Z 2 gauge field. The properties of these actions are discussed in detail in appendix B. 14 The relationship of these Z 2 gauge theories to the fermion path integrals is crucial in our discussion of Chern-Simons matter duality in section 4.
In general, we indicate the additional level by a subscript valued mod 8 (e.g. (Z 2 ) L ). For Chern-Simons theory with gauge group G we indicate this Z 8 -valued level by a second subscript. 12 In the special case of O(2) this coupling is trivial [32]. We therefore omit the superscript in this case. 13 In [4] our O(N ) 0 was denoted by O(N ) + and our O(N ) 1 was called O(N ) − . 14 The special case 4f [B] has an elementary action π X B ∪ B ∪ B, and represents a bosonic Dijkgraaf-Witten theory [49] for Z 2 gauge group classified by H 3 (BZ 2 , U (1)) = Z 2 .
In summary, our complete list for possible quantum O(N ) Chern-Simons theories and their coupling constants is This classification of discrete levels may be repeated for any gauge group G, and in particular the Z 8 -valued level exists for any group that admits non-vanishing first Stiefel-Whitney class w 1 . Thus for instance, the groups P in ± (N ) may be used to define Chern-Simons: One of our main results will be explicit level-rank dualities for these gauge theories, including the required maps on the discrete θ-parameters.
It is important to stress that the gauge theories we describe here are in general spin topological field theories. That is, they depend explicitly on a choice of spin structure S on the three-manifold X. In particular, all such theories contain a transparent line ψ of spin 1/2.
When K is even and L = 0 (mod 4) the theories O(N ) p K,L may in addition be defined without the choice of spin structure. However, both the level-rank dualities and Chern-Simons matter dualities of interest to us only make sense as spin theories. For instance, the latter involve dynamical fermions where the spin structure is required. We can promote O(N ) p K,L at bosonic values of the levels to a spin theory by tensoring with {1, ψ}: an almost trivial theory containing two transparent lines, the identity and the spinor. In particular, the existence of the line ψ restores the dependence on spin structure. In the following, we use the notation O(N ) p K,L to denote the spin version of the theory (i.e. tensoring with {1, ψ} implicit) unless explicitly indicated. We adopt the same convention for other global forms of the gauge group.

Ordinary Global Symmetries and Counterterms
Let us describe the global symmetries of these gauge theories. There may be ordinary (zero-from) global symmetries, as well as one-form global symmetries and we describe them in turn.
The ordinary global symmetries may be understood by starting with the smallest group SO(N ), which has the largest zero-form symmetry. The symmetries of SO(N ) K depend on the parity of N and K.
If N is even, the Lie algebra so(N ) has an outer automorphism C discussed in section 2.1.1. This defines a charge conjugation symmetry C of SO(N ) K , which acts non-trivially on the lines in the topological field theory. 15 Equivalently, one may view this as acting directly on the SO(N ) connection. Expanding in a standard Lie algebra basis of antisymmetric matrices the transformation is If N is odd, the transformation (2.9) can be achieved by conjugation by an element of SO(N ) and hence does not permute representations. Therefore, for odd N charge conjugation is not a true symmetry of the topological field theory SO(N ) K . Nevertheless, when N is odd we still find it useful to discuss a symmetry C which we will identify with (−1) F where F is the fermion number. As we will see, this identification is natural from the point of view of level-rank duality.
Similarly, for K even we may define a magnetic global symmetry M of SO(N ) K that permutes the lines. Like charge conjugation, the magnetic symmetry is a Z 2 global symmetry. To measure the magnetic charge, one integrates the second Stiefel-Whitney class w 2 of the gauge bundle over a two-cycle.
To understand how M acts on lines in the TQFT, it is convenient to view the theory SO(N ) K as Spin(N ) K /Z 2 where the quotient means that we gauge a Z 2 one-form global symmetry [1,2]. The generating line of this one-form global symmetry gives rise in SO(N ) K to a transparent line transforming in the K-th symmetric traceless power of the vector representation (i.e. Dynkin indices (K, 0, · · · , 0)), which has spin K/2. In the case of K even this transparent line is a boson, and there are pairs of line defects that are related by fusion with the transparent line. Those lines of Spin(N ) K that are fixed points under fusion with the one-form symmetry generator are doubled in the spectrum of SO(N ) K . The two lines in a given doublet are exchanged under the action of the symmetry M [22]. An equivalent point of view on the magnetic symmetry M via chiral algebras is discussed in section 2.5 below.
When K is odd one may similarly define a conserved charge M measured by w 2 . However the associated symmetry acts trivially on lines since pairs related by fusion with the transparent line may be distinguished by their spin. The meaning of this magnetic symmetry is the following. For odd level the theory SO(N ) K depends on the spin structure S. We can probe this dependence by shifting S by a Z 2 gauge field B. Under this transformation the minimally quantized Chern-Simons action responds as [50] CS(A, S + B) = CS(A, S) + π X w 2 ∪ B . (2.10) Thus, for odd level, B may be interpreted as a background gauge field for M. More physically, at odd level the transparent line is a spinor and the magnetic charge is identified with fermion number mod 2.
We summarize the identifications between the charge conjugation and magnetic symmetry in table 2. Depending on N and K there may be additional ordinary global symmetries. For instance, if N and K are even and N K is an odd multiple of 8 there is a Z 2 quantum zero-form symmetry that permutes the anyons [26] defined by fusing the anyons charged under the Z 2 one-form symmetry with the generator of the one-form symmetry. In the following we focus on the symmetries C and M.
In the theory SO(N ) K with even N and K the symmetries C and M both square to one and commute, 16 and hence the zero-form symmetry is Z 2 × Z 2 . We may couple our system to background gauge fields B C and B M for these Z 2 symmetries. Additionally we may add to the action local counterterms for these gauge fields. The possible local counterterms have been determined and admit a Z 8 × Z 8 × Z 4 classification [47]. Each Z 8 factor is the level for the individual gauge fields B C and B M (i.e. if it is gauged one obtains (Z 2 ) L ), while the Z 4 controls a counterterm that depends on both backgrounds. We express the counterterm action as where the parameters enjoy the identification More details on these counterterns are presented in appendix B.
Starting from the case of SO(N ) K we can gauge any of the ordinary global symmetries with specified values of the counterterms. In this way we can produce all the gauge groups discussed in section 2.1 together with specified discrete θ-parameters, as well as other Figure 3: A map of possible gauge groups obtained by starting with SO(N ) and gauging symmetries (Z 2 levels suppressed). In Appendix C we discuss some details of this map.
models. The zero-form symmetries of the resulting theories are the quotient of Z 2 × Z 2 by the subgroup that is made dynamical. We illustrate this in figure 3.
As an illustrative example of this process, consider starting with SO(N ) K and gauging the magnetic symmetry M. This inserts in the action a term π X w 2 ∪ B M , with B M now a dynamical Z 2 gauge field. The resulting sum over B M constrains w 2 to vanish and implies that the gauge group is Spin(N ). If we include the counterterm Lf [B M ] then we construct the theory Spin(N ) K,L defined in (4.34). This corresponds to the choice y +z = L in (2.11).
Analogously, starting from SO(N ) K and gauging either C or the product CM with fixed counterterms produces O(N ) 0 K,L and O(N ) 1 K,L respectively. In the special case where N and K are both odd the identification of global symmetries discussed around table 2 implies that M=C and hence gauging them should produce equivalent field theories. To make this precise, recall that for odd N we have O(N ) ∼ = SO(N )×Z 2 . The relationship between the O(N ) Chern-Simons action (with our choice of charge conjugation (2.9)) and that of the factorized Therefore, for N and K both odd, we have the following equivalence of spin Chern-Simons (2.14) No analogous relationship holds for even N or K.

One-form Global Symmetries
Now let us turn to the one-form global symmetry of these models. A starting point to understanding these symmetries is via the center of the gauge groups shown in table 3 [38,[40][41][42].
Group In general, each element of the center of the gauge group may give rise to a one-form global symmetry. For each Wilson line in a representation R of the gauge group, the charge of the line is the phase defined by the action of the associated element of the center in the representation R. In order for this definition to truly give rise to a global symmetry, it is necessary that there exists a line in the spectrum of the theory that can measure this phase by linking. This is the case in all examples in table 3 except for SO(N ) K and O(N ) K . The line generating the one-form symmetry associated to the center of the gauge group has Dynkin indices (0, · · · , 0, K). If K is odd this representation is a spinorial and excluded from the spectrum. If K is even it generates a Z 2 global symmetry.
For SO(N ) K , and O(N ) K the center symmetry at even level exhausts the one-form global symmetry. However for other gauge groups there may exist additional quantum one-form symmetries that are not manifest at the level of the classical action. Let us first consider the case of vanishing Z 2 discrete θ-parameter and subsequently generalize. A practical way to understand the additional symmetries is as bonus symmetries that arise from gauging ordinary global symmetries.
In general, if we begin with any three-dimensional quantum field theory and gauge a Z r global symmetry, the resulting theory has an emergent Z r one-form global symmetry whose generating line is the Wilson line of the Z r gauge theory. The inverse process also exists. Namely, gauging the emergent Z r one-form global symmetry in the resulting theory produces an emergent zero-form global symmetry generated by the Wilson surface of the Z r two-form gauge theory, and the result is the original theory. 18 We can apply this logic to the gauge groups appearing in figure 3, starting from the one-form symmetry of SO(N ) K . For instance if N and K are even we deduce that and P in ± (N ) K,0 must have quantum Z 2 one-form global symmetries. The exact form of the resulting one-form global symmetry group is either Z 2 × Z 2 or Z 4 depending on the level. Some useful explicit examples are (N even): We can also easily add the Z 2 discrete θ-parameter to the discussion. Instead of viewing the θ-parameter as an added Lf (w 1 ) in the Lagrangian, as we did above, we use (2.15). The theory ( Then if G is any gauge group discussed in section 2.1, we can express the models with discrete θ-parameter as (2. 16) In this expression we deviate from our standard notation of labeling the TQFT by the gauge group of the Chern-Simons theory. Instead, here the quotient means that we gauge a Z 2 one-form global symmetry of the TQFT in the numerator. This Z 2 one-form symmetry is generated by a product of a Wilson line in G K,0 and the electric Wilson line in the (Z 2 ) L factor. The remaining one-form symmetry after gauging is spanned by the subset of Abelian anyons in G K,0 × (Z 2 ) L that are uncharged under the gauged Z 2 , with the identification of lines that differ by fusion with the Z 2 generator. 19 In any theory with one-form global symmetry we may activate background two-form gauge fields. For instance, consider any gauge group that admits bundles with non-trivial w 1 . If we insert a line defect, then the integral of w 1 around a cycle linking the line measures 18 We can also gauge the Z r zero-form symmetry with different counterterms for the Z r gauge field to produce different theories, and each of them has the dual Z r one-form symmetry. Gauging this one-form symmetry takes us back to the original theory. 19 In the case where the generating line of Z 2 has half-integral spin, we do not identify lines that differ by fusion with the one-form symmetry generator since they have different spin and can be distinguished. However, the difference between any two such lines is the transparent spin one-half line. Since the transparent line is local with respect to all lines in the theory, it does not generate a non-trivial one-form global symmetry and thus does not affect the resulting one-form symmetry in the quotient. Further discussion of the spectrum of lines after gauging a one-form symmetry is presented in section 2.5. a one-form charge. We may refine our observables by coupling this global symmetry to background fields by adding to the action π X w 1 ∪ B 2 where B 2 is a Z 2 two-form gauge field.

't Hooft Anomalies of the Global Symmetries
The global symmetries described in the previous sections participate in 't Hooft anomalies. We present the anomalies of SO(N ) K with N and K even; those of other models may be deduced by gauging.
As described in section 2.2, there is a Z 2 × Z 2 global symmetry generated by M and C. These zero-form symmetries do not have any anomalies amongst themselves. Indeed, they may clearly be gauged.
Next consider the possible anomalies involving only one-form symmetries. The generating line of the Z 2 one-form global symmetry has spin N K/16. Since we are considering spin theories, this symmetry may be gauged if the spin is half-integral. Thus in general there is an anomaly, which may be represented by a classical action on a four-manifold Y with boundary X. This action is written in terms of the background two-form gauge field is the Pontryagin square, and we have used the fact that on a spin four-manifold Y , P(B 2 ) is divisible by two.
Finally, let us describe the mixed anomalies between the zero-form and one-form global symmetries. These are encoded in the following four-dimensional action: To derive the formula (2.18), we must consider the one-form symmetry after gauging any of the ordinary global symmetries. For instance, consider gauging M with trivial background B 2 and B C . Since the anomaly action (2.18) vanishes, there is no obstruction to this process. Now suppose that we turn on a background two-form B 2 . In this case (2.18) is generally non-zero if N = 2 (mod 4). This means that the allowed class of background B 2 is restricted.
To deduce the allowed backgrounds, let β : H j (Y, Z 2 ) → H j+1 (Y, Z 2 ) be the Bockstein homomorphism. Then using the fact that β obeys a Leibniz rule we can reexpress the anomaly involving B 2 and B M as Thus the allowed class of two-form backgrounds are those where β(B 2 ) vanishes. The Bockstein map is the obstruction to lifting the class B 2 from a Z 2 gauge field to a Z 4 gauge field. Therefore, we deduce that after gauging B M our topological field theory can naturally couple to a Z 4 two-form gauge field.
We will now show that this Z 4 is the one-form global symmetry after gauging and that the Z 4 two-form gauge field is a background field for this symmetry. When we promote B M to a dynamical field there is an emergent Z 2 one-form global symmetry. This emergent symmetry couples to a background field B 2 by modifying the action to include a term π X B 2 ∪ B M . Let us consider the behavior of the action, including the coupling to B 2 , under gauge transformation of B M . Since B M is now a dynamical field the total action must be invariant under any such transformation, i.e. the anomalous transformation of the action under B M gauge transformations must cancel. This is achieved by imposing the following relation (the symbol δ is the coboundary in cohomology) (2.20) Note that in theories without a mixed anomaly (2.19), we require that B 2 is closed. The modification (2.20) cancels the anomalous variation of the action and ensures that B M can be consistently gauged. Observe also that the left-hand-side of (2.20) is trivial in cohomology ensuring that B 2 may be extended to a class with Z 4 coefficients. Let B 2 be any Z 4 cochain extending B 2 . We construct a Z 4 cocycle by the combination B 2 + 2B 2 , which is closed by (2.20). In particular, the Z 2 emergent one-form symmetry that couples to B 2 is the Z 2 subgroup of this Z 4 . Therefore we conclude that the one-form global symmetry after gauging is extended to Z 4 . 20 This matches with the expected one-form global symmetry. Indeed when the anomaly is non-trivial i.e. N = 2 (mod 4), the one-form symmetry of Spin(N ) K is Z 4 (see table 3).
Similarly, one can deduce the other terms in (2.18) by gauging either C or CM and using the one-form symmetries of O(N ) 0 K,0 , O(N ) 1 K,0 given in (2.15). This interplay between mixed 't Hooft anomalies and extensions of the global symmetry is analogous to the discussion in [51] involving CP symmetry and the one-form symmetry.

Chiral Algebras
The properties of the Chern-Simons theories described in previous sections are also encoded in their associated chiral algebras. We discuss examples in section 3.3 and appendix F.
The most familiar case is that of the simply connected group associated to the algebra so(N ), i.e. Spin(N ) K . In this case the associated chiral algebra is the (enveloping algebra of the) Kac-Moody algebra of currents.
To obtain the chiral algebra of SO(N ) K from that of Spin(N ) K we must extend the chiral algebra [21]. This is the chiral algebra description of gauging a one-form global symmetry in the associated Chern-Simons theory [22]. Let a denote the generator of the one-form global symmetry, and assume that a has integer spin. In the Chern-Simons theory gauging a has the following effects on the spectrum of lines [21][22][23]: • We exclude from the spectrum all lines that carry non-trivial charge under a.
• We identify lines b and a · b that differ by fusion with a.
• Lines b that are stabilized under fusion (i.e. b = a · b) are taken as several distinct lines in the spectrum of the gauged theory.
The associated operation on chiral algebras is extension. The chiral algebra is enlarged to include the current associated to the line a, forcing all allowed modules to be local with respect to these additional currents. The modules of the extended chiral algebra are thus enlarged to include the action of modes of a. Finally, those modules of the original theory, which are stabilized under the action of the a modes may now be assigned a phase under the a action and hence give rise to several distinct modules of the extended chiral algebra.
If a has half-integral spin, we still exclude all lines that carry non-trivial charge under a, but we do not identify b with a · b since their spins differ by a half integer, and hence they are always distinct.
We may apply this general procedure to obtain the chiral algebra of SO(N ) K . The extending representation is the transparent line of spin K/2 in the K-th symmetric traceless power of the vector representation (Dynkin labels (K, 0, · · · , 0)). The magnetic symmetry M acts to exchange the lines that are doubled under this extension.
To obtain the chiral algebras for other gauge groups we can apply the chiral algebra analogue of gauging a zero-form global symmetry. This is an orbifold [22]. The zero-form symmetries C and M act on the SO(N ) K chiral algebra as automorphisms. In particular, for even K the magnetic symmetry M permutes the two distinct modules in each pair b ± satisfying b · a = b. By suitably introducing twisted sectors [52] for either C or

Level-Rank Duality
In this section we derive level-rank dualities for Chern-Simons theories with gauge group based on the Lie algebra so(N ).
One way to phrase our result is to consider SO(N ) K coupled to background Z 2 ×Z 2 gauge fields B C and B M for the global symmetry C and M. The level-rank duality then states how the correlation functions in the presence of background fields are related including the required map on counterterms for these gauge fields. Let us denote by SO(N ) K [B C , B M ], the SO(N ) K topological field theory coupled to background fields. Then, our explicit duality is (3.1) A special case of this result, with K = N = 2 so that both theories are Abelian, was discussed in [27].
Note crucially that under level-rank duality the symmetries C and M (and hence also their background fields) are exchanged [26]. We explain this feature in more detail in section 3.1 below.
Starting from this result we may add any desired counterterms and gauge the global symmetries to obtain a host of other level-rank dualities. Several examples are Note that these are dualities among spin TQFTs, thus keeping with our earlier convention, we add the transparent spin 1/2 line ψ to the spectrum if required. Without this addition the dualities are in general false. Additionally, we observe that the second duality in (3.2) holds for arbitrary L. This is possible since the symmetry CM is mapped to itself under level-rank duality.
We claim that the dualities (3.1) and (3.2) hold for all N and K. In order to make sense of this for either N or K odd, where some of the global symmetries do not act on SO(N ) K we use our general discussion in section 2. In the remainder of this section we prove the dualities (3.2). This also establishes the level-rank duality (3.1) of SO(N ) K coupled to background fields.

Conformal Embeddings and Non-Spin Dualities
Our strategy for deriving the result (3.2) will be to bootstrap our way up starting from the level-rank dualities that arise for non-spin theories, and then subsequently generalize to the spin theories of interest. Thus in this section, unlike others, we discuss non-spin TQFTs and their associated chiral algebras (i.e. we do not tensor with the {1, ψ} sector).
The basic tool is the conformal embedding of non-spin chiral algebras. Consider N K real two-dimensional fermions ζ α a where α = 1, · · · , N and a = 1, · · · K. These generate the current algebra Spin(N K) 1 . By forming singlets out of the a or α indices, we can generate various currents. The first are which generate Kac-Moody algebras for Spin(N ) K , and Spin(K) N respectively. Other objects of interest are: If K is even, Λ (α 1 α 2 ···α K ) has integer dimension and can be used to extend the chiral algebra from can be used to extend the chiral algebra to SO(K) N . (See section 2.5.) Thus we deduce the following conformal embeddings of chiral algebras (see also [24,25]): Note that in the above embeddings, the subalgebras on the left are not in general maximal, i.e. depending on N and K, there may be strictly larger chiral algebras that embed inside Spin(N K) 1 . In particular, the centers on the left and right of (3.5) need not agree.
A related point is that in general there are modules of the subalgebras that do not occur in the decomposition of any module of Spin(N K) 1 . One might attempt to remedy this by quotienting the groups on the left by elements of their center, but in general there is no quotient that imposes the required selection rules. 21 A consequence of this is that in general there is no map between the simple currents on the left and right of the conformal embeddings (3.5). Indeed, since there are more modules of the subalgebra, the simple currents of the subalgebra need not act faithfully on the subset of modules that arise via decomposition of modules of the larger algebra. Similarly, the simple currents of the larger algebra may fail to be local with respect to modules of the subalgebra that do not arise from the decomposition. 22 Although the centers in the conformal embeddings (3.5) are not in general matched, it is crucial for the derivation of level-rank duality that each factor of the subalgebra acts faithfully. Thus, every module of one of the factors occurs in some decomposition of a module of Spin(N K) 1 .
For our application, we aim to gauge some of the zero-form symmetries in (3.5). Thus, we must understand their action in more detail. For concreteness, we focus on the case N and K both even where C and M act as true symmetries of the topological field theory that permute anyons. The required generalizations of level-rank duality for odd N or K are discussed in Appendix E.
Let us explain why C and M are exchanged via level-rank duality. We will do this by direct inspection of the representations of the chiral algebras.
The representations of the group SO(N ) are labelled by Young tableau, Y, built from the vector representation. Such a tableau is specified by a tuple (l 1 , · · · , l N/2 ) of row lengths (see Appendix A for conventions). The l i for i < N/2 are non-negative integers. The final element l N/2 is an integer of either sign accounting for the two chiralities of spinors. 23 When we discuss modules of the chiral algebra SO(N ) K we must take into account the fact that the chiral algebra of SO(N ) K is larger than that of Spin(N ) K (see section 2.5). The extending representation is a current in the K-th symmetric power of the vector representation, which is described by a tableau with (l 1 , l 2 , · · · , l N/2 ) = (K, 0, · · · , 0). This means that as modules of SO(N ) K there is the following spectral flow identification [21,22]: Using this identification we may restrict to those primaries with l 1 ≤ K/2.
We can also explicitly see the primaries of representations that are doubled due to the extension. A representation is fixed under spectral flow if l 1 = K/2 and l N/2 = 0. Each such representation gives rise to two modules of the chiral algebra SO(N ) K . They are permuted by the magnetic symmetry M. The charge conjugation symmetry C is also visible, it simply acts on the final label by l N/2 → −l N/2 . Next let us inspect the modules of the chiral algebra Spin(N K) 1 . Since N K is even, there are four distinct representations: 1, ζ, σ ± . We ask how these modules decompose under the embedded chiral algebra SO(N ) K × SO(K) N . The current generating Spin(N K) 1 is a general bilinear in the fermions ζ. As a representation of SO(N ) × SO(K) it decomposes as: 24 The last two terms in the direct sum above are simply the currents of the embedded chiral algebra identified in (3.3). The first two terms are new primaries that appear in the decomposition of the identity under the subalgebra SO(N ) K × SO(K) N . Notice that these primaries are labelled by pairs of tableaux each with an even number of boxes that are related by transposition. This remains true for all other primaries obtained from this decomposition. Indeed, the current algebra primaries of each of the subalgebra factors do not involve derivatives of the fermions ζ α a and hence are subject to Fermi statistics. This implies that whenever two upper indices α, β are symmetrized, the corresponding lower indices a, b must be anti-symmetrized and vice versa.
Based on this logic, we can readily deduce properties of decompositions of modules of where the subscript on the tableau indicates the parity of the number of boxes. Similarly, we can also deduce properties of the decomposition of the modules σ + and σ − = σ + · ζ. In fact, at least one of them contains the simple current of SO(N ) K or SO(K) N [24,25], and thus the decompositions can be obtained by fusion with the right-hand-sides of (3.8).
The fact that Young tableaux are paired with their transpose in the decomposition of modules of Spin(N K) 1 clarifies the map of global symmetries C ↔ M under level-rank duality. The basic point is simply that if Y is any tableau which is acted on non-trivially by C then M acts non-trivially on Y T . Indeed, C acts on a tableau if l 1 < K/2 and l N/2 = 0. When this is so, the transposed Young tableau has l T 1 = N/2 and l T K/2 = 0. In particular such a representation is stabilized by the spectral flow (3.6) and hence is acted on by M.
We are now equipped to discuss gauging the ordinary global symmetries in the chiral algebra embeddings. Consider the symmetry that acts with C on the first factor and M on the second factor in (3.5). It is achieved by an inner automorphism of Spin(N K) 1 , which acts on the fermions ζ α a by giving some of them periodic boundary conditions on the cylinder (compare to the definition (2.9)) 25 periodic: ζ 1 a , antiperiodic: ζ α>1 a . (3.9) Since we have mapped the symmetries between the two sides of the conformal embedding we can gauge to produce new embeddings. Gauging the symmetry (C, M) is equivalent to an inner-automorphism orbifold of Spin(N K) 1 with the twists (3.9). This leads to the conformal embedding: Therefore we deduce the conformal embedding 26 The embeddings (3.10)-(3.12) allow us to obtain dualities among non-spin Chern-Simons theories. First we have the following equivalences of chiral algebras 27 where on the right-hand side above the chiral algebras are GKO cosets. Here we make use of the fact mentioned above that in the conformal embeddings (3.5) each factor of the subalgebra acts faithfully. Thus every module of the left-hand side of (3.13) is an allowed representation of the coset. In particular this means that the simple currents must match between the left and right of (3.13), since if they did not, some modules would necessarily be forbidden. 25 Recall that when we study the RCFT on a cylinder the representations (3.8) arise in the NS sector where the fermions ζ α a are antiperiodic. 26 The special case K = 2 or N = 2 coincides with (3.10) This uses the fact that M and C are not outer automorphisms of SO(2) K and SO(N ) 2 respectively. 27 The case N = 2 of the first equation was studied in [53].

From (3.13) we obtain the Chern-Simons dualities
where the common one-form symmetries Z and Z are In these equations the Z 2 × Z 2 quotients use the two generators of the one-form symmetry χ and j from each factor in the numerator of (3.14). In the Z 4 case the quotient uses the generator j (with χ = j 2 ) from each factor. 28 The consistency of the quotient depends on the spin of these generators being integral. These spins are the sum of the contributions from each factor in (3.14). (In checking this we use the fact that the spins of χ and j in the first factors are 0 and − N K 16 .) We also require that χ and j have trivial mutual braiding so that there is no anomaly [2].
We stress that these dualities, and the associated chiral algebra isomorphisms can be rigorously proven.

Level-Rank Duality for Spin Chern-Simons Theory
We now promote the non-spin dualities (3.14) to spin dualities and simplify. Thus in this section we restore our convention that all theories are spin TQFTs.
The first step is to use the duality Spin(L) 1 ↔ (Z 2 ) −L discussed in appendix B. This gives When the common one-form symmetry is Z 4 the quotient is generated by a product of the Wilson line j in the continuous factor and the basic magnetic line in each Z 2 factor. When the common one-form symmetry is Z 2 × Z 2 , one Z 2 is generated by a product of the Wilson line j in the continuous factor and the basic magnetic line in each Z 2 factor.
The quotient by this Z 2 may be viewed as a quotient on the gauge group in the numerator of (3.16). However, the second Z 2 is generated by a product of Wilson lines, χ from the continuous group and the electric Wilson line in the two Z 2 groups. The quotient by this Z 2 is not a quotient of the gauge group, but of the TQFT and thus the above deviates from our convention of labeling TQFTs by the Chern-Simons gauge groups. (See the discussion around (2.16).) When j generates a Z 2 one-form symmetry, we have (see Appendix I for proof) where the quotient on (Z 2 ) −N K uses the basic magnetic line. When j generates a Z 4 oneform symmetry (with j 2 = χ) we instead find where (Z 4 ) M is the Abelian Chern-Simons theory (M/4π)udu + (4/2π)udv with U (1) gauge fields u, v, and the quotient on (Z 4 ) −2N K uses the basic magnetic line (i.e. exp(i v)). (Note that the Z 4 level is that defined by the Abelian Chern-Simons theory, which differs by a factor of two from our conventions for the Z 2 level. In order to remind us of this difference we change the fonts, e.g. Z 2 vs. Z 4 ).
We next use the following Abelian Chern-Simons dualities: where the quotient uses the product of the charge two magnetic line in (Z 4 ) 8M and the basic Wilson line in (Z 2 ) 2L . These may be established by changing variables. To prove the first, write where a = a, b = b + a, x = x − y − (L/2)b, y = y. To prove the second line of (3.19), proceed as Consider the first duality in (3.16). We can simplify the right hand side as follows. Suppose L = −K/2 is even, we tensor the first duality in (3.17) with (Z 2 ) 2L and take the Z 2 quotient generated by the product of χ and the basic Wilson line on the left. Using the change of variables (3.19) for the the numerator on the right makes the quotient diagonal and we find the right hand side of (3.16) for the first duality. The left hand side is thus Similarly for odd L = −K/2 we tensor the first duality in (3.18) with (Z 2 ) 2L and take the Z 2 quotient generated by the product of χ and the basic Wilson line on the left. Using the change of variables (3.19) for the numerator on the right makes the quotient diagonal and we find the right hand side of (3.16) for the first duality. The left hand side is again Therefore we prove that for all even N, K (rearranging (Z 2 ) 2L ),

Consistency Checks
In this section we present a few simple consistency checks of the level-rank dualities stated in equation (3.2). In appendix F we also discuss various low-rank examples of chiral algebras involved in the dualities. in Spin(K) N is the spinor of Dynkin label (0, · · · , 0, 1). We will compute their dimensions and demonstrate that they agree.
The conformal dimension of the twist operator σ of O(N ) 0 K can be computed as follows. Denote the Kac-Moody current by J µν , the C symmetry changes the sign of J 1i with i = 2, · · · N . We evaluate the one-point function of the Sugawara stress tensor in the presence of the twist operator by expanding J 1i in half-integral modes: where we used the central term in the current commutator Kmδ m+m ,0 , thus for integral modes it vanishes after summing over positive and negative integers, while for half-integral modes it gives a non-trivial contribution. Since T (z)σ(0)|0 ∼ hσ(0)σ(0) z 2 |0 + · · · this determines the conformal weight of the twist operator σ to be (N −1)K 16(N +K−2) . The same result was obtained in [54].
Using the fact that the spinor of Spin(K) −1 has spin −K/16 we see that . (3.26) This agrees with the spin of the spinor representation of Spin(K) −N , which can be computed from the Casimir (see e.g. [55] and appendix A). Therefore we find the lines have the same spin as expected from the duality.

Counting the Lines
As another consistency check, we count the number of lines in each theory and show that they match in the level-rank dualities stated in equation (3.2). We take even N, K > 2.
The number of lines in Spin(N ) K with even N, K is the number of non-negative integral solutions for the affine Dynkin labels λ 0 +λ 1 +λN 2 −1 +λN 2 +2 N/2−2 i=2 λ i = K where λ 0 is the label for the extended node in the affine Dynkin diagram. The tensor representations have Dynkin labels λ N/2−1 , λ N/2 both even or both odd, otherwise the representation is spinorial.
The number of tensor and spinor representations are given by As discussed in section 2.5, the chiral algebra of SO(N ) K is the chiral algebra of Spin(N ) K extended by the representation of Dynkin label (K, 0, · · · , 0). The spinor representations are projected out and the tensor representations are identified with each other or doubled. For even N, K the number of lines is The chiral algebra O(N ) 0 K,0 for even N, K can be obtained from SO(N ) K by an orbifold with the symmetry C, which acts on the Dynkin labels as λ N/2−1 ↔ λ N/2 . The number of untwisted and twisted primaries in the chiral algebra of O(N ) 0 K can be derived by [52]: The chiral algebra O(N ) 1 K,0 for even N, K can be obtained from SO(N ) K by orbifold with the symmetry CM, which acts as λ N/2−1 ↔ λ N/2 , and permutes the two primaries in every doubled representations. The number of untwisted and twisted primaries in the chiral algebra of O(N ) 1 K,0 can be derived by [52]: Using the above formulas, one can verify that the number of lines match in the dualities Note that for even K and as spin theories, O(N ) 0 K,K (or O(N ) 1 K,K ) has the same number of lines as O(N ) 0 K,0 (or O(N ) 1 K,0 ). Meanwhile for odd K , the number of untwisted primaries is doubled by the presence of the lines 1, χ of Spin(K ) −1 , but the number of twisted primaries remains the same. In particular in the last two dualities of (3.31) the number of primaries matches for the untwisted/twisted sectors respectively in the dual chiral algebras.

Chern-Simons Matter Duality
In this section we derive new Chern-Simons matter dualities. We extend the previously conjectured dualities in [26,33] by coupling them to background fields for the global symmetries. Gauging the global symmetries we find new dualities. We similarly extend the phase diagrams of [6].

Fermion Path Integrals and Counterterms
In order to utilize level-rank dualities in the context of Chern-Simons matter theories, we must understand how the counterterms we have studied in the previous sections may be generated by integrating out massive degrees of freedom. For a review of many of the elements described below see [56].
We first consider a real (Majorana) fermion λ coupled to an SO(N ) gauge field A and transforming in representation R. Since R is real, λ may be given an SO(N ) invariant mass m. The phase of the fermion partition function depends on the sign of m. We fix conventions such that the phase is 29 In particular, in the massless theory we take the phase to be the average between these, that is exp iπ 4 η(A) . In these formulas, η(A) is the eta-invariant defined by a regularized sum of eigenvalues of the Dirac operator. 30 The APS index theorem [57] relates the eta invariant to the minimally quantized spin Chern-Simons action CS(A) as well as a gravitational Chern-Simons term CS grav .
In the above c R is the quadratic Casimir of the representation R, and the gravitational 29 Note that these conventions imply a choice of scheme for the Fermion path integral. A different choice of scheme would shift the Chern-Simons level for both positive and negative mass by an integer k. The invariant scheme independent statement is that the difference between positive and negative mass is a level c R Chern-Simons term. 30 For instance using zeta function regularization we have: η(A) = lim s→0 k sign(α k )|α k | −s , where α k are the eigenvalues of the Dirac operator coupled to A.

Chern-Simons terms is defined by
where Y is a four-manifold with boundary X and R is the curvature two-form. In practice we will use formula (4.2) for vectors and two index tensors for which: Note that the partition function of the massive fermion (of either sign of m) defines a local effective action of the gauge field A. By contrast the massless fermion gives a non-local phase. In general, when describing the level of a Chern-Simons matter theory, we follow the convention that the theory is labelled by an effective level, which is the average of the level at m > 0 and m < 0.
Similar analysis applies to the case of complex fermions. For instance, a massive complex fermion of charge q coupled to a U (1) gauge field gives a contribution to the effective level of k m>0 − k m<0 = q 2 . (4.5) As in the case of real fermions, one typically labels the massless theory by the effective level, which receives a contribution q 2 /2 from such a fermion. Now let us extend our discussion to a single real Majorana fermion λ coupled to a Z 2 gauge field B. Again we fix conventions such that for negative mass the phase of the partition function is trivial, whereas for positive mass it is non-trivial and defined by the eta invariant. In particular, the massless theory has phase exp iπ 4 η(B) . The analog of the APS index theorem is [57] exp Here f [B] is the basic Z 2 action discussed in section 2.1 and Appendix B. We again label theories by an effective level, which includes the bare coupling (an integer mod 8) as well as a fraction arising from fermions that are odd under the Z 2 symmetry. With these conventions, (4.6) implies that integrating out a massive fermion shifts the Z 2 level by sign(m)/2 One simple way to check (4.6) is to consider two Majorana fermions, which we combine into a single complex fermion. If both fermions are odd under the Z 2 , the effective action for m > 0 is simply the square of (4.6). Thus, neglecting gravitational counterterms, the phase of the partition function for positive mass is exp (2if [B]). Since the level is even, we can represent this effective action by Abelian Chern-Simons theory following (B.4) and compare to (4.5). We see that, for positive mass, a charge q complex fermion yields (Z 2 ) 2q 2 . This is the expected answer since, when q is even, 2q 2 = 0 (mod) 8 and hence trivial for a Z 2 gauge field, while if q is odd 2q 2 = 2 (mod) 8.
In the following applications we will be interested in how the levels for the Z 2 × Z 2 global symmetry defined by C and M are changed by integrating out massive degrees of freedom. We define the action of charge conjugation to be compatible with the action (2.9) on gauge fields. In particular, C acting on a field (either scalar or fermion) reflects the first index in a vector representation, and acts trivially on other indices: (4.7) Let x R indicate the number of components of an SO(N ) representation that are charged under C. For the representations of interest to us: We take a parameterization of the counterterms in the presence of massless fields to be Upon activating a mass m for a fermion in representation R these counterterms shift. Since the magnetic symmetry M is non-perturbative and all level shifts are one-loop exact, the coefficients y and z above are unmodified. The total effect is therefore (x, y, z) −→ x + sign(m)x R 2 , y, z . (4.10) To further apply our results to theories with more general tensor matter, it is necessary to investigate the properties of monopole operators in more detail. In particular we will argue that the charge of a monopole operator V under the charge conjugation symmetry C may be changed by transition through a point where a fermion becomes massless.
We first consider the theory of SO(2) K+1/2 ∼ = U (1) K+1/2 coupled to a single complex fermion ψ of charge one. Since the Chern-Simons level jumps by one between positive and negative fermion mass, the gauge charge of the bare classical monopole differs by one as well. Thus, if V represents the gauge invariant monopole operator for negative mass, the operator for positive mass must be dressed by an additional fermion. Therefore, the monopole operator for positive mass is V ψ.
This analysis carries over straightforwardly to SO(N ) K coupled to fermions in the vector representation. The only essential difference is that in this case, the monopole charge is only conserved mod 2. Across a vector fermion transition, the M charge is unchanged, the electric charge is shifted, and the gauge invariant monopole acquires an additional fermion across the transition.
If we now consider SO(N ) Chern-Simons theory coupled to a fermion ψ [i,j] transforming in the adjoint representation we find additional effects. We examine a GNO monopole embedded in the SO(2) subgroup of SO(N ) which rotates the two-plane spanned by the last two indices. We refer to this operator as V [N,N −1] . Note that this is the minimally charged monopole. Across a massless transition for ψ [i,j] , the electric charge of V [N,N −1] is changed by N − 2. Therefore across the transition the gauge invariant monopole operator jumps as (4.11) Notice also that depending on N and K there may in fact be no gauge invariant monopole operator in the spectrum. Specifically, when N is even and K − c R 2 is odd the monopole operator is odd under the center of SO(N ) and this charge cannot be screened by any other fields in the model. Meanwhile, for N odd, or K − c R 2 even, there is a gauge invariant local monopole operator.
Assuming that a gauge invariant monopole operator exists, let us now act on it with the charge conjugation symmetry C. As in (2.9) we take the operator C to act as a minus sign on the index 1. From (4.11) we therefore see that the C charge of the monopole operator differs for m ψ < 0 and m ψ > 0. An identical analysis applies to the case of ψ (i,j) in a symmetric traceless tensor representation.
We can phrase this result in terms of the discrete θ-parameters of the section 2.1. Consider the SO(N ) gauge theory in the presence of a background C gauge field B C . The monopole charge is measured by the second Stiefel-Whitney class w 2 . The fact that the monopole charge differs across a tensor transition means that the positive and negative mass theories differ by the coupling π X w 2 ∪ B C . This means that the theory with vanishing m ψ can be described imprecisely by saying that the coupling is ±1/2. This coupling is shifted when a tensor field is given a mass by sign(m ψ )/2, so that it is properly quantized after the massive fermions have been integrated out. This effect described above is even more dramatic in the O(N ) gauge theory, where B C = w 1 is dynamical. In that case the different integral values of the coupling π X w 2 ∪ w 1 label the theories O(N ) 0 and O(N ) 1 . Thus we see that these two gauge theories are related through a transition of a massless tensor fermion. We denote the theory at the origin by O(N ) ±1/2 . In particular this implies that O(N ) Chern-Simons theory coupled to an odd number of fermions in a two index tensor representation has a parity anomaly.
One immediate application of this analysis is that we can rephrase the discussion in [26] about the relationship between the non-supersymmetric Chern-Simons matter dualities reviewed in section 4.2 and the supersymmetric N = 2 dualities described in [4]. As discussed in section 3, level-rank duality of SO(N ) K exchanges the Z 2 symmetries C and M. This map of symmetries also holds in the boson-fermion dualities for SO(N ) K coupled to vector matter. By contrast, in N = 2 supersymmetric theories there are also symmetries C susy and M susy however under the duality the map of symmetries is instead To explain the difference in the symmetry map under duality, note that the N = 2 theory has a pair of gauginos transforming in the adjoint representation under SO(N ). The nonsupersymmetric duality can be obtained from the supersymmetric one by giving mass to these gauginos and flowing to the infrared. Therefore, according to the discussion above, the supersymmetric theory differs from the non-supersymmetric theory by the coupling π X w 2 ∪ B C . In particular, this means that the symmetries of the supersymmetric and non-supersymmetric theories are related as In fact, the superymmetric theory, defined by the massless gauginos, has effective coupling π X w 2 ∪ B C . If the gauginos are given mass (of either sign) the coefficient of this term shifts to become trivial. But at the massless point it still has non-trivial effects on the C charges of monopole operators.

Dualities with Fundamental Matter
We can apply our refined understanding of level-rank duality of orthogonal gauge theories to obtain dualities of Chern-Simons theories coupled to vector matter.
Let us recall briefly the dualities described in [26]. They concern SO(N ) Chern-Simons theories coupled to real scalars (φ) or Majorana fermions (ψ) in vector representations. Explicitly the duality is (4.14) where in the above, the scalars are subject to a quartic potential and both theories are tuned to flow to a transition point in the infrared.
Level-rank duality provides an essential consistency check on (4.14). Indeed, the obvious mass terms in the UV description of the theories flow to relevant operators at the fixed point that may be used to give mass to any of the scalar or fermi fields. In particular, if we gap all the matter fields we find level-rank dual topological field theories.
We can also turn this logic around, and use the consistency of the duality (4.14) to provide a check on our result (3.1) for level-rank duality coupled to background fields.
Consider the theory with scalars, now coupled to background Z 2 gauge fields B C and B M for the charge conjugation and magnetic symmetry. As is common, the validity of the duality (4.14) in the presence of background fields may require us to add counterterms for these gauge fields [8,9]. Without loss of generality, we couple the fermionic theory to background gauge fields without counterterms. Then, the bosonic theory as a function of background fields is (4.15) Here, the coefficients α, β, γ parameterize our ignorance. We could use (3.1) to fix them. Instead, we will constrain them by demanding consistency of the duality (4.14) in the presence of background fields.
Note that the parameters α, β, γ are part of the ultraviolet definition of the theory, and cannot depend on symmetry breaking patterns, i.e. they depend only on N and K. If we now give negative mass squared to L scalars and positive mass squared to N f − L we arrive in the infrared at the topological field theory (4.16) On the fermion side of the duality, we can give positive mass to L of the vectors and negative mass to N f − L. The gauge group is unmodified, but the Chern-Simons level is shifted according the discussion in 4.1. Using (4.10) we find (4.17) We now demand that (4.16) and (4.17) are dual for all L. From this we determine:  From this we conclude that (4.20) for some N and K independent integers p and q. This matches our general result (3.1) for level-rank duality, provided we fix p = q = 1.

Dualities for Spin(N ) and O(N )
Now that we have fixed the exact counterterms required for the duality (4.14) to hold in the presence of background fields, we can immediately derive new results. Gauging C, M, and CM produces three new dualities: 31 Note that as a special case when there is no matter (N f = 0), the above reduce to the level-rank dualities of section 3.
Some special cases of these are worth mentioning. For K = 1 we find where in the second and last dualities the fermions are odd under the Z 2 gauge field. The first duality gives infinitely many scalar theories that describe the same N f free Majorana fermions with the decoupled (Z 2 ) 0 , which is time-reversal invariant (similar dualities appeared in [26,33]). The theories on the right-hand-side of the second and third dualities are also essentially free. Specifically, they are free fermions coupled to a discrete gauge theory, which reduces the local operators to the Z 2 invariant sector. Comparing the second duality with the last duality for L = −1 also gives infinite many boson/boson dualities which describe the same fixed point as that of (Z 2 ) −N +N f /2 coupled to N f ψ. 31 For odd N the group O(N ) is a product Z 2 ×SO(N ) and therefore its representation theory is factorized. In particular there is a vector representation of SO(N ) that is even under the Z 2 factor as well as one that is odd under the Z 2 factor. Our dualities hold for the representation that is odd under the Z 2 factor. Similarly, for N = 1 we find (4.24) where in the first and last dualities the scalars are odd under the Z 2 gauge field. The second duality gives infinitely many fermionic theories that describe the same N f real Wilson-Fisher scalars with the decoupled (Z 2 ) 0 . Comparing the first duality with the last duality for L = 1 also gives infinite many fermion/fermion dualities which describe the same fixed point as that of (Z 2 ) K coupled to N f φ.
where the fermion in the first duality has charge 2. These dualities are valid only for N f < N [26]. For other values the dualities are still valid but with a more subtle interpretation [5][6][7].
Comparing the second duality with the last duality for L = −1 gives the boson/boson duality Similarly, for N = 2 we find where the scalar in the second duality has charge 2. Comparing the first duality with the last duality for L = 1 gives the fermion/fermion duality 29) which describes the same theory as O(2) −K,−K with N f φ.
If we specialize to N = K = 2 and N f = 1 they become where the matter in the U (1) theories has charge 2. They can be summarized into Here we also deviate from our standard notation and the quotient is not of the gauge group, but denotes a gauging of the one-form global symmetry. Specifically, the quotient uses the Wilson line of (Z 2 ) −2 .

Phase Diagram of Adjoint QCD
As a final application of our level-rank duality result (3.1), we consider the phase diagram of orthogonal gauge theories coupled to fermionic matter in a two-index tensor representation discussed in [6]. We focus on the case of small Chern-Simons level, i.e. the range: The problem is to determine the infrared behavior of these theories as a function of the mass m of the fermionic matter. A complete solution to this problem was conjectured in [6] and we review it below.
There are two obvious phases where |m| is large and the fermions may be integrated out semi-classically. These are gapped TQFTs described by SO(N ) Chern-Simons theory with level depending on the sign of the mass.
As |m| is reduced, a new quantum phase appears. This quantum phase is also gapped and described by an SO Chern-Simons theory but with a different gauge group and value of the level.
The passage from a semiclassical phase to the quantum phase proceeds through a tran-sition that is weakly coupled in dual variables. The dual theory also has a two-index tensor fermion. However, this tensor has the opposite symmetry to the original matter defining the model. Thus, in the adjoint theory, the transition from the semiclassical to quantum phase is governed by a symmetric tensor transition, while in the theory with symmetric matter it is governed by an adjoint transition.
As we dial further into the quantum regime, we find that the adjoint theory becomes N = 1 supersymmetric at a special value of the bare mass. Based on index calculations in [37], it is expected that this theory spontaneously breaks supersymmetry and therefore in addition to the TQFT we also find a massless goldstino. In the symmetric tensor theory, no such effect occurs.
These phase diagrams are illustrated in figure 4. As is evident from the explicit levels shown there, level-rank duality is crucial for the consistency of the full picture.
We can use our improved understanding of level-rank duality in the presence of background gauge fields to provide a new consistency check of this conjectured picture. As we have discussed in section 3, level-rank duality shifts the values of the Z 2 × Z 2 counterterms. Additionally the various tensor matter transitions change the counterterms as well as shift the X w 2 ∪ B C counterterm as discussed in section 4.1. The fact that all these discrete counterterms close on a consistent picture is a striking test of the validity of this phase diagram.
One way to present the information encoded by the counterterm consistency described above is to promote some of the background fields to be dynamical and hence obtain the phase diagram for another gauge group. We illustrate the results for the Spin(N ) and O(N ) theories in figures 5, 6, and 7 below.
In these figures it is convenient to introduce a notation analogous to the Z 2 level for theories with gauge group Spin(N ): (4.34) The first expression is defined in terms of a Chern-Simons theory based on the group . The third expression uses the duality (1.7). Here the Z 2 quotient is not simply a quotient of the gauge group in the numerator. It is given by gauging the diagonal one-form symmetry of the Z 2 subgroup in the center of Spin(N ), whose quotient results in SO(N ), and the Z 2 one-form symmetry generated by the Wilson line of (Z 2 ) L . Note that this quotient exists for all L. An example of an allowed line in this quotient is the product of a spinor in Spin(N ) and an 't Hooft line in (Z 2 ) L . For L = 0 the theory Spin(N ) K,0 is the same as the standard Spin(N ) K Chern-Simons theory.
( , ) Figure 4: The phase diagrams of SO(N ) gauge theory coupled tensor fermions. The infrared TQFTs, together with relevant level-rank duals are shown along the bottom. The blue dots indicate the transitions from the semiclassical phase to the quantum phase. This proceeds through a tensor transition described by a dual theory, which covers part of the phase diagram. At a special value of the mass in the quantum phase of the adjoint theory, a massless goldstino appears. These figures are identical to those in [6] except that we now add the map of the Z 2 × Z 2 global symmetry.

A Representation Theory of so(N )
The Young tableaux is defined from Dynkin labels λ i by non-increasing row lengths l i , i = 1, · · · , n where n is the rank.
so(2n + 1) : The number of boxes is r = n i=1 l i . Note for so(2n) the last row length comes with a sign while other row lengths are non-negative.
Tensor representations are defined by even λ n for so(2n + 1) and even (λ n − λ n−1 ) for so(2n), which correspond to Young tableaux with integral row lengths. Otherwise they are spinor representations (we also refer to them as spinorial representations).

B Z 2 Topological Gauge Theory in Three Dimensions
In this section we describe Z 2 classical gauge theories in three spacetime dimensions. We are interested in theories that depend on the spin structure of the underlying three-manifold X. These are also known as fermionic symmetry protected topological phases (SPT) with Z 2 unitary symmetry. Such theories have been completely determined [45][46][47][48], and admit a Z 8 classification.
A practical way to produce these local actions is via SO(L) 1 spin Chern-Simons theory. Since these theories depend on the spin structure, they can couple to a Z 2 gauge field B by shifting the spin structure with the background B. Equivalently, from the relation (2.10) they couple to B by the magnetic symmetry M, and we define the action f L [B] via the normalized partition function Although we have defined the action by a functional integral, it is known that the result is local since SO(L) 1 is an invertible field theory [10].
There are two significant properties that are useful in manipulating these counterterms. First, the index L behaves as a level (i.e. f L [B] is linear in L). This follows from the simple duality We use this linearity to simplify notation and write is the minimal non-trivial action.
A second useful property is that for even level L = 2n the action 2nf [B] is simply related to Abelian Chern-Simons theory. Explicitly 32 where in the above, the U (1) field a is dynamical and enforces the constraint that B is a Z 2 gauge field [58,59]. (For a discussion of these theories see also [1,27].) Note that n = 1 above is the minimal allowed level in U (1) [49] for Z 2 gauge group classified by H 3 (BZ 2 , U (1)) = Z 2 . They are independent of the spin structure. The particular case L = 4 has the action π X B ∪ B ∪ B.
If we promote the Z 2 background gauge field B to be a dynamical field b we have We will denote the left hand side by (Z 2 ) L (with L = 0 mod 4 defined to be bosonic). It is a spin TQFT for L = 0 mod 4. In particular, (Z 2 ) L for odd L has anyons that obey the fusion rule of the Ising TQFT with spins 0, 1 2 , − L 16 mod 1, tensored with {1, ψ} where ψ is the transparent spin one-half line. The Wilson line of (Z 2 ) L corresponds to the product of the line in the vector representation of Spin(L) and ψ, and it has integral spin. The basic magnetic line of (Z 2 ) L corresponds to the line in the fundamental spinor representation of Spin(L) and it has spin − L 16 . (Z 2 ) L has zero framing anomaly. The chiral algebra corresponding to (Z 2 ) L can be read off from (B.6) (also from (B.4) for even L).
This construction of SPT phases may be generalized to any discrete group G that contains a Z 2 subgroup. Consider a G bundle on X. A gauge field γ may be viewed as a map to the classifying space γ : X → BG. For every choice ρ ∈ H 1 (BG, Z 2 ), we then obtain a Z 2 gauge field γ * ρ ∈ H 1 (X, Z 2 ). Consider where as before Z(SO(L) 1 )[B] with B ∈ H 1 (X, Z 2 ) is the partition function of SO(L) 1 coupled to B by the magnetic symmetry M (equivalently it couples via shifting the spin structure by B and using (2.10)). f [γ * ρ] is a local topological action of the classical G gauge theory. For discrete symmetry G it can be expressed as the Arf invariant of the symmetry defects [46,48]. Other descriptions include [60,61] and the references there.
We can use the above construction, together with fermionic SPT phases that can be produced from Abelian Chern-Simons actions to produce a complete list of the fermionic SPT phases for Z 2n unitary symmetry. We will reproduce the classifications in [45] and [47] obtained from different methods.
All fermionic SPT phases for Z 2n unitary symmetry can be expressed as follows (denote the background gauge field by B ∈ H 1 (X, Z 2n )) where in the above a is a dynamical field that constrains the U (1) field B to be a Z 2n gauge field.
The change of variables u → u + N +1 2 B − y, z → x + N B , y → y − N B produces the identification K ∼ K + N . For even N there is no such identification. 34 In this section, as throughout the paper, w i (G) refers to the Stiefel-Whitney classes of a principle bundle with structure group G.
We can gauge the Z 2 symmetries by promoting the gauge fields to be dynamical. In this way we produce figure 3. We can also gauge the one-form symmetry in the P in + (N ) theory. We will focus on oneform symmetries dual to the gauged C, M symmetries. Denote their background two-form Z 2 gauge fields by B 2 , B 2 , they couple to the P in + (N ) theory by where B C , B M are dynamical. As in the discussion below (C.2), the presence of the dynamical fields B C and B M means that the bundles are P in + (N ) bundles with non-trivial Stiefel-Whitney classes.
• We can gauge both Z 2 one-form symmetries by promoting both B 2 , B 2 to be dynamical. This imposes B C = B M = 0 and we recover the SO(N ) gauge theory. We view the Stiefel-Whitney class w 1 as a Z 2 gauge field for the charge conjugation C of SO(N ). These discrete couplings depend on how the Z 2 is embedded in O(N ). For even N there is no natural choice, and our convention is specified by (2.9). If we change our convention and define C to flip the signs of more indices, the Z 2 levels are modified. Formulas for the change in the action can be derived following the logic below.
When N is odd, the orthogonal group factorizes O(N ) = SO(N ) × Z 2 , and thus every O(N ) bundle is separately an SO(N ) bundle and a Z 2 bundle. One natural choice of Z 2 subgroup is this Z 2 factor, which commutes with SO(N ). However, to be uniform with our treatment of even N we continue to use the convention (2.9), which corresponds to a Z 2 that is embedded non-trivially in each factor of SO(N ) × Z 2 .
Let us derive the relation between the Lagrangians for these two choices of Z 2 subgroup. Explicitly the formula we would like to prove is: where on the left the Z 2 with gauge field w 1 is non-trivially embedded in SO(N ) × Z 2 as defined by the charge conjugation (2.9), but on the right it is factorized from SO(N ).
To derive (D.1) observe that the charge conjugation transformation (2.9) can be expressed as e πJ where J is the element of the Lie algebra Therefore the dynamical O(N ) gauge field may be expressed as a sum of an SO(N ) gauge field together with a Z 2 gauge field B C which also sources J For practical manipulations it is useful to view B C as a U (1) gauge field constrained to Z 2 by a Lagrange multiplier field.
We now evaluate the Chern-Simons action (2.6). To evaluate the terms involving the field B C it suffices to consider the case where the SO(N ) gauge field is of the form Evaluating the O(N ) Chern-Simons action on (D.3) we then find (below B C is normalized to have periods 0 and π): We recognize the sum over fluxes 2π is the expression for the Stiefel-Whitney class w 2 (SO(N )). Meanwhile, using the relationship between Abelian Chern-Simons theory and

E Derivation of Level-Rank Duality for Odd N or K
In this appendix we derive the counterterm in (3.1) when N or K is odd. As in section 3, we derive this result, by proving the spin Chern-Simons dualities (3.23)-(3.24) for N or K odd: We will use various formulas from section 2.2 for the Chern-Simons action of SO(N ) K with odd N coupled to the backgrounds B C , B M for the symmetries C, M. The Chern-Simons action can be expressed as From (E.2) we can obtain the O(N ) 0 K,0 theory by promoting B C to be dynamical with Similarly, we can obtain the O(N ) 1 K theory by promoting B C = B M to be dynamical 35

E.1 Even N and odd K
We start with the conformal embedding with N K real fermions where in the above the relation between the centers of the left and right chiral algebras is subject to the same discussion as that following (3.5).
Consider gauging (C, M) on the left hand side (and an outer automorphism equivalent K,0 it is Z 2 × Z 2 for odd N and even K, while Z 2 for odd N and K. In O(N ) 1 K,0 it is Z 2 for odd N and even K, Z 2 × Z 2 for odd K and N = 1 mod 4, and Z 4 for odd K and N = 3 mod 4.
to C on the right). C transforms the currents of Spin(N ) K by changing the sign of J 1i with i = 2, · · · , N . To be compatible with the transformation the N K indices are partitioned into K and N K as in section 3.1. Therefore we obtain the conformal embedding The conformal embedding implies the duality of chiral algebras where we again use the fact that each factor in the subalgebra in (E.6) acts faithfully. (See the discussion around (3.13).) This implies the non-spin Chern-Simons duality We denote the generators of the Z 2 × Z 2 simple currents on the left-hand side by χ, j C . They have spin of 1 2 and 0 respectively. Gauging the Z 2 one-form symmetry generated by χ results in the theory O(N ) 0 K , while gauging the Z 2 one-form symmetry generated by j C results in the theory Spin(N ) K . On the right-hand side χ maps to (1, 1, χ) and j C maps to (1, χ, χ). (See also footnote 28.) Taking the Z 2 quotient in (E.8) generated by χ on the left and (1, 1, χ) on the right produces the spin duality which implies the spin Chern-Simons duality O(N ) 0 K,0 ↔ Spin(K) −N,−K . By adding a (Z 2 ) K theory on both sides and gauging a one-form symmetry as in appendix I, the above implies (E.10) For the special case K = 1 the spin duality (E.9) reproduces O(N ) 0 1,0 ↔ Spin(1) 1 with Spin(1) N ≡ (Z 2 ) 0 for even N .
Consider next the Z 2 quotient in (E.8), which on the left brings P in + (N ) K to Spin(N ) K , and on the right it is generated by (1, χ, χ). We find Comparing the right-hand side with (E.3), which defines the O(K) Chern-Simons theory for odd K, gives the spin Chern-Simons duality Similarly consider the Z 2 quotient in (E.8), which on the left brings P in + (N ) K to O(N ) 1 K , and on the right it is generated by (1, χ, 1) : Comparing with (E.4) gives the spin Chern-Simons duality (E.14)

E.2 Odd N, K
We start from the conformal embedding for odd N, K Each factor of the subalgebra above acts faithfully and thus we obtain the following duality of chiral algebras The corresponding non-spin Chern-Simons duality is Promoting to spin theories and comparing the right-hand side with (E.3) gives the spin Chern-Simons duality Note also that since N and K are both odd we also have the duality (2.14). Combining with the above, this implies Taking the Z 2 quotient in (E.17) generated by χ of Spin(N ) K , Spin(K) −N gives Comparing with (E.4) produces the spin Chern-Simons duality Therefore for N or K odd we establish the same dualities (E.1), and (3.1) follows.

F Low Rank Chiral Algebras and Level-Rank Duality
In this appendix we present some details of familiar chiral algebras and their relation to level-rank duality.

F.1 Chiral Algebras Related to so(2)
Let us describe the chiral algebras related to the Lie algebra so(2). 36 We consider We start with P in + (2) k,0 , its chiral algebra is the charge conjugation orbifold of Spin(2) k = U (1) 4k that takes charge Q to −Q mod 4k. This chiral algebra was constructed in [52]. The spectrum is built from U (1) 4k as: • the identity in U (1) 4k is split into the invariant part 1 and j = i∂φ. They have conformal dimensions 0,1.
• the original primary of charge 2k splits into a symmetric part φ 1 2k and an antisymmetric part φ 2 2k . They have conformal dimensions k/2.
• the twisted sectors of the original identity and primary of charge 2k. Denote them by σ 1 , σ 2 of conformal dimension 1 16 and τ 1 , τ 2 of conformal dimension 9 16 .
The fusion rules can be obtained from the modular S matrix (see [52]). In particular there are Z 2 × Z 2 simple currents 1, j, φ 1 2k , φ 2 2k . They have conformal weights 0, 1, k/2, k/2 respectively. These currents are the Abelian anyons generating the one-form global symmetry. In particular by extending the chiral algebra by these currents we can obtain the other algebras in (F.1).
• Extending the chiral algebra P in + (2) k by j. From the modular S matrix we find that σ a , τ a are projected out, and from the fusion rules we find that φ 1 2k , φ 2 2k are identified. Thus the resulting chiral algebra is U (1) 4k = Spin(2) k .
• Extending the chiral algebras P in + (2) k by φ 1 2k . From the modular S matrix we find that σ 2 , τ 2 and φ q with odd q are projected out.

F.2 Chiral Algebras Related to so(4)
Next we discuss chiral algebras related to so(4). The simplest is Spin(4) k which is simply the product SU (2) k × SU (2) k .
The Moore-Read Pfaffian theory [63] can be expressed as the spin Chern-Simons theory [27] SU (2) 2 × U (1) −4 × U (1) 8 where the first Z 2 quotient acts on SU (2) 2 × U (1) −4 and the second quotient acts on U (1) −4 × U (1) 8 . To simplify the quotients we can use the duality U (1) −4 × U (1) 8 ↔ U (1) 4 × U (1) −8 (which can be proven by a change of variables as in [27]). In the new variables, the first Z 2 quotient acts diagonally on SU (2)  The theory O(2) 2,1 is equivalent to the T-Pfaffian theory [29,30], which can be expressed as U (1)  We can couple the theories O(2) 2,1 , O(2) 2,5 to a background U (1) gauge field A and investigate the mixed anomaly between the U (1) and the time-reversal symmetries. The O(2) Chern-Simons theory does not have U (1) magnetic symmetry, but it can couple to U (1) symmetry using its one-form symmetry. 39 Both O(2) 2,1 and O(2) 2,5 have Z 4 one-form symmetry, and the generating line has spin   38 In fact, from the spins of lines one can conclude that O(2) 2,L for other integers L = 1 mod 4 are not time-reversal invariant. 39 This is an example of coupling a TQFT to an ordinary global symmetry using the Abelian anyons as in [14] for discrete symmetries. Here we couple O(2) 2,L to the continuous U (1) symmetry that does not permute anyons. The O(2) 2,L theory also has an intrinsic Z 2 magnetic symmetry that permutes anyons (it is not the Z 2 subgroup of the U (1) symmetry).
where the bulk terms ± 8 4π B 2 B 2 are equivalent on a closed four-manifold as expected from the anomaly matching for the dualities. By substituting the value for the background B 2 = 1 4 dA we find the mixed anomaly 1 8π dAdA between the time-reversal symmetry and the U (1) symmetry. 40 This is the same parity anomaly as that of one massless Dirac fermion. The lines can carry fractional U (1) charges determined by their charges under the one-form symmetry.

I Duality Via One-form Symmetry
Consider a TQFT T with an Abelian anyon a of spin L/(2N ) mod 1 that generates a Z N one-form symmetry (we assume N L is even for simplicity). 41 Then we can prove the following duality 42 x with even and odd L respectively. (Note that L is defined mod 2N .) To prove (I.1) denote the Z N two-form gauge field of the gauged one-form symmetry on the right by B 2 and couple it to (Z N ) 0 and (Z N ) N for even and odd L as Even L : Odd L :  (1.5). When N = 2 mod 4 they have one-form symmetry with non-trivial 't Hooft anomaly. 41 For example, T can be the Chern-Simons theory with gauge algebra so(N ), with the one-form symmetry discussed in section 2. 42 Notice the intentional change of font below. The theory (Z 2 ) L is not the same as the theory (Z N ) L when N = 2. They are related by (B.4) (i.e. (Z 2 ) L ↔ (Z 2 ) 2L ).
Odd L : B 2 → B 2 − dλ, x → x + λ, y → y − L + 1 2 λ . (I. 3) In (I.2) the last terms B 2 B 2 can be ignored, since they will be cancelled by the 't Hooft anomaly of the Z N one-form symmetry in T . In this step, we use the fact that the 't Hooft anomaly of a one-form symmetry is given by the self-braiding of the generating line [1,2,64].
To simplify (I.2) we can perform the one-form gauge transformation with λ = −x, which change the gauge fields (B 2 , x, y) to (B 2 + dx, 0, y + Lx/2) for even L and (B 2 + dx, 0, y + (L + 1)x/2) for odd L. Then (I.2) becomes X N (B 2 + dx) y/(2π) where y = y + Lx/2 for even L and y = y + (L + 1)x/2 for odd L. Integrating out y constrains B 2 to be a trivial two-form Z N gauge field and removes the quotient. Therefore the theory on the right of (I.1) is the original theory T .
A simple example illustrating the duality (I.1) is the relationship between the SU (N ) Chern-Simons theory, and U (N ) Chern-Simons theory coupled to a U (1) multiplier that constrains the U (N ) gauge field [1,20]. Consider SU (N ) K × (Z N ) N K with the Lagrangian K 4π Tr bdb where b is an SU (N ) gauge field, and x, y are U (1) gauge fields. For simplicity we will take K to be even. Next we perform a Z N quotient such that b, x are not properly quantized but the U (N ) gauge field u = b + 1 N x is well-defined. The Lagrangian in the new variables is K 4π Tr udu + 2 3 u 3 + 1 2π (Tr u)dy , (I.5) which is the U (N ) K,K Chern-Simons action constrained by a U (1) multiplier y, and we recognize it as the SU (N ) K Chern-Simons action [20]. Thus we find that for even K, where the quotient on (Z N ) N K leads to selection rule on Wilson line of x but not for y, namely it is generated by exp(i y + iK x). For even K we can use (Z N ) N K ∼ = (Z N ) 0 by the redefinition y → y − K 2 x, then the quotient on (Z N ) 0 is generated by the line exp(i y + i K 2 x). This agrees with the duality (I.1), where the generating line of the Z N one-form symmetry in SU (N ) K has spin −K/(2N ) and thus L = −K.