Matrix ensembles with global symmetries and 't Hooft anomalies from 2d gauge theory

The Hilbert space of a quantum system with internal global symmetry $G$ decomposes into sectors labelled by irreducible representations of $G$. If the system is chaotic, the energies in each sector should separately resemble ordinary random matrix theory. We show that such"sector-wise"random matrix ensembles arise as the boundary dual of two-dimensional gravity with a $G$ gauge field in the bulk. Within each sector, the eigenvalue density is enhanced by a nontrivial factor of the dimension of the representation, and the ground state energy is determined by the quadratic Casimir. We study the consequences of 't Hooft anomalies in the matrix ensembles, which are incorporated by adding specific topological terms to the gauge theory action. The effect is to introduce projective representations into the decomposition of the Hilbert space. Finally, we consider ensembles with $G$ symmetry and time reversal symmetry, and analyze a simple case of a mixed anomaly between time reversal and an internal $\mathbb{Z}_2$ symmetry.


Introduction
Two-dimensional quantum gravity arises in several different physical contexts. It serves as the simplest toy model of higher-dimensional quantum gravity, as the worldsheet description of the first-quantized string, and also as an approximation to the dynamics in the throats of higher-dimensional near-extremal black holes. The most successful approach to these models exploits an old idea [1,2] which sought to model the integral over random surfaces as a continuum limit of random triangulations [3][4][5][6][7]. This relationship between double-scaled matrix integrals and 2d gravity has been studied extensively, and appears to provide a quantitative definition of the simplest universality classes of two-dimensional quantum gravity [8][9][10].
The purpose of this paper is to show how to incorporate global symmetries in this correspondence between 2d gravity and matrix integrals. In order to do so, we include dynamical gauge fields in the bulk gravity theory. One motivation for this is as a warmup for discussing higher dimensional gravity theories (which would include dynamical gauge fields in a reduction to 2d), or gravity theories with higher supersymmetry. Another motivation is to explore the effect of 't Hooft anomalies in random matrix theory. Finally, we expect that aspects of this setup (although not the exact connection to random matrix theory) will be relevant for the bulk description of SYK-like theories with global symmetry [28][29][30][31][32][33][34][35].
We will now summarize the paper.
In section two, we give a definition of random matrix theory including some global symmetry group G that commutes with the random matrix (which we think of as a Hamiltonian). The Hilbert space breaks apart into different representations of G, and essentially, one can define separate random Hamiltonians acting in these subspaces. More precisely, we study correlation functions in the matrix ensemble of xTr e´β 1 H . . . Tr e´β nH y c where H is the full Hamiltonian, including G symmetry. Each of the partition functions can be decomposed into a sum of traces over subspaces corresponding to particular representations, Tr Hr pe´β H q, with correlations xTr Hr 1 pe´β 1 H q . . . Tr Hr n pe´β nH qy c " δ r 1 ,...,rn dimpr 1 q n xTr e´β 1 H pr 1 q . . . Tr e´β nH pr 1 q y c .
Here H pr i q is the Hamiltonian acting on the different copies of the representation r i . It is drawn from an ordinary random matrix ensemble without global symmetry. The expectation value on the RHS has a "genus" expansion, with coefficients determined by the loop equations [36,37] of random matrix theory.
In section three we discuss the bulk gauge theory that will be added in order to reproduce the random matrix correlations of the form (1). The partition functions of Yang-Mills and BF gauge theories on general Riemann surfaces were computed in [38][39][40][41][42][43][44]. We focus on the case of topological (BF-type) gauge theories, which are insensitive to local fluctuations of the geometry. This means that for each topology, the partition function of an arbitrary 2d gravity theory coupled to the gauge theory factorizes into the partition function of the gravity theory itself, times a partition function in the BF Figure 1: A cartoon of the geometry that computes Z g pβ 1 , r 1 ; . . . ; β n , r n q. There is a genus g surface glued to n "trumpets" associated to the insertions of Tr Hr pe´β H q on the RMT side. The boundary conditions at the ends of the trumpets are determined by β and r.
gauge theory.
To compare to the random matrix observables (1), we need to study the combined gravity theory on a space with n boundaries, with particular boundary conditions related to the values of tβ i u and the representations tr i u. To match the results at a given order g in the "genus" expansion of the matrix integral, we study the gravity theory on a space of genus g. As we show using [38][39][40][41][42][43][44], the BF gauge theory partition function on this space with the appropriate boundary conditions is Z gauge g pβ 1 , r 1 ; . . . ; β n , r n q " δ r 1 ,...,rn pdimpr 1 qq nˆv olpGq dimpr 1 q˙2 g`n´2 n ź j"1 e´β j c 2 pr 1 q{2 .
To get the full partition function, we multiply this by the partition function of the original 2d gravity theory without gauge fields.
In section four, we show that (1) and (2) are compatible with each other, and that (2) indicates a particular relationship between the random matrix theories that describe each subspace. In particular, the sector labelled by the irreducible representation r has a density of states proportional to pdimprqq 2 . One factor of dimprq arises from the obvious spectral degeneracy due to the G symmetry of the system. However, the second factor of dimprq implies that the ranks of the random matrices in the fixed representation sectors are proportional to dimprq as well. A possible explanation of the second factor of dimprq is that the Hilbert space carries the action of a second copy of G that commutes with the first G-symmetry but does not commute with the Hamiltonian. 1 We also find that the ground state energy in each sector is proportional to the quadratic Casimir c 2 prq. This result is clearly model dependent, but does reproduce the dependence of the ground state energy on the charge in the complex SYK model [35].
In section five, we discuss a generalization of this calculation, which immediately suggests itself in the gauge theory language but is rarely considered in the random matrix literature. This is to consider the effect of 't Hooft anomalies in the global symmetry G on the random matrix ensemble. In the gauge theory formulation, this is achieved by including particular discrete topological terms in the bulk action. The resulting partition functions are still calculable, and can be expressed in terms of restricted classes of projective representations of the group G. We find that the dual matrix integral again factors into distinct sectors, each now corresponding to a genuinely projective representation of G. These results dovetail nicely with recent discussions in the QFT literature [46][47][48] and are relevant for the complex SYK model, which exhibits a mixed anomaly between the global U p1q symmetry and charge conjugation when the number of Dirac fermions is odd [30,49].
In section six, as a final variant, we also consider matrix ensembles with a G symmetry and time-reversal invariance. In the bulk, this corresponds to summing over non-orientable surfaces. In the case without any 't Hooft anomalies, we find that the dual matrix integral is GOE or GSE like for self-conjugate representations of G, and contains degenerate pairs of GUE blocks for pairs pr, rq with r ‰ r. We also study an example with a mixed anomaly between an internal Z 2 symmetry and time reversal, and find two degenerate GUE-like sectors that are exchanged by the time reversal symmetry, even though both the irreps of Z 2 are self-conjugate. The interpretation is that, in the presence of the anomaly, the time-reversal operation and the Z 2 operator anti -commute, rather than commute.
In section seven we conclude, and in appendix A we give a detailed computation of some BF theory path integrals that are used in the main text. In appendix B we discuss the details of the U p1q case as an illustrative example, and in appendix C we discus the case where the bulk gravity theory is the JT model, where simpler computations with standard Yang-Mills theory are possible.
Note added: After our analysis of the anomaly-free case was completed, we learned of the paper [50] which has partial overlap with our section 3 and gives an interesting interpretation of the partition functions in terms of matrices whose entries are functions on the group. In the final stages of our project, we also learned of the paper [51] which has overlap with a special case of our results for the partition functions of P SU pN q gauge theories with 't Hooft anomaly.

Expectations from random matrix theory
In the original application of random matrix theory to physics, one views the random matrix as a model for a quantum Hamiltonian H, and one defines an ensemble that is "as random as possible" given the symmetries of H. For example, without imposing any symmetries at all, a good notion of "as random as possible" is to integrate over all Hermitian matrices where dH is a flat measure on the L 2 independent real components of an LˆL Hermitian matrix, and V pHq is a "potential" function that determines the leading distribution of the eigenvalues, generalizing Wigner's semicircle.
In random matrix theory, the most important symmetry is the antiunitary time-reversal symmetry. The presence or absence of this symmetry changes the random matrix ensemble in a fundamental way. For example, if the Hamiltonian commutes with a time reversal symmetry T satisfying T 2 " 1, then one can choose a basis in which T " K, where K is simply the complex conjugation operator. T-symmetry then implies that the components of H are real, and the relevant notion of "as random as possible" replaces the integral dH over components of a Hermitian matrix with an integral dH over the independent components of a real symmetric matrix. This turns out to change the random matrix integral in rather important ways.
Ordinary unitary symmetries play a less fundamental role than time-reversal. The reason is that there is a somewhat trivial modification of "as random as possible" that incorporates unitary symmetries. To explain this, let G be a group of unitary symmetries that commutes with H. Then the Hilbert space on which H acts decomposes into a direct sum of subspaces corresponding to irreducible representations of G: Each H r consists of the states that transform under the symmetry G in representation r. Such states can be further grouped into multiplets of dimension dimprq that transform among themselves under the action of G. So we can choose a basis for the states of the full Hilbert space as |r, a; iy, where r labels the representation, a P t1, . . . , dimprqu labels the state within a given multiplet, and i labels the different multiplets. The G symmetry of the Hamiltonian H implies that xr, a; i|H|r 1 , a 1 ; i 1 y " δ r,r 1 δ a,a 1 H prq ii 1 .
However, G symmetry gives no constraints at all on the matrix H prq . One can therefore define a maximally random matrix ensemble with G symmetry by taking the H prq matrices for each representation r to be independent random matrices.
To state this more precisely, we will have to introduce some notation, starting with the case with no G symmetry. In this paper, we will focus on aspects of the random matrix H that depend only on its eigenvalues λ 1 , . . . , λ L . A convenient observable of this type is the "thermal partition function" Below, we will leave the dependence on the eigenvalues tλu implicit and use the simpler notation Zpβq. We will also denote expectation values in the matrix integral (3) using the notation x¨y. An interesting set of observables are the connected correlation functions (or cumulants) of a product of n partition functions. A basic fact in random matrix theory is that such observables have an asymptotic 1{L expansion of the form The summation variable g is referred to as the "genus" and in general it takes both integer and halfinteger values. In the simplest hermitian matrix integral, it takes only integer values. The coefficient functions Z g pβ 1 . . . β n q give the 1{L expansion of the matrix integral, and they can be computed efficiently using a set of equations known as the "loop equations." 2 There are two pieces of input data to the loop equations, and these two pieces of data specify what we mean by a matrix integral. The first piece is a discrete choice of symmetry class, in particular whether there is a time-reversal symmetry and if so whether T 2 "`1 or´1. This piece of data determines what we mean by dH in (3). The second piece of data is the potential V pHq. In practice, it is more convenient to give an equivalent piece of data, which is the leading large L approximation to the density of eigenvalues: One can solve for ρ 0 pxq in terms of the potential and vice versa. In the simplest ("one cut") matrix integrals, ρ 0 pxq is supported in a single interval of the real axis. Note that ρ 0 pxq is normalized so that its integral is one. The leading approximation to the total density of eigenvalues has an extra factor of L: ρ total 0 pxq " Lρ 0 pxq.
Given these two pieces of data (the symmetry class and ρ 0 pxq), a universal recursion relation that follows from the loop equations determines all of the Z g pβ 1 . . . β n q coefficients [37].
The types of matrix integrals that are related to 2d gravity are not quite of the form (3). Instead, they are "double-scaled" matrix integrals. Formally, these are integrals in which the interval of support of the leading distribution of eigenvalues is the half-line x ě x 0 , and we relax the requirement of normalizability of ρ 0 pxq. More precisely, they can be obtained as limits of ordinary matrix integrals, where we take L Ñ 8 and adjust the potential V pHq in such a way that pointwise where ρ 0 pxq is supported on the half-line x ě x 0 , and is not normalized. The parameter e S 0 is the leftover parameter, which plays a role analogous to L in ordinary matrix integrals. In particular, the double-scaling procedure commutes with the loop equations, but the expansion becomes a series in e S 0 rather than L: An important fact for this paper follows from the form of this expansion. If we take a double-scaled random matrix theory and rescale ρ 0 pxq Ñ λρ 0 pxq, then the expansion coefficients will transform as To see this, note that both rescalings can be accomplished by shifting S 0 Ñ S 0`l og λ.
To state this more precisely, it is helpful to define a thermal partition function restricted to a given representation sector Zpβ, rq :" Tr Hr e´β H " dimprq Tr e´β H prq .
The trace in the final expression is over the i index in (6) that labels the different multiplets within the subspace H r . Independence of the H prq matrices corresponding to different sectors implies a "diagonal" property in the representation label, xZpβ 1 , r 1 q . . . Zpβ n , r n qy c " δ r 1 ,...,rn dimpr 1 q n xTr e´β 1 H pr 1 q . . . Tr e´β nH pr 1 q y c .
One can then define a random matrix ensemble in the presence of G symmetry by saying that the expectation value on the RHS is an expectation value in an ordinary random matrix ensemble with no G symmetry, as defined previously. In particular, associated to each sector r will be a function ρ prq 0 pxq that characterizes the leading density of eigenvalues of the matrix H prq . The expectation value on the RHS will then have a genus expansion with coefficients determined by ρ prq 0 pxq and the loop equations.
In the next two sections, we will show how the structure in (15) arises in 2d gravity once we incorporate a bulk version of G symmetry.

Gauge theory partition functions
We would like to start with a 2d gravity theory that is dual to (or at least approximated by) a random matrix ensemble without G symmetry, and somehow modify it to make it dual to a random matrix ensemble with G symmetry. For example, we can start with the correspondence between JT gravity and a particular double-scaled matrix integral. This can be viewed as a type of disorder-averaged AdS/CFT correspondence. In AdS/CFT duality generally, the presence of a global symmetry in the boundary theory means that the bulk theory should have a gauge symmetry. So, at least tentatively, in order to describe a random matrix ensemble with G symmetry, we should include a dynamical G gauge theory in the bulk.
We will choose the bulk action to be that of the simplest 2d gauge theory, which is the topological BF theory. Boundary terms and boundary conditions will be discussed in section 3.2. The fields in this theory consist of a gauge field A with field strength F " dA`A^A, and an adjoint-valued scalar field B. The action on a closed 2d manifold Σ is The integral over the field B is a Lagrange multiplier that imposes F " 0, so the path integral localizes to an integral over flat connections. In general, there is a moduli space of such connections, and the path integral computes the volume of this space, with respect to a measure that we will describe in more detail below.

Path integral on a closed surface
The path integral can be computed efficiently by decomposing the surface into three-holed spheres, as explained in [43]. 3 A three-holed sphere is a space with the topology of a sphere with three disks removed. To compute the path integral on such a space, we need boundary conditions for each of the S 1 boundaries. A convenient choice is to fix the holonomy U " P expp´ş γ Aq around each circle. Under a gauge transformation that acts nontrivially at the boundary, the holonomy transforms by conjugation, so gauge invariance implies that the path integral with fixed holonomy will be a "class function," meaning a function of U that is conjugation-invariant. On the three-holed sphere, the path integral of the BF theory is a class function of the three holonomies where the subscript indicates genus zero.
One can write a simple expression for (17), as shown in [43]. The expression is particularly simple when expressed in the basis of characters. The characters χ r pU q " Tr r pU q for different representations provide a complete orthonormal basis of class functions: The result of [43] is that, in the representation basis, the three-holed sphere path integral is In particular, the result is "diagonal." To compute the path integral of the BF theory on an arbitrary orientable closed surface, one simply builds the surface up by gluing together three-holed spheres. Suppose that we have two spaces with S 1 boundaries that we want to glue together, and that the path integrals on the two spaces with fixed holonomy on the S 1 are ψpU q and φpU q, respectively. Then the path integral on the connected space The U´1 in one factor is due to the fact that if we pick a consistent orientation of the 2d surface, and cut it along an S 1 , then the opposite orientation of the S 1 will be induced on the two cut pieces.
To build a closed surface of genus g ą 1, one can glue together 2g´2 three-holed spheres. Using (19) and (20), one finds that the genus g partition function in the BF theory is

Boundary conditions
To make contact with random matrix theory, we would like to understand what gauge theory object is dual to an insertion in the matrix integral of The Zpβ, rq appearing here is a matrix integral partition function in a fixed representation sector, and was defined in (14). V P G is a group element, and we will sometimes write it as V " e βµ , with µ a chemical potential. 4 In the bulk gauge theory, this insertion corresponds to the requirement that the 2d bulk space should have a boundary with boundary conditions determined by β and V , in a way that we will describe below. In fact, to compare the gauge theory and matrix integral formulas, it will be convenient to directly work with insertions of Zpβ, rq, with fixed representation r. These can be obtained by taking a weighted integral over V : This insertion can be described as another type of boundary condition in the bulk gauge theory, characterized by β and r.
We would like to compute the path integral of the gauge theory on arbitrary orientable surfaces, with boundaries of the type that correspond to insertions of Zpβ, rq. This path integral can be constructed using a gluing procedure. One important component in the gluing is the three-holed sphere discussed above. We will also need the path integral on a "trumpet" geometry, with the Zpβ, rq boundary conditions at one end, and the gluing boundary condition at the other end. Finally, as a special case, we will also need the path integral on the disk with Zpβ, rq boundary conditions on the boundary. The disk and trumpet path integrals are computed from the BF theory perspective in appendix A. We will discuss them from a related Yang-Mills perspective below. Either way, the results are For Z gauge T , the final r 1 argument labels the representation at the gluing end of the trumpet.
The trumpet path integral, together with the formula for the three-holed sphere above, can be used to give the partition function of the BF theory with Zpβ, rq boundary conditions, and an arbitrary connected topology. The only fact that one needs to know is that a genus g surface with n boundaries can be decomposed into 2g`n´2 three-holed spheres. Since the three-holed sphere is diagonal in representation (see eq. (17)), and the trumpet is also diagonal in representation (see eq. (25)), all representations will have to be equal. Multiplying together the factors for n trumpets and 2g`n´2 three-holed spheres, one finds Z gauge g pβ 1 , r 1 ; . . . ; β n , r n q " δ r 1 ,...,rn pdimpr 1 qq nˆv olpGq dimpr 1 q˙2 g`n´2 n ź j"1 e´β j c 2 pr 1 q{2 .
This formula is actually the only thing we will need to know about the bulk gauge theory in order to match to random matrix theory. Plugging in g " 0 and n " 1, one finds that this formula also gives the right answer for the special case of the disk (24).
The rest of this section should be regarded as optional. We will describe the boundary conditions that correspond to insertions of (22). Because they are slightly unusual from the perspective of 2d gauge theory, we will discuss them from two different perspectives below. Detailed computations in the BF perspective are in appendix A.

Yang-Mills theory
It will be helpful to think about a generalization of the BF theory to a Yang-Mills theory with a position-dependent coupling constant e 2 pxq: Here and below, we use boldface for the Yang-Mills fields, to distinguish them from the BF fields in the discussion below. After integrating out B, one gets a standard Yang-Mills theory. A simple boundary condition is the "gluing" boundary condition discussed above, where we fix the holonomy V of the gauge field around an S 1 boundary. To relate this to the dual boundary theory, we interpret V as the holonomy of a background gauge field on the boundary circle, which is to say that this V is the same as the V in the insertion introduced in (22).
The theory (27) was solved in [43] for an arbitrary e 2 pxq, and the answer is simple to state. In the discussion of the BF theory, we saw that the three-holed sphere is "diagonal" in the representation basis, so the partition function can be written as a single sum over representations. The effect of the e 2 pxq term is simply to add an additional weighting We will choose the function e 2 pxq to be concentrated in a narrow annular region near each true boundary (as opposed to artificial boundaries that are included in e.g. the pants decomposition), so that this weighting factor is where β j is the renormalized length of the j-th boundary. With this choice of e 2 pxq, the disk and trumpet answers in (24) and (25) follow from results in [43].
The physics of this Yang-Mills setup is as follows. In the bulk of the space, we have e 2 pxq " 0, so the B field acts as a Lagrange multiplier that forces the gauge field to be flat. However, in a small region near the boundary, e 2 pxq is nonzero, and the gauge field can fluctuate. This fluctuation is the off-shell "particle-on-a-group" mode that has been identified in the low-energy limit of the SYK model with global symmetry [28-30, 32-34, 58, 59]. Because the gauge field is flat everywhere in the bulk of the space, one would expect that the somewhat unusual Yang-Mills theory we just described could be understood as a boundary condition in a conventional BF theory. We turn to this next.

BF theory with a non-topological boundary
The same particle-on-a-group theory that we just discussed has also been derived from pure BF theory with a particular boundary condition in [60]. Generalizing this slightly to include a chemical potential, the theory is together with the boundary condition Here u is a renormalized time coordinate along the boundary, and it runs from zero to β. The quantity µ is a chemical potential, as we will see in a moment. Note that although the boundary conditions relate B to A u , they do not determine the value of B itself, and the fluctuations in B become the particle-on-a-group mode [60].
An important difference between these boundary conditions and the Yang-Mills ones is that (31) is not gauge-invariant. So, in the BF description, we restrict the gauge transformations to act trivially at the boundary. The asymptotically constant would-be gauge transformations A Ñ gAg´1`gdg´1 that do not vanish at the boundary become global symmetries. The corresponding Noether charge can be worked out from the action (30): From this it follows that for small variations µ Ñ µ`δµ, the change in the action is which means that µ is indeed the chemical potential.
In appendix A, we work out the disk and trumpet formulas (24) and (25) in detail from the BF theory path integral with these boundary conditions. The fact that the answers agree with the Yang-Mills results from [43] establishes in a roundabout way that the two descriptions are equivalent. We will also give a direct (although less precise) path-integral argument for their equivalence.

Relationship between the two descriptions
In order to relate the two descriptions, it is convenient to consider the thin annulus near the boundary where the YM coupling is nonzero, and where the YM gauge field can fluctuate. Roughly, we identify the BF theory as living in the region inside the inner boundary of this strip, where the gauge field is forced to be flat. The fluctuating boundary mode of the BF theory will describe the YM gauge field in the remaining part of the geometry, which is the thin annulus itself.
In relating the theories, the following detail is important. Normally in YM theory, we fix the holonomy of the gauge field at the boundary in terms of the chemical potential V " e βµ , and we quotient by gauge transformations that are nonzero on the boundary. However, an equivalent prescription is to fix A τ pointwise along the boundary, and not quotient by gauge transformations on the boundary. To relate the theories, we will take this perspective. Rather than defining the YM theory by V " e βµ , we will define it by A u | BΣ "´µ.
Now, the main idea is that the BF and YM gauge fields are the same in the interior of the geometry, and in the thin annular region, they differ by a term proportional to the boundary value of the B field of the BF theory: Here x is a coordinate that goes from x " 0 (inner boundary of the thin annulus) to x " ε (outer boundary of the thin annulus). The motivation for this term linear in B is that it makes the BF boundary condition (31) consistent with the YM boundary condition (34). Substituting the above into the YM action, we find that in the thin annulus, In going to the final expression, we integrated over the radial x direction in the thin annulus, assuming that B is approximately constant in this small interval. After doing the Gaussian integral over B, this becomes which is the action for the boundary mode in the BF description. So we see that after integrating out the B field of the YM description, the fluctuations of A in the thin annulus become the fluctuations in the boundary mode of the BF description.

Comparison to random matrix theory
Now, let us try to compare the bulk gauge-theory result (26) to random matrix theory. As a starting point, we should remember that the BF or YM gauge theory is only part of the bulk theory. In addition, we have whatever "seed" 2d gravity theory is dual to the matrix integral without global symmetry. For example, this could be the p2, pq minimal string, or JT gravity. Then the full partition function on genus g with n boundaries characterized by tβ i , r i u is Z g pβ 1 , r 1 ; . . . ; β n , r n q " Z grav g pβ 1 , . . . , β n qZ gauge g pβ 1 , r 1 ; . . . ; β n , r n q.
Here Z grav g pβ 1 . . . β n q is the partition function of the 2d gravity theory without the bulk gauge theory included, and Z gauge g is given in (26). Note that this simple factorization is a result of the fact that the BF theory is topological in the bulk, and doesn't depend on the details of the metric or the bulk gravity theory.
We define a seed ρ grav 0 pxq as the leading density of eigenvalues associated to Z grav 0 : Given this function, what is the leading density of eigenvalues of the full theory in a given representation sector? Due to the exact dimprq degeneracy in sector r, we would like to write with ρ prq 0 pxq to be interpreted as the leading density of distinct eigenvalues in the sector of the Hilbert space transforming in representation r, not including the degeneracy. In other words, ρ prq 0 pxq is the leading density of eigenvalues of H prq . Our formula for the disk (24) implies that Compatibility with (40) and (41) then requires that So the leading density of eigenvalues in the different sectors are all described by the same function ρ grav 0 pxq, but with shifted ground state energies c 2 prq{2, and densities (of distinct eigenvalues) rescaled by a factor proportional to dimprq. Note that this factor in the density of distinct eigenvalues combines with the exact dimprq degeneracy to imply that the total number of eigenvalues in each sector is proportional to dimprq 2 .
In random matrix theory, the function ρ prq 0 pxq completely determines the genus expansion of correlation functions of Tr e´β H prq . And, because of the simple relationship between ρ prq 0 and ρ grav 0 , the prediction can actually be written in a simple way in terms of the correlation functions of the seed theory Z grav g pβ 1 . . . β n q. The relationship is Both of the multiplicative factors on the RHS have simple explanations. The factors of e´β j c 2 prq{2 account for the shift in the ground state energy by c 2 prq{2. The other factor involving volpGq{ dimprq accounts for the rescaling of ρ prq 0 relative to ρ grav 0 , as explained in (13).
Finally, using (15) to convert from the partition function of distinct eigenvalues Tr e´β H prq to the total partition function in each sector Zpβ, rq, we find Z g pβ 1 , r 1 ; . . . ; β n , r n q " xZpβ 1 , r 1 q . . . Zpβ, r n qyˇˇg (45) " δ r 1 ,...,rn dimpr 1 q n xTr e´β 1 H pr 1 q . . . Tr e´β nH pr 1 q yˇˇg (46) This equation is precisely consistent with (39) and the answer for the BF theory in (26). This establishes that if the seed 2d gravity theory was dual to a random matrix ensemble, then after coupling to BF theory, the result will be dual to a random matrix ensemble with G symmetry.

Global symmetries with anomalies
In Section 2 it was assumed that, for a quantum mechanical ensemble with G symmetry, the Hilbert space on which the Hermitian matrix H acts decomposes into a direct sum of subspaces corresponding to the irreducible representations of G. However, since states in quantum mechanics are identified projectively, the total Hilbert space is only required to furnish projective representations of G. In principle, the decomposition of the Hilbert space in (4) could therefore include a sum over projective representations. As we will review, replacing the sum over ordinary representations by a particular class of these projective representations can be described by saying that the theory has an 't Hooft anomaly in the realization of the G symmetry.
The presence of this anomaly is a type of qualitative distinction in the realization of the G symmetry. In the AdS/CFT context (and in the study of SPT phases), an 't Hooft anomaly in the boundary description can be described in the bulk by adding discrete topological terms that assign phase weighting to nontrivial gauge bundles. In this section, we will see that after including such terms, the bulk theory remains dual to a random matrix integral, but with a particular set of projective representations appearing, indicating the 't Hooft anomaly.
We will work with the Yang-Mills description of the theory, since it is straightforward to incorporate holonomies that do not belong to the connected component of the identity in G. The coupling will still be delta-function localized on the boundary, so the theory is topological away from the boundary.

Non-trivial bundles and discrete θ terms
The partition function of a gauge theory with gauge group G on a manifold Σ involves an integral over gauge equivalence classes of connections on all principal G-bundles with base Σ. For topologically trivial Σ, the only class of G-bundle is GˆΣ, but for general Σ and certain choices of G, the partition function separates into integrals over distinct topological classes of bundles. The definition of the quantum field theory requires an unambiguous rule for weighting these different sectors in a manner compatible with locality and unitarity. In previous sections, we have implicitly weighted all classes of bundles uniformly. When G is a simply-connected Lie group, there are no non-trivial bundles and the point is moot. However, for generic G and Σ there exist distinct theories that differ from one another through the inclusion of discrete topological terms in the gauge theory action.
The allowed weighting factors for topological classes of G-bundles are classifiable [61,62] in any dimension, but for our purposes a more pedestrian approach is possible. Since our primary motivation is to introduce a sum over projective representations in the dual matrix ensemble, we will restrict attention to topological weighting factors that measure the obstruction to lifting a G-bundle to a r Gbundle, where r G is a central extension of G. Rather than providing an exhaustive treatment, we will specialize the general discussion to an interesting subclass of theories, and then illustrate the construction with a small number of representative examples.

Projective representations and central extensions
A unitary projective representation of a group G on a vector space H is a homomorphism from G to P U pHq. 5 Given such a representation, one can pick a (non-unique) lift to U pHq, in which case the group law is obeyed up to a system of phases: The system of phases ω : GˆG Ñ U p1q defines a 2-cocycle in the group cohomology of G. Since the lift is non-unique, each element U pgq is only defined up to a g-dependent phase U 1 pgq " f pgqU pgq.
Changing the lift sends and quotienting by this redundancy defines a class rωs P H 2 pG, U p1qq. If this class is trivial, the representation can be "de-projectivized," or lifted to an honest linear representation of G, while a nontrivial class rωs presents an obstruction to de-projectivization.
The central extension of a group G by an abelian group C is defined by a short exact sequence where C is a subgroup of the center of r G, i is the inclusion map and π : r G Ñ G is a surjective homomorphism. Central extensions of G by C can also be classified, up to isomorphism, by group cohomology. Each such extension corresponds to a class rEs P H 2 pG, Cq. Therefore, isomorphism classes of central extensions of G by U p1q are in bijective correspondence with isomorphism classes of projective representations.
In the case where C is a proper subgroup of U p1q, there are generally more group extensions of G by C than there are distinct classes of projective representations with phase systems ω contained in C. However, there is always at least one group r G whose linear representations contain all of the projective representations of G: the Schur covering group r G S . 6 The Schur covering group is a stem 7 extension of G by the degree two group homology of G: For a finite group, H 2 pG, Zq is the same as H 2 pG, U p1qq, and is also known as the Schur multiplier of G. The Schur covering group is not unique unless the group G is perfect (equal to its commutator subgroup), but all Schur covering groups for a finite group G are isoclinic. 8 In particular, this implies that if r G 1 and r G 2 are two Schur covering groups of a finite group G, then r G 1 and r G 2 have the same number of representations of each dimension. In other words, the partition functions on closed surfaces of two 2D gauge theories whose gauge groups are isoclinic will be equal to each other.
When G is a compact, connected semi-simple Lie group, the analog of the Schur covering group is the universal cover r G of G. In this case, r G is simply connected, and the quotient π : r G Ñ G by a subgroup Γ " kerpπq of the center of r G realizes r G as a central extension of G by Γ. All projective representations of G can be realized as linear representations of r G, and the non-trivial classes rωs correspond to representations of r G for which some element of Γ is represented non-trivially.
is called a stem extension if C is also contained in the commutator subgroup of r G. 8 See, for example, https://groupprops.subwiki.org/wiki/Isoclinic_groups. in a given representation r r of r G, the generator z is equal to e 2πik 1 {N for some k 1 that depends on the representation r r. So in general χ r r pr gzq " e 2πik 1 pr rq{N χ r r pr gq.
We will follow a convention and refer to the value of k 1 as the "N -ality" of the representation r r. 9 Topological actions and partition functions for finite gauge groups For a finite gauge group G, each bundle on a closed Riemann surface Σ of genus g is completely specified by the holonomies around the non-contractible cycles in Σ, modulo overall conjugation by G. Each bundle therefore represents an element of Hompπ 1 pΣq, Gq{G and a unique topological class. Since there is a unique flat connection in each class, the possible partition functions of the theory are completely determined by the relative weights assigned to each topological class of bundle: The simplest choice of topological action, SpΣ, γq " 0, weights all bundles equally and simply counts the number of G-bundles on Σ, modulo conjugation. In general, we can allow SpΣ, γq to be multivalued, provided that the phase in (53) is well-defined. The possible choices of SpΣ, γq consistent with factorization can be classified using group cohomology [61]. Each action corresponds to a class rSs P H 2 pBG, U p1qq, where BG is the classifying space for principal G-bundles. 10 This cohomology ring is isomorphic to the group cohomology used in the classification of projective representations, H˚pBG, U p1qq " H˚pG, U p1qq, so that a choice of topological action also singles out a particular class of non-trivial projective representations of G. As we will see, the partition function of this theory in the representation basis can be expressed solely in terms of this particular class of projective representations. Concretely, the classifying map ρ : Σ Ñ BG allows one to pull back cohomology ρ˚: H 2 pBG, U p1qq Ñ H 2 pΣ, U p1qq. Pairing the image of rSs under this map with the fundamental homology cycle rΣs yields a topological action SpΣ, γq " xρ˚rSs, rΣsy (54) which depends only on the topological class of G bundle (provided that Σ has no boundary).
We would like a practical way to evaluate the action (54) in concrete examples. We will focus on finite groups G such that H 2 pBG, U p1qq equals Z N . In this case, the group G has N distinct classes of projective representations. We choose a Schur covering group 11 (in this case an extension of G by Z N ), and distinguish (and weight) G bundles according to whether or not they lift to r G bundles. For discrete G, each bundle is topological, and is therefore completely specified by its transition functions g ij on an open cover tU i u of Σ. On each triple intersection of the open cover, the transition functions 9 If p is coprime with N , then z p also generates kerpπq. Our choice of generator z defines what we mean by N -ality of a representation of G, as well as the G-bundle with minimal topological number in the discussion that follows. 10 BG is the base space of the so-called "universal bundle" EG. The topological classes of G bundles over a manifold M are classified by the homotopy classes of maps M ρ Ý Ñ BG, which can be used to pull back the bundle over BG to a bundle over M . See section 2 of [61] for a discussion aimed at physicists. 11 The choice does not affect the answer since all Schur covering groups are isoclinic.
of the G bundle satisfy the cocycle condition Picking a lift G Ñ r G, each transition function lifts to an element in r G: g ij Ñ r g ij . On a generic triple intersection, one will have A nonzero element of Z N appearing in the cocycle condition represents a possible obstruction to lifting the G bundle to a r G bundle. Changing the lift of the transition functions can change the local values of the r c ijk , but if the transition functions cannot be lifted in such a way so as to remove this obstruction globally, then the G-bundle does not lift to a r G bundle and we expect the topological action (54) to be nonzero. Concretely, the assignment of an element of Z N to each triple intersection (modulo local gauge transformations and changes of lift) defines aČech 2-cocycle rω N s P H 2 pΣ, Z N q which can then be paired with rΣs to define an integer ω " xrω N s, rΣsy P Z N .
Since we are assuming that H 2 pBG, U p1qq " Z N , our theories are labelled by an integer k P t0, . . . , N´1u. 12 To determine the effect of the topological term (54) on the partition function, we begin by grouping the G-bundles on Σ according to the value of ω: where γ P Hompπ 1 pΣq, Gq and Z Σ, ω denotes the partition function restricted to G-bundles on Σ with topological number ω. In order to determine Z Σ, ω , it is convenient to introduce the partition function of the gauge theory with gauge group r G with no topological weighting factor, which we denote r Z Σ : The final expression is the analog of (21) for finite groups, and it is derived the same way [43]. The irreducible representations of r G are denoted by r r. Because r G is a Schur covering group, all representations of G, projective or not, occur in the sum.
All G bundles that do not lift to r G bundles can be obtained from honest r G bundles using a simple trick that involves excising a small disk D from Σ [43,65]. As we have seen, specifying a G bundle for a finite group G involves specifying holonomies Since we began with an honest G-bundle, it is guaranteed that u P ker π » Z N . However, u may not be equal to 1 r G , in which case the bundle does not lift. The value of ω P Z N in (57) is given directly by u.
Note that the r U i 's and the r V i 's become admissible holonomies for a r G bundle if we cut out a small disk D from Σ 13 and impose a holonomy around BD equal to u´1. Therefore, an equivalent construction of G-bundles with obstruction number ω simply starts with the collection of admissable r G-bundles, excises a small disk in each, and imposes the holonomy u´1 determined by ω around the excision. Since this action is performed on each r G bundle, we can use the formula for the partition function of the r G-theory on a Riemann surface with one boundary [43] to obtain This formula requires some explanation. First, u is the element of kerpπq » Z N that is given by z ω , where z is the elementary generator of Z N . From (52), we therefore have where k 1 is the N -ality, discussed near (52). Finally, the factor N 1´2g " p| r G|{|G|q 1´2g can be interpreted as the inverse of a Z N partition function, which corrects for the fact that the r G gauge theory overcounts configurations from the perspective of a G gauge theory. In particular, each of the 2g holonomies can be given N different lifts to r G.
Substituting (60) into (57) and using the orthogonality relation with k, k 1 P t0, . . . N´1u, we conclude that Z pkq Σ is a sum over only those representations of r G with "N -ality" k. Note that for k " 0, the only representations that contribute are linear representations of G, and the normalization factors are such that we recover the original Z Σ .

Connected Lie Groups
When G is a connected, simply-connected Lie group, all principal G-bundles are topologically trivial and homeomorphic to GˆΣ. When G is connected, but not simply-connected, non-trivial bundles exist and are in one-to-one correspondence with the elements of π 1 pGq. This correspondence can be explained as follows. The universal cover r G is a central extension of G by π 1 pGq. Because r G is simply connected, there is only one class of bundle r E " r GˆΣ, and there is a simple procedure to construct the non-trivial G bundles from r E [43,65], just as in the discrete group case. 14 Given the trivial bundle r E, one cuts out a small disk D from Σ, and glues it back with a transition function u P π 1 pGq. This procedure defines a G bundle E u which does not lift to a r G bundle. To see this, note that because π 0 pGq " 0, the bundle is trivial when restricted to D and to Σ´D. On each patch, E u therefore lifts to a r G-bundle. However, the overlap of these two patches is a circle, and the transition function u : S 1 Ñ G defines a closed path in G but not in r G. The lifted transition functions are therefore not single-valued in r G and E u is not homeomorphic to r E.
One can alternately diagnose this obstruction using a characteristic class. Given a G-bundle E u , 13 Concretely, imagine the representation of Σ as a 4g-gon with the standard identification of the edges, and imagine cutting out the disk from the center of this polygon.
the transition functions on the open cover satisfy the cocycle condition on triple intersections g ij g jk g ki " 1 .
E u lifts to a r G-bundle on each open patch, but the lifts of the transition functions will generically satisfy r g ij r g jk r g ki " r c ijk P π 1 pGq .
Non-trivial r c ijk presents a potential obstruction to lifting E u to a r G-bundle. Changing the patchwise lift changes the local values of the r c ijk , but if they cannot all be trivialized globally then the bundle does not lift. In fact, since the obstruction is topological, it can always be localized to a small patch as in the previous discussion. The assignment of an element of π 1 pGq to each triple intersection (modulo local gauge transformations and changes of lift) in the open cover of E u defines aČech 2-cocycle rωs P H 2 pΣ, π 1 pGqq which can be paired with rΣs to produce the topological action S " xrωs, rΣsy , which depends only on the topological class of the bundle E u .
When π 1 pGq " Z N , the analysis is the same as for the finite group case above. One finds Summing over ω as in (57), one finds again that the Z pkq Σ is a sum over representations of r G with N -ality equal to k.

Manifolds with boundary and the anomaly
The characteristic classes that define the topological terms are well-defined and gauge invariant on closed manifolds: they depend only on the bundle, rather than a particular connection on the bundle. In particular, given some representative ω N of the class rω N s P H 2 pΣ, Z N q, a variation of the connection or a gauge transformation induces a shift by a coboundary which integrates to zero on a closed surface: δω " xδb, rΣsy " xb, BrΣsy " 0 .
However, on manifolds with boundary xb, BrΣsy P Z N , and the weighting factors are not necessarily gauge-invariant or independent of the connection on the bundle. In general, the non-invariance of the "topological" term is completely controlled by the connection on the boundary. Honest gauge transformations that vanish at the boundary will not change the path integral. However, if we consider a gauge transformation that does not vanish on some S 1 boundary, and instead describes a nontrivial element of π 1 pGq as we wind around the boundary circle, then xb, BrΣsy will be nonzero and the path integral will transform by a phase.
The boundary values of the gauge fields represent background gauge fields for the global symmetry G in the random matrix ensemble. A gauge transformation that does not vanish on the boundary represents a gauge transformation of this background gauge field. The non-invariance of the partition function under such a transformation is the definition of an 't Hooft anomaly.
With this understanding, let's now try to define the partition function with boundaries in the theory with the anomaly. The naive generalization of (57) to a manifold with a single boundary and prescribed holonomy U P G would be In this formula, one would like "Z Σ, ω pβ 1 , U 1 q" to denote the partition function of the G gauge theory restricted "to the class of bundles with topological number ω and prescribed holonomy U ". As we have noted, this formal object is ill-defined, since the value of ω on a manifold with boundary is no longer an invariant. The left hand side of the equation is well-defined but not invariant under large gauge transformations that wind non-trivially around the boundary circle. These gauge transformations correspond to non-trivial elements of π 1 pGq and change the phase of the path integral in a controlled way. This phase ambiguity can be repackaged by lifting the holonomy U 1 to an elementŨ 1 of π´1pU 1 q P r G. Since there are no topologically non-trivial gauge transformations in r G, once the lift of U 1 is chosen the path integral is defined unambiguously. However, different choices of the lift result in different overall phases, matching the ambiguity in the G-theory's partition function. Having chosen a definite phase for the path integral by lifting to r G, the partition functions in the fixed topological sectors can be computed by excising a disk from Σ and gluing in one with holonomy u P Z N , as in Section 5.1. A well-defined version of (69) therefore reads Again, the N´2 g factor can be interpreted as the inverse of a Z N partition function on a genus g surface with one boundary.
The discussion is identical on a surface with n boundaries. One would like to compute the partition function Z pkq g pβ 1 , U 1 ; . . . ; β n , U n q with specified honolomy U i P G on the i th boundary component. This object has phase ambiguities associated to elements of π 1 pGq acting at each boundary. These ambiguities can be repackaged by working with a r G-theory and lifting the U i to elements of the covering group r U i P π´1pU i q P r G. There is an N -fold choice for each r U i , and there is no canonical way to make this choice. 15 In this formulation, the dependence of the partition function on the choice of an element of π´1pU i q is the statement of the anomaly. The phase ambiguities match those of the G-theory: the partition function transforms the same way (by a phase related to an element of the center of r G) when one performs a large gauge transformation in the G theory or when one changes the choice of lift in π´1pU i q in the r G-theory. Following the prescription of excising a small disk in [43], we get the analog of (66) and (57) for general 15 Note that if Ui " 1G, then there is a natural choice r Ui " 1 r G , since the identity element of every group is unique. manifolds with boundary: " ÿ r r δ k,k 1 pr rq dimpr rq nˆv olpGq dimpr rq˙2 The Kronecker delta ensures that we sum only over representations of N -ality k. In the case of a finite group, we would have the same formula, with volpGq replaced by |G|.
Let's see how this formula reproduces the 't Hooft anomaly. Suppose that we transform one of the holonomies U i , by a background gauge transformation that corresponds to the elementary generator of π 1 pGq. U i will just transform by conjugation, but the lift r U i will be multiplied by z, the generator of kerpπq. Using (52), we find that (73) will transform by a definite phase e 2πik{N which characterizes the 't Hooft anomaly. In particular, in the case k " 0, we sum over honest linear representations, and the result is just the partition function in the theory with no anomaly.

Connection to random matrix theory
The formula (73) (or its analog for finite groups) can be converted to the representation basis by exploiting the orthogonality of characters of r G, and the projection formula (18) for the group r G. 16 The resulting expression for Z g pβ 1 , r 1 ; . . . ; β n , r n q is identical to (26), except for the restriction to projective representations of fixed N -ality. The discussion of section 4 goes through as before, and we conclude that the bulk theory is dual to a random matrix ensemble with G symmetry but only projective representations of fixed N -ality.

Examples
In the rest of this section, we consider specific examples to illustrate the above general theory. In section 5.4.1, we consider the finite group G " Z 2ˆZ2 , for which there are two Schur covering groups: the dihedral group with eight elements and the quaternion group. In section 5.4.2, we consider the case with G " Op2q and r G " Pin`p2q. Here G is continuous, but disconnected. In section 5.4.3, we consider the case G " P SU pN q and r G " SU pN q. Here G is connected, but not simply connected, and r G is its universal cover; this is the original setting in [68].

Z 2ˆZ2
The simplest internal symmetry group capable of exhibiting an anomaly in quantum mechanics is Z 2ˆZ2 , see the second column of Table 1 of [62]. Since H 2 pZ 2ˆZ2 , U p1qq " Z 2 , there are two choices for the gauge theory action and a single non-trivial class of projective representation. However, there are multiple inequivalent central extensions of Z 2ˆZ2 by Z 2 classified by the group H 2 pZ 2ˆZ2 , Z 2 q " Z 2 'Z 2 'Z 2 . There are four possible r G's, and thus multiple elements of H 2 pZ 2ˆZ2 , Z 2 q can correspond 16 After projecting (73) to a given r r using the orthogonality of the characters of r G, we are only left with a dependence on dimpr rq. Thus the answer is independent of the choice of r G, since the various possible r G are isoclinic.
to the same r G. Explicitly, there is Z 2ˆZ2ˆZ2 (appearing once), Z 2ˆZ4 (appearing thrice), the dihedral group D 8 (appearing thrice), and the quaternion group Q (appearing once). Of these, D 8 and Q are isoclinic Schur covering groups, while Z 2ˆZ2ˆZ2 and Z 2ˆZ4 are not stem extensions, and therefore are not Schur covering groups. 17 Since Z 2ˆZ2 is abelian, it suffices to work with the abelianization of π 1 pΣq when enumerating bundles. Each bundle is characterized by a homomorphism H 1 pΣ, Zq Ñ Z 2ˆZ2 , of which there are 4 2g . The simplest theory with this gauge symmetry counts the number of such bundles modulo the conjugation action, and has the partition function (Z 2ˆZ2 theory without anomaly) .
This expression in the "bundle basis" is of course also equal to the expression in the representation basis (21). The group Z 2ˆZ2 has 4 conjugacy classes and 4 one-dimensional representations, so the partition function can also be expressed as It is possible to construct a variant of this theory that distinguishes the Z 2ˆZ2 bundles that lift to bundles of the covering group D 8 from those that do not. 18 The corresponding action is related to the non-trivial element of H 2 pZ 2ˆZ2 , U p1qq. The dihedral group has the presentation The elements t1, a 2 u are central, and D 8 {t1, a 2 u " Z 2ˆZ2 . The group D 8 has five conjugacy classes, and therefore five irreducible representations. Four of these representations are one-dimensional and restrict to representations of Z 2ˆZ2 (since a 2 is represented trivially). The fifth irreducible representation of D 8 has dimension two, and the central element a 2 is represented by´I 2ˆ2 . This corresponds to the unique class of non-trivial projective representation of Z 2ˆZ2 . The path integral of the D 8 gauge theory on a closed surface is given by the sum over representations (21) We will now explicitly evaluate the partition functions of the Z 2ˆZ2 theory with the anomaly. The topological action (54) corresponding to the non-trivial element of H 2 pZ 2ˆZ2 , U p1qq " Z 2 evaluates to 0 if the Z 2ˆZ2 bundle lifts to a D 8 bundle, and returns 1 2 otherwise. The partition function with the anomaly therefore takes the form where ωpγq " 0 if γ lifts to a D 8 bundle and ωpγq " 1 otherwise. The calculation therefore reduces to counting Z 2ˆZ2 bundles with signs. The sum over Z 2ˆZ2 bundles that lift to D 8 bundles is simply related to the D 8 partition function (77) in the representation basis through the formula (60) and gives Because the kernel of the covering map D 8 Ñ Z 2ˆZ2 contains a single non-identity element a 2 , the nonlifting bundles can all be constructed from the liftable bundles by excising a small disk and imposing the holonomy a 2 around it. According to the general formula (60), each D 8 representation occurring in this second sum is weighted by plus or minus one depending on whether a 2 is represented nontrivially in that representation. One easily obtains The partition function of the theory without the anomaly is the sum of (79) and (80), also known as 4 2g´1 . This is in complete agreement with (74). Note that the sum projects out the two-dimensional representation of D 8 which defines a genuinely projective representation of Z 2ˆZ2 . The partition function of the theory with the anomaly, Eq. (78), is the difference of (79) and (80), and projects onto the single genuinely projective representation: We emphasize that if one is simply counting the number of bundles, and not quotienting by conjugations, one is computing the volume of moduli space rather than the partition function. The moduli space volumes for a finite group are simply equal to |G| times the relevant partition function.
It is instructive to check these results on the torus. There are 8 2 " 64 possible assignments of D 8 holonomies pu, vq to the two homology cycles of the torus. Since D 8 is nonabelian, the necessary condition uvu´1v´1 " 1 for a D 8 bundle is not automatically satisfied, and only 40 choices of pu, vq satisfy the relation and define D 8 bundles. These 40 bundles, after accounting for conjugation, yield r Z g"1 " 5 in agreement with (77) for g " 1. The remaining 24 pairs pu, vq satisfy uvu´1v´1 " a 2 and are accounted for in (80). In the Z 2ˆZ2 language, out of the sixteen possible assignments of Z 2ˆZ2 holonomy pU, V q to the two cycles of the torus, ten pairs lift to admissible D 8 holonomies, while six do not.
We now turn to the evaluation of the Z 2ˆZ2 gauge theory partition function on surfaces with boundary. In the theory without the anomaly, we need to specify a holonomy U i P Z 2ˆZ2 on each boundary i P t1, . . . , nu. Since the discrete gauge theories are truly topological and independent of the length of the boundary curves, we can simply use the answers from [43]: Z pk"0q g pβ 1 , r 1 ; . . . ; β n , r n q " 4 2g`n´2 δ r 1 ,...,rn .
Evaluation of this partition function in the theory with the anomaly is more subtle. As discussed in section 5.2, we need to specify a holonomy U i P Z 2ˆZ2 for each boundary, and also a choice of lift r U i P π´1pU i q Ă D 8 . Because the lifts of the non-identity elements of Z 2ˆZ2 are traceless in the two-dimensional representation of D 8 , the answer for the path integral in the theory with the anomaly should vanish unless all of the U i 's are equal to the identity.
Let's check this mechanically. Suppose that we glue a trumpet with holonomy U around the S 1 into a larger manifold. There is a choice of Wilson line V across the S 1 gluing locus, and we need to sum over this. The fact that this sum gives zero can be established using the locality argument in [24]: if we zoom in on a neighborhood of the gluing, then we will find a geometry with the topology of a cylinder S 1ˆI , with holonomy U on the S 1 and Wilson line V on the interval. This same sum arises in the calculation of the torus partition function with fixed holonomy U around one of the cycles, and arbitrary holonomy v around the other.
We therefore consider the restricted holonomy sum on the torus, where U " a, and we sum over V " 1, a, b, ab. Because Z 2ˆZ2 is abelian, we will have U V U´1V´1 " 1 for any of these four choices.
To check whether the bundle lifts to D 8 , we need to check if U V U´1V´1 " 1 using only the relations of D 8 . One can check In Z 2ˆZ2 , we have a 2 " 1, but in D 8 , it is not one, so one finds that half of the bundles lift and half do not. So the conclusion is that on the torus with holonomy on one cycle restricted to be U " a, the sum over gauge bundles weighted by the anomaly term vanishes. One can repeat this calculation for the case U " b or U " ab with the same conclusion.

Op2q
We now consider the simplest example of a continuous, but disconnected symmetry group, Op2q " U p1q¸Z 2 . We denote the connected component of the identity in Op2q by Op2q`, and the other connected component by Op2q´. An Op2q symmetry naturally arises in systems with a U p1q symmetry that are invariant under charge conjugation, and the possible mixed anomaly between U p1q and Z 2 has interesting consequences both in quantum mechanics and in gauge theory [46,48]. 19 By an Op2q BF gauge theory, we mean a sum over all flat Op2q bundles. There are several classes of Op2q bundle, each distinguished by a characteristic class. The first Stiefel-Whitney class ω 1 P H 1 pΣ, Z 2 q is an obstruction to orientability of the bundle. If it vanishes, the Op2q bundle defines an SOp2q bundle, or a complex line bundle. Such bundles are classified by their first Chern class c 1 P H 2 pΣ, Rq which vanishes for a flat bundle. If ω 1 ‰ 0, then the Chern class cannot be defined for the bundle, but a mod 2 analog ω 2 P H 2 pΣ, Z 2 q, the second Stiefel-Whitney class, still makes sense. Bundles with ω 1 " ω 2 " 0 can be lifted to Spinp2q bundles, and bundles with ω 2 " 0 can be lifted to Pin`p2q bundles (whether or not ω 1 is trivial). Since we are not considering matrix ensembles with time reversal symmetry, all Riemann surfaces in this section are oriented. For rank-2 vector bundles over oriented Riemann surfaces ω 1 Y ω 1 " 0, and so the only topological weighting factor for Op2q bundles that is consistent with factorization is ω 2 . There is thus a unique theory with anomalous Op2q symmetry [62], and it corresponds to weighting the Op2q bundles according to whether or not they admit a Pin`p2q lift. 20 The group Pin`p2q is a double cover of Op2q, with the kernel of the covering map given by the center of Pin`p2q: Not all Op2q bundles lift to Pin`p2q bundles, and not all representations of Pin`p2q descend to Op2q representations. The group Pin`p2q has two one-dimensional irreducible representations: the trivial representation and the determinant representation, both of which restrict to representations of Op2q.
In addition, there are an infinite number of two-dimensional representations labelled by elements of m P N{2. The representations with integer m descend to representations of Op2q. When m is not an integer, the nontrivial central element of Pin`p2q is represented by´I 2ˆ2 , and the Pin`p2q representation defines a genuinely projective representation of Op2q. Following the general discussion in Section 5.1, we expect the Op2q symmetric quantum mechanical system with the anomaly to contain precisely these projective representations.
We first consider the theory without the anomaly, where the general formulas of section 3 are valid. The partition function on a closed genus-g surface is given by the sum over all irreducible representations, as in (21): where the factor of 4π in this expression arises because volpOp2qq " 4π, in a standard convention. Note that this partition function (86) is formally divergent, because we have infinitely many 2d irreps and no Boltzmann suppression on closed surfaces. For Riemann surfaces with boundary, the partition functions in the representation basis are given by the general expression (26). In the holonomy basis, we will have Z pk"0q g pβ 1 , u 1 ; . . . , β n , u n q " p4πq 2g`n´2˜1`n Now, let us turn to the theory with the anomaly. As discussed above, the anomaly term is the second Stiefel-Whitney class of the Op2q bundle [47]. 21 We can compute the partition function on closed surfaces using the general method described in section 5.1. The results are Note that these expressions are also divergent. Now we combine the above two equations using (57) to closed surfaces agree and the choice does not effect the calculation of the Op2q partition functions. This is completely analogous to the choice of D8 or Q in section 5.4.1. 21 In more geometric terms, for a rank-2 vector bundle E over a Riemann surface Σ, the quantity ş Σ ω2 is the obstruction to having a section of unit vectors. get the formal partition function Z pk"1q g " Z g,ω"0´Zg,ω"1 " p4πq 2g´2 Next we consider manifolds with boundary in the theory with the anomaly. The partition function vanishes if any of the boundary holonomies belong to Op2q´, since these elements are represented by traceless elements in the projective representations. If a boundary holonomy U belongs to Op2q`, then the phase of the partition function is ambiguous and we have to specify a lift of this holonomy to Pin`p2q, as discussed in section 5.2. This lift requires a choice since there are two elements r U , r U 1 P Pin`p2q that map to U P Op2q under the covering map π : Pin`p2q Ñ Op2q. There is no canonical choice of r U or r U 1 , and the partition function flips sign under the interchange. To see this explicitly, parametrize the connected component of the identity in Pin`p2q by an angle θ which has periodicity 4π. For fixed r U 1 , . . . r U n P Pin`p2q, the n-boundary partition function takes the form (73), which in this case is explicitly given as Changing the lift of the holonomy from r U i to r U 1 i amounts to sending θ i Ñ θ i`2 π. Since all of the m's appearing in the sum are of the form pinteger`1{2q, the partition function flips sign under the shift of θ i by 2π. This is one of the defining features of the theory with the anomaly, and we see it explitly in (91). We can also rewrite this in the representation basis, as we explained in section 5.3. Note also the the partition functions on manifolds with a boundary are convergent, as opposed to closed surfaces, because of the presence of Boltzmann suppression factors.

P SU pN q
The last example that we will consider is P SU pN q gauge theory. P SU pN q is connected but not simply connected, and can be viewed either as the quotient of SU pN q by its center Z N , or as the quotient of U pN q by its center.
On a closed, oriented surface there is a single topological class of SU pN q principal bundle. In order to construct a non-trivial P SU pN q bundle from this SU pN q bundle, one excises a disk and glues in one with holonomy u P Z N . Said differently, one relaxes the SU pN q cocycle condition on the transition functions g ij to require g ij g jk g kl P Z N , since these elements are represented trivially under the projection π : SU pN q Ñ P SU pN q. The assignment of elements of Z N to each triple overlap on the surface defines a class rω N s P H 2 pΣ, Z N q through theČech cohomology, and the pairing of this class with the fundamental homology class defines a topological invariant ω " xrω N s, rΣsy P Z N of the bundle. This number can be interpreted as the mod N first Chern class of a corresponding U pN q bundle. The possible theories are labeled by an integer k P t0, . . . N´1u and the partition functions take the form For example, in the case N " 2 for which P SU p2q " SOp3q " SU p2q{t˘1u, there are exactly two classes of SOp3q bundle. The relevant SOp3q partition functions on a genus g surface are The partition function of the SOp3q theory without the anomaly is and contains only the genuine linear representations of SOp3q. The SOp3q theory with the anomaly has Z pk"1q and contains only the genuinely projective representations of SOp3q, as described in Section 5.1. On a surface with boundary but trivial holonomy, the partition functions take a similar form with Boltzmann factors and the appropriate classes of representations.
The topological term requires more care on manifolds with boundary and non-trivial holonomy (corresponding to non-trivial background fields in the quantum mechanics). The class rω N s is a topological invariant of the bundle because under a change of connection, the representative changes by a coboundary: On a manifold without boundary xδb, rΣsy " 0 so that the invariant is independent of any choices that went into its definition. On a manifold with boundary BΣ, one needs to specify both boundary conditions on BΣ, and in order to evaluate the topological term one also has to specify a representative of the cohomology class ω N . If one simply specifies a holonomy U P P SU pN q on BΣ, the phase of the partition function transforms under large gauge transformations that do not vanish at the boundary circle (non-trivial elements of π 1 pP SU pN qq " Z N ) where b is the 1-cocycle defined in (96). The explicit formulas for partition functions can be written using the methods of section 5.2.

Incorporating time-reversal symmetry and unorientable surfaces
So far, we have only discussed the gauge theory on orientable surfaces. However, one can also consider a bulk theory in which orientation-reversal is gauged. Concretely, this means that surfaces can be glued together with a reversal of orientation, and so in particular, unorientable surfaces should be allowed. Bulk theories in which orientation is gauged are expected to be related to boundary theories with timereversal symmetry. In the context of random matrix theory, this would mean GOE-like or GSE-like matrix ensembles, see [70,71] in the "minimal string" and [24] in JT gravity.
Following the strategy of the first parts of this paper, we will imagine starting with a "seed" unoriented 2d gravity theory such that Z grav pβ 1 . . . β n q agrees with the genus expansion of a GOE-like or GSE-like random matrix integral. Then we will ask what happens when we include a gauge theory for the group G.
As a first step, let's discuss the gluing rule in the gauge theory when we glue two manifolds together across a S 1 boundary with an orientation reversing twist. It is convenient to start with the ordinary gluing rule (20) in the holonomy basis, Reversing the orientation of one of the boundaries prior to gluing replaces U Ø U´1 in one factor, leading to [43] ż dU volpGq ψpU qφpU q " In the final expression we wrote the answer in the representation basis, using the property of the characters χ r pU´1q " χ r pU q. The new gluing rule is simple in the representation basis, and glues representation r to its conjugate representation r.
The other new ingredient we need to consider is the possibility of including unorientable surfaces in the path integral. These surfaces can be constructed by cutting n c holes in an orientable surface of genus g 0 , and attaching n c "crosscaps." We use g " g 0`n c 2 to denote the genus of the surface after this operation. In order to perform this gluing in the gauge theory, one only needs to know that the wave function of the gauge theory on a crosscap in the representation basis is (see [43], section 2.4) Ψ 1 2 prq " s r δ r,r . (100) The δ r,r factor indicates that unorientable surfaces only contribute to path integrals with boundary conditions that include real or pseudo-real representations of the group G. The factor s r is one if the representation is real, and minus one if the representation is pseudo-real [43].
Note that in order to add a crosscap to a space with at least one boundary, we need to add a three-holed sphere, and then glue in a crosscap on one of the new boundaries. So in the representation basis, the total factor associated to adding a crosscap will be volpGq dimprq where the first factor comes from the additional three-holed sphere.
Let's now try to interpret these changes to the bulk theory from the perspective of random matrix theory. Suppose first that r ‰ r. Then (100) vanishes and crosscaps do not contribute, but the modified gluing rule (99) allows us to glue r to r. This implies that the only effect of gauging orientation-reversal in the bulk theory is to replace the δ r 1 ,...,rn in eq. (26) with a δ symbol that is equal to one if the representations are equal or conjugate, and zero otherwise. So in any correlation function, an insertion of Zpβ, rq has the same effect as an insertion of Zpβ, rq. Thus Zpβ, rq " Zpβ, rq identically. In random matrix theory, the interpretation of this statement is that the eigenvalues in sector r remain GUE-like, but are precisely degenerate with corresponding eigenvalues in the sector r.
Next, suppose that r " r. Then crosscaps do contribute, and there are two different ways that any trumpet can be glued into a larger surface: with or without orientation reversal prior to gluing. The gauge theory does not notice the orientation reversal if r " r. Also, the weighting of the crosscap volpGq{ dimprq is such that (26) remains true on nonorientable surfaces (once we generalize g Ñ g 0`n c 2 where g 0 is the genus without crosscaps, and n c is the number of crosscaps). With this generalization of the genus, the random matrix prediction for GOE-like or GSE-like ensembles is also (47), so if the bulk theory without the gauge theory was dual to a GOE-like or GSE-like ensemble, then after coupling to gauge theory, this remains true in sectors with r " r. An interesting detail is that if r is pseudo-real and not real, then the sign associated to a crosscap will be reversed from that of the parent theory, and the statistics will be changed from GOE-like to GSE-like and vice versa. (See [72] for a proof that this sign interchanges GSE and GOE.) Both the r " r and r ‰ r results have a simple explanation in random matrix theory. We assume a time-reversal operator T that commmutes with the full Hamiltonian H. The operator T acts on the full Hilbert space in such a way that it maps H r Ø H r . If r is real, then T preserves H r and implies that the Hamiltonian restricted to this subspace commutes with T. So the corresponding eigenvalues should be drawn from a time-reversal-invariant ensemble (GOE-like or GSE-like). On the other hand, if r is complex, then T does not imply any time-reversal symmetry within H r . So the eigenvalues should remain GUE-like, but degenerate between H r and H r .

An example of a mixed anomaly including time-reversal
The inclusion of time-reversal symmetry makes new types of anomalies possible. We will illustrate this with the simplest example, where G " Z 2 . Without time reversal, there is no possible anomaly for this group. But with time-reversal, there is a mod 2 anomaly which we now discuss.
The anomaly is described in the bulk theory by a new type of topological action for the sum over Z 2 bundles, which would be trivial in a theory without orientation reversal. The term can be understood either as As we will see, the two are equal. 22 Here, w Op2q 1 is the first Stiefel-Whitney class of the tangent bundle. It assigns one to 1-cycles along which the orientation is reversed, and zero to 1-cycles along which the orientation is not reversed. Similarly, the class w Z 2 1 assigns one to 1-cycles with nontrivial Z 2 holonomy, and zero to 1-cycles with trivial holonomy.
On an orientable 2-manifold, both expressions are equal to one and therefore trivial. For the second expression, this is obvious since orientability implies that w Op2q 1 " 0. To see that the first expression vanishes identically, recall that the cup product algebra 23 on an orientable Riemann surface is where α i and β j are the 1-cocycles dual to the standard A i and B j cycles of the Riemann surface, and γ is the 2-cocycle. This algebra implies that w 1 Y w 1 vanishes mod 2 for w 1 set equal to any integer combination of the α i and β j . is the same thing as p´1q nc where nc is the number of crosscaps. This is related to an anomaly of a very simple kind, turning a GOE-like matrix integral with T 2 " 1 into a GSE-like one with T 2 "´1. 23 For a discussion, see section 3.2 of [73].
However, on an unorientable manifold, the expressions in (102) are in general nontrivial. An important special case is RP 2 , for which the cup product algebra with Z 2 coefficients is Here α is dual to the 1-cycle A along which the orientation is reversed, 24 and γ is the 2-cycle. If we consider a Z 2 bundle with nontrivial holonomy along A, then we will find and therefore both expressions in (102) are equal to minus one. This has an important implication: it means that the sum over Z 2 bundles on RP 2 weighted by (102) vanishes. The answer for the trivial Z 2 bundle is one, and the answer for the nontrivial bundle is minus one.
A general unorientable surface can be constructed by starting with an orientable surface, cutting holes, and gluing in crosscaps. Associated to each crosscap is a 1-cycle that passes through it, along which the orientation is reversed. The sum over Z 2 bundles along this 1-cycle will vanish by the same argument as above. So we conclude that unorientable surfaces do not contribute to the path integral in the theory weighted by (102).
Although non-oriented surfaces do not contribute to the path integral, the theory with the weighting (102) does not simply reduce to the theory without orientation gauged. Gauging orientation allows the possibility to glue "trumpets" to the rest of the manifold with a reversal of orientation. In fact, locally at the point that a trumpet is glued to the rest of the manifold, there are two different Z 2 options: one can reverse the orientation, and one can act with the nontrivial Z 2 element. We need to understand the weighting of (102) for these four possibilities.
These four choices only affect the region near the gluing, and because the weighting factor (102) is local, we can study the sum over these four possibilities in a slightly simpler context, as explained in [24]. Specifically, imagine that we are gluing two trumpets together to form the double-trumpet. Then we can glue the "big ends" of the double-trumpet together to form a closed manifold. In the case where the orientation is not reversed at the gluing, this manifold is topologically a torus. Since the torus is orientable, the weighting factor is trivial, and we learn that the weighting is one, regardless of whether or not we act with Z 2 before gluing.
In the case where the orientation is reversed, gluing the "big ends" together gives a Klein bottle. The cup product algebra on the Klein bottle is as follows: Here α is dual to the 1-cycle that originally formed the boundary at the "big end" of the double trumpet, and β is dual to the 1-cycle that goes through the double trumpet from one "big end" to the other. γ is dual to the 2-cycle. For the tangent bundle, we have w " β, since the orientation is reversed as we pass through the waist of the double trumpet. For the Z 2 bundle, we have where σ, τ are both either one or zero. We should sum over the two values of τ , since this corresponds 24 If we view RP 2 as a disk closed off by a crosscap, then A is the cycle that goes "through" the crosscap.
to gluing with or without an action of Z 2 . But we should hold σ fixed, because this corresponds to the Z 2 holonomy at the "big end" of the trumpet, which is fixed as part of the boundary conditions. The result of the cup product is where we used σ 2 " σ. Because the answer does not depend on τ , the weighting is the same for both choices of holonomy through the double trumpet, in other words for both choices of whether we act with Z 2 before gluing together. However, we find that the weighting is one for the case where the holonomy at the "big end" is trivial, and the weighting is minus one in the other case.
Adding this together with the contributions we computed using the torus, we find that the total answer vanishes in the case where the boundary holonomy is nontrivial, and the total answer is four in the case where it is trivial. The above discussion was for the double trumpet, but by locality a similar story will apply any time we glue a trumpet to any surface. In particular, the answer will vanish any time one of the trumpets has an asymptotic boundary with the nontrivial Z 2 holonomy.
Let's now give an interpretation of this in random matrix theory. We expect to find a correspondence to a matrix ensemble with a time-reversal symmetry T and a Z 2 global symmetry, generated by an operator we will refer to as Z. The Hilbert space breaks up into two sectors corresponding to the two representations of the Z 2 symmetry, H " H`' H´, where Z acts as˘1 on the two subspaces. A trumpet boundary with trivial Z 2 holonomy corresponds in the matrix integral to an insertion of while an insertion with nontrivial holonomy Z corresponds to an insertion of TrpZe´β H q " Tr H`p e´β H q´Tr H´p e´β H q.
The vanishing of all gravity path integrals with nontrivial holonomy means that TrpZe´β H q vanishes identically. This means that the two sectors H´and H`have precisely the same spectrum of energy eigenvalues. Note that because unorientable surfaces vanish, the statistics in either sector will be GUE-like.
This pattern can be explained by saying that the Z and T operators do not commute, but instead satisfy ZT "´TZ.
The minus sign in this equation is the boundary expression of the mixed anomaly between time reversal and Z 2 . Notice that it implies that T exchanges the subspaces H˘with each other. In this situation, time reversal implies exact degeneracy between the two sectors, but doesn't place any restriction on either sector individually, so the ensemble consists of two degenerate GUE-like sectors.

Summary and discussion
In this paper, we studied two-dimensional gauge theory coupled to gravity as a dual description of certain matrix ensembles with global symmetry G. First, we studied theories without anomalies. The matrix ensemble splits into several smaller uncorrelated matrix ensembles labelled by the irreducible representations r of G. The ground state energy in each sector is proportional to c 2 prq. The density of eigenvalues in each sector is proportional to pdim rq 2 . One of these factors of dimprq arises from the exact degeneracy due to the G symmetry. However, there is a leftover factor of dimprq, which implies that the number of copies of each irrep appearing in the spectrum is proportional to dimprq. These copies are not exactly degenerate. One can speculate that they could be related to the existence of a second action of G on the Hilbert space that commutes with the G-symmetry action but does not commute with the Hamiltonian. In other words, the second copy of G acts in the space indexed by the letter i in (6), but does not commute with the Hamiltonian. This is reminiscent of the paper [45] that constructed, in the setting of JT gravity coupled to matter, a gauge-invariant SL 2 algebra that does not commute with the Hamiltonian. 25 It may be important to understand this point better.
Next, we studied theories with anomalies. The different sectors are now labelled by the projective representations of G. We also studied G symmetry in the presence of time reversal symmetry and concluded that self-conjugate representations correspond to GOE and GSE type blocks, whereas we get degenerate pairs of GUE blocks for representations with r ‰ r. Finally, we studied a mixed anomaly between Z 2 and time reversal, and concluded that that the Hilbert space has two sectors that are exchanged by the time reversal symmetry, and hence the matrix ensemble consists of two degenerate GUE-like sectors.

A.1 The disk
We start with the case of the disk. The path integral over B in the interior of the disk imposes the constraint F " 0, so we have to integrate over flat connections. On the disk topology, a flat connection can be written as 26 A " gdg´1, where the formal gauge transformation g is a map from the disk to the group G. In the BF theory, we require true gauge transformations to vanish at the boundary, which means that the boundary values of g cannot be changed by a gauge transformation. These boundary values are physical modes, and we need to path-integrate over them. On the boundary, (112) reduces to A τ " gB τ g´1, and the boundary action of the BF theory (30) becomes (working with zero chemical potential at the moment) Here g " gpτ q P G is a function of the time coordinate along the boundary. This action is the well-known 1d sigma model that describes a particle moving on the group manifold G.
There are subtly different path integrals that one can consider with this action. The most obvious option is to integrate gpτ q over the full space looppGq of maps from the circle to G, with the ultralocal measure that follows from the metric The path integral with the integration measure associated to this metric is most easily obtained using canonical quantization of the particle-on-a-group theory. The energy eigenfunctions of the corresponding quantum mechanical system are the matrix elements of g in an irreducible representation r, namely ψ r,ab pgq " xr, a|g|r, by, and the corresponding energies are c 2 prq{2. Since there are dimprq 2 such matrix elements, the degeneracy is dimprq 2 , and one finds the partition function [75] Z ultralocal pβq " For the application to BF theory, this is not quite the right way to treat the path integral. One can see this by noting that under right-multiplication by a constant group element, gpτ q Ñ gpτ q¨h, the formula for A in (112) is unchanged. This means that the space looppGq is a redundant description of the flat connections on the disk. Instead, we should integrate over the quotient of this space by right G actions, denoted looppGq{G.
The appropriate measure for integrating over looppGq{G is the one that follows from the symplectic form of the BF theory: where δ i A are small changes to the flat connection and Σ is the spacetime manifold. We are interested in evaluating this symplectic form for configurations of the type (112), with variations parametrized by δg. It will be helpful to have a formula for the RHS of (116) in the case where one of the variations is a gauge transformation, and the other variation η preserves the flatness of A: ż Tr rpdΘ`rA, Θsq^ηs " ż Tr rdpΘηq´Θpdη`η^A`A^ηqs (117) " ż bdy Tr rΘηs .
In the last step we used that dη`η^A`A^η " 0 in order for the variation corresponding to η to preserve the flatness of A. We can use (118) to compute ωpδ 1 g, δ 2 gq. We set Θ equal to the gauge transformation associated to δ 1 g, which is Θ " gδ 1 g´1, and η equal to δ 2 pgdg´1q. Simplifying slightly, one finds which can also be written as It will be useful to compare the measure on looppGq{G induced by this symplectic form to the meaure on looppGq induced by the ultralocal measure (114). As we will see, the ratio of these measures is a measure on the group G. First, we note that the symplectic form (120) is right-invariant under the action of looppGq, and the ultralocal measure (114) is invariant under both left and right actions, so it is sufficient to compare the measures at the identity point gpτ q " id. At the identity point, we can identify δg´1pτ q with an element of the Lie algebra tpτ q P g, and we can decompose this function into Fourier modes tpτ q " where T A are anti-Hermitian and form an orthonormal basis for the Lie algebra of G, so that The set of Fourier modes parametrize the tangent space to looppGq at the identity, and the set of nonzero Fourier modes parametrize the tangent space to looppGq{G. So the ratio of the ultralocal and symplectic measures should be understood as a measure on the space of zero modes t A 0 .
To work out the precise measure, we write out the symplectic form explicitly in terms of the coordinates t A n . More precisely, we will write it in terms of the real and imaginary parts of t A n : The corresponding measure is On the other hand, in the same coordinates the ultralocal measure is Note that we have kept careful track of the overall multiple α of the symplectic form, but we have not kept track of a similar constant multiple of the metric (114). In fact, in writing (125), we implicitly adjusted the overall normalization of (114) in order to cancel some factors. The reason is that the measure associated to (114) is actually independent of rescalings of the metric (114). Rescaling the metric would multiply the measure by factors of the form ś n pconst.q, which is equal to one after renormalization. On the other hand, multiplying ω by a constant would rescale the symplectic measure by a factors of the form ś n‰0 pconst.q, which is not equal to one.
With this understanding, we can now compute the ratio where in the final equality we took the renormalized product (e.g. using zeta function regularization). The final expression in (126) is a measure on the Lie algebra of the group, normalized according to the metric xt, sy "´2α Trptsq , where t, s P g. This metric on the Lie algebra induces a bi-invariant metric on the group, and we denote the corresponding volume as volpGq. Note that this volume depends on the normalization coefficient α. For example, volpSU p2qq " p4αq Our conclusion is that the path integral over looppGq{G with the symplectic measure will be related to the path integral over looppGq with the ultralocal measure according to The expression on the LHS is the sum over all representations of the function Z gauge D pβ, rq in (24). In section A.4 we will show how to get the formula for fixed representation.
We will now address a subtlety that arises in the case of non-simply connected groups. Suppose that we have a gauge field of the form (112). In order for this to be nonsingular everywhere in the interior of the disk, the image of the boundary of the disk under g must be a contractible path in the group G. However, for non-simply-connected groups, the integral over looppGq or looppGq{G includes configurations gpτ q that do not have this property.
Such configurations can be incorporated in the BF theory by including nontrivial bundles for the bulk gauge field A. 27 On the disk topology, these bundles can be described using two patches. For example, if we use a radial coordinate r that runs between zero and one, then we can use a patch near the center P 1 " tr ă 2{3u and an annular region that includes the boundary, P 2 " t1{3 ă r ď 1u. The intersection is an annular region t1{3 ă r ă 2{3u, and the bundle is described by a transition function that maps this region into G. By using a transition function that winds around the desired noncontractible cycle of G as the angular coordinate winds around the annulus, we can find a nonsingular flat connection that has the form (112) in the outer patch, with noncontractible gpτ q. 27 Normally, all bundles over the disk are trivial. But with fixed gauge at the boundary, there are nontrivial bundles.
For example, in the case of G " U p1q, we can take This provides a flat connection on the bundle defined by the transition function In the outer region P 2 , the gauge field is equal to (112) with a g that winds n times around U p1q.

A.2 The trumpet
Another useful path integral is the "trumpet" path integral. This space is topologically a cylinder, but we will use the term trumpet to emphasize that the two boundaries are treated differently. In particular, at the "big end" of the trumpet, we have a non-topological boundary condition that supports the particle-on-a-group theory. The other "topological" end will always be glued onto another topological boundary, and we will work out how this gluing works later.
For the moment, we are interested in the path integral of the particle-on-a-group theory on the nontopological boundary. The analysis of this system is similar to that of the disk path integral considered above, with one important distinction: because the cylinder contains a non-contractible cycle, there exist additional non-trivial flat connections with holonomy U .
For example, if we take the periodic direction of the cylinder to be parametrized by τ , then a gauge field A " adτ (132) would describe a situation with holonomy U " e´β a . A more general flat connection would be a formal gauge transformation of this one, The particle-on-a-group theory for the trumpet arises from the path integral over the boundary values of gpτ q on the boundary at "big end" of the trumpet.
To analyze this theory, it is convenient to change variables to r gpτ q " gpτ qe´a τ . Then we have simply However, note that r g is no longer periodic, but instead satisfies r gpβq " r gp0qU , where U " e´β a . It makes sense to consider the particle-on-a-group theory with this non-periodic boundary condition and with the ultralocal measure associated to (114). Using the Hilbert space for the particle on the group manifold, one finds (see section A.4 below for some details on a slightly more general computation) which reduces to the disk computation (115) for U " 1.
The path integral we actually want is the one with the symplectic measure (116). To work this out explicitly, we start with the expression for A in (133). The value of g in the bulk is not meaningful since it can be changed by a true gauge transformation that vanishes on the boundary, but the values of g on the big end of the trumpet are physical. Even so, the parametrization (133) is slightly redundant, since multiplication gpτ q Ñ gpτ q¨h by a group element h that commutes with U preserves the form of A. For a generic U , the subgroup of G that commutes with U will be a maximal torus of the Lie group, which we refer to as T . This redundancy is reflected in the fact that, for a fixed a, the symplectic form (116) is degenerate and its zero modes span the maximal torus. To obtain a non-zero answer using the symplectic measure, we must therefore quotient the domain of integration in the path integral by the right-action of elements of T . In other words, we should integrate the boundary values of g over the space looppGq{T .
We are interested in the path integral over looppGq{T , with the measure that follows from the symplectic form (116). The induced measure on the space of g fluctuations, generalizing (120), is We would like to compare the measure associated to this symplectic form with the ultralocal measure.
Because of right-invariance, it is enough to work out the ratio of these measures close to the identity, where we can view dg as a Lie algebra element. We decompose the Lie algebra g " g 0 ' g K , where g 0 is the Lie algebra of the maximal torus T Ă G that contains U , and g K is the orthocomplement of T in G. Then, for the fluctuation components in g 0 , the calculation is the same as for the disk computation above. In particular, the ratio of the ultralocal and symplectic measures in the g 0 directions is a measure on the space of zero modes in g 0 itself.
For the fluctuations in the g K directions, we have to do a new calculation. In general, the measure associated to a symplectic form ω " 1 2 ω ij dx i dx j is given by In the final expression, the ψ i are Grassman variables. To compute the Pfaffian of the symplectic form ω, we replace dx i Ñ ψ i in the symplectic form and integrate exp ω over the variables ψ i . For the infinite dimensional case we are interested in, this becomes a Grassman path integral.
It will be enough to consider the case of g " sup2q. We will work with the basis for the Lie algebra This is a different normalization than (122), but as we will see below, this can be absorbed into the constant α below. We take a " ia Z Z and we want to compute the Pfaffian of the symplectic form for the components corresponding to fluctuations in the X and Y Lie algebra directions, working close to the identity. To do so, we make the replacement in the symplectic form (136) dg´1pτ q gpτ q Ñ iψ X pτ qX`iψ Y pτ qY and then evaluate the path integral over ψ X pτ q and ψ Y pτ q. This is Here ψ 1 denotes a derivative of ψ with respect to τ . Because we are integrating over all modes, the answer is independent of α and choosing α " 1 4 , this becomes a more-or-less conventional path integral, with two Majorana fermions satisfying periodic boundary conditions in Euclidean time. The path integral can be done by performing an explicit mode decomposition, but it is evaluated most easily by quantizing the theory in a two-dimensional Hilbert space, e.g.
The (141) is where we inserted ip´1q F " iZ to impose periodic boundary conditions for ψ X and ψ Y .
In order to generalize this computation beyond sup2q, it is helpful to rewrite the answer in terms of det g K p1´U q where U acts on g K via the adjoint action. Continuing with our SU p2q example, we have U " e´i βa Z Z . The eigenvalues of Z, acting in the adjoint representation, are˘2. So This implies that for the case of sup2q, we have For a general Lie algebra, we will have a copy of the sup2q calculation for each pair of Lie algebra generators that correspond to a given root. Taking the product over all such factors, one finds that (145) is actually the general formula.
So the path integral on looppGq{T is where Z ultralocal pβ; U q was given in (135). The factor in the numerator is (145), and the factor in the denominator arises from the integral over fluctuations in the g 0 directions, as explained before.

A.3 The double trumpet
The double trumpet is a space with the topology of the cylinder, with the non-topological boundary condition (31) on both ends, each supporting a particle-on-a-group mode. The path integral on this space is important, for its own sake. However, it is also useful because the double trumpet can be constructed by gluing two ordinary trumpets together along their "small ends." So comparison of the trumpet path integral and the double trumpet path integral will teach us the gluing rule for the small end of a trumpet.
On the cylinder topology, a flat gauge field can be parametrized as 28 just as in (133). The path integral for the double trumpet involves an integral over the particle-on-agroup modes associated to both boundaries, together with an integral over the holonomy parametrized by a. The measure for all of these pieces is induced by the symplectic form (116).
The new component of the symplectic form that we have to evaluate is ωpδg, δaq. To evaluate this, it is convenient to use (118) with Θ a gauge transformation corresponding to δg, namely Θ " gδg´1. The second parameter η corresponds to the variation of a, so η " gpδa dτ qg´1. We get ωpδg, δaq " 2α Here g L and g R are the values of g on the two boundaries of the double trumpet. We can therefore write the full symplectic form as In this expression, g L and g R are functions of τ , but a is constant.
As before, we would like to work out the measure induced by this symplectic form. By rightinvariance, it is sufficient to work near the identity for g L and g R , so that dg´1 L " dt L and dg´1 R " dt R are Lie algebra elements. For the nonzero Fourier modes of dg´1, the last term involving a drops out, and we find the same symplectic form as for the trumpet calculation. For the Fourier zero modes, however, the situation is different. Writing the Fourier zero modes as t 0 R and t 0 L , it is convenient to define t˘" t 0 R˘t0 L .
Then the symplectic form can be written as ωˇˇz ero modes " αβ Tr " dt´^`2da`ra, dt`s˘ı.
This form appears to be degenerate, because there are linear combinations of dt`and da that are zero modes of ω. However, all this means is that our coordinates on the space of gauge fields are overcomplete. A quick way to identify a minimal set is to restrict to the set of nonzero modes of the symplectic form. A convenient restriction is to t´P g, t`P g K , a P g 0 .
When t´P g K , the term proportional to 2da in (151) vanishes. The part of the integral with t´in g K therefore combines with the integral with t`in g K to give the same zero mode integral that is found for the separate computation of two trumpets, as discussed in the last subsection.
It remains to understand the measure for the integral over t´and a in g 0 . For these modes, the term proportional to the commutator in (151) vanishes. Since βda " dU U´1, the Pfaffian of the restriction of (151) to these modes is just the measure associated to the Lie algebra metric (127), restricted to g 0 . Thus the double trumpet with no restriction on the representations on the two ends is given by Z gauge 0 pβ 1 , β 2 q " volpT q ż T dU Z looppGq{T pβ 1 , U qZ looppGq{T pβ 2 , U´1q .
Here, the factor of volpT q came from the integral over the component of t´in g 0 , extended appropriately away from the identity. The integral dU is over the torus, with the measure associated to the Lie algebra metric (127). 29 Plugging in (146) and (135), the RHS is explicitly ż T dU volpT q det g K p1´U q ÿ r,r 1 dimprq dimpr 1 qχ r pU qχ r 1 pU´1qe´β 1 c 2 prq{2´β 2 c 2 pr 1 q{2 .
Using the Weyl integral formula, the integral over the torus T can be replaced by an integral over the full group G: ż G dU volpGq ÿ r,r 1 dimprq dimpr 1 qχ r pU qχ r 1 pU´1qe´β 1 c 2 prq{2´β 2 c 2 pr 1 q{2 .
Our route to this formula was somewhat involved. It seems likely that there is a quicker method, using quantization of the BF theory on the interval that stretches between the two ends of the trumpets. Indeed, the fact that the coefficients that appear in (156) must be integers follows immediately from that perspective.

A.4 Including a chemical potential
We would like to work out the formula for the trumpet or disk partition function when we include a chemical potential µ. The action for the BF theory including µ was given in (30), with the boundary condition in (31). The corresponding action for the particle-on-a-group boundary mode is obtained by substituting (133) into the boundary action : This formula is appropriate for the disk when a " 0 and appropriate for the trumpet when a ‰ 0. The global G symmetry for which µ is a chemical potential corresponds to left-multiplication gpτ q Ñ h¨gpτ q.
With a generic chemical potential included, the symmetry is reduced from G to a maximal torus T .
We would like to understand how the above computations of the disk and trumpet path integrals are modified by the µ term. It is convenient to rewrite the action (157) as I "´1 2 ż β 0 dτ Tr " pr gB τ r g´1q 2 ‰ , r gpτ q " e´µ τ gpτ qe´a τ .
So we have the ordinary particle-on-a-group action, but with a variable r g that is not periodic in time, and instead satisfies r gpβq " V´1r gp0qU . Here U " e´β a and V " e βµ .
With respect to the ultralocal measure, this path integral can be done by quantizing the particleon-a-group theory. The eigenfunctions of the Hamiltonian are the matrix elements of g in a given representation ψ r,ab pgq " xr, a|g|r, by, and the corresponding energy eigenvalue is c 2 prq{2. This gives Z ultralocal pβ, V ; U q " ÿ rab ż dg ψ r,ab pV´1gU qψ r,ab pgqe´β c 2 prq{2 (160) " ÿ r χ r pV´1qχ r pU qe´β c 2 prq{2 , which generalizes the earlier formulas (135) and (115).
We can use (23) to find a corresponding formula with fixed representation instead of fixed chemical potential: Z ultralocal pβ, r; U q " dimprqχ r pU qe´β c 2 prq{2 .
Since we didn't change the measure when we introduced the chemical potential, the relationship between the ultralocal and symplectic path integrals remains the same, and in particular from (129) and (146), we have Z looppGq{T pβ, r; U q " dimprq b det g K p1´U q volpT q χ r pU qe´β c 2 prq{2 .
To derive the formula for the trumpet (25) from (164), we need to transform the boundary condition at the "small end" to the boundary condition that can be glued using the gluing rule (20). We will do this using an indirect argument. First, the corresponding formula for the double trumpet with fixed representation boundary conditions is Z gauge 0 pβ 1 , r 1 ; β 2 , r 2 q " ż T dU volpT q det g K p1´U q dimpr 1 q dimpr 2 qχ r 1 pU qχ r 2 pU´1qe´β 1 c 2 pr 1 q{2´β 2 c 2 pr 2 q{2 " dimpr 1 q 2 δ r 1 ,r 2 e´p β 1`β2 qc 2 pr 1 q{2 .
This is the result that was reported in (25).

B The case of U(1) symmetry
In this appendix, we write down the partition functions on a general Riemann surface for the special case of U p1q symmetry. The motivation for this case is the complex SYK model, see [35] for recent work. Other references include [28,30]. We can take all the results directly from Appendix A, but since the U p1q case is considerably simpler, and of some interest in its own right, we present it here separately, in brief. The action is given in (30), with boundary condition (31).
The path integral on the disk can be reduced to a path integral over the space looppGq{G. The space of flat connections can be parametrized as A " i dΘ, for which the symplectic form (116) evaluates to Now we parametrize Θ bdy pτ q " ř m‰0 pt Since U p1q is not simply connected, we have to include the winding configurations discussed at the end of Section A.1. The essential point is that a gauge field configuration can have unit holonomy with multiple possible configurations of Θ " 2πn τ β . Summing over different saddles, we get the final answer: We can do a Poisson resummation and rewrite the result (170) as which is a special case of (129) and (161) with U " 1 and V " e βµ . (The volume of the group U p1q evaluated with the metric (128) on the group is p2αq form (43). We emphasize that the path integral (171) does not have a Hilbert space interpretation, and is subtly different from the path integral of a particle-on-a-group, because the zero mode is not being integrated over.
The partition function on the trumpet geometry reduces to a path integral on looppGq{T , but since T " G for U p1q, we will get the same expression as on the right hand sides of (170) and (171). The difference is that if there is a holonomy U " e iϕ on the inner geodesic boundary of the trumpet, then βµ will be shifted to βµ´iϕ.
As an example of a gluing calculation, we discuss the partition function for a double trumpet, which was presented for a general group in Section A.3. There is considerable simplification since the "maximal torus" is the entire group as g K is empty. The factor of volpT q and the integral over U in (153) are simply interpreted as integrals over the holonomy from the one end of the double trumpet to the other, and the holonomy along the waist, respectively. The result is (156).
For a general orientable Riemann surface, we find Z gauge g pβ 1 , µ 1 ; . . . ; β n , µ n q " p8π 2 αq 2g`n´2 2 ÿ qPZ e qβpµ 1`. ..`µnq e´p β 1`. ..`βnq q 2 2 . (172) C AdS-JT gravity plus Yang-Mills theory in the bulk Throughout this paper we have considered either the Yang-Mills theory with a coupling constant that is delta-function peaked on the boundary, or the BF theory with a special non-topological boundary condition. Either way, the theory is topological in the bulk, and this allowed us to be agnostic as to what the gravity theory is, since the full partition function factorized between the gravity sector and the gauge sector (on a given topology).
However, one could also contemplate non-topological gauge theories. A mild version of this is the standard Yang-Mills theory in the bulk, with a uniform coupling constant e 2 . In this case, in a given representation sector, the gauge theory path integral depends on the metric, but only in a very simple way [43] Z Y M g pU 1 ; . . . ; U n q9 ÿ r pdim rq χ χ r pU 1 q . . . χ r pU n q exp "´e 2 Ac 2 prq{2 ‰ , where A is the area of the surface. We would like to make two comments about this.
First, the action of JT gravity can be written as a linear combination of the Euler characteristic, of A and of L where L is the boundary length [76,77]. So in a given representation sector, the effect of the Yang-Mills theory is just to change the coefficient of the A term. This means that JT gravity coupled to Yang-Mills (even with finite coupling) is as solvable as ordinary JT gravity.
Second, in the case where we define JT gravity with asymptotic boundaries rather than boundaries of finite length, the area A will go to infinity. In order to avoid projecting onto a single representation in (173), we will need to take e 2 Ñ 0 in this limit, in such a way that e 2 A is finite. Because we are working in hyperbolic space, the area A will be proportional to the boundary length, and in fact we will find e 2 A Ñ #pβ 1`¨¨¨`βn q where β j are the renormalized lengths of the boundary components, and # is a constant that can be absorbed into a redefinition of β. In the limit of asymptotic boundaries, then, JT gravity coupled to Yang-Mills theory reduces to the rather odd theory we studied in the main text, with e 2 concentrated in a delta function at the boundaries.