Moduli stack of principal bundles

In algebraic geometry, given a smooth projective curve X over a finite field $$\mathbf{F}_q$$ and a smooth affine group scheme G over it, the moduli stack of principal bundles over X, denoted by $$\operatorname{Bun}_G(X)$$, is an algebraic stack given by: for any $$\mathbf{F}_q$$-algebra R,
 * $$\operatorname{Bun}_G(X)(R) = $$ the category of principal G-bundles over the relative curve $$X \times_{\mathbf{F}_q} \operatorname{Spec}R$$.

In particular, the category of $$\mathbf{F}_q$$-points of $$\operatorname{Bun}_G(X)$$, that is, $$\operatorname{Bun}_G(X)(\mathbf{F}_q)$$, is the category of G-bundles over X.

Similarly, $$\operatorname{Bun}_G(X)$$ can also be defined when the curve X is over the field of complex numbers. Roughly, in the complex case, one can define $$\operatorname{Bun}_G(X)$$ as the quotient stack of the space of holomorphic connections on X by the gauge group. Replacing the quotient stack (which is not a topological space) by a homotopy quotient (which is a topological space) gives the homotopy type of $$\operatorname{Bun}_G(X)$$.

In the finite field case, it is not common to define the homotopy type of $$\operatorname{Bun}_G(X)$$. But one can still define a (smooth) cohomology and homology of $$\operatorname{Bun}_G(X)$$.

Basic properties
It is known that $$\operatorname{Bun}_G(X)$$ is a smooth stack of dimension $$(g(X) - 1) \dim G$$ where $$g(X)$$ is the genus of X. It is not of finite type but locally of finite type; one thus usually uses a stratification by open substacks of finite type (cf. the Harder–Narasimhan stratification), also for parahoric G over curve X see and for G only a flat group scheme of finite type over X see.

If G is a split reductive group, then the set of connected components $$\pi_0(\operatorname{Bun}_G(X))$$ is in a natural bijection with the fundamental group $$\pi_1(G)$$.

Behrend's trace formula
This is a (conjectural) version of the Lefschetz trace formula for $$\operatorname{Bun}_G(X)$$ when X is over a finite field, introduced by Behrend in 1993. It states: if G is a smooth affine group scheme with semisimple connected generic fiber, then
 * $$\# \operatorname{Bun}_G(X)(\mathbf{F}_q) = q^{\dim \operatorname{Bun}_G(X)} \operatorname{tr} (\phi^{-1}|H^*(\operatorname{Bun}_G(X); \mathbb{Z}_l))$$

where (see also Behrend's trace formula for the details) A priori, neither left nor right side in the formula converges. Thus, the formula states that the two sides converge to finite numbers and that those numbers coincide.
 * l is a prime number that is not p and the ring $$\mathbb{Z}_l$$ of l-adic integers is viewed as a subring of $$\mathbb{C}$$.
 * $$\phi$$ is the geometric Frobenius.
 * $$\# \operatorname{Bun}_G(X)(\mathbf{F}_q) = \sum_P {1 \over \# \operatorname{Aut}(P)}$$, the sum running over all isomorphism classes of G-bundles on X and convergent.
 * $$\operatorname{tr}(\phi^{-1}|V_*) = \sum_{i = 0}^\infty (-1)^i \operatorname{tr}(\phi^{-1}|V_i)$$ for a graded vector space $$V_*$$, provided the series on the right absolutely converges.