text:
\section{Introduction}
The classical Siegel-Weil formula expresses certain Siegel Eisenstein series as generating series of representation numbers of quadratic forms. Starting from  \cite{Kudla97}, Kudla initiated an influential program that seeks to establish the arithmetic Siegel-Weil formula, which expresses central derivatives of these series as arithmetic intersection numbers of $n$ special divisors in the Shimura varieties associated to $\mathrm{GSpin}(n-1,2)$ or $\mathrm{GU}(n-1,1)$.

In \cite{KR1} and \cite{KR2}, Kudla and Rapoport defined integral models of unitary Shimura varieties associated to $\mathrm{GU}(n-1,1)$ over an imaginary quadratic field ${\bf k}$ and special cycles associated to a certain class of special endomorphisms on them. They showed that the intersection of $n$ independent special divisors is supported on the supersingular locus of the Shimura variety over a finite set of primes of $\mathbb{Q}$ inert or ramified in ${\bf k}$. Over an inert prime $p$, they formulated a local version of the arithmetic Siegel-Weil formula (the local Kudla-Rapoport conjecture), which expresses intersection number of $n$ special divisors on the corresponding Rapoport-Zink spaces as derivative of local densities of hermitian forms. They then explained how the nonarchimedean component of the arithmetic Siegel-Weil formula (also known as the global Kudla-Rapoport conjecture) follows from the local Kudla-Rapoport conjecture.

In \cite{KR1} and \cite{KR2}, Kudla and Rapoport proved their conjectures when the support of the intersection has zero dimension, which essentially reduces to the case when $n=1,2$. Recently, Li and Zhang \cite{LZ} proved the conjecture for general $n$.

Over a prime $p$ ramified in ${\bf k}$, it has been speculated that there should be analogues of Kudla-Rapoport conjectures. In this case, one can consider the integral model of Shimura variety and its corresponding Rapoport-Zink spaces proposed by Kr\"amer \cite{Kr}. The Kr\"amer model is regular and has semi-stable reduction over $p$.

In this paper and \cite{HSY}, we prove the analogue of
Kudla–Rapoport conjecture for the Kr\"amer models when $n = 2$ at odd ramified primes.
These results shed light on how  Kudla-Rapoport type of conjectures should be formulated for the Kr\"amer model at ramified primes for general $n$.

\subsection{Special cycles on Rapoport-Zink spaces}
Let $p$ be an odd prime integer. Let $F_0$ be a finite extension of $\mathbb{Q}_p$ and $F$ be a ramified quadratic extension of $F_0$. Denote by $\mathcal{O}_F$ and $\mathcal{O}_{F_0}$ their rings of integers respectively. Assume the residue field of $\mathcal{O}_{F_0}$ is $\mathbb{F}_q$ and let $k$ be its algebraic closure. We denote by $\bar{a}$ the Galois conjugate of $a\in F$ over $F_0$. We fix a uniformizer $\pi\in F$ such that $\pi_0=\pi^2\in \mathcal{O}_{F_0}$. Let $\breve{F}_0$  be the completion of a maximal unramified extension of $F_0$ and $\breve{F}:=F\otimes_{F_0} \breve{F}_0$. Let $\mathcal{O}_{\breve F}$ and $\mathcal{O}_{\breve{F}_0}$ be the rings of integers of $\breve{F}$ and $\breve{F}_0$ respectively. Let $\mathrm{Herm}_n$ be the group scheme over $\mathcal{O}_{F_0}$ defined by
\begin{equation}\label{eq:Herm_n local}
    \mathrm{Herm}_n(R)=\{X\in M_{n\times n} (R\otimes_{\mathcal{O}_{F_0}} \mathcal{O}_F)\mid X=X^*\}\
\end{equation}
for an $\mathcal{O}_{F_0}$-algebra $R$ where $X^*=\bar{X}^t$.

We consider the formal moduli space $\mathcal{N}^\mathrm{Pap}$  which is the  functor over $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}$ whose $S$-point is the groupoid of isomorphism classes of quadruples $ (X,\iota,\lambda,\rho)$ over $S$ for an $\mathcal{O}_{\breve{F}_0}$-scheme $S$. Here $X$ is a strict formal $\mathcal{O}_{F_0}$-module (which is a particular kind of formal $p$-divisible group, see Section \ref{sec:modulispaces}) over $S$ of dimension $n$ and $F_0$-height $2n$. The action $\iota:\mathcal{O}_{F}\rightarrow \mathrm{End}(X)$ is a ring homomorphism such that the induced action on $\mathrm{Lie}\,  X$ satisfies certain signature conditions.
$\lambda:X\rightarrow X^\vee$ is a principal polarization compatible with $\iota$. Finally, $\rho$ is an $\mathcal{O}_F$-linear quasi-isogeny of height $0$ from $X\times_S \bar{S} $ to $\mathbb{X}\times_{\mathrm{Spec}\,  k} \bar{S}$ where $\bar{S}=S\times \mathrm{Spec}\,  k$ and $(\mathbb{X},\iota_\mathbb{X},\lambda_\mathbb{X})$ is a fixed framing object. $\mathcal{N}^\mathrm{Pap}$ is representable by a formal scheme over $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}$ which is normal, flat of relative dimension $n-1$ over $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}$ and has isolated singularities (see \cite[Theorem 4.5]{P}). We refer to Section \ref{sec:modulispaces} for a detailed definition of $\mathcal{N}^\mathrm{Pap}$ and $\mathcal{N}^\mathrm{Kra}$ below.

In order to resolve the singularities, \cite{Kr} proposes a new moduli problem $\mathcal{N}^\mathrm{Kra}$ which is flat over $\mathrm{Spf}\,  \mathcal{O}_{\breve F}$, has semi-stable reduction and has a natural morphism $\Phi:\mathcal{N}^\mathrm{Kra} \rightarrow \mathcal{N}^\mathrm{Pap}$. It is known to the experts that $\mathcal{N}^\mathrm{Kra}$ is in fact the blow-up of $\mathcal{N}^\mathrm{Pap}$ along its singular locus. But due to the lack of a precise reference, we provide a proof of this fact in Appendix \ref{sec:Kramer model is blow up}.
The exceptional divisor of this blow-up is denoted by $\mathrm{Exc}$ and is isomorphic to $\mathbb{P}^{n-1}/k$.

In the rest of this subsection we specialize to the case $n=2$.
Let $\mathbb{Y}$ be the unique strict formal $\mathcal{O}_{F_0}$-module of dimension $1$ and $F_0$-height $2$. It admits an $\mathcal{O}_F$-action $\iota_\mathbb{Y}:\mathcal{O}_F\rightarrow \mathrm{End}(\mathbb{Y})$ and a compatible polarization $\lambda_\mathbb{Y}:\mathbb{Y}\rightarrow \mathbb{Y}^\vee$. The space of special quasi-homomorphisms $\mathbb{V}=\mathrm{Hom}_{\mathcal{O}_F}(\mathbb{Y},\mathbb{X})\otimes_{\mathbb{Z}} \mathbb{Q} $ is a $2$ dimensional $F$-vector space with the natural hermitian form
\[h(x,y)=\iota_\mathbb{Y}^{-1} (\lambda_\mathbb{Y}^{-1}\circ y^\vee \circ \lambda_\mathbb{X} \circ x)\]
where $y^\vee$ is the dual homomorphism of $y$. Let us briefly recall that $n$ dimensional hermitian spaces associated to the quadratic extension $F/F_0$ are classified by the Hasse invariant which is the class
\begin{equation}\label{eq:Hasse invariant}
    (-1)^{\frac{n(n-1)}{2}} d \in F_0^\times/\mathrm{Nm}(F^\times)\cong \{\pm 1\}
\end{equation}
where $d$ is the determinant of a given hermitian form.
When $n=2$, we say a hermitian space is anisotropic if it does not contain a line of length zero elements, or equivalently its Hasse invariant is $-1$. Otherwise we say it is isotropic.
When $(\mathbb{V},h(,))$ is anisotropic, by \cite[Section 8]{RSZ} there is an isomorphism
\[\mathcal{N}^\mathrm{Pap}\cong \mathcal{M}_{\Gamma_0(\pi)}=\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}[[X,Y]]/(XY-\pi_0),\]
where $\mathcal{M}_{\Gamma_0(\pi)} $ is the deformation space of degree $q$ isogenies between Lubin-Tate formal groups.
When $(\mathbb{V},h(,))$ is isotropic, then by \cite{KR3} (see also \cite{RSZ}), $\mathcal{N}^\mathrm{Pap}$ is isomorphic to the formal scheme whose generic fiber is the Drinfeld $p$-adic half plane. Our key assumption in this paper is
\begin{equation}\label{eq:anisotropicassumption}
    (\mathbb{V},h(,))\text{ is anisotropic},
\end{equation}
which we make in the rest of the introduction.
The isotropic case is treated in \cite{HSY}.

For any ${\bf x}\in\mathbb{V}^m$ ($1\leq m \leq 2$), we define $\mathcal{Z}^\mathrm{Kra}({\bf x})$  (resp. $\mathcal{Z}({\bf x})$) to be the closed subscheme of $\mathcal{N}^\mathrm{Kra}$ (resp. $\mathcal{N}^\mathrm{Pap}$) where the quasi-homomorphism $\rho^{-1}\circ {\bf x}:\mathbb{Y}^m \rightarrow \mathbb{X}$ deforms to a homomorphism (see Definition \ref{def:localspecialcycle}).
By \cite[Proposition 4.3]{Ho2}, $\mathcal{Z}^\mathrm{Kra}(x)$ for a single $x\in \mathbb{V}$ is a Cartier divisor.
In order to decompose $\mathcal{Z}^\mathrm{Kra}(x)$, we define Weil divisors $\mathcal{Y}^\kappa_{s,\pm}$ (see Section \ref{subsec:quasi canonical lifting on NPap}) on $\mathcal{N}^\mathrm{Pap}$ and Cartier divisors $\mathcal{Z}^\kappa_{s,\pm}$ (see Definition \ref{def:quasicanonicaldivisoronKramer}) on $\mathcal{N}^\mathrm{Kra}$ for an integer $s\geq 0$. Here $\kappa$ is an embedding of $\mathcal{O}_F$ into the quaternion algebra with center $F_0$ determined by ${\bf x}$, see \eqref{eq:kappa x}.
The pullback of the universal formal $\mathcal{O}_{F_0}$-module over $\mathcal{N}^\mathrm{Pap}$ (resp. $\mathcal{N}^\mathrm{Kra}$) to these divisors are quasi-canonical lifts of level $s$ in the sense of \cite{G}. Moreover $\mathcal{Z}^\kappa_{s,\pm}$ is the strict transform of $\mathcal{Y}^\kappa_{s,\pm}$ under the blow-up $\Phi:\mathcal{N}^{\mathrm{Kra}}\rightarrow \mathcal{N}^\mathrm{Pap}$.
When $s=0$, $\mathcal{Z}^\kappa_{0,+}$ and $\mathcal{Z}^\kappa_{0,-}$ are the same and is denoted by $\mathcal{Z}^\kappa_0$.
Our first major result is then the following decomposition theorem (Theorem \ref{decompositionofspecialcycles}).
\begin{theorem}
For any ${\bf x} \in \mathbb{V}\setminus\{0\}$,
we have the following equality of Cartier divisors on $\mathcal{N}^\mathrm{Kra}$.
\[\mathcal{Z}^\mathrm{Kra}({\bf x})=\mathcal{Z}^\kappa_0+\sum_{s=1}^a \mathcal{Z}^\kappa_{s,-}+\sum_{s=1}^{a} \mathcal{Z}_{s,+}^\kappa+(a+1) \mathrm{Exc},\]
where $a$ is the $\pi_0$-adic valuation of $h({\bf x},{\bf x})$.
\end{theorem}

The reduced locus  of $\mathcal{N}^\mathrm{Kra}$ is its exceptional divisor. In particular it is proper over $\mathrm{Spec}\,  k$.
For a full rank lattice $\mathbb{L}\subset \mathbb{V}$ and a basis $\{x_1,x_2\}$ of $\mathbb{L}$, we define the intersection number
\begin{equation}\label{IntL}
    \mathrm{Int}(\mathbb{L})=\chi(\mathcal{N}^\mathrm{Kra}, \mathcal{O}_{\mathcal{Z}^\mathrm{Kra}(x_1)}\otimes^{\mathbb{L}} \mathcal{O}_{\mathcal{Z}^\mathrm{Kra}(x_2)}),
\end{equation}
where $\mathcal{O}_{\mathcal{Z}^\mathrm{Kra}(x)}$ is the structure sheaf of $\mathcal{Z}^\mathrm{Kra}(x)$, $\otimes^{\mathbb{L}}$ is the derived tensor product of coherent sheaves on $\mathcal{N}^\mathrm{Kra}$ and $\chi$ denotes the Euler-Poincar\'e characteristic. By \cite{Ho2}, this quantity is independent of the choice of $\{x_1, x_2\}$, hence is an invariant of $\mathbb{L}$. We say two hermitian matrices $T_1$ and $T_2$ in $\mathrm{Herm}_n(F_0)$ are equivalent if there is a $g\in \mathrm{GL}_n(\mathcal{O}_F)$ such that $g^* T_1 g=T_2$.
We then prove the following theorem (Theorem \ref{thm:maintheorem1}).
\begin{theorem}\label{thm:IntrothmA}
Suppose $(\mathbb{V},h(,))$ is anisotropic.
Let $\mathbb{L}$ be a hermitian $\mathcal{O}_F$-lattice in $\mathbb{V}$ whose hermitian form is represented by a Gram matrix equivalent to $T=\left(\begin{array}{cc}
    u_1 (-\pi_0)^a & 0 \\
    0 & u_2 (-\pi_0)^b
\end{array}\right)$,where $u_1,u_2\in \mathcal{O}_{F_0}^\times$ and $a,b\geq 0$. Then
\[\mathrm{Int}(\mathbb{L})=2 \sum_{s=0}^{min\{a,b\}}q^s(a+b+1-2s)-a-b-2.\]
\end{theorem}

\subsection{Local density}
Fix an additive character $\psi$ of $F_0$ with conductor $\mathcal{O}_{F_0}$.
For $S\in\mathrm{Herm}_m(F_0)$ and $T\in\mathrm{Herm}_n(F_0)$, define
\begin{equation}
    \alpha(S, T) = \int_{\mathrm{Herm}_n(F_0)} \int_{M_{m,n}(\mathcal{O}_F)} \psi(\mathrm{Tr}( Y(S[X]-T))) dX dY
\end{equation}
where $dX$ and $dY$ are Haar measures on $M_{m,n}(\mathcal{O}_F)$ and $\mathrm{Herm}_n(\mathcal{O}_{F_0})$ respectively such that $\mathrm{vol}(M_{m,n}(\mathcal{O}_F), dX) =\mathrm{vol}(\mathrm{Herm}_n(\mathcal{O}_{F_0}), dY)=1$ and $\mathrm{Tr}$ stands for the matrix trace. The quantity $\alpha(S,T)$ is independent of the choice of $\psi$ and is called the representation density of $T$ by $S$, or simply (hermitian) local density. We refer to Lemma \ref{lem:definitionoflocaldensity} to justify the name. Define
\[S_r=S\oplus \frac{1}{\pi}\left(\begin{array}{cc}
    0 & I_r \\
    -I_r & 0
\end{array}\right).\]
It can be shown that there is a polynomial $\alpha(S,T,X)\in \mathbb{Q}[X]$ such that $\alpha(S_r,T)=\alpha(S,T,q^{-2r})$, see \cite[Corollary 5.4]{Hi}. We define the derivative of the local density $\alpha(S,T)$ to be
\begin{equation}\label{eq:alphaprime}
  \alpha'(S,T)=-\frac{\partial}{\partial X} \alpha(S,T,X)|_{X=1}.
\end{equation}

Now go back to the situation of Theorem \ref{thm:IntrothmA}.
We take $S$ to be a Gram matrix of the unique self-dual hermitian lattice (up to hermitian isometries) of rank $2$ which has Hasse invariant $1$.  We can compute
$\alpha(S,T,X)$ and $\alpha(S,S)$ following the idea of \cite{Hi}. Then we obtain the following theorem (see Theorem \ref{thm:maintheorem2}).
\begin{theorem}\label{thm:IntrothmB}
Let $\mathbb{L},T$ be as in Theorem \ref{thm:IntrothmA} and
$S$ be as above. Then
\[   \mathrm{Int}(\mathbb{L})=2\cdot \frac{\alpha'(S,T)}{\alpha(S,S)}.\]
\end{theorem}
\begin{remark}
The factor $2$ in the theorem is essentially the ramification index of $F/F_0$ which comes naturally from global considerations, see \eqref{eq:degcZ} below. One can compare with the inert case, see \cite[Theorem 3.4.1]{LZ}, where this number is $1$.
\end{remark}
\begin{remark}
In general when the Rapoport-Zink space has bad reduction, one needs to modify the analytic (right hand) side of Theorem \ref{thm:IntrothmB}. This is first discovered in \cite{KRshimuracurve}. See also \cite{San3}, \cite[Section 10]{LZ} and \cite{HSY}.
\end{remark}
We also obtain formulas of $\alpha(S,T,X)$ for some other choices of $S$ and $T$ which might be of independent interest, see Theorem \ref{thm:localdensity calculation}.

\subsection{Global moduli problem and Eisenstein series}
In the second part of the paper, we apply the local results above to the global intersection problem proposed by \cite{KR2}.
Let ${\bf k}$ be an imaginary quadratic field.
As in the local case, let $\mathrm{Herm}_n$ be the group scheme over $\mathbb{Z}$ defined by
\begin{equation}\label{eq:Herm_n global}
   \mathrm{Herm}_n(R)=\{X\in M_{n\times n} (R\otimes_{\mathbb{Z}} \mathcal{O}_{\bf k})\mid X=X^*\}
\end{equation}
for any algebra $R$.
Let $\mathcal{M}^\mathrm{Kra}_{(n-1,1)}$ be the moduli functor over $\mathrm{Spec}\,  \mathcal{O}_{\bf k}$ which parametrizes principally polarized abelian varieties $A$ with an action $\iota:\mathcal{O}_{\bf k} \rightarrow \mathrm{End}(A)$, a polarization $\lambda: A\rightarrow A^\vee$ compatible with $\iota$ and a filtration $\mathcal{F}_A\subset \mathrm{Lie}\,  A$ which satisfies the signature $(n-1,1)$ condition (see Section \ref{sec:globalintersecionnumber}).
In particular $\mathcal{M}_{(1,0)}:=\mathcal{M}^\mathrm{Kra}_{(1,0)}$ is the moduli space of CM elliptic curves with $\mathcal{O}_{k}$-action.
Let $V$ be a  hermitian vector space over ${\bf k}$ of signature $(1,1)$ containing a self-dual lattice $L$. The lattice $L$ determines an open and closed substack
\[\mathcal{M}\subset\mathcal{M}_{(1,0)}\times_{\mathrm{Spec}\,  \mathcal{O}_{\bf k}} \mathcal{M}^\mathrm{Kra}_{(1,1)}\]
which is an integral model of a unitary Shimura curve.
For a point in $\mathcal{M}(S)$ ($S$ an $\mathcal{O}_{\bf k}$-scheme), i.e.,
a pair of data $(E,\iota_0,\lambda_0)\in \mathcal{M}_{(1,0)}(S)$ and $(A,\iota,\lambda,\mathcal{F}_A)\in \mathcal{M}^\mathrm{Kra}_{(1,1)}(S)$, define the projective $\mathcal{O}_{\bf k}$-module of finite rank
\[V'(E,A)=\mathrm{Hom}_{\mathcal{O}_{\bf k}}(E,A).\]
It is equipped with the hermitian form $h'(x,y)=\iota_0^{-1}(\lambda_0^{-1}\circ y^\vee \circ \lambda \circ x)$. For a $m \times m$ positive-definite hermitian matrix $T$ with values in $\mathcal{O}_{\bf k}$, let $\mathcal{Z}^\mathrm{Kra}(T)$ be the stack of collections $(E,\iota_0,\lambda_0, A,\iota, \lambda,\mathcal{F}_A,{\bf x})$ where $ (E,\iota_0,\lambda_0, A,\iota, \lambda,\mathcal{F}_A)\in \mathcal{M}(S)$ and ${\bf x} \in V'(E,A)^m$ with $h'({\bf x},{\bf x})=T$. The moduli space $\mathcal{Z}^\mathrm{Kra}(T)$ is a representable by a Deligne-Mumford stack which is finite and unramfied over $\mathcal{M}$. When $t\in \mathbb{Z}_{>0}$, $\mathcal{Z}^\mathrm{Kra}(t)$ is a divisor by \cite[Proposition 3.2.3]{Ho1}.

Let $T\in \mathrm{Herm}_2(\mathbb{Z})$ and assume it is positive definite. Let $V_T$ be the hermitian space with Gram matrix $T$. Let $V_p=V\otimes_\mathbb{Q} \mathbb{Q}_p$. Define
\begin{equation}\label{eq:Diff}
    \mathrm{Diff}(V_T,V):=\{\ell \text{ a finite prime of } \mathbb{Q} \mid V_\ell \text{ is not isomorphic to } (V_T)_\ell\}
\end{equation}
where isomorphic means isomorphic as hermitian spaces.
Then $\mathcal{Z}^\mathrm{Kra}(T)$ is empty if $|\mathrm{Diff}(V_T,V)|>1$. If $\mathrm{Diff}(V_T,V)=\{p\}$ for a prime $p$ inert or ramified in ${\bf k}$,
it is proved in \cite[Proposition 2.22]{KR2} that
the support of $\mathcal{Z}^\mathrm{Kra}(T)$ is on the supersingular locus of $\mathcal{M}$ over the residue field of ${\bf k}_p$. Let $e$ be the ramification index of ${\bf k}_p/\mathbb{Q}_p$.
Define
\begin{equation}\label{eq:degcZ}
    \widehat{\mathrm{deg}}(\mathcal{Z}^\mathrm{Kra}(T))=\chi(\mathcal{Z}^\mathrm{Kra}(T),\mathcal{O}_{\mathcal{Z}^\mathrm{Kra}(x_1)}\otimes^{\mathbb{L}} \mathcal{O}_{\mathcal{Z}^\mathrm{Kra}(x_2)})\cdot \log p^{2/e},
\end{equation}
where $t_1, t_2$ are the diagonal entries of $T$.

Let $E(z,s,L)$ (see section \ref{sec:Eisensteinseries}) be the incoherent Eisenstein series considered by \cite{KR2}. It can be analytically continued to $s\in \mathbb{C}$ and satisfies a functional equation centered at $s=0$. Let $E'_T(z,0,L)$ be the $T$-th Fourier coefficient of its central derivative. Then we have the following theorem (Theorem \ref{globalmainthm}).

\begin{theorem}
Let $T\in \mathrm{Herm}_2(\mathbb{Z})$ be positive definite and assume $\mathrm{Diff}(V_T,V)=\{p\}$ where $p$ is an odd prime ramified in ${\bf k}$ such that $V_{p}$ is isotropic. Then
\[E'_T(z,0,L)=C_1 \cdot \widehat{\mathrm{deg}}(\mathcal{Z}^\mathrm{Kra}(T)) \cdot q^T, \]
where $C_1$ is a constant that only depends on ${\bf k}$ and $L$ and $q=\exp(2\pi i \mathrm{Tr}(Tz))$.
\end{theorem}
\begin{remark}
The hermitian space $V_p$ in the theorem has the opposite Hasse invariant as the hermitian space $\mathbb{V}$ with hermitian form $h(,)$.
\end{remark}

\noindent
{\bf Acknowledgements.}
First we would like to thank Michael Rapoport for suggesting studying special cycles at ramified primes. We would also like to thank Qiao He, Brian Smithling, Tonghai Yang and Wei Zhang for helpful discussions. Finally, we would like thank the referee for valuable suggestions.

\noindent
{\bf Data availability statement:}
The paper has no associated data.

\part{Local theory}
Denote by $\sigma$ the Frobenius of $k/\mathbb{F}_q$ and $\breve{F}_0/F_0$. Let $\mathbb{H}$ be the unique quaternion algebra with center $F_0$ and $\mathcal{O}_{\mathbb{H}}$ be its ring of integers. Let $\mathrm{val}_{\pi_0}$ ($\mathrm{val}_{\pi}$ resp.) be the valuation on $\breve F$ such that $\mathrm{val}_{\pi_0}(\pi_0)=1$ ($\mathrm{val}_{\pi}(\pi)=1$ resp.).
There exists a $\delta\in \mathcal{O}_{\mathbb{H}}^\times$ such that $\delta^2\in F_0$ and $\delta \pi=-\pi \delta$.
For a local $p$-adic ring $\mathcal{O}$, let $\mathrm{Nilp}\,  \mathcal{O}$ be the category of $\mathcal{O}$-schemes $S$ such that $p\cdot \mathcal{O}_S$ is a locally nilpotent ideal sheaf. For $S\in \mathrm{Nilp}\,  \mathcal{O}$, let $\bar{S}$ be its special fiber. Unless otherwise specified, all tensor products are defined over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$.

\section{Moduli spaces}\label{sec:modulispaces}
\subsection{Rapoport-Zink spaces}\label{subsec:RZ spaces}
For a scheme $S$ over $\mathrm{Spec}\,  \mathcal{O}_{F_0}$, a formal $\mathcal{O}_{F_0}$-module over $S$ is a formal $p$-divisible group $X$ over $S$ with an action $i:\mathcal{O}_{F_0}\rightarrow \mathrm{End}(X)$. We say $X$ is a strict formal $\mathcal{O}_{F_0}$-module if $\mathcal{O}_{F_0}$ acts on $\mathrm{Lie}\,  X$ via the structure morphism $\mathcal{O}_{F_0}\rightarrow \mathcal{O}_S$.
Let $(\mathbb{X},\iota_\mathbb{X})$ be a strict formal $\mathcal{O}_{F_0}$-module of dimension $n$ and $F_0$-height $2n$ over $k$ with an action $\iota_\mathbb{X}:\mathcal{O}_{F}\rightarrow \mathrm{End}(X)$ that extends the action of $\mathcal{O}_{F_0}$. Let $\lambda_{\mathbb{X}}$ be a principal polarization whose associated Rosati involution induces on $\mathcal{O}_F$ the nontrivial Galois automorphism over $F_0$.

We consider the Rapoport-Zink space $\mathcal{N}^\mathrm{Pap}$, a functor over $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}$ which represents the moduli problem such that $\mathcal{N}^\mathrm{Pap}(S)$ is the groupoid of isomorphism classes of quadruples $ (X,\iota,\lambda,\rho)$ over $S$ for $S\in \mathrm{Nilp}\,  \mathcal{O}_{\breve F}$. Here $X$ is a strict formal $\mathcal{O}_{F_0}$-module over $S$ of dimension $n$ and $F_0$-height $2n$ with an $\mathcal{O}_F$-action $\iota:\mathcal{O}_{F}\rightarrow \mathrm{End}(X)$ that extends the action of $\mathcal{O}_{F_0}$ satisfying the Kottwitz signature condition
\begin{equation}\label{eq:Kottwitzcondition}
    \mathrm{char}(\iota(\pi)|\mathrm{Lie}\,  X)=(T-\pi)^{n-1}(T+\pi),
\end{equation}
and the Pappas wedge condition proposed in \cite{P}
\begin{equation}\label{eq:wedgecondition}
    \wedge^n(\iota(\pi)+\pi|\mathrm{Lie}\,  X)=0, \ \wedge^2(\iota(\pi)-\pi|\mathrm{Lie}\,  X)=0.
\end{equation}
$\lambda:X\rightarrow X^\vee$ is a principal polarization whose associated Rosati involution induces on $\mathcal{O}_F$ the nontrivial Galois automorphism over $\mathcal{O}_{F_0}$ where $X^\vee$ is the dual of $X$ in the category of strict formal $\mathcal{O}_{F_0}$-modules.
Finally $\rho:X\times_S \bar{S} \rightarrow \mathbb{X} \times_{\mathrm{Spec}\,  k} \bar{S}$ is an $\mathcal{O}_F$-linear quasi-isogeny of height $0$ such that $\lambda$ and $\rho^*(\lambda_\mathbb{X})$ differ locally on $\bar{S}$ by a factor in $\mathcal{O}_{F_0}^\times$. An isomorphism between two quadruples $(X,\iota,\lambda,\rho)$ and $(X',\iota',\lambda',\rho')$ is given by an $\mathcal{O}_F$-linear isomorphism $\alpha:X\rightarrow X'$ such that $\rho'\circ (\alpha \times_S \bar{S})=\rho$ and $\alpha^*(\lambda')$ is a $\mathcal{O}_{F_0}^\times$-multiple of $\lambda$.

By \cite[Proposition 2.1]{RTW}, $\mathcal{N}^\mathrm{Pap}$ is representable by a separated formal scheme, locally formally of finite type over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ of relative dimension $n-1$. Moreover it is normal and has isolated singularities.
Let $(\mathbb{Y},\iota_\mathbb{Y},\lambda_\mathbb{Y})$ be the unique strict formal $\mathcal{O}_{F_0}$-module of dimension $1$ and $F_0$-height $2$ over $\mathrm{Spec}\,  k$, together with an action $\iota_\mathbb{Y}:\mathcal{O}_F\rightarrow \mathrm{End}(\mathbb{Y})$ that lifts the $\mathcal{O}_{F_0}$-action and a principal polarization $\lambda_\mathbb{Y}: \mathbb{Y}\rightarrow \mathbb{Y}^\vee$. Let $\mathcal{N}_{(1,0)}$ be the Rapoport-Zink space defined similarly as above using the framing object $(\mathbb{Y},\iota_\mathbb{Y},\lambda_\mathbb{Y})$.
Then $\mathcal{N}_{(1,0)}\cong {\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ and the universal strict $\mathcal{O}_{F_0}$-module over $\mathcal{N}_{(1,0)}$ is the canonical lift $\mathcal{G}$ of $\mathbb{Y}$ with respect to the $\mathcal{O}_F$ action (see \cite{G} or \cite[Section 8]{ARGOS}).

Let $\mathcal{N}^\mathrm{Kra}$ be the functor over $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}$ whose $S$-point is the groupoid of isomorphism classes of quintuples $ (X,\iota,\lambda,\rho,\mathcal{F}_X)$ over $S\in \mathrm{Nilp}\,  \mathcal{O}_{\breve F}$. Here the quadruple $(X,\iota,\lambda,\rho)$ has exactly the same meaning as in the definition of $\mathcal{N}^\mathrm{Pap}$ and the additional data $\mathcal{F}_X$ is a $\mathcal{O}_F\otimes_{\mathcal{O}_{F_0}}\mathcal{O}_S$-stable local direct summand of rank $n-1$ of $\mathrm{Lie}\,  X$. We require that $\mathcal{O}_F$ acts on $\mathcal{F}_X$ via the structure map $\mathcal{O}_F\rightarrow\mathcal{O}_S$ and acts on $\mathrm{Lie}\,  X/\mathcal{F}_X$ via the Galois conjugate of the structure map. An isomorphism between two quintuples $(X,\iota,\lambda,\rho,\mathcal{F}_X)$ and $(X',\iota',\lambda',\rho',\mathcal{F}_{X'})$ is given by an $\mathcal{O}_F$-linear isomorphism $\alpha:X\rightarrow X'$ such that $\rho'\circ (\alpha \times_S \bar{S})=\rho$, $\alpha^*(\lambda')$ is a $\mathcal{O}_{F_0}^\times$-multiple of $\lambda$ and $\alpha^*(\mathcal{F}_{X'})=\mathcal{F}_X$.
The following is essentially due to \cite{Kr}, see Theorem 2.3.2 and 2.3.3 of \cite{BHKRY1}.
\begin{proposition}\label{prop:Kramermodel}
$\mathcal{N}^\mathrm{Kra}$ is representable by a formal scheme flat over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ which is regular and has semi-stable reduction. The natural forgetful map
\[\Phi:\mathcal{N}^\mathrm{Kra}\rightarrow \mathcal{N}^\mathrm{Pap},(X,\iota,\lambda,\rho,\mathcal{F}_X)\mapsto (X,\iota,\lambda,\rho) \]
is an isomorphism outside the singular locus $\mathrm{Sing}$ of $\mathcal{N}^\mathrm{Pap}$ where $\iota(\pi)$ acts on $\mathrm{Lie}\,  X$ by $0$. Moreover $\Phi^{-1}(\mathrm{Sing})$ is a union of exceptional divisors each of which is isomorphic to the projective space $\mathbb{P}^{n-1}/k$.
\end{proposition}

The following fact should be well-known to experts. However due to the lack of a precise reference, we prove it in Appendix \ref{sec:Kramer model is blow up}.
\begin{proposition}\label{prop: Kra is blow up of Pappas}
$\mathcal{N}^\mathrm{Kra}$ is the blow-up of $\mathcal{N}^\mathrm{Pap}$ along its singular locus Sing.
\end{proposition}

\subsection{An exceptional isomorphism of moduli spaces}\label{subsec:exceptional iso}
From now on we assume $n=2$. In this case the right hand side of \eqref{eq:Kottwitzcondition} is $T^2-\pi_0$, hence is defined over $\mathcal{O}_{F_0}$. Furthermore the wedge condition \ref{eq:wedgecondition} is implied by \eqref{eq:Kottwitzcondition} so can be omitted.

Let $\mathbb{M}:=M(\mathbb{X})$ be the relative covariant Dieudonn\'e module of $\mathbb{X}$ over $\mathcal{O}_{F_0}$ and $N:=\mathbb{M} \otimes_{\mathbb{Z}} \mathbb{Q}$. Recall that $N$ is a $4$-dimensional $\breve{F}_0$-vector space with a $\sigma$-linear operator $F_\mathbb{X}$ and a $\sigma^{-1}$-linear operator $V_\mathbb{X}$ (see \cite[Appendix B.8]{fargues2006isomorphisme}), both commuting with the $F$-action which we still denote as $\iota_\mathbb{X}$. The polarization $\lambda_\mathbb{X}$ induces a skew symmetric $\breve{F}_0$ valued form $\langle,\rangle_\mathbb{X}$ on $N$ satisfying
\begin{align*}
    \langle F_\mathbb{X} (x),y\rangle_\mathbb{X}=&\langle x,V_\mathbb{X} (y)\rangle_\mathbb{X}^\sigma, \\
    \langle\iota_{\mathbb{X}}(a)x,y\rangle_\mathbb{X}=&\langle x,\iota_{\mathbb{X}}(\bar{a}y)\rangle_\mathbb{X}, a\in F.
\end{align*}
We denote by $\Pi_\mathbb{X}$ the endomorphism $\iota_{\mathbb{X}}(\pi)$ of $N$ and we often write $\Pi$ if there is no ambiguity. Following \cite{KR3}, we can define a  form $(,)_\mathbb{X}$ on $N$ by
\begin{equation}\label{eq:definitionof(,)}
(x,y)_\mathbb{X}=\delta[\langle \Pi x, y\rangle_\mathbb{X}+\pi \langle x, y\rangle_\mathbb{X}].
\end{equation}
Let $\tau=\Pi V_\mathbb{X}^{-1}$. Then $C:=N^\tau$ is a hermitian $F$-vector space such that $C \otimes_F \breve F= N$. The key assumption of this paper is that
\begin{equation}\label{eq:keyassumption}
    \text{the hermitian form } (,)_\mathbb{X} \text{ is anisotropic.}
\end{equation}
Equivalently, $-d \notin \mathrm{Nm}_{F/F_0}(F^\times)$ where $d$ is the determinant of $(,)_\mathbb{X}$. This is equivalent to the condition \eqref{eq:anisotropicassumption} in the introduction, see \eqref{eq:relationsonhermitianforms} below. Such a framing object $(\mathbb{X},\iota_\mathbb{X},\lambda_\mathbb{X})$ is unique up to isogenies which preserve the polarization up to a scalar in $\mathcal{O}_{F_0}^\times$.

\begin{comment}
Suppose $\pi_0=\epsilon p$ and let $\eta \in W$ such that $\eta \cdot \eta^\sigma=\epsilon^{-1}$. Define the $\sigma$-linear operator $\tau=\eta \Pi V^{-1}$ on $N$. Set $C=N^\tau$,  we obtain a $4$ dimensional $\mathbb{Q}_p$-vector space with an isomorphism
\[C\otimes_{\mathbb{Q}_p} W_\mathbb{Q} \simeq N.\]
Then for $x,y \in C$
\begin{align*}
    <x,y>=&<\tau x,\tau y>=<\eta \Pi V^{-1}x,\eta \Pi V^{-1}y> \\
    =& \eta^2 (-p \epsilon) <V^{-1}x,V^{-1}y> \\
    =& \eta^2 (-p \epsilon) p^{-1} <x,y>^\sigma \\
    =&-\frac{\eta}{\eta^\sigma} <x,y>^\sigma
\end{align*}
Choose $\delta\in\mathbb{Z}_{p^2}^{\times} \backslash \mathbb{Z}_p^{\times}$ such that $\delta^2\in \mathbb{Z}_p^\times$. Then the restriction of the form
\begin{equation}
    <,>'=\eta^\sigma \delta <,>
\end{equation}
to $C$ defines a skew symmetric form with values in $\mathbb{Q}_p$, and
\begin{equation}\label{definitionof(,)}
    (x,y)=<\Pi x,y>'+<x,y>'\pi
\end{equation}
defines a hermitian form on $C$ with
\[<x,y>'=\frac{1}{2} \mathrm{tr}_{F/F_0}(\pi^{-1}(x,y)).\]
\end{comment}

In fact, $\mathcal{N}^\mathrm{Pap}$ can be descended to $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}_0}$ (see \cite[Section 8]{RSZ}). We denote by $\mathcal{N}$ the corresponding moduli functor defined over $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}_0}$. In other words we have
\begin{equation}
   \mathcal{N}^\mathrm{Pap}= \mathcal{N} \times_{\mathrm{Spf}\,  \mathcal{O}_{\breve{F}_0}} {\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }.
\end{equation}
where $\times$ is the complete tensor product for formal schemes.
By assumption \eqref{eq:keyassumption} we have the following.
\begin{proposition}(\cite[Section 8]{RSZ})
$\mathcal{N}$ has a unique reduced point on its special fiber.
As formal schemes,
\[\mathcal{N} \cong \mathrm{Spf}\,  \mathcal{O}_{\breve{F}_0} [[x,y]]/(x y-\pi_0).\]
In particular $\mathcal{N}$ has semi-stable reduction and is regular.
\end{proposition}
\begin{remark}
In contrast, $\mathcal{N}^\mathrm{Pap}$ is not regular. But it is normal and Cohen-Macaulay, see \cite[Theorem 4.5]{P}.
\end{remark}

Moreover by \cite[Section 8]{RSZ}, $\mathcal{N}$ is isomorphic to a Lubin-Tate deformation space with Iwahori level structure. We recall the construction now.
In the following, we define every moduli functor over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ as this is all we need.
Let $\mathcal{M}_{\Gamma_0(\pi)}$ represent the functor over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ that associate each scheme $S\in \mathrm{Nilp}\,  \mathcal{O}_{\breve{F}}$ the set of isomorphism classes of quadruples
\[(Y,Y',\phi:Y \rightarrow Y',\rho_Y),\]
where $Y$ and $Y'$ are strict formal $\mathcal{O}_{F_0}$-modules over $S$ of $F_0$-height $2$ and dimension one, $\phi$ is an isogeny of degree $q$ and $\rho_Y: Y\times_{S} \bar{S}\rightarrow \mathbb{Y} \times_{\mathrm{Spec}\,  k} \bar{S}$ is a quasi-isogeny of formal $\mathcal{O}_{F_0}$-modules of height $0$. We can define a map $ \mathcal{M}_{\Gamma_0(\pi)}\rightarrow \mathcal{N}^\mathrm{Pap}$ as follows. Let $(Y,Y',\phi, \rho_Y)$ be in $ \mathcal{M}_{\Gamma_0(\pi)}(S)$, set
\[X:=Y\times Y'.\]
We can define an $\mathcal{O}_F$-action on $X$ by
\begin{equation}\label{eq:iota X in cN}
   \iota_X(\pi)=\left(\begin{array}{cc}
     & \phi' \\
    \phi &
\end{array} \right),
\end{equation}
where $\phi'$ is the dual isogeny of $\phi$ ($ \phi'\circ \phi=\pi_0$). Define the framing map
\begin{equation}\label{eq:rhoY'}
  \rho_{Y'}: Y'\times_{S} \bar{S}\overset{\phi^{-1}}{\longrightarrow} Y\times_{S} \bar{S} \overset{\rho_Y}{\longrightarrow} \mathbb{Y} \times_{\mathrm{Spec}\,  k} \bar{S} \overset{\iota_{\mathbb{Y}}(\pi)}{\longrightarrow} \mathbb{Y} \times_{\mathrm{Spec}\,  k} \bar{S}.
\end{equation}
Then $\rho_Y^*(\lambda_{\mathbb{Y}}) $ and $\rho_{Y'}^*(\lambda_{\mathbb{Y}}) $ lift to principal polarization $\lambda_Y$ of $Y$ and $\lambda_{Y'}$ of $Y'$. Let
\[\lambda_X=\left(\begin{array}{cc}
    \lambda_Y &  \\
     & \lambda_{Y'}
\end{array} \right).\]
Then we get the object $(X,\iota_X, \lambda_X,\rho_X)\in \mathcal{N}^\mathrm{Pap}(S)$. This defines a map $ \mathcal{M}_{\Gamma_0(\pi)}\rightarrow \mathcal{N}^\mathrm{Pap}$ which is obviously functorial in $S$.
\begin{proposition}(\cite[Proposition 8.2]{RSZ})\label{prop:exceptionaliso}
 the map $ \mathcal{M}_{\Gamma_0(\pi)}\rightarrow \mathcal{N}^\mathrm{Pap}$ is an isomorphism.
\end{proposition}

Let $\mathcal{M}$ be the Lubin-Tate moduli functor over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ that associates to each scheme $S$ the set of isomorphism classes of pairs
\[(Y,\rho_Y)\]
where $Y$ is a strict formal $\mathcal{O}_{F_0}$-module of $F_0$-height $2$ and dimension $1$ over $S$ and $\rho_Y:Y\times_S \bar{S}\rightarrow \mathbb{Y} \times_{\mathrm{Spec}\,  k} \bar{S}$ a quasi-isogeny of formal $\mathcal{O}_{F_0}$-modules of height $0$. Then it is well-known that (see for example \cite[Theorem 3.8]{viehmannKonstantin})
\begin{equation}
    \mathcal{M}\cong {\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }[[T]].
\end{equation}
For later use we recall the following lemma from classical literature.
\begin{lemma}\label{lem:modularequation}
$\mathcal{M}_{\Gamma_0(\pi)}$ embeds into $\mathcal{M}\times\mathcal{M}$ as a divisor.
In other words, there is a $f\in \mathcal{O}_{\breve{F}_0}[[X,Y]]$ such that
\[\mathcal{M}_{\Gamma_0(\pi)}\cong \mathrm{Spf}\,  \mathcal{O}_{\breve{F}}[[X,Y]]/(f(X,Y)).\]
For $i=1,2$, let $p_i$ be the morphism which is the composition of the embedding  $\mathcal{M}_{\Gamma_0(\pi)}\rightarrow \mathcal{M}\times \mathcal{M}$ with the projection of $\mathcal{M}\times \mathcal{M}$ to its $i$-th factor.
Then $p_i$ is finite of degree $q+1$.
\end{lemma}
\begin{proof}
This is well-known so we sketch its proof very quickly.
With the choice of framing maps $\rho_Y$ and $\rho_{Y'}$ as in \eqref{eq:rhoY'}, $\mathcal{M}_{\Gamma_0(\pi)}$ is exactly the locus of $\mathcal{M}\times\mathcal{M}$ where the isogeny $\iota_\mathbb{Y}(\pi)$ lifts. The fact that $\mathcal{M}_{\Gamma_0(\pi)}$ is a divisor is now an immediate consequence of Grothendieck-Messing deformation theory.

To prove the finiteness of the morphism $\mathcal{M}_{\Gamma_0(\pi)}\rightarrow \mathcal{M}$, notice that the morphism $\mathcal{M}'\rightarrow \mathcal{M}$ factor through $\mathcal{M}_{\Gamma_0(\pi)}$ where $\mathcal{M}'$ is the Lubin-Tate space with Drinfeld level structure:
\[\mathcal{M}'(S)=\{(X,\rho,z)\mid (X,\rho)\in \mathcal{M}(S), z\in X \text{ is a divisor of exact order } q\}.\]
$\mathcal{M}'$ is in turn a subfunctor of $\mathcal{M}'$ whose $S$-point is
\[\mathcal{M}''(S)=\{(X,\rho,z)\mid (X,\rho)\in \mathcal{M}(S), z\in X, [\pi_0](z)=0\}\]
where $[\pi_0]$ is the action of $\pi_0$ on $X$.
So it suffices to prove the finiteness of $\mathcal{M}''\rightarrow \mathcal{M}$.
But this is a consequence of the Weierstrass preparation theorem for complete local rings and the fact that $[\pi_0]\times k$ can be represented by a polynomial.

Finally, to calculate the degree of the morphism $\mathcal{M}_{\Gamma_0(\pi)}\rightarrow \mathcal{M}$, it is enough to compute it on the generic fiber by studying the Tate module. The degree is then in fact $|\mathbb{P}^1(\mathbb{F}_q)|=q+1$.
\end{proof}
\begin{remark}\label{rmk:modularequation}
When $F_0=\mathbb{Q}_p$, the equation $f(X,Y)$ is exactly the classical modular polynomial such that
\[f(X,Y)\equiv (X-Y^p)(Y-X^p)\pmod{p}.\]
\end{remark}

\subsection{Dieudonn\'e module of the framing objects}\label{subsec:Dieudonnemodulecalculation}
We know that $\mathcal{M}_{\Gamma_0(\pi)}$ has a unique $k$-point which is $(\mathbb{Y},\mathbb{Y}, \iota_{\mathbb{Y}}(\pi),\mathrm{id}_\mathbb{Y})$. Under the isomorphism  $ \mathcal{M}_{\Gamma_0(\pi)}\rightarrow \mathcal{N}^\mathrm{Pap}$, this point goes to $(\mathbb{X},\iota_\mathbb{X},\lambda_\mathbb{X},\mathrm{id}_\mathbb{X})\in \mathcal{N}^\mathrm{Pap}$ where
\begin{equation}\label{eq:definitionofbX}
    \mathbb{X}=\mathbb{Y}\times \mathbb{Y}, \ \iota_\mathbb{X}(\pi)=\left(\begin{array}{cc}
         &  \iota_\mathbb{Y}(\pi)\\
      \iota_\mathbb{Y}(\pi)   &
    \end{array}\right),\ \lambda_\mathbb{X}=\left(\begin{array}{cc}
      \lambda_\mathbb{Y}   &  \\
         & \lambda_\mathbb{Y}
    \end{array}\right).
\end{equation}
$(\mathbb{X},\iota_\mathbb{X},\lambda_\mathbb{X},\rho_\mathbb{X})$ is the unique reduced $k$-point of $\mathcal{N}^\mathrm{Pap}$, we denote it by Sing. Here $(\mathbb{X},\iota_\mathbb{X},\lambda_\mathbb{X})$ is actually the framing object for $\mathcal{N}^\mathrm{Pap}$. We describe its relative Dieudonn\'e module $\mathbb{M}$ explicitly.

First let us describe the relative Dieudonn\'e module $M(\mathbb{Y})$ of $\mathbb{Y}$ (see \cite[Remark 2.15]{Shi1}). As an $\mathcal{O}_{\breve{F}_0}$ lattice, it is of rank 2. We can choose a basis $\{e,f\}$ such that
$F_\mathbb{Y} e=f,F_\mathbb{Y} f=\pi_0 e,V_\mathbb{Y} e=f,V_\mathbb{Y} f=\pi_0 e$ and $\langle e,f\rangle_\mathbb{Y}=\delta$. With respect to this basis,
$\mathrm{End}(\mathbb{Y})$ is of the form
\begin{equation}\label{eq:End bY is Oo_H}
    \left\{\left(\begin{array}{cc}
    a & b \pi_0  \\
    b^\sigma & a^\sigma
\end{array}\right) \mid a,b \in F_0[\delta]\cap \mathcal{O}_{\mathbb{H}}\right\}\cong \mathcal{O}_{\mathbb{H}}.
\end{equation}
One can check that under the pairing $\langle,\rangle_\mathbb{Y}$, the Rosati involution of an element in $\mathrm{End}(\mathbb{Y})$ is given by the main involution of $\mathbb{H}$
\begin{equation}\label{rosatiinvolutionofbG}
    \left(\begin{array}{cc}
    a & b\pi_0  \\
    b^\sigma & a^\sigma
\end{array}\right)^*=
\left(\begin{array}{cc}
    a^\sigma & -b\pi_0  \\
    -b^\sigma & a
\end{array}\right).
\end{equation}
As in the proof of \cite[Proposition 8.2]{RSZ},
by changing basis using elements in $\mathbb{H}\cap \mathrm{SL}_2(F_0)$ we can assume $F$ and $V$ are of the same matrix form as before and
\begin{equation}\label{eq:standardpiaction}
  \Pi=\left(\begin{array}{cc}
    0 & \pi_0  \\
    1 & 0
\end{array}\right).
\end{equation}
Thus $\tau$ is the diagonal matrix $\mathrm{Diag}\{1,1\}$. It fixes the $F_0$-vector space $\mathrm{span}_{F_0}\{ e,f\}$. Then
\begin{equation}\label{eq:(e,e)}
    (e,e)_\mathbb{Y}=-\delta^2
\end{equation}
As $\mathcal{O}_F$ is a DVR and $M(\mathbb{Y})\otimes_\mathbb{Z} \mathbb{Q}$ is a one dimensional $F$-space, there is a unique self-dual $\mathcal{O}_F$-lattice w.r.t. $(,)_\mathbb{Y}$, i.e., $\mathrm{span}\{e\}$. Let $\rho_{\mathbb{Y}}$ be the identity of $\mathbb{Y}$, then $(\mathbb{Y},\iota_\mathbb{Y}, \lambda_\mathbb{Y},\rho_\mathbb{Y})$ is the unique closed point of $\mathcal{N}_{(1,0)}(k)$.

Now let $\mathbb{X}$ be defined in \eqref{eq:definitionofbX}. We denote the first copy of $\mathbb{Y}$ as $\mathbb{Y}_1$ and the second copy as $\mathbb{Y}_2$.
In terms of the Dieudonn\'e module $\mathbb{M}=M(\mathbb{X})$ we assume that $\{e_1, f_1\}$ is a basis of $M(\mathbb{Y}_1)$  and $\{e_2, f_2\}$ is a basis of $M(\mathbb{Y}_2)$ such that
\[F_\mathbb{X} e_i=f_i,F_\mathbb{X} f_i=\pi_0 e_i, V_\mathbb{X} e_i=f_i,V_\mathbb{X} f_i=\pi_0 e_i,\langle e_i,f_j\rangle_\mathbb{X}=\delta \delta_{ij},\  i,j=1,2.\]
Using \eqref{eq:iota X in cN} and \eqref{eq:standardpiaction}, we can see that
\begin{equation}\label{eq:Pimatrixform}
    \Pi(e_1)=f_2, \ \Pi(f_1)=\pi_0 e_2,\
    \Pi(e_2)= f_1, \ \Pi(f_2)=\pi_0 e_1.
\end{equation}
It is then easy to see that $\Pi^2=\pi_0$ and $\langle\Pi x,y\rangle_{\mathbb{X}}=\langle x,-\Pi y\rangle_{\mathbb{X}} $ for $x,y\in M(X)$.
Define
\begin{equation}\label{eq:v_1 v_2}
   v_1:= e_1+e_2, \ v_2:=\delta (e_1-e_2).
\end{equation}
Then we have
\[\tau(v_1)=v_1, \tau(v_2)=v_2,\]
where $\tau=\Pi V_\mathbb{X}^{-1}$ and
\begin{align}\label{eq:Gram matrix of v_1 v_2}
    (v_1,v_1)_\mathbb{X}=&\delta \langle\Pi v_1,v_1\rangle_\mathbb{X}+\pi \delta\langle v_1,v_1\rangle_\mathbb{X}
    = -2\delta^2 , \\ \nonumber
    (v_1,v_2)_\mathbb{X}=& \delta \langle\Pi v_1,v_2\rangle_\mathbb{X}+\pi \delta\langle v_1,v_2\rangle_\mathbb{X}
    = 0, \\ \nonumber
    (v_2,v_2)_\mathbb{X}=& \delta \langle\Pi v_2,v_2\rangle_\mathbb{X}+\pi \delta\langle v_2,v_2\rangle_\mathbb{X}
    = 2\delta^4 .
\end{align}

\begin{comment}
And we have
\begin{align*}
    \Pi(e_1+e_2)=f_1+f_2, &\  \Pi(f_1+f_2)=\pi_0 (e_1+e_2),\\
    \Pi(e_1-e_2)=-(f_1-f_2), &\  \Pi(f_1-f_2)=-\pi_0 (e_1-e_2).
\end{align*}
So the hermitian form of $C$ with respect to the basis $\{v_1,v_2\}$ is represented by the Gram matrix
\[\left(\begin{array}{cc}
   -2\delta^2   & 0 \\
    0 & 2\delta^4
\end{array}\right).\]
Recall that a two dimensional hermitian form over $F_0$ with determinant $d$ is anisotropic if and only if $(-d)\notin \mathrm{Nm}_{F/F_0}(F^\times)$. Hence the above hermitian form is anisotropic since it has determinant $-\delta^2( 2\delta^2)^2 $ and $\delta^2 \notin \mathrm{Nm}_{F/F_0}(F^\times)$.

For later use, we define an automorphism $s_\delta$ of $(\mathbb{X},\iota_\mathbb{X}, \lambda_\mathbb{X})$  by
\begin{equation}\label{s_delta}
   s_\delta(x,y)=(\delta x, -\delta y),
\end{equation}
where $x,y\in \mathbb{Y}(R)$, $R$ is a $k$-algebra.
We need to check that $s_\delta \circ \iota_\mathbb{X}(\pi)=\iota_\mathbb{X}(\pi)\circ s_\delta$. In fact
\begin{align*}
    s_\delta \circ \iota_\mathbb{X}(\pi)(x,y)=& s_\delta(\pi y,\pi x)
    = (\delta \pi y,-\delta \pi x),\\
    \iota_\mathbb{X}(\pi)\circ s_\delta(x,y)=& \iota_\mathbb{X}(\pi) (\delta x, -\delta y)
    = (-\pi \delta y,\pi \delta x).
\end{align*}
Moreover, the induced action of $s_\delta$ on $\mathbb{M}$ multiply the bilinear form $\langle,\rangle_\mathbb{X}$ by $-\delta ^2$.

\[s_\delta (e_1)=\delta e_1, s_\delta (f_1)=-\delta f_1,s_\delta (e_2)=-\delta e_2,s_\delta (f_2)=\delta f_2,\]
\[s_\delta (v_1)=v_2, s_\delta (v_2)=\delta^2 v_1.\]
\end{comment}

\subsection{Kr\"amer model}\label{subsec:Kramermodel}
We need some information on  the local model $N^\mathrm{Kra}$ of $\mathcal{N}^\mathrm{Kra}$ in the sense of \cite[Definition 3.27]{RZ}. Again we assume $n=2$ and  \eqref{eq:anisotropicassumption}.
For the complete definition, see Appendix \ref{sec:Kramer model is blow up}.
For now we just need to know that $N^\mathrm{Kra}$ is representable by a regular scheme which is flat over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ and can be covered by affine charts $U_i$ charts $U_i=\mathrm{Spec}\,  R_i$ ($i=1,2$) where
\begin{equation}\label{eq:Kramer model equation}
    R_i=\mathcal{O}_{\breve F}[x_i^1, x_i^2, y_i]/(y_i((x_i^1)^2+(x_i^2)^2)-2\pi, x^i_i=1).
\end{equation}
The following transition relations between coordinate functions hold in $U_i\cap U_j$ where $x_i^j$ and $x_j^i$ are units.
\begin{equation}\label{eq:coordinate change of Kramer model}
    x_i^\ell=x_i^j x_j^\ell,\ y_i=(x_j^i)^2 y_j.
\end{equation}
The special fiber of $N^\mathrm{Kra}$ consists of two divisors $Z_1$ and $Z_2$ where $Z_1 \cong \mathbb{P}^{1}/k$ is the exceptional divisor of $N^\mathrm{Kra}$ defined by the equation $y_i=0$ in $U_i$:
\begin{equation}\label{eq:Z1}
    Z_1\cap U_i=\mathrm{Spec}\,  (k[x_i^1, x_i^2]/(x_i^i-1)).
\end{equation}
And $Z_2$ is defined by the equation $\sum_{j=1}^2 (x_i^j)^2=0$ in $U_i$:
\begin{equation}\label{eq:Z2}
    Z_2 \cap U_i=\mathrm{Spec}\,  (k[x_i^1,x_i^2,y_i]/(x_i^i-1,(x_i^1)^2+(x_i^2)^2).
\end{equation}

\begin{lemma}\label{lem:Z1 intersect Z2}
$Z_1$ and $Z_2$ intersect transversely at the two singular points of the special fiber $N^\mathrm{Kra}_s$ of $N^\mathrm{Kra}$ and the intersection number is $2$.
\end{lemma}
\begin{proof}
From \eqref{eq:Z1} and \eqref{eq:Z2}, we see that the intersection of $Z_1$ and $Z_2$ in $U_i$ ($1\leq i \leq 2$) is
\[\mathrm{Spec}\,  (k[x_i^1, x_i^2]/(x_i^i-1,(x_i^1)^2+(x_i^2)^2).\]
Hence in the homogeneous coordinate of $\mathbb{P}^1/k$, the intersection locus is the union of two points $[(1,\sqrt{-1})]$ and $[(-1,\sqrt{-1})]$, each with multiplicity one. Notice that the two points are exactly the singular locus of $N^\mathrm{Kra}_s$.
\end{proof}

\begin{lemma}\label{lem:cNKra is completion of local model}
There is an isomorphism of formal schemes
\[s:\mathcal{N}^\mathrm{Kra} \rightarrow (N^\mathrm{Kra})_{Z_1},\]
where $(N^\mathrm{Kra})_{Z_1}$ is the formal completion of $N^\mathrm{Kra}$ along $Z_1$.
\end{lemma}
\begin{proof}
By \cite[Proposition 3.33]{RZ}, there is a formally \'etale morphism
\[s_0:\mathcal{U}\rightarrow (N^\mathrm{Pap})_\pi\]
where $\mathcal{U}$ is an \'etale neighbourhood of $\mathcal{N}^\mathrm{Pap}$, $N^\mathrm{Pap}$ is the local model of $\mathcal{N}^\mathrm{Pap}$ (whose definition will be recalled in Appendix \ref{sec:Kramer model is blow up}) and $(N^\mathrm{Pap})_\pi$ is its $\pi$-adic completion. Since $\mathcal{N}^\mathrm{Pap}$ is strictly Henselian and local (this for example follows from Proposition \ref{prop:exceptionaliso}), $\mathcal{U}=\mathcal{N}^\mathrm{Pap}$.
By the proof of \cite[Corollary 4.13]{P}, we have
\[N^\mathrm{Pap}=\mathcal{O}_{\breve F}[x_1,x_2]/(x_1^2+x_2^2-\pi_0)\]
and the image of Sing under $s_0$ is the point $pt$ in the special fiber of $N^\mathrm{Pap}$ defined by $x_1=x_2=\pi=0$. Again since $\mathcal{N}^\mathrm{Pap}$ is strictly Henselian and local, $s_0$ factor through
\[s_0':\mathcal{N}^\mathrm{Pap}\rightarrow (N^\mathrm{Pap})_{pt}\]
which is again formally \'etale. Here $(N^\mathrm{Pap})_{pt}$ is the completion of $(N^\mathrm{Pap})_\pi$ along $pt$. Since both structure rings are local and strictly Henselian, the morphism $s'_0$ is in fact an isomorphism. The lemma now follows from Proposition \ref{prop: Kra is blow up of Pappas} and its analogue for local models, namely Lemma \ref{lem:local model isomorphism}.
\end{proof}

We denote the unique exceptional divisor of $\mathcal{N}^\mathrm{Kra}$ by $\mathrm{Exc}$. By Proposition \ref{prop:Kramermodel}, $\iota_\mathbb{X}(\pi)$ acts trivially on $\mathrm{Lie}\,  \mathbb{X}$. Hence we can choose $\mathcal{F}_\mathbb{X}$ to be any line in $\mathrm{Lie}\,  \mathbb{X}$ and $\mathrm{Exc}=\mathbb{P}^1(\mathrm{Lie}\, \mathbb{X})$.
Under this isomorphism of Lemma \ref{lem:cNKra is completion of local model}, we have,
\begin{equation}
    s^{-1}(Z_1)=\mathrm{Exc}=\mathbb{P}^1(\mathrm{Lie}\, \mathbb{X})\cong \mathbb{P}^1(V\mathbb{M}/\pi_0\mathbb{M}),
\end{equation}
where the last isomorphism  sends a line $L$ in $\mathrm{Lie}\,  \mathbb{X}$ to its perpendicular line $L^\vee\subset V\mathbb{M}/\pi_0\mathbb{M}$ under the pairing $\langle,\rangle_\mathbb{X}$ described in Section \ref{subsec:Dieudonnemodulecalculation}.

We now describe $s^{-1} (Z_1\cap Z_2)$, namely the two singular points of the special fiber of $\mathcal{N}^\mathrm{Kra}$. Recall that $V_\mathbb{X}\mathbb{M}=\Pi \mathbb{M}=\mathrm{span}\{f_1,f_2\}$ in the coordinates introduced in  Section \ref{subsec:Dieudonnemodulecalculation}. The quadratic form $(x_i^1)^2+(x_i^2)^2$ that shows up in equation \eqref{eq:Kramer model equation} corresponds to the quadratic form (see \cite[page 9]{Kr})
\[\{\Pi v,\Pi w\}:=\langle\Pi v,  w\rangle_{\mathbb{X}},\]
for $\Pi v,\Pi w \in V \mathbb{M}$. Now by equation \eqref{eq:Pimatrixform} we see that
\[\{f_1,f_1\}=\langle e_2,f_1\rangle_\mathbb{X}=0.\]
Similarly $\{f_2,f_2\}=0$. Hence $s^{-1} (Z_1\cap Z_2)$ correspond to the two lines spanned by $f_1$ and $f_2$ respectively in $V\mathbb{M}/\pi_0\mathbb{M}$. Taking their perpendicular lines in $\mathrm{Lie}\, \mathbb{X}= \mathbb{M}/V\mathbb{M}$, we have shown that
\begin{lemma}\label{lem:intersectionofZ1Z2}
$\mathrm{Exc}\cap s^{-1}(Z_2)$ are the two points $P_1=\mathrm{span}_k\{e_1\}$ and $P_2=\mathrm{span}_k\{e_2\}$ in $\mathbb{P}^1(\mathrm{Lie}\, \mathbb{X})$.
\end{lemma}

The reduced locus of $\mathcal{N}^\mathrm{Kra}$ is its exceptional divisor. In particular it is proper over $\mathrm{Spec}\,  k$.
For two divisors $\mathcal{Z}_1$ and $\mathcal{Z}_2$ of $\mathcal{N}^\mathrm{Kra}$ such that the support of their intersection is contained in the reduced locus, one can define their intersection number to be
\begin{equation}
   \mathcal{Z}_1 \cdot \mathcal{Z}_2= \chi(\mathcal{N}^\mathrm{Kra}, \mathcal{O}_{\mathcal{Z}_1}\otimes^{\mathbb{L}} \mathcal{O}_{\mathcal{Z}_2}).
\end{equation}
where $\otimes^{\mathbb L}$ is the derived tensor product of coherent sheaves on $\mathcal{N}^\mathrm{Kra}$ and $\chi$ takes the Euler characteristics. It is easy to compute the self intersection number of $\mathrm{Exc}$.
\begin{lemma}\label{lem:Excselfintersection}
\[\mathrm{Exc}\cdot \mathrm{Exc}=-2.\]
\end{lemma}
\begin{proof}
By Lemma \ref{lem:cNKra is completion of local model}, it suffices to compute $Z_1\cdot Z_1$. Since $N^\mathrm{Kra}$ is regular and flat over $\mathrm{Spf}\,  \mathcal{O}_{\breve F}$,
Proposition 1.21 of \cite[Chapter 9]{L} implies that the intersection number of $Z_1$ with the special fiber $N^\mathrm{Kra}_s$ of $N^\mathrm{Kra}$ is $0$. But
\[N^\mathrm{Kra}_s=Z_1+Z_2.\]
The lemma now follows from Lemma \ref{lem:Z1 intersect Z2}.
\end{proof}

\section{Quasi-canonical lifting divisors}\label{sec:quasicanonicalliftingdivisor}
In this section we define sub formal schemes of $\mathcal{N}^\mathrm{Pap}$ and $\mathcal{N}^\mathrm{Kra}$ based on the theory of quasi-canonical lifts of Gross (\cite{G}). Our main reference is \cite{W}. For simplicity we often use $\otimes k$ to denote the base change $\times_{{\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }} \mathrm{Spec}\,  k$.
\subsection{Quasi-canonical lifts on $\mathcal{M}$}\label{subsec:quasicanonicallifts}
Let $\kappa:\mathcal{O}_F\hookrightarrow \mathrm{End}(\mathbb{Y})=\mathcal{O}_{\mathbb{H}}$ be an embedding. Via this embedding we obtain a map $\mathcal{O}_F\rightarrow \mathrm{End}(\mathrm{Lie}\,  \mathbb{Y})=k$, which extends the canonical residue map $\mathcal{O}_{F_0}\rightarrow k$.
\begin{comment}
determined by
\begin{equation}\label{kappaembedding}
   \kappa(a+b \pi)=\left(\begin{array}{cc}
    a & b \pi_0 \\
    b & a
\end{array}\right), a,b\in \mathcal{O}_{F_0}
\end{equation}
where we have identified $\mathcal{O}_\H$ with $\mathrm{End}(\mathbb{Y})$ via \eqref{eq:End bY is Oo_H}.
\end{comment}

Fix an $s\geq 0$. Let
\begin{equation}\label{eq:Oo_s}
  \mathcal{O}_s=\mathcal{O}_{F_0}+\mathcal{O}_F\cdot \pi_0^s.
\end{equation}
Let  $M_s$ be the ring class field of $\mathcal{O}_s^\times$, i.e., \ the finite abelian extension of $\breve{F}$ corresponding to the subgroup $\mathcal{O}_s^\times$ of $\mathcal{O}_F^\times$ under the reciprocity isomorphism of Lubin-Tate theory:
\begin{equation}\label{eq:Artinmap}
   \gamma:\mathrm{Gal}(\bar{\breve{F}}/\breve{F})^{ab}\rightarrow \mathcal{O}_F^\times.
\end{equation}
Let $W_s$ be the ring of integers of $M_s$.
Notice that in this notation $M_0=\breve{F}$, $W_0=\mathcal{O}_{\breve F}$. We have
\[[W_s: \mathcal{O}_{\breve{F}}]=[\mathcal{O}_F^\times:\mathcal{O}_s^\times]=q^s.\]
By its definition, $W_s/\mathcal{O}_{\breve{F}_0}$ is totally ramified and integrally closed.

\begin{definition}(\cite[Definition 3.1]{W})\label{def:quasi canonical lifts}
A quasi-canonical lift of level $s$ with respect to the embedding $\kappa:\mathcal{O}_F\hookrightarrow \mathcal{O}_{\mathbb{H}}$ is a triple $(\mathcal{G}',\rho,\iota_{\mathcal{G}'})$. Here $\mathcal{G}'$ is a lift of $\mathbb{Y}$ defined over some finite extension $A'/ \mathcal{O}_{\breve{F}}$. Meanwhile $\rho: \mathcal{G}'\times \mathrm{Spec}\,  k \overset{\sim}{\longrightarrow} \mathbb{Y}$ is an isomorphism of strict formal $\mathcal{O}_{F_0}$-modules and $\iota_{\mathcal{G}'}:\mathcal{O}_s \overset{\sim}{\longrightarrow} \mathrm{End}(\mathcal{G}')$ is an  $\mathcal{O}_{F_0}$-algebra isomorphism. We require the following conditions.
\begin{enumerate}
    \item The composition of $\iota_{\mathcal{G}'}$ together with the natural embedding $\mathrm{End}(\mathcal{G}')\rightarrow \mathrm{End} (\mathrm{Lie}\,  \mathcal{G}')=A'$ is the canonical inclusion $\mathcal{O}_s\rightarrow A'$.\
    \item The composition of $\iota_{\mathcal{G}'}$ with the inclusion $\mathrm{End}(\mathcal{G}')\hookrightarrow \mathrm{End}(\mathbb{Y})=\mathcal{O}_{\mathbb{H}}$ induced by $\rho$ is equal to $\kappa|_{\mathcal{O}_s}$.
\end{enumerate}
We call a quasi-canonical lift of level $0$ a canonical lift.
\end{definition}
\begin{remark}
To ease notation, we often omit $\iota_{\mathcal{G}'}$ from the triple $(\mathcal{G}',\rho,\iota_{\mathcal{G}'})$. We also say $\mathcal{G}'$ is a quasi-canonical lift without mentioning the framing map $\rho$ if condition (1) above is satisfied.
\end{remark}
\begin{remark}\label{rmk: cG independent of kappa}
Let $\kappa,\kappa'$ be two embeddings $\mathcal{O}_F\rightarrow \mathcal{O}_{\mathbb H}$. By Skolem-Noether Theorem, there is an element $a\in \mathcal{O}^\times_{\mathbb H}$ such that $\kappa'=a\kappa a^{-1}$. If $(\mathcal{G}',\rho)$ is a quasi-canonical lift of level $s$ with respect to $\kappa$, then $(\mathcal{G}',\iota_\mathbb{Y}(a)\circ \rho)$ is a quasi-canonical lift of level $s$ with respect to $\kappa'$.
\end{remark}

Canonical lift can be defined over $\mathcal{O}_{\breve F}$ and is unique up to isomorphism, we fix such a choice and denote it by $\mathcal{G}$. By Remark \ref{rmk: cG independent of kappa} we can assume $\mathcal{G}\otimes k=\mathbb{Y}$ and $\iota_\mathcal{G}\otimes k=\iota_\mathbb{Y}$.
More generally quasi-canonical lifts of level $s$ always exists. Their minimal ring of definition is $W_s$, see Theorem 3.2 and Corollary 4.7 of \cite{W}. A quasi-canonical lift $(\mathcal{G}_s,\rho)$ with respect to $\kappa$ defines a deformation of $(\mathbb{Y},\rho_\mathbb{Y})$ to $\mathrm{Spf}\,  W_s$. Hence we obtain a morphism
\[\mathrm{Spf}\,  W_s\rightarrow \mathcal{M}.\]
\begin{lemma}\label{lem: definition of cW_s}
The morphism $\mathrm{Spf}\,  W_s\rightarrow \mathcal{M}$ is a closed embedding and defines a Cariter divisor $\mathcal{W}_s^\kappa$ of $\mathcal{M}$. Moreover the resulting divisor $\mathcal{W}_s^\kappa$ is independent of the choice of the quasi-canonical lift $(\mathcal{G}_s,\rho)$.
\end{lemma}
\begin{proof}
Since $\mathcal{M}\cong \mathrm{Spf}\, \mathcal{O}_{\breve{F}}[[X]]$, the first claim follows from the fact that $X$ pullbacks to a uniformizer of $W_s$, which in turn follows from \cite[Corollary 4.7]{W}.

Assume that $\mathcal{W}_s^\kappa$ is defined by the degree $q^s$ monic polynomial $g_s(X)$.
By \cite[Theorem 3.2]{W}, the set of quasi-canonical lifts of level $s$ is acted simply transitively on by the Galois group $\mathrm{Gal}(W_s/\mathcal{O}_{\breve F})$ and can be identified with
\begin{equation}\label{eq:g_s(X)}
    \mathrm{Hom}_{\mathcal{O}_{\breve{F}}}(\mathcal{O}_{\breve{F}}[[X]]/(g_s(X)),W_s),
\end{equation}
or in other words the set of roots of $g_s(X)$ in $W_s$. This proves the second claim of the lemma.
\end{proof}
\begin{remark}\label{rmk: root of g_s generates W_s}
by \cite[Corollary 4.7]{W}, we know that each root $x_s$ of $g_s(X)$ is a uniformizer of $W_s$. In particular, $W_s=\mathcal{O}_{\breve F}[x_s]$.
\end{remark}

\subsection{Quasi-canonical lifting divisors on $\mathcal{N}^\mathrm{Pap}$}\label{subsec:quasi canonical lifting on NPap}
Throughout the rest of the paper we use the notation
\begin{equation}\label{eq:m(s)}
    m(s)=\left\{\begin{array}{cc}
    s-1 & \text{ if } s\geq 1,\\
    0 & \text{ if } s=0.
\end{array}\right.
\end{equation}
\begin{proposition}\label{prop:quasi canonical divisor on NPap}
For all $s\geq 0$ there exist quasi-canonical lifts $(\mathcal{G}_s,\rho_s)$ of level $s$ with respect to $\kappa$ together with a morphism $\beta_s:\mathcal{G}_{m(s)}\rightarrow \mathcal{G}_s$ such that the following diagrams commute
\begin{equation}\label{eq:cXs definition diagram}
\begin{tikzcd}
\mathcal{G}_{0}\otimes k\arrow{r}{\beta_0\otimes k} \arrow{d}{\rho_0} & \mathcal{G}_{0}\otimes k \arrow{d}{\rho'_0}\\
\mathbb{Y} \arrow{r}{\iota_\mathbb{Y}(\pi)} & \mathbb{Y}
\end{tikzcd},
\begin{tikzcd}
\mathcal{G}_{m(s)}\otimes k\arrow{r}{\beta_s\otimes k} \arrow{d}{\rho_{m(s)}} & \mathcal{G}_{s}\otimes k \arrow{d}{\rho_s}\\
\mathbb{Y} \arrow{r}{\iota_\mathbb{Y}(\pi)} & \mathbb{Y}
\end{tikzcd}
\end{equation}
where $s\geq 1$ in the second diagram.
These define Weil divisors $\mathcal{Y}_{s,+}^\kappa$ of $\mathcal{N}^\mathrm{Pap}$ isomorphic to $\mathrm{Spf}\,  W_s$. The morphism
\[\mathcal{Y}_{s,+}^\kappa\rightarrow \mathcal{N}^\mathrm{Pap}\overset{p_2}{\rightarrow} \mathcal{M}\]
induces an isomorphism from $\mathcal{Y}_{s,+}^\kappa$ to its image $\mathcal{W}_s^\kappa$.
\end{proposition}
\begin{proof}
We proceed by induction on $s$.
First let $(\mathcal{G}_0,\rho_0)=(\mathcal{G},\rho_\mathcal{G})$ be a canonical lift with respect to $\kappa$ and $\beta_0=\iota_{\mathcal{G}}(\pi)$. Then we can define $\rho'_0$ by \eqref{eq:rhoY'} such that the first diagram in \eqref{eq:cXs definition diagram} commutes.
Recall that by  Lemma \ref{lem:modularequation}, we have $\mathcal{M}_{\Gamma_0(\pi)}=\mathrm{Spf}\,  R$, where
\begin{equation}\label{eq:coordinateringofcN}
    R:=\mathcal{O}_{\breve{F}}[[X,Y]]/(f(X,Y)).
\end{equation}
Let $x_0\in W_0$ be the unique root of the polynomial $g_0(X)$ where $g_0(X)$ is as in \eqref{eq:g_s(X)}. Now assume inductively that we have defined $x_s\in W_s$ for $s\geq 0$ and that $x_s$ is a root of $g_s(X)$. In particular $W_s=\mathcal{O}_{\breve{F}}[x_s]$ and the isomorphism
\[\mathcal{O}_{\breve{F}}[[X]]/(g_s(X))\rightarrow W_s, \ X\mapsto x_s\]
corresponds to a quasi-canonical lift $(\mathcal{G}_s,\rho_s)$ of level $s$ (see the proof of Lemma \ref{lem: definition of cW_s}). Consider the equation
\begin{equation}\label{eq:modularequation}
    f(x_s,Y)=0.
\end{equation}
By the moduli interpretation of $\mathcal{M}_{\Gamma_0(\pi)}$, a solution $y$ to the above equation corresponds to a strict formal $\mathcal{O}_{F_0}$-module $\mathcal{G}'$ over $W_s[y]$ together with a degree $q$ isogeny
\[\beta':\mathcal{G}_s\rightarrow \mathcal{G}'.\]
By the proof of \cite[Proposition 4.6]{W}, $\mathcal{G}'$ is a quasi-canonical lift of level either $s+1$ or $m(s)$ and we can choose $y$ such that $\mathcal{G}'$ is of level $s+1$. We define $x_{s+1}$ to be such a $y$ and define $\mathcal{G}_{s+1}:=\mathcal{G}'$ and $\beta_{s+1}:=\beta'$. Equation \eqref{eq:rhoY'} then gives us a framing map $\rho_{s+1}:\mathcal{G}_{s+1}\otimes k\rightarrow \mathbb{Y}$ defined by
\begin{equation}\label{eq:normalizationofbetas}
  \rho_{s+1}=(\beta_s\otimes k)^{-1} \circ \rho_{s} \circ \iota_\mathbb{Y}(\pi).
\end{equation}
This finishes the definition of quasi-canonical lifts $(\mathcal{G}_s,\rho_s)$ inductively. The commutativity of the second diagram in \eqref{eq:cXs definition diagram} follows from \eqref{eq:normalizationofbetas}.

Define an $\mathcal{O}_{\breve{F}}$-algebra homomorphism
\begin{equation}\label{eq:varphi_s sharp}
    \varphi_s^\sharp: \mathcal{O}_{\breve{F}}[[X,Y]]/(f(X,Y))\rightarrow W_s, X\mapsto x_{m(s)}, Y \mapsto x_{s}.
\end{equation}
$\varphi_s^\sharp$ is surjective as $x_s$ is a generator of $W_s$ for $s\geq 0$. Hence it defines a closed sub formal scheme $\mathcal{Y}_{s,+}^\kappa\cong \mathrm{Spf}\,  W_s$ of $\mathcal{N}^\mathrm{Pap}$. Since $\mathcal{Y}_{s,+}^\kappa$ has codimension $1$ and $W_s$ is an integral domain, it is a Weil divisor.
\end{proof}

Using Tate modules, we can see that there is a unique morphism
\begin{equation}\label{gamma_s}
    \gamma_s:\mathcal{G}_s\rightarrow \mathcal{G}_{m(s)}
\end{equation}
such that
\[\beta_s\circ \gamma_s=\iota_{\mathcal{G}_s}(\pi_0).\]
Then it is automatically true that
\[\gamma_s \circ \beta_s=\iota_{\mathcal{G}_{m(s)}}(\pi_0),\]
and
\begin{equation}\label{eq:gamma_s commutative diagram}
  \rho_{m(s)}\circ (\gamma_s\otimes k) \circ \rho_{s}^{-1}= \iota_\mathbb{Y} (\pi).
\end{equation}
Let $\lambda_s:\mathcal{G}_s\rightarrow \mathcal{G}^\vee_s$ be the unique principal polarization that lifts $\mathbb{Y} \rightarrow \mathbb{Y}^\vee$ corresponding to the bilinear form $\langle,\rangle_\mathbb{Y}$ on $M(\mathbb{Y})$.
According to the dictionary translating between objects in $\mathcal{M}_{\Gamma_0(\pi)}$ and $\mathcal{N}^\mathrm{Pap}$ discussed before Proposition \ref{prop:exceptionaliso},
the pullback of the universal object of $\mathcal{N}^\mathrm{Pap}$ to $\mathcal{Y}_{s,+}^\kappa$ is
$(X_s^+,\iota_s^+,\lambda_s^+,\rho_s^+)$ where
\begin{equation}\label{eq:Xs+}
    X_s^+=\mathcal{G}_{m(s)}\times \mathcal{G}_{s},\ \iota_s^+(\pi)=\left(\begin{array}{cc}
     & \gamma_s \\
    \beta_s &
\end{array}\right), \lambda_s^+=\lambda_{m(s)}\times \lambda_{s},
\end{equation}
and
\begin{equation}\label{eq:rho_s^+}
    \rho_s^+=\begin{cases}
    \rho_{m(s)}\times \rho_{s} & \text{ if } s>0,\\
    \rho_0\times \rho_0' & \text{ if } s=0.
    \end{cases}
\end{equation}
Similarly for $s\geq 1$ we can define a closed sub formal scheme $\mathcal{Y}_{s,-}^\kappa\cong \mathrm{Spf}\,  W_s $ of $\mathcal{N}^\mathrm{Pap}$ such that the pullback of the universal object of $\mathcal{N}^\mathrm{Pap}$ to $\mathcal{Y}_{s,-}^\kappa$ is
$(X_s^-,\iota_s^-,\lambda_s^-,\rho_s^-)$ where
\begin{equation}\label{eq:Xs-}
    X_s^-=\mathcal{G}_s\times \mathcal{G}_{m(s)},\ \iota_s^-(\pi)=\left(\begin{array}{cc}
     & \beta_s \\
    \gamma_s &
\end{array}\right), \lambda_s^-=\lambda_s\times \lambda_{m(s)},\ \rho_s^-=\rho_{s}\times \rho_{m(s)}.
\end{equation}

\begin{remark}
When $s=0$ we denote $\mathcal{Y}_{0,+}^\kappa$ by $\mathcal{Y}_{0}^\kappa$ as well. We also define $\mathcal{Y}_{0,-}^\kappa$ to be $\mathcal{Y}_{0}^\kappa$ for uniformality of statements.
\end{remark}

Let $\mathcal{W}_s^\kappa$ be as in Lemma \ref{lem: definition of cW_s}. Then $p_i^*(\mathcal{W}_s^\kappa)$ ($i=1,2$) is a Cartier (hence also Weil) divisor on $\mathcal{N}^\mathrm{Pap}$.
\begin{lemma}\label{lem:piW and cY}
For all $s\geq 0$ we have the following equality of Weil divisors on $\mathcal{N}^\mathrm{Pap}$.
\[p_1^*(\mathcal{W}_s^\kappa)=\mathcal{Y}_{s+1,+}^\kappa +\mathcal{Y}_{s,-}^\kappa,\ p_2^*(\mathcal{W}_s^\kappa)=\mathcal{Y}_{s+1,-}^\kappa +\mathcal{Y}_{s,+}^\kappa.\]
\end{lemma}
\begin{proof}
We prove the first equation.
By the moduli interpretation in Proposition \ref{prop:quasi canonical divisor on NPap}, both $\mathcal{Y}_{s+1,+}^\kappa$ and $\mathcal{Y}_{s,-}^\kappa$ are sub divisors of $p_1^*(\mathcal{W}_s^\kappa)$. Since $p_1$ is finite of degree $q+1$ and $\mathcal{W}_s^\kappa$ has degree $q^s$ over $\mathcal{O}_{\breve{F}}$, we know that $p_1^*(\mathcal{W}_s^\kappa)$ has degree $q^s(q+1)$ over $\mathcal{O}_{\breve{F}}$. On the other hand $\mathcal{Y}_{s+1,+}^\kappa$ and $\mathcal{Y}_{s,-}^\kappa$ are isomorphic to $\mathrm{Spf}\,  W_{s+1}$ and $\mathrm{Spf}\,  W_s$ respectively. By counting the degrees, we see that the inclusion of $\mathcal{Y}_{s+1,+}^\kappa +\mathcal{Y}_{s,-}^\kappa$ into $p_1^*(\mathcal{W}_s^\kappa)$ is in fact an equality.
\end{proof}

\begin{corollary}\label{cor: Gal acts transitively}
The Galois group $\mathrm{Gal}(W_s/\mathcal{O}_{\breve{F}})$ acts simply transitively on diagrams which satisfy the condition stated in Proposition \ref{prop:quasi canonical divisor on NPap}. In particular, the divisor $\mathcal{Y}_{s,+}^\kappa$ is independent of the choice of such a diagram. Similar statements hold for $\mathcal{Y}_{s,-}^\kappa$.
\end{corollary}
\begin{proof}
Let $x_s$ be the root of $g_s(X)$ corresponding to $(\mathcal{G}_s,\rho_s)$.
Consider the roots of the following degree $q+1$ equation
\[f(X,x_s).\]
By  Lemma \ref{lem:piW and cY}, there are exactly $q$ roots which correspond to quasi-canonical lifts of level $s+1$ and there is a unique root $x_{m(s)}$ which  corresponds to a quasi-canonical lift of level $m(s)$. Since $\mathrm{Gal}(W_s/\mathcal{O}_{\breve{F}})$ acts simply transitively on the roots of $g_s(X)$, it also acts simply transitively on such pairs $(x_{m(s)},x_s)$. But such a pair exactly corresponds to a diagram in Proposition \ref{prop:quasi canonical divisor on NPap}.
\end{proof}

\subsection{Quasi-canonical lifting divisors on $\mathcal{N}^\mathrm{Kra}$}
For a blow-up $\tilde{X}\rightarrow X$ and a morphism $Y\rightarrow X$, the strict transform of $Y$ under $\tilde{X}\rightarrow X$ is defined in the definition below \cite[Corollary 7.15]{hartshorne2013algebraic}.
\begin{definition}\label{def:quasicanonicaldivisoronKramer}
Define $\mathcal{Z}_{s,+}^\kappa$ (resp. $\mathcal{Z}_{s,-}^\kappa$) to be the strict transform of $\mathcal{Y}_{s,+}^\kappa$ (resp. $\mathcal{Y}_{s,-}^\kappa$) under the blow-up $\Phi:\mathcal{N}^\mathrm{Kra}\rightarrow \mathcal{N}^\mathrm{Pap}$. Notice that $\mathcal{Z}_{0,+}^\kappa=\mathcal{Z}_{0,-}^\kappa$, so we also denote it by $\mathcal{Z}_0^\kappa$.
\end{definition}

\begin{proposition}\label{prop:blowupquasicanonicaldivisor}
$\mathcal{Z}_{s,+}^\kappa$ is an irreducible Cartier divisor of $\mathcal{N}^\mathrm{Kra}$.
The blow-up $\Phi$ induces an isomorphism
\[\mathcal{Z}_{s,+}^\kappa \overset{\sim}{\rightarrow} \mathcal{Y}_{s,+}^\kappa.\]
In particular $\mathcal{Z}_{s,+}^\kappa\cong \mathrm{Spf}\,  W_s$.
Similar statements hold for $\mathcal{Z}_{s,-}^\kappa$.
\end{proposition}
\begin{proof}
As in the proof of Proposition \ref{prop:quasi canonical divisor on NPap}, we identify $\mathcal{O}_{\breve F}[Y]/(g_s(Y))$ with $W_s$ by the map
\[\mathcal{O}_{\breve F}[Y]/(g_s(Y))\rightarrow W_s, Y \mapsto x_s\]
where $x_s$ is a root of $g_s(Y)$.
Then the closed embedding $\mathcal{Y}_{s,+}^\kappa\rightarrow\mathcal{N}^\mathrm{Pap}$ corresponds to the $\mathcal{O}_{\breve F}$-algebra homomorphism
\[\varphi_{s}^\sharp:\mathcal{O}_{\breve F}[[X,Y]]/(f(X,Y))\rightarrow W_s, X\mapsto x_{m(s)},Y \mapsto x_s\]
where $x_{m(s)}$ is as in the proof of Corollary \ref{cor: Gal acts transitively}.
$\mathcal{N}^\mathrm{Kra}$ is the blow-up of $\mathcal{N}^\mathrm{Pap}$ along the ideal $I=(\pi,X,Y)$. Hence $\mathcal{Z}_{s,+}^\kappa$ is isomorphic to the blow-up of $\mathrm{Spf}\,  W_s$ along the ideal generated by $\varphi_{s}^\sharp(I)$ in $W_s$.
Recall that any blow-up along a principal ideal is an isomorphism and $W_s$ is a P.I.D.. This proves the first claim of the Proposition. In particular, $\mathcal{Z}_{s,+}^\kappa$ is an irreducible Weil divisor of $\mathcal{N}^\mathrm{Kra}$. As $\mathcal{N}^\mathrm{Kra}$ is regular, $\mathcal{Z}_{s,+}^\kappa$ is also an irreducible Cartier divisor.
\end{proof}

\begin{proposition}\label{intersectionnumber1withExc}
For all $s\geq 0$ we have
\[\mathcal{Z}_{s,-}^\kappa \cdot \mathrm{Exc}=\mathcal{Z}_{s,+}^\kappa \cdot \mathrm{Exc}=1.\]
\end{proposition}
\begin{proof}
$\mathrm{Exc}$ is exactly the supersingular locus of $\mathcal{N}^\mathrm{Kra}$. To be more precise,
if $X_1\times X_2$ is the universal $\mathcal{O}_{F_0}$-module of $\mathcal{N}^\mathrm{Kra}$ under the identification $\mathcal{M}_{\Gamma_0(\pi)}\cong\mathcal{N}^\mathrm{Pap}$, then the supersingular locus is where $X_1=X_2=\mathbb{Y}$, or equivalently the locuas where endomorphism ring of both $X_1$ and $X_2$ is $\mathcal{O}_\mathbb{H}$. By applying \cite[Theorem 2.1]{V} to any element in $\mathcal{O}^\times_\mathbb{H}\setminus \mathcal{O}_{F}$,
the supersingular locus of $\mathcal{Z}_{s,\pm}^\kappa$ is exactly their reduced locus which is $\mathrm{Spec}\,  k$. This implies the proposition.
\end{proof}

\begin{proposition}\label{prop:cZintersectwithspecialfiber}
For $s\geq 1$, the divisor $\mathcal{Z}_{s,-}^\kappa$ intersects the special fiber $\mathcal{N}^\mathrm{Kra}_s$ of $\mathcal{N}^\mathrm{Kra}$ only at $P_1$ while $\mathcal{Z}_{s,+}^\kappa$ intersects $\mathcal{N}^\mathrm{Kra}_s$ only at $P_2$. Here $P_1$ and $P_2$ are the only singular points of $\mathcal{N}^\mathrm{Kra}_s$ described in Lemma \ref{lem:intersectionofZ1Z2}.
\end{proposition}
\begin{proof}
We need to use the concepts of formal modulus  of quasi-canonical lifts, see \cite[Section 4]{W}. First we deal with $\mathcal{Z}_{s,-}^\kappa$.
We know by \cite[Proposition 4.6]{W} that the formal modulus of $\mathcal{G}_s$ is
\[v(\mathcal{G}_s)=\frac{1}{2q^s}.\]
Recall that we have a degree $q$ isogeny $\gamma_s: \mathcal{G}_{s}\rightarrow \mathcal{G}_{s-1}$. In terms of power series, it can be represented by (see \cite[equation (4.1)]{W}):
\[\gamma_s(X)=c_s X+\text{ higher order terms}.\]
Define $v(\mathrm{Lie}\, (\gamma_s)):=\mathrm{val}_{\pi_0} (c_s)$. This is independent of the choice of the parameter $X$. Recall that the dual isogeny $\beta_s:\mathcal{G}_{s-1}\rightarrow \mathcal{G}_s $ satisfies $\beta_s \circ \gamma_s=\iota_{\mathcal{G}_s}(\pi_0)$ and is represented by
\[\beta_s(X)=b_s X+\text{ higher order terms}.\]
Assume that $\{E_1\}$ is a basis of $\mathrm{Lie}\, \mathcal{G}_s$ and $\{E_2\}$ is a basis of $\mathrm{Lie}\,  \mathcal{G}_{s-1}$. We assume that the basis $\{E_1,E_2\}$ of $\mathrm{Lie}\,  X_s^-$ lifts the basis $\{e_1,e_2\}$ of $\mathrm{Lie}\,  \mathbb{X}$ in Section \ref{subsec:Dieudonnemodulecalculation}. Then with respect to the basis $\{E_1,E_2\}$ of $\mathrm{Lie}\,  X_s^-$, we have
\[\iota_s^-(\pi)|_{\mathrm{Lie}\,  X_s^-}=\left(\begin{array}{cc}
    0 & b_s \\
    c_s & 0
\end{array}\right).\]
Its $\pi$-eigenspace is then the span of
\begin{equation}
    e_\pi=E_1+\frac{c_s}{\pi} E_2.
\end{equation}
By \cite[Corollary 4.8]{W}, we have
\[v(\mathrm{Lie}\, (\gamma_s))=1-v(\mathcal{G}_s)=1-\frac{1}{2q^s}.\]

The vector $e_\pi$ reduces to $e_1$ at the special fiber as $\mathrm{val}_{\pi_0}(\frac{c_s}{\pi})=\frac{1}{2}-\frac{1}{2q^s}>0$.
Then the filtration $\mathrm{span}\{e_\pi\}\subset\mathrm{Lie}\,  X$ over $\mathcal{Z}_{s,-}^\kappa$ is $\mathcal{F}_X$ in the definition of Kr\"amer model. As $\mathcal{F}_X$ reduces to $\mathrm{span}\{e_1\}$ at the special fiber, $\mathcal{Z}_{s,-}^\kappa$ intersect $\mathcal{N}^\mathrm{Kra}_s$ at $P_1=\mathrm{span}\{e_1\}$.

The case for $\mathcal{Z}_{s,+}^\kappa$ is the same with above except that one has to switch the roles  of  $e_1$ and $e_2$ in the above calculation. This finishes the proof of the proposition.
\end{proof}

Let $\bar\kappa:\mathcal{O}_F\rightarrow \mathcal{O}_{\mathbb H}$ be the embedding defined by
\[\bar\kappa(a)=\kappa(\bar a).\]
\begin{proposition}\label{prop:cZ0intersectspecialfiber}
The divisor $\mathcal{Z}_0^\kappa$ intersects with $\mathcal{N}^\mathrm{Kra}_s$ at exactly one point of $\mathrm{Exc}$ which is not $P_1$ or $P_2$. Moreover $\mathcal{Z}_0^\kappa$ and $\mathcal{Z}_0^{\bar\kappa}$ do not intersect.
\end{proposition}
\begin{proof}
Since $\mathcal{Z}_0^\kappa\cong \mathrm{Spf}\,  \mathcal{O}_{\breve F}$, its intersection number with the special fiber $\mathcal{N}^\mathrm{Kra}_s$ is the length of the module $\mathcal{O}_{\breve F}/(\pi)$ which is $1$. By Proposition \ref{intersectionnumber1withExc}, $\mathcal{Z}_0^\kappa$ and $\mathrm{Exc}$ do intersect.
By Lemma \ref{lem:intersectionofZ1Z2}, $P_1$ and $P_2$ are where the divisors $\mathrm{Exc}$ and $s^{-1}(Z_2)$ in $\mathcal{N}^\mathrm{Kra}_s$ intersect. If $\mathcal{Z}_0^\kappa$ intersects with $\mathrm{Exc}$ at $P_1$ or $P_2$, the intersection number $\mathcal{Z}_0^\kappa\cdot \mathcal{N}^\mathrm{Kra}_s$ would be at least $2$ as $\mathcal{Z}_0^\kappa$ would intersect both $\mathrm{Exc}$ and $s^{-1}(Z_2)$. This proves the first claim of the proposition.

As in the proof of Proposition \ref{prop:cZintersectwithspecialfiber}, $\mathcal{Z}_0^\kappa$ intersects with $\mathrm{Exc}$ at the point which corresponds to the $\pi$-eigenspace of $\kappa(\pi)$. Similarly  $\mathcal{Z}_0^{\bar\kappa}$ intersects with $\mathrm{Exc}$ at the point which corresponds to the $\pi$-eigenspace of $\bar\kappa(\pi)=\kappa(-\pi)$. Since these two eigenspaces are different, $\mathcal{Z}_0^\kappa$ and $\mathcal{Z}_0^{\bar\kappa}$ do not intersect.
\end{proof}

\begin{corollary}
\label{cor:strict transform respect summation}
The strict transform of $p_1^*(\mathcal{W}_s^\kappa)$ under the blow-up $\Phi$ is the disjoint union of $\mathcal{Z}_{s+1,+}^\kappa$ and $\mathcal{Z}_{s,-}^\kappa$. The strict transform of $p_2^*(\mathcal{W}_s^\kappa)$ under the blow-up $\Phi$ is the disjoint union of $\mathcal{Z}_{s+1,-}^\kappa$ and $\mathcal{Z}_{s,+}^\kappa$.
\end{corollary}
\begin{proof}
The corollary is a consequence of Lemma \ref{lem:piW and cY} and Proposition \ref{prop:blowupquasicanonicaldivisor}. The fact that  $\mathcal{Z}_{s+1,+}^\kappa$ (resp. $\mathcal{Z}_{s+1,-}^\kappa$) and $\mathcal{Z}_{s,-}^\kappa$ (resp. $\mathcal{Z}_{s,+}^\kappa$) are disjoint follows from Proposition \ref{prop:cZintersectwithspecialfiber} and \ref{prop:cZ0intersectspecialfiber}.
\end{proof}

\section{Special cycles }\label{specialcyclessection}
In this section, we define special cycles on $\mathcal{N}^\mathrm{Kra}$ and decompose them into irreducible cycles that are introduced in Section \ref{sec:quasicanonicalliftingdivisor}.
\subsection{Definition of special cycles}
We can define special cycles in the same way as \cite{KR1} and \cite{Shi1}. The definition makes sense for both $\mathcal{N}^\mathrm{Pap}$ and $\mathcal{N}^\mathrm{Kra}$ and gives us closed sub formal schemes in both cases.

First define the space of special quasi-homomorphisms to be the $F$-vector space
\begin{equation}\label{eq:bV}
    \mathbb{V}=\mathrm{Hom}_{\mathcal{O}_F}(\mathbb{Y},\mathbb{X})\otimes_\mathbb{Z} \mathbb{Q}.
\end{equation}
For $x,y \in \mathbb{V}$, let
\begin{equation}\label{h(,)}
    h(x,y)=\lambda_\mathbb{Y} \circ y^\vee \circ\lambda_\mathbb{X} \circ x\in \mathrm{End}_{\mathcal{O}_F}(\mathbb{Y})\otimes \mathbb{Q} \xrightarrow[\sim]{\iota_\mathbb{Y}^{-1}} F.
\end{equation}

For $x,y\in \mathbb{V}$ we abuse notation and denote the induced map between the corresponding relative Dieudonn\'e modules still by $x,y$. Then by \cite[Lemma 3.6]{Shi1} we have
\begin{equation}\label{eq:relationsonhermitianforms}
    h(x,y)(e,e)_\mathbb{Y}=(x(e),y(e))_\mathbb{X},
\end{equation}
where $(,)_\mathbb{X}$ and $(,)_\mathbb{Y}$ are the hermitian forms defined in \eqref{eq:definitionof(,)} for the rational relative Dieudonn\'e module of $\mathbb{X}$ and $\mathbb{Y}$ respectively and $\{e\}$ is a basis of $M(\mathbb{Y})$. In particular, $h(,)$ similar to $(,)_\mathbb{X}$, so one is anisotropic if and only if the other is.

\begin{definition}\label{def:localspecialcycle}
For a fixed $m$-tuple ($m\leq 2$) ${\bf x}=[x_1,\ldots,x_m]$ of special homomorphisms $x_i\in \mathbb{V}$, the associated special cycle $\mathcal{Z}^\mathrm{Kra}({\bf x})$ ($\mathcal{Z}({\bf x})$ resp.) is the subfunctor of collections $\xi=(Y,\iota,\lambda_{Y}, \rho_{Y}; {X},\iota,\lambda_{ X},\rho_{ X},\mathcal{F})$ in $\mathcal{N}_{(1,0)} \times \mathcal{N}^\mathrm{Kra}$ ( $\xi=(Y,\iota,\lambda_{Y}, \rho_{Y}; {X},\iota,\lambda_{ X},\rho_{ X})$ in $\mathcal{N}_{(1,0)} \times \mathcal{N}^\mathrm{Pap}$ resp.) such that the quasi-homomorphism
    \[\rho^{-1}_{X}\circ {\bf x} \circ \rho_{ Y}: {Y}^m\times_S \bar{S}\rightarrow { X}\times_S \bar{S}\]
deforms to a homomorphism from ${Y}^m$ to ${X}$.
\end{definition}
\begin{comment}
\begin{remark}
We know that $\mathcal{N}_{(1,0)}\cong {\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ and $Y\cong \mathcal{G}$, the canonical lift. We can fix such an identification by using the framing map $\rho_\mathcal{G}=\mathrm{id}_\mathbb{G}$. Then $\mathcal{N}_{(1,0)} \times_{\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}} \mathcal{N}^\mathrm{Kra}$  ($\mathcal{N}_{(1,0)} \times_{\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}} \mathcal{N}^\mathrm{Pap} $ resp.) is identified with $ \mathcal{N}^\mathrm{Kra}$ ($\mathcal{N}^\mathrm{Pap}$ resp.). Hence we often drop the first quadruple $(Y,\iota,\lambda_{Y}, \rho_{Y})$ in $\xi$ of Definition \ref{def:localspecialcycle}.
\end{remark}
\end{comment}

\subsection{Quasi-canonical lifting cycles in special cycles}\label{quasicanonicalliftingcycles}
Fix an ${\bf x}\in \mathbb{V}\setminus\{0\}$. Let $\mathrm{pr}_i:\mathbb{X}\rightarrow \mathbb{Y}$ be the natural projection to the $i$-th factor where we identify $\mathbb{X}$ with $\mathbb{Y}\times \mathbb{Y}$ as in \eqref{eq:definitionofbX}.
\begin{lemma}\label{lem:pr_1 pr_2 x}
For any ${\bf x}\in \mathbb{V}$, we have
\[\iota_\mathbb{Y}(\pi)\circ \mathrm{pr}_2\circ {\bf x}=\mathrm{pr}_1\circ {\bf x}\circ \iota_\mathbb{Y}(\pi),\quad \iota_\mathbb{Y}(\pi)\circ \mathrm{pr}_1\circ {\bf x}=\mathrm{pr}_2\circ {\bf x}\circ \iota_\mathbb{Y}(\pi).\]
\end{lemma}
\begin{proof}
Let $z$ be an $R$-point of $\mathbb{Y}$ where $R$ is a $k$-algebra. Then by  \eqref{eq:definitionofbX}, we know that
\[\iota_\mathbb{X}(\pi)\circ {\bf x} (z)=(\iota_{\mathbb{Y}}(\pi)\circ \mathrm{pr}_2 \circ {\bf x}(z),\iota_{\mathbb{Y}}(\pi)\circ \mathrm{pr}_1 \circ {\bf x}(z)).\]
On the other hand, since ${\bf x}$ is $\mathcal{O}_F$-linear, we know
\[\iota_\mathbb{X}(\pi)\circ {\bf x} (z)={\bf x}\circ \iota_\mathbb{Y} (\pi) (z)=(\mathrm{pr}_1\circ {\bf x}\circ \iota_\mathbb{Y} (\pi) (z),\mathrm{pr}_2\circ {\bf x}\circ \iota_\mathbb{Y} (\pi) (z)).\]
Equate the right hand sides of the above two equations, the lemma is proved.
\end{proof}
\begin{lemma}\label{lem:rho_0 is iso}
If ${\bf x}\in \mathbb{V}$ and $h({\bf x},{\bf x})\in \mathcal{O}_{F_0}^\times$, then the morphism $\mathrm{pr}_1\circ {\bf x}:\mathbb{Y}\rightarrow \mathbb{Y}$ is an isomorphism.
\end{lemma}
\begin{proof}
Assume that $\mathrm{pr}_1\circ {\bf x}:\mathbb{Y}\rightarrow \mathbb{Y}$ is not an isomorphism. Since $\mathbb H$ is a division algebra complete with respect to the $\pi$-adic topology, we know that $\mathrm{pr}_1\circ {\bf x} \circ \iota_\mathbb{Y}(\pi)^{-1}$ and $ \iota_\mathbb{Y}(\pi)^{-1}\circ\mathrm{pr}_1\circ {\bf x}$ are morphisms as well. Then by Lemma \ref{lem:pr_1 pr_2 x}, we know that $\iota_\mathbb{Y}(\pi)^{-1}\circ\mathrm{pr}_2\circ {\bf x}$ is also a morphism. Hence $\iota_\mathbb{X}(\pi)^{-1}\circ {\bf x}$ defines a morphism from $\mathbb{Y}$ to $\mathbb{X}$. By the definition of $h(,)$ (see \eqref{h(,)}), we know that
\[-\pi_0^{-1} h({\bf x},{\bf x})=h(\iota_\mathbb{X}(\pi)^{-1}\circ {\bf x},\iota_\mathbb{X}(\pi)^{-1}\circ {\bf x})\in \mathcal{O}_{F_0}.\]
This contradict the fact that $h({\bf x},{\bf x})\in \mathcal{O}_{F_0}^\times$.
\end{proof}

Fix a ${\bf x}\in \mathbb{V}\setminus\{0\}$, let $a$ be the $\pi_0$-adic valuation of $h({\bf x},{\bf x})$. Define
\begin{equation}\label{eq:rho_0}
   {\bf u}={\bf x}\circ\iota_\mathbb{Y}(\pi^{-a}), \quad \rho_0:=\mathrm{pr}_1\circ {\bf u}.
\end{equation}
Then by Lemma \ref{lem:rho_0 is iso}, $\rho_0:\mathbb{Y} \rightarrow \mathbb{Y}$ is an isomorphism. Moreover $(\mathcal{G}_0,\rho_0)=(\mathcal{G},\rho_0)$ is a canonical lift of $\mathbb{Y}$ with respect to the embedding  $\kappa_{\bf x}:\mathcal{O}_F\rightarrow \mathrm{End}(\mathbb{Y})\cong \mathcal{O}_{\mathbb H}$ defined by
\begin{equation}\label{eq:kappa x}
  \kappa_{\bf x}(a):=\rho_0\circ \iota_\mathbb{Y}(a) \circ \rho_0^{-1}=(\mathrm{pr}_1\circ {\bf x})\circ \iota_\mathbb{Y}(a) \circ (\mathrm{pr}_1\circ {\bf x})^{-1}.
\end{equation}
We can construct a system of quasi-canonical lifts $(\mathcal{G}_s,\rho_s)$ with respect to $\kappa_{\bf x}$ as in Proposition \ref{prop:quasi canonical divisor on NPap}.
Define $\alpha_s: \mathcal{G}\rightarrow \mathcal{G}_{s}$ by
\begin{equation}\label{eq:alpha_s}
    \alpha_s= \left\{\begin{array}{cc}
      \mathrm{Id}_\mathcal{G}   & \text{ if } s=0 \\
      \beta_s\circ \beta_{s-1}\circ \ldots \circ \beta_1   & \text{ if } s\geq 1.
    \end{array}\right.
\end{equation}
Define the map ${\bf x}_s^+:\mathcal{G}\rightarrow X_s^+$ where $X_s^+$ is described in \eqref{eq:Xs+} by
\begin{equation}\label{OEactiononXs+}
  {\bf x}_s^+=[(\alpha_{m(s)}\circ \iota_\mathcal{G}(\pi)^{s-m(s)})\times \alpha_s]\circ \Delta,
\end{equation}
where $m(s)$ is defined in \eqref{eq:m(s)} and $\Delta$ is the diagonal embedding $\mathcal{G}\rightarrow X_0$.
\begin{lemma}\label{lem:OoFlinearality}
We have the following commutative diagram
\begin{equation}\label{eq:xs+ commutative diagram}
\begin{tikzcd}
\mathcal{G}\otimes k\arrow{r}{{\bf x}_s^+\otimes k} \arrow{d}{\mathrm{Id}_\mathbb{Y}} & X_{s}^+\otimes k \arrow{d}{\rho_s^+}\\
\mathbb{Y} \arrow{r}{{\bf u}\circ \iota_\mathbb{Y}(\pi^s)} & \mathbb{X}=\mathbb{Y}\times \mathbb{Y}
\end{tikzcd}.
\end{equation}
Moreover ${\bf x}_s^+$ is an $\mathcal{O}_F$-module morphism.
\end{lemma}
\begin{proof}
First assume $s\geq 1$. Put the commutative diagrams in \eqref{eq:cXs definition diagram} together, we have
\[
   \rho_s\circ (\alpha_s \otimes k)=\iota_\mathbb{Y}(\pi^s)\circ \rho_0.
\]
We then have
\begin{align*}
    &\rho_s^+\circ ({\bf x}_s^+\otimes k)\\
    =&(\rho_{s-1}\times \rho_{s})\circ(((\alpha_{s-1}\circ \iota_\mathcal{G}(\pi))\times \alpha_s)\otimes k)\circ i_1\\
    =&(\rho_{s-1}\circ (\alpha_{s-1} \otimes k)\circ \iota_\mathbb{Y}(\pi))\times (\rho_s\circ (\alpha_s \otimes k))\\
    =&(\iota_\mathbb{Y}(\pi)^{s-1}\circ \rho_0\circ \iota_\mathbb{Y}(\pi))\times (\iota_\mathbb{Y}(\pi)^s\circ \rho_0)\\
    =&\iota_\mathbb{X}(\pi)^{s-1}\circ((\rho_0\circ \iota_\mathbb{Y}(\pi))\times (\iota_\mathbb{Y}(\pi)\circ \rho_0)).
\end{align*}
By the fact that $\rho_0=\mathrm{pr}_1\circ{\bf u}$ and Lemma \ref{lem:pr_1 pr_2 x}, the above is equal to
\begin{align*}
    &\iota_\mathbb{X}(\pi)^{s-1}\circ((\mathrm{pr}_1\circ{\bf u}\circ \iota_\mathbb{Y}(\pi))\times (\iota_\mathbb{Y}(\pi)\circ \mathrm{pr}_1\circ{\bf u}))\\
    =&\iota_\mathbb{X}(\pi)^{s-1}\circ((\mathrm{pr}_1\circ{\bf u}\circ \iota_\mathbb{Y}(\pi))\times ( \mathrm{pr}_2\circ{\bf u}\circ\iota_\mathbb{Y}(\pi)))\\
    =&\iota_\mathbb{X}(\pi)^{s-1}\circ {\bf u} \circ \iota_\mathbb{Y}(\pi)\\
    =&{\bf u} \circ \iota_\mathbb{Y}(\pi^s).
\end{align*}
This proves the commutativity of the diagram in the lemma when $s\geq 1$. The proof for $s=0$ is similar and left to the reader.
Now we need to check that ${\bf x}_s^+$ is an $\mathcal{O}_F$-module morphism.
Because the reduction map $\mathrm{Hom}(X,Y)\rightarrow \mathrm{Hom}(X\otimes k, Y\otimes k)$ is injective, it suffices to check that
\begin{equation}\label{eq:OoElinearilty}
    \rho_s^+\circ ({\bf x}_s^+\otimes k)\circ \iota_\mathbb{Y}(\pi)=\rho_s^+\circ (\iota_s^+(\pi)\otimes k)\circ ({\bf x}_s^+\otimes k).
\end{equation}
By the commutative of \eqref{eq:xs+ commutative diagram}, the left hand side of the above equation is ${\bf u}\circ \iota_\mathbb{Y}(\pi)^{s+1}$. Recall the definition of $\iota_s^+$ in \eqref{eq:Xs+} and the definition of $\iota_{\mathbb{X}}$ in \eqref{eq:definitionofbX}.  By the definition of the moduli problem $\mathcal{M}_{\Gamma_0(\pi)}$, we know that
\[\rho_s^+\circ (\iota_s^+(\pi)\otimes k)=\iota_{\mathbb{X}}(\pi)\circ \rho_s^+.\]
Combine this with the commutativity of \eqref{eq:xs+ commutative diagram}, we see
\begin{align*}
    &\rho_s^+\circ (\iota_s^+(\pi)\otimes k)\circ ({\bf x}_s^+\otimes k)\\
    =& \iota_{\mathbb{X}}(\pi)\circ \rho_s^+ \circ ({\bf x}_s^+\otimes k)\\
    =& \iota_{\mathbb{X}}(\pi)\circ {\bf u} \circ \iota_\mathbb{Y}(\pi)^s\\
    =& {\bf u}\circ \iota_\mathbb{Y}(\pi)^{s+1}.
\end{align*}
This proves \eqref{eq:OoElinearilty}. The lemma is proved.
\end{proof}

Similarly define the map ${\bf x}_s^-:\mathcal{G}\rightarrow X_s^-$ by
\begin{equation}\label{OEactiononXs-}
  {\bf x}_s^-=[ \alpha_s \times (\alpha_{m(s)}\circ \iota_{\mathcal{G}}(\pi)^{s-m(s)})]\circ \Delta.
\end{equation}
By a similar calculation as in the case of ${\bf x}_s^+$, we know that ${\bf x}_s^-$ is $\mathcal{O}_F$-linear and lifts the homomorphism
$(\rho_{s}^-)^{-1}\circ ({\bf u} \circ \iota_\mathbb{Y}(\pi^s))\circ \rho_\mathcal{G}:\mathcal{G}\otimes k\rightarrow X_s^-\otimes k$.

We summarize the above constructions by the following lemma.
\begin{lemma}\label{lem:quasicanonicalliftsinspecialcycle}
For $0\leq s \leq a$, $\mathcal{Y}_{s,+}^{\kappa_{\bf x}}$ and $\mathcal{Y}_{s,-}^{\kappa_{\bf x}}$ are sub formal schemes of $\mathcal{Z}({\bf x})$ while $\mathcal{Z}_{s,+}^{\kappa_{\bf x}}$ and $\mathcal{Z}_{s,-}^{\kappa_{\bf x}}$ are sub formal schemes of $\mathcal{Z}^\mathrm{Kra}({\bf x})$.
\end{lemma}
\begin{proof}
By Lemma \ref{lem:OoFlinearality}, the composition of homomorphisms
\[\mathcal{G}\overset{\pi^{a-s}}{\longrightarrow}\mathcal{G}\overset{{\bf x}_s^+}{\longrightarrow} X_s^+\]
is $\mathcal{O}_F$-linear and
lifts $(\rho_s^+)^{-1}\circ {\bf x} \circ \rho_\mathcal{G}$. Hence $\mathcal{Y}_{s,+}^{\kappa_{\bf x}}\hookrightarrow \mathcal{Z}({\bf x})$ and $\mathcal{Z}_{s,+}^{\kappa_{\bf x}}\hookrightarrow \mathcal{Z}^\mathrm{Kra}({\bf x})$.
\end{proof}

\subsection{Decomposition of special divisors}
It is proved in \cite[Proposition 4.3]{Ho2} that for ${\bf x}\in \mathbb{V}\setminus\{0\}$, $\mathcal{Z}^\mathrm{Kra}({\bf x})$ is a Cartier divisor. We say a Cartier divisor $\mathcal{Z}$ of $\mathcal{N}^\mathrm{Kra}$ is irreducible if it is connected and is irreducible in each affine charts of $\mathcal{N}^\mathrm{Kra}$. We say an irreducible divisor $S$ over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ is horizontal if $\pi$ is not locally nilpotent on the structure sheaf of $S$. Otherwise we say $S$ is vertical.
Any irreducible divisor is either horizontal or vertical. Any Cartier divisor $\mathcal{Z}$ of $\mathcal{N}^\mathrm{Kra}$ that can be decomposed into irreducible ones can thus be decomposed into horizontal part and vertical part
\[\mathcal{Z}=\mathcal{Z}_h+\mathcal{Z}_v\]
where every irreducible component of $\mathcal{Z}_h$ (resp. $\mathcal{Z}_v$) is horizontal
(resp. vertical).

\begin{theorem}\label{decompositionofspecialcycles}
Let ${\bf x}={\bf x}_0\cdot \pi^a\in \mathbb{V}$ such that $h({\bf x}_0,{\bf x}_0)\in \mathcal{O}_{F_0}^\times$. Define $\kappa_{\bf x}$ as in \eqref{eq:kappa x}. Then we have the following equality of Cariter divisors on $\mathcal{N}^\mathrm{Kra}$.
\[\mathcal{Z}^\mathrm{Kra}({\bf x})=\mathcal{Z}_0^{\kappa_{\bf x}}+\sum_{s=1}^a \mathcal{Z}_{s,+}^{\kappa_{\bf x}}+\sum_{s=1}^{a} \mathcal{Z}_{s,-}^{\kappa_{\bf x}}+ (a+1) \mathrm{Exc}.\]
\end{theorem}
\begin{proof}
Step 1.
$\mathrm{Exc}$ is obviously in $\mathcal{Z}^\mathrm{Kra}({\bf x})$ since the point Sing is always in $\mathcal{Z}({\bf x})$. And it follows from Lemma \ref{lem:quasicanonicalliftsinspecialcycle} and that all the other irreducible components on the right hand side of the equation indeed show up in the decomposition of $\mathcal{Z}^\mathrm{Kra}({\bf x})$.

\noindent Step 2.
By Proposition \ref{prop:exceptionaliso}, the universal object over $\mathcal{N}^\mathrm{Kra}$ is $(X,\iota,\lambda,\rho,\mathcal{F}_X)$ where $X=G_1\times G_2$ and $\rho=\rho_1\times \rho_2$ where $(G_1,\rho_1)$ and $(G_2,\rho_2)$ are deformations of $(\mathbb{Y},\rho_\mathbb{Y})$. Define $\mathcal{Z}({\bf x};\mathrm{pr}_i)$ to be the sub formal scheme of (the $i$-th) $\mathcal{M}$ where
\[\rho_i^{-1}\circ \mathrm{pr}_i \circ{\bf x}\]
deforms to homomorphism $\mathcal{G}\rightarrow G_1$. By \cite[Proposition 7.1]{RSZexotic}, we know that
\[\mathcal{Z}({\bf x};\mathrm{pr}_i)=\sum_{j=0}^a \mathcal{W}_j^{\kappa_{\bf x}}.\]
By Corollary \ref{cor:strict transform respect summation}, we have the following equality of Cartier divisors on $\mathcal{N}^\mathrm{Kra}$
\[(\Phi\circ p_1)^*(\mathcal{Z}({\bf x};\mathrm{pr}_1))=\mathcal{Z}_0^{\kappa_{\bf x}}+\sum_{j=1}^a \mathcal{Z}_{j,+}^{\kappa_{\bf x}} +\sum_{j=1}^a \mathcal{Z}_{j,-}^{\kappa_{\bf x}} + \mathcal{Z}_{a+1,+}^{\kappa_{\bf x}}+a_1 \mathrm{Exc},\]
\[(\Phi\circ p_2)^*(\mathcal{Z}({\bf x};\mathrm{pr}_2))=\mathcal{Z}_0^{\kappa_{\bf x}}+\sum_{j=1}^a \mathcal{Z}_{j,+}^{\kappa_{\bf x}} +\sum_{j=1}^a \mathcal{Z}_{j,-}^{\kappa_{\bf x}} +\mathcal{Z}_{a+1,-}^{\kappa_{\bf x}}+a_2 \mathrm{Exc},\]
where $a_1,a_2\in \mathcal{Z}_{\geq 0}$.
However by definition $\mathcal{Z}^\mathrm{Kra}({\bf x})$ is a sub formal scheme of both $(\Phi\circ p_i)^*(\mathcal{Z}({\bf x};\mathrm{pr}_i))$. Hence it can be decomposed into irreducible divisors and its horizontal part is also a sub divisor of both $(\Phi\circ p_i)^*(\mathcal{Z}({\bf x};\mathrm{pr}_i))_h$. This shows that the horizontal part of $\mathcal{Z}^\mathrm{Kra}({\bf x})$ is
\[\mathcal{Z}_0^{\kappa_{\bf x}}+\sum_{s=1}^a \mathcal{Z}_{s,-}^{\kappa_{\bf x}}+\sum_{s=1}^{a} \mathcal{Z}_{s,+}^{\kappa_{\bf x}}.\]

\noindent Step 3.
Let $V$ be a vertical component of $\mathcal{Z}^\mathrm{Kra}({\bf x})$, We claim that $\Phi(V)$ must be supported on the reduced locus of $\mathcal{N}^\mathrm{Pap}$ which is its unique point Sing. This claim follows from the same proof as that of \cite[Lemma 5.1.1]{LZ}. Alternatively there are isogenies $\rho_i^{-1}\circ \mathrm{pr}_i \circ{\bf x}:\mathbb{Y}\rightarrow G_i$. Hence the pullbacks of $G_1$ and $G_2$ to $\mathcal{Z}^\mathrm{Kra}({\bf x})$ are supersingular. This implies that $V=\mathrm{Exc}$.
It remains to calculate the multiplicity $m$ of the exceptional divisor $\mathrm{Exc}$ in $\mathcal{Z}^\mathrm{Kra}({\bf x})$. By Proposition \ref{intersectionnumber1withExc} and \ref{prop:cZ0intersectspecialfiber},  we know that
\[m=\mathcal{Z}_0^{\bar{\kappa}_{\bf x}} \cdot \mathcal{Z}^\mathrm{Kra}({\bf x}).\]
Notice that $\bar{\kappa}_{\bf x}$ can be obtained by
\[
  \bar\kappa_{\bf x}(a)=\rho_0\circ \iota_\mathbb{Y}(\delta)\circ \iota_\mathbb{Y}(a) \circ \iota_\mathbb{Y}(\delta)^{-1}\circ \rho_0^{-1}
\]
where $\rho_0$ is as in \eqref{eq:rho_0}.
If $\mathcal{Z}_0^{\kappa_{\bf x}}$ is determined by the first diagram in \eqref{eq:cXs definition diagram}, then $\mathcal{Z}_0^{\bar{\kappa}_{\bf x}}$ is determined by the  diagram
\[
\begin{tikzcd}
\mathcal{G}\otimes k\arrow{r}{\beta_0\otimes k} \arrow{d}{\rho_0\circ \iota_\mathbb{Y}(\delta)} & \mathcal{G}\otimes k \arrow{d}{\rho'_0\circ \iota_\mathbb{Y}(-\delta)}\\
\mathbb{Y} \arrow{r}{\iota_\mathbb{Y}(\pi)} & \mathbb{Y}
\end{tikzcd}.
\]
Apply \eqref{eq:xs+ commutative diagram} to the case $s=0$, we see that
\[(\rho_0\times \rho_0')^{-1}\circ {\bf u}=\mathrm{Id}_\mathbb{Y} \times \mathrm{Id}_\mathbb{Y}. \]
Hence
\[
    ((\rho_0\circ \iota_\mathbb{Y}(\delta))\times(\rho'_0\circ \iota_\mathbb{Y}(-\delta)))^{-1}\circ {\bf x}=\iota_\mathbb{Y}(\delta^{-1}\cdot \pi^a)\times\iota_\mathbb{Y}(-\delta^{-1}\cdot \pi^a).
\]
By the definition of $\mathcal{Z}_0^{\bar{\kappa}_{\bf x}}$ and $\mathcal{Z}^\mathrm{Kra}({\bf x})$, their intersection is the locus in $\mathcal{Z}_0^{\bar{\kappa}_{\bf x}}\cong{\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ such that the map
\[((\rho_0\circ \iota_\mathbb{Y}(\delta))\times(\rho'_0\circ \iota_\mathbb{Y}(-\delta)))^{-1}\circ {\bf x}: \mathbb{Y}\rightarrow \mathbb{Y} \times \mathbb{Y}\]
deforms to a homomorphism $\mathcal{G}\rightarrow \mathcal{G}\times \mathcal{G}$. By \cite[Theorem 1.4]{W}, the above map lifts to $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}/(\pi^{a+1})$ but not to $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}}/(\pi^{a+2})$. This finishes the proof.
\end{proof}

\section{Intersection of special cycles}
\subsection{Deformations of homomorphisms between quasi-canonical lifts}
Most of this subsection is the same as \cite[Section 7]{KR1}. A crucial difference occurs at \eqref{eq:n_r,sofpsi} (compared to \cite[Lemma 7.4]{KR1}), because we are working on schemes over ${\mathrm{Spf}\,\mathcal{O}_{\breve{F}} }$ instead of $\mathrm{Spf}\,  \mathcal{O}_{\breve{F}_0}$. As in loc. cit., we can assume $\kappa(a)=\iota_\mathbb{Y}(a)$ and $\rho_s=\mathrm{Id}_\mathbb{Y}$ for all $s\geq 0$. Then by \eqref{eq:normalizationofbetas} we know $\beta_s\otimes k =\iota_{\mathbb{Y}}(\pi)$.

Assume that $A$ is a finite extension of $\mathcal{O}_{\breve{F}_0}$ with uniformizer $\lambda$, and let $A_m:=A/ \lambda^{m+1}$. We also let $e$ be the absolute ramification index of $A$ over $\mathcal{O}_{\breve{F}_0}$ and denote by $\mathrm{ord}_A$ the discrete valuation on $A$ with $\mathrm{ord}_A(\lambda)=\frac{1}{e}$. Define
\begin{equation}\label{eq:e_s}
    e_s:=[W_s:\mathcal{O}_{\breve{F}_0}]=2q^s
\end{equation}
to be the ramification index of $W_s/\mathcal{O}_{\breve{F}_0}$.
Suppose $\mathcal{G}_r$ and $\mathcal{G}_s$ are the quasi-canonical lifts defined over $A$. Suppose that a homomorphism
\[\psi: \mathcal{G}_r \times_{\mathrm{Spf}\,  W_r} \mathrm{Spec}\,  k \longrightarrow \mathcal{G}_s \times_{\mathrm{Spf}\,  W_s} \mathrm{Spec}\,  k  \]
is given. Define $n_{r,s} (\psi)$ to be the maximal $m$ such that $\psi$ lifts to a homomorphism $\mathcal{G}_r \times_{\mathrm{Spf}\,  W_r} \mathrm{Spf}\,  A_m \longrightarrow \mathcal{G}_s \times_{\mathrm{Spf}\,  W_s} \mathrm{Spf}\,  A_m  $.

Let $H_{r,s}\subset \mathcal{O}_{\mathbb H}=\mathrm{End}(\mathbb{Y})$ be the subset of elements $\phi$ that lift to homomorphisms from $\mathcal{G}_r$ to $\mathcal{G}_s$.  By \cite[Proposition 1.1]{W2}, if $s\geq r$, then $H_{r,s}=\pi^{s-r} \mathcal{O}_r$.
\begin{comment}
and there is an isomorphism
\begin{equation}\label{H_r,s}
    H_{r,s} \overset{\sim}{\longrightarrow} H_{r,s+1}, \ \phi \mapsto \pi \phi.
\end{equation}
\end{comment}
Passage to dual isogenies shows that $n_{r,s}(\phi)=n_{s,r}(\phi^\vee)$. Hence we may assume $s\geq r$, as we shall do from now on. For $\psi \in \mathcal{O}_{\mathbb{H}} \setminus H_{r,s}$, let
\begin{equation}\label{l_r,s}
   l_{r,s}(\psi)=\mathrm{max} \{v(\psi+\phi)\mid \phi\in H_{r,s}\},
\end{equation}
where $v$ is the valuation on $\mathbb H$ with $v(\pi)=1$. More explicitly, $l=l_{r,s}(\psi)$ is the positive integer such that
\begin{equation}
    \psi \in (\pi^{s-r} \mathcal{O}_r +\pi^l  \mathcal{O}_{\mathbb{H}})\setminus(\pi^{s-r} \mathcal{O}_r +\pi^{l+1}  \mathcal{O}_{\mathbb{H}}).
\end{equation}
Notice that if $v(\psi)<s-r$, then $l_{r,s}(\psi)=v(\psi)$.
What we need is $n_{0,s}(\psi)$ which is determined in the following proposition.
\begin{proposition}\label{lengthofliftingsinquasicanonicallifts}
Let $l=l_{0,s}(\psi)$. Then
\[n_{0,s}(\psi)=e/e_s\cdot\left\{\begin{array}{ccc}
    &\frac{q^{l+1}-1}{q-1} & \text{ if } l<s, \\
     &\frac{q^{s}-1}{q-1}+ \frac{1}{2}(l+1-s) e_s & \text{ if } l\geq s.
\end{array}\right.\]
\end{proposition}
\begin{proof}
The proof is almost the same with that of \cite[Proposition 7.2]{KR1} with slight changes in numerology. So we only sketch the key steps here with emphasize on where the numerology differs.
First by \cite[Theorem 2.1]{V}, if $\psi\in \mathcal{O}_{\mathbb{H}}\setminus H_{r,r}$ with $l_{r,r}(\psi)=l$, then
\[n_{r,r}(\psi)=e/ e_r \left\{\begin{array}{cc}
   \frac{(q^{l/2}-1)(q+1)}{q-1}+1  & \text{if } l\leq 2r\text{ and } l \text{ even}, \\
     \frac{(q^{(l-1)/2}-1)(q+1)}{q-1}+q^{(l-1)/2}+1  & \text{if } l\leq 2r\text{ and } l \text{ odd},  \\
     \frac{(q^{r-1}-1)(q+1)}{q-1}+q^{r-1}+(\frac{l+1}{2}-r)e_r +1  & \text{if } l\geq 2r-1.
\end{array}\right.  \]
Secondly suppose that $\mathcal{G}_r$, $\mathcal{G}_s$ and $\mathcal{G}_{s+1}$ are defined over $A$ and that $\psi\in \mathcal{O}_{\mathbb H} \setminus H_{r,s}$ for $r\leq s$. Then by \cite[Corollary 5.3]{W}, we have
\[n_{r,s+1}(\pi\psi)=n_{r,s}(\psi)+e/e_{s+1}.\]
We can use induction on $s$ by the above equation. To initiate the induction process, we need the following equation which is a variant of Lemma 7.4 of \cite{KR1}.
\begin{equation}\label{eq:n_r,sofpsi}
  n_{r,s}(\psi)=\frac{1}{2}(e/e_{s})e_r \text{ if } l_{r,s}(\psi)=0 \text{ and } s\geq 2r.
\end{equation}
The whole process of inductive calculation is exactly the same as loc.cit, so we omit it. This finishes the proof of the proposition.
\end{proof}

\subsection{Intersection of special cycles}
We now describe a basis of $\mathbb{V}$.
Define $i_1:\mathbb{Y} \rightarrow \mathbb{X}$ and $i_2:\mathbb{Y} \rightarrow \mathbb{X}$ by the function on $R$-points ($R$ a $k$-algebra)
\begin{equation}\label{i_1 i_2}
   i_1(x)=(x,x),\ i_2(x)=(\delta x,-\delta x).
\end{equation}
\begin{lemma}
$i_1$ and $i_2$ are $\mathcal{O}_F$-morphisms.
\end{lemma}
\begin{proof}
It is a direct calculation.
\begin{align*}
    i_1(\iota_\mathbb{Y}(\pi)x)=(\pi x,\pi x),\quad & i_2(\iota_\mathbb{Y}(\pi)x)=(\delta\pi x,-\delta\pi x),\\
    \iota_\mathbb{X}(\pi)i_1(x)=(\pi x,\pi x), \quad & \iota_\mathbb{X}(\pi)i_2(x)=(-\pi \delta x,\pi \delta x).
\end{align*}
The lemma follows.
\end{proof}

\begin{lemma}
We know that
\begin{equation}
    h(i_1,i_1)=2, h(i_1,i_2)=0, h(i_2,i_2)=-2\delta^2.
\end{equation}
In particular $i_1,i_2$ span a unimodular lattice in $\mathbb{V}$.
\end{lemma}
\begin{proof}
We can check directly that
\[i_1(e)=v_1,\ i_2(e)=v_2\]
where $v_1,v_2$ are as in \eqref{eq:v_1 v_2}. The lemma now follows from equation \eqref{eq:relationsonhermitianforms}, \eqref{eq:(e,e)} and \eqref{eq:Gram matrix of v_1 v_2}.
\end{proof}

Define $\kappa:=\kappa_{i_1}$ as in \eqref{eq:kappa x}. Then $\kappa_{i_2}=\bar\kappa$.

\begin{proposition}\label{intersectionnumberofquasicanonicalliftsandspecialcycles} Assume that ${\bf x}=i_1\circ \pi^a$ and $\mathbf{y}=i_2\circ \pi^b$. Then we have
\[\mathcal{Z}_{s,+}^\kappa\cdot \mathcal{Z}^\mathrm{Kra}(\mathbf{y})=\mathcal{Z}_{s,-}^\kappa\cdot \mathcal{Z}^\mathrm{Kra}(\mathbf{y})=\left\{\begin{array}{ccc}
    &\frac{q^{b+1}-1}{q-1} & \text{ if } b\leq s, \\
     &\frac{q^{s}-1}{q-1}+ (b+1-s) q^s & \text{ if } b\geq s,
\end{array}\right.\]
\[\mathcal{Z}_{s,+}^{\bar\kappa}\cdot \mathcal{Z}^\mathrm{Kra}({\bf x})=\mathcal{Z}_{s,-}^{\bar\kappa}\cdot \mathcal{Z}^\mathrm{Kra}({\bf x})=\left\{\begin{array}{ccc}
    &\frac{q^{a+1}-1}{q-1}  & \text{ if } a\leq s ,\\
     &\frac{q^{s}-1}{q-1}+ (a+1-s) q^{s} & \text{ if } a\geq s.
\end{array}\right.\]
\end{proposition}
\begin{proof}
Let $A=W_s$ and $\lambda$ be a uniformizer of $A$.
By Proposition \ref{prop:quasi canonical divisor on NPap} and \ref{prop:blowupquasicanonicaldivisor}, we know that $\mathcal{Z}_{s,+}^\kappa\cong \mathrm{Spf}\,  W_s$ and the formal $\mathcal{O}_{F_0}$-module over $ \mathcal{Z}_{s,+}^\kappa$ is $\mathcal{G}_{m(s)}\times \mathcal{G}_{s}$.
Then $\mathcal{Z}_{s,+}^\kappa\cap \mathcal{Z}^\mathrm{Kra}(\mathbf{y})$ is the locus of $\mathcal{Z}_{s,+}^\kappa$ such that the map
\begin{equation}\label{mapfromF0totYs-}
    (\iota_\mathbb{Y}(\delta\pi^b) \times \iota_\mathbb{Y}(-\delta\pi^b))\circ i_1:\mathbb{Y}\rightarrow \mathbb{Y}\times \mathbb{Y}
\end{equation}
lifts to a homomorphism $\mathcal{G}\rightarrow \mathcal{G}_{m(s)}\times \mathcal{G}_{s}$. Let
\[m=\mathcal{Z}_{s,+}^\kappa\cdot \mathcal{Z}^\mathrm{Kra}(\mathbf{y}),\]
then $m$ is biggest integer such that the map in equation \eqref{mapfromF0totYs-} can be lifted to $ \mathcal{G}\times_{\mathrm{Spf}\,  W_0} \mathrm{Spec}\,  A_m \rightarrow (\mathcal{G}_{m(s)}\times \mathcal{G}_{s}) \times_{\mathrm{Spf}\,  W_s} \mathrm{Spec}\,  A_m $.

By Proposition \ref{lengthofliftingsinquasicanonicallifts}, the map
\[\iota_\mathbb{Y}(\delta)\circ \iota_\mathbb{Y}(\pi)^b:\mathbb{Y}\rightarrow \mathbb{Y} \]
can be lifted to $ \mathcal{G}\times_{\mathrm{Spf}\,  W_0} \mathrm{Spec}\,  A_{m_1} \rightarrow \mathcal{G}_{s} \times_{\mathrm{Spf}\,  W_s} \mathrm{Spec}\,  A_{m_1} $, but not to $ \mathcal{G}\times_{\mathrm{Spf}\,  W_0} \mathrm{Spec}\,  A_{m_1+1} \rightarrow \mathcal{G}_s \times_{\mathrm{Spf}\,  W_s} \mathrm{Spec}\,  A_{m_1+1}$ where
\[m_1=\left\{\begin{array}{ccc}
    &\frac{q^{b+1}-1}{q-1} & \text{ if } b<s, \\
     &\frac{q^{s}-1}{q-1}+ (b+1-s) q^s & \text{ if } b\geq s,
\end{array}\right.\]
as $l_{0,s}(\pi^b \circ \delta)=b$.

Similarly,  the map
\[\iota_\mathbb{Y}(\delta)\circ \iota_\mathbb{Y}(\pi)^b:\mathbb{Y}\rightarrow \mathbb{Y} \]
can be lifted to $ \mathcal{G}\times_{\mathrm{Spf}\,  W_0} \mathrm{Spec}\,  A_{m_2} \rightarrow \mathcal{G}_{m(s)} \times_{\mathrm{Spf}\,  W_s} \mathrm{Spec}\,  A_{m_2} $, but not to $ \mathcal{G}\times_{\mathrm{Spf}\,  W_0} \mathrm{Spec}\,  A_{m_2+1} \rightarrow \mathcal{G}_{m(s)} \times_{\mathrm{Spf}\,  W_s} \mathrm{Spec}\,  A_{m_2+1}$ where
\[m_2=q^{s-m(s)}\cdot\left\{\begin{array}{ccc}
    &\frac{q^{b+1}-1}{q-1}  & \text{ if } b<m(s) ,\\
     &\frac{q^{m(s)}-1}{q-1}+ (b+1-m(s)) q^{m(s)} & \text{ if } b\geq m(s),
\end{array}\right.\]
as $l_{0,s-1}(\pi^b \circ \delta)=b$.
Then we know that
\[m=min\{m_1,m_2\}=m_1.\]
Similar arguments produce the formula for the other cases in the proposition.
\end{proof}

\begin{corollary}\label{intersectionnumberofquasicanonicalliftingdivisors}
Suppose $s,t\geq 1$. Then
\[\mathcal{Z}_{s,+}^\kappa \cdot \mathcal{Z}_{t,+}^{\bar\kappa}=\mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}_{t,-}^{\bar\kappa}=q^{min\{s,t\}}-1.\]
\end{corollary}
\begin{proof}
We prove
\begin{equation}\label{eq:cZ intersect cZ}
  \mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}_{b,-}^{\bar\kappa}=q^{min\{s,b\}}-1
\end{equation}
The other case is similar and left to the reader. First by Proposition and \ref{prop:cZintersectwithspecialfiber} and \ref{prop:cZ0intersectspecialfiber}, we know for all $s,t\geq 0$
\begin{equation}\label{eq: cZ- intersect barcZ+}
    \mathcal{Z}_{s,+}^\kappa\cdot \mathcal{Z}_{t,-}^{\bar\kappa}=\mathcal{Z}_{s,-}^\kappa\cdot  \mathcal{Z}_{t,+}^{\bar\kappa}=0.
\end{equation}
When $s=0$ or $b=0$, equation \eqref{eq:cZ intersect cZ} follows directly from this. Now assume $s\geq 1$ and $b\geq 1$.
By Theorem \ref{decompositionofspecialcycles}, we have
\[
   \mathcal{Z}^\mathrm{Kra}(i_2\circ \pi^b)=\mathcal{Z}_0^{\bar\kappa}+\sum_{t=1}^b \mathcal{Z}_{b,-}^{\bar\kappa}+ \sum_{t=1}^b \mathcal{Z}_{b,+}^{\bar\kappa} +(b+1) \mathrm{Exc}.
\]
This together with \eqref{eq: cZ- intersect barcZ+} and Proposition \ref{intersectionnumber1withExc} implies
\begin{equation}
   \mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}^{\bar\kappa}_{b,-}
    =\mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}^\mathrm{Kra}(i_2\circ \pi^{b})-\mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}^\mathrm{Kra}(i_2\circ \pi^{b-1})-1.
\end{equation}
Now apply Proposition \ref{intersectionnumberofquasicanonicalliftsandspecialcycles} to the right hand side of the above.
If $b\leq s$, then
\[\mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}^\mathrm{Kra}(i_2\circ \pi^{b})-\mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}^\mathrm{Kra}(i_2\circ \pi^{b-1})=\frac{q^{b+1}-1}{q-1}-\frac{q^{b}-1}{q-1}=q^b.\]
If $b\geq s+1$, then
\begin{align*}
    &\mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}^\mathrm{Kra}(i_2\circ \pi^{b})-\mathcal{Z}_{s,-}^\kappa \cdot \mathcal{Z}^\mathrm{Kra}(i_2\circ \pi^{b-1})\\
    =&[\frac{q^s-1}{q-1}+(b+1-s)q^s]-[\frac{q^s-1}{q-1}+(b-s)q^s]\\
    =&q^s.
\end{align*}
The corollary now follows.
\end{proof}

For a rank two integral lattice $\mathbb{L}$ in $\mathbb{V}$, define $\mathrm{Int}(\mathbb{L})$ as in equation \eqref{IntL}.
\begin{theorem}\label{thm:maintheorem1}
Suppose $\mathbb{V}$ has dimension $2$ and $(\mathbb{V},h(,))$ is anisotropic.
Let $\mathbb{L}$ be a hermitian lattice in $\mathbb{V}$ whose hermitian form is represented by a Gram matrix equivalent to $T=\left(\begin{array}{cc}
    u_1 (-\pi_0)^a & 0 \\
    0 & u_2 (-\pi_0)^b
\end{array}\right)$, where $u_1,u_2\in \mathcal{O}_{F_0}^\times$ and $a,b\geq 0$. Then
\[\mathrm{Int}(\mathbb{L})=\mu_q(T),\]
where
\[\mu_q(T):=2 \sum_{s=0}^{min\{a,b\}}q^s(a+b+1-2s)-a-b-2.\]
\end{theorem}
\begin{proof}
By \cite{Ho2}, the intersection number $\mathrm{Int}(\mathbb{L})$ is well-defined. In other words, we can choose any basis $\{{\bf x},\mathbf{y}\}$ of  $\mathbb{L}$, then we have
\[\mathrm{Int}(\mathbb{L})=\mathcal{Z}^\mathrm{Kra}({\bf x}) \cdot \mathcal{Z}^\mathrm{Kra}(\mathbf{y}).\]
So we can choose $ \{{\bf x},\mathbf{y}\}$ such that
\[\left(\begin{array}{cc}
    h({\bf x},{\bf x}) & h({\bf x},\mathbf{y}) \\
    h(\mathbf{y},{\bf x}) & h(\mathbf{y},\mathbf{y})
\end{array}\right)=\left(\begin{array}{cc}
    u_1 (-\pi)^a & 0 \\
    0 & u_2 (-\pi)^b
\end{array}\right).\]
We can further assume that ${\bf x}=i_1\circ \pi^a$ and $\mathbf{y}=i_2\circ \pi^b$ by changing the frame $\rho_\mathbb{X}$ by an element in $\mathrm{U}(C)$ if necessary (it is an isomorphism).

Decompose  $\mathcal{Z}^\mathrm{Kra}({\bf x})$ and $ \mathcal{Z}^\mathrm{Kra}(\mathbf{y})$ as in Theorem \ref{decompositionofspecialcycles}. Combine the decomposition with Proposition \ref{prop:cZintersectwithspecialfiber} and \ref{prop:cZ0intersectspecialfiber}, we have
\[\mathcal{Z}^\mathrm{Kra}({\bf x})\cdot \mathcal{Z}^\mathrm{Kra}(\mathbf{y})=\mathrm{I}+\mathrm{II}+\mathrm{III}\]
where
\[\mathrm{I}=(a+1)(b+1)\mathrm{Exc}\cdot \mathrm{Exc},\]
\[\mathrm{II}=(\mathcal{Z}_0^\kappa+\sum_{s=1}^a \mathcal{Z}_{s,-}^\kappa+\sum_{s=1}^{a} \mathcal{Z}_{s,+}^\kappa)\cdot (b+1)\mathrm{Exc}+(\mathcal{Z}_0^{\bar\kappa}+\sum_{s=1}^b \mathcal{Z}_{s,-}^{\bar\kappa}+\sum_{s=1}^{b} \mathcal{Z}_{s,+}^{\bar\kappa})\cdot (a+1)\mathrm{Exc},\]
\[\mathrm{III}=(\sum_{s=1}^b \mathcal{Z}_{s,-}^{\bar\kappa})\cdot (\sum_{t=1}^a \mathcal{Z}_{t,-}^\kappa)+(\sum_{s=1}^b \mathcal{Z}_{s,+}^{\bar\kappa})\cdot (\sum_{t=1}^a \mathcal{Z}_{t,+}^\kappa).\]
By Lemma \ref{lem:Excselfintersection},
\[\mathrm{I}=-2(a+1)(b+1).\]
By Proposition \ref{intersectionnumber1withExc},
\[\mathrm{II}=(2a+1)(b+1)+(2b+1)(a+1).\]
By Corollary \ref{intersectionnumberofquasicanonicalliftingdivisors},
\[(\sum_{s=1}^b \mathcal{Z}_{s,-}^{\bar\kappa})\cdot (\sum_{t=1}^a \mathcal{Z}_{t,-}^\kappa)=(\sum_{s=1}^b \mathcal{Z}_{s,+}^{\bar\kappa})\cdot (\sum_{t=1}^a \mathcal{Z}_{t,+}^\kappa)=\sum_{s=1}^b\sum_{t=1}^a q^{min\{s,t\}}-ab.\]
For $0 \leq e \leq min\{a,b\}$, the set of indices $(s,t)$ that contributes to the summand $q^e$ in the above summation is
\[\{(s,t)\mid t=e,e< s \leq b\}\sqcup \{(s,t)\mid s=e,e\leq t \leq a\}.\]
Hence
\[\sum_{s=1}^b\sum_{t=1}^a q^{min\{s,t\}}=\sum_{e=1}^{min\{a,b\}}(a+b-2e+1)q^e.\]
Putting the terms $\mathrm{I}$, $\mathrm{II}$ and $\mathrm{III}$ together and simplify. This finishes the proof of the theorem.
\end{proof}

\section{A Kudla-Rapoport type theorem}\label{sec:KRconjecture}
In this section we relate the intersection number $\mu_q(T)$ defined in Theorem \ref{thm:maintheorem1} to the derivative of certain local density polynomial.
\subsection{Local density polynomials}
Let $|\cdot|$ be the absolute value on $F$ normalized such that $|\pi|=\frac{1}{q}$.
For $X,Y\in \mathrm{Herm}_n(F_0)$, set $\langle X,Y\rangle=\mathrm{Tr}(XY)\in F_0$ where $\mathrm{Tr}$ is matrix trace.
For $S\in \mathrm{Herm}_m(F_0)$ and $X\in M_{m,n}(F)$, we denote $S[X]=X^* SX$.
Define $X_n:=\mathrm{Herm}_n(F_0)\cap \mathrm{GL}_n(F)$.
Fix an additive character $\psi$ of $F_0$ with conductor $\mathcal{O}_{F_0}$. Define
\[ \mathrm{Herm}^\vee_n(\mathcal{O}_{F_0}):=\{ T=(t_{ij}) \in \mathrm{Herm}_n(F_0)\mid \mathrm{ord}_{\pi}(t_{ii}) \geq 0,  \mathrm{ord}_{\pi}(t_{ij}\partial_F) \geq 0 \text{ if } i\neq j\}\]
where $\partial_F$ is a generator of the different ideal of $F/F_0$. In the current paper we have $(\partial_F)=(\pi)$. When $F/F_0$ is unramified and $p\neq 2$, $(\partial_F)=(1)$. The lattice $\mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})$ is the dual of $\mathrm{Herm}_n(\mathcal{O}_{F_0})$ under the pairing $\langle,\rangle$.
For $S\in \mathrm{Herm}^\vee_m(\mathcal{O}_{F_0})\cap X_m$ and $T\in\mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})\cap X_n$, define
\begin{equation}\label{eq:definitionoflocaldensity}
    \alpha(S, T) = \int_{\mathrm{Herm}_n(F_0)} \int_{M_{m,n}(\mathcal{O}_F)} \psi(\langle Y,S[X]-T\rangle) dX dY
\end{equation}
where $dX$ and $dY$ are Haar measures on $M_{m,n}(\mathcal{O}_F)$ and $\mathrm{Herm}_n(\mathcal{O}_{F_0})$ respectively such that $\mathrm{vol}(M_{m,n}(\mathcal{O}_F), dX) =\mathrm{vol}(\mathrm{Herm}_n(\mathcal{O}_{F_0}), dY)=1$. The quantity $\alpha(S,T)$ only depends on the equivalent classes of $S$ and $T$.
\begin{lemma}\label{lem:definitionoflocaldensity}
\begin{align*}
		\alpha(S, T) 	&=q^{\ell n (n-2m)} |\{ X \in M_{m,n}(\mathcal{O}_{F}/\pi_0^\ell):\,  S[X]-T \in  \pi_0^\ell \cdot \mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})\}|\\
		&= |\partial_F|^{-\frac{n(n-1)}2}  q^{\ell n (n-2m)} |\{ X \in M_{m,n}(\mathcal{O}_{F}/\pi_0^\ell):\,  S[X]-T \in  \pi_0^\ell \cdot \mathrm{Herm}_n(\mathcal{O}_{F_0}) \}|
\end{align*}
for sufficiently large $\ell$. In particular the classical local density
\[\alpha^{\mathrm{cl}}(S, T)= \lim_{\ell \rightarrow \infty} q^{\ell n (n-2m)} |\{ X \in M_{m,n}(\mathcal{O}_{F}/\pi_0^\ell):\,  S[X]-T \in  \pi_0^\ell \cdot \mathrm{Herm}_n(\mathcal{O}_{F_0}) \}|\]
differs from $\alpha(S, T)$ by the factor $|\partial_F|^{{\frac{n(n-1)}2}}$.
\end{lemma}
\begin{proof}
\begin{align*}
    \alpha(S,T)=& \lim_{\ell\rightarrow \infty}\int_{\frac{1}{\pi_0^\ell} \mathrm{Herm}_n(\mathcal{O}_{F_0})} dY \int_{M_{m,n}(\mathcal{O}_F)} \psi (\langle Y, S[X]-T\rangle) dX\\
    =& \lim_{\ell\rightarrow \infty}  \int_{M_{m,n}(\mathcal{O}_F)} dX \int_{\frac{1}{\pi_0^\ell} \mathrm{Herm}_n(\mathcal{O}_{F_0})} \psi (\langle Y, S[X]-T\rangle) dY\\
    =&  \lim_{\ell\rightarrow \infty}  \int_{M_{m,n}(\mathcal{O}_F)}  \mathrm{char}\{\pi_0^\ell \mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})\}(S[X]-T)\cdot \mathrm{vol}(\frac{1}{\pi_0^\ell} \mathrm{Herm}_n(\mathcal{O}_{F_0}),dY)dX.
\end{align*}
Here we have used the orthogonality of characters on $\frac{1}{\pi_0^\ell} \mathrm{Herm}_n(\mathcal{O}_{F_0})$ and the duality between $\mathrm{Herm}_n(\mathcal{O}_{F_0})$ and $\mathrm{Herm}_n^\vee(\mathcal{O}_{F_0})$. Hence
\begin{align*}
    \alpha(S,T)=& \lim_{\ell\rightarrow \infty}  q^{n^2\ell} \int_{M_{m,n}(\mathcal{O}_F)}  \mathrm{char}\{\pi_0^\ell \mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})\}(S[X]-T) dX\\
    =& \lim_{\ell\rightarrow \infty}  q^{n^2\ell} \sum_{x\in M_{m,n}(\mathcal{O}_F/(\pi_0^\ell))}\int_{x+\pi_0^\ell M_{m,n}(\mathcal{O}_F)}  \mathrm{char}\{\pi_0^\ell \mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})\}(S[X]-T) dX.
\end{align*}
where the summation is over $x\in M_{m,n}(\mathcal{O}_F/(\pi_0^\ell))$. It is easy to see that if $S[X]-T\in \pi_0^\ell \mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})$ then $S[\tilde X]-T\in \pi_0^\ell \mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})$ for all $\tilde{X}$ such that $\tilde{X}-X\in \pi_0^\ell M_{m,n}(\mathcal{O}_F)$.  Hence we get the first equality in the lemma. Swap the roles of $\mathrm{Herm}_n(\mathcal{O}_{F_0})$ and $\mathrm{Herm}_n^\vee(\mathcal{O}_{F_0})$ in the above calculations, we get the second equality in the lemma.
\end{proof}

Let $\mathcal{H}=\begin{pmatrix}0&\pi^{-1}\\-\pi^{-1}&0\end{pmatrix}$ and we use the same notation to define the rank $2$ hermitian lattice with Gram matrix $\mathcal{H}$.
Define
\begin{equation}
    S_r=S\oplus \mathcal{H}^r.
\end{equation}
By the methods of \cite[Corollary 5.4]{Hi} one can prove that
\begin{equation}\label{eq:localdensitypolynomial}
    \alpha(S_r,T)=\alpha(S,T,X)|_{X=q^{-2r}}
\end{equation}
where $\alpha(S,T,X)\in\mathbb{Q}[X]$ is a polynomial. Let $\chi$ be the quadratic character of the extension $F^\times/F_0^\times$, namely,
\begin{equation}
    \chi(a)=\left\{\begin{array}{cc}
        1 & \text{ if } a\in \mathrm{Nm}_{F/F_0}(F^\times), \\
        -1 & \text{ if } a\in F^\times_0\setminus \mathrm{Nm}_{F/F_0}(F^\times).
    \end{array}\right.
\end{equation}
For $T\in \mathrm{Herm}_n(F_0)$, define
\[\chi(T)=\chi((-1)^{\frac{n(n-1)}{2}} \mathrm{det}(T)).\]
The following theorem will be use in this paper as well as \cite{HSY}.
\begin{theorem}\label{thm:localdensity calculation}
Assume that $u_1,u_2,v\in  \mathcal{O}_{F_0}^\times$. Define $\epsilon_1 =\chi(-u_1 u_2)$ and $\epsilon_2 =\chi(-v)$. Assume $a\geq b$ are non-negative integers.
Let $S=\mathrm{Diag}\{v,1\}$.
\begin{enumerate}
    \item Assume that $T=\mathrm{Diag}\{u_1 (-\pi_0)^a,u_2 (-\pi_0)^b\}$. Then we have
\begin{align}\label{eq:local density first formula}
\alpha(S, T, X)
 =& (1-X) (1+ \epsilon_2 + q \epsilon_2) \sum_{e=0}^b (q X)^e
   -\epsilon_1 q^{b+1} X^{a+1} (1-X) \sum_{e=0}^{b} (q^{-1}X)^e
   \\ \nonumber
   -&\epsilon_1 (1+q) ( X^{a+ b +2}+ \epsilon_1 \epsilon_2)
   + (1+\epsilon_2) q^{b+1} X^{b+1} (1+\epsilon_1 X^{a-b}).
\end{align}
And
\begin{equation}\label{eq:local density second formula}
    \alpha(\mathcal{H},T,X)=(1-q^{-2}X)(\sum_{e=0}^bq^e X^e+\epsilon_1\sum_{e=a+1}^{a+b+1} q^{a+b+1-e} X^e).
\end{equation}

\item
Assume that $T= \left(\begin{array}{cc}
    0 & (-\pi)^{2a-1} \\
   (\pi)^{2a-1}  & 0
\end{array}\right)$ where $a\geq 0$.  Then
\begin{align}\label{eq:local density third formula}
     \alpha(S,T,X)=&(1-X)(1+\epsilon_2+q\epsilon_2)\sum_{e=0}^{a} (q X)^e -q^{2a+1}(1-X)\sum_{e=a+1}^{2a}(q^{-1}X)^e\\ \nonumber
    &-(q+1)(X^{2a+1}+\epsilon_2)+(q+1)(1+\epsilon_2)q^{a}X^{a+1}.
\end{align}
And
\begin{equation}\label{eq:local density fourth formula}
     \alpha(\mathcal{H},T,X)=(1-q^{-2}X)(\sum_{e=0}^{a} q^e X^e+\sum_{e=a+1}^{2a} q^{2a-e} X^e).
\end{equation}
\end{enumerate}
\end{theorem}
We postpone the proof of the theorem to the next section. Now let us focus on its consequence.
\subsection{A Kudla-Rapoport type theorem}
We now go back to the situation of Theorem \ref{thm:maintheorem1}.
We define $\alpha'(S,T)$ as in \eqref{eq:alphaprime}. Hence
\begin{equation}\label{alpha'andF'}
    \frac{\partial}{\partial r} \alpha(S_r,T)|_{r=0}=2 \log q\cdot \alpha'(S,T).
\end{equation}
\begin{theorem}\label{thm:maintheorem2} Suppose $\mathbb{V}$ has dimension $2$ and $(\mathbb{V},h(,))$ is anisotropic.
Let $\mathbb{L}$ be a hermitian lattice in $\mathbb{V}$ whose hermitian form is represented by a Gram matrix $T$. Then
\[\mathrm{Int}(\mathbb{L})
   =2 \frac{\alpha'(S,T)}{\alpha(S,S)},\]
where $S=\left(\begin{array}{cc}
    v & 0 \\
    0 & 1
\end{array}\right)$ with $v\in \mathcal{O}_{F_0}^\times$ and $\chi(-v)=1$.
\end{theorem}
\begin{proof}
Assume as before that ${\bf x}=(x_1,x_2)$ and $\mathbb{L}=\mathrm{span}\{x_1,x_2\}$. First assume $T\in \mathrm{Herm}_2(\mathcal{O}_{F_0})$. Since both sides of the equation only depends on the equivalent class of $T$, we can assume $T$ is of the form in Theorem \ref{thm:maintheorem1}.
By the assumption that $(\mathbb{V},h(,))$ is anisotropic, we know that $\chi(-u_1 u_2)=-1$. Without loss of generality we assume $a\geq b$.
Evaluate the first equation of Theorem \ref{thm:localdensity calculation} at $\epsilon_1=\epsilon_2=1$ and $a=b=0$, we have
\[\alpha(S,S)=\alpha(S,S,1)=(-X^2+(2q-2)X+1)|_{X=1}=2q-2.\]
Evaluate the same equation at $\epsilon_1=-1$, $\epsilon_2=1$, we have
\begin{align}\label{eq:alpha(S,T)}
\alpha(S, T, X)
 =& (1-X) (2 + q ) \sum_{e=0}^b (q X)^e
   + q^{b+1} X^{a+1} (1-X) \sum_{e=0}^{b} (q^{-1}X)^e
   \\ \nonumber
   +& (1+q) ( X^{a+ b +2}-1)
   + 2 q^{b+1} X^{b+1} (1- X^{a-b}).
\end{align}
Hence
\begin{align*}
    &\alpha'(S,T)\\
    =&(2+q)\sum_{e=0}^b q^e+q^{b+1} \sum_{e=0}^b q^{-e}-(1+q)(a+b+2)+2q^{b+1}(a-b)\\
    =&2q^{b+1}(a-b+1)+4\sum_{s=1}^b q^s-2q-(q+1)(a+b).
\end{align*}
On the other hand, by theorem \ref{thm:maintheorem1}, we have
\begin{align*}
    &\frac{1}{2}\alpha(S,S)\mathrm{Int}(\mathbb{L})
    =\frac{1}{2}\alpha(S,S)\mu_q(T)\\
    =&(q-1)[2 \sum_{s=0}^{b}q^s(a+b+1-2s)-a-b-2]\\
    =&2 \sum_{s=1}^{b+1}q^{s}(a+b+3-2s)-2\sum_{s=0}^{b}q^s(a+b+1-2s)-(q-1)(a+b+2)\\
    =&2q^{a+1}(a-b+1)+4\sum_{s=1}^b q^s-2q-(q+1)(a+b).
\end{align*}
This finishes the proof of the theorem when $T\in \mathrm{Herm}_2(\mathcal{O}_{F_0})$.

If $T\in \mathrm{Herm}_2(F_0)\setminus\mathrm{Herm}_2(\mathcal{O}_{F_0})$, then $\mathcal{Z}({\bf x})$ is empty by \cite[Theorem 1.2]{Shi1}. Meanwhile since $\mathbb{L}$ is anisotropic, by Jordan decomposition and \cite[Proposition 8.1]{J} there exists an element $v\in \mathbb{L}$ such that
\[\mathrm{val}_{\pi_0}(h(v,v))\leq -1.\]
Hence $\alpha(S_r,T)=0$ for all $r$. This shows that $\alpha'(S,T)=0$. So again the equality in the theorem holds.
\end{proof}

For later use, we also make the following calculations. Let $T$ be as in Theorem \ref{thm:maintheorem1}.
Let $S'=\left(\begin{array}{cc}
    v' & 0 \\
    0 & 1
\end{array}\right)$ with  $ \chi(-v')=-1$.
Then by Theorem \ref{thm:localdensity calculation}, we have
\begin{equation}\label{alphaS'S'}
    \alpha(S',T)=\alpha(S',S')=2(q+1),
\end{equation}
In particular, it is independent of $a$ and $b$.

\section{Local density of hermitian forms}\label{sec:local density}
In this section we prove Theorem \ref{thm:localdensity calculation}. We denote by $\mathrm{tr}(\cdot)$ the trace function of $F/F_0$. We use the uniformizer $\varpi_0=-\pi_0$ of $F_0$ since it simplifies many expressions. We will use results from \cite{Hi} to prove the first and the second formula of Theorem \ref{thm:localdensity calculation}, and use results from \cite{LL2} to prove the second and fourth formula.
\subsection{Hironaka's algorithm}
For any congruence subgroup $\Gamma \subset \mathrm{GL}_n(\mathcal{O}_F)$, define
\begin{equation}
    \alpha(Y;\Gamma):=\lim_{d\rightarrow \infty} q^{-dn^2} N_{d}(Y;\Gamma) ,
\end{equation}
where
\[N_d(Y;\Gamma):=| \big\{ \gamma\in \Gamma \ \mathrm{mod}(\pi_0^d) \mid \gamma^* Y\gamma \equiv Y \mathrm{mod} (\pi_0^d) \big\}|.\]

\begin{theorem}\label{thm:Hironakaformula} (\cite[Proposition 3.2]{Hi})
Let $\Gamma$ be a congruence subgroup of $\mathrm{GL}_n(\mathcal{O}_F)$. For $T\in X_n$, $ S \in X_m$, we have
\[\alpha(S,T)=\sum_{Y \in \Gamma \backslash X_n} \frac{\mathcal{G}_{\Gamma}(Y,T)\mathcal{G}(Y,S)}{\alpha(Y;\Gamma)},\]
where
\[ \mathcal{G}(Y,S)=\int_{M_{m,n}(\mathcal{O}_F)} \psi(\langle Y,S[X]\rangle)dX,\]
\[\mathcal{G}_\Gamma(Y,T)=\int_{\Gamma} \psi(\langle Y[\gamma],-T\rangle)d\gamma=\int_{\Gamma} \psi(\langle Y,-T[\gamma^*]\rangle)d\gamma.\]
Here $d\gamma$ is the Haar measure on $M_{n,n}(\mathcal{O}_F)$ such that $M_{n,n}(\mathcal{O}_F)$ has measure one and $dX$ is the Haar measure on $M_{m,n}(\mathcal{O}_F)$ such that $M_{m,n}(\mathcal{O}_F)$ has measure one.
\end{theorem}
\begin{remark}\label{rmk:error of Hironaka}
In \cite[Proposition 3.2]{Hi}, $\mathcal{G}_\Gamma(Y,T)$ is defined to be
\[\int_{\Gamma} \psi(\langle Y,-T[\gamma]\rangle)d\gamma\]
which is incorrect.
\end{remark}
Now we specialize to the case when $n=2$ and $\Gamma$ is the Iwahori subgroup
\[\Gamma=\{\gamma=(\gamma_{ij})\in \mathrm{GL}_n(\mathcal{O}_F)\mid \gamma_{21}\in \pi \mathcal{O}_F\}.\]

\subsection{Classification of hermitian lattice under the Iwahori subgroup}\label{subsec:Iwahoriclassify}
By \cite[Theorem 2.8]{Hi}, the set $\Gamma\backslash X_2$ can be represented by elements of the form
\begin{equation}\label{eq:Gamma_0orbitsofhermitianmatrix}
    Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)}=\left(\begin{array}{cc}
   \epsilon_1 \varpi_0^{e_1}  & 0 \\
    0 & \epsilon_2 \varpi_0^{e_2}
\end{array}\right),
\text{ and } Y_{((12),e)}=\left(\begin{array}{cc}
   0  & \pi^e \\
    (-\pi)^e & 0
\end{array}\right),
\end{equation}
where $ \epsilon_i=1 $ or $\sigma$ and $e_1,e_2,e\in \mathbb{Z}$. Here $\sigma\in \mathcal{O}_{F_0}^\times$ and $\chi(\sigma)=-1$.
\begin{lemma}\label{lem:alpha Gamma}
Define
\[\alpha(e_1,e_2):=\left\{\begin{array}{cc}
   4q^{e_2+3e_1-1}  & \text{ if } e_2\geq e_1  \\
   4q^{e_1+3 e_2}   &  \text{ if } e_2< e_1.
\end{array}\right.\]
Then $\alpha(Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)};\Gamma)=\alpha(e_1,e_2)$. We also have $\alpha(Y_{((12),e)};\Gamma)=q^{2e-1} (q-1)$.
\end{lemma}
\begin{proof}
This is a special case of \cite[Theorem 2.10]{Hi}.
\end{proof}

\subsection{Gauss integrals}\label{subsec:Gaussintegrals}
We denote by $\bar{\chi}$ the function on $\mathcal{O}_F/\pi \mathcal{O}_F\cong\mathcal{O}_{F_0}/ \varpi_0 \mathcal{O}_{F_0}\cong \mathbb{F}_q$ such that
\begin{equation}
    \bar{\chi}(a)=\left\{\begin{array}{cc}
        1 & \text{ if } a\in (\mathbb{F}_q^\times)^2, \\
        -1 & \text{ if } a\in \mathbb{F}_q^\times\setminus (\mathbb{F}_q^\times)^2, \\
        0 & \text{ if } a= 0.
    \end{array}\right.
\end{equation}
Let $\psi$ be an additive character of $F_0$ with conductor $\mathcal{O}_{F_0}$.
Define $\bar{\psi}$ on $\mathcal{O}_{F_0}/ \varpi_0 \mathcal{O}_{F_0}\cong \mathbb{F}_q$ by
\begin{equation}
    \bar{\psi}(\bar{a})=\psi(\frac{a}{\varpi_0}).
\end{equation}
where $a\in \mathcal{O}_{F_0}$ is any representative of $\bar{a}\in \mathcal{O}_{F_0}/ \varpi_0 \mathcal{O}_{F_0}$. We need some preliminary results on some Gauss type of integrals.
For $a\in \mathbb{F}_q^\times$ define the Gauss sum on $\mathbb{F}_q$ by
\begin{equation}
 g_a(\bar{\chi},\bar{\psi})=\sum_{b\in \mathbb{F}_q}\bar{\chi}(b) \bar{\psi}(ab).
\end{equation}
We also denote $g_1(\bar{\chi},\psi)$ simply by $g(\bar{\chi},\psi)$. Then
\begin{equation}\label{eq:g_aandg}
    g_a(\bar{\chi},\bar{\psi})=\bar{\chi}(a^{-1}) g(\bar{\chi},\bar{\psi})=\bar{\chi}(a) g(\bar{\chi},\bar{\psi}).
\end{equation}
It is easy to see that
\begin{equation}
    g_a(\bar{\chi},\bar{\psi})=\sum_{b\in \mathbb{F}_q} \bar{\psi}(ab^2)
\end{equation}
using the fact that $\sum_{b\in R} \bar{\psi}(ab)+\sum_{b\in N} \bar{\psi}(ab)+1=0$ where $R=(\mathbb{F}_q^\times)^2$ and $N=\mathbb{F}_q^\times \setminus (\mathbb{F}_q^\times)^2$. The following is a classical result.
\begin{lemma}\label{lem:guasssumsquare}
\[g_a(\bar{\chi},\bar{\psi})^2=q\cdot \bar{\chi}(-1).\]
\end{lemma}
\begin{remark}
It turns out that in the calculation of local density, only $g_a(\bar{\chi},\bar{\psi})^2$ instead of $g_a(\bar{\chi},\bar{\psi})$ shows up in the final expression. This is to be expected since local density is independent of the choice of character $\psi$.
\end{remark}

\begin{lemma}\label{lem:Gaussintegral}
Let $v\in F^\times$ and $w \in F_0^\times$. Assume $w=w_0 \varpi_0^s$ where $s=\mathrm{val}_{\varpi_0}(w)$.
\begin{enumerate}
\item Define $J(w):=\int_{\mathcal{O}_F} \psi(w x \bar{x}) dx$, then
\[J(w)=\left\{\begin{array}{cc}
     1 & \text{ if }s\text{ is non-negative}, \\
     q^{s} \chi(w_0) g(\bar{\chi},\bar{\psi}) & \text{ if }s\text{ is negative}.
\end{array}\right.\]
\item Define $J^*(w):=\int_{\mathcal{O}_F^\times} \psi(w x \bar{x}) dx$. Then we have
\[J^*(w)=\left\{\begin{array}{cc}
   0  &  \text{ if } \mathrm{val}_{\varpi_0}(w)<-1,\\
   \frac{1}{q}\chi(w_0) g(\bar{\chi},\bar{\psi}) -\frac{1}{q} & \text{ if } w=w_0 \varpi_0^{-1}, w_0 \in \mathcal{O}_F^\times,\\
   1-\frac{1}{q}  &  \text{ if } \mathrm{val}_{\varpi_0}(w)\geq 0.
\end{array}\right.\]
In particular, it is zero if and only if $\mathrm{val}_{\varpi_0}(w)<-1$.
\item
$\int_{\mathcal{O}_F}\int_{\mathcal{O}_F} \psi(\mathrm{tr}(\frac{1}{\pi} v\bar{x} y))dx dy=q^{min\{\mathrm{val}_\pi(v),0\}} $.
\item $\int_{\mathcal{O}_F}\int_{\mathcal{O}_F^\times} \psi(\mathrm{tr}(\frac{1}{\pi} v\bar{x} y))dx dy=q^{min\{\mathrm{val}_\pi(v),0\}}-q^{min\{\mathrm{val}_\pi(v)+1,0\}-1} $. In other words it is zero if $\mathrm{val}_{\pi}(v)<0$ and is $(1-\frac{1}{q})$ if $\mathrm{val}_{\pi}(v)\geq 0$ .
\item \begin{align*}
    &\int_{\mathcal{O}_F^\times}\int_{\mathcal{O}_F^\times} \psi(\mathrm{tr}(\frac{1}{\pi} v\bar{x} y))dx dy\\
    =&q^{min\{\mathrm{val}_\pi(v),0\}}-2q^{min\{\mathrm{val}_\pi(v)+1,0\}-1} +q^{min\{\mathrm{val}_\pi(v)+2,0\}-2}.
\end{align*}
In other words, it is $(1-q^{-1})^2$ if $\mathrm{val}_\pi(v)\geq 0$, $ -q^{-1}(1-q^{-1})$ when $\mathrm{val}_\pi(v)=-1$ and $0$ if $\mathrm{val}_\pi(v)<0$.
\end{enumerate}
\end{lemma}
\begin{proof}
(1), (2), (3) and (5) are covered in \cite[Lemma 5.1]{Hi}. We write down the proof of (1) for illustration.
If $\mathrm{val}_{\varpi_0}(w) \geq 0$, then $J(w)=1$. Assume now $\mathrm{val}_{\varpi_0}(w)<0$ and let $k=-\mathrm{val}_{\varpi_0}(w)$. Then
\begin{align*}
     J(w)=& \sum_{z \in \mathcal{O}_F/(\pi^k)} \int_{z+\pi^k \mathcal{O}_F} \psi(w x\bar{x})dx\\
     =& q^{-k} \sum_{z \in \mathcal{O}_F/(\pi^k)} \int_{\mathcal{O}_F} \psi(w (z+\pi^k x)\overline{(z+\pi^k x)})dx \\
     =& q^{-k} \sum_{z \in \mathcal{O}_F/(\pi^k)} \psi(w z\bar{z}) \int_{\mathcal{O}_F} \psi[\mathrm{tr}(\pi^k w\bar{z} x)]dx\\
     =& q^{-k} \sum_{z \in \mathcal{O}_F/(\pi^k)} \psi(w z\bar{z})  \mathrm{char}(\mathcal{O}_F) (w \bar{z} \pi^{k+1}).
\end{align*}
The nonzero terms in the above summation are those with $z\in (\pi^{k-1})$. So
\begin{align*}
    J(w)=& q^{-k}\sum_{z\in \mathcal{O}_F/(\pi)}\psi(\frac{w_0}{\varpi_0} z \bar{z}) \\
    =& q^{-k}\sum_{z\in \mathcal{O}_{F_0}/(\varpi_0)}\psi(\frac{w_0}{\varpi_0} z^2) \\
    =& q^{-k} \chi(w_0) g(\bar{\chi},\bar{\psi}).
\end{align*}
Here in the last step we use \eqref{eq:g_aandg}.

(4) follows from (3) as
\begin{align*}
  &\int_{\mathcal{O}_F}\int_{\mathcal{O}_F^\times} \psi(\mathrm{tr}(\frac{1}{\pi} v\bar{x} y))dx dy\\
  =&\int_{\mathcal{O}_F}\int_{\mathcal{O}_F} \psi(\mathrm{tr}(\frac{1}{\pi} v\bar{x} y))dx dy-\frac{1}{q}\int_{\mathcal{O}_F}\int_{\pi \mathcal{O}_F} \psi(\mathrm{tr}(\frac{1}{\pi} v\bar{x} y))dx dy\\
  =& \int_{\mathcal{O}_F}\int_{\mathcal{O}_F} \psi(\mathrm{tr}(\frac{1}{\pi} v\bar{x} y))dx dy-\frac{1}{q}\int_{\mathcal{O}_F}\int_{ \mathcal{O}_F} \psi(\mathrm{tr}(\frac{1}{\pi} (-v \pi )\bar{x} y))dx dy.
\end{align*}
This finishes the proof of the lemma.
\end{proof}

Due to Remark \ref{rmk:error of Hironaka}, we need to recalculate $\mathcal{G}_\Gamma(Y,T)$ in the formula of Theorem \ref{thm:Hironakaformula}. Recall that we have defined $Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)}$ and $Y_{((12),e)}$ in \eqref{eq:Gamma_0orbitsofhermitianmatrix}.
\begin{lemma}\label{lem:G_Gamma T diagonal}
Assume that $T=\mathrm{Diag}\{u_1\varpi_0^a, u_2\varpi_0^b\}$,
where $u_1,u_2\in \mathcal{O}_{F_0}^\times$.
Then we have
\[\mathcal{G}_\Gamma \left(Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)},T\right)=\frac{1}{q}  J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(-\epsilon_2 u_1 \varpi_0^{a+e_2+1}) J^*(-\epsilon_2  u_2\varpi_0^{b+e_2}),\]
and
\[\mathcal{G}_\Gamma \left(Y_{((12),e)},T\right)=\frac{1}{q}(q^{min\{2a+e+2,0\}}-q^{min\{2a+e+3,0\}-1}) (q^{min\{2b+e+1,0\}}-q^{min\{2b+e+2,0\}-1}).\]
\end{lemma}
\begin{proof}
Let $\gamma=\left(\begin{array}{cc}
    x & y \\
    z & w
\end{array}\right)\in \Gamma$. Then
\[T[\gamma^*]=\left(\begin{array}{cc}
    u_1\varpi_0^a x\bar{x} +u_2\varpi_0^b y \bar{y} & u_1\varpi_0^a x \bar{z} +u_2\varpi_0^b y \bar{w} \\
    u_1\varpi_0^a z \bar{x} +u_2\varpi_0^b \bar{y}w &  u_1\varpi_0^a z\bar{z} +u_2\varpi_0^b w \bar{w}
\end{array}\right).\]
So we have
\begin{align*}
    &\mathcal{G}_\Gamma (Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)},T) \\
=&\int_{\mathcal{O}_F^\times} \psi(-\epsilon_1 u_1 \varpi_0^{a+e_1} x \bar{x}) dx \int_{ \mathcal{O}_F} \psi(-\epsilon_1  u_2 \varpi_0^{b+e_1} y \bar{y}) dy \int_{\pi \mathcal{O}_F} \psi(-\epsilon_2 u_1 \varpi_0^{a+e_2} z\bar{z}) dz \int_{\mathcal{O}_F^\times} \psi(-\epsilon_2  u_2\varpi_0^{b+e_2} w \bar{w}) dw  \\
=&\frac{1}{q}\int_{\mathcal{O}_F^\times} \psi(-\epsilon_1 u_1 \varpi_0^{a+e_1} x \bar{x}) dx \int_{ \mathcal{O}_F} \psi(-\epsilon_1  u_2 \varpi_0^{b+e_1} y \bar{y}) dy \int_{ \mathcal{O}_F} \psi(-\epsilon_2 u_1 \varpi_0^{a+e_2+1} z\bar{z}) dz \int_{\mathcal{O}_F^\times} \psi(-\epsilon_2  u_2\varpi_0^{b+e_2} w \bar{w}) dw  \\
=& \frac{1}{q} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(-\epsilon_2 u_1 \varpi_0^{a+e_2+1}) J^*(-\epsilon_2  u_2\varpi_0^{b+e_2}).
\end{align*}

And we have
\begin{align*}
    &\mathcal{G}_\Gamma (Y_{((12),e)},T) \\
=& \int_{\pi \mathcal{O}_F} \int_{\mathcal{O}_F^\times}\psi[\mathrm{tr}(-u_1\varpi_0^a \pi^e z \bar{x})]dx dz \int_{ \mathcal{O}_F} \int_{\mathcal{O}_F^\times}\psi[\mathrm{tr}(-u_2\varpi_0^b \pi^e w \bar{y})]dw dy\\
=& \frac{1}{q} \int_{ \mathcal{O}_F} \int_{\mathcal{O}_F^\times}\psi[\mathrm{tr}(-u_1\varpi_0^{a} \pi^{e+1} z \bar{x})]dx dz \int_{ \mathcal{O}_F} \int_{\mathcal{O}_F^\times}\psi[\mathrm{tr}(-u_2\varpi_0^b \pi^e w \bar{y})]dw dy\\
=& \frac{1}{q}(q^{min\{2a+e+2,0\}}-q^{min\{2a+e+3,0\}-1}) (q^{min\{2b+e+1,0\}}-q^{min\{2b+e+2,0\}-1}),
\end{align*}
where the last equality follows from (4) of Lemma \ref{lem:Gaussintegral}.
\end{proof}

The proof of the following lemma is similar to that of the previous one which follows directly from Lemma \ref{lem:Gaussintegral}, so we omit it.
\begin{lemma}
Assume that $T=Y_{((12),a)}$.
Then we have
\[\mathcal{G}_\Gamma \left(Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)},T\right)= \frac{1}{q}(q^{min\{a+2 e_1+1,0\}}-q^{min\{a+2e_1+2,0\}-1})(q^{min\{a+2 e_2+2,0\}}-q^{min\{a+2e_2+3,0\}-1}),\]
and
\[\mathcal{G}_\Gamma \left(Y_{((12),e)},T\right)=\frac{1}{q} (q^{min\{a+e+1,0\}}-2q^{min\{a+e+2,0\}-1}+q^{min\{a+e+3,0\}-2}) q^{min\{a+e+2,0\}}.\]
\end{lemma}

\begin{lemma}\label{lem:GYmultiplicative}
For any $Y\in X_2$,
\[\mathcal{G}(Y,S_1\oplus S_2)=\mathcal{G}(Y,S_1)\mathcal{G}(Y,S_2).\]
\end{lemma}
\begin{proof}
Assume that $S_i$ has rank $m_i$ ($i=1,2$). Also assume that $x_1$ and $x_2$ are of size $m_1\times 1$, $x_3$ and $x_4$ are of size $m_2\times 1$. Let
\[X_1=(x_1 \ x_2), \ X_2=(x_3 \ x_4),\ X=\left(\begin{array}{c}
     X_1  \\
     X_2
\end{array}\right).\]
Then
\begin{align*}
    &\left(\begin{array}{cc}
        x_1^* & x_3^* \\
        x_2^* & x_4^*
    \end{array}\right)
    \left(\begin{array}{cc}
        S_1 & 0 \\
        0 & S_2
    \end{array}\right)
    \left(\begin{array}{cc}
        x_1 & x_2 \\
        x_3 & x_4
    \end{array}\right)\\
    =& \left(\begin{array}{cc}
        x_1^* & x_3^* \\
        x_2^* & x_4^*
    \end{array}\right)
    \left(\begin{array}{cc}
        S_1 & 0 \\
        0 & 0
    \end{array}\right)
    \left(\begin{array}{cc}
        x_1 & x_2 \\
        x_3 & x_4
    \end{array}\right)+\left(\begin{array}{cc}
        x_1^* & x_3^* \\
        x_2^* & x_4^*
    \end{array}\right)
    \left(\begin{array}{cc}
        0 & 0 \\
        0 & S_2
    \end{array}\right)
    \left(\begin{array}{cc}
        x_1 & x_2 \\
        x_3 & x_4
    \end{array}\right)\\
    =&\left(\begin{array}{cc}
        x_1^*S_1 x_1 & x_1^* S_1 x_2 \\
        x_2^* S_1 x_1 & x_2^*S_1 x_2
    \end{array}\right)+\left(\begin{array}{cc}
        x_3^*S_2 x_3 & x_3^* S_2 x_4 \\
        x_4^* S_2 x_3 & x_4^*S_2 x_4
    \end{array}\right)\\
    =& S_1[X_1]+S_2[X_2]
\end{align*}
Hence
\[\langle Y,(S_1\oplus S_2)[X]\rangle=\langle Y,S_1[X_1]\rangle+ \langle Y,S_2[X_2]\rangle.\]
The lemma follows.
\end{proof}

\begin{lemma}\label{lem:G(Y,S)}
Assume that $S_r=\mathrm{Diag}\{ v_1 \varpi_0^{f_1}, v_2 \varpi_0^{f_2}\}\oplus \mathcal{H}^r$,
where $v_1, v_2\in \mathcal{O}_{F_0}^\times$.
Then we have
\begin{align*}
    & \mathcal{G} \left(Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)},S_r\right)\\
=& J(v_1 \epsilon_1 \varpi_0^{e_1+f_1})J(v_1\epsilon_2 \varpi_0^{e_2+f_1}) J(v_2 \epsilon_1 \varpi_0^{e_1+f_2})J(v_2\epsilon_2 \varpi_0^{e_2+f_2}) (q^r)^{2min\{e_1,0\}+2min\{e_2,0\}},
\end{align*}
and
\[\mathcal{G} \left(Y_{((12),e)},S_r\right)=q^{min\{e+2f_1+1,0\}} q^{min\{e+2f_2+1,0\}}(q^r)^{2 min\{e,0\}}.\]
\end{lemma}
\begin{proof}
\begin{align*}
    \mathcal{G} (Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)},\langle v_1 \varpi_0^{f_1}\rangle)=&\int_{\mathcal{O}_F} \psi(\epsilon_1 v_1 \varpi_0^{e_1+f_1} x\bar{x} )dx\int_{\mathcal{O}_F} \psi(\epsilon_2 v_1 \varpi_0^{e_2+f_1} x\bar{x} )dx \\
 =& J(v_1 \epsilon_1 \varpi_0^{e_1+f_1})J(v_1\epsilon_2 \varpi_0^{e_2+f_1}).
\end{align*}
Similarly
\begin{align*}
    \mathcal{G} (Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)},\langle v_2 \varpi_0^{f_2}\rangle)
 = J(v_2 \epsilon_1 \varpi_0^{e_1+f_2})J(v_2\epsilon_2 \varpi_0^{e_2+f_2}).
\end{align*}
We also have
\begin{align*}
    \mathcal{G} (Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)}, \mathcal{H})=& \int_{\mathcal{O}_F^2} \psi[\mathrm{tr}(\frac{1}{\pi}\epsilon_1 \varpi_0^{e_1} \bar{x}y)]dxdy  \int_{\mathcal{O}_F^2} \psi[\mathrm{tr}(\frac{1}{\pi}\epsilon_2 \varpi_0^{e_2} \bar{x}y)]dxdy \\
=& q^{2min\{e_1,0\}+2min\{e_2,0\}}, \nonumber
\end{align*}
where the last equality follows from Lemma \ref{lem:Gaussintegral}. The first equation in the lemma now follows from Lemma \ref{lem:GYmultiplicative}. For the second equation in the lemma, we have
\begin{align*}
    \mathcal{G} (Y_{((12),e)},\langle v_1 \varpi_0^{f_1}\rangle)=& \int_{\mathcal{O}_F^2} \psi [\mathrm{tr} (\frac{1}{\pi}v_1 \pi^{e+2f_1+1} \bar{x} y)] dx dy\\
=&q^{min\{e+2f_1+1,0\}},
\end{align*}
where the last equality follows from Lemma \ref{lem:Gaussintegral}. Similarly
\[\mathcal{G} (Y_{((12),e)},\langle v_2 \varpi_0^{f_2}\rangle)
=q^{min\{e+2f_2+1,0\}},\]
and
\begin{align*}
    \mathcal{G} (Y_{((12),e)},\mathcal{H})= \big\{\int_{\mathcal{O}_F^2} \psi [\mathrm{tr}(\pi^{e-1}\bar{x}y)dxdy]\big\}^2
= q^{2 min\{e,0\}}. \nonumber
\end{align*}
Then the second equation in the lemma follows from Lemma \ref{lem:GYmultiplicative}.
\end{proof}

Similarly we can prove the following.
\begin{lemma}
Assume that $S_r=Y_{((12),f)}\oplus \mathcal{H}^r$.
Then we have
\begin{align*}
    & \mathcal{G} \left(Y_{(id,e_1,e_2,\epsilon_1,\epsilon_2)},S_r\right)
= q^{min\{2e_1+f+1,0\}+min\{2e_2+f+1,0\}} (q^r)^{2min\{e_1,0\}+2min\{e_2,0\}},
\end{align*}
and
\[\mathcal{G} \left(Y_{((12),e)},S_r\right)=q^{2min\{e+f+1,0\}}(q^r)^{2 min\{e,0\}}.\]
\end{lemma}

\subsection{Proof of \eqref{eq:local density first formula}}
In the following we simply write $\mathfrak{g}=g(\bar{\chi},\bar{\psi})$.
By Theorem \ref{thm:Hironakaformula}, Lemma \ref{lem:alpha Gamma}, \ref{lem:G_Gamma T diagonal} and \ref{lem:G(Y,S)}, we have
\begin{align*}
    &\alpha(S_r,T)\\
    =&\sum_{\epsilon_1, \epsilon_2} \sum_{(e_1,e_2)\in \mathbb{Z}^2} \frac{1}{q}  J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(-\epsilon_2 u_1 \varpi_0^{a+e_2+1}) J^*(-\epsilon_2  u_2\varpi_0^{b+e_2})\\
    &\cdot J(v\epsilon_1 \varpi_0^{e_1})J(v\epsilon_2 \varpi_0^{e_2})J(\epsilon_1 \varpi_0^{e_1})J(\epsilon_2 \varpi_0^{e_2})  (q^r)^{2min\{e_1,0\}+2min\{e_2,0\}} \cdot \alpha(e_1,e_2)\\
    +&\sum_{e\in Z} \frac{1}{q}(q^{min\{2a+e+2,0\}}-q^{min\{2a+e+3,0\}-1}) (q^{min\{2b+e+1,0\}}-q^{min\{2b+e+2,0\}-1})\\
    &\cdot q^{2min\{e+1,0\}} (q^r)^{2 min\{e,0\}} \frac{1}{q^{2e-1}(q-1)},
\end{align*}
where the summation of $\epsilon_1,\epsilon_2$ is over $\mathcal{O}_{F_0}^\times/\mathrm{Nm}(\mathcal{O}_F^\times)$. The second summation is easy to compute:
\begin{align}\label{eq: sum of alpha(e) terms}
     &\frac{1}{q}(1-\frac{1}{q})^2[\sum_{e=-2b-1}^{-1}q^{2(e+1)} q^{2er}\frac{1}{q^{2e-1}(q-1)}+\sum_{e=0}^\infty  \frac{1}{q^{2e-1}(q-1)}]\\ \nonumber
     =&(q-1) \sum_{e=-2b-1}^{-1} q^{2er}+\frac{1}{q+1}.
\end{align}
For a subset $\Lambda$ of $\mathbb{Z}^2$ define
\begin{align}\label{eq:I(Lambda)}
    I(\Lambda):=&\sum_{\epsilon_1, \epsilon_2} \sum_{(e_1,e_2)\in \Lambda} \frac{1}{q} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(\epsilon_2 u_1 \varpi_0^{a+e_2+1}) J^*(-\epsilon_2  u_2\varpi_0^{b+e_2})\\ \nonumber
    \cdot &  J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1})J(v\epsilon_2 \varpi_0^{e_2})J(\epsilon_2 \varpi_0^{e_2})  (q^r)^{2min\{e_1,0\}+2min\{e_2,0\}} \cdot\frac{1}{\alpha(e_1,e_2)}.
\end{align}
We know from Lemma \ref{lem:Gaussintegral} that $J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1})\neq 0$ if and only if $ e_1\geq -a-1$, and $J^*(-\epsilon_2 u_2 \varpi_0^{b+e_2})\neq 0$ if and only if $ e_2\geq -b-1$. In the following calculations, we will repeatedly using Lemma \ref{lem:guasssumsquare} and \ref{lem:Gaussintegral} sometimes without explicitly referring to them.
We will also use the following obvious facts
\begin{equation}\label{eq: summation of epsilon}
    \sum_{\epsilon \in \mathcal{O}_{F_0}^\times/\mathrm{Nm}(\mathcal{O}_F^\times)}\chi(\epsilon)=0, \ \sum_{\epsilon \in \mathcal{O}_{F_0}^\times/\mathrm{Nm}(\mathcal{O}_F^\times)}\chi(\epsilon^2)=2.
\end{equation}
\begin{lemma}\label{lem: I Z -b-1}
\begin{align*}
     &I(\mathbb{Z}\times \{-b-1\})\\
     =& -  (q^r)^{-2(b+1)} [\chi(-u_1 u_2)  (q^r)^{-2(a+1)}+(q-1)q^b\sum_{e_1=-b}^{-1} q^{e_1}  (q^r)^{2e_1}+\chi(-v) q^b].
\end{align*}
\end{lemma}
\begin{proof}
By the definition of $I(\mathbb{Z}\times \{-b-1\})$ and Lemma \ref{lem:Gaussintegral}, we have
\begin{align*}
    &I(\mathbb{Z}\times \{-b-1\})\\
    =& \sum_{\epsilon_1, \epsilon_2} \sum_{e_1\in \mathbb{Z}}
    \frac{1}{q} [\frac{1}{q}\chi(-\epsilon_2 u_2)\mathfrak{g}-\frac{1}{q}]\chi(-v)q^{-2b-1} (q^r)^{-2(b+1)}\\
    &\cdot J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1}) (q^r)^{2min\{e_1,0\}} \cdot\frac{1}{\alpha(e_1,-b-1)}.
\end{align*}
Since $\sum_{\epsilon_2}\chi(\epsilon_2)=0$, we know the above is equal to
\begin{align}\label{eq:I Z -b-1}
   & - 2 \chi(-v)q^{-2b-3} (q^r)^{-2(b+1)} (\sum_{e_1=-a-1}^{-a-1}+\sum_{e_1=-a}^{-b-2}+\sum_{e_1=-b-1}^{-b-1}+\sum_{e_1=-b}^{-1}+\sum_{e_1=0}^{\infty})\\ \nonumber
    \cdot&  \sum_{\epsilon_1} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1}) (q^r)^{2min\{e_1,0\}} \cdot\frac{1}{\alpha(e_1,-b-1)}.
\end{align}
Since $\sum_{\epsilon_1}\chi(\epsilon_1)=0$, we know that
\begin{align*}
    &\sum_{e_1=-a-1}^{-a-1} \sum_{\epsilon_1} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1}) (q^r)^{2min\{e_1,0\}} \cdot\frac{1}{\alpha(e_1,-b-1)}\\
    =&\sum_{\epsilon_1} [\frac{1}{q}\chi(-\epsilon_1 u_1)\mathfrak{g}-\frac{1}{q}] q^{b-a-1}\chi(-\epsilon_1 u_2)\mathfrak{g} \chi(-v) \cdot q^{-2a-1}\cdot (q^r)^{-2(a+1)}
    \cdot \frac{1}{4q^{-(b+1)-3(a+1)-1}}\\
    =&\frac{1}{2}q^{2b+3} \chi(u_1 u_2 v)  (q^r)^{-2(a+1)}.
\end{align*}
And if $a\geq b+2$ we know that (otherwise the following calculation is not needed)
\begin{align*}
    &\sum_{e_1=-a}^{-b-2} \sum_{\epsilon_1} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1}) (q^r)^{2min\{e_1,0\}} \cdot\frac{1}{\alpha(e_1,-b-1)}\\
    =& \sum_{e_1=-a}^{-b-2} \sum_{\epsilon_1} (1-\frac{1}{q}) q^{b+e_1}\chi(-\epsilon_1 u_2) \mathfrak{g} \chi(-v) q^{2e_1+1} (q^r)^{2e_1} \cdot\frac{1}{\alpha(e_1,-b-1)}\\
    =&0.
\end{align*}
Similarly if $a>b $ we know that (otherwise the following calculation is not needed)
\begin{align*}
    \sum_{e_1=-b-1}^{-b-1} \sum_{\epsilon_1} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1}) (q^r)^{2min\{e_1,0\}} \cdot\frac{1}{\alpha(e_1,-b-1)}=0.
\end{align*}
By Lemma \ref{lem:guasssumsquare}, \ref{lem:Gaussintegral} and \eqref{eq: summation of epsilon},
We also know that
\begin{align*}
    &\sum_{e_1=-b}^{-1} \sum_{\epsilon_1} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1}) (q^r)^{2min\{e_1,0\}} \cdot\frac{1}{\alpha(e_1,-b-1)}\\
    =& \sum_{e_1=-b}^{-1} \frac{1}{2}  (1-\frac{1}{q}) q^{e_1+3b+4} \chi(-v) (q^r)^{2e_1},
\end{align*}
and
\begin{align*}
    &\sum_{e_1=0}^{\infty} \sum_{\epsilon_1} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1}) (q^r)^{2min\{e_1,0\}} \cdot\frac{1}{\alpha(e_1,-b-1)}\\
    =&\frac{1}{2} q^{3b+3}.
\end{align*}
Plug the above five terms back into \eqref{eq:I Z -b-1}, the lemma is proved.
\end{proof}

\begin{lemma}\label{lem:I Z e_2 <0}
For $-b\leq e_2\leq -1$, we have
\begin{align*}
    &I(\mathbb{Z}\times \{e_2\})\\
    =& (q^r)^{2e_2}[(q-1)\chi(-u_1 u_2 ) q^{b+1+e_2} q^{-2(a+1)r}+ (q-1)^2\sum_{e_1=-b}^{e_2}  q^{e_2-e_1} (q^r)^{2e_1}\\
    +& (q-1)^2\sum_{e_1=e_2+1}^{-1}  q^{e_1-e_2-1} (q^r)^{2e_1}+(q-1)\chi(-v) q^{-e_2-1}].
\end{align*}
\end{lemma}
\begin{proof}
Apply Lemma \ref{lem:guasssumsquare}, \ref{lem:Gaussintegral} and \eqref{eq: summation of epsilon} again, we have
\begin{align*}
     &I(\mathbb{Z}\times \{e_2\})\\
    = & 2\frac{1}{q} (1-\frac{1}{q}) \chi(-v) q^{2e_2+1} (q^r)^{2e_2} (\sum_{e_1=-a-1}^{-a-1}+\sum_{e_1=-a}^{-b-2}+\sum_{e_1=-b-1}^{-b-1}+\sum_{e_1=-b}^{e_2}+\sum_{e_1=e_2+1}^{-1}+\sum_{e_1=0}^{\infty})\\
    &\sum_{\epsilon_1} J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1}) J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1})(q^r)^{2min\{e_1,0\}}\cdot\frac{1}{\alpha(e_1,e_2)}.
\end{align*}
Denote the summand of the last equation by $s(e_1,e_2)$. As in the proof of Lemma
\ref{lem: I Z -b-1}, we know that
\begin{align*}
    \sum_{e_1=-a-1}^{-a-1} \sum_{\epsilon_1} s(e_1,e_2)=&\frac{1}{2} \chi(u_1 u_2 v) q^{b+2-e_2} q^{-2(a+1) r},\\
    \sum_{e_1=-a}^{-b-2} \sum_{\epsilon_1} s(e_1,e_2)=&0,\\
    \sum_{e_1=-b-1}^{-b-1} \sum_{\epsilon_1} s(e_1,e_2)=&0,\\
    \sum_{e_1=-b}^{e_2} \sum_{\epsilon_1} s(e_1,e_2)=&\sum_{e_1=-b}^{e_2}\frac{1}{2}(q-1) \chi(-v) q^{-e_1-e_2+1} (q^r)^{2e_1},\\
    \sum_{e_1=e_2+1}^{-1} \sum_{\epsilon_1} s(e_1,e_2)=&\sum_{e_1=e_2+1}^{-1} \frac{1}{2}(q-1) \chi(-v) q^{e_1-3e_2} (q^r)^{2e_1},\\
    \sum_{e_1=0}^{\infty} \sum_{\epsilon_1}s(e_1,e_2)=&\frac{1}{2}q^{-3e_2}.
\end{align*}
Combining all the terms above finishes the proof of the lemma.
\end{proof}

\begin{lemma}\label{lem:I Z e_2 geq 0}
\begin{align*}
    I(\mathbb{Z}\times \mathbb{Z}_{\geq 0})=\chi(u_1 u_2 v)q^{b+1} q^{-2(a+1) r}+\sum_{e_1=-b}^{-1}(q-1) \chi(-v) q^{-e_1} (q^r)^{2e_1}+\frac{q}{q+1}.
\end{align*}
\end{lemma}
\begin{proof}
Assume now $e_2\geq 0$.
Apply Lemma \ref{lem:guasssumsquare}, \ref{lem:Gaussintegral} and \eqref{eq: summation of epsilon} again, we have
\begin{align*}
    &I(\mathbb{Z}\times \{e_2\})\\
    =& 2\frac{1}{q}(1-\frac{1}{q})  (\sum_{e_1=-a-1}^{-a-1}+\sum_{e_1=-a}^{-b-2}+\sum_{e_1=-b-1}^{-b-1}+\sum_{e_1=-b}^{-1}+\sum_{e_1=0}^{e_2}+\sum_{e_1=e_2+1}^{\infty})\sum_{\epsilon_1}   \\
    &\cdot J^*(-\epsilon_1 u_1 \varpi_0^{a+e_1}) J(-\epsilon_1 u_2\varpi_0^{b+e_1})
    J(v\epsilon_1 \varpi_0^{e_1})J(\epsilon_1 \varpi_0^{e_1}) (q^r)^{2min\{e_1,0\}} \cdot\frac{1}{\alpha(e_1,e_2)}.
\end{align*}
Again denote the summand of the last equation by $s(e_1,e_2)$
The first four terms of the summation have been computed in the previous two lemmas.  We also have
\begin{align*}
    \sum_{e_1=0}^{e_2}  \sum_{\epsilon_1} s(e_1,e_2)=&\frac{1}{2} (q-1)q^{-e_2}\frac{1-q^{-3(e_2+1)}}{1-q^{-3}},\\
    \sum_{e_1=e_2+1}^{\infty}  \sum_{\epsilon_1} s(e_1,e_2)=&\frac{1}{2}q^{-4e_2-1}.
\end{align*}
We hence have
\begin{align*}
    I(\mathbb{Z}\times \{e_2\})=&\frac{1}{q}(1-\frac{1}{q}) [\chi(u_1 u_2 v) q^{b+2-e_2} q^{-2(a+1) r}\\
    +&\sum_{e_1=-b}^{-1}(q-1) \chi(-v) q^{-e_1-e_2+1} (q^r)^{2e_1}
    + (q-1)q^{-e_2}\frac{1-q^{-3(e_2+1)}}{1-q^{-3}}+q^{-4e_2-1}].
\end{align*}
Summing over $e_2\in \mathbb{Z}_{\geq 0}$ and a further simplification proves the lemma.
\end{proof}

Combine \eqref{eq: sum of alpha(e) terms}, and Lemma \ref{lem: I Z -b-1}, \ref{lem:I Z e_2 <0} and \ref{lem:I Z e_2 geq 0}, we have
\begin{align}\label{eq:alpha S,T,X initial expression}
    &\alpha(S,T,X)\\ \nonumber
    =&(q-1) \sum_{e=1}^{2b+1} X^e+1-(q-1)q^b\sum_{e=1}^{b} q^{-e}  X^{e+b+1}\\ \nonumber
    +&\sum_{e_2=1}^{b}(q-1)^2\sum_{e_1=e_2}^{b}  q^{e_1-e_2} X^{e_1+e_2}+\sum_{e_2=2}^{b}(q-1)^2\sum_{e_1=1}^{e_2-1}  q^{-e_1+e_2-1} X^{e_1+e_2}\\ \nonumber
    -&  \chi(-u_1 u_2)  X^{a+b+2}
    +\sum_{e=1}^{b} (q-1) \chi(-u_1 u_2 ) q^{b+1-e} X^{a+1+e}\\ \nonumber
    +&\sum_{e=1}^{b}(q-\frac{1}{q}) \chi(-v) q^{e} X^{e}-\chi(-v) q^b X^{b+1}
    + \chi(u_1 u_2 v)q^{b+1} X^{a+1}.
\end{align}
Define
\[A=\sum_{e_2=1}^{b}(q-1)^2\sum_{e_1=e_2}^{b}  q^{e_1-e_2} X^{e_1+e_2}, \ B=\sum_{e_2=2}^{b}(q-1)^2\sum_{e_1=1}^{e_2-1}  q^{-e_1+e_2-1} X^{e_1+e_2}.\]
\begin{lemma}\label{lem:A+B}
For $2\leq k \leq b+1$, the $X^k$-coefficient of $A+B$ is $(q-1)(q^{k-1}-1)$.
For $b+2\leq k \leq 2b$, the $X^k$-coefficient of $A+B$ is $(q-1)(q^{2b-k+1}-1)$.
\end{lemma}
\begin{proof}
Define
\[\Lambda_A=\{(e_1,e_2)\in \mathbb{Z}^2 \mid e_2\leq e_1 \leq b, 1\leq e_2 \leq b\},\
\Lambda_B=\{(e_1,e_2)\in \mathbb{Z}^2 \mid 1\leq e_1 \leq e_2-1, 2\leq e_2 \leq b\},\]
and
\[\Lambda_A(k)=\{(e_1,e_2)\in \mathbb{Z}^2 \mid e_1+e_2=k\}\cap \Lambda_A,\ \Lambda_B(k)=\{(e_1,e_2)\in \mathbb{Z}^2 \mid e_1+e_2=k\}\cap \Lambda_B. \]
We then have
\begin{align*}
    \Lambda_A(k)=\{(k-1,1),(k-2,2),\ldots, (\lfloor\frac{k+1}{2}\rfloor,\lfloor\frac{k}{2}\rfloor)\},&  \text{ for } 2\leq k \leq b+1,\\
    \Lambda_A(k)=\{(b,k-b),(b-1,k-b+1),\ldots, (\lfloor\frac{k+1}{2}\rfloor,\lfloor\frac{k}{2}\rfloor)\}, & \text{ for }
    b+2\leq k \leq 2b,\\
    \Lambda_B(k)=\{(1,k-1),(2,k-2),\ldots,(\lfloor\frac{k-1}{2}\rfloor,\lfloor\frac{k}{2}\rfloor+1)\}, & \text{ for } 3\leq k \leq b+1,\\
    \Lambda_B(k)=\{(k-b,b),(k-b+1,b-1),\ldots,(\lfloor\frac{k-1}{2}\rfloor,\lfloor\frac{k}{2}\rfloor+1)\}, & \text{ for } b+2 \leq k\leq 2b-1.
\end{align*}
Since
\[A=\sum_{\Lambda_A} (q-1)^2 q^{e_1-e_2} X^{e_1+e_2}, \quad B=\sum_{\Lambda_B} (q-1)^2 q^{e_1-e_2} X^{e_1+e_2}, \]
the lemma follows easily.
\end{proof}

Apply the above Lemma and simplify \eqref{eq:alpha S,T,X initial expression}, we get
\begin{align}\label{eq:TDSUformula}
    &\alpha(S,T,X)\\ \nonumber
    =&1+(q-1)\sum_{e=1}^{b+1} q^{e-1}X^e
    -\chi(-u_1 u_2)  X^{a+b+2}
    +\sum_{e=1}^{b} (q-1)\chi(-u_1 u_2 ) q^{b+1-e} X^{a+1+e}\\ \nonumber
    +&\sum_{e=1}^{b}(q-\frac{1}{q}) \chi(-v) q^{e} X^{e}-\chi(-v) q^b X^{b+1}+ \chi(u_1 u_2 v)q^{b+1} X^{a+1}. \nonumber
\end{align}
Using the identity
\begin{equation}\label{eq:difference identity}
   (1-X)\sum_{e=0}^b Y^e X^e=(q-1)\sum_{e=1}^b Y^{e-1} X^e+1-Y^b X^{b+1}
\end{equation}
with $Y=q$ and $\frac{1}{q}$, it is easy to see that the formula \eqref{eq:TDSUformula} is the same as the first formula in Theorem \ref{thm:localdensity calculation}. This finishes the proof. \qedsymbol

\subsection{Proof of \eqref{eq:local density third formula}}
According to Theorem \ref{thm:Hironakaformula},  Lemma \ref{lem:alpha Gamma}, \ref{lem:G_Gamma T diagonal} and \ref{lem:G(Y,S)}, we have
\begin{align*}
    &\alpha(S_r,T)\\
    =&\sum_{\epsilon_1, \epsilon_2}\sum_{e_1\in \mathbb{Z}} \sum_{e_2\in \mathbb{Z}} \frac{1}{q}(q^{min\{a+2 e_1+1,0\}}-q^{min\{a+2e_1+2,0\}-1})(q^{min\{a+2 e_2+2,0\}}-q^{min\{a+2e_2+3,0\}-1})\\
    \cdot & J(v \epsilon_1 \varpi_0^{e_1})J(v\epsilon_2 \varpi_0^{e_2}) J( \epsilon_1 \varpi_0^{e_1})J(\epsilon_2 \varpi_0^{e_2}) (q^r)^{2min\{e_1,0\}+2min\{e_2,0\}}\cdot \alpha(e_1,e_2)\\
    +& \sum_{e\in \mathbb{Z}} \frac{1}{q} (q^{min\{a+e+1,0\}}-2q^{min\{a+e+2,0\}-1}+q^{min\{a+e+3,0\}-2}) \\
    \cdot & q^{2min\{e+1,0\}}(q^r)^{2 min\{e,0\}}\cdot \frac{1}{q^{2e-1}(q-1)}.
\end{align*}
The second summation is easy to compute, it is
\begin{align*}
    & (\sum_{e=-a-2}^{-a-2}+\sum_{e=-a-1}^{-1}+\sum_{e=0}^\infty) \frac{1}{q} (q^{min\{a+e+1,0\}}-2q^{min\{a+e+2,0\}-1}+q^{min\{a+e+3,0\}-2}) \\
    \cdot & q^{2min\{e+1,0\}}(q^r)^{2 min\{e,0\}}\cdot \frac{1}{q^{2e-1}(q-1)}\\
    =&-(q^r)^{-2a-4}+(q-1)\sum_{e=-a-1}^{-1} (q^r)^{2e}+\frac{1}{q+1}.
\end{align*}

Again for a subset $\Lambda \subseteq \mathbb{Z}^2$ define
\begin{align*}
    I(\Lambda)
    :=&\sum_{\epsilon_1, \epsilon_2}\sum_{(e_1,e_2)\in \Lambda} \frac{1}{q}(q^{min\{a+2 e_1+1,0\}}-q^{min\{a+2e_1+2,0\}-1})(q^{min\{a+2 e_2+2,0\}}-q^{min\{a+2e_2+3,0\}-1})\\
    \cdot & J(v \epsilon_1 \varpi_0^{e_1})J(v\epsilon_2 \varpi_0^{e_2}) J( \epsilon_1 \varpi_0^{e_1})J(\epsilon_2 \varpi_0^{e_2}) (q^r)^{2min\{e_1,0\}+2min\{e_2,0\}}\cdot \alpha(e_1,e_2).
\end{align*}
The summand is nonzero if and only if $a+2e_2+2\geq 0$ and $a+2e_1+1\geq 0$, or equivalently $e_2\geq -\left \lfloor{\frac{a}{2}}\right \rfloor -1=-\frac{a+1}{2}$ and $e_1\geq -\left \lfloor{\frac{a+1}{2}}\right \rfloor=-\frac{a+1}{2}$ since $a$ is odd.

Assume that $a> 0$, otherwise the following is not needed and can be skipped.
\begin{align}\label{eq:TASU I a/2-1}
    & I( \{ -\frac{a+1}{2} \}\times \mathbb{Z})\\ \nonumber
    =&\sum_{e_2\in \mathbb{Z}} \sum_{\epsilon_1, \epsilon_2} \frac{1}{q}(1-\frac{1}{q})
    q^{-\left \lfloor{\frac{a}{2}}\right \rfloor-1}\cdot
    \chi(v\epsilon_1) \mathfrak{g}\cdot
    q^{-\left \lfloor{\frac{a}{2}}\right \rfloor-1}\cdot
     \chi(\epsilon_1) \mathfrak{g} \cdot(q^r)^{-2\left \lfloor{\frac{a}{2}}\right \rfloor-2}\\ \nonumber
    \cdot &(q^{min\{a+2 e_2+2,0\}}-q^{min\{a+2e_2+3,0\}-1})
     J(v \epsilon_2 \pi_0^{e_2}) J( \epsilon_2 \pi_0^{e_2}) (q^r)^{2min\{e_2,0\}}\cdot \alpha(-\frac{a+1}{2},e_2)\\ \nonumber
     =& 2 (1-\frac{1}{q})
    q^{-a-1} \chi(-v)
     (q^r)^{-a-1} (\sum_{e_2=-\frac{a+1}{2}}^{-1}+\sum_{e_2=0}^\infty)\\ \nonumber
     & \cdot\sum_{\epsilon_2}(q^{min\{a+2 e_2+2,0\}}-q^{min\{a+2e_2+3,0\}-1})
     J(v \epsilon_2 \varpi_0^{e_2}) J( \epsilon_2 \varpi_0^{e_2}) (q^r)^{2min\{e_2,0\}}\cdot \alpha(-\frac{a+1}{2},e_2)\\ \nonumber
    =&\sum_{e_2=-\frac{a+1}{2}}^{-1} (q-1)^2 q^{e_2+\left \lfloor{\frac{a}{2}}\right \rfloor+1}
     (q^r)^{2e_2-a-1}+(q-1)q^{\left \lfloor{\frac{a}{2}}\right \rfloor+1} \chi(-v) (q^r)^{-a-1}.
\end{align}

Assume that $a> 0$, otherwise the following calculation is not needed and can be skipped. For $-\left \lfloor{\frac{a}{2}}\right \rfloor \leq e_1\leq -1$, we have
\begin{align}\label{eq:TASU I e_1 Z}
    & I(\{e_1\}\times \mathbb{Z})\\ \nonumber
    =& 2 \frac{1}{q}(1-\frac{1}{q})q^{2e_1+1} \chi(-v) (q^r)^{2e_1}  (\sum_{e_2=-\left \lfloor{\frac{a}{2}}\right \rfloor-1}^{e_1-1}+\sum_{e_2=e_1}^{-1}+\sum_{e_2=0}^\infty) \sum_{ \epsilon_2}\\ \nonumber
    \cdot &(q^{min\{a+2 e_2+2,0\}}-q^{min\{a+2e_2+3,0\}-1})
    \cdot J(v\epsilon_2 \varpi_0^{e_2}) J(\epsilon_2 \varpi_0^{e_2}) (q^r)^{2min\{e_2,0\}}\cdot \alpha(e_1,e_2)\\ \nonumber
    =&\sum_{e_2=-\left \lfloor{\frac{a}{2}}\right \rfloor-1}^{e_1-1} (q-1)^2q^{e_1-e_2-1} (q^r)^{2e_1+2e_2}+ \sum_{e_2=e_1}^{-1} (q-1)^2q^{e_2-e_1} (q^r)^{2e_1+2e_2}+(q-1)q^{-e_1}  \chi(-v) (q^r)^{2e_1}.
\end{align}

Now consider $e_1\geq 0$. Then
\begin{align*}
    &I(\{e_1\}\times \mathbb{Z})\\
    =& 2\frac{1}{q}(1-\frac{1}{q}) (\sum_{e_2=-\left \lfloor{\frac{a}{2}}\right \rfloor-1}^{-1}+\sum_{e_2=0}^{e_1-1}+\sum_{e_2=e_1}^\infty)\sum_{ \epsilon_2} \\
    \cdot & (q^{min\{a+2 e_2+2,0\}}-q^{min\{a+2e_2+3,0\}-1}) J(v\epsilon_2 \varpi_0^{e_2}) J(\epsilon_2 \varpi_0^{e_2}) (q^r)^{2min\{e_2,0\}}\cdot \alpha(e_1,e_2)\\
    =& \frac{1}{q} (1-\frac{1}{q})[\sum_{e_2=-\left \lfloor{\frac{a}{2}}\right \rfloor-1}^{-1}  (q-1) q^{-e_1-e_2} \chi(-v) (q^r)^{2e_2}+(1-\frac{1}{q}) q^{-e_1}\frac{1-q^{-3e_1}}{1-q^{-3}}+ q^{-4e_1+1}].
\end{align*}
Hence we get
\begin{equation}\label{eq:TASU Z geq0 Z}
     I(\mathbb{Z}_{\geq 0}\times \mathbb{Z})=\sum_{e_2=-\left \lfloor{\frac{a}{2}}\right \rfloor-1}^{-1} (q-1) q^{-e_2-1} \chi(-v) (q^r)^{2e_2}+\frac{q}{q+1}.
\end{equation}

As in Lemma \ref{lem:A+B}, for $a>0$, we can show that
\begin{align}\label{eq:TASU simplify step}
    &\sum_{e_1=1}^{\left \lfloor{\frac{a}{2}}\right \rfloor}\sum_{e_2=e_1+1}^{\left \lfloor{\frac{a}{2}}\right \rfloor+1}(q-1) q^{e_2-e_1-1} X^{e_1+e_2}+\sum_{e_1=1}^{\left \lfloor{\frac{a}{2}}\right \rfloor}\sum_{e_2=1}^{e_1}(q-1) q^{e_1-e_2}X^{e_1+e_2}\\ \nonumber
    =&\sum_{e=2}^{\left \lfloor{\frac{a}{2}}\right \rfloor+1} (q^{e-1}-1) X^e+\sum_{e=\left \lfloor{\frac{a}{2}}\right \rfloor+2}^{a} (q^{a-e+1}-1) X^e.
\end{align}

Combining \eqref{eq:TASU I a/2-1}, \eqref{eq:TASU I e_1 Z}, \eqref{eq:TASU Z geq0 Z} and \eqref{eq:TASU simplify step}, we have that
for all $a\geq -1$
\[
     \alpha(S,T,X)
    =-X^{a+2}+\sum_{e=\frac{a+1}{2}+1}^{a+1} (q-1) q^{a+2-e} X^{e}+(q-1)\sum_{e=1}^{\frac{a+1}{2}} q^{e-1} X^e+1+\sum_{e=1}^{ \frac{a+1}{2}}(q^2-1)\chi(-v)q^{e-1}X^{e}.
\]
Using the identity \eqref{eq:difference identity} with $Y=q$ and $\frac{1}{q}$, we see that the above is the same with the third formula in Theorem \ref{thm:localdensity calculation}. \qedsymbol

\subsection{Proof of \eqref{eq:local density second formula} and \eqref{eq:local density fourth formula}}
For $T\in \mathrm{Herm}_n(F_0), S\in \mathrm{Herm}_m(F_0)$,
we define primitive local densities as in \cite{kitaoka1983note}:
\begin{align}
    \beta(S, T)&=q^{\ell n (n-2m)}\cdot\\ \nonumber
    & |\{ X \in M_{m,n}(\mathcal{O}_{F}/\pi_0^\ell):\mathrm{rank}_{\mathcal{O}_F/\pi\mathcal{O}_F}(X)=n,  S[X]-T \in  \pi_0^\ell \cdot \mathrm{Herm}^\vee_n(\mathcal{O}_{F_0})\}|
\end{align}
for sufficiently large $\ell$. We define the primitive local density polynomial
$\beta(S,T,X)\in \mathbb{Q}[X]$ by
\begin{equation}
    \beta(S,T,q^{-2r})=\beta(S_r,T).
\end{equation}
The following is the analogue of \cite[Theorem 1]{kitaoka1983note} in the Hermitian form case.
\begin{proposition}\label{prop:induction on fundamental invariants}
Define $U_n=\mathrm{GL}_n(\mathcal{O}_F)$ and $ \pi_{n,i}$ to be the double coset $U_n (\pi I_i\oplus I_{n-i}) U_n$ in $\mathrm{GL}_n(F)$. Then we have
\begin{align*}
			\alpha(S, T, X)
			= \sum_{i=1}^{n} (-1)^{i-1} q^{i(i-1)/2+i(n-m)}X^{i}
		 \cdot \sum_{g\in U_n\backslash \pi_{n,i}} \alpha(S,T[g^{-1}],X) + \beta(S,T,X).
		\end{align*}
\end{proposition}
We now assume again that $m=n=2$.
\begin{lemma} Assume that $T$ is integral or $T=\mathcal{H}$.
\begin{align*}
	\beta(\mathcal{H},T,X)=\begin{cases}
				(1-q^{-2}X),& \text{ if $T$ is equivalent to } \mathcal{H},\\
				(1-X)(1-q^{-2}X), & \text{ otherwise}.
	\end{cases}
\end{align*}
\end{lemma}\label{lem:primitive local density}
\begin{proof}
This is a special case of \cite[Lemma 2.16]{LL2}. We simply evaluate the summand of their formula at $s+1$ and $L=L'$, and make the substitution $X=q^{-2s}$.
\end{proof}

We define the fundamental invariant of $T$ following \cite[Definition 2.12]{LL2}. If $T$ is equivalent to $\mathrm{Diag}\{u_1 (-\pi_0)^a,u_2 (-\pi_0)^b\}$ with $u_1,u_2\in \mathcal{O}_{F_0}^\times$ and $a\geq b$, we define its fundamental invariant to be $i(T)=(2a+1,2b+1)$. If $T$ is equivalent to $\begin{pmatrix}
0 & \pi^{2a-1} \\
(-\pi)^{2a-1} & 0
\end{pmatrix}$, we define its fundamental invariant to be $i(T)=(2a,2a)$. The set of fundamental invariants is partially ordered by the partial order inherited from $\mathbb{Z}^2$.

Our proof is based on induction on $i(T)$.
Notice that $i(T[g^{-1}])<i(T)$ for any $g\in U_2\backslash \pi_{2,i}$ ($i=1,2$). If $i(T)=(s,t)$ with $s\geq t$ and $t<0$, then $\alpha(S,T,X)=0$. By Proposition \ref{prop:induction on fundamental invariants}, it suffices to prove that
\begin{equation}\label{eq:induction on fi formula}
``\alpha(\mathcal{H},T,X)"-\sum_{i=1}^{2} (-1)^{i-1} q^{i(i-1)/2}X^{i}
		 \cdot \sum_{U_n\backslash \pi_{n,i}} ``\alpha(\mathcal{H},T[g^{-1}],X)"= \beta(\mathcal{H},T,X)
\end{equation}
for any $T$ such that $i(T)\geq (0,0)$,
where $``\alpha(\mathcal{H},T,X)"$ is the claimed formula of $\alpha(\mathcal{H},T,X)$ in Theorem \ref{thm:localdensity calculation}.

\noindent
Case 1. We first prove the case $\chi(T)=-1$. In this case we can assume  $T=\mathrm{Diag}\{u_1 (-\pi_0)^a,u_2 (-\pi_0)^b\}$ with $u_1,u_2\in \mathcal{O}_{F_0}^\times$ and $a\geq b$. Define
\[
    \mu(a,b,X)=\frac{``\alpha(\mathcal{H},T,X)"}{1-q^{-2}X}=\begin{cases}
    \sum_{e=0}^bq^e X^e-\sum_{e=a+1}^{a+b+1} q^{a+b+1-e} X^e,& \text{ if } b\geq 0 \\
    0, & \text{ if } b< 0,
    \end{cases}
\]
where $T\in \mathrm{Herm}_2(F_0)$ such that $\chi(T)=-1$ and $i(T)=(2a+1,2b+1)$.
The set $U_2\backslash \pi_{2,1}$ is represented by $q+1$ elements
\begin{equation}
    \gamma_\infty=\begin{pmatrix}
    \pi & 0\\
    0 & 1
    \end{pmatrix},
    \gamma_x=\begin{pmatrix}
    1 & x\\
    0 & \pi
    \end{pmatrix}, \quad x\in \mathcal{O}_F/\pi \mathcal{O}_F.
\end{equation}
The set $U_2\backslash \pi_{2,2}$ is the singleton represented by $\mathrm{Diag}\{\pi,\pi\}$. According to the preceding argument, it suffices to prove that in each the following sub cases, \eqref{eq:induction on fi formula} holds.
\begin{enumerate}[label=(\alph*)]
    \item $i(T)=(2a+1,2b+1)$ with $a>b>0$.
    \item $i(T)=(2a+1,2b+1)$ with $a>b=0$.
    \item $i(T)=(2a+1,2a+1)$ with $a>0$.
    \item $i(T)=(2a+1,2a+1)$ with $a=0$.
\end{enumerate}
If $i(T)=(2a+1,2b+1)$ with $a>b$, then
\[i(T[\gamma_\infty^{-1}])=(2a-1,2b+1), \quad i(T[\gamma_x^{-1}])=(2a+1,2b-1).\]
In this case we need to show that
\[
     \mu(a,b,X)-q X\mu(a,b-1,X)-X\mu(a-1,b,X)+q X^2\mu(a-1,b-1,X)=1-X.
\]
If $i(T)=(2a+1,2a+1)$, then
\[i(T[\gamma_\infty^{-1}])=(2a+1,2a-1), \quad i(T[\gamma_x^{-1}])=(2a+1,2a-1).\]
In this case we need to show that
\[
     \mu(a,a,X)-(q+1) X\mu(a,a-1,X)+q X^2\mu(a-1,a-1,X)=1-X.
\]
In sub case (a), we have
\begin{align*}
    &\mu(a,b,X)-q X\mu(a,b-1,X)-X\mu(a-1,b,X)+q X^2\mu(a-1,b-1,X)\\
    =&\sum_{e=0}^b q^e X^e-\sum_{e=a+1}^{a+b+1} q^{a+b+1-e} X^e
    -\sum_{e=1}^b q^e X^e+\sum_{e=a+2}^{a+b+1} q^{a+b+2-e} X^e \\
    -&\sum_{e=0}^b q^e X^{e+1}+\sum_{e=a+1}^{a+b+1} q^{a+b+1-e} X^e
    +\sum_{e=1}^b q^e X^{e+1}-\sum_{e=a+2}^{a+b+1} q^{a+b+2-e} X^e\\
    =&1-X.
\end{align*}
In sub case (b), we have
\begin{align*}
    &\mu(a,b,X)-q X\mu(a,b-1,X)-X\mu(a-1,b,X)+q X^2\mu(a-1,b-1,X)\\
    =&\mu(a,0,X)-X\mu(a-1,0)\\
    =&1-X.
\end{align*}
Sub case (c) and (d) are similar and left to the reader.

\noindent
Case 2. We first prove the case $\chi(T)=1$. In this case $T$ can be either diagonalized or anti-digonalized. According to the fundamental invariant, we define
\[
    \nu(s,t,X)=\begin{cases} \sum_{e=0}^b q^e X^e+\sum_{e=a+1}^{a+b+1} q^{a+b+1-e} X^e &\text{ if } s=2a+1,t=2b+1,b\geq 0, \\
     \sum_{e=0}^a q^e X^e+\sum_{e=a+1}^{2a} q^{2a-e} X^e &\text{ if } s=t=2a, a\geq 0,\\
    0 & \text{ if } t< 0.
    \end{cases}
\]
Again it suffices to prove that in each the following sub cases, \eqref{eq:induction on fi formula} holds.
\begin{enumerate}[label=(\alph*)]
    \item $i(T)=(2a+1,2b+1)$ with $a>b>0$.
    \item $i(T)=(2a+1,2b+1)$ with $a>b=0$.
    \item $i(T)=(2a+1,2a+1)$ with $a>0$.
    \item $i(T)=(1,1)$.
    \item $i(T)=(2a,2a)$ with $a>0$.
    \item $i(T)=(0,0)$.
\end{enumerate}
If $i(T)=(2a+1,2b+1)$ with $a>b$ we assume $T=\mathrm{Diag}\{u_1 (-\pi_0)^a,u_2 (-\pi_0)^b\}$ with $u_1,u_2\in \mathcal{O}_{F_0}^\times$. Then
\[i(T[\gamma_\infty^{-1}])=(2a-1,2b+1), \quad i(T[\gamma_x^{-1}])=(2a+1,2b-1).\]
In this case we need to show that
\[
     \nu(2a+1,2b+1,X)-q X\nu(2a+1,2b-1,X)-X\nu(2a-1,2b+1,X)+q X^2\nu(2a-1,2b-1,X)=1-X.
\]
If $i(T)=(2a+1,2a+1)$, we assume $T=\begin{pmatrix}
0 & \pi^{2a} \\
(-\pi)^{2a} & 0
\end{pmatrix}$.  Then
\[i(T[\gamma_\infty^{-1}])=(2a,2a), \quad i(T[\gamma_x^{-1}])=(2a+1,2a-1) \text{ for } x\neq0, \quad i(T[\gamma_0^{-1}])=(2a,2a) .\]
In this case we need to show that
\[
     \nu(2a+1,2a+1,X)-(q-1) X\nu(2a+1,2a-1,X)-2X\nu(2a,2a,X)+q X^2\nu(2a-1,2a-1,X)=1-X.
\]
If $i(T)=(2a,2a)$, we assume $T=\begin{pmatrix}
0 & \pi^{2a-1} \\
(-\pi)^{2a-1} & 0
\end{pmatrix}$.  Then
\[i(T[\gamma_\infty^{-1}])=(2a-1,2a-1), \quad i(T[\gamma_x^{-1}])=(2a-1,2a-1).\]
In this case we need to show that
\[
     \nu(2a,2a,X)-(q+1) X\nu(2a-1,2a-1,X)+q X^2\nu(2a-2,2a-2,X)=\begin{cases}
     1-X & \text{ if } a>0, \\
     1 & \text{ if } a=0.
     \end{cases}
\]

In sub case (a), we have
\begin{align*}
    &  \nu(2a+1,2b+1,X)-q X \nu(2a+1,2b-1,X)-X \nu(2a-1,2b+1,X)+q X^2  \nu(2a-1,2b-1,X) \\
     =&\sum_{e=0}^b q^e X^e+\sum_{e=a+1}^{a+b+1} q^{a+b+1-e} X^e
    -\sum_{e=1}^b q^e X^e-\sum_{e=a+2}^{a+b+1} q^{a+b+2-e} X^e \\
    -&\sum_{e=0}^b q^e X^{e+1}-\sum_{e=a+1}^{a+b+1} q^{a+b+1-e} X^e
    +\sum_{e=1}^b q^e X^{e+1}+\sum_{e=a+2}^{a+b+1} q^{a+b+2-e} X^e\\
    =&1-X.
\end{align*}
In sub case (b), we have
\begin{align*}
    &  \nu(2a+1,2b+1,X)-q X \nu(2a+1,2b-1,X)-X \nu(2a-1,2b+1,X)+q X^2  \nu(2a-1,2b-1,X) \\
     =&  \nu(2a+1,1,X)-X \nu(2a-1,1,X)\\
     =&1-X.
\end{align*}
The rest cases are similar and we leave the calculation to the reader.
\qedsymbol

\part{Global theory}

\section{Intersection of special cycles on unitary Shimura curves}\label{sec:globalintersecionnumber}
We switch our notations in this section. Let ${\bf k}=\mathbb{Q}[\sqrt{-\Delta}]$ be an imaginary quadratic extension of $\mathbb{Q}$ with discriminant $-\Delta$. Let $\chi$ be the character of $\mathbb{A}^\times$ associated to the extension $F/F_0$.
Let $\mathrm{Herm}_n$ be the group scheme defined by \eqref{eq:Herm_n global}. For a sub-algebra $R$ of $\mathbb{R}$, we denote by $\mathrm{Herm}_n(R)_{>0}$ the set of positive definite hermitian matrices in  $\mathrm{Herm}_n(R)$.
\subsection{Global moduli problem} In this subsection, we briefly review the definition of an integral model of Shimura variety defined  in \cite{BHKRY1} over $\mathrm{Spec}\,  \mathcal{O}_{\bf k}$ . Let
\[\mathcal{M}^{\mathrm{Kra}}_{(n-1,1)} \rightarrow \mathrm{Spec}\,  \mathcal{O}_{\bf k}\]
be the algebraic stack which assigns to each $\mathcal{O}_{\bf k}$-scheme $S$ the groupoid of isomorphism classes of quadruples $(A,\iota,\lambda,\mathcal{F}_A)$ where
\begin{enumerate}
    \item $A\rightarrow S$ is an abelian scheme of relative dimension $n$;
    \item $\iota:\mathcal{O}_{\bf k}\rightarrow \mathrm{End}(A)$ is an action satisfies the following determinant condition
    \[\mathrm{char}(T-\iota(\alpha)\mid \mathrm{Lie}\,  A)=(T-s(\alpha))^{n-1}(T-s(\bar{\alpha})) \in \mathcal{O}_S[T],\]
    for all $\alpha\in \mathcal{O}_{\bf k}$ where $s:\mathcal{O}_{\bf k}\rightarrow \mathcal{O}_S$ is the structure morphism;
    \item There is a principal polarization $\lambda:A\rightarrow A^\vee $ whose Rosati involution satisfies $\iota(\alpha)^*=\iota(\bar{\alpha})$ for all $\alpha \in \mathcal{O}_{\bf k}$;
    \item $\mathcal{F}_A \subset \mathrm{Lie}\,  A$ is an $\mathcal{O}_{\bf k}$-stable $\mathcal{O}_S$-module local direct summand of rank $n-1$ satisfying the Kr\"amer condition: $\mathcal{O}_{\bf k}$ acts on $\mathcal{F}_A$ by the structure map $s:\mathcal{O}_{\bf k} \rightarrow \mathcal{O}_S$ and acts on $\mathrm{Lie}\,  A/\mathcal{F}_A$ by the complex conjugate of the structure map.
\end{enumerate}
$\mathcal{M}^{\mathrm{Kra}}_{(n-1,1)}$ is flat of dimension $n-1$ over $\mathrm{Spec}\,  \mathcal{O}_{\bf k}$. It is smooth over $\mathrm{Spec}\,  \mathcal{O}_{\bf k}[\frac{1}{\sqrt{-\Delta}}]$ and has semi-stable reduction over primes of ${\bf k}$ dividing $\sqrt{-\Delta}$. This is indicated by the corresponding behaviour of its local model studied in \cite{Kr}. As a special case, $\mathcal{M}_{(1,0)}$ is the moduli stack of elliptic curve with $\mathcal{O}_bk$-action.

Assume that $\mathbb{F}$ is an algebraically closed field of characteristic $p$ over ${\bf k}$. Let
\[(E_0,\iota_0,\lambda_0,A,\iota,\lambda,\mathcal{F}_A)\in (\mathcal{M}_{(1,0)}\times \mathcal{M}^{\mathrm{Kra}}_{(n-1,1)})(\mathrm{Spec}\,  \mathbb{F}).\]
We can define a hermitian form $h(x,y)$ on the relative prime to $p$ Tate module
\begin{equation}
    T^p(E_0,A):=\mathrm{Hom}_{\mathcal{O}_{\bf k}}(T^p(E_0),T^p(A))
\end{equation}
as in \cite[Section 2.3]{KR2} using the polarizations $\lambda_0,\lambda$ and Weil pairings on $E_0,A$.

Fix a hermitian space $W$ over ${\bf k}$  of signature $(n-1,1)$ that contains a self-dual lattice $\mathfrak a$ and a hermitian space $W_0$ over ${\bf k}$  of signature $(1,0)$ that contains a self-dual lattice $\mathfrak{a}_0$. Define
\begin{equation}\label{eq:VandL}
    V:=\mathrm{Hom}_{\bf k} (W_0,W), \quad L:=\mathrm{Hom}_{\mathcal{O}_{\bf k}}(\mathfrak{a}_0,\mathfrak{a}).
\end{equation}
$V$ and $L$ are equipped with hermitian forms coming from the ones on $W_0$ and $W$. Define $G:=\mathrm{U}(W)$. Also define the group scheme $\mathrm{GU}(W)$ over $\mathbb{Q}$ by
\[\mathrm{GU}(W)(R)=\{g\in \mathrm{GL}_R(W\otimes R)\mid (gv,gw)=c(g)(v,w),\forall v,w\in W\otimes R\}\]
where $R$ is any $\mathbb{Q}$-algebra. Also define $Z:=\mathrm{Res}_{{\bf k}/\mathbb{Q}} \mathbb{G}_m=\mathrm{GU}(W_0)$ and
\begin{equation}\label{eq:tildeG}
    \tilde{G}:=Z\times_{\mathbb{G}_m} \mathrm{GU}(W)
\end{equation}
where the maps from the factors on the right hand side to $\mathbb{G}_m$ are $\mathrm{Nm}_{{\bf k}/\mathbb{Q}}$ and the similitude character $c(g)$ respectively. We have an isomorphism of group schemes
\begin{equation}\label{eq:tildeGisomorphism}
   \tilde{G}\rightarrow Z\times \mathrm{U}(W), (z,g)\mapsto (z,z^{-1}g).
\end{equation}
Let $K_G$ be the compact subgroup of $G(\mathbb{A}_f)$ that stabilizes the lattice $\mathfrak{a}\otimes \mathbb{A}_f$ and $K_Z=\hat{\mathbb{Z}}^\times\subset Z(\mathbb{A}_f)$. Under the isomorphism \eqref{eq:tildeGisomorphism}, define
\begin{equation}
    K:=K_Z\times K_G.
\end{equation}

Now define
$\mathcal{M}\subset \mathcal{M}_{(1,0)}\times \mathcal{M}^{\mathrm{Kra}}_{(n-1,1)}$
to be the open and closed substack such that $(E_0,\iota_0,\lambda_0,A,\iota,\lambda,\mathcal{F}_A)\in \mathcal{M}(S)$ if and only if there is an isomorphism of hermitian $\mathcal{O}_{\bf k}\otimes_\mathbb{Z} \mathbb{A}^p_f$-modules
\begin{equation}
    T^p(E_{0,s},A_s)\cong L\otimes \mathbb{A}^p_f
\end{equation}
for any geometric point $s\in S$ where $p$ is the characteristic of $s$. If $s$ has characteristic zero, simply use $T(E_{0,s},A_s)$ instead.
$\mathcal{M}$ is an integral model of the Shimura variety associated to the group $\tilde{G}$ with level structure defined by $K$.

\subsection{Intersection of special cycles}
Now we review the definition of special cycles. For $(E,\iota_0,\lambda_0, A,\iota, \lambda,\mathcal{F}_A)\in \mathcal{M}(S)$ where $S$ is an $\mathcal{O}_{\bf k}$-scheme, consider the projective $\mathcal{O}_{\bf k}$-module of finite rank
\[V'(E,A)=\mathrm{Hom}_{\mathcal{O}_{\bf k}}(E,A).\]
On this module there is a hermitian form $h'(x,y)$ defined by
\begin{equation}
    h'(x,y)=\iota_0^{-1}(\lambda_0^{-1}\circ y^\vee \circ \lambda \circ x),
\end{equation}
where $y^\vee$ is the dual homomorphism of $y$. It is proved in \cite[Lemma 2.7]{KR2} that $h'(x,y)$ is positive semi-definite.
\begin{definition}\label{def:globalspecialcycle}
For $T\in \mathrm{Herm}_m(\mathbb{Z})_{>0}$, the special cycle $\mathcal{Z}^\mathrm{Kra}(T)$ is the collection  $(E,\iota_0,\lambda_0,A,\iota ,\lambda,\mathcal{F}_A,{\bf x})$ where
\[(E,\iota_0,\lambda_0,A,\iota ,\lambda,\mathcal{F}_A)\in \mathcal{M}(S)\]
and ${\bf x}=(x_1,\ldots,x_m)\in \mathrm{Hom}_{\mathcal{O}_{\bf k}}(E,A)^m$ such that
\[h'({\bf x},{\bf x})=(h'(x_i,x_j))=T.\]
\end{definition}

For a $T\in \mathrm{Herm}_n(\mathbb{Z})_{>0}$, let $V_T$ be the hermitian space over ${\bf k}$ with Gram matrix $T$. Define $\mathrm{Diff}(V_T,V)$ as in \eqref{eq:Diff}.
By the Hasse principal, the cardinality of $\mathrm{Diff}(V_T,V)$ is odd.  By \cite[Proposition 2.22]{KR2} or \cite[Proposition 5.4]{Shi1}, $\mathcal{Z}^\mathrm{Kra}(T)$ is empty if $|\mathrm{Diff}(V_T,V)|>1$ and is supported on $\mathcal{M}^{ss}_{p}$ if
$\mathrm{Diff}(V_T,V)=\{p\}$ where $p$ is a prime inert or ramified in ${\bf k}$ and $\mathcal{M}^{ss}_p$ is the super singular locus of $\mathcal{M}$ over ${\bf k}_p$.

For a hermitian lattice or vector space $M$, define
\begin{equation}
    \Omega(T,M)=\{x\in M\mid (x,x)=T\}.
\end{equation}
For a positive definite hermitian lattice $L$, let $[[L]]$ be its genus. Define the representation number
\begin{equation}\label{eq:rgen}
   r_{\mathrm{gen}}(T,[[L]])=\sum_{M\in [[L]]} |\mathrm{Aut}(M)|^{-1} |\Omega(T,M)|
\end{equation}
where $\mathrm{Aut}(M)$ is the automorphism group of $M$.

We now specialize to the case when $n=2$. Our main global geometric result is the following theorem.
\begin{theorem}\label{globaintersectionnumber}
Let $p$ be an odd prime of $\mathbb{Q}$ ramified in ${\bf k}$ such that $V_p$ is isotropic. Assume $T\in \mathrm{Herm}_2(\mathbb{Z})_{>0}$ with $\mathrm{Diff}(V_T,V)=\{p\}$. Let $h_{\bf k}$ be the class number of ${\bf k}$ and $w_{\bf k}$ be the number of units in $\mathcal{O}_{\bf k}^\times$. Then
\[\widehat{\mathrm{deg}}(\mathcal{Z}^\mathrm{Kra}(T))=\log p\cdot \mu_p(T)\cdot \frac{h_{\bf k}}{ w_{\bf k}} r_{\mathrm{gen}}(T,[[L']]),\]
where $\widehat{\mathrm{deg}}(\mathcal{Z}^\mathrm{Kra}(T))$ is defined in \eqref{eq:degcZ}, $L'$ is a self-dual lattice in $V_T$ such that $L'\otimes \mathbb{A}^p_f\cong L\otimes \mathbb{A}^p_f$ as hermitian spaces and $\mu_p(T)$ is as in Theorem \ref{thm:maintheorem1}.
\end{theorem}
\begin{proof}
The theorem follows from Theorem \ref{thm:maintheorem1} and the standard $p$-adic uniformization theorem for basic locus of Shimura varieties (see for example \cite[Theorem 6.30]{RZ}).
By our assumption $V_T\otimes_{\mathbb{Q}} \mathbb{Q}_p$ contains a unique integral lattice, hence
the proof of \cite[Theorem 11.8]{KR2} applies to our situation without any change. So we omit the details.
\end{proof}

\section{Derivative of incoherent Eisenstein series}\label{sec:Eisensteinseries}
For the moment, let $(V,(,))$ be any non-degenerate hermitian space over ${\bf k}$ of dimension $m$. Let $G=\mathrm{U}(V)$ and let $H=\mathrm{U}(W_{n,n})$ where $(W_{n,n},\langle,\rangle)$ is a split skew hermitian space of dimension $2n$. Let $\mathbb{W}=V\otimes_{\bf k} W_{n,n}$ with the symplectic form
\[\langle\langle v_1\otimes w_1,v_2 \otimes w_2\rangle\rangle=\mathrm{tr}_{{\bf k}/\mathbb{Q}} ((v_1,v_2)\langle w_1, w_2 \rangle),\]
There is a homomorphism $G\times H\rightarrow \mathrm{Sp}(\mathbb{W})$ and $(G,H)$ is a reductive dual pair.

Fix a character $\eta$ of ${\bf k}_\mathbb{A}^\times$ whose restriction to $\mathbb{Q}_\mathbb{A}^\times$ is $\chi^m$ where $\chi$ is the global quadratic character attached to the extension ${\bf k}/\mathbb{Q}$. By \cite{Kudlasplitting}, the choice of $\eta$ determines a homomorphism
\[G(\mathbb{A})\times H(\mathbb{A}) \rightarrow \mathrm{Mp}(\mathbb{W})(\mathbb{A}),\]
where $\mathrm{Mp}(\mathbb{W})(\mathbb{A})$ is the metaplectic cover of $\mathrm{Sp}(\mathbb{W})(\mathbb{A})$, hence a Weil representation $\omega$ of $G(\mathbb{A})\times H(\mathbb{A}) $ on the Schwartz space $\mathcal{S}(V(\mathbb{A})^n)$. We normalize this so that the action of $G(\mathbb{A})$ is given by
\[(\omega(g,1)\varphi)(x)=\varphi(g^{-1}x).\]
The Weil representation depends on a choice of a continuous additive character $\psi$ on $ \mathbb{Q} \backslash \mathbb{A}$. We fix such a choice given by
\begin{equation}
    \psi_\infty(x)=\exp(2\pi i x), \psi_\ell(x)=\exp(-2 \pi i \lambda(x)),
\end{equation}
where $\lambda$ is the canonical map $\mathbb{Q}_\ell \rightarrow \mathbb{Q}_\ell/\mathbb{Z}_\ell \hookrightarrow \mathbb{Q}/\mathbb{Z}$.

We are interested in exactly the same incoherent Eisenstein series considered in \cite[Section 9]{KR2}, whose construction we now briefly recall. From now on assume $V$ is of signature $(n-1,1)$ and contains a self-dual lattice $L$. Let $\varphi_f\in \mathcal{S}(V(\mathbb{A}_f)^n)$ be the characteristic function of $(L\otimes \hat{\mathbb{Z}})^n$. The incoherent Eisenstein series is defined to be $E(h,s,\Phi)$ for $\Phi(h,s)=\Phi_\infty(h,s)\otimes \Phi_f(h,s,L)$ where $\Phi_f(h,s,L)$ is the Siegel-Weil section associated to $\varphi_f$ and $\Phi_\infty(h,s)$ is the Siegel-Weil section attached to the Gaussian of a hermitian space of signature $(n,0)$. We have
\[E(h,s,\Phi)=\sum_{\gamma \in P({\bf k})\backslash H({\bf k})} \Phi(\gamma h,s),\]
where $P\subset H$ is the Siegel parabolic subgroup. The Eisenstein series has meromorphic continuation to $s\in \mathbb{C}$ and a functional equation relating $s\leftrightarrow -s$. We call $E'(h,0,\Phi)=\frac{\partial}{\partial s} E(h,s,\Phi)|_{s=0}$ its central derivative.

Let us to relate the above Eisenstein series to the classical Eisenstein series. Let $D(W_{n,n})$ be defined by
\[D(W_{n,n})=\{z\in M_n(\mathbb{C})\mid v(z):=(2i)^{-1} (z-z^*)>0\}. \]
Write $z=u(z)+i v(z)$ where $u(z)=\frac{1}{2}(z+z^*)$, and let
\[h_z=\left(\begin{array}{cc}
    I_n & u(z) \\
     & I_n
\end{array}\right)\left(\begin{array}{cc}
   a &  \\
     & (a^*)^{-1}
\end{array}\right)\in H(\mathbb{R}),\]
where $a\in \mathrm{GL}_n(\mathbb{C})$ with $v(z)=a a^*$. Note that $iI_n\in D(W_{n,n})$ and $h_z\cdot iI_n=z$. Now let
\begin{equation}\label{eq:h(z)}
    h(z)=(h_z,1)\in H(\mathbb{R})\times H(\mathbb{A}_f)=H(\mathbb{A}).
\end{equation}
Define
\begin{equation}\label{classicalEisenstein}
    E(z,s,\Phi)=\eta_\infty(\mathrm{det}(a))^{-1} \mathrm{det}(v(z))^{-\frac{n}{2}} E(h(z),s,\Phi).
\end{equation}
It is the corresponding classical Eisenstein series of $ E(h,s,\Phi)$.

Recall that for a place $v$ of $\mathbb{Q}$ we can define the local Whittaker function
\begin{equation}\label{eq:W_T,v}
    W_{T,v}(h_v,s,\Phi_v)=\int_{\mathrm{Herm}_n(\mathbb{Q}_v)} \Phi_v(w^{-1}n(b)h_v,s) \psi_v (-\mathrm{tr}(Tb))db,
\end{equation}
where
\[w=\left(\begin{array}{cc}
     & I_n \\
    -I_n &
\end{array}\right), n(b)=\left(\begin{array}{cc}
    I_n & b \\
     & I_n
\end{array}\right),\]
and $db$ is the self-dual measure with respect to the pairing
\[\psi_v (\mathrm{tr}(bc))\]
on  $\mathrm{Herm}_n(\mathbb{Q}_v)$.

By a standard unfolding calculation, we know that the $T$-th Fourier coefficient $E_T(h(z),s,\Phi)$ of $E(h(z),s,\Phi)$ for a non-degenerate $T$ is
\begin{equation}
    E_T(h(z),s,\Phi)=\prod_{v} W_{T,v}(h_v(z),s,\Phi_v),
\end{equation}
where the product is taken over all places of $\mathbb{Q}$, is convergent for large $s$
and has an analytic continuation to $s\in \mathbb{C}$.
\begin{remark}
To ease notations, we write $W_{T,p}(s,\Phi_p)$ for $W_{T,p}(1,s,\Phi_p)$ for a finite prime $p$.
\end{remark}

\subsection{Main global identity} Now we specialize to the case when $n=2$. Let $V$ and $L$ be as in \eqref{eq:VandL}.
We suppose that $T\in \mathrm{Herm}_2(\mathbb{Z})_{>0}$ with $\mathrm{Diff}(V_T,V)=\{p\}$ for an odd prime $p$ ramified in ${\bf k}$. We assume $V'=V_T$ is anisotropic over ${\bf k}_p$.
Fix an isomorphism $V'(\mathbb{A}_f^p)=V(\mathbb{A}_f^p)$ and let $L'$ be the lattice in $V'$ determined by $L'\otimes \hat{\mathbb{Z}}^p=L\otimes \hat{\mathbb{Z}}^p$ and $L'_p=\Lambda$ where $\Lambda\subset V'_p$ is the unique self-dual lattice. Let $\varphi'_f\in \mathcal{S}((V')^2)$ be the characteristic function of $(L'\otimes \hat{\mathbb{Z}})^2$. Let $\Phi'$ be the Siegel-Weil section associated to $\varphi'_f\otimes\varphi_\infty$.

\begin{proposition}\label{W'PhiandWPhi'}
For $T\in \mathrm{Herm}_2(\mathbb{Z})_{>0}$ with $\mathrm{Diff}(V_T,V)=\{p\}$ where $p$ is an odd prime ramified in ${\bf k}$. Suppose that under the action of $\mathrm{GL}_2(\mathcal{O}_{{\bf k},p})$, $T$ is equivalent to
\[\left(\begin{array}{cc}
    u_1 (-\Delta)^a &  \\
     & u_2 (-\Delta)^b
\end{array}\right),\]
where $u_1,u_2 \in \mathbb{Z}_p^\times$ with $\chi_p(-u_1 u_2)=-1$. Let
\[S'=\left(\begin{array}{cc}
    u_1 u_2  &  \\
     & 1
\end{array}\right), S=\left(\begin{array}{cc}
    v  &  \\
     & 1
\end{array}\right),\]
where $v\in \mathbb{Z}_p^\times$ and $ \chi_p(-v)=1$.
\begin{enumerate}
    \item We have
    \[W'_{T,p}(0,\Phi_p)=\gamma_p(V)^2 p^{-\frac{5}{2}} \alpha_p(S,S) \mu_p(T) \log p,\]
    where the derivative is taken with respect to $s$, the function $\mu_p(T)$ is defined in Theorem \ref{thm:maintheorem1} and $\gamma_p(V)$ is an eighth root of unity defined in equation \eqref{gammapV}.
    \item We have
    \[W_{T,p}(0,\Phi'_p)=\gamma_p(V)^2 p^{-\frac{5}{2}} \alpha_p(S',S'). \]
\end{enumerate}
\end{proposition}
We postpone the proof of the above proposition to the next subsection.
Notice that the hermitian form on $L'_p$ can be represented by the Gram matrix $S'$ and the hermitian form on $L_p$ can be represented by the Gram matrix $S$.

Write
\[E(z,s,L)=E(z,s,\Phi)\]
to emphasize the dependence on the choice of the self-dual lattice $L$.
\begin{proposition}\label{prop:E'_T}
Assume $T\in \mathrm{Herm}_2(\mathbb{Z})_{>0}$ with $\mathrm{Diff}(V_T,V)=\{p\}$ for an odd prime $p$ ramifieid in ${\bf k}$ and $V_{p}$ is isotropic. Then
\[E'_T(z,0,L)= C \cdot \mu_p(T) \log p \cdot r_{\mathrm{gen}}(T,[[L']])\cdot q^T, \]
where $L'$ is obtained from $L$ as explained before Proposition \ref{W'PhiandWPhi'}, $q=\exp(2\pi i \mathrm{Tr}(Tz))$ and $C$ is as in \cite[Corollary 9.4]{KR2}. The constant $C$ only depends on ${\bf k}$ and $L$.
\begin{comment}
\[C= \mathrm{vol}(G'(\mathbb{R}),d\nu') \mathrm{vol}(K,d\nu).\]
\end{comment}
\end{proposition}
\begin{proof}
Following Proposition \ref{W'PhiandWPhi'}, the proof is exactly the same as that of \cite[Corollary 9.4]{KR2}.
\end{proof}

We can now state the main global result of the paper.
\begin{theorem}\label{globalmainthm}
Let $p$ be an odd prime ramified in ${\bf k}$ such that $V_{p}$ is isotropic.
Let $T\in \mathrm{Herm}_2(\mathbb{Z})_{>0}$.  Assume that $\mathrm{Diff}(V_T,V)=\{p\}$. Then
\[E'_T(z,0,L)=C_1 \cdot \widehat{\mathrm{deg}}(\mathcal{Z}^\mathrm{Kra}(T)) \cdot q^T, \]
where
\begin{equation}\label{C_1}
    C_1=\frac{w_k}{h_k} C
\end{equation}
where $C$ is as in Proposition \ref{prop:E'_T}.
\end{theorem}
\begin{remark}
If $T$ is not integral, i.e., $T\in \mathrm{Herm}_2(\mathbb{Q})\setminus \mathrm{Herm}_2(\mathbb{Z})$, then both sides of the equation in the above theorem are zero.
\end{remark}
\begin{proof}
The theorem follows easily from Proposition \ref{prop:E'_T} and Theorem \ref{globaintersectionnumber}.
\end{proof}

\subsection{Derivative of Whittaker functions}
The purpose of this subsection is to explain the relation between local Whittaker functions and local densities of hermitian forms for an odd prime $p$ ramified in ${\bf k}$. In particular we prove Proposition \ref{W'PhiandWPhi'}. Let $F:={\bf k}_p$.

Let $L_{r,r}$ be a $2r$ dimensional hermitian $\mathcal{O}_F$-lattice with the hermitian form $(,)_{r,r}$ represented by the Gram matrix
\begin{equation}\label{interpolationmatrix}
    \frac{1}{\sqrt{-\Delta}} \left(\begin{array}{cc}
    0 & I_r \\
    -I_r & 0
\end{array}\right).
\end{equation}
Let $V_{r,r}:=L_{r,r}\otimes\mathbb{Q}$ and let $\varphi_{r,r}^n$ be the characteristic function of the lattice $L_{r,r}^n\subset V_{r,r}^n$.
We choose an $\mathcal{O}_F$-basis $\{e_1,\ldots,e_n,f_1,\ldots,f_n\}$ of $W_{n,n}$ with respect to which the skew hermitian form on $W_{n,n}$ is represented by the matrix
$\left(\begin{array}{cc}
    0 & I_n \\
    -I_n & 0
\end{array}\right)$.
Since $V_{r,r}$ has even dimension, $H:=\mathrm{U}(W_{n,n})$ acts on $V_{r,r}^n$ by the Weil representation $\omega_r$ determined by the additive character $\psi$ on $\mathbb{Q}\backslash\mathbb{A}$. Let $P$ be the Siegel parabolic that preserves the flag $\mathrm{span}\{e_1,\ldots,e_n\}\subset W_{n,n}$ and $P=MN$ be its Levi decomposition where
\[M=\left\{m(a)=\left(\begin{array}{cc}
    a &  \\
     & {}^t \bar{a}^{-1}
\end{array}\right)\mid a\in \mathrm{Res}_{F/F_0}\mathrm{GL}_n\right\},
N=\left\{n(b)=\left(\begin{array}{cc}
    1 & b \\
     & 1
\end{array}\right)\mid b\in \mathrm{Herm}_n\right\}.\]

\begin{lemma}\label{Kinvariance}
The function $\varphi_{r,r}^n$ is $K$-invariant where $K=\mathrm{U}(W_{n,n})(\mathcal{O}_{F_0})$ is a maximal compact subgroup of $\mathrm{U}(W_{n,n})$.
\end{lemma}
\begin{proof}
By the Bruhat decomposition of $K$, we know that
\[K=\sqcup_{j=0}^n P(\mathcal{O}_{F_0})w_j P(\mathcal{O}_{F_0}),\]
where
\[w_j=\left(\begin{array}{cccc}
  I_{n-j} &  &   &  \\
   &  &   & I_j \\
   &  & I_{n-j}  &  \\
  &-I_{j} &    &
\end{array}\right).\]
Write $x=(x',x'')$ where $x'\in V_{r,r}^{n-j}$ and $x''\in V_{r,r}^j$.
Recall from \cite[Section 5]{Kudlasplitting}:
\begin{equation}\label{eq:w_jaction}
    \omega_r(w_j^{-1}) \varphi_{r,r}^n (x)=\gamma_p(V_{r,r})^{-j} \varphi_{r,r}^{n-j}(x')\int_{V_{r,r}^j} \psi_p(-\mathrm{tr}_{F/\mathbb{Q}_p} (\mathrm{Tr}(x'',y)_{r,r}))\varphi_{r,r}^j(y)dy,
\end{equation}
where the measure $dy$ is defined in a way such that $\mathrm{vol}(L_{r,r}^j,dy)=1$ and $\gamma_p(V_{r,r})$ is defined in the same way as \eqref{gammapV} below. One can show that $\gamma_p(V_{r,r})=1$ in our case.

The key observation is that $L_{r,r}$ is self dual with respect to the symmetric form $\mathrm{tr}_{F/\mathbb{Q}_p}[(,)_{r,r}]$. Hence
\begin{align*}
    \int_{V_{r,r}^j} \psi_p(-\mathrm{tr}_{F/\mathbb{Q}_p}(\mathrm{Tr}(x'',y)_{r,r}))\varphi_{r,r}^j(y)dy= 1_{L_{r,r}^j}(x'').
\end{align*}
In conclusion we have
\begin{equation}
    \omega_r(w_j) \varphi_{r,r}^n (x)=\varphi_{r,r}^{n-j}(x') \varphi_{r,r}^{j}(x'')= \varphi_{r,r}^n(x).
\end{equation}
The invariance under the action of $P(\mathcal{O}_{F_0})$ is easy to check. We have completed the proof.
\end{proof}
Hence we conclude that
\begin{corollary}\label{interpolationtrick}
Let $|\cdot|_p$ be the valuation on ${\bf k}_p$ such that $|\sqrt{-\Delta}|_p=\frac{1}{p}$ for a uniformizer $\pi$ of ${\bf k}_p$. Then
\[
    \omega_r(g) \varphi_{r,r}^n (0)=|\mathrm{det}(a(g))|_p^r,
\]
where $g=a(g)n(g)k(g)$ with $k(g)\in K$, $a(g)\in M$ and $n(g)\in N$.
\end{corollary}

\begin{proposition}\label{prop:Whittakerfunctionandlocaldensity}
Let $S\in \mathrm{Herm}_m(\mathbb{Q}_p)$  and define
\[S_r=S\oplus \frac{1}{\sqrt{-\Delta}} \left(\begin{array}{cc}
    0 & I_r \\
    -I_r & 0
\end{array}\right).\]
Let $\varphi_p$ the characteristic function of $L^n$ where $L$ is a hermitian $\mathcal{O}_F$-lattice with Gram matrix $S$.
Let $\Phi_p$ be the Siegel-Weil section associated to $\varphi_p$ and $V:=L\otimes \mathbb{Q}$. Then
\[W_{T,p}(r,\Phi_p)=\gamma_p(V)^n |\mathrm{det}(S)|_p^{n} |\Delta|_p^e \alpha_p(S_r,T),\]
where $e=\frac{1}{2} nm+\frac{1}{4}n(n-1)$ and
\begin{equation}\label{gammapV}
    \gamma_p(V)=(-\Delta,\mathrm{det}(V_p))_p \gamma_p(\Delta,\psi_{p,\frac{1}{2}})^m \gamma_p(-1,\psi_{p,\frac{1}{2}})^{-m}.
\end{equation}
Here $(,)_p$ is the local Hilbert symbol and $\gamma_p(a,\psi_{p,\frac{1}{2}}) $ is the Weil index with respect to the additive character $\psi_{p,\frac{1}{2}}$ given by $\psi_{p,\frac{1}{2}}(x)=\psi_p(\frac{1}{2}x)$, see for example \cite{Kudlasplitting} and \cite[Chapter I.4]{kudla1996notes}.
\end{proposition}
\begin{remark}
Over ${\bf k}_p$ for an odd prime $p$ inert in ${\bf k}$, we know that
\[\frac{1}{\sqrt{-\Delta}} \left(\begin{array}{cc}
    0 & I_r \\
    -I_r & 0
\end{array}\right)\sim
 \left(\begin{array}{cc}
    0 & I_r \\
    I_r & 0
\end{array}\right).\]
The latter Gram matrix is used in \cite[Proposition 10.1]{KR2}.  However their calculation does not apply to the case when $p$ is ramified in ${\bf k}$.
\end{remark}
\begin{proof}
Define $V_p^{[r]}=V\oplus V_{r,r}$ and
\[\varphi_p^{[r]}=\varphi_p\otimes\varphi_{r,r}^n\in \mathcal{S}((V_p^{[r]})^n).\]
Corollary \ref{interpolationtrick} and \eqref{eq:W_T,v} imply
\begin{align*}
    W_{T,p}(r,\Phi_p)=\int_{N(F_0)}\psi_p(-\mathrm{Tr}(Tb))\gamma_p(V)^n\int_{(V_p^{[r]})^n} \psi_p(\mathrm{Tr}(b(x,x)))\varphi_p^{[r]}(x)dxdb.
\end{align*}
The proof afterwards is exactly the same as that of \cite[Proposition 10.1]{KR2}.
\end{proof}

\noindent
\textit{Proof of Proposition \ref{W'PhiandWPhi'}}:
By Proposition \ref{prop:Whittakerfunctionandlocaldensity} and \eqref{alpha'andF'}, we have
\[W'_{T,p}(0,\Phi_p)=2\gamma_p(V_p)^2 p^{-\frac{5}{2}}\alpha'(S,T)  \log p .\]
Now (1) follows from the fact that $\alpha'(S,T)=\frac{1}{2}\alpha(S,S)\mu_p(T)$, see the proof of Theorem \ref{thm:maintheorem2}.
Again by Proposition \ref{prop:Whittakerfunctionandlocaldensity},
\[W_{T,p}(0,\Phi'_p)=\gamma_p(V'_p)^2 p^{-\frac{5}{2}} \alpha_p(S',T).\]
Notice that $\gamma_p(V'_p)=-\gamma_p(V_p)$. Then (2) follows from equation \eqref{alphaS'S'}.
\qedsymbol

redpajama_set_name: RedPajamaArXiv