text:
\chapter{Sites and stacks}\label{chap:stacks}
In this chapter, we will give a general treatment of stacks on a site.
Our aim is to develop a general theory of geometric stacks which resembles that of stacks over differentiable manifolds.
The focus of our treatment is to relate geometric stacks on a well behaved site $\C$ to groupoids internal to $\C$.

A significant background in category theory is not necessary to understand our work here.
However, it is not possible (or advisable) to completely avoid category theory and we will apply simple categorical reasoning when appropriate.
After all, the objects of study (stacks) are inherently categorical.
The author also hopes that the following will provide a reasonable bridge between category theory and geometry and hence we use a language that is intelligible to a person in either subject.
This chapter will proceed as follows:
\begin{itemize}
  \item In Section~\ref{section:categories_and_topology} we will introduce our notation and recall the basic definitions for categories as well as establish the notion of a category with topology.
  \item In Section~\ref{section:stacks} we will proceed to define categories fibered in groupoids and stacks and provide a precise definition for what we mean by \emph{geometric} stack.
  \item In Section~\ref{section:groupoids} we will define what we mean by a groupoid internal to a site. We will then proceed to define the functor $\B$ which will relate groupoids to geometric stacks. This section will conclude with a proof of Theorem~\ref{thm:chapter1} which states that $\B$ is an equivalence.
  \item In Section~\ref{section:examples1} we will take a look at a few simple example of sites to which we can apply our results.
\end{itemize}
The general strategy we will use is piecemeal borrowed from a variety of expository texts on the subject. In particular, our work is guided by Xu and Behrend~\cite{PXstacks} as well as Metlzer~\cite{Mstacks} which have both written excellent treatments of the subject.
Lerman~\cite{LOrbifolds} and del Hoyo~\cite{MR3089760} also provided the author with significant inspiration and intuition. Lastly, another short treatment of the main theorem of this chapter, in the setting of smooth manifolds, can be found in Blohmann~\cite{BlohmannSLGs}.
\section{Categories and topology}\label{section:categories_and_topology}
\subsection{Notation}
Categories will play a central role in both the study of groupoids and sites. It will be convenient to recall our basic definitions and notation.

\begin{definition}\label{defn:category}
A \emph{category} $\C$ is composed of a collection $\C_0$ called the objects, and a collection $\C_1$ called the morphisms, together with the following:
\begin{itemize}
\item to every morphism $f \in \C_1$ we associate two objects $M$ and $N$ called the \emph{source} and \emph{target} of $f$ respectively. This situation is summarized by the notation: $f\colon M \to N$;
\item to every object $M \in \C_0$ we associate a morphism $\Id_M$ called the \emph{unit} of $M$;
\item to every pair of morphisms $f\colon M \to N$ and $g \colon N \to O$ we associate a morphism $g \circ f\colon M \to O$.
\end{itemize}
This data must satisfy the following axioms:
\begin{enumerate}[(C1)]
\item the source and target of $\Id_M$ is $M$,
\item the source of $f \circ g$ is the source of $f$,
\item the target of $f \circ g$ is the target of $f$,
\item given any $f\colon M \to N$ and $\Id_M\colon M \to M$ then $f \circ 1_M =f$,
\item given any $f\colon M \to M$ and $\Id_M\colon y \to y$ then $\Id_M \circ f = f$,
\item given any three morphisms $f,g$ and $g$ then $(h \circ g) \circ f = h \circ (g \circ f)$ whenever defined.
\end{enumerate}
\end{definition}
\begin{example}[Sets]
The category whose objects are sets and whose morphisms are set theoretic mappings will be denoted by $\Set$.
\end{example}
\begin{example}[Topological spaces]
The category whose objects are topological spaces and whose morphisms are continuous mappings will be denoted by $\Top$.
\end{example}
\begin{example}[Smooth manifolds]
The category whose objects are smooth manifolds and whose morphisms are smooth maps will be denoted by $\Man$.
\end{example}
\begin{example}[Open sets]
  Given a topological space $X$, then we will denote the category whose objects are open subsets of $X$ and morphisms are given by subset inclusions.
\end{example}
\begin{example}[Opposite category]
  Suppose $\C$ is any category. Then we can construct a new category $\C^{op}$ called the \emph{opposite category} for which the source and target are swapped, and the order of composition is reversed.
\end{example}

Given any two objects, $M$ and $N \in \C_0$, we denote by $\Hom(M,N)$ the subcollection of $\C_1$ which consists of morphisms whose source is $M$ and target is $N$. Sometimes we may write $\End(M)$ to denote $\Hom(M,M)$ the \emph{endomorphisms} of $M$.

Given an arbitrary object $M \in \C$, then a \emph{generalized element} $x$ is a morphism $x$ whose codomain is $M$.
Generalized elements and morphisms will be distinguished by our notation.
For example, generalized elements of $M$ will usually be denoted by $x$ or $y$ whereas morphisms in $\C$ are denoted by $f$ or $g$.
One can `push forward' generalized elements along a morphisms  $f \colon M \to N$ by taking $f(x) := f \circ x$ which is a generalized element of $N$.

\begin{example}[Slice category]
  Given any category $\C$ and an object $M$ in $\C_0$, one can define a new  category $\C/M$ called the \emph{slice category of} $M$.
  An object in $\C/M$ is a morphism $f\colon N \to M$.
  A morphism in $\C/M$ is a commutative triangle:
  \begin{equation}\label{eqn:slice}
  \begin{tikzcd}
    N_2 \arrow[r, "f_1"] \arrow[d, "g"] & M \arrow[d, "1_M" swap] \\
    N_2 \arrow[r, "f_2"] & M \\
  \end{tikzcd}
\end{equation}
where the source is $f_1$, the target is $f_2$ and composition is defined by composing in $\C$ vertically.
\end{example}
\begin{definition}
A \emph{commutative} square consists of four morphisms illustrated below:
\[
\begin{tikzcd}
  M \arrow[r, "f"] \arrow[d, "h"] & N \arrow[d, "g"] \\
  O \arrow[r, "k"]                & P
\end{tikzcd}
\]
such that $g \circ f = k \circ h$. A commutative square is a \emph{pullback square} if for any $f' \colon M' \to N$ and $h' \colon M' \to O$ there is a unique morphism $e \colon M' \to M$ such that $f \circ e = f'$ and $g \circ e = g'$.

The pullback property implies that $g$ and $k$ define $M$ up to a unique isomorphism. For this reason we may write $M = O \times_{g,k} N$ or $M = O \times_P N$ and call $M$ the \emph{fiber product} of $k$ and $g$. Following this notational convention, we may use $f' \times h'$ or $(f', h')$ to denote the unique morphism defined by the universal property (called $e$ above). $\pr_1$ and $\pr_2$ will denote the projection maps $O \times_P N \to O$ and $O \times_P N \to N$, respectively.

For most categories, when fiber products exists there is a canonical such object. However, the universal property only guarantees uniqueness up to a unique isomorphism. To justify our use of the notation $O \times_{g,k} N$ we will assume that for any given category, we have made a choice of fiber product for every pair of morphisms $g$ and $k$ such that the fiber product exists.
For example, when $C = \Set$ then the most natural choice is the set $\{ (x,y) : g(x) = k(y) \}$.
\end{definition}
\begin{definition}
  Given a morphism $f \colon M \to N$ in a category $\C$, we say that $f$ is an \emph{isomorphism} if there exists a morphism such that $ f \circ g = \Id_N$ and $g \circ f = \Id_M$. In such a case, we may write $g = f\inv$.

  A morphism is $f \colon M \to N$ is called \emph{cartesian} if for all $g \colon M' \to N$ the fiber product $M' \times_M M$ exists. How strong the cartesian condition is depends on how many fiber products the category admits. For instance, in the category of manifolds the cartesian maps are the (local) submersions. On the other hand, in the category of sets every morphism is cartesian.
\end{definition}

\begin{definition}\label{defn:functor}
  A \emph{functor} $F\colon \C \to \D$ is a pair of mappings of collections $F_i \colon \C_i \to \D_i$, $i=0,1$ such that $F$ respects the source, target, and composition relationships. That is:
  \[  \left(f\colon M \to N \right)\, \mapsto \,  \left(F_1(f)\colon F_0(M) \to F_0(N)\right) \quad \mbox{ and } \quad F_1(f \circ g) = F_1(f) \circ F_1(g). \]
  For general categories, we will typically omit the subscripts in $F_0$ and $F_1$ for brevity.

  A functor $F\colon \C \to \D$ is called
  \begin{itemize}
    \item \emph{full} if the mapping $\Hom(M,N) \to \Hom(F(M),F(N))$ is surjective,
    \item \emph{faithful} if that same mapping is injective,
    \item \emph{fully faithful} if both of the above hold,
    \item \emph{surjective on objects} if $F_0$ is surjective,
    \item \emph{essentially surjective on objects} (or just \emph{essentially surjective}) if every object in $\D$ is isomorphic to one in the image of $F_0$,
    \item an \emph{isomorphism} if there exists another functor $G\colon \D \to \C$ such that $F \circ G$ and $G \circ F$ are identity functors, \item an \emph{equivalence of categories} if it is both essentially surjective and fully faithful.
  \end{itemize}
\end{definition}
\begin{remark}
  We do not assume that our categories are \emph{concrete} (meaning that they have a fully faithful functor into the category of sets).
  For this reason, all definitions of morphisms or proofs of equalities of morphisms should technically be done without reference to `points' or `elements'. However, the notation for composition of morphisms can be cumbersome and most computations done in terms of elements can be turned into computations involving compositions of morphisms in some category.

  Our use of the generalized element notation helps to alleviate this problem.
  For instance, if we want to define a morphism $f \colon M_1 \times_X M_2 \to N_1 \times_Y N_2$.
  Then we may write:
  \[ f(m_1,m_2) := (f_1(m_1),f_(m_2)) \, . \]
  Formally, this means $f := (f_1 \circ \pr_1) \times (f_2 \circ \pr_2)$. The expression can be made precise if we think of $m_1$ as the generalized element $\pr_1 \colon M_1 \times_X M_2 \to M_1$ and $m_2$ as the generalized element $\pr_2 \colon M_1 \times_X M_2 \to M_2$.
\end{remark}
\subsection{Grothendieck topology}
The categories that we are interested in come with topological structures.
The concept of a Grothendieck topology allows us to explore the consequences of such a structure in the abstract.
We will begin with the concept of a sieve, which is just a collection of morphisms closed under right composition. Throughout this subsection, $\C$ is a fixed category.

\begin{definition}\label{sieve}
  A \emph{sieve $S$ on an object $M \in \C_0$} is a (possibly empty) collection of morphisms whose target is $M$, such that $S$ is closed under precomposition. That is, for all $f \in S$ and $g \in \C_1$ then $f \circ g \in S$ whenever it is defined.
\end{definition}
Let us make a few remarks about sieves:
  \begin{itemize}
    \item An arbitrary subcollection $S' \subset \Hom(-,M)$ defines always defines a sieve $S := \{ f \circ g : f \in S', \, g \in \C_1 \}$. In such a case we say that $S$ is \emph{generated by} $S'$.
    \item Given a sieve $S$ on $M$ and a morphism $g \colon N \to M$, the collection $g^* S := \{ f \colon g \circ f \in S \}$ is called the \emph{pullback sieve} along $g$.
    \item Given two sieves $S$ and $T$ on $M$, the intersection $S \cap T$ is also a sieve.
    \item Give a sieves $S = \{ s_i \colon U_i \to M \}_{i \in I}$ and $T = \{ t_j \colon V_j \to M \}_{J \in J}$ let $S \times_M T$ denote the collection of fiber products $\{s_i \times_M t_j \}_{(i,j) \in I \times J}$.
    $S_1 \times_M S_2$ is a sieve. However, if either $S_1$ or $S_2$ is generated by cartesian morphisms, then $S_1 \times_M S_2$ generates $S_1 \cap S_2$.

    When $S = T$ we denote the elements of $S \times_M S$ by $\{ s_{i j} \colon U_{i j} \to M \}$. We extend this notation to higher products as well, where $s_{ijk} \colon U_{ijk} \to M$ denotes the map $U_i \times_M U_j \times_M U_k \to M$.
  \end{itemize}
  We can now define a Grothendieck topology. Roughly speaking, a Grothendieck topology is a collection of distinguished sieves which are designated covering sieves.
  Covering sieves should roughly behave like a sieve generated by open embeddings whose images cover the target.
  \begin{definition}\label{defn:grotop}
    A Grothendieck topology on a category $\C$ is an assignment to each object $M$, a collection of subsets of $\Hom(-,M)$ called \emph{covering sieves}. This assignment must satisfy the following properties:
  \begin{enumerate}[(T1)]
      \item The whole of $\Hom(-,M)$ is a covering sieve of $M$.
      \item If $S$ is a covering sieve of $M$ and $g\colon Y \to M$ is any morphism, then the pullback $g^*S$ is a covering sieve of $Y$.
      \item Suppose $S$ is a covering sieve on $M$ and $T$ is an arbitrary sieve on $M$ such that $g^*T$ is a covering sieve for all $g \in S$. Then $T$ is a covering sieve.
  \end{enumerate}
  \end{definition}
  The condition (T2) should be interpreted as being analogous to the fact that the inverse image of an open cover is an open cover. (T3) is corresponds to the observation that a collection of subsets is an open cover if and only if it covers every element of a covering. In practice, defining a Grothendieck topology is often easier to do in terms of generators called covering families.
\begin{definition}\label{defn:pretop}
Let $\C$ be a category.
A Grothendieck pre-topology is an assignment to each object $M$ in $\C$ of a collection of subcollections of the set $\Hom(-,M)$ called \emph{covering families}.
This assignment must satisfy some properties.
\begin{enumerate}[(PT1)]
\item If $f\colon N \to M$ is an isomorphism then $\{ f \}$ is a covering family.
\item If $\{ u_i\colon N_i \to M \}$ is a covering family then each $u_i$ is cartesian and $\{ \pr_2\colon N_i \times_M N \to N \}$ is a covering family of $N$.
\item If ${\{ u_i\colon N_i \to M \}}_{i \in I}$ is a covering family of $M$ and ${\{ N_{ij} \to N_i \}}_{j \in J_i}$ is covering family of $N_i$ for each $i$, then the compositions $\{ N_{ij} \to N_i \to M \}$ constitute a covering family of $M$.
\end{enumerate}
To a pre-topology, we associated a Grothendiek topology by defining the covering sieves to be those sieves which are generated by covering families.
\end{definition}
\begin{example}
  We can equip the category of open subsets of a topological sets $X$ with a pre-topology by defining $\{ u_i: U_i \into U \}$ be a covering family if $\bigcup U_i = U$. That is, a covering family is a covering in the conventional sense.
\end{example}
\begin{example}\label{example:pretopman1}
If $\C = \Man$, then we can give $\Man$ the following pre-topology: a covering $\{ u_i\colon U_i \to M \}$ of manifold $M$ is a collection of \'etale smooth maps $u_i$ whose images cover $M$.
This is the same pre-topology used in~\cite{PXstacks}.
\end{example}
\begin{example}\label{example:pretopman2}
If $\C = \Man$, then we can give $\Man$ the following pre-topology: a covering $\{ u_i\colon U_i \to M \}$ of manifold $M$ is a collection of open embeddings $u_i$ whose images cover $M$.
\end{example}

While Example~\ref{example:pretopman1} and Example~\ref{example:pretopman2} are different pre-topologies, it is easy to check that they generate the same Grothendieck topology.

\begin{definition}\label{defn:site}
  A \emph{site} is a category $\C$ together with a Grothendieck topology
\end{definition}
\section{Stacks}\label{section:stacks}

\subsection{Fibered categories}
There are a few different ways to present the subject, but for our purposes a fibered category will be a functor into $\C$ satisfying certain properties.
We will typically denote the domain of this functor with $\X$, $\Y$, or $\Zcal$. Objects in these categories will be typically denoted with upper case letters $X$, $Y$ and $Z$, while morphisms will be denoted $a$, $b$, and $c$.
\begin{definition}\label{defn:cfg}
A \emph{category fibered in groupoids} (abbreviated CFG) over a category $\C$ is a category $\X$ together with a functor $\pi\colon \X \to \C$ such that the following properties hold.
\begin{enumerate}[(CFG1)]
\item Given any morphism $f\colon M \to N$ in $\C$ and object $Y$ in $\X$ such that $\pi(Y) = N$, then there exists a morphism $a\colon X \to Y$ in $\X$ such that $\pi(a)=f$.
\[
\begin{tikzcd}
   \exists X \arrow[dashed, r, "\exists a"] \arrow[dash, d] & Y \arrow[dash, d] \\
   M \arrow[r, "f"] & N
\end{tikzcd}
\]
\item Given morphisms $f\colon M_1 \to M_2$ and $g\colon M_2 \to M_3$ in $\C$ together with $a\colon X \to Z$ and $b\colon Y \to Z$ such that $\pi(a) = g \circ f$ and $\pi(b) = g$, then there exists a unique morphism $c$ such that $\pi(c) = f$ and $b \circ c = a$.
\[
\begin{tikzcd}
  X \arrow[dash, d] \arrow[rr, bend left, "a"] \arrow[r, dashed, "\exists! c"] & Y \arrow[dash, d] \arrow[r, "b"] & Z\arrow[dash, d] \\
  M_1 \arrow[r, "f"]& M_2 \arrow[r, "g"] & M_3
\end{tikzcd}
\]
\end{enumerate}
\end{definition}
\begin{example}
  Given any object $M$ in $\C$, let $\bar{M}$ denote the slice category of $M$. Let $\pi\colon \bar{M} \to \C$ be the functor:
  \[
  \left(\begin{tikzcd}
    N_1 \arrow[d, "g"]\arrow[r, "f_1"] & M \arrow[d, equal] \\
    N_2 \arrow[r, "f_2"] & M
  \end{tikzcd}\right)
  \mapsto g \colon N_1 \to N_2
  \]
  It is straightforward to verify that this functor satisfies the axioms of a category fibered in groupoids.
  \end{example}
  \begin{example}
    Let $F \colon \C^{\mathbf{op}} \to \mathbf{Set}$ be a presheaf. That is, $F$ is a contravariant functor from $\C$ to the category of sets. Then we can define a CFG over $\C$ as follows. The object collection of $\X$ is defined to be the disjoint union of the sets $F(M)$ for each object $M$ in $\C$. There is a morphism $a \colon X \to Y$ in $\X$ if and only if there exists an $f$ such that $F(f)(Y) = X$.
  \end{example}
The name `fibered in groupoids' arises from the following observation.
Fix an object $M$ of $\C$ and consider the subcategory $X_M$ which is defined as below:
\[ (\X_M)_0 := \{X \in \X_0 : \pi(X) = M \} \qquad (\X_M)_1 := \{ a \in \X_1 : \pi(a) = 1_M \} \, . \]
\begin{lemma}\label{lemma:CFGgroupoid}
  $\X_M$ is a groupoid. That is, every morphism in $\X_M$ has an inverse.
\end{lemma}
\begin{proof}
  Let $a\colon X \to Y$ be a morphism in $\X_M$. Then consider the following diagram:
  \[
  \begin{tikzcd}
    Y \arrow[dash, d] \arrow[rr, bend left, "1_Y"]  & X \arrow[dash, d] \arrow[r, "a"] & Y\arrow[dash, d] \\
    M \arrow[r, "1_M"]& M \arrow[r, "1_M"] & M
  \end{tikzcd}
  \]
  (CFG2) says that there exists a unique $b: Y \to X$ such that $a \circ b = 1_Y$.
  This shows that $a$ admits a left inverse. On the other hand, consider the related diagram:
  \[
  \begin{tikzcd}
    X \arrow[dash, d] \arrow[rr, bend left, "a"]  & X \arrow[dash, d] \arrow[r, "a"] & Y\arrow[dash, d] \\
    M \arrow[r, "1_M"]& M \arrow[r, "1_M"] & M
  \end{tikzcd}
  \]
  We can see immediately that both $b \circ a$ and $1_X$ satisfy the existence invoked in (CFG2) and, since such a morphism must be unique, they are equal.
\end{proof}
The objects guaranteed by (CFG1) are called a \emph{pullback} of $Y$ along $f$ and we will denote them by $f^*Y$ or $Y|_M$.
Due to the fact that the pullback is only unique up to a unique isomorphism, this is a slight abuse of notation.
Generally, in the following text one should interpret statements about $f^* Y$ and $Y|_M$ as holding for an arbitrary choice of pullback representative.
Hence, we are claiming implicitly that our arguments and definitions are invariant under this choice.

Linguistically, we think of a CFG $\X$ as sitting `above' $\C$.
Hence a morphism in $a \in \X$ is said to \emph{over} a morphism $f$ in $\C$ if $\pi(a) = f$.
Similarly, an object $X \in \X$ is said to be \emph{over} $\pi(x) \in \C$.

\begin{lemma}
Given $\pi(Y) = N$ and $f: M \to N$, then $f^* Y$ is unique up to a unique isomorphism. That is, suppose we are given $a_1 \colon X_1 \to Y$ and $a_1 \colon X_1 \to Y$ such that $\pi(a_i) = f$ for $i = 1,2$.
Then there exists a unique isomorphism $b: X_1 \to X_2$ such that $a_2 \circ b = a_1$.
\end{lemma}
\begin{proof}
  Suppose there exists $a_1 \colon X_1 \to Y$ and $a_2\colon X_2 \to Y$ such that $\pi(a_1) = \pi(a_2) = f$. Then we have a diagram:
  \[
  \begin{tikzcd}
    X_1 \arrow[dash, d] \arrow[rr, bend left, "a_1"]  & X_2 \arrow[dash, d] \arrow[r, "a_2"] & Y\arrow[dash, d] \\
    M \arrow[r, "1_M"]& M \arrow[r, "f"] & N
  \end{tikzcd}
  \]
  Then (CFG2) tells us that there exists a unique morphism $b$ such that $a_2 \circ b = a_1$.
  Since $b \in \X_M$, Lemma~\ref{lemma:CFGgroupoid} tells us that $b$ is an isomorphism.
\end{proof}
\begin{definition}\label{defn:morphismofcfgs}
A morphism of CFGs $\F\colon \X \to \Y$ is a functor which commutes with the projections to $\C$.
A morphism of CFGs is called an \emph{isomorphism} if it is an equivalence of categories.
A 2-morphism $\eta\colon \F_1 \to \F_2$ is a (necessarily invertible) natural transformation of functors.
\end{definition}
\begin{definition}
  A CFG is called \emph{representable} if it is isomorphic to $\bar M$ for some object $M \in \C$.
\end{definition}
Formally, this notion of morphisms and 2-morphisms makes CFGs over $\C$ into a strict bicategory (see Definition~\ref{defn:strict2category}). We will keep the more cumbersome technical results regarding bicategories in the appendix for the sake of brevity.
The above bicategory data is clearly coherent since it is strict.
Bicategories have their own version of the fiber product which we call the \emph{homotopy fiber product} and is denoted with $\til\times$ (see Definition~\ref{defn:2pullback}).

\subsection{Stacks}\label{subsection:stacks}

A stack is just a CFG over a site which satisfies some `gluing' axioms. These axioms can roughly be translated as saying that both morphisms and objects are constructed from local data. Before we state the definition, we should clarify a minor bit of notation:

Let $\X$ be a CFG over $\C$. Let $u \colon U \to M$ be a morphism in $\C$
 and $\phi\colon P \to Q$ be a morphism in $\X$ covering $\Id_M$. Given pullbacks $P|_U$ and $Q|_U$, then we denote by $\phi|_U: P|_U \to Q|_U$ the unique morphism such that:
  \[
  \begin{tikzcd}
    P \arrow[r, "\phi"] & Q \\
    P|_U \arrow[u] \arrow[r, "\phi|_U"] & Q|_U \arrow[u]
  \end{tikzcd}
  \]
  commutes.
The existence and uniqueness of this morphism is an immediate consequence of (CFG2).

\begin{definition}\label{defn:stack}
A CFG $\X$ over a site $\C$ is called a \emph{stack} if it satisfies:
\begin{enumerate}[(S1)]
  \item Given the following data:
    \begin{itemize}
      \item a covering sieve ${\{ s_i \colon U_i \to M \}}_{i \in I}$,
      \item objects $P$ and $Q$ in $\X_M$,
      \item morphisms $\phi_i \colon P|_{U_i} \to Q|_{U_i}$ covering the identity,
    \end{itemize}
    such that for all $s_i$ and $s_j$:
  \[ \phi_i|_{U_{ij}} = \phi_j|_{{U_{ij}}} \, . \]
  There exists a unique morphism $\phi: P \to Q$ such that $\phi|_{P|_{U_i}} = \phi_i$.
\item Given the following data:
      \begin{itemize}
        \item a covering family ${\{ s_i \colon U_i \to M \}}_{a \in A}$ of an object $M$ in $\C$,
        \item a collection of objects ${\{ P_i \in \X_{U_i} \}}_{i \in A}$,
        \item morphisms $\phi_{ij}: P_j|_{U_{ij}} \to P_i|_{U_{ij}}$
      \end{itemize}
        such that, for all $i,j,k \in I$, $\phi_{ij}|_{U_{ijk}} \circ \phi_{jk}|_{U_{ijk}} = \phi_{ik}|_{U_{ijk}}$.

        There exists an object $P$ over $M$ together with morphisms ${\{ \phi_i: P|_{U_i} \to P_i \}}_{i \in A}$ such that
        \[ \phi_{ij} \circ \phi_{j}|_{U_{ij}} = \phi_i|_{U_{ij}}. \]
\end{enumerate}
A CFG which satisfies at least (S1) is called a \emph{pre-stack}.
\end{definition}
\begin{example}
  Let $\C$ be any site. Then $\Id_\C \colon \C \to \C$ is a stack. It is representable if and only if $\C$ has a terminal object.
\end{example}
\begin{example}
  Let $\C$ be any site, then any representable CFG $\X \isom \C/M$ is a stack if and only if $\Id \colon \C \to \C$ is a (pre-)stack.
\end{example}
\begin{example}
  Let $\C$ be the site of smooth manifolds and let $G$ be a Lie group. Then $\B G$, the category of principal $G$-bundles, is a stack.
\end{example}
\begin{example}
  Let $F\colon \C^{op} \to \mathbf{Set}$ be a presheaf. Then the associated CFG $\X$ is a pre-stack if an only if it satisfies the locality axiom, i.e.:
  \[ s|_{U_i} = t|_{U_i} \quad \forall U_i \quad \Rightarrow \quad s = t \, . \]
  Furthermore $F$ is a sheaf if and only if $\X$ is a stack.
\end{example}
\subsection{Morphisms of stacks}

Morphisms of stacks are defined to be morphisms of the underlying CFGs.
In this subsection we will review a few important classes of such morphisms.
\begin{definition}
  Let $F: \X \to \Y$ be a morphism of CFGs over a site.
  \begin{itemize}
  \item We say $F$ is \emph{locally essentially surjective} or an \emph{epimorphism} if for any object $Y \in \Y_M$, there is a covering sieve ${\{ U_a \}}_{a \in A}$ of $M$ such that each $Y|_{U_a}$ is isomorphic to an object in the image of $F$.
  \item We say $F$ is \emph{representable} if for any morphism $\bar{M} \to \Y$ with $M \in \C$, the fiber product $\X \til\times_\Y \bar{M}$ is representable.
  \item We say $F$ is a \emph{submersion} if it is a representable epimorphism.
  \item We say $F$ is a \emph{monomorphism} if it is fully faithful.

\end{itemize}
\end{definition}

There is a one-to-one correspondence between morphisms of representable stacks $F: \bar{M} \to \bar{N}$ and morphisms $F'\colon M \to N$ in $\C$. In other words, the functor $M \mapsto \bar{M}$ is fully faithful (the Yoneda lemma).
We should clarify that that for our examples, the term submersion will actually correspond to \emph{surjective} submersions.
\begin{example}\label{ex:morphismsofreps}
  Let $f\colon M \to N$ be a morphism in $\C$ and let $\bar{f}\colon \bar M \to \bar N$ be the associated morphism of representable CFGs. Then $\bar f$ is an epimorphism if and only if $f$ admits local sections. That is there exists a covering $S = \{ s_i \colon U_i \to M \}$ of $N$ together with morphisms $\{ \sigma_i \colon U_i \to M \}$ such that $f \circ \sigma_i = s_i$ for all $s \in S$.
  \[ \begin{tikzcd}
    & U_i \arrow[dr, "{s_i}"] \arrow[dl, dashed, "{\exists \sigma_i}" swap] & \\
    M \arrow[rr, "f"] & & N
  \end{tikzcd} \]

  The functor $\bar f$ is always a monomorphism. Lastly, $\bar{f}$ is representable if and only if it is cartesian. Generally, we will say that a morphism $f$ in a site $\C$ is a submersion if and only if $\bar{f}$ is a submersion.
\end{example}

\begin{definition}
  A stack $\X$ is \emph{geometric} or \emph{presentable} if there exists a submersion (i.e. a representable epimorphism) $\bar{M} \to \X$.
\end{definition}
The significance of this definition will be made more clear in the next section, where we begin our discussion of groupoids.

\section{Groupoids}\label{section:groupoids}

Throughout this section $\C$ will be some choice of site as defined above. Objects of $\C$ will be denoted with letters such as $M$ and $N$. Our goal is to develop the correspondence between groupoids internal to a site and geometric stacks. We will develop this correspondence in a relatively high level of generality to unify the proofs for specific cases. To begin, we will need to make sure our working conditions are reasonable, and so we will need to make a few additional assumptions about $\C$.

\begin{definition}\label{defn:sub}
To any site $\C$, there is a distinguished class of maps that we call \emph{submersions}. A morphism $f \colon M \to N$ in $\C$ is called a \emph{submersion} if it is cartesian (always admits fiber products) and $f$ admits local sections.
By local sections, we mean that there exists a covering $S = \{ s_i \colon U_i \to M \}$ of $N$ together with morphisms $\{ \sigma_i \colon U_i \to M \}$ such that $f \circ \sigma_i = s_i$ for all $s \in S$.
\[ \begin{tikzcd}
  & U_i \arrow[dr, "{s_i}"] \arrow[dl, dashed, "{\exists \sigma_i}" swap] & \\
  M \arrow[rr, "f"] & & N
\end{tikzcd} \]
The submersions in $\C$ are precisely those morphisms which give rise to submersions of the associated representable stacks (see Example~\ref{ex:morphismsofreps}.)

There is a CFG of submersions which we call $\mathbf{Sub}$.
The objects $\mathbf{Sub}$ are defined to be the submersions in $\C$. The morphisms of $\mathbf{Sub}$ are defined to be pullback squares:
\[
\begin{tikzcd}
  f^* P \arrow[r] \arrow[d] & P \arrow[d, "p"] \\
  N \arrow[r, "f"] & M
\end{tikzcd}
\]
Composition is defined by horizontal composition of pullback squares. The CFG projection $\mathbf{Sub} \to \C$ is defined by:
\[
\begin{tikzcd}
  f^* P \arrow[r] \arrow[d] & P \arrow[d, "p"] \\
  N \arrow[r, "f"] & M
\end{tikzcd}
\mapsto
\begin{tikzcd}
  N \arrow[r, "f"] & M
\end{tikzcd}
\]
It is not difficult to check that $\mathbf{Sub}$ is a CFG. Axiom (CFG1) follows from the fact that submersions are stable under base change, (corollary of Lemma~\ref{lemma:basechangelemma}). Axiom (CFG2) follows from the universal property of pullback squares.
\end{definition}
\begin{definition}\label{defn:goodsite}
  A site $\C$ is \emph{good} if the following hold:
  \begin{enumerate}[(GS1)]
    \item $\C$ has an initial object. That is, there exists an object $\emptyset \in \C$ such that for anther other object $M$ in $\C$, there is a unique morphism $\emptyset \to M$.
    \item Every covering sieve is generated by some set of cartesian morphisms.
    \item Morphisms in $\C$ are local. That is, given a pair of objects $M$ and $N$ together with a covering sieve $S = \{ s_i \colon U_i \to M \}$ on $M$ and maps $f_i \colon U_i \to N$ such that the following diagram commutes:
    \[
    \begin{tikzcd}
     U_{ij} \arrow[d] \arrow[r] &  U_i \arrow[d, "f_i"] \\
     U_j \arrow[r, "f_j"] & N
    \end{tikzcd}
    \]
    there exists a unique morphism $f \colon M \to N$ such that $f \circ s_i = f_i$ for all $s_i$.
    \item The CFG of submersions $\Sub$ (Definition~\ref{defn:sub}) is a stack.
    \item If $f \circ g$ is a submersion, then $f$ is a submersion.
  \end{enumerate}
\end{definition}

The requirement of the existence of an initial object is for fairly minor technical reasons.
For $\Man$ the initial object is the \emph{empty manifold}. We need such an object so that fiber products will exist in cases where the images of the smooth maps are disjoint. We do not require the existence of a terminal object as this fails for some of the examples of sites which we are interested (i.e $\DMan$). The requirement of cartesian generators is necessarily standard either, but it prevents some aberrant behavior and the author is not aware of an example of an interesting site which does not satisfy this property.

Condition (GS3) is necessary since we need a way of constructing new morphisms in $\C$.
It is also reasonable to expect that morphisms in $\C$ are local with respect to the ambient topology.
Note that (GS3) implies that $\Sub$ is a pre-stack and so (GS4) is about gluing of objects.
(GS4) also implies that being a submersion is local in the codomain.
The last condition, (GS5) is needed to prove Lemma~\ref{lemma:invertiblegmor}.
There are weaker versions that suffice to prove this lemma, but we have chosen an easy to state version that resembles the smooth case.

From here on out, and throughout the appendix, we assume that $\C$ is a good site.

\begin{remark}
  For some settings, it may be prudent to be more restrictive with the definition of a submersion. For instance, it may be the case that the set of cartesian epimorphisms do not satisfy (GS5). In this situation, the arguments in this text will still work so long as our designated class of maps satisfy the following properties:
\begin{itemize}
  \item they must be submersions in our weaker sense (cartesian epimorphisms);
  \item they must include isomorphisms;
  \item they must make $\C$ into a good site (i.e. they satisfy (GS4) and (GS5)).
\end{itemize}
In such a setting, one should adjust the definition of a presentation accordingly.
\end{remark}
\subsection{Internal groupoids}

Roughly speaking, an internal groupoid is a groupoid whose arrows and units are objects of a category (or a site). To do this, we will transfer the groupoid data into a collection of morphisms such that a collection of diagrams commutes. Throughout this subsection, $\C$ denotes an

\begin{definition}\label{defn:internalgroupoid}
  A groupoid internal to a site $\C$, also called a $\C$-groupoid, consists of the following data:
  \begin{itemize}
    \item objects $\G$ and $M$ in $\C$ called the arrows and units,
    \item submersions $\s, \t \colon \G \to M$, called the \emph{source} and \emph{target} (see Definition~\ref{defn:sub} for the definition of a submersion in a general site),
    \item morphisms $\u\colon M \to \G$ and $\i \colon \G \to \G$ called the \emph{unit} and \emph{inverse}
    \item a morphism $\m \colon \G \times_{\s,\t} \G \to \G$.
  \end{itemize}
    such that (A)-(F) of Definition~\ref{defn:category} hold (when interpreted as commutative diagrams in $\C$). We also require that the following diagrams commute:
    \begin{enumerate}[(G1)]
      \item ($\i$ is an involution)
      \[
      \begin{tikzcd}
         & \G \arrow[dr, "\i"] & \\
         \G \arrow[ur, "\i"] \arrow[rr, "\Id"] & & \G
      \end{tikzcd}
      \]
      \item (compatibility of $\i$ with $\s$ and $\t$)
      \[\begin{tikzcd}
       & M & \\
       \G \arrow[ur, "\s"] \arrow[rr, "\i"] & & \G \arrow[ul, "\t" swap]
      \end{tikzcd}\]
      \item (compatibility of $\i$ with $\m$)
      \[
      \begin{tikzcd}
        \G \arrow[d, "\t"] \arrow[r, "\Id \times \i"] & \G \times_{\s,\t} \G \arrow[d, "\m"] \\
        M \arrow[r, "\u"] & \G
      \end{tikzcd}
      \]
    \end{enumerate}
\end{definition}
\begin{example}
  A $\Man$-groupoid is called a \emph{Lie groupoid}.
\end{example}
\begin{example}
  Given any $\C$-groupoid $\G \grpd M$, we can construct the \emph{opposite} groupoid $\G^{op}$ for which the source and target maps are reversed, and the multiplication morphism comes from the composition:
   \[  \G \times_{\t, \s} \G \to \G \times_{\s,\t} \G \to \G . \]
\end{example}
\begin{example}
  Any object $M \in \C$ has an associated \emph{trivial groupoid} $1_M$ for which the arrows and objects are both $M$ and the source and target maps are identities.
\end{example}
We will use the notation $G \rightrightarrows M$ to denote a $\C$-groupoid whose arrows are $\G$ and units are $M$. The notation $\G\enn$ will denote the $n$-fold fiber product $\G \times_{\s,\t} \cdots \times_{\s, \t} \G$. By convention we define $\G\zero := M$.

Since $\G$ comes with two morphisms to $M$, there is some ambiguity when writing things such as $\G \times_M N$.
To alleviate this, given $f \colon N \to M$, when we take a fiber product on the right side, as in $\G \times_M N$ we always mean $\G \times_{\s, f} N$.
Similarly, $N \times_M \G = N \times_{f, \t} \G$. From this convention, it should be clear that we think of arrows in the groupoid as going from right to left.

\begin{definition}\label{defn:internalmorphism}
  Let $\G \grpd M$ and $\H \grpd N$ be $\C$-groupoids. A \emph{morphism} of $\C$-groupoids, denoted $F \colon \G \to \H$ consists of two morphisms $F_1 \colon \G \to \H$ and $F_0 \colon M \to N$ such that the following diagrams commute:
  \begin{enumerate}[(GM1)]
  \item (Compatibility of $F$ with $\s$ and $\t$)
  \[
    \begin{tikzcd}
      \G \arrow[d,"\s"] \arrow[r, "F_1"] & \H \arrow[d,"\s"] \\
      M \arrow[r, "F_0"] & N
    \end{tikzcd}
    \quad \mbox{ and } \quad
    \begin{tikzcd}
      \G \arrow[d,"\t"] \arrow[r, "F_1"] & \H \arrow[d,"\t"] \\
      M \arrow[r, "F_0"] & N
    \end{tikzcd}
    \]
    \item
    \[
    \begin{tikzcd}[column sep= large]
      \G\two \arrow[rr, "{(F \circ \pr_1) \times (F \circ \pr_2)}"] \arrow[d, "\m"] & & \H\two  \arrow[d, "\m"] \\
      \G \arrow[rr, "F_1"] & & \H
    \end{tikzcd}
    \]
\end{enumerate}
\end{definition}
\begin{remark}
  We may sometimes denote the multiplication morphism with $\cdot$. For instance, $f \cdot g$ is a synonym for $\m \circ (f \times g)$. Of course, the associativity of $\m$ implies that $(f \cdot g) \cdot h = f \cdot (g \cdot h)$ whenever such morphisms are well defined.
\end{remark}
\subsection{Internal actions}

\begin{definition}\label{defn:action}
Let $\G \grpd M$ be a $\C$-groupoid. Then a \emph{left} $\G$ action on an object $P$ in $\C$ consists of the following data:
\begin{itemize}
  \item a morphism $\t^P \colon P \to M$,
  \item a morphism $\m_L \colon \G \times_M P \to P$
\end{itemize}
such that the following diagrams commute:
\begin{enumerate}[GA1]
  \item (Compatibility of $\m_L$ with units)
  \[\begin{tikzcd}
     & \G \times_M P \arrow[dr, "\m_L"] & \\
     P \arrow[ur, "{(\u \circ J) \times \Id}"] \arrow[rr, "\Id"] & & P
  \end{tikzcd}\]
  \item (Associativity)
  \[
  \begin{tikzcd}[column sep = huge]
    \G \times_M \G \times_M P
    \arrow[d, "{(\m(\pr_1,\pr_2),\pr_3)}" swap]
    \arrow[rr, "{(\pr_1, (\m_L(\pr_2, \pr_3)))}"] & & \G \times_M P \arrow[d, "\m_L"] \\
    \G \times_M P \arrow[rr, "\m_L"]  & & P
  \end{tikzcd}
  \]
\end{enumerate}
A right action is defined in a symmetrical fashion. That is, we swap all instances of $\s$ and $\t$ and write $\m_R$ instead of $\m_L$.
\end{definition}
Like with groupoids, we will sometimes write $f \cdot g$ to mean $\m_L(f \times g)$.

In the case where $\C$ is manifolds or topological spaces. This corresponds to the standard definition of a groupoid action.

\begin{definition}
  Let $\G \grpd M$ be a $\C$-groupoid and $P$, $\m_L^{P}$, $\t^P$ be a left action of $\G$ on $P$ as above. Suppose $Q$, $m_L^Q$ and $\t^{Q}$ is another left $\G$ action. Then we say a morphism $\phi: P \to Q$ is $\G$-equivariant if:
  \begin{enumerate}[(GE1)]
    \item (Preserves the anchor)
    \[\begin{tikzcd}
       & M &
      \\
      P \arrow[ur, "\t^P"] \arrow[rr, "\phi"] & & Q \arrow[ul, "{\t^{Q}}" swap]
    \end{tikzcd}\]
    \item (Preserves the product)
    \[
    \begin{tikzcd}
      \G \times_M P \arrow[d, "\m_L^P"] \arrow[rr, "{(\pr_1,\phi \circ \pr_2)}"] & & \G \times_M Q \arrow[d, "\m_L^Q"] \\
      P \arrow[rr, "\phi"] & & Q
    \end{tikzcd}
    \]
  \end{enumerate}
\end{definition}

\begin{definition} Let $\G \grpd M$ be a $\C$-groupoid. A left $\G$-bundle over an object $N$ in $\C$, consists of a left $\G$ action on $P$, together with a submersion $\s^P \colon P \to M$ such that:
  \begin{enumerate}[GB1]
    \item (compatibility of $\m_L$ with $\s^P$)
    \[
    \begin{tikzcd}
      \G \times_M P \arrow[r, "\m_L"] \arrow[d, "\pr_2"] & P \arrow[d, "\s^P"] \\
      P \arrow[r, "\s^P"] & N
    \end{tikzcd}
    \]
  \end{enumerate}
  Furthermore, we say that the $\G$ is
  \begin{enumerate}[(GB2)]
    \item \emph{almost principal} if $\s^P \colon P \to N$ is a submersion and $\m_L \times \pr_2 \colon \G \times_M P \to P \times_{N} P$ is a submersion
    \item \emph{principal} if it is almost principal and $\m_L \times \pr_2 \colon \G \times_M P \to P \times_{N} P$ is an isomorphism (i.e. diagram (GB1) is a pullback square).
  \end{enumerate}
  Right $\G$-bundles are defined in the obvious symmetric manner.

  A left action on $P$ is called \emph{(almost) principal} if it can be made into a (almost) principal $\G$-bundle over some manifold $N$. Since such a submersion $P \to N$ is unique up to a unique isomorphism (see Lemma~\ref{lemma:equivariantmaps}) it makes sense to write $P /\G$ to indicate some canonical choice of $N$.

  If $P \to N$ and $Q \to N'$ are equipped with the structure of a $\G$-bundle, then a morphism of $\G$-bundles is a pair of maps $\phi \colon P \to Q$ and $f \colon N \to N'$ such that $\phi$ is $\G$-equivariant and the following commutes:
  \begin{enumerate}[(GBM)]
    \item (Compatible with projection)
    \[
    \begin{tikzcd}
      P \arrow[r, "\phi"] \arrow[d, "\s^P"] & Q \arrow[d, "\s^Q"] \\
      N \arrow[r, "f"] & N'
    \end{tikzcd}
    \]
    \end{enumerate}
\end{definition}
A left $\G$-bundle is illustrated with a diagram:
\[
\begin{tikzcd}
\G \darrow & P \laction \arrow[dl, "\t"] \arrow[dr, "\s" swap] & \\
M & & N
\end{tikzcd}
\]
The reader should check that in the case of $\C = \Man$ a principal $\G$-bundle is the standard object.
The morphism $A \colon \G \times_M P \to P \times_N P$ defined by
\[ A(g, p) = (g \cdot p, p) \] is called the \emph{total action}.
Note that the total action is an isomorphism implies the existence of a division map. That is, a morphism $\til \m_L \colon P \times_N P \to \G$ such that:
\[
\til \m_L(p,q) \cdot q = p
\]
The condition that the action is principal implies that the division map is uniquely defined by this property.

Given a $\G$-action on $P$. We say that the action is \emph{principal} if there exists an object $N$ and a submersion $P \to N$ which makes $P$ a principal $\G$-bundle over $N$.
In such a case, we denote $N$ by $P/\G$.
This notation is sensible since, by Lemma~\ref{lemma:equivariantmaps}, $N$ is unique up to a unique isomorphism.

To keep notation from getting out of hand, we will distinguish between $\s^P$ and $\s$ when it is not necessary. We think of ``arrows'' in a $\G$-bundle as going from right to left. For this reason, if $P$ is a \emph{right} $\G$-bundle, the morphism $\t^P$ is the projection to the base instead of $\s^P$.
\begin{example}
  Any $\C$-groupoid $\G \grpd M$ can be made into a $\G$-bundle over $M$ by left multiplication. The inverse of the total action can be constructed directly using the division map on the groupoid $\m \circ (\pr_1 \times (\i \circ pr_2))$.
\end{example}
\begin{example}
  Suppose $P$ is a left $\G$-bundle. Then we can form a right $\G$-bundle called $P^{op}$ whose total space is the same as $P$ and whose source is the target of $P$. The right action is define in the obvious way:
  \[ p \cdot g := \i(g) \cdot p \]
\end{example}
\begin{example}
  Let $\G \grpd M$ be a $\C$-groupoid and suppose $f \colon N \to M$ is a morphism in $\C$. Then $\G \times_M N$ naturally inherits the structure of a left principal $\G$-bundle. Such a bundle is called the \emph{trivial bundle} associated to $f$.
\end{example}
\begin{example}\label{ex:pullbackbundle}
  Suppose $P \to N$ is a principal (left) $\G$-bundle and $f \colon N' \to N$ is a morphism in $\C$. Then there exists a unique $\G$-bundle structure on $f^* P := P \times_N N'$ such that $f^* P \to P$ is a morphism of $\G$-bundles. Such a bundle is called the \emph{pullback} bundle. The multiplication map on $f^* P$ is defined below:
  \[ \m_L^{f^* P}(g,(g',p)) := (g \cdot g',p ) \]

  From this point of view, the trivial bundle associated to a morphism $f \colon N \to M$ is the pullback of $\G$ as a $\G$-bundle. For this reason we will use $f^* \G$ to denote the trivial $\G$ bundle associated to $f$.
\end{example}
A \emph{trivialization} of a $\G$-bundle $P$ is a $\G$-bundle isomorphism $f^* \G \to P$.
Our next lemma gives us some insight into the local geometry of principal $\G$-bundles.
\begin{lemma}\label{lemma:bundletrivialization}
  Suppose $P \to N$ is a principal left $\G$-bundle.
  There is a one-to-one correspondence between trivializations $\phi: f^* \G \to P$ and sections $\sigma \colon N \to P$ such that $\t^P \circ \sigma = f$.
\end{lemma}
\begin{proof}
  Suppose we have an $f \colon N \to M$ and recall $f^* \G := \G \times_M N$. Let $\til \sigma := (\u \circ f, \Id)$ be the canonical section of $f^*\G$. Then $\sigma := \phi \circ \til \sigma$ is a section of $P$. Furthermore, it clearly satisfies $\t \circ \sigma = f$.

  For the other direction of the correspondence, suppose $\sigma \colon N \to P$ is a section. Then we can define
  \[ \phi(g,x) = g \cdot \sigma(x) \, . \]
  That $\phi$ is equivariant is fairly routine. To see that $\phi$ is an isomorphism we will the division map to construct its inverse:
  \[ \phi\inv(p) := (\til \m_L(p,\sigma \circ \s(p)), \s(p)) \]
\end{proof}
\begin{definition}
  Let $\G \grpd M$ and $\H \grpd N$ be $\C$-groupoids. A $(\G, \H)$-bibundle consists of an object $P$ in $\C$ as well as a left $\G$ bundle structure on $P$ and right $\H$ bundle structure on $P$ such that the source and target maps are shared between them. Lastly, we require that:
  \begin{enumerate}[(BB)]
    \item (the actions commute)
    \[
    \begin{tikzcd}[column sep = huge]
      \G \times_M P \times_N \H
      \arrow[rr, "{(\m_L(\pr_1,\pr_2),\pr_3)}"]
      \arrow[d, "{(\pr_1,(\m_R (\pr_2 ,\pr_3))}" swap] & & P \times_N \H \arrow[d, "\m_R"] \\
      \G \times_M P \arrow[rr, "\m_L"] & & P
    \end{tikzcd}
    \]
  \end{enumerate}
  A bibundle is \emph{left(right) principal} if the left(right) action forms a principal left(right) $\G$ bundle over $N$($M$).
  We say that the bibundle is \emph{principal} or \emph{biprincipal} if it is both left and right principal.

  If $P$ and $P'$ are both equipped with $(\G, \H)$-bibundle structures, then a morphism $\phi \colon P \to P'$ is a morphism of $(\G, \H)$-bibundles if it is equivariant with respect to both actions.
\end{definition}
A $(\G,\H)$-bibundle can be illustrated with a diagram of the form:
\[
\begin{tikzcd}
\G \darrow & P \laction \raction \arrow[dl, "\t"] \arrow[dr, "\s" swap] & \H \darrow \\
M & & N
\end{tikzcd}
\]
\begin{example}
  Any $\C$-groupoid $\G \grpd M$ is naturally a biprincipal $(\G, \G)$-bibundle. It is called the \emph{trivial} $(\G,\G)$-bibundle.
\end{example}
\begin{example}
  Suppose $F \colon \G \to \H$ is a $\C$-groupoid homomorphism covering $f \colon M \to N$. Then we can construct a bibundle $P := f^* \H$. The left action on $P$ is the trivial $\H$ action while the left action of $\G$ is defined by the rule:
  \[ (h,x) \cdot g = (h F(g), x) \, . \]
\end{example}
We will take a closer look at this last example in Chapter~\ref{chap:morita}.
\subsection{Generalized morphisms}

Bibundles allow us to generalize weaken the notion of a groupoid morphism. We will see later that this weaker notion of morphism is precisely what is needed to study the stack associated to a $\C$-groupoid.

\begin{definition}
  Let $\G \grpd M$ and $\H \grpd N$ be $\C$-groupoids. A \emph{Hilsum-Skandalis map} or a \emph{generalized morphism} is a left principal $(\G, \H)$-bibundle.

  An \emph{equivalence} of generalized morphisms is a morphism of $(\G,\H)$-bibundles.
\end{definition}
We use the term equivalence due to the fact that all bibundle morphisms are automatically isomorphisms (see Lemma~\ref{lemma:bibundlemorphisms}).
Generalized morphisms can be composed via the following construction.
Let $P$ be a $(\G, \H)$-bibundle and $Q$ be a $(\H, \K)$-bibundle illustrated below:
  \[
  \begin{tikzcd}
  \G \darrow & P \laction \raction \arrow[dl, "\t"] \arrow[dr, "\s" swap] & \H \darrow & Q \arrow[dl, "{\t}"] \arrow[dr, "{\s}" swap] \laction \raction & \K \darrow \\
  M & & N & & O
\end{tikzcd}
  \]
  Consider the object $P \times_{N} Q$ and the canonical morphism $\hat \t \colon P \times_N Q \to N$. Note that this is the target map of a (left) action of $\H$ whose product is given by:
  \[ \hat \m_L(h,(p,q)) := (p \cdot \i(h), h \cdot q)  \]
  By Lemma~\ref{lemma:diagonalaction}, this action is principal. We denote $(P \times_N Q) / \H$ with $P \otimes_\H Q$.

  Notably, $P \otimes Q$ inherits a $(\G, \K)$-bibundle structure. The anchor maps are the unique maps which make the below diagram commute:
  \[
  \begin{tikzcd}
     &  \arrow[dl] P \times_N Q \arrow[dd] \arrow[dr] & \\
  M &               & O \\
    & \arrow[ul] P \otimes_\H \arrow[ur] Q
  \end{tikzcd}
  \]
  These maps exist due to Lemma~\ref{lemma:equivariantmaps}. Similarly, the left action map is the unique morphism such that the diagram below commutes.
  \[
  \begin{tikzcd}[column sep = huge]
  \G \times_{M} P \times_N Q \arrow[rr, "(\m_L ( \pr_1 \times \pr_2)) \times \pr_3"] \arrow[d, "{\Id \times (\pi \circ (\pr_1 \times \pr_2))}"]
  & & P \times_N Q \arrow[d, "\pi"]\\
  \G \times_{M} P \otimes_\H Q \arrow[rr] & & P \otimes_\H Q
  \end{tikzcd}
  \]
  The right action is defined similarly.

  \begin{lemma}
    These actions make $P \otimes_\H Q$ a left principal $(\G, \K)$-bibundle.
  \end{lemma}
  \begin{proof}
  We must show the total action is an isomorphism. Note that that the total action makes the following diagram commute:
  \[
  \begin{tikzcd}
    \G \times_M (P \times_N Q) \arrow[d] \arrow[r] & (P \times_N Q) \times_O (P \times_N Q) \arrow[d] \\
    \G \times_M (P \otimes_\H Q) \arrow[r] & (P \otimes_\H Q) \times_O (P \otimes_\H Q)
  \end{tikzcd}
  \]
  Where the vertical arrows are the projections under the action of $\H$. By Corollary~\ref{corollary:equivariantmaps}, the fact that the top arrow is an isomorphism implies that the bottom arrow is as well.

  Similarly, Corollary~\ref{corollary:equivariantmaps} implies that the left and right actions must commute, since they are obtained by reducing commuting left and right actions modulo $\H$.
  \end{proof}

  \begin{remark}
    We will use tensor product notation for constructing maps involving $P \otimes Q$. For instance, we may sometimes write $f \otimes g$ to denote the post composition of $f \times g$ with the projection $P \times_N Q \to P \otimes Q$. Similarly, if we write:
    \[ p \otimes q \mapsto f(p,q) \]
    We mean to denote the unique morphism obtained from the $\H$ invariant map $f$.
  \end{remark}

  With this product in hand, we can define the bicategory of generalized morphisms.
  \begin{definition}
    Let $\morpoid$ (generalized morphisms) denote the following bicategory:
    \begin{itemize}
      \item The objects of $\morpoid$ are $\C$-groupoids.
      \item The 1-morphisms are generalized morphisms of $\C$-groupoids.
      \item The 2-morphisms isomorphisms of generalized morphisms.
    \end{itemize}
    If $P$ is a $(\G, \H)$-bibundle, then we say the source of $P$ is $\H$ and the target of $P$ is $\G$.
    Composition of generalized morphisms is by the tensor product defined above.
    Vertical composition of 2-morphisms is by composition in $\C$.
    Suppose $P_1$ and $Q_1$ and $(\G, \H)$-bibundles and $P_2$ and $Q_2$ are $\H$, $\K$ bibundles.
    Given 2-morphisms $\alpha \colon P_1 \to P_2$ and $\beta \colon Q_1 \to Q_2$ then vertical composition is the unique 2-morphism $\alpha \otimes_\H \beta$ such that the below diagram commutes.
    \[
    \begin{tikzcd}
      P_1 \times_N Q_1 \arrow[d, "(\alpha \circ \pr_1) \times (\beta \circ \pr_2)" swap] \arrow[r] & P_1 \otimes_\H Q_1 \arrow[d, "\alpha \otimes_\H \beta"] \\
      P_2 \times_N Q_2 \arrow[r] & P_2 \otimes_\H Q_2
    \end{tikzcd}
    \]
    Again, existence and uniqueness of this morphism is given by Corollary~\ref{corollary:equivariantmaps}.

    Given a $\C$-groupoid $\G$, the unit 1-morphism is $\G$ (viewed as a $\G$-bibundle with the obvious actions).
    The left unit $\mathbb{U}_L$ is the unique 2-morphism $\G \otimes_\G P \to P$ obtained by reducing the left multiplication modulo $\G$.
    The right unit is defined similarly.

    Suppose $P_1$, $P_2$ and $P_3$ are $(\G_1, \G_2)$, $(\G_2, \G_3)$, and $(\G_3, \G_4)$-bimodules, respectively. Where $\G_i \grpd M_i$ are $\C$-groupoids.
    Associativity is the unique 2-morphism obtained by reducing the canonical isomorphism:
    \[ (P_1 \times_{M_2} P_2) \times_{M_3} P_3 \to P_1 \times_{M_2} (P_2 \times_{M_3} P_3) \, .  \]
    modulo the actions of $\G_2$ and $\G_3$.
  \end{definition}
  We have omitted the proof that this data satisfies the coherence conditions for a bicategory since we will show later that $\morpoid$ is equivalent to a (strict) bicategory and must therefore be coherent.

  \begin{lemma}\label{lemma:invertiblegmor}
    A generalized morphism is (weakly) invertible if and only if it is biprincipal.
  \end{lemma}
  \begin{proof}
    Suppose $P$ is a biprincipal $(\G,\H)$-bundle for $\C$-groupoids $\G \grpd M$ and $\H \grpd N$. Let $P^{op}$ be the $(\H,\G)$-bibundle obtained by taking the opposite actions on $P$.

    Then we claim that $P \otimes_\H P^{op} \isom \G$ as $\G$-bundles. By the definition of $P \otimes_\H P^{op}$ we have that:
    \[ P \otimes_\H P^{op} = P \times_N P /\H \]
    We have division map $\til \m_L \colon P \times_N P \to \G$ and it is clear that $\til \m_L$ is $\H$-invariant.
    By Lemma~\ref{lemma:equivariantmaps} we obtain a morphism $\Phi \colon P \otimes_\H P^{op} \to \G$. Since $\til \m_L$ is $\G$-equivariant we have that $\Phi$ is equivariant and so $\Phi$ is a $\G$-bundle morphism. Since $\Phi$ covers the identity it is an isomorphism (see Lemma~\ref{lemma:principalbundlemorphisms}).
    The argument is symmetric for $P^{op} \times_\G P$.

    On the other hand, suppose $P$ has a weak inverse $Q$. Then since $P \otimes Q \isom \H$ we can conclude that $\t \circ \pr_1 \colon P \times_N Q \to M$ is a submersion. By (GS5) from the definition of a good site, we conclude that $\t$ is a submersion.

    To conclude the proof, we need to show that the right action on $P$ is principal.
    First note that $\s \colon Q \to M$ is a submersion (by a similar argument as before).
    Therefore, we can choose a covering $\{ U_i \to M \}$ of $M$ with sections $\sigma_i \colon U_i \to Q$ of $\s \colon Q \to M$.
    Such sections let us construct a family of maps $U_i \times_M P \to Q \otimes P$ by using the rule:
    \[ (x, p) \mapsto \sigma_i(x) \otimes p \]
    Similarly, we have a family of morphisms:
    \[ U_i \times_M P \times_{\t,\t} P \to (Q \otimes P) \times_{\t,\t} (Q \otimes P) \quad (x,p,q) \mapsto ((\sigma_i(x) \otimes p), (\sigma_i(x) \otimes q))  \]
    By using the division map for the right action on $Q \otimes P$ we get local division maps $\delta_i \colon U_i \times_M \times P \times_{\t,\t} P \to \H$ for the right action on $P$. Since $\C$ is a good site, we can glue the $\delta_i$ together into a global division morphism $\delta \colon P \times_{\t,\t} P \to \H$. That this division map gives inverts the total action follows from the definition of the action on $Q \otimes_\H P$.
  \end{proof}
  \subsection{The classifying stack}

  Suppose $\G$ is a $\C$-groupoid. Then consider the category $\B \G$ such that
  \begin{itemize}
    \item an object in $\B \G$ is a principal $\G$ bundle $P \to N$
    \item a morphism in $\B \G$ is an equivariant map $\phi \colon P \to Q$.
  \end{itemize}
  Observe that there is a natural forgetful functor $\B \G \to \mathbf{Sub}$. This follows from:
  \begin{lemma}\label{lemma:bgtosub}
    Suppose $\G$ is a $\C$-groupoid. Let $P \to N_1$ and $Q \to N_2$ be principal left $\G$-bundles and $\phi \colon P \to Q$ be a $\G$-bundle morphism covering $f \colon N_1 \to N_2$. Then
    \[
    \begin{tikzcd}
      P  \arrow[d] \arrow[r, "\phi"] & Q \arrow[d]\\
      N_1 \arrow[r, "f"] & N_2
    \end{tikzcd}
    \]
    is a pullback square in $\C$.
  \end{lemma}
  \begin{proof}
  We must show that $\til \phi \colon P \to f^* Q = Q \times_{N_2} N_1$ is an isomorphism. In other words, it suffices to prove the lemma in the case where $f = \Id$. Therefore, without loss of generality assume $N_1 = N_2 = N$ and $f = \Id$.

  Let $S = \{ s_i \colon U_i \to N_1 \}$ be a covering sieve such that the the pullback bundles $ \{ s_i^* P \to U_i \}$ and $\{ s_i^*Q \to U_i \}$ admit sections. Let $\phi_i \colon s_i^* P \to s_i^* Q \}$ be defined as below:
  \[
  \phi_i(p,x) := (\phi(p),x)
  \]
  By Lemma~\ref{lemma:principalbundlemorphisms} each $\phi_i$ is invertible. Hence the collection $\phi_i\inv$ defines the inverse of $\phi$ locally. Since $\C$ is a good site, the $\phi_i\inv$ can be glued to obtain a global inverse of $\phi$.
  \end{proof}

The functor $\B \G \to \mathbf{Sub}$ is a faithful inclusion. In general, it is not full or essentially surjective.
Now consider the forgetful functor $\pi:= \B \G \to \C$ which passes to the base of the $\G$-bundle.
  \begin{theorem}
    The functor $\pi \colon \B \G \to \C$ makes $\B \G$ a category fibered in groupoids.
  \end{theorem}
  \begin{proof}
    We must show (CFG1) and (CFG1) from Definition~\ref{defn:cfg}. First of all, (CFG1) follows from the construction of the pullback bundle (Example~\ref{ex:pullbackbundle}).

    To show (CFG2), suppose we are given morphisms $f\colon M_1 \to M_2$ and $g\colon M_2 \to M_3$ in $\C$ together with $a\colon P \to R$ and $b\colon Q \to R$ such that $\pi(a) = g \circ f$ and $\pi(b) = g$. We must show that there exists a unique morphism $c$ such that $\pi(c) = f$ and $b \circ c = a$.
    \[
    \begin{tikzcd}
      P \arrow[d] \arrow[rr, bend left, "a"] \arrow[r, dashed, "\exists! c"] & Q \arrow[d] \arrow[r, "b"] & R\arrow[d] \\
      M_1 \arrow[r, "f"]& M_2 \arrow[r, "g"] & M_3
    \end{tikzcd}
    \]
    Since $\B \G \to \mathbf{Sub}$ is a faithful inclusion, we know that there exists a morphism $c$ which makes the diagram commute. We only need to show that $c$ is $\G$-equivariant. By Lemma~\ref{lemma:bgtosub} we know that we can replace $Q$ with $g^*R$ and $P$ with $f^*g^*R$. Since $f^* g^* R \to g^* R$ is clearly $\G$-equivariant, the theorem follows.
  \end{proof}
  \begin{theorem}\label{thm:bgstack}
    $\B \G$ is a stack.
  \end{theorem}
  \begin{proof}
    We need to show that $\B \G$ satisfies (S1) and (S2) from Definition~\ref{defn:stack}.
    \begin{enumerate}[(S1)]
      \item Suppose we are given the following data:
        \begin{itemize}
          \item a covering sieve ${\{ s_i \colon U_i \to N \}}_{i \in I}$,
          \item objects $P$ and $Q$ in $\B\G_N$,
          \item morphisms $\phi_i \colon P|_{U_i} \to Q|_{U_i}$ covering the identity,
        \end{itemize}
        such that
      \[ \phi_i|_{U_{ij}} = \phi_j|_{{U_{ij}}} \, . \]
      We must show there exists a unique morphism $\phi: P \to Q$ such that $\phi|_{P|_{U_i}} = \phi_i$.
      Since $\B\G \to \mathbf{Sub}$ is an inclusion and $\mbox{Sub}$ is a stack, we already know that there is a morphism $\phi\colon P \to Q$. We must show that $\phi$ is $\G$ equivariant. In other words, we need the following diagram to commute:
      \[
      \begin{tikzcd}
        \G \times_M P \arrow[d, "\m_L"] \arrow[rr, "\pr_1 \times (\phi \circ \pr_2)"] & & \G \times_M Q \arrow[d, "\m_L"]  \\
        P \arrow[rr, "\phi"]  &  & Q
      \end{tikzcd}
      \]
      The maps $P|_{U_i} \to P$ and $Q|_{U_i} \to Q$ generate covering sieves of $P$ and $Q$, respectively. Since we know each $\phi_i \colon P|_{U_i} \to Q|_{U_i}$ is $\G$-equivariant. We can conclude that the above diagram commutes locally. Since $\C$ is a good site, it must commute globally.
      \item Now suppose we are given the following data:
          \begin{itemize}
            \item a covering sieve ${\{ s_i \colon U_a \to N \}}_{i \in I}$ of an object $N$ in $\C$,
            \item a collection of objects ${\{ P_i \in \X_{U_i} \}}_{i \in I}$,
            \item morphisms $\phi_{ij}: P_j|_{U_{ij}} \to P_i|_{U_{ij}}$
          \end{itemize}
            such that, for all $i,j,k \in I$ such that $s_{ijk}$ exists, $\phi_{ij}|_{U_{ijk}} \circ \phi_{jk}|_{U_{ijk}} = \phi_{ik}|_{U_{ijk}}$.

            We must show there exists a principal $\G$-bundle $P$ over $N$ together with morphisms ${\{ \phi_i: P|_{U_i} \to P_i \}}_{i \in I}$ such that
            \[ \phi_{ij} \circ \phi_{j}|_{U_{ij}} = \phi_i|_{U_{ij}}. \]

            Again, we know that there exists $P \to N$ in $\Sub_N$ which satisfies this data. We claim that there is an action of $\G$ on $P$ which makes each $\phi_i$ equivariant. In other words, we must construct a morphism $\m_L \colon \G \times_M P \to P$. To do this, observe that $\{ \G \times_M P_i \to \G \times_M P \}$ generates a covering sieve of $\G \times_M P$. Hence we can treat each left action of $\G$ on $P_i$ as a locally defined left action on $P$. Since these actions are assumed to agree on intersections and $\C$ is a good site, we conclude that they can be glued together into a unique map $\G \times_M P \to P$.
            The resulting morphism will constitute an action since diagrams which commute locally in a good site must commute globally.
    \end{enumerate}

  \end{proof}

\subsection{Geometric stacks}
  So far we have observed that a $\C$-groupoid gives rise to a stack. Let $\mathbf{Stacks}$ be the bicategory of stacks over $\C$. In this section we will extend the relationship $\G \mapsto \B \G$ to a pseudofunctor (see Definition~\ref{defn:pseudofunctor}) of bicategories $\B \colon \morpoid \to \mathbf{Stacks}$ and prove the main properties of $\B$. A pseudofunctor of bicategories is just a map of objects, 1-morphisms, and 2-morphisms, together with a compatibility map relating the compositions.

  We have already defined the action of $\B$ on objects.
  To define $\B$ on 1-morphisms we must construct a morphism of CFGs $\B P \colon \B \H \to \B \G$ for a left principal $(\G,\H)$-bibundle $P$.

  Suppose $Q$ is a principal left $\H$ bundle (i.e. an object of $\B \H$). Then we define $\B P(Q) := P \otimes_\H Q$. Given $\phi\colon Q_1 \to Q_2$ a $\H$-bundle morphism. Then $\B P( \phi) \colon P \otimes_\H Q_1 \to P \otimes_\H Q_2$ is the unique morphism making the following diagram commute:
  \[
  \begin{tikzcd}[column sep = huge]
    P \times_N Q_1 \arrow[rr, "\pr_1 \times (\phi \circ \pr_2)"] \arrow[d] &  &P \times_N Q_2 \arrow[d] \\
    P \otimes_\H Q_1 \arrow[rr, "\B P(\phi)"] & & P \otimes_\H Q_2
  \end{tikzcd}
  \]
  It is clear that $\B P (\phi \circ \psi) = \B P(\phi) \circ \B P(\psi)$ and so $\B P$ is a functor. This defines $\B$ on 1-morphisms.

  Now suppose $\Phi: P_1 \to P_2$ is a $(\G, \H)$-bibundle isomorphism. We must define a natural transformation $\B \Phi \colon \B \P_1 \to \B \P_2$.
  In other words, we need a function $\eta \colon (\B \H)_0 \to (\B \G)_1$. Given an object $Q$ in $\B \G$, let
  \[ \eta(Q) \colon P_1 \otimes_\H Q \to P_2 \otimes Q  \]
  be the unique morphism obtained by reducing $(\Phi \circ \pr_1) \times \pr_2 \colon P_1 \times_N Q \to P_2 \times_N Q$ modulo $\H$.
  Clearly this makes the below diagram commutes for any morphism $\phi$ in $\B\G$ and so $\eta$ defines a natural transformation.
  \[
  \begin{tikzcd}
    P_1 \otimes_\H Q_1 \arrow[r, "\eta(Q_1)"] \arrow[d, "\B P_1 (\phi)"] & P_2 \otimes_\H Q_1 \arrow[d, "\B P_2 (\phi)"] \\
    P_1 \otimes_\H Q_2 \arrow[r, "\eta(Q_2)"] & P_2 \otimes Q_2
  \end{tikzcd}
  \qquad
  \begin{tikzcd}
  p_1 \otimes q_1 \arrow[r, mapsto] \arrow[d, mapsto] &  \Phi(p_1) \otimes q_1 \arrow[d, mapsto] \\
  p_1 \otimes \phi(q_1) \arrow[r, mapsto] & \Phi(p_1) \otimes \phi(q_1)
\end{tikzcd}
  \]
  Suppose $P_1 \colon \H \to \G$ and $P_2 \colon \K \to \H$ are 1-morphisms in $\morpoid$. For $\B$ to be a pseudofunctor, we should exhibit a natural transformation $\B (P_1 \otimes P_2) \isom \B(P_1) \circ \B(P_2)$. In other words, for each object $Q$ in $\B\G$ we need an isomorphism $\mathbb{B}_1(P_1,P_2,P_3) \colon (P_1 \otimes P_2) \otimes Q \to P_1 \otimes (P_2 \otimes Q)$.
  This isomorphism is constructed canonically by the associator of the fiber product in $\C$. Lastly, for each $\C$-groupoid $\G$, we should exhibit a natural isomorphism $\mathbb{B}_2(\G)$ between the functor:
  \[ \B \G \to \B \G \qquad P \mapsto \G \otimes_\G P \]
  and the identity functor on $\B\G$. This natural transformation comes from the canonical isomorphism between $\G \otimes_\G P$ and $P$.

  Technically, to show that $\B$ is a well defined pseudofunctor, we need to check coherence of this data. Since this calculation is straightforward and not particularly enlightening, so we will omit the proof.

  \begin{proposition}
    Let $\G \grpd M$ be a $\C$-groupoid for $\C$ a good site. Then $\B \G$ is a geometric stack.
  \end{proposition}
  \begin{proof}
    Let $p \colon \bar M \to \B \G$ be the functor $f \mapsto f^* \G$.
    That is, it sends a morphism $f \colon N \to M$ to the associated trivial bundle $f^* \G$.
    We claim that $p$ is a presentation of $M$.

    Since every $\G$-bundle is locally trivial, it follows that $p$ is an epimorphism.
    Hence, we only need to show that $p$ is a representable morphism of CFGs.
    Suppose $q \colon \bar N \to \B \G$ is a morphism of CFGs. Without loss of generality, we can assume that $q(g) = g^* q(\Id_N)$.
    Then Lemma~\ref{lemma:bundleispullback} says that there is a pullback square:
    \[
    \begin{tikzcd}
      \bar Q \arrow[r, "\s"] \arrow[d, "\t"] & \bar N \arrow[d, "q"] \\
      \bar M \arrow[r, "p"]           & \B\G
    \end{tikzcd}
    \]
    Which immediately implies that $p$ is representable.
  \end{proof}

  Let $\GStacks \subset \mathbf{Stacks}$ be the full sub-bicategory of geometric stacks. Then the previous result says that we can restrict the codomain of $\B$ to the full sub-2-category of geometric stacks.
  We now state the main theorem of the chapter.
  \begin{theorem}[Fundamental theorem of geometric stacks]\label{thm:chapter1}
    Suppose $\C$ is a good site.
    The pseudofunctor $\B$ is an equivalence between $\morpoid$, the bicategory of $\C$-groupoids and bibundles, and $\GStacks$, the bicategory of geometric stacks.
  \end{theorem}

  Before we proceed to prove this theorem, we should mention some of the context for this result.
  In the case of $\C = \Man$, it is folklore. For instance, one can find a statement and (partial) proof of the result in Blohmann~\cite{BlohmannSLGs}. In the case where $\C$ is the site of topological spaces, we are not aware of a reference which states the above theorem in this form.
  However, since the study of higher structures in $\Top$ is very well developed, the author considers it likely that it is at least an easy corollary of an existing theorem.
  The main utility of the Theorem is not in applying it to a well known site.
  Rather, it is mainly useful for understanding geometric stacks for newly defined or uncommon sites.
  In fact, this is precisely what we will do in Chapter~\ref{chap:dman}.

  There are two (equivalent) definitions of equivalence of bicategories (see Leinster~\cite{Leinster} for a discussion of this). The one that we will use, (and the one that appears in Definition~\ref{defn:pseudofunctor}) is as follows: a pseudofunctor $F$ is an equivalence if and only if $F$ is an equivalence of categories at the level of Hom-categories and $F$ is surjective up to weak equivalences. Hence, we can split the proof of Theorem~\ref{thm:chapter1} into the next two propositions.
  \begin{proposition}
    The pseudofunctor $\B$ is biessentially surjective onto geometric stacks. That is, every geometric stack $\X$ is equivalent to $\B \G$ for some $\C$-groupoid $\G$.
  \end{proposition}
  \begin{proof}
    Suppose $p \colon \bar M \to \X$ is a presentation.
    Lemma~\ref{prop:CFGgroupoidstruct} says that $\bar M \til\times_{\X} \bar M$ is a strict groupoid internal to CFGs.
    Furthermore, since the CFG of arrows is representable, there exists a $\C$-groupoid $\G$ and a 2-pullback square:
    \begin{equation}\label{eqn:biessentiallysurj}
    \begin{tikzcd}
      \bar \G \arrow[r, "\s"] \arrow[d, "\t"] & \bar M \arrow[d] \\
      \bar M \arrow[r]                   & \X
    \end{tikzcd}
  \end{equation}

    We claim that $\B \G$ is equivalent to $\X$. By Lemma~\ref{lemma:stackification} it suffices to show that there exists a pre-stack $\Y$ together with a pair of local equivalences (see Definition~\ref{defn:localequivalence}) $\B \G \from \Y \to \X$.
    Let $\Y$ be defined to be the pre-stack of trivial $\G$ bundles. That is: the objects of $\Y$ are defined to be morphisms $f \colon N \to M$. The morphisms of $\Y$ are isomorphisms $\phi \colon f_1^* \G \to f_2^* \G$.

    The forgetful functor $\Y \to \B\G$ is clearly a local equivalence. We need to construct a local equivalence $E \colon \Y \to \X$.
    Recall that a local equivalence is a fully faithful and locally essentially surjective functor.
    Since $\Y$ has the same objects as $\bar M$, we can define $E \colon \Y \to \X$ to be equal to $p$ at the level of objects.
    Since we are working with CFGs, it suffices to define $E$ for morphisms covering the identity.
    Suppose $\phi \colon f_1^* \G \to f_2^* \G$ is a morphism in $\Y$ covering the identity for $f_i \colon N \to M$.

    By Lemma~\ref{lemma:gbundlecycle} there is a unique $\gamma \colon N \to \G$ such that
    \[ \phi(g,x) = (g \cdot \gamma(x), x) . \]
    Let $\eta \colon \bar M_0 \to \X_1$ be the natural transformation which witnesse the 2-commutativity of Diagram~\ref{eqn:biessentiallysurj}.
    Then we define $E(\phi) := \eta(\gamma)$ where $\gamma \colon N \to M$ is the morphism just described.

    To see that $E$ is a functor, observe that
    \[ E( \phi_1 \circ \phi_2) = \eta(\m(\gamma_2,\gamma_1)) = \eta(\gamma_1) \circ \eta(\gamma_2) = E(\phi_1) \circ E(\phi_2) \]
    The second equality comes from two facts:
    \begin{itemize}
      \item if $F \colon \bar \G \to \bar M \til\times_{\X} \bar M$ is the canonical map, then $\eta = \pr_{1.5} \circ F_0 \colon \G_0 \to \bar M \til\times_{\X} \bar M$;
      \item the groupoid operation on $\G$ is, by definition, the one obtained via $F \colon \bar \G \to \bar M \til\times_{\X} \bar M$.
    \end{itemize}

    Now that we have defined $E$, it is clear that $E$ is locally essentially surjective so we only need to show that it is fully faithful.
    It suffices to show this for morphisms covering the identity.
    Fix a pair of objects $f$ and $g$ in $\Y$.
    Suppose $a \colon f^* X_0 \to g^* X_0$ is a morphism in $\X$ covering the identity.
    Consider the object $(f, a, g)$ in $\bar M \til\times_{\B\G} \bar M$. Since $F$ is an equivalence, $(f, a, g)$ is in the orbit of $F(\gamma)$ for a unique $\gamma \in \bar \G$.
    Since this process inverts $E$ we conclude that $E|_{\Hom(f,g)}$ is a bijection.
  \end{proof}
  \newcommand{\Bun}{\mathbf{Bun}}
  \begin{proposition}
    Let $\G \grpd M$ and $\H \grpd N$ be $\C$-groupoids and let $\Bun(\G,\H)$ be the category whose objects are generalized morphisms $P \colon \G \to \H$ and morphisms are isomorphisms of generalized morphisms.
    On the other hand, let $\Hom(\B\G, \B\H)$ be the category whose objects are CFG morphisms $\B\G \to \B\G$ and morphisms are natural transformations.
    Then $\B \colon \Bun(\G,\H) \to \Hom(\B\G, \B\H)$ is an equivalence of categories.

    In other words, the psuedofunctor $\B$ is bi-fully faithful.
  \end{proposition}
  \begin{proof}
    We will first show essential surjectivity. Suppose $F \colon \B\G \to \B\H$ is a CFG morphism. Then consider $\bar N \til\times_{\B\H} \bar M$ which fits into the 2-commutative diagram:
    \[
    \begin{tikzcd}
      \bar N \til\times_{\B\H} \bar M \arrow[rr] \arrow[dd]  &    & \bar M \arrow[d] \\
                                                            &      & \B \G \arrow[d, "F"] \\
      \bar N \arrow[rr]                                       & & \B\H
    \end{tikzcd}
    \]
    By Lemma~\ref{lemma:CFGbundle}, $\bar N \til\times_{\B\H} \bar M$ has a left $\bar \H$ action and a right $\bar \G$ action. Its clear from the definitions of these actions that they commute. Since $\bar N \to \B\H$ is a presentation, there exists a $(\H,\G)$-bundle $P$ which fits into a 2-commutative square:
    \[
    \begin{tikzcd}
      \bar P \arrow[rr, "\s" ] \arrow[dd, "\t"]            &      & \bar M \arrow[d] \\
                                                           &      & \B \G \arrow[d, "F"] \\
      \bar N \arrow[rr]                                    &      & \B\H
    \end{tikzcd}
    \]
    The right action of $\G$ is principal since $\s$ is a submersion (see Lemma~\ref{lemma:CFGbundle} for why the action is principal).
    Note that $P \to \B\G$ is a presentation. Therefore, by replacing $M$ with $P$, we can assume without loss of generality that there exists a 2-commutative square:
    \[
    \begin{tikzcd}
      \bar M \arrow[r, "f"] \arrow[d] & \bar N \arrow[d] \\
      \B \G \arrow[r, "F"] & \B\H
    \end{tikzcd}
    \]
    In such a case, we get a morphism $\sigma \colon M \to P$ which splits $\s \colon P \to M$.
    Since $P$ admits a section, we can assume without loss of generality that $P = \G \times_{\s,f} N = f^* \G$.

    Now we claim that there is a natural transformation $\eta \colon \B P \to F$. Such a natural transformation must associate to each object $Q$ in $\B\G$ an isomorphism $P \otimes_\G Q \to F(Q)$.
    We will first define $\eta$ for trivial $\G$ bundles. Suppose $g^*\G \to N'$ is such a $\G$-bundle. Then $P \otimes_\G g^* \G$ can be identified with $g^*f^* \H$ (due to the fact that $P$ admits a section).

    The equivalence $\bar P \to \bar N \til\times_{\B\H} \bar N$ sends $\rho \colon N' \to P$ to the triple $(\t \circ \rho, \alpha(\rho), \s \circ \rho)$ where
    \[ \alpha(\rho) \colon (t \circ \rho)^*\H \to F((\s \circ \rho)^*\G) , . \]
    Then we can define $\eta$ on trivial $\G$-bundles to be $\eta(g^* \G) := \alpha(\sigma \circ g)$. Therefore:
    \[ \eta(g^* \G) \colon g^* f^* \H \to F(g^* \G) \, . \]

    To define $\eta$ for non-trivial $P$, we extending it (non canonically) by making a choice (for each $P$) of a local trivialization and define $\eta(P)$ to be the unique $\H$-bundle isomorphism obtained from gluing the identifications coming from $\eta$ applied to each trivialized piece. Since $\eta$ satisfies the condition for being a natural transformation locally, it also satisfies the condition globally after glueing. This shows $\B \colon \Bun(\G,\H) \to \Hom(\G,\H)$ is essentially surjective.

    We will now show that it is fully faithful. Fix a left principal $(\G, \H)$-bibundle $P$ for $\C$-groupoids $\G\grpd M$ and $\H \grpd N$. Now consider the function $\B \colon \Isom(P,P) \to \Isom(\B P, \B P)$. Suppose that $\B \phi = \Id_P$ for $\phi \colon P \to P$.
    Then for all $Q \in \B \G$, $\phi \otimes \Id \colon P \otimes Q \to P \otimes Q$ is the identity, hence $\phi \colon P \to P$ must be the identity. This shows that the function is injective.

    Now let $\eta \colon \B P \to \B P$ be a natural transformation, we want to show $\eta$ is in the image. We know that $\eta(Q) \colon P \otimes Q \to P \otimes Q$ and
    \[
    \begin{tikzcd}
      P \otimes Q_1 \arrow[r, "\eta(Q_1)"] \arrow[d, "\B P(\psi)"] & P \otimes Q_1 \arrow[d, "\B P(\psi)"] \\
      P \otimes Q_2 \arrow[r, "\eta(Q_1)"]                           & P \otimes Q_2
    \end{tikzcd}
    \]
    commutes for any morphism $\psi \colon Q_1 \to Q_2$ in $\B \G$.
    In particular, by taking $Q = \H$ and observing that there is a canonical isomorphism $P \otimes \H \isom P$ then we get a $\G$-bundle isomorphism $\phi \colon P \to P$. We claim that $\phi$ is a bibundle morphism. To show this we need to explain why $\phi$ is $\H$-equivariant. To see this, consider an arbitrary morphism $\gamma \colon N' \to \H$, by the natural isomorphism condition the following diagram commutes:
    \[
    \begin{tikzcd}
      P \otimes (\t \circ \gamma)^* \H \arrow[rr, "\eta(Q_1)"]
      \arrow[d, "{p \otimes (h,x) \mapsto p \otimes (h \cdot \gamma(x), x)}" swap]
      & & P \otimes (\t \circ \gamma)^* \H
      \arrow[d, "{p \otimes (h,x) \mapsto p \otimes (h \cdot \gamma(x), x)}"]  \\
      P \otimes (\s \circ \gamma)^* \H
      \arrow[rr, "\eta(Q_1)"]              &             & P \otimes (\s \circ \gamma)^* \H  \\
  \end{tikzcd}
    \]
    Using the definition of $\phi$, we can extend this diagram as below:
    \[
    \begin{tikzcd}
      (\t \circ \gamma)^* P \arrow[d, "{(p,x) \mapsto p \otimes (\gamma(x),x))}" swap] \arrow[rr, "{(p,x) \mapsto (\phi(p),x)}"]  & & (\t \circ \gamma)^* P  \arrow[d, "{(p,x) \mapsto p \otimes (\gamma(x),x))}"] \\
      P \otimes (\t \circ \gamma)^* \H \arrow[rr, "\eta(Q_1)"]
      \arrow[d, "{p \otimes (h,x) \mapsto p \otimes (h \cdot \gamma(x), x)}" swap]
      & & P \otimes (\t \circ \gamma)^* \H
      \arrow[d, "{p \otimes (h,x) \mapsto p \otimes (h \cdot \gamma(x), x)}"]  \\
      P \otimes (\s \circ \gamma)^* \H
      \arrow[d, "{p \otimes (h,x) \mapsto (p \cdot h, x)}" swap] \arrow[rr, "\eta(Q_1)"]              &             & P \otimes (\s \circ \gamma)^* \H \arrow[d, "{p \otimes (h,x) \mapsto (p \cdot h, x)}"] \\
        (\t \circ \gamma)^* P\arrow[rr, "{(p,x) \mapsto (\phi(p),x)}"] & & (\t \circ \gamma)^* P  \\
    \end{tikzcd}
    \]
    Which implies that $(\phi(p) \cdot \gamma(x),x) = (\phi(p) \cdot \gamma(x), x)$ and so $\phi$ must be $\H$-equivariant.

    To finish, we need to show that $\B (\phi) = \eta \colon \B P \to \B \P$. Which is equivalent to showing that
    \[ \eta(Q) = \phi \otimes \Id_Q \colon P \otimes Q \to P \otimes Q \]
    for all objects $Q \in \B\G$. It suffices to show this for trivial $\H$-bundles since we only need to check equality of maps locally.
    Suppose $Q = f^* \H$ then by the definition of $\phi$ we have that
    \[
    \begin{tikzcd}
      P \otimes f^* \H \arrow[rr, "\eta(f^* \H)"] \arrow[d] & & P \otimes f^* \H \arrow[d] \\
      f^* P \arrow[rr, "{(p,x) \mapsto (\phi(p),x)}"] &  & f^* P
    \end{tikzcd}
    \]
    commutes, where the vertical arrows are the canonical identifications. Since $\phi$ is equivariant, we also know that:
    \[
    \begin{tikzcd}
      P \otimes f^* \H \arrow[rr, "\eta(f^* \H)"] \arrow[d] & & P \otimes f^* \H \arrow[d] \\
      f^* P \arrow[rr, "{(p,x) \mapsto (\phi(p),x)}"] &  & f^* P
    \end{tikzcd}
    \]
    Since $\phi$ is $\H$-equivariant, we have that:
    \[
    \begin{tikzcd}
      P \otimes f^* \H \arrow[rr, "{\phi \otimes \Id_\H}"] \arrow[d] & & P \otimes f^* \H \arrow[d] \\
      f^* P \arrow[rr, "{(p,x) \mapsto (\phi(p),x)}"] &  & f^* P
    \end{tikzcd}
    \]
    commutes as well. Since the vertical arrows are the same isomorphisms in both of these diagrams, we can put them together to obtain the desired equality.
  \end{proof}
    These two propositions complete the proof of the main theorem. In the next section we will look at a few examples of sites and study the geometric meaning of these concepts in each setting.

    \section{Examples}\label{section:examples1}
    Here we will briefly explore a few examples of good sites and the geometric interpretation of our theorems.
    \subsection{Manifolds}
    Let $\C$ be the site of manifolds. Then a $\C$-groupoid is a Lie groupoid. A principal $\C$-groupoid bundle is the same as a principal bundle of the associated Lie groupoid. Principal bibundles of Lie groupoids are called Morita equivalences. The theorem says the study of geometric stacks over the site of smooth manifolds is equivalent to the study of principal groupoid bundles.

    It is clear that a submersion in the sense we have discussed thus far is the same as a surjective submersion of manifolds. However, if we wish, we can be more strict with the definition of submersion, and we will obtain a corresponding class of geometric stack represented by a Lie groupoid.

    \begin{example}
      Suppose we redefine submersion to mean \emph{locally trivial fibration}. Then a $\C$-groupoid becomes a Lie groupoid $\G \grpd M$ for which the source map makes $\G$ into a locally trivial fibration. By our theorem, the stacks represented by such groupoids are precisely those which admit a presentation $p \colon M \to \X$ which is a locally trivial fibration. In this case, we mean that $p$ is a representable epimorphism such that for any $\bar N \to X$, the associated map $\bar M \times_{\X} \bar N \to N$ is a locally trivial fibration of manifolds.

      A sub-example of this case are the stacks represented by \emph{source proper} Lie groupoids. That is, groupoids whose source maps are proper submersions.
    \end{example}
    Apart from alternative notions of submersion, we can also enrich the category of manifolds with additional data.
    \begin{example}
      Let $\C$ be the category whose objects are pairs $(M,X)$ where $X$ is a vector field on the smooth manifold $M$. A morphism in this category is a smooth map $f \colon (M,X) \to (N,Y)$ such that $X$ and $Y$ are $f$-related.

      We can give $\C$ a Grothendiek topology by setting a covering family to be a collection of open embeddings $(U_i, X|_{U_i}) \to (M, X)$ whose images cover $M$. This site comes with a forgetful functor to $\Man$. A submersion in this category is just a surjective submersion. A $\C$-groupoid is a Lie groupoid $\G$ equipped with a vector field $X$ which is \emph{multiplicative}.
      \[ \m_*(X,X) = X \]

      Recent work by Berwick-Evans and Lerman \cite{Berwick} has shown that such a vector field is a reasonable candidate for the definition of a vector field on a geometric stack.
      Hence, we obtain our first example of an interesting strategy. One can try to understand structures on a geometric stack by equipping the site itself with additional structure.
    \end{example}

    \subsection{Schemes}

    The site of schemes over a base satisfies our axioms for a \emph{good site} when equipped with the etale topology. Gluing along submersions is easy since schemes are already defined locally. If one is more strict and requires more topological properties such as seperatedness, then one might need to be careful, but most of the time these properties are preserved as long as you gluing inside of $\Sub$.
    In this context, it is also reasonable to replace site theoretic submersions with `smooth' morphisms of stacks.

    Our definition of a geometric stack is very close to the definition of an \emph{Artin} stack. For an Artin stack, one commonly requires that the diagonal embedding:
    \[ \X \to \X \times \X \]
    be a representable morphism of stacks. We have a good reason for not requiring this in the manifold setting since it would imply that:
    \[ (\t,\s) \colon \G \to M \times M \]
    is a local submersion, due to the following pullback square:
    \[
    \begin{tikzcd}
      \bar \G \arrow[r, "{(\t,\s)}"] \arrow[d]     & \bar M \times \bar M \arrow[d] \\
      \B\G     \arrow[r]               & \B\G \times \B\G
    \end{tikzcd}
    \]
    Since every map of schemes is cartesian, the condition of representability is much weaker in the algebraic geometry setting.
    A nice property of this Artin condition is that it is equivalent to requiring that for each $X$ and $Y$ in $\X_N$, there is a scheme $S$ such that maps into $S$ classify isomorphisms $X \to Y$ which cover the identity. For Lie groupoids, we can only expect this to be the case when $X$ and $Y$ are trivial $\G$-bundles.

    \subsection{Algebroids}

    A \emph{Lie algebroid} is a vector bundle $A \to TM$, equipped with a Lie bracket $[ \cdot , \cdot]_A $ on its space of sections and a \emph{anchor map} $\rho \colon A \to TM$ such that:
    \begin{equation}\label{eqn:algebroidleibnitz}
      [ \alpha , f\beta]_A = f [\alpha, \beta]_A + \rho(\alpha)(f) \beta \quad \forall \alpha, \beta \in \Gamma(A) \quad \forall f \in C^\infty(M)
    \end{equation}

    If $A$ and $B$ are Lie algebroids, a morphism of Lie algebroids is a vector bundle morphism $F \colon A \to B$ which commutes with the anchors and is compatible with the brackets. We will not state the bracket compatibility condition here, but we will comment that it implies that
    \[ F_*([\alpha,\beta]_A) = [F_*(\alpha),F_*(\beta)]_B \]
    whenever the pushforward of $\alpha$ and $\beta$ by $F$ are well defined.

    Let $\C$ be the category whose objects are algebroids and whose morphisms are algebroid morphisms. The cartesian morphisms in this category are precisely the ones whose underlying vector bundle map is a vector bundle epimorphism covering a (local) submersion.
    Equip $\C$ with the Grothendieck (pre)topology whose covering families are the inclusion $A|_U \into A$ for open embeddings $U \to M$.

    Under this definition of Grothendieck topology, the ``submersions'' are algebroid maps $F \colon A \to B$ which cover submersions and admit local algebroid splittings $B|_U \to A$. Unlike with ordinary vector bundles, finding splittings of algebroid morphisms is non-trivial and we cannot expect them to exist in general. Hence, a submersion in this category is a fairly strong condition.

    A $\C$-groupoid is a groupoid internal to algebroids $A \grpd B$ such that the source (and target) morphisms are submersions in the above sense. This is the same as a LA-groupoid~\cite{Mackenzie} except for the local splitting condition.
    \[
    \begin{tikzcd}
      A \darrow \arrow[r] & \G \darrow \\
      B \arrow[r]         & M
    \end{tikzcd}
    \]
    The forgetful functor from $\C$ to manifolds can be extended to a functor $\B A \to \B\G$ where $\G$ is the underlying Lie groupoid associated to $A \grpd B$. This is a candidate for a definition of a Lie algebroid on a geometric stack. One caveat to this is that $\B A$ is not a stack over $\Man$. This is in contrast to the non-singular setting, where the total space of a Lie algebroid is also a manifold.
    One can get around this issue by first applying the ``total space'' functor to $\B A$ and then stackifying.

    One should take care that a principal $A \grpd B$ bundle internal to algebroids is not the same as a principal bundle as a $\C$-groupoid. The important distinction is the local splitting conditions. The main distinction comes from the fact that we require submersions to admit local sections and, in general, one cannot expect a surjective morphism of algebroids $F \colon A \to B$ to admit local sections, even if the base of the morphism is the identity.

config: arxiv