text:
\section{Introduction}

\subsection{Statement of results} The first goal of this paper is to study the cohomology of certain Shimura varieties with infinite level at $p$ and prove a vanishing theorem for their compactly supported cohomology above the middle degree. The second goal of this paper is to give an application to Galois representations for torsion in the cohomology of locally symmetric spaces.

The first question is motivated by a deep conjecture of Calegari--Emerton on the completed (co)homology of general locally symmetric spaces~\cite[Conjecture 1.5]{calegari-emerton}, which in the case of tori is equivalent to the Leopoldt conjecture, cf.~\cite{hill}. This conjecture is motivated by the Langlands reciprocity conjecture and is expected to play an important role in the development of the classical and $p$-adic Langlands programs; see for example~\cite{emerton-icm} and~\cite{gee-newton}. When the locally symmetric spaces do not admit an algebraic structure, the Calegari--Emerton conjecture seems out of reach at the moment, outside the case of low-dimensional examples such as arithmetic hyperbolic $3$-manifolds. For Shimura varieties of Hodge type, Scholze~\cite{scholze-galois} recently made significant progress towards the Calegari--Emerton conjectures.

Let $(G,X)$ be a Shimura datum of Hodge type.\footnote{To avoid complications in the introduction, we allow the non-standard setup of \cite[\S 4]{scholze-galois} as well as the usual setup, and will not make any explicit distinction between Shimura data and connected Shimura data.}
Let $K^p\subset G(\AA^p_f)$ be a sufficiently small compact open subgroup which we fix; this will denote the tame level and we drop it from the notation for simplicity. Choose an integral model of $G$ over ${\mathbb Z}_p$. For $m\in {\mathbb Z}_{\geq 1}$, let
\[
\Gamma(p^m)\colonequals \left\{\gamma\in G({\mathbb Z}_p)\mid \gamma\equiv \mathrm{Id}\mod{p^m}\right\}%
\]
and let $X_{\Gamma(p^m)}$ denote the corresponding Shimura variety of tame level $K^p$ and level $\Gamma(p^m)$ at $p$. Below, we consider this Shimura variety as a complex analytic space of dimension $d$ and we let $H^i_c$ denote the compactly supported singular cohomology.

\begin{thm}[Corollary 4.2.2 of~\cite{scholze-galois}]\label{scholze's thm} Let $r\in {\mathbb Z}_{\geq 1}$. If $i>d$, then
\[
\varinjlim_{m} H^i_c(X_{\Gamma(p^m)}, {\mathbb Z}/p^r{\mathbb Z}) = 0.
\]
\end{thm}

\noindent See~\cite[Cor. 4.2.3]{scholze-galois} for the direct connection to the Calegari--Emerton conjecture, which is phrased in terms of completed homology and completed Borel--Moore homology. We explain this further in \S~\ref{strategy}; for now, let us mention that Scholze's theory of perfectoid spaces and his $p$-adic Hodge theory for rigid analytic varieties both play a crucial role in the proof of Theorem~\ref{scholze's thm}.

In this paper, we prove a stronger version of Scholze's result, in the particular case of $\mathrm{U}(n,n)$- and $\mathrm{Sp}_{2n}$-Shimura varieties. More precisely, let $F$ be a CM field in which the prime $p$ splits completely. Let $G/{\mathbb Q}$ be either a quasi-split unitary group of rank $2n$ defined with respect to the extension $F/F^+$, when $F$ is an imaginary CM field with totally real subfield $F^+$, or $G=\mathrm{Res}_{F/{\mathbb Q}}\mathrm{Sp}_{2n}$, when $F$ is a totally real field. We let $K^p\subset G(\AA^p_f)$ be a sufficiently small compact open subgroup.
After the choice of an integral model of $G$, we also consider a compact open subgroup $K_p\subseteq G({\mathbb Z}_p)$ and higher levels of the form
\[
\Gamma_1(p^m)\colonequals \left\{\gamma=(\gamma_{\mathfrak{p}})_{\mathfrak{p}}\in G({\mathbb Z}_p)\mid \gamma_{\mathfrak{p}}\equiv \left(\begin{array}{cc} I_n  & * \\ 0 & I_n \end{array}\right)\pmod{p^m}\right\}
\]
for $m\in {\mathbb Z}_{\geq 1}$, where $\mathfrak{p}$ runs through primes of $F$ above $p$ induced by a fixed CM type $\Psi$ of $F$ when $F$ is imaginary CM, and all primes of $F$ above $p$ when $F$ is totally real. Let $X_{K_p\cap\Gamma_1(p^m)}$ be the Shimura variety for $G$ with tame level $K^p$ and level $K_p\cap\Gamma_1(p^m)$ at $p$. We prove the following result.

\begin{thm}[Corollary~\ref{main cor} when $F$ is imaginary CM and Corollary~\ref{main cor - siegel} when $F$ is totally real]\label{unified main theorem} Let $r\in{\mathbb Z}_{\geq 1}$ and let $K_{p} \subseteq G(\Z_p)$ be an open compact subgroup. If $i>d$, then
\[
\varinjlim_{m} H^i_c(X_{K_{p} \cap \Gamma_1(p^m)}, {\mathbb Z}/p^r{\mathbb Z}) = 0.
\]
\end{thm}

\noindent We note that this can be used to recover Scholze's result at level $\Gamma(p^\infty)$, by taking a limit over the levels $K_p$. On the other hand, by going down to level $\Gamma_1(p^\infty)$, our result goes beyond what Calegari--Emerton have conjectured.

\begin{remark} The question of vanishing of cohomology of Shimura varieties at \emph{finite level} has been studied extensively recently, motivated in part by the Calegari--Geraghty program for proving modularity beyond the Taylor--Wiles setting~\cite{calegari-geraghty}. At finite level, results have been obtained, among other works, in~\cite{lan-suh, lan-suh2, boyer, caraiani-scholze}. These are all under various assumptions and, except for~\cite{lan-suh2}, deal with compact Shimura varieties.

For $\mathrm{U}(n,n)$-Shimura varieties, which are non-compact, the strongest result we expect is joint work in progress of one of us (A.C.) with Scholze~\cite{caraiani-scholze2}. There, we prove a vanishing result for compactly supported cohomology at finite level, after localizing at a system of Hecke eigenvalues that is sufficiently generic in a precise sense and that also satisfies a version of a non-Eisenstein condition. (We also need to assume for technical reasons that $F$ is not an imaginary quadratic field.) The genericity we impose is a representation-theoretic condition, which can be thought of as a mod $p$ analogue of temperedness, and the method of proof is completely different from that of Theorem~\ref{unified main theorem}. Unlike at level $\Gamma_1(p^\infty)$, we do not expect the result at finite level to hold true without some kind of non-degeneracy assumption on the system of Hecke eigenvalues. Moreover, proving the analogue of the main result of~\cite{caraiani-scholze2} for $\mathrm{Sp}_{2n}$-Shimura varieties would require substantially more work involving the trace formula, as would the unitary case when $F$ is an imaginary quadratic field.
\end{remark}

\begin{remark}
We expect the argument presented in this paper to naturally go through for Hodge type Shimura varieties at primes where the group is \emph{split}, and also in some other cases (e.g. for Harris--Taylor Shimura varieties at primes which are split in the imaginary quadratic field). However, some assumption on the prime $p$ appears to be necessary for our current argument to work --- see Remark~\ref{explanation for p split} for more details. We intend to leave the question of generalizing Theorem~\ref{unified main theorem} (in particular, removing the assumption on $p$) for future work.
\end{remark}

As mentioned above, we also give an application of Theorem~\ref{unified main theorem}. More precisely, we use the result to eliminate the nilpotent ideal in the construction of Galois representations associated to torsion in the cohomology of locally symmetric spaces for $\GL_n/F$, due to~\cite{scholze-galois} and refined by~\cite{newton-thorne}. We explain this further below; we do not define all the notions here, but they are made precise in Section~\ref{Borel-Serre}.

Set $M\colonequals \mathrm{Res}_{F/{\mathbb Q}}\GL_n$. For a sufficiently small compact open subgroup $K_M\subset M(\AA_f)$, let $X^{M}_{K_M}$ be the corresponding locally symmetric space for $M$. Let $S$ be a finite set of primes of ${\mathbb Q}$, containing $p$ as well as all the bad primes. We consider the abstract spherical Hecke algebra $\mathbb{T}^S_M$ away from $S$. It acts in the usual way on $H^*(X^M_{K_M}, {\mathbb Z}_p)$ and gives rise to the Hecke algebra
\[
\mathbb{T}^S_M(K_M)\colonequals \mathrm{Im}\left(\mathbb{T}^S_M\to \mathrm{End}_{{\mathbb Z}_p}\left(H^*(X^{M}_{K_M},{\mathbb Z}_p)\right)\right).
\]
Let $\mathfrak{m}\subset \mathbb{T}^S_M(K_M)$ be a maximal ideal. We have the following result due to Scholze.

\begin{thm} There exists a unique continuous semisimple Galois representation
\[
\bar{\rho}_{\mathfrak{m}}\colon\mathrm{Gal}(\overline{F}/F)\to \GL_n(\overline{{\mathbb F}}_p)
\]
such that, for every prime $w$ of $F$ above a rational prime $l\not\in S$,
the characteristic polynomial of $\bar{\rho}_{\mathfrak{m}}(\mathrm{Frob}_{w})$ is determined, in a precise way,
by the Hecke eigenvalues of $\mathfrak{m}$ at $w$.
\end{thm}

We continue to assume that $p$ splits completely in $F$ and also assume that $\bar{\rho}_{\mathfrak{m}}$ is absolutely irreducible. We
replace $H^*(X^{M}_{K_M}, {\mathbb Z}_p)$ by the complex $R\Gamma(X^M_{K_M}, {\mathbb Z}_p)$, which naturally lives in the
derived category $D({\mathbb Z}_p)$ of ${\mathbb Z}_p$-modules. Its cohomology recovers $H^*(X^{M}_{K_M}, {\mathbb Z}_p)$ and the
action of $\mathbb{T}^S_M$ on $H^*(X^{M}_{K_M}, {\mathbb Z}_p)$ lifts to an action on $R\Gamma(X^M_{K_M}, {\mathbb Z}_p)$.
We consider the Hecke algebra
\[
\mathbb{T}^S_M(K_M)^{\mathrm{der}}\colonequals \mathrm{Im}\left(\mathbb{T}^S_M\to \mathrm{End}_{D({\mathbb Z}_p)}\left(R\Gamma(X^M_{K_M}, {\mathbb Z}_p)\right)\right).
\]
This surjects onto $\mathbb{T}^S_M(K_M)$ with kernel a nilpotent ideal. We localize $\mathbb{T}^S_M(K_M)^{\mathrm{der}}$ at $\mathfrak{m}$.
Using Theorem~\ref{unified main theorem}, we prove the following.

\begin{thm}[Rough statement of Theorem~\ref{eliminating nilpotent ideal}]\label{intro: nilpotent ideal} There exists a unique continuous Galois representation
\[
\rho_{\mathfrak{m}}\colon\mathrm{Gal}(\overline{F}/F)\to \GL_n(\mathbb{T}^S_M(K_M)^{\mathrm{der}}_{\mathfrak{m}})
\]
such that, for every prime $w$ of $F$ above a rational prime $l\not\in S$,
the characteristic polynomial of $\rho_{\mathfrak{m}}(\mathrm{Frob}_{w})$ is determined, in a precise way,
by the spherical Hecke operators in $\mathbb{T}^S_M(K_M)^{\mathrm{der}}_{\mathfrak{m}}$ at $w$.
\end{thm}

\begin{remark}\leavevmode
\begin{enumerate}
\item Up to a nilpotent ideal $I\subset \mathbb{T}^S_M(K_M)^{\mathrm{der}}_{\mathfrak{m}}$ of nilpotence degree $4$, this is proved in Theorem 1.3 of~\cite{newton-thorne} (see also Corollary 5.4.4 of~\cite{scholze-galois}). We eliminate the nilpotent ideal $I$ and thus prove a more natural statement about the existence of Galois representations.
\item For simplicity, we have chosen to state this result with trivial ${\mathbb Z}_p$-coefficients in the introduction. However, in Theorem~\ref{eliminating nilpotent ideal}
we also allow twisted coefficients corresponding to an irreducible algebraic representation of $M$.
\item Under the assumption that $p$ splits completely in $F$, this finishes the proof of the first part of Conjecture B of~\cite{calegari-geraghty}. The nilpotent ideal does not usually cause problems for applications of Conjecture B to automorphy lifting theorems, since the key point there is to determine the support of a certain patched module and nilpotents do not affect the support. However, eliminating the nilpotent ideal is important for some more subtle questions, such as those concerning Bloch--Kato conjectures for automorphic motives, cf.~\cite{cgh}, or local-global compatibility for the $p$-adic local Langlands correspondence, cf.~\cite{gee-newton}. These potential applications would also need local-global compatibility at $p$ for the Galois representations $\rho_{\mathfrak{m}}$, which is still open.
\end{enumerate}
\end{remark}

To deduce Theorem~\ref{intro: nilpotent ideal} from Theorem~\ref{unified main theorem}, we use a detailed study of the boundary of the Borel--Serre compactification of the locally symmetric spaces for $G$ (in particular the strata relevant to the Levi subgroup $M$) and the derived Hecke algebra introduced in~\cite{newton-thorne}. For a compact open subgroup $K\subset G(\AA_f)$, we denote by $X^G_K$ the corresponding locally symmetric space for $G$, with Borel--Serre compactification $X^{G,\mathrm{BS}}_K$ and boundary $\partial X^{G,\mathrm{BS}}_K$. After the work of Newton--Thorne, the unique source of nilpotence was the ambiguity coming from excision long exact sequence used in the construction of the Galois representation $\rho_{\mathfrak{m}}$:
\[
\dotsb \to H^i(X^G_K,{\mathbb Z}/p^r{\mathbb Z})\to H^i(\partial X^{G,\mathrm{BS}}_K,{\mathbb Z}/p^r{\mathbb Z})\to H^{i+1}_c(X^G_K,{\mathbb Z}/p^r{\mathbb Z})\to \dotsb.
\]
(Recall that this long exact sequence is the excision sequence attached to the decomposition
\[
X^{G,\mathrm{BS}}_K=X^G_K\sqcup \partial X^{G,\mathrm{BS}}_K,
\]
where we have also used the fact that the open immersion $X^G_K\hookrightarrow X^{G,\mathrm{BS}}_K$ is a homotopy equivalence.) By showing vanishing of compactly supported cohomology above the middle degree, we eliminate this ambiguity, at least for the cohomology of the boundary above the middle degree.

We emphasize that we genuinely need to use Theorem~\ref{unified main theorem} for this argument, and we could not have made use of Theorem~\ref{scholze's thm} instead. Very roughly speaking, we want to realize the completed cohomology on the side of the locally symmetric spaces for $M$ as a direct summand in the boundary cohomology of the Borel--Serre compactification at some infinite level (for $G$), above the middle degree (so that we can make use of the vanishing result to eliminate the ambiguity mentioned above). At level $\Gamma(p^{\infty})$, this is not possible as the cohomology of the relevant part of the boundary vanishes above the middle degree. However, it is possible to do this at level $\Gamma_{1}(p^{\infty})$ (up to a twist); this is the content of Theorem \ref{direct summand}.

We remark that splitting off the cohomology of the locally symmetric space for $M$ from the cohomology of the boundary of the Borel--Serre compactification is significantly more subtle at level $\Gamma_1(p^\infty)$ than at finite level. To prove Theorem \ref{direct summand} we introduce a new idea, namely we apply an ordinary projector in the sense of Hida theory. This is inspired by arguments with ordinary parts developed in the upcoming paper~\cite{accghlnstt}.

\subsection{Strategy}\label{strategy} We now give a short sketch of the proof of Theorem~\ref{unified main theorem}. In fact, we think it might be helpful to the reader to first explain (a modified version of) the proof of Theorem~\ref{scholze's thm}. The perfectoid Shimura variety, minimally compactified, admits a Hodge--Tate period morphism
\[
\pi_{\mathrm{HT}}\colon ({\mathcal X}^*_{\Gamma(p^\infty)})_{\mathrm{\acute{e}t}}\to |\mathscr{F}\!\ell_{G,\mu}|,
\]
where $|\mathscr{F}\!\ell_{G,\mu}|$ is the topological space underlying a certain flag variety of dimension $d$ and we think of $\pi_{\mathrm{HT}}$ as a morphism of sites. The Hodge--Tate period morphism has the property that $\mathscr{F}\!\ell_{G,\mu}$ has an affinoid cover such that the preimage under $\pi_{\mathrm{HT}}$ of every member of the cover is an affinoid perfectoid space, with strongly Zariski closed boundary. This implies that the fibers of $\pi_{\mathrm{HT}}$ over points of rank $1$ (a condition that can be formulated on the level of the topological space) are affinoid perfectoid spaces with strongly Zariski closed boundary. To prove Theorem~\ref{scholze's thm}, it is enough to show that
\[
H^i_{\mathrm{\acute{e}t}}({\mathcal X}^*_{\Gamma(p^\infty)}, j_{!}{\mathbb F}_p)=0\ \mathrm{for}\ i>d,
\]
where $j\colon{\mathcal X}_{\Gamma(p^\infty)}\hookrightarrow {\mathcal X}^*_{\Gamma(p^\infty)}$ is the open immersion. The primitive comparison theorem in $p$-adic Hodge theory (in the form \cite[Theorem 3.13]{scholze-survey}; see also \cite[\S 3, Theorem 8]{faltings}) reduces us to proving that
\[
H^i_{\mathrm{\acute{e}t}}\left({\mathcal X}^*_{\Gamma(p^\infty)}, j_{!}({\mathcal O}^+/p)^a\right)=0\ \mathrm{for}\ i>d.
\]
We can compute the latter cohomology groups using the Leray spectral sequence for $\pi_{\mathrm{HT}}$. Using the fact that the cohomological dimension of the topological space $|\mathscr{F}\!\ell_{G,\mu}|$ is bounded by $d$ (which follows from a theorem of Scheiderer), we see that it is enough to prove for every point $x\in \mathscr{F}\!\ell_{G,\mu}$ that
\[
R^i\pi_{\mathrm{HT},*}j_{!}({\mathcal O}^+/p)^a_x=0\ \mathrm{for}\ i>0.
\]
We reduce to the case of points of rank $1$, where we use the fact that the fibers of $\pi_{\mathrm{HT}}$ are affinoid perfectoid spaces with strongly Zariski closed boundary. In this case, we have the desired vanishing for the \'etale cohomology of $j_{!}({\mathcal O}^+/p)^a$ (see Proposition~\ref{strongly Zariski closed vanishing}).

We now explain how to adapt these ideas to prove Theorem~\ref{unified main theorem}, focusing on the case $K_{p}=G(\Z_p)$ (the argument for the general case is identical). We want to use the Leray spectral sequence for the Hodge--Tate period morphism at level $\Gamma_1(p^\infty)$, namely the morphism of sites
\[
\pi_{\mathrm{HT}/N_0}\colon ({\mathcal X}^*_{\Gamma_1(p^\infty)})_{\mathrm{\acute{e}t}}\to |\mathscr{F}\!\ell_{G,\mu}|/N_0,
\]
where $N_0=\cap_{m\geq 0}\Gamma_1(p^m)$ and we take the quotient $|\mathscr{F}\!\ell_{G,\mu}|/N_0$ on the level of topological spaces. The sheaves $R^i\pi_{\mathrm{HT}/N_0,*}j_{!}({\mathcal O}^+/p)^a$ will in general not vanish for $i>0$. This is related to the fact that the Shimura variety ${\mathcal X}^*_{\Gamma_1(p^\infty)}$ is not a perfectoid space; it is best thought of in the category of diamonds. However, we show that $|\mathscr{F}\!\ell_{G,\mu}|/N_0$ admits a stratification by locally closed strata $|\mathscr{F}\!\ell^w_{G,\mu}|/N_0$, induced from the generalized Bruhat stratification of the algebraic flag variety $\Flr_{G,\mu}$ by Schubert cells, such that for every $x\in |\mathscr{F}\!\ell^w_{G,\mu}|/N_0$ we have
\[
R^i\pi_{\mathrm{HT}/N_0,*}j_{!}({\mathcal O}^+/p)^a_x=0\ \mathrm{for}\ i>d-\dim \mathscr{F}\!\ell^w_{G,\mu}.
\]
This is enough to prove the desired vanishing result for compactly supported cohomology.

In order to control the stalks of $R^i\pi_{\mathrm{HT}/N_0,*}j_{!}({\mathcal O}^+/p)^a$ over different Schubert cells, we use crucially that certain open strata in the compactified Shimura variety at intermediate infinite levels are perfectoid. The precise result is Theorem~\ref{general perfectoid stratum}. We prove this theorem by generalizing Scholze's theory of the overconvergent anticanonical tower and combining it with an argument inspired by work of Ludwig~\cite{ludwig}. (A technical detail is that in the course of the proof we replace our connected Shimura varieties with the PEL-type Shimura varieties associated to the corresponding similitude groups. As we are working over a perfectoid field $(C,{\mathcal O}_C)$, the difference is only on the level of connected components.)

\begin{remark}\label{explanation for p split} We explain why we need to impose the condition that $p$ splits completely in $F$. Roughly, the idea is that the geometry of $\mathscr{F}\!\ell_{G,\mu}$ is controlled by the absolute Weyl group of $G_{{\mathbb Q}_p}$, whereas the action of $G({\mathbb Q}_p)$ on $\mathscr{F}\!\ell_{G,\mu}$ only gives us access to the relative Weyl group of $G_{{\mathbb Q}_p}$. This means that, when $G_{{\mathbb Q}_p}$ is not split, there will be in general ``absolute'' Schubert cells in $\mathscr{F}\!\ell_{G,\mu}$ over which we will not have optimal control.

For example, let $F=F^+\cdot F_0$, with $F^+$ real quadratic and $F_0$ imaginary quadratic. Assume that $p$ splits in $F_0$ but stays inert in $F^+$. Consider a $\mathrm{U}(1,1)$-Shimura variety defined with respect to $F/F^+$. Then $\mathscr{F}\!\ell_{G,\mu}$ can be identified with $\mathrm{Res}_{F^+_{p}/{\mathbb Q}_p}\mathbb{P}^{1,\mathrm{ad}}$,
which over $\Spa(C,{\mathcal O}_C)$ gives the product of two copies of $\mathbb{P}^{1,\mathrm{ad}}_{C}$. Inside $\mathscr{F}\!\ell_{G,\mu}$, we have $\mathbb{A}^{1,\mathrm{ad}}_{C}\times \mathbb{A}^{1,\mathrm{ad}}_{C}$, which is the non-canonical locus, and $\{\infty\}\times \{\infty\}$, which is the canonical locus. We can control both of these loci using the methods developed in this paper. However, we also have the absolute Schubert cells $\mathbb{A}^{1,\mathrm{ad}}_{C}\times \{\infty\}$ and $\{\infty\}\times \mathbb{A}^{1,\mathrm{ad}}_{C}$, over which we cannot optimally bound the degrees in which $R\pi_{\mathrm{HT},*}j_{!}({\mathcal O}^+/p)^a$ is supported.

Assume that $F=F^+\cdot F_0$, where $F^+$ is a totally real field of degree $f$. Furthermore, assume that $p$ splits in $F_0$, but has arbitrary behavior in $F^+$. By embedding a $\mathrm{U}(n,n)$-Shimura variety defined with respect to $F/F^+$ into a $\mathrm{U}(nf, nf)$-Shimura variety defined with respect to $F_0/{\mathbb Q}$, we obtain some non-trivial bound such that compactly supported cohomology of the $\mathrm{U}(n,n)$-Shimura variety at level $\Gamma_1(p^\infty)$ vanishes for all degrees higher than this bound. Unfortunately, this bound is usually higher than the middle degree of cohomology. Still, this exercise suggests that Theorem~\ref{unified main theorem} is likely to hold more generally.
\end{remark}

\subsubsection{Organization of the paper}
In Section~\ref{diamonds and cohomology}, we collect some results about diamonds and their cohomology that will play a key role in the rest of the paper. This includes new results that may be independently useful such as a Hochschild--Serre spectral sequence for the compactly supported \'etale cohomology of diamonds (Theorem~\ref{hochschildserre}).
Section~\ref{recollections} is devoted to preliminaries on Shimura varieties. This essentially consists of extending the results of~\cite{scholze-galois} to our PEL-type unitary Shimura varieties. One subtlety is that we need to consider the anticanonical tower at more general levels.
Section~\ref{stratifications} discusses the generalized Bruhat decomposition on the Hodge--Tate period domain and proves that certain open strata in the Shimura variety at intermediate levels already have a perfectoid structure (Theorem~\ref{general perfectoid stratum}).
Section~\ref{vanishing} gives a proof of the main theorem for unitary Shimura varieties. A key geometric input comes from Proposition~\ref{rational neighborhood}, where we study adic spaces equipped with the action of a profinite group and construct invariant rational neighborhoods.
Section~\ref{Siegel case} provides the group-theoretic preliminaries needed to make the argument also go through in the Hilbert--Siegel case and gives a sketch of the proof in this case.
Section~\ref{Borel-Serre} introduces the locally symmetric spaces for $\GL_n/F$ and gives the application to Galois representations using the derived Hecke algebra introduced by Newton--Thorne.

\subsection{Acknowledgements} We are very grateful to Peter Scholze for suggesting the idea for this project and for many useful conversations. We are also very grateful to James Newton for many useful conversations and in particular for providing us with a complete proof of Theorem~\ref{factors through classical} (essentially due to~\cite{newton-thorne}), which is crucial for the arguments in Section~\ref{Borel-Serre}. We also thank Ahmed Abbes, Patrick Allen, David Hansen, Kiran Kedlaya, Judith Ludwig and Jack Thorne for useful comments and/or conversations. We are grateful to Mathilde Gerbelli-Gauthier for her contributions to this project at an initial stage.

This project arose as a continuation of A.C. and C.J.'s project group at the 2017 Arizona Winter School. We thank the organizers of the A.W.S. for the wonderful experience, and we thank Andrea Dotto, Mohammed Zuhair Mullath, Lue Pan, Mafalda Santos, Jun Su and Peng Yu for their participation in the project group. The Winter School was supported by NSF grant DMS-1504537 and by the Clay Mathematics Institute.

\section{Diamonds and cohomology}\label{diamonds and cohomology}

In this section we recall the definition of diamonds and some facts about them and their cohomology from \cite{diamonds}. For set-theoretic considerations we refer to \cite[\S 4]{diamonds}; we choose a cardinal $\kappa$ as in \cite[Lemma 4.1]{diamonds}, which allows us to consider countable inverse limits of rigid spaces over some (fixed) non-archimedean field, and all perfectoid spaces will be tacitly assumed to be $\kappa$-small (\cite[Definition 4.3]{diamonds}). We will make no further mention of set-theoretic considerations. For details and precise definitions of any concept or terminology, we refer to \cite{diamonds}. We will write ``$(K,K^{+})$ is a perfectoid field'' to mean that $K$ is a perfectoid field and $K^{+}$ is an open and bounded \emph{valuation} subring.

\subsection{Generalities}

To start, we define some categories of perfectoid spaces. The category of all perfectoid spaces will be denoted by $\mathrm{Pfd}$ and the full subcategory of all perfectoid spaces in characteristic $p$ will be denoted by $\mathrm{Perf}$. For a fixed perfectoid Huber pair $(R,R^{+})$, let $\mathrm{Pfd}_{(R,R^{+})}$ denote the slice category of $\mathrm{Pfd}$ of perfectoid spaces over $\Spa(R,R^{+})$. If $R^{+}=R^{\circ}$, we will simply write $\mathrm{Pfd}_{R}$. The tilting equivalence allows us to identify $\mathrm{Pfd}_{(R,R^{+})}$ with $\mathrm{Pfd}_{(R^{\flat},R^{\flat +})}$, which is a slice of $\mathrm{Perf}$.

The category $\mathrm{Pfd}$ carries two important Grothendieck topologies, the pro-\'etale topology and the v-topology, defined in \cite[Definition 8.1]{diamonds} (and they induce topologies with the same name on all the other categories defined above). Both topologies are subcanonical, cf.~\cite[Corollary 8.6, Theorem 8.7]{diamonds}, and we will conflate perfectoid spaces and their corresponding representable sheaves. A diamond is, by definition, a sheaf on $\mathrm{Perf}$ for the pro-\'etale topology which can be written as the quotient of a perfectoid space $X$ by a pro-\'etale equivalence relation \cite[Definitions 11.1, 11.2]{diamonds}. Diamonds turn out to be sheaves for the v-topology as well \cite[Proposition 11.9]{diamonds}. Any diamond $X$ has an underlying topological space, denoted by $|X|$. The underlying set of $|X|$ can be described as the set of equivalence classes of maps of diamonds
$$ x \colon \Spa(K,K^{+}) \to X, $$
where $(K,K^{+})$ is a perfectoid field of characteristic $p$, and two maps $x_{i} \colon \Spa(K_{i},K_{i}^{+}) \to X$ ($i=1,2$) are equivalent if there is a third perfectoid field $(K_{3},K^{+}_{3})$ (of characteristic $p$) with \emph{surjections} $f_{i} \colon \Spa(K_{3},K^{+}_{3}) \to \Spa(K_{i},K^{+}_{i})$ such that $x_{1}\circ f_{1} = x_{2} \circ f_{2}$ \cite[Proposition 11.13]{diamonds}.

All diamonds that appear in this paper are \emph{(locally) spatial} \cite[Definition 11.17]{diamonds}. If $X$ is (locally) spatial, then $|X|$ is a (locally) spectral space, and any quasicompact open subset $|U| \subseteq |X|$ defines an open subfunctor $U\subseteq X$, which is a (locally) spatial diamond \cite[Proposition 11.18, 11.19]{diamonds}. Any locally spatial diamond $X$ has an associated \'etale site $X_{\mathrm{\acute{e}t}}$ consisting of maps $Y \to X$ of diamonds which are \'etale (this implies that $Y$ is automatically locally spatial by \cite[Corollary 11.28]{diamonds}); see \cite[Definition 14.1]{diamonds}. Following \cite[Convention 10.2]{diamonds}, we require all \'etale maps to be locally separated. We also remark that fiber products of (locally) spatial diamonds are (locally) spatial \cite[Corollary 11.29]{diamonds}.

\medskip

There is a functor $Y \mapsto Y^{\lozenge}$ from the category of analytic adic spaces over $\Z_p$ to the category of diamonds, defined in \cite[\S 15]{diamonds}. Any $Y^{\lozenge}$ is locally spatial, and it is spatial if and only if $Y$ is qcqs. Moreover, $|Y|=|Y^{\lozenge}|$. Of particular importance to us is that this functor induces an equivalence of \'etale sites $Y_{\mathrm{\acute{e}t}}\cong Y_{\mathrm{\acute{e}t}}^{\lozenge}$ \cite[Lemma 15.6]{diamonds}. In particular, we may compute the \'etale cohomology of rigid analytic varieties and perfectoid spaces using the associated diamonds.

\medskip

Next, we state a general result on inverse limits that we will use many times.

\begin{prop}\label{inverselimit}
Let $(X_{i})_{i\in I}$ be a cofiltered inverse system of (locally) spatial diamonds with qcqs transition maps. Then $X=\varprojlim_{i}X_{i}$ is a (locally) spatial diamond and the natural map $|X| \to \varprojlim_{i}|X_{i}|$ is a homeomorphism.
\end{prop}

\begin{proof}
This is (a special case of) \cite[Lemma 11.22]{diamonds}; we refer to the statement there for precise set-theoretic conditions, which will always be satisfied in the applications in this paper.
\end{proof}

We finish this subsection with some topological considerations. Let $X$ be a spatial diamond and let $S$ be a spectral space. Assume that we have a surjective spectral map $p \colon |X| \to S$. Given $s\in S$, set $\Gen(s)\colonequals \bigcap_{V}V$ where $V$ ranges through the quasicompact opens containing $s$; this is the set of generizations of $s$. We can put a canonical (spatial) diamond structure on $p^{-1}(\Gen(s))$, by defining $p^{-1}(\Gen(s))=\varprojlim_{V}p^{-1}(V)$, where $p^{-1}(V)$ is a spatial diamond as mentioned above, and using Proposition \ref{inverselimit}. Following a common abuse of notation in the theory of adic spaces, we will simply write $p^{-1}(s)$ for $p^{-1}(\Gen(s))$ and refer to it as the (topological) fiber of $p$ at $s$. When $S=\pi_{0}(|X|)$ and $p$ is the canonical projection, this gives a canonical diamond structure on each connected component of $|X|$.

\subsection{Some results on cohomology}

In this subsection we will record some results on the \'etale cohomology of diamonds that we will use in this paper. We start with a result on inverse systems.

\begin{prop}\label{invlimcoh}
Let $X_{i}$, $i\in I$, be a cofiltered inverse system of spatial diamonds with inverse limit $X$. Let $i\in I$ and assume that ${\mathcal F}_{i}$ is an abelian sheaf on $(X_{i})_{\mathrm{\acute{e}t}}$, with pullback ${\mathcal F}_{j}$ to $X_{j}$ for $j\geq i$ and pullback ${\mathcal F}$ to $X$. Then the natural map
$$ \varinjlim_{j\geq i} H_{\mathrm{\acute{e}t}}^{q}(X_{j},{\mathcal F}_{j}) \to H^{q}_{\mathrm{\acute{e}t}}(X,{\mathcal F}) $$
is an isomorphism for all $q$.
\end{prop}

\begin{proof}
This is \cite[Proposition 14.9]{diamonds}.
\end{proof}

Next, we give a generalization of a base change property \cite[Lemma 4.4.1]{caraiani-scholze} to the setting of diamonds. To state it, we first discuss ``geometric points'' on $X_{\mathrm{\acute{e}t}}$, for $X$ a locally spatial diamond. This discussion is local, so we may assume that $X$ is spatial. For any $x\in |X|$, consider the cofiltered category $I_{x}$ of maps $f \colon U \to X$ which are composites of quasicompact open immersions and finite \'etale maps and which satisfy $x\in |f(U)|$ (note that this condition is stable under fiber products over $X$, using \cite[Proposition 12.10]{diamonds} to verify the last condition).
We may form the inverse limit
$$ \overline{x} = \varprojlim_{(U \to X) \in I_{x}} U; $$
this is a spatial diamond by Proposition \ref{inverselimit}. We call it the \emph{geometric point} above $x$.

\begin{lemma}\label{geometricpt}
We have $\overline{x}=\Spa(C,C^{+})$ for some algebraically closed perfectoid field $(C,C^{+})$, and the image of the natural map $\pi \colon \overline{x} \to X$ contains $x$.
\end{lemma}

\begin{proof}
We begin with the last assertion; we claim that $\pi(|\overline{x}|)=\{y\in |X| \mid y\in |f(U)|\,\, \forall\,(f\colon U \to X) \in I_{x}\}=\Gen(x)$. The second equality follows since \'etale maps are open and $I_{x}$ contains all open neighborhoods of $x$. For the first, note that all $|f| \colon |U| \to |X|$ are spectral maps of spectral spaces, so we may use the constructible topology. Since the inclusion $\subseteq$ is clear, it remains to prove the opposite inclusion, which amounts to showing that $\varprojlim_{f \in I_{x}} |f|^{-1}(y)$ is non-empty as long as all $|f|^{-1}(y)$ are non-empty. The $|f|^{-1}(y)$ are compact Hausdorff spaces, so this is true.

\medskip

We now prove the first part. We have shown that $\overline{x}\neq \emptyset$, so by \cite[Propositions 7.16, 11.26]{diamonds} it suffices to show that $\overline{x}$ is connected and that every surjective \'etale map $Y \to \overline{x}$ which can be written as a composite of quasicompact open immersions and finite \'etale maps splits. For connectedness, note that if $\overline{x}=V_{1} \sqcup V_{2}$ then this disconnection comes from some disconnection $(f \colon U=U_{1} \sqcup U_{2} \to X) \in I_{x}$. Without loss of generality $x\in |f(U_{1})|$, but then $(U_{1} \to X) \in I_{x}$ and so $V_{2}$, which is the preimage of $U_{2}$, must be empty, so $\overline{x}$ is connected. To see that any $Y \to \overline{x}$ as above splits, we first note that by \cite[Proposition 11.23]{diamonds} it must come via pullback from some $V \to U $, where $(U \to X) \in I_{x}$ and $V \to U$ is the composite of quasicompact open immersions and finite \'etale maps. Since $Y \to \overline{x}$ is surjective, $x$ is in the image of the natural map $|Y| \to |X|$. Since this map factors via $|Y| \to |V|$, this forces $x$ to be in the image of the natural map $|V| \to |X|$ and hence $(V \to X) \in I_{x}$. Since $V \to U$ splits over $V \to U$, this implies that $Y \to \overline{x}$ splits.
\end{proof}

\begin{cor}
Let $X$ be a locally spatial diamond, let $x\in |X|$ and let ${\mathcal F}$ be an \'etale sheaf on $X$. The assignment ${\mathcal F} \mapsto {\mathcal F}_{\overline{x}}=\varinjlim_{(U \to X) \in I_{x}} {\mathcal F} (U)$ defines a topos-theoretic point of $X_{\mathrm{\acute{e}t}}$, and the collection $\{\overline{x} \mid x\in |X| \}$ is a conservative family (i.e. ${\mathcal F} =0$ if and only if ${\mathcal F}_{\overline{x}}=0$ for all $x$).
\end{cor}

\begin{proof}
The morphism $\pi \colon \overline{x} \to X$ is quasi-pro-\'etale and maps the closed point of $|\overline{x}|$ to $x$ (since $|\pi|(|\overline{x}|)=\Gen(x)$ by the proof of Lemma \ref{geometricpt}). The corollary now follows from \cite[Proposition 14.3]{diamonds}.
\end{proof}

We now come to the base change result, generalizing \cite[Lemma 4.4.1]{caraiani-scholze}. The result is a special case of \cite[Corollary 16.10(ii)]{diamonds} (we thank David Hansen for pointing this out to us), but we give the (short and simple) proof as the same argument will used in other places.

\begin{prop}\label{basechange}
Let $f \colon Y \to X$ be a qcqs map of locally spatial diamonds and let $x\in |X|$ with corresponding geometric point $\overline{x}$. Set $Y_{\overline{x}}=Y\times_{X}\overline{x}$ and let ${\mathcal F}$ be an abelian sheaf on $Y_{\mathrm{\acute{e}t}}$. Then the natural map
$$ (R^{i}f_{\mathrm{\acute{e}t},\ast}{\mathcal F})_{\overline{x}} \to H^{i}_{\mathrm{\acute{e}t}}(Y_{\overline{x}},{\mathcal F}) $$
is an isomorphism for all $i$ (here ${\mathcal F}$ also denotes the pullback of ${\mathcal F}$ to $Y_{\overline{x}}$).
\end{prop}

\begin{proof}
Without loss of generality, $X$ is spatial. Since $\overline{x}=\varprojlim_{(U \to X) \in I_{x}}U$ (using the notation above), we have $Y_{\overline{x}} = \varprojlim_{(U \to X) \in I_{x}}f^{-1}(U)$. By Proposition \ref{invlimcoh}, we have
$$ (R^{i}f_{\mathrm{\acute{e}t},\ast}{\mathcal F})_{\overline{x}} = \varinjlim_{(U\to X)\in I_{x}} H^{i}_{\mathrm{\acute{e}t}}(f^{-1}(U),{\mathcal F}) \cong H^{i}_{\mathrm{\acute{e}t}}(Y_{\overline{x}},{\mathcal F}) $$
via the natural map, as desired.
\end{proof}

We will also require a ``topological'' version of the base change result.

\begin{prop}\label{topbasechange}
Let $X$ be a spatial diamond and let $S$ be a spectral space. Assume that there is a spectral map $|f| \colon |X| \to S$; precomposing with the natural morphism of sites $X_{\mathrm{\acute{e}t}} \to |X|$, this gives a morphism of sites $f \colon X_{\mathrm{\acute{e}t}} \to S$. Let $s\in S$ and consider the spatial diamond $f^{-1}(s)$ defined just before this section. If ${\mathcal F}$ is an abelian sheaf on $X_{\mathrm{\acute{e}t}}$, then the natural map
$$ (R^{i}f_{\ast}{\mathcal F})_{s} \to H^{i}_{\mathrm{\acute{e}t}}(f^{-1}(s),{\mathcal F}) $$
is an isomorphism for all $i$.
\end{prop}

\begin{proof}
We write $\Gen(s)=\bigcap_{s\in U}U$ with $U$ quasicompact open and then proceed as in the proof of Proposition \ref{basechange}.
\end{proof}

We now move on to a version of the Hochschild--Serre spectral sequence involving the lower shriek functor. For this, we will need to define the lower shriek functor for open immersions and the notion of $G$-torsors for profinite groups $G$. We start with the lower shriek functor. Since what we need is rather elementary, we give the definitions instead of appealing to the more abstract constructions of \cite{diamonds}, such as e.g.\ \cite[Definition/Proposition 19.1]{diamonds}. Let $j \colon U \to X$ be an \'etale map of locally spatial diamonds. As usual, we may define an extension by zero functor $j_{!}$ from sheaves on $U_{\mathrm{\acute{e}t}}$ to sheaves on $X_{\mathrm{\acute{e}t}}$ by sheafifying the presheaf
$$ \left( V \overset{f}{\to} X \in X_{\mathrm{\acute{e}t}} \right) \mapsto \bigsqcup_{(V \overset{g}{\to} U) \in U_{\mathrm{\acute{e}t}};\,j\circ g=f}{\mathcal F}(V \overset{g}{\to} U). $$
One checks that $j_{!}$ is exact and is a left adjoint to $j^{\ast}$. We record the following base change results.

\begin{lemma}\label{shriekbasechange}
Let $f \colon X^{\prime} \to X$ be a map of spatial diamonds and let $j \colon U \to X$ be an \'etale map with pullback $j^{\prime} \colon U^{\prime} \to X^{\prime}$. Denote the map $ U^{\prime} \to U$ by $g$.
\begin{enumerate}
\item Let ${\mathcal F}$ be an \'etale sheaf on $U$. Then the natural map $j^{\prime}_{!}g^{\ast}{\mathcal F} \to f^{\ast}j_{!}{\mathcal F} $ is an isomorphism.

\item Assume that $j$ is a partially proper open immersion and that $g$ is an isomorphism; we use it to identify $U^{\prime}$ and $U$ and think of $g$ as the identity. Let ${\mathcal G}$ be an abelian sheaf on $U_{\mathrm{\acute{e}t}}$. Then the natural map $j_{!}{\mathcal G} \to Rf_{\ast}j_{!}^{\prime}{\mathcal G}$ is an isomorphism.
\end{enumerate}
\end{lemma}

\begin{proof}
We begin with part (1). It suffices to check this on geometric points of $X^{\prime}$, so let $z\in |X^{\prime}|$ and let $\overline{z}$ be the corresponding geometric point. The assertion then reduces to checking that $(f^{\ast}j_{!}{\mathcal F})_{\overline{z}}=0$ if $\overline{z} \to X^{\prime}$ does not factor through $U^{\prime} \to X^{\prime}$. As usual, one has $(f^{\ast}j_{!}{\mathcal F})_{\overline{z}} \cong (j_{!}{\mathcal F})_{\overline{f(z)}}$.
If $\overline{z}$ does not factor through $U^{\prime} \to X^{\prime}$, then $\overline{f(z)}$ does not factor through $U \to X$, so $(j_{!}{\mathcal F})_{\overline{f(z)}}=0$ and we get the conclusion.

\medskip
We now prove part (2). As above, it suffices to show that $(Rf_{\ast}j^{\prime}_{!}{\mathcal G})_{\overline{x}}=0$ for any $x\in |X|\setminus |U|$. By Proposition \ref{basechange}, we have
$$ (R^{i}f_{\ast}j^{\prime}_{!}{\mathcal G})_{\overline{x}} \cong H^{i}_{\mathrm{\acute{e}t}}(X^{\prime}_{\overline{x}},h^{\ast}j^{\prime}_{!}{\mathcal G}) $$
for all $i$, where $h$ is the map $X^{\prime}_{\overline{x}} \to X^{\prime}$. By part (1), the stalk of $h^{\ast}j^{\prime}_{!}{\mathcal G}$ is $0$ over any geometric point outside $U\times_{X^{\prime}}X^{\prime}_{\overline{x}}$. Since $j$ is partially proper and $x\in |X|\setminus |U|$, $\Gen(x) \cap |U| = \emptyset $ and hence $U\times_{X^{\prime}}X^{\prime}_{\overline{x}} =\emptyset$. Thus, $h^{\ast}j^{\prime}_{!}{\mathcal G}=0$ and the conclusion follows.
\end{proof}

\medskip

Next, we move on to torsors. Let $G$ be a profinite group. Following \cite[Definition 10.12]{diamonds}, we define a v-sheaf $\underline{G}$
$$ X \mapsto \Hom_{cts}(|X|,G) $$
on $\mathrm{Perf}$, and define a (right) $G$-torsor to be a map $f \colon \widetilde{X} \to X$ of locally spatial diamonds with a right action of $\underline{G}$ on $\widetilde{X}$ over $X$ such that the induced map $\widetilde{X}\times \underline{G} \to \widetilde{X} \times_{X}\widetilde{X}$ is an isomorphism (this is equivalent to the definition given in \cite[Definition 10.12]{diamonds} by \cite[Lemma 10.13]{diamonds}). We may now state our Hochschild--Serre spectral sequence; we apologize for the slightly cumbersome setup.

\begin{thm}\label{hochschildserre}
Let $G$ be a profinite group and let $\Sigma$ be a set of open normal subgroups of $G$ which form a basis of neighborhoods of the identity. Assume also that $G\in \Sigma$. We let $(X_{N})_{N\in \Sigma}$ be an inverse system of spatial diamonds and we assume that each $X_{N}$ carries a right action of $\underline{G/N}$, and that these actions are compatible. Set $X=X_{G}$ and $\widetilde{X}=\varprojlim_{N\in \Sigma}X_{N}$.
The spatial diamond $\widetilde{X}$ carries a right $\underline{G}$-action and we assume that the natural map $\pi \colon \widetilde{X} \to X$ is surjective on topological spaces. Assume that there is a partially proper open immersion $j \colon U \to X$ with pullback $j_{N} \colon U_{N} \to X_{N}$ such that $U_{N} \to U$ is a $G/N$-torsor. If $\widetilde{j} \colon \widetilde{U} \to \widetilde{X} $ is the pullback, then $\widetilde{U} \to U$ is a $G$-torsor. Let ${\mathcal F}$ be an abelian sheaf on $U_{\mathrm{\acute{e}t}}$. Then there is a spectral sequence
$$ E_{2}^{rs}=H^{r}_{cts}(G,H^{s}_{\mathrm{\acute{e}t}}(\widetilde{X},\widetilde{j}_{!}{\mathcal F})) \implies H^{r+s}_{\mathrm{\acute{e}t}}(X,j_{!}{\mathcal F}), $$
where $H^{\ast}_{cts}(G,-)$ denotes the continuous group cohomology for $G$, and $H^{\ast}_{\mathrm{\acute{e}t}}(\widetilde{X},\widetilde{j}_{!}{\mathcal F})$ is given the discrete topology.
\end{thm}

\begin{proof}
There will be a lot of abuse of notation in this proof regarding pullbacks and lower shrieks; these cause no mathematical trouble by Lemma \ref{shriekbasechange}(1). We will use \cite[Propositions 14.7, 14.8]{diamonds} repeatedly in this proof, which together imply that \'etale cohomology of locally spatial diamonds may be computed on the v-site. Thus, we have $H_{\mathrm{\acute{e}t}}^{\ast}(X,j_{!}{\mathcal F})=H_{v}^{\ast}(X,j_{!}{\mathcal F})$. The map $\pi$ is a v-cover by \cite[Lemma 12.11]{diamonds} since it is quasicompact and surjective on topological spaces. We therefore have a \v{C}ech-to-derived functor spectral sequence
$$ E_{2}^{rs}=\check{H}^{r}(\mathfrak{U},{\mathcal H}^{s}(j_{!}{\mathcal F})) \implies H^{r+s}_{v}(X,j_{!}{\mathcal F}) $$
where $\mathfrak{U}$ is the v-cover $(\widetilde{X} \to X)$ and ${\mathcal H}^{s}$ denotes the derived functors of the inclusion from v-sheaves to v-presheaves on $\widetilde{X}$. It remains to show that
$$ \check{H}^{r}(\mathfrak{U},{\mathcal H}^{s}(j_{!}{\mathcal F}))=H^{r}_{cts}(G,H_{\mathrm{\acute{e}t}}^{s}(\widetilde{X},\widetilde{j}_{!}{\mathcal F})). $$
The \v{C}ech complex computing the left-hand side is
\[ H_{\mathrm{\acute{e}t}}^{s}(\widetilde{X},\widetilde{j}_{!}{\mathcal F}) \to H_{\mathrm{\acute{e}t}}^{s}(\widetilde{X}\times_{X}\widetilde{X},\widetilde{j}_{!}{\mathcal F}) \to \dotsb \to H_{\mathrm{\acute{e}t}}^{s}((\widetilde{X}_{/X})^{n},\widetilde{j}_{!}{\mathcal F}) \to \dotsb, \label{cech} \tag{$\ast$} \]
where $(\widetilde{X}_{/X})^{n}$ denotes the fiber product $\widetilde{X} \times_{X} \dots \times_{X}\widetilde{X}$ with $n$ factors, and we have equated v-cohomology and \'etale cohomology. There is a morphism
$$ f=(f_{n})_{n\geq 1} \colon (\widetilde{X}\times \underline{G}^{n-1})_{n\geq 1} \to ((\widetilde{X}_{/X})^{n})_{n\geq 1}, $$
$$ f_{n}(x,g_{1},\dots,g_{n-1})=(x,xg_{1},\dots,xg_{n-1}), $$
of simplicial spatial diamonds. Since $\widetilde{U} \to U$ is a $G$-torsor, $f$ restricts to an isomorphism
$$ (\widetilde{U}\times \underline{G}^{n-1})_{n\geq 1} \cong ((\widetilde{U}_{/U})^{n})_{n\geq 1}. $$
By abuse of notation, we also write $\widetilde{j}$ for the open immersions $\widetilde{U}\times\underline{G}^{n-1} \to \widetilde{X} \times \underline{G}^{n-1}$ and the open immersions $(\widetilde{U}_{/U})^{n} \to (\widetilde{X}_{/X})^{n}$. The natural map $\widetilde{j}_{!}{\mathcal F} \to Rf_{n,\ast}\widetilde{j}_{!}{\mathcal F}$ is an isomorphism of \'etale sheaves on $(\widetilde{X}_{/X})^{n}$ by Lemma \ref{shriekbasechange}(2), since the immersion $(\widetilde{U}_{/U})^{n} \to (\widetilde{X}_{/X})^{n}$ is partially proper (this follows from partial properness of $U \to X$ because partial properness is stable under base change). Thus, the complex (\ref{cech}) is equal to
$$ H_{\mathrm{\acute{e}t}}^{s}(\widetilde{X},\widetilde{j}_{!}{\mathcal F}) \to H_{\mathrm{\acute{e}t}}^{s}(\widetilde{X}\times \underline{G},\widetilde{j}_{!}{\mathcal F}) \to \dotsb \to H_{\mathrm{\acute{e}t}}^{s}(\widetilde{X}\times \underline{G}^{n-1},\widetilde{j}_{!}{\mathcal F}) \to \dotsb $$
which in turn is equal to the direct limit over $N\in \Sigma$ of the complexes
$$ H_{\mathrm{\acute{e}t}}^{s}(X_{N},j_{N,!}{\mathcal F}) \to H_{\mathrm{\acute{e}t}}^{s}(X_{N}\times \underline{G/N},j_{N,!}{\mathcal F}) \to \dotsb \to H_{\mathrm{\acute{e}t}}^{s}(X_{N}\times \underline{G/N}^{n-1},j_{N,!}{\mathcal F}) \to \dotsb $$
by Proposition \ref{invlimcoh}. As these complexes compute $H^{\ast}(G/N, H^{s}_{\mathrm{\acute{e}t}}(X_{N},j_{N,!}{\mathcal F}))$, we deduce that $\check{H}^{r}(\mathfrak{U},{\mathcal H}^{s}(j_{!}{\mathcal F}))=H^{r}_{cts}(G,H_{\mathrm{\acute{e}t}}^{s}(\widetilde{X},\widetilde{j}_{!}{\mathcal F}))$, as desired, by taking direct limits.
\end{proof}

We finish this section with some facts about spectral spaces that we will need. First, recall that if $S$ is a spectral space, then it carries a notion of (Krull) dimension $\dim S$, where $1+\dim S$ is defined as the supremum of the lengths of finite chains of specializations.

\begin{lemma}\label{spectral quotient}
Let $S$ be a spectral space with a continuous right action of a profinite group $G$. Then $S/G$ is a spectral space, and the natural map $S \to S/G$ is spectral, open and generalizing. Moreover, if $\dim S$ is finite, then so is $\dim S/G$ and $\dim S = \dim S/G$.
\end{lemma}

\begin{proof}
This is \cite[Lemma 3.2.3]{extensions} (note that openness of the quotient map is automatic for group quotients).
\end{proof}

We will also need the following:

\begin{lemma}\label{homeomorphism onto orbit}
Let $S$ be a spectral space with a continuous right action of a profinite group $G$. Let $s\in S$ be a point with no proper generizations and let $G_{s} \subseteq G$ be the stabilizer of $s$. Then $G_{s}$ is closed and the natural map $G_{s}\backslash G \to S$ given by $G_{s}g \mapsto sg$ is a homeomorphism onto the orbit of $s$ (with the subspace topology).
\end{lemma}

\begin{proof}
The map is continuous and bijective and $G_{s}\backslash G$ is quasicompact, so the orbit is quasicompact and it suffices to show that it is also Hausdorff. Since $G$ acts by homeomorphisms, all $sg$ have no proper generizations. The result now follows since the subspace of points with no proper generizations is Hausdorff. This is presumably well known; the proof goes as follows. By definition, $x\in S$ has no proper generizations if and only if $x=\bigcap_{U\in J_{x}} U$, where $U$ ranges over the set $J_{x}$ of quasicompact opens containing $x$. If $y\neq x$ is another such point, then
$$ \bigcap_{U\in J_{x},V\in J_{y}}U\cap V = \{x\} \cap \{y\} = \emptyset. $$
Since the $U$ and $V$ are closed in the constructible topology (which is compact Hausdorff), we must have $U\cap V=\emptyset$ for some $U\in J_{x}$, $V\in J_{y}$.
\end{proof}

\subsection{Structure sheaves}\label{structure sheaves}

In this section, we fix a perfectoid field $(K,K^{+})$ and a pseudouniformizer $\varpi\in K$ and work with diamonds over $\Spa(K,K^{+})$. Let $X$ be a locally spatial diamond over $(K,K^{+})$. Consider the quasi-pro-\'etale site $X_{\mathrm{qpro\acute{e}t}}$ which consists of all quasi-pro-\'etale maps $Y \to X$ of locally spatial diamonds (see \cite[Definition 10.1]{diamonds})
with the quasi-pro-\'etale topology \cite[Definition 14.1]{diamonds}. By the definition of diamonds, the perfectoid spaces which are quasi-pro-\'etale over $X$ form a basis of $X_{\mathrm{qpro\acute{e}t}}$. Since we are working over $(K,K^{+})$, we think of these as perfectoid spaces over $(K,K^{+})$, using the tilting equivalence. The assignment
$$ Y \mapsto {\mathcal O}_{Y}^{+}(Y) $$
defines a sheaf ${\mathcal O}_{X}^{+}$ (of $K^{+}$-modules) on perfectoid spaces in $X_{\mathrm{qpro\acute{e}t}}$ by \cite[Theorem 8.7]{diamonds} (indeed even for the v-topology). It extends uniquely to a sheaf on $X_{\mathrm{qpro\acute{e}t}}$ which we will denote by ${\mathcal O}_{X}^{+}$. We also get the quotient sheaf ${\mathcal O}_{X}^{+}/\varpi$, which is what we will be interested in. Note that if $f\colon Y \to X$ is a quasi-pro-\'etale morphism of locally spatial diamonds over $(K,K^{+})$, then $f^{\ast}({\mathcal O}^{+}_{X}/\varpi)={\mathcal O}^{+}_{Y}/\varpi$ since $Y_{\mathrm{qpro\acute{e}t}}$ is a slice of $X_{\mathrm{qpro\acute{e}t}}$.

\begin{remark}
We emphasize that the sheaf ${\mathcal O}_{X}^{+}$ depends not only on the diamond $X$, but also on the structure map $X \to \Spa(K,K^{+})$. We have nevertheless chosen not to include $(K,K^{+})$ in the notation, in part to keep it simple, and also because all diamonds (and perfectoid spaces) in this paper will naturally live over a perfectoid field which should be clear from the context. We hope that this does not cause any confusion.
\end{remark}

We thank Peter Scholze for pointing out that the map in the following lemma should be an isomorphism, and not merely an almost isomorphism (the fact that it is an almost isomorphism suffices for the applications in this paper).

\begin{lemma}
Let $X$ be a locally spatial diamond over $(K,K^{+})$. Let $\nu \colon X_{\mathrm{qpro\acute{e}t}} \to X_{\mathrm{\acute{e}t}}$ be the natural morphism of sites. Then the natural map $\nu^{\ast}\nu_{\ast}({\mathcal O}^{+}_{X}/\varpi) \to {\mathcal O}_{X}^{+}/\varpi$ is an isomorphism.
\end{lemma}

\begin{proof}
First, we remark that the category of \'etale sheaves on $X$ embeds fully faithfully into the category of quasi-pro-\'etale sheaves on $X$ by \cite[Proposition 14.8]{diamonds} via $\nu^{\ast}$. Thus, we may rephrase the Lemma as saying that ${\mathcal O}_{X}^{+}/\varpi$ is an \'etale sheaf on $X$. By \cite[Theorem 14.12(ii)]{diamonds}, this may be checked quasi-pro-\'etale locally on $X$ (indeed v-locally), so we may assume that $X$ is a strictly totally disconnected perfectoid space. In this case, quasi-pro-\'etale maps are the same as pro-\'etale maps by definition, and the topos of the site $X_{\mathrm{pro\acute{e}t}}^{\mathrm{aff}}$ of affinoid pro-\'etale maps $Y \to X$ is equivalent to the topos of $X_{\mathrm{qpro\acute{e}t}}$, so we may work on $X_{\mathrm{pro\acute{e}t}}^{\mathrm{aff}}$. So, let $Y=\varprojlim_{i}Y_{i} \to X$ be an affinoid pro-\'etale map with $Y=\Spa(A,A^{+})$, and with $Y_{i}=\Spa(A_{i},A_{i}^{+})$ \'etale over $X$. We need to show that the natural map
$$ f \colon \varinjlim_{i}({\mathcal O}^{+}_{X}/\varpi)(Y_{i}) \to ({\mathcal O}^{+}_{X}/\varpi)(Y) $$
is an isomorphism. Since $X$ is strictly totally disconnected it has no higher \'etale cohomology, so $({\mathcal O}^{+}_{X}/\varpi)(Y_{i}) = A_{i}^{+}/\varpi$ for all $i$. It follows that
$$\nu^{\ast}\nu_{\ast}({\mathcal O}^{+}_{X}/\varpi)(Y) = \varinjlim_{i}({\mathcal O}^{+}_{X}/\varpi)(Y_{i}) = A^{+}/\varpi, $$
so $\nu^{\ast}\nu_{\ast}({\mathcal O}^{+}_{X}/\varpi)$ is equal to the \emph{presheaf} quotient of ${\mathcal O}^{+}_{X}$ by $\varpi$ on $X_{\mathrm{pro\acute{e}t}}^{\mathrm{aff}}$, and the natural map is the natural map from the presheaf quotient to its sheafification. But $\nu^{\ast}\nu_{\ast}({\mathcal O}^{+}_{X}/\varpi)$ is a sheaf on $X_{\mathrm{pro\acute{e}t}}^{\mathrm{aff}}$ by definition, so the natural map is an isomorphism.
\end{proof}

Thus, we may think of ${\mathcal O}_{X}^{+}/\varpi$ as a sheaf on $X_{\mathrm{\acute{e}t}}$. In this paper we will mostly be interested in the corresponding almost sheaf $({\mathcal O}^{+}_{X}/\varpi)^{a}$. We note that, on $X_{\mathrm{qpro\acute{e}t}}$, $({\mathcal O}^{+}_{X}/\varpi)^{a}$ can be described as the almost sheaf given by
$$ \left( \Spa(R,R^{+}) \to X \right) \mapsto (R^{+}/\varpi)^{a} $$
on affinoid perfectoid $\Spa(R,R^{+}) \to X \in X_{\mathrm{qpro\acute{e}t}}$. This follows from \cite[Proposition 8.5(iii)]{diamonds}, since $\Spa(R,R^{+})_{\mathrm{qpro\acute{e}t}}$ and $\Spa(R,R^{+})_{\mathrm{pro\acute{e}t}}$ (defined as in \cite[Definition 8.1(ii)]{diamonds}) define the same topos. We have the following compatibility with the usual ${\mathcal O}_{X}^{+}/\varpi$ on rigid spaces.

\begin{lemma}\label{compatibility of structure sheaves}
Let $Z$ be a rigid space over $(K,{\mathcal O}_{K})$ and consider the usual sheaf ${\mathcal O}_{Z}^{+}/\varpi$ on $Z_{\mathrm{\acute{e}t}}$. Then, under the equivalence $Z_{\mathrm{\acute{e}t}}\cong Z_{\mathrm{\acute{e}t}}^{\lozenge}$, $({\mathcal O}_{Z}^{+}/\varpi)^{a}=({\mathcal O}_{Z^{\lozenge}}^{+}/\varpi)^{a}$.
\end{lemma}

\begin{proof}
By \cite[Corollary 3.17]{scholze-padicHodge} we may compute the values of $({\mathcal O}_{Z}^{+}/\varpi)^{a}$ on the pro-\'etale site $Z_{\mathrm{pro\acute{e}t}}$ as defined in \cite{scholze-padicHodge}; by the equivalence $Z_{\mathrm{\acute{e}t}}\cong Z^{\lozenge}_{\mathrm{\acute{e}t}}$ and Proposition \ref{inverselimit}, $Z_{\mathrm{pro\acute{e}t}}$ is naturally a subcategory of $Z^{\lozenge}_{\mathrm{qpro\acute{e}t}}$, and any cover in $Z_{\mathrm{pro\acute{e}t}}$ is a cover in $Z^{\lozenge}_{\mathrm{qpro\acute{e}t}}$ (but we make no assertion about the converse). By \cite[Lemma 4.10]{scholze-padicHodge}, $({\mathcal O}_{Z}^{+}/\varpi)^{a}(U)=(R^{+}/\varpi)^{a}$ on any affinoid perfectoid $U=\Spa(R,R^{+}) \to Z \in Z_{\mathrm{pro\acute{e}t}}$. Since these form a basis for $Z_{\mathrm{pro\acute{e}t}}$ and are also affinoid perfectoid as elements of $Z^{\lozenge}_{\mathrm{qpro\acute{e}t}}$, the lemma follows from the description of $({\mathcal O}_{Z^{\lozenge}}^{+}/\varpi)^{a}$ given just before this lemma.
\end{proof}

Let $X$ be a locally spatial diamond over $(K,K^{+})$. Since $({\mathcal O}^{+}_{X}/\varpi)^{a}$ on $X_{\mathrm{\acute{e}t}}$ is preserved under pullback by quasi-pro-\'etale maps, it will be convenient for us to record some (perhaps a priori surprising) examples of quasi-pro-\'etale maps.

\begin{prop}\label{finite maps}
Let $f \colon Y \to X$ be a finite map of rigid spaces over $(K,{\mathcal O}_{K})$. Then the associated map $f^{\lozenge} \colon Y^{\lozenge} \to X^{\lozenge}$ of diamonds is quasi-pro-\'etale.
\end{prop}

\begin{proof}
  By \cite[Proposition 13.6]{diamonds}, we need to check that the pullback of $f^\lozenge$ along every $\Spa(C,{\mathcal O}_{C}) \to X^{\lozenge}$, with $(C,{\mathcal O}_{C})$ complete algebraically closed, is pro-\'etale. By definition of $X^{\lozenge}$, such a map corresponds precisely to a map $\Spa(C^{\sharp},{\mathcal O}_{C^{\sharp}}) \to X$ of adic spaces over $(K,{\mathcal O}_{K})$, where $C^{\sharp}$ is the untilt of $C$ over $K$. Since the diamondification functor commutes with fiber products, we are left with checking that if $Z \to \Spa(C^{\sharp},{\mathcal O}_{C^{\sharp}})$ is finite, then $Z^{\lozenge} \to \Spa(C^{\sharp},{\mathcal O}_{C^{\sharp}})$ is pro-\'etale. But, since $Z^{\lozenge}=(Z^\mathrm{red})^{\lozenge}$ (by definition and reducedness of perfectoid rings) and $Z^\mathrm{red}$ is a finite set of copies of $\Spa(C^{\sharp},{\mathcal O}_{C^{\sharp}})$, this is true.
\end{proof}

Note that in the case of closed immersions one can be more explicit; see (the argument in) \cite[Remark 7.9]{diamonds}.

\medskip

For our next result, we use the notion of a \emph{rank one point}, following \cite{extensions}. Let $X$ be a locally spatial diamond (not necessarily over $(K,K^{+})$). By definition (\cite[Definition 3.2.1]{extensions}), $x\in |X|$ is a rank one point if it satisfies any of the following equivalent conditions:
\begin{enumerate}
\item $x$ has no proper generizations in $|X|$;

\item There is a perfectoid field $(L,{\mathcal O}_{L})$ and a map $\Spa(L,{\mathcal O}_{L}) \to X$ with topological image $x$;

\item $x= \bigcap |U|$ where $|U|$ ranges over the quasicompact opens of $|X|$ containing $x$.
\end{enumerate}
Equivalently, one may define the set of rank one points as the image of the ``Berkovich space'' $|X|^{B}$ inside $|X|$; see \cite[Definition 13.7]{diamonds}. We then get the following version of \cite[Lemma 4.4.2]{caraiani-scholze}.

\begin{lemma}\label{rankonepointsisom}
Let $X$ be a locally spatial diamond over $(K,K^{+})$ and let $\iota \colon U \to X$ be a quasicompact open immersion such that $|U|\subseteq |X|$ contains all rank one points of $|X|$. Let $j \colon V \to X$ be a partially proper open immersion; write $j$ also for the immersion $U \cap V \to U$. Then, for any $i$, the natural map
$$ H^{i}_{\mathrm{\acute{e}t}}(X,j_{!}({\mathcal O}^{+}_{V}/\varpi)^{a} ) \to H^{i}_{\mathrm{\acute{e}t}}(U,j_{!}({\mathcal O}^{+}_{U\cap V}/\varpi)^{a}) $$
is an isomorphism.
\end{lemma}

\begin{proof}
It suffices to prove that the adjunction map $j_{!}({\mathcal O}_{V}^{+}/\varpi)^{a} \to R\iota_{\mathrm{\acute{e}t},\ast}j_{!}({\mathcal O}_{U\cap V}^{+}/\varpi)^{a}$ is an isomorphism, which we may check on stalks on geometric points $\overline{x}$ of $X$. By Proposition \ref{basechange} and Lemma \ref{shriekbasechange}, this reduces us to proving the special case of the proposition when $X=\Spa(C,C^{+})$ for some algebraically closed extension $(C,C^{+})$ of $(K,K^{+})$. Since $U$ contains all rank one points of $X$, we must have $U=\Spa(C,C^{++})$ for some open bounded valuation subring $C^{++} \supseteq C^{+}$. Since $j$ is partially proper, we either have $V=X$ or $V=\emptyset$. In the latter case, the lemma is trivial. In the former case, we are left with checking that $C^{+}/\varpi \to C^{++}/\varpi $ is an almost isomorphism (which it is), and that higher cohomology vanishes, which it does since all \'etale covers of $X$ are split.
\end{proof}

\section{Preliminaries on Shimura varieties}
\label{recollections}
The following notation will be used through Section~\ref{vanishing}.
Let $F$ be an imaginary CM field with
totally real subfield $F^+$.
Let $f = [F^+:{\mathbb Q}]$.
Let $c$ be the non-trivial element in $\Gal(F/F^+)$, which
we note corresponds to complex conjugation. Let $p$ be a
rational prime that \emph{splits completely} in $F$.
We fix an algebraically closed and complete extension $C$ of
${\mathbb Q}_p$ with ring of integers $\mathcal{O}_C$; e.g., we may take $C = \CC_p$.
We write $x^{(n)}$ for a list of $n$ copies of an object $x$.
For example, $\diag(1^{(n)}) \in \GL_n({\mathbb C})$ is the identity matrix on ${\mathbb C}^n$.

\subsection{Unitary Shimura varieties}\label{3.1}
\subsubsection{Quasi-split unitary groups}\label{subsect:unitary_group} We define the quasi-split unitary group $G/{\mathbb Q}$
and the corresponding group of unitary similitudes $\widetilde{G}/{\mathbb Q}$.

Fix $\alpha \in F$ with $c(\alpha) = -\alpha$.
For $n \in {\mathbb Z}_{>0}$, let
\[ J_n \colonequals \diag(-\alpha^{(n)},\alpha^{(n)}) \in \GL_{2n}(F). \]
Let $V \colonequals F^{2n}$ be an $F$-vector space of dimension $2n$.
Then $J_n$ determines a non-degenerate, skew-Hermitian pairing
\[
  \psi\colon V \times V \rightarrow {\mathbb Q},\quad \psi(x,y) \colonequals \Tr_{F/{\mathbb Q}}(c(x)^t J_n y);
\]
i.e., $\psi$ is alternating, ${\mathbb Q}$-bilinear, and satisfies
\[
 \psi(ax,y)=\psi(x,c(a)y) \text{ for all $x,y\in V$ and $a\in F$.}
\]
Let $G$ denote the unitary group and $\widetilde{G}$ its
corresponding group of unitary similitudes of the
Hermitian pair $(V, \psi)$, considered as algebraic groups over ${\mathbb Q}$.
Concretely, we define $G$ and $\widetilde{G}$ as subgroup
schemes of $\mathrm{GL}(V)$ by
\begin{IEEEeqnarray*}{rCl}
  G(R) & = & \{ g \in \Aut_{F\otimes_{\mathbb Q} R}(V \otimes_{\mathbb Q} R) \mid \psi(gx,gy)=\psi(x,y) \text{ for all $x,y \in V\otimes_{\mathbb Q} R$} \}  \text{ and} \\
   \widetilde{G}(R) & = & \{ (g,r) \in \Aut_{F\otimes_{{\mathbb Q}}R}( V \otimes_{\mathbb Q} R) \times R^\times \mid \psi(gx,gy)=r \cdot \psi(x,y) \text{ for all $x,y \in V \otimes_{\mathbb Q} R$} \}
\end{IEEEeqnarray*}
for any ${\mathbb Q}$-algebra $R$.  These groups are
related by the short exact sequence
\begin{equation*}
\label{SESunitary}
0\to G\to\widetilde{G}\to\mathbb{G}_m\to 0.
\end{equation*}

The group of real points of $G$ has the expression
\[
G({\mathbb R}) \cong \prod_{\iota \colon F^+ \hookrightarrow {\mathbb R}} \mathrm{U}(n,n) ,
\]
where $\mathrm{U}(n,n)$ is the real unitary group of signature $(n,n)$.

\subsubsection{The Shimura Variety for $\widetilde{G}$}\label{subsubsect:Sh_datum}
We construct the Shimura datum $(\widetilde{G},\widetilde{X})$.
Recall that a CM type of $F$ is a subset
\[ \Psi = \{ \iota_1, \dotsc, \iota_f \} \subset \Hom_{\mathbb Q}(F,{\mathbb C}) \]
such that
\[ \Psi \sqcup \Psi^c = \Hom_{\mathbb Q}(F,{\mathbb C}) \]
where $\Psi^c = \{\iota_1\circ c,\ldots, \iota_f\circ c\}$.
Here we choose $\Psi$ to be the CM type for which $\Im(\iota_k(\alpha)) > 0$ for all $k$.
Then
\[ V \otimes_{\mathbb Q} {\mathbb R} \simeq \prod_{\iota \in \Psi} V \otimes_{F,\iota} {\mathbb C}. \]
For each $\iota \in \Psi$, we can identify $V \otimes_{F,\iota} {\mathbb C} \simeq {\mathbb C}^{2n}$ and thus obtain an ${\mathbb R}$-algebra homomorphism
\begin{IEEEeqnarray*}{RcCc}
  h_{\iota,0} \colon & {\mathbb C} & \rightarrow & \End_{\mathbb R}(V \otimes_{F,\iota} {\mathbb C}) \\
  & z & \mapsto & \diag(z^{(n)},\bar{z}^{(n)}).
\end{IEEEeqnarray*}
The various $h_{\iota,0}$ combine to an ${\mathbb R}$-algebra homomorphism
\[ h_0 \colonequals (h_{\iota_1,0},\dotsc,h_{\iota_f,0}) \colon {\mathbb C} \rightarrow \prod_{\iota \in \Psi} \End_{\mathbb R}(V \otimes_{F,\iota} {\mathbb C}) \subset \End_{\mathbb R} (V \otimes_{\mathbb Q} {\mathbb R}). \]
For all $k = 1,\dotsc,f$ and all $z \in {\mathbb C}$, $\overline{h(z)}^t \cdot \iota_k(J_n) = \iota_k(J_n) \cdot h(\bar{z})$ and $\iota_k(J_n)\cdot h(i) = -\iota_k(\alpha)i\cdot I_{2n}$ is positive definite.
Thus, the tuple $(F,c,V,\psi,h_0)$ is a rational PEL datum of type A.

Upon restricting its domain to ${\mathbb C}^\times$, the morphism $h_0$ induces a homomorphism of real algebraic groups
\[ h\colon \SS \rightarrow \widetilde{G}_{\mathbb R}. \]
Here, $\SS\colonequals\Res_{{\mathbb C}/{\mathbb R}}{\mathbb G}_m$ is the Deligne torus.
We denote the $\widetilde{G}({\mathbb R})$-conjugacy class of $h$ by $\widetilde{X}$ and
observe that $(\widetilde{G},\widetilde{X})$ provides a Shimura datum.

The Hodge cocharacter attached to $h\in \widetilde{X}$ is given by the composition
\[ \mu \colon {\mathbb G}_{m,{\mathbb C}} \xrightarrow{z \mapsto (z,1)} {\mathbb G}_{m,{\mathbb C}} \times {\mathbb G}_{m,{\mathbb C}} \simeq \SS_{\mathbb C} \xrightarrow{h_{\mathbb C}} \widetilde{G}_{\mathbb C}. \]
It will be important in Subsection~\ref{subsubsect:flag_variety} to have an explicit description of $\mu$.
\begin{lem}\label{lem:Hodge_cocharacter}
  The Hodge cocharacter can be identified with the morphism
  \begin{IEEEeqnarray*}{CcCcCl}
    \mu \colon & {\mathbb G}_m & \to & \prod_{\iota\in\Psi}\GL_{2n,{\mathbb C}} & \times & {\mathbb G}_{m,{\mathbb C}} \\
    & z & \mapsto & (( \diag(z^{(n)},1^{(n)}) )_{\iota \in \Psi} &,& z ).
  \end{IEEEeqnarray*}
\end{lem}
\begin{proof}
  The assertion follows from two observations.

  First, note that
  \[ \GL_{2n}(F \otimes_{\mathbb Q} {\mathbb C}) \simeq \prod_{\iota \in \Psi} \(\GL_{2n}(F \otimes_{F,\iota} {\mathbb C}) \times \GL_{2n}(F \otimes_{F,\iota\circ c} {\mathbb C})\). \]
  Under this isomorphism, the involution on $\GL_{2n}(F \otimes_{\mathbb Q} {\mathbb C})$ determined by $c$ is identified with the involution that swaps the factors corresponding to $\iota$ and $\iota \circ c$ for every $\iota \in \Psi$.
  Hence,
  \[ \widetilde{G}_{\mathbb C} \simeq \left\{ (g_1,\dotsc,g_{2n},r) \in \( \prod_{\iota \in \Psi} \GL_{2n,{\mathbb C}} \times \GL_{2n,{\mathbb C}} \) \times {\mathbb G}_{m,{\mathbb C}} \mid g^t_{2k} J_n g_{2k-1} = r \cdot J_n,\, k = 1,\dotsc,n \right\}. \]
  Projection onto the odd factors gives an isomorphism $\widetilde{G}_{\mathbb C} \xrightarrow{\sim} (\prod_{\iota \in \Psi}\GL_{2n,{\mathbb C}}) \times {\mathbb G}_{m,{\mathbb C}}$.

  Second, for each $\iota \in \Psi$ and all $z \in {\mathbb C}$, the pair of matrices $(h_{\iota,0})_{\mathbb C}(z,1) \in \GL_{2n}(F\otimes_{F,\iota}{\mathbb C}) \times \GL_{2n}(F\otimes_{F,\iota\circ c}{\mathbb C})$ is given by
  \begin{IEEEeqnarray*}{+Cl+x*}
    & \(\diag\(\(\tfrac{z+1}{2}+i\tfrac{z-1}{2i}\)^{(n)},\(\tfrac{z+1}{2}-i\tfrac{z-1}{2i}\)^{(n)}\),\diag\(\(\tfrac{z+1}{2}-i\tfrac{z-1}{2i}\)^{(n)},\(\tfrac{z+1}{2}+i\tfrac{z-1}{2i}\)^{(n)}\)\) \\
    = & \( \diag(z^{(n)},1^{(n)}),\diag(1^{(n)},z^{(n)})\). & \qedhere
  \end{IEEEeqnarray*}
\end{proof}

The reflex field of a Shimura datum $(\widetilde{G}, \widetilde{X})$ is
the minimal field of definition of the conjugacy class of the Hodge
cocharacter $\{\mu\}$. In our case, $h$ can be defined over $F$, and
all elements of its $\Gal(F/{\mathbb Q})$-orbit are in the same conjugacy class.
Hence, the reflex field is ${\mathbb Q}$.
As the homomorphisms $h$ are defined to be compatible with the natural complex structure on $V$ coming from the CM field $F$, we have the decomposition
$V_{\mathbb C} = V^{-1,0}\oplus V^{0,-1}$, where $h$ acts on $V^{-1,0}$
and $V^{0,-1}$ by the characters $z$ and $\bar{z}$, respectively. Note that for the specific choice of $h$ above, $V^{-1,0}$ is
already defined over ${\mathbb Q}$.

For a sufficiently small open compact subgroup $\widetilde{K}$ of $\widetilde{G}(\AA_f)$, the double quotient
\[
\widetilde{G}({\mathbb Q}) \backslash \left( \widetilde{X} \times \widetilde{G}(\AA_f) / \widetilde{K} \right)
\]
is a smooth quasi-projective variety over $\CC$ of dimension $n^2 \cdot f$. Its complex points parametrize abelian varieties equipped with extra structures (\emph{p}olarizations, \emph{e}ndomorphisms, and \emph{l}evel structure). The explicit description of the complex points follows by specializing the PEL moduli problem below to $S=\Spec \CC$.

\subsubsection{PEL Moduli Problem for $(\widetilde{G},\widetilde{X})$}
We will now describe a PEL moduli problem.
When the open compact subgroup $\widetilde{K}$ is sufficiently small,
this problem will be representable by a smooth
quasi-projective scheme $X_{\widetilde{K}}$
over ${\mathbb Q}$,
whose ${\mathbb C}$-points $X_{\widetilde{K}}({\mathbb C})$
coincide with
the above described double quotient
$\widetilde{G}({\mathbb Q}) \backslash \widetilde{X} \times \widetilde{G}(\AA_f) / \widetilde{K}$.
\footnote{In our case, since $\dim_F V =2n$ is even, the Hasse principle holds and we get a single copy of the
double quotient \cite[\S 7]{kottwitz-shimura}.}
We will make use of the results of \cite[\S 5-8]{kottwitz-shimura}.

The moduli problem is defined over the category of connected, locally noetherian ${\mathbb Q}$-schemes.
For any such test object $S$, $X_{\widetilde{K}}(S)$ parametrizes equivalence classes of quadruples $(A,\lambda, \iota, \eta \widetilde{K})$, where
\begin{itemize}
 \item $A$ is an abelian scheme over $S$,
 \item $\lambda\colon A \rightarrow A^\vee$ is a polarization of $A$,
 namely, an isogeny inducing a polarization over each geometric fiber,
 \item $\iota\colon F \hookrightarrow \End^0(A) \colonequals \End(A)\otimes_{\mathbb Z} {\mathbb Q}$
       defines an $F$-action on $A$ via quasi-isogenies such that the complex conjugation $c$ is compatible with the Rosati involution given by the polarization $\lambda$,
       i.e., $\lambda \circ \iota(x^c)=\iota(x)^\vee \circ \lambda$ for all $x\in F$, and
 \item For any geometric point $\bar s$ of $S$, $\eta \widetilde{K}$ is a $\pi_1^{\mathrm{\acute{e}t}}(S,\bar s)$-invariant $\widetilde{K}$-orbit of $F \otimes_{\mathbb Q} \AA_f$-isomorphisms
       \[
	\eta\colon V \otimes_{\mathbb Q} \AA_f \stackrel{\sim}{\rightarrow} V_f(A_{\bar{s}})
       \]
       identifying the pairing $\psi \otimes_{\mathbb Q} \AA_f$ with the $\lambda_{\bar{s}}$-Weil pairing up to an $\AA_f^\times$-multiple,
       where $V_f(A_{\bar{s}})$ is the rational adelic Tate module of the geometric fiber $A_{\bar{s}}$ at $\bar s$.
 \end{itemize}

The quadruples $(A, \lambda, \iota, \eta \widetilde{K})$ in
this moduli description are
further required to satisfy Kottwitz's determinant condition, which
in this algebraic case states that
the characteristic polynomials of the $F$-actions over the
${\mathbb Q}$-vector space $V^{-1,0}$ and the $\mathcal{O}_S$-module
$\Lie A$ coincide.

Two quadruples $(A, \lambda, \iota, \eta \widetilde{K})$ and
$(A', \lambda', \iota', \eta' \widetilde{K})$ are equivalent if there is a
quasi-isogeny between $A$ and $A'$ compatible with the
polarizations $\lambda$ and $\lambda'$ up to a ${\mathbb Q}^\times$-multiple.
This isogeny further respects the $F$-actions induced by $\iota$
and $\iota'$, and takes the $\widetilde{K}$-orbit $\eta \widetilde{K}$ to $\eta' \widetilde{K}$.

This moduli problem can be extended to locally noetherian ${\mathbb Q}$-schemes $S$
which are not necessarily connected by taking a disjoint union
over the sets corresponding to the connected components of $S$.

We note that our moduli problem uses a ``definition by isogeny classes''
\cite[\S 1.4.2]{lan-thesis} whereas \cite{scholze-galois} uses a
``definition by isomorphism classes'' \cite[\S 1.4.1]{lan-thesis}.
These two formulations are equivalent, as demonstrated in
\cite[\S 1.4.3]{lan-thesis}.  The equivalence makes it clear that there
is a universal abelian variety living over the Shimura variety
for $(\widetilde{G},\widetilde{X})$.

\subsubsection{The Shimura Variety for $(G,X)$}\label{ShimuraGX}
There is an isomorphism $\widetilde{G}({\mathbb R}) \cong G({\mathbb R}) \times ({\mathbb R}^+)^{\times}$,
where $({\mathbb R}^+)^{\times}$ can be identified with a subgroup of the center of
$\widetilde{G}({\mathbb R})$.
Consequently, $G({\mathbb R})$ acts transitively on $\tilde{X}$.
We define $X = \tilde{X}$.
For a sufficiently small compact open subgroup
$K$ of $G(\AA_f)$, the double quotient
\[
 G({\mathbb Q}) \backslash X \times G(\AA_f) / K
\]
is a complex manifold with a unique structure
of an algebraic variety $X_{K}$ over ${\mathbb C}$ by the theorem of Baily--Borel \cite{baily-borel}.

We can identify $X_{K}({\mathbb C})$ with an open and closed subset of
$X_{\widetilde{K}}({\mathbb C})$.
Using the canonical model $X_{\widetilde{K}}$ over ${\mathbb Q}$,
$X_{K}$ descends to a canonical model over a number field, which depends on $K$.

\subsubsection{Compactifications of Canonical Models}
We will consider the minimal (Satake--Baily--Borel) compactifications of these varieties.
Let $X_{\widetilde{K}}^\ast$ denote the minimal compactification of $X_{\widetilde{K}}$.
Similarly, the superscript $\ast$ will denote the minimal compactification for other Shimura varieties.

\subsubsection{Level subgroups}\label{levels} In this subsection,
we define the level subgroups $\widetilde{\Gamma}_0(p^m)$, $\widetilde{\Gamma}_1(p^m)$,
and $\widetilde{\Gamma}(p^m)$ for any positive integer $m$.

Recall that the $2n$-dimensional $F$-vector space $V$
is equipped with a skew-Hermitian pairing $\psi$ valued in ${\mathbb Q}$.
We fix a choice of an ${\mathcal O}_F \otimes_{{\mathbb Z}} {\mathbb Z}_{(p)}$-lattice $L\subset V$
that is self-dual with respect to $\psi$.
More precisely, $L$ is a free $\mathcal{O}_F\otimes_{\mathbb Z} {\mathbb Z}_{(p)}$-module of rank
$2n$ such that $L\otimes_{\mathbb Z} {\mathbb Q} = V$, and
\[
L=L^\vee \colonequals \{ v\in V \mid \psi(v, \ell)\in {\mathbb Z}_{(p)} \text{ for all $\ell\in L$}\}.
\]
If we choose the parameter $\alpha$ so that $\alpha \otimes 1 \in ({\mathcal O}_F \otimes_{{\mathbb Z}} {\mathbb Z}_{(p)})^{\times}$,
then we can also choose
$L = \mathcal{O}^{2n}_F \otimes_{{\mathbb Z}} {\mathbb Z}_{(p)}$.

We extend $\widetilde{G}$ to be a group scheme over ${\mathbb Z}_{(p)}$ by defining
\[
 \widetilde{G}(R) \colonequals \{ (g, r)\in \Aut_{\mathcal{O}_F \otimes_{{\mathbb Z}_p} R} (L\otimes_{\Z_p} R) \times R^\times
\mid \psi(gx, gy)=r\cdot\psi(x,y) \text{ for all $x,y\in L\otimes_{{\mathbb Z}_p} R$}\}
\]
for any ${\mathbb Z}_{(p)}$-algebra $R$.

We will write $\alpha \cdot \psi$ for the Hermitian form $(x,y) \mapsto \psi(x,\alpha y)$.
The vector space $V$ has a decomposition
\[
V=V^+\oplus V^-
\]
where $\alpha\cdot\psi$ is positive (resp. negative) definite on $V^+$ (resp. $V^-$).
Note that both $V^+$ and $V^-$ are $n$-dimensional $F$-vector spaces.
The lattice $L$ also decomposes as $L^+ \oplus L^-$ accordingly,
where $L^+=L\cap V^+$ and $L^-=L\cap V^-$.
For any $g\in \widetilde{G}({\mathbb Z}_p)$, we denote by $\bar{g}$ the image of $g$ under $\widetilde{G}({\mathbb Z}_p)\rightarrow \widetilde{G}({\mathbb Z}/p^m)$.

Then we can define
\begin{align*}
 \widetilde{\Gamma}_0(p^m) &\colonequals \{g\in \widetilde{G}({\mathbb Z}_p) \mid \text{$\bar{g}$ stabilizes $L^+\otimes{\mathbb Z}/p^m \subset L\otimes{\mathbb Z}/p^m$}\}, \\
\widetilde{\Gamma}_1(p^m) &\colonequals \{g\in \widetilde{G}({\mathbb Z}_p) \mid \text{$\bar{g}$ fixes $L^+\otimes{\mathbb Z}/p^m$ and  $(L/L^+)\otimes{\mathbb Z}/p^m$}\}, \\
\widetilde{\Gamma}(p^m)&\colonequals \{g\in \widetilde{G}({\mathbb Z}_p) \mid \bar{g}=0 \}
 = \ker\left[ \widetilde{G}(\Z_p) \rightarrow \widetilde{G}({\mathbb Z}/p^m) \right].
\end{align*}

More explicitly:
\begin{align*}
\widetilde{G}(\Z_p)&=\left\{(g,r)\in g\in \GL_{2n}(\mathcal{O}_F\otimes_{{\mathbb Z}} {\mathbb Z}_p)\times {\mathbb Z}_p^{\times}\mid c(g)^t J_ n g=rJ_n\right\}\\
  \widetilde{\Gamma}_0(p^m) &\colonequals \left\{(g,r)\in \widetilde{G}({\mathbb Z}_p) \mid g= (g_{\mathfrak{p}})_{\iota_{\mathfrak{p}}\in \Psi}, g_{\mathfrak{p}}\equiv \left(\begin{array}{cc} * & *\\ 0 & * \end{array}\right) \bmod p^m \right\}, \\
  \widetilde{\Gamma}_1(p^m) &\colonequals \left\{(g,r)\in \widetilde{G}({\mathbb Z}_p) \mid g= (g_{\mathfrak{p}})_{\iota_{\mathfrak{p}}\in \Psi}, g_{\mathfrak{p}}\equiv  \left(\begin{array}{cc} I_n  & * \\ 0 & I_n \end{array}\right) \bmod p^m\right\}, \\
  \widetilde{\Gamma}(p^m)&\colonequals \left\{(g,r) \in \widetilde{G}({\mathbb Z}_p) \mid g= (g_{\mathfrak{p}})_{\iota_{\mathfrak{p}}\in \Psi}, g_{\mathfrak{p}}\equiv \left(\begin{array}{cc} I_n & 0 \\ 0 & I_n \end{array}\right) \bmod p^m \right\},
\end{align*}
where $*$ means arbitrary $n\times n$ matrix and $I_n$ is the $n\times n$ identify matrix.

\subsection{The anticanonical tower}\label{subsect: anticanonical tower}
Here we recall Kottwitz's integral
canonical model for the Shimura variety for $\widetilde{G}$
with hyperspecial level~\cite[\S 5]{kottwitz-shimura}.

Fix a level $\widetilde{K}=\widetilde{K}^p\widetilde{K}_p$ where $\widetilde{K}^p\subset \widetilde{G}(\AA_f^p)$
denotes the tame part and $\widetilde{K}_p\subset \widetilde{G}({\mathbb Q}_p)$ is the level at $p$.
As $\widetilde{G}$ is quasi-split and $p$ is unramified in $F$, there
exist hyperspecial levels at $p$.
We will choose the level at $p$, $\widetilde{K}_p$, to be hyperspecial.

The following integral PEL moduli problem is representable
by a smooth quasi-projective scheme over ${\mathbb Z}_{(p)}$
when $\widetilde{K}^p$ is sufficiently small.
We continue to denote this moduli problem by $X_{\widetilde{K}}$,
but note that it is defined over the category of connected
locally noetherian schemes over ${\mathbb Z}_{(p)}$.
For any such test object $S$, $X_K(S)$ parametrizes
equivalence classes of quadruples $(A, \lambda, \iota, \eta \widetilde{K})$, where
\begin{itemize}
 \item $A$ is (up to prime-to-$p$ isogeny) an abelian scheme over $S$,
 \item $\lambda\colon A \rightarrow A^\vee$ is a polarization of $A$; more precisely, a prime-to-$p$ isogeny inducing a polarization over each geometric fiber,
 \item $\iota\colon \mathcal{O}_F\otimes_{\mathbb Z} {\mathbb Z}_{(p)} \hookrightarrow \End(A)\otimes_{\mathbb Z} {\mathbb Z}_{(p)}$ is a homomorphsim of ${\mathbb Z}_{(p)}$-algebras, such that $\lambda \circ \iota(x^c)=\iota(x)^\vee \circ \lambda$ for all $x\in \mathcal{O}_{F, \mathfrak{p}}$, and
 \item For any geometric point $\bar s$ of $S$, $\eta \widetilde{K}$ is a $\pi_1^\mathrm{\acute{e}t}(S,s)$-invariant $\widetilde{K}$-orbit of $F\otimes_{\mathbb Q} \AA_f^p$-isomorphisms
\[
 \eta \colon V \otimes_{\mathbb Q} \AA_f^p \xrightarrow{\sim} V_f^p(A_{\bar{s}}).
\]
identifying the pairing $\psi \otimes_{\mathbb Q} \AA_f^p$ with the $\lambda_{\bar{s}}$-Weil pairing up to an $\AA_f^{p,\times}$-multiple, where $V_f^p(A_{\bar{s}})$ is the rational adelic Tate module of $A_{\bar{s}}$ away from $p$.
\end{itemize}
\noindent The quadruples $(A, \lambda, \iota, \eta \widetilde{K})$ are required to satisfy Kottwitz's determinant condition:
the characteristic polynomials of the $\mathcal{O}_{F, \mathfrak{p}}$-actions over the ${\mathbb Q}$-vector space $V^{-1,0}$ and the $\mathcal{O}_S$-module $\Lie A$ coincide.

Two quadruples $(A, \lambda, \iota, \eta \widetilde{K})$ and
$(A', \lambda', \iota', \eta' \widetilde{K})$ are equivalent if there
is a prime-to-$p$ isogeny between $A$ and $A'$ compatible
with the polarizations $\lambda$ and $\lambda'$ up to a
${\mathbb Z}_{(p)}^\times$-multiple. This isogeny
further respects the $\mathcal{O}_{F, \mathfrak{p}}$-actions
induced by $\iota$, $\iota'$, and takes the $\widetilde{K}$-orbit
$\eta \widetilde{K}$ to $\eta' \widetilde{K}$. This moduli problem
then extends to
the category of locally noetherian schemes as before.

Let $X^\ast_{\widetilde{K}}$ be the minimal compactification
of the integral model $X_{\widetilde{K}}$,
as constructed by Lan~\cite[Chapter 7]{lan-thesis}. This is a projective,
but not necessarily smooth, scheme over $\Spec {\mathbb Z}_p$; its generic fiber is the minimal
compactification of the generic fiber of $X_{\widetilde{K}}$.

There is a Hecke action of $\widetilde{G}(\AA_f)$ on the tower $(X_{\widetilde{K}})_{\widetilde{K}}$
by precomposition $\eta\mapsto \eta\circ g$. We
emphasize that this is a~\emph{right} action. This action extends to the tower of
minimal compactifications $(X^\ast_{\widetilde{K}})_{\widetilde{K}}$.

\subsubsection{Formal and Adic Models}\label{subsubsect:formal_adic_models}
As the tame level $\widetilde{K}^p$ is fixed throughout the paper,
we drop it from our notation. Recall that we have fixed a complete non-archimedean algebraically closed extension $C$ of ${\mathbb Q}_{p}$. Ultimately, we will work over $C$ in this paper, so to keep the notation uniform throughout we will stick to working over $C$ in the remainder of this section, but we remark that we could have chosen to work over any perfectoid extension of $\Q_p^\mathrm{cycl}$, the completion of $\Q_p(\zeta_{p^{\infty}})$.\footnote{We could also work over $\Q_p$, as long as some minor adjustments are made to some of the statements.} For $\widetilde{K}_p\subset \widetilde{G}({\mathbb Q}_p)$ hyperspecial, we denote the ${\mathbb Z}_p$-model of the PEL-type Shimura variety by $X^\ast$ and we
let $\mathfrak{X}^\ast_{{\mathbb Z}_p}$ be the formal completion of $X^\ast$
along its special fiber. This is a formal scheme over $\Spf {\mathbb Z}_p$. We let $\mathfrak{X}^\ast$ denote
the base change of $\mathfrak{X}^\ast_{{\mathbb Z}_p}$ to $\Spf {\mathcal O}_{C}$ and
${\mathcal X}^\ast$ denote the generic fiber of $\mathfrak{X}^\ast$, viewed as an adic space. This is a proper adic space over $\Spa (C,{\mathcal O}_{C})$.

For any higher level $\widetilde{K}_p\subset \widetilde{G}({\mathbb Q}_p)$,
we let ${\mathcal X}^\ast_{\widetilde{K}_p}$ be the adic space corresponding to the base change to $C$ of the ${\mathbb Q}$-scheme $X^\ast_{\widetilde{K}_p}$.%
\footnote{If $Y$ is a scheme locally of finite type over $\Spec\ C$, we take $Y^{\mathrm{ad}}\colonequals Y\times_{C}\Spa\ (C, {\mathcal O}_C)$,
which is an adic space locally of finite type over $\Spa (C, {\mathcal O}_C)$, where the fiber product is in the sense of~\cite[Prop.~3.8]{huber-adic-spaces}.} This agrees
with the previous definition when $\widetilde{K}_p$ is hyperspecial.
We define ${\mathcal X}_{\widetilde{K}_p}$ similarly, as the adic space corresponding to the base change
to $C$ of the ${\mathbb Q}$-scheme $X_{\widetilde{K}_p}$. We remark that the latter is not quasicompact, but it is open in ${\mathcal X}^\ast_{\widetilde{K}_p}$. The closed complement
is the boundary, which we denote by ${\mathcal Z}_{\widetilde{K}_p}$.

We will need the following result. For the analogue for schemes, see~\cite[Cor. 7.2.5.2]{lan-thesis}.

\begin{lemma}\label{adic quotient} For two compact open subgroups $\widetilde{K}'\subset \widetilde{K}$ such that $\widetilde{K}'$ is normal in $\widetilde{K}$,
${\mathcal X}^\ast_{\widetilde{K}}$ can be identified with the quotient of ${\mathcal X}^\ast_{\widetilde{K}'}$ by the finite group $\widetilde{K}/\widetilde{K}'$.
\end{lemma}

\begin{proof}

We adapt
the proof in~\cite[Cor. 7.2.5.2]{lan-thesis} to the corresponding adic spaces.
Note that both ${\mathcal X}^*_{K}$ and ${\mathcal X}^*_{K'}$ are normal, since they are analytifications of normal
algebraic varieties. Note also that on the open part, ${\mathcal X}_{K'}$ is a $(K/K')$-torsor over ${\mathcal X}_K$.
(This holds true for the algebraic varieties, and the analytification functor preserves torsors for finite groups,
as it preserves fiber products.)
The result now follows from Theorem~\ref{bartenwerfer} and Corollary~\ref{abstract adic quotient} below.
\end{proof}

\begin{thm}[Sec.~3,~\cite{bartenwerfer}]\label{bartenwerfer} Let $Y$ be a normal rigid space over $C$, $Z\subset Y$ a
nowhere dense Zariski closed subset, with open complement $U$.
Let $j\colon U\hookrightarrow Y$ be the open immersion.
Then ${\mathcal O}^+_{Y} \xrightarrow{\sim} j_*{\mathcal O}^+_{U}$ and ${\mathcal O}_{Y} \xrightarrow{\sim} (j_*{\mathcal O}^+_{U})[1/p]$.

In particular,
if $Y$ is affinoid and $f\in {\mathcal O}_Y(U)$ is bounded, then $f$ extends uniquely to an element of
${\mathcal O}_Y(Y)$, so ${\mathcal O}_Y(Y)\xrightarrow{\sim} {\mathcal O}^+_Y(U)[1/p]$.
\end{thm}

\begin{cor}\label{abstract adic quotient} Let $f\colon \widetilde{Y}\to Y$ be a finite
morphism of normal rigid analytic spaces. Assume that there exists a finite group $H$ acting on $\widetilde{Y}$,
acting trivially on $Y$, and such that $f$ is $H$-equivariant. Assume that there exists a
Zariski open and dense subset $U\subseteq Y$ such that $\widetilde{U}\colonequals f^{-1}(U)$
is Zariski open and dense in $\widetilde{Y}$ and such that $f$ identifies $U$ with
the quotient $\widetilde{U}/H$. Then $Y=\widetilde{Y}/H$.
\end{cor}

\begin{proof} By finiteness and the construction of quotients by finite groups,
we are reduced to the case when $Y$ is affinoid, and then we need to prove that
${\mathcal O}_Y(Y)={\mathcal O}_{\widetilde{Y}}(\widetilde{Y})^{H}$.
Since $U=\widetilde{U}/H$, ${\mathcal O}_Y(U)=\left({\mathcal O}_{\widetilde{Y}}(\widetilde{U})\right)^{H}$,
and from this it follows that ${\mathcal O}^{bd}_Y(U)=\left({\mathcal O}^{bd}_{\widetilde{Y}}(\widetilde{U})\right)^{H}$,
where ${\mathcal O}^{bd}_Y(U)\colonequals {\mathcal O}^+_Y(U)[1/p]$ denotes the sub-presheaf of bounded functions.
By Theorem~\ref{bartenwerfer}, ${\mathcal O}^{bd}_Y(U)={\mathcal O}_Y(Y)$ and
${\mathcal O}^{bd}_{\widetilde{Y}}(\widetilde{U})={\mathcal O}_{\widetilde{Y}}(\widetilde{Y})$, and the result follows.
\end{proof}

\begin{remark} It is also possible to deduce Lemma~\ref{adic quotient} from the case of schemes, using that the adification functor from schemes to adic spaces preserves quotients by finite groups (this can be checked with a bit of work from the definitions).
\end{remark}

\subsubsection{Notation for ``infinite level'' Shimura varieties}\label{notation for infinite level}
Before proceeding, we will set out the notation for infinite level Shimura varieties. Recall that we have fixed a prime-to-$p$-level $\widetilde{K}^{p}$. Our finite level Shimura varieties ${\mathcal X}_{\widetilde{K}}$ are indexed by the corresponding open subgroups $\widetilde{K}\subseteq \widetilde{G}(\Z_p)$. Our infinite level Shimura varieties will arise as limits of towers $({\mathcal X}_{\widetilde{K}})_{\widetilde{K}}$, where the $\widetilde{K}$ run through a cofiltered inverse system of open subgroups. Thus, the resulting limit (if it exists in a suitable sense) will only depend on the intersection $\widetilde{H}=\bigcap\widetilde{K}$, which is a closed subgroup of $\widetilde{G}(\Z_p)$. It therefore makes sense to make the following general definition:

\begin{defn}
Let $\widetilde{H}\subseteq \widetilde{G}(\Z_p)$ be a closed subgroup. We define a locally spatial diamond ${\mathcal X}_{\widetilde{H}}$ by
$$ {\mathcal X}_{\widetilde{H}} \colonequals \varprojlim_{\widetilde{H}\subseteq \widetilde{K}}{\mathcal X}^{\lozenge}_{\widetilde{K}}, $$
where the limit ranges over the open subgroups $\widetilde{K}$ with $\widetilde{H} \subseteq \widetilde{K} \subseteq \widetilde{G}(\Z_p)$. Note that this exists by Proposition \ref{inverselimit}. We define ${\mathcal X}^{\ast}_{\widetilde{H}}$ similarly; this is a spatial diamond (again by Proposition \ref{inverselimit}).
\end{defn}

We note that we have a natural identification $|{\mathcal X}_{\widetilde{H}}|=\varprojlim_{\widetilde{H} \subseteq \widetilde{K}}|{\mathcal X}_{\widetilde{K}}|$ by Proposition \ref{inverselimit}.

\begin{rem} \leavevmode
\begin{enumerate}
\item When $\widetilde{H} = \widetilde{K}$ is open, we have defined ${\mathcal X}_{\widetilde{K}}\colonequals {\mathcal X}_{\widetilde{K}}^{\lozenge}$. This abuse of notation will be in place throughout this paper. It can be justified by the fact that the diamondification functor is fully faithful on \emph{normal} rigid spaces; see \cite[Proposition 10.2.4]{berkeley-notes} and \cite[Theorem 8.2.3]{kedlaya-liu-2}. Also, it should (hopefully) be clear from the context whether ${\mathcal X}_{\widetilde{K}}$ is regarded as a rigid space or a diamond.

\item If $(X_{i})_{i\in I}$ is an inverse system of rigid spaces with qcqs transition maps, and $X$ is a perfectoid space with $X \sim \varprojlim_{i}X_{i}$ in the sense of \cite[Definition 2.4.1]{scholze-weinstein}, then $X=\varprojlim_{i}X_{i}^{\lozenge}$ as diamonds by \cite[Proposition 2.4.5]{scholze-weinstein}.
\end{enumerate}
\end{rem}

With this definition, we may extend the towers $({\mathcal X}_{\widetilde{K}})_{\widetilde{K}}$ and $({\mathcal X}^{\ast}_{\widetilde{K}})_{\widetilde{K}}$, for open subgroups $\widetilde{K}$, to towers $({\mathcal X}_{\widetilde{H}})_{\widetilde{H}}$ and $({\mathcal X}^{\ast}_{\widetilde{H}})_{\widetilde{H}}$ where we index over all closed subgroups. The right action of $\widetilde{G}(\Q_p)$ on $({\mathcal X}_{\widetilde{K}})_{\widetilde{K}}$ and $({\mathcal X}^{\ast}_{\widetilde{K}})_{\widetilde{K}}$ extends naturally to a right action on $({\mathcal X}_{\widetilde{H}})_{\widetilde{H}}$ and $({\mathcal X}^{\ast}_{\widetilde{H}})_{\widetilde{H}}$, and if $\widetilde{H} \subseteq \widetilde{G}(\Z_p)$ is normal then $\widetilde{G}(\Z_p)/\widetilde{H}$ acts on ${\mathcal X}_{\widetilde{H}}$. Note that, for arbitrary $\widetilde{H}$, if $g\in \widetilde{G}(\Q_p)$ and $\widetilde{H},g^{-1}\widetilde{H} g \subseteq \widetilde{G}(\Z_p)$, then right multiplication of $g$ induces an isomorphism ${\mathcal X}_{\widetilde{H}} \xrightarrow{\sim} {\mathcal X}_{g^{-1}\widetilde{H} g}$ of diamonds.

\medskip

Next, we define some closed subgroups corresponding to the open subgroups defined in subsection \ref{levels}.

\begin{defn} We let $\widetilde{\mathbf{1}}\subseteq \widetilde{G}(\Z_p)$ denote the trivial subgroup, and define
$$ \widetilde{P}_{\mu,0} = \bigcap_{m\geq 0}\widetilde{\Gamma}_{0}(p^{m}),\,\,\,\, \widetilde{N}_{0}=\bigcap_{m\geq 0}\widetilde{\Gamma}_{1}(p^{m}). $$
\end{defn}

We remark that $\widetilde{P}_{\mu,0}=\widetilde{P}_{\mu}(\Z_p)$ for a parabolic $\widetilde{P}_{\mu}$ which will be formally introduced in subsection \ref{hodgetatemapsection};
similarly $\widetilde{N}_{0}=\widetilde{N}(\Z_p)$ where $\widetilde{N}$ is the unipotent radical of $\widetilde{P}_{\mu}$.
Also note that $\widetilde{\mathbf{1}}=\bigcap_{m\geq 0}\widetilde{\Gamma}(p^{m})$.

To finish this subsection, we record two lemmas generalising the corresponding facts for open subgroups to closed subgroups.

\begin{lemma}\label{exhibiting a diamond as a quotient}
Let $\widetilde{H}$ be a closed subgroup of $\widetilde{G}(\Z_p)$. Then $|{\mathcal X}^{\ast}_{\widetilde{H}}|\cong |{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}|/\widetilde{H}$ via the natural map $|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}| \to |{\mathcal X}^{\ast}_{\widetilde{H}}|$ (and similarly for open Shimura varieties).
\end{lemma}

\begin{proof}
We prove the statement on minimal compactifications; the statement for open Shimura varieties can be deduced from this or proved using the same method (it also follows from the next lemma). For each $m\geq 0$, we have $|{\mathcal X}^{\ast}_{\widetilde{H} \widetilde{\Gamma}(p^{m})}|=|{\mathcal X}^{\ast}_{\widetilde{\Gamma}(p^{m})}|/\widetilde{H}$ via the natural map $|{\mathcal X}^{\ast}_{\widetilde{\Gamma}(p^{m})}| \to |{\mathcal X}^{\ast}_{\widetilde{H} \widetilde{\Gamma}(p^{m})}|$ by Lemma \ref{adic quotient}. Taking inverse limits, one obtains $\varprojlim_{m\geq 0}|{\mathcal X}^{\ast}_{\widetilde{H}\widetilde{\Gamma}(p^{m})}|\cong \(\varprojlim_{m\geq 0}|{\mathcal X}^{\ast}_{\widetilde{\Gamma}(p^{m})}|\)/\widetilde{H}$ (using that $\widetilde{H}$ is compact Hausdorff). We are now done, using that $|{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}|=\varprojlim_{m\geq 0}|{\mathcal X}_{\widetilde{\Gamma}(p^{m})}^{\ast}|$ and $|{\mathcal X}^{\ast}_{\widetilde{H}}|=\varprojlim_{m\geq 0}|{\mathcal X}_{\widetilde{H}\widetilde{\Gamma}(p^{m})}^{\ast}|$.
\end{proof}

\begin{lemma}\label{torsor}
Let $\widetilde{H}_{1}\subseteq \widetilde{H}_{2}$ be closed subgroups of $\widetilde{G}(\Z_p)$ and assume that $\widetilde{H}_{1}$ is normal in $\widetilde{H}_{2}$. Then ${\mathcal X}_{\widetilde{H}_{1}} \to {\mathcal X}_{\widetilde{H}_{2}}$ is a $\widetilde{H}_{2}/\widetilde{H}_{1}$-torsor.
\end{lemma}

\begin{proof}
Set $\widetilde{K}_{i,m}=\widetilde{H}_{i}\widetilde{\Gamma}(p^m)$ for $i=1,2$ and $m\geq 0$. Then $\widetilde{K}_{1,m}$ is normal in $\widetilde{K}_{2,m}$ and hence ${\mathcal X}_{\widetilde{K}_{1,m}} \to {\mathcal X}_{\widetilde{K}_{2,m}}$ is a $\widetilde{K}_{2,m}/\widetilde{K}_{1,m}$-torsor compatibly in $m$, i.e.\ we have compatible isomorphisms
$$ {\mathcal X}_{\widetilde{K}_{2,m}} \times \underline{\widetilde{K}_{2,m}/\widetilde{K}_{1,m}} \xrightarrow{\sim} {\mathcal X}_{\widetilde{K}_{1,m}} \times_{{\mathcal X}_{\widetilde{K}_{2,m}}} {\mathcal X}_{\widetilde{K}_{1,m}} $$
(this holds for rigid spaces and follows formally for diamonds, since fiber products are preserved). Taking the inverse limit over $m$ gives us the isomorphism ${\mathcal X}_{\widetilde{H}_{2}} \times \underline{\widetilde{H}_{2}/\widetilde{H}_{1}} \xrightarrow{\sim} {\mathcal X}_{\widetilde{H}_{1}} \times_{{\mathcal X}_{\widetilde{H}_{2}}} {\mathcal X}_{\widetilde{H}_{1}}$, so ${\mathcal X}_{\widetilde{H}_{1}} \to {\mathcal X}_{\widetilde{H}_{2}}$ is a $\widetilde{H}_{2}/\widetilde{H}_{1}$-torsor as desired.
\end{proof}

\subsubsection{The anticanonical tower}\label{sec: anticanonical} In this section, we adapt the construction
of the anticanonical tower over a neighborhood of the ordinary
locus as in~\cite[Sec.~3]{scholze-galois} to the PEL-type Shimura varieties for $\widetilde{G}$ introduced above.

The special fiber of the integral model $X^\ast$ admits a Newton stratification --
see, for example,~\cite[\S 3.3]{lan-stroh}.
For our quasi-split group $\widetilde{G}$, the reflex field is ${\mathbb Q}$, so~\cite[Thm. 1.6.3]{wedhorn-thesis}
(together with~\cite[\S 3.3]{lan-stroh} for the extension to the boundary)
implies that there exists an
open dense ordinary stratum in $X^*_{\overline{\mathbb{F}}_p}$. As usual,
one can also recover the ordinary stratum as the complement of the vanishing locus of
the Hasse invariant $\mathrm{Ha}$. Over $X^\ast$, there is a canonical line bundle which we denote by $\omega$; this extends the line bundle
over $X$ obtained as the top exterior power of the sheaf of invariant differentials on the universal abelian
scheme over $X$. The Hasse invariant $\mathrm{Ha}$ is a section of $\omega_{\overline{\mathbb{F}}_p}^{\otimes (p-1)}$. It can also be defined
over $X_{\overline{\mathbb{F}}_p}$ using the Verschiebung isogeny and extended canonically to the boundary.\footnote{If $n\geq 2$, the
codimension of the boundary in $X^*_{\overline{\mathbb{F}}_p}$ is at least $2$, so one can make use of the Koecher principle.}

\medskip
Note that we have an embedding of Shimura data $(\widetilde{G},\widetilde{X}) \hookrightarrow (\widetilde{G}^{\prime},\widetilde{X}^{\prime})$, where $\widetilde{G}^{\prime}={\rm GSp}_{2n[F:{\mathbb Q}]}$ and $(\widetilde{G}^{\prime},\widetilde{X}^{\prime})$ is the corresponding Siegel Shimura datum; moduli-theoretically this corresponds to forgetting the endomorphisms. We also define $G^{\prime}={\rm Sp}_{2n[F:{\mathbb Q}]}\subseteq \widetilde{G}^{\prime}$. If $\widetilde{K}^{\prime}\subseteq \widetilde{G}^{\prime}(\Z_p)$ is an open subgroup we let $X_{\widetilde{K}^{\prime}}^{\prime}$ etc. denote the corresponding Siegel Shimura variety, for a choice of tame level $\widetilde{K}^{\prime,p}$ that we will only write out when needed. When $\widetilde{K}^{p} \subseteq \widetilde{K}^{\prime,p}$, we have a morphism
$$ X^{\ast}_{\overline{{\mathbb F}}_{p}} \to X^{\prime,\ast}_{\overline{{\mathbb F}}_{p}} $$
extending the morphism that forgets the level structure, and the Hasse invariant $\mathrm{Ha}$ on $X^{\ast}_{\overline{{\mathbb F}}_{p}}$ is the pullback of the Hasse invariant on $X^{\prime,\ast}_{\overline{{\mathbb F}}_{p}}$. In what follows, we fix a lift of the Hasse invariant to the adic generic fiber ${\mathcal X}^{\prime,\ast}$ (base changed to $C$) and pull it back to ${\mathcal X}^{\ast}$.

Our goal in this subsection is to define analogues of the anticanonical tower of Siegel modular varieties from \cite[\S 3]{scholze-galois} for our unitary Shimura varieties and prove certain perfectoidness properties. We first recall the results from \cite[\S 3]{scholze-galois} that we need (partially to set up notation), and prove an additional result that will be crucial for us in this paper (Proposition~\ref{anticanonical tower at intermediate levels Siegel}).

For arbitrary closed subgroups $\widetilde{H}^{\prime}\subseteq \widetilde{G}^{\prime}(\Z_p)$, define a spatial diamond
$$ {\mathcal X}_{\widetilde{H}^{\prime}}^{\prime,\ast} = \varprojlim_{\widetilde{H}^{\prime}\subseteq \widetilde{K}^{\prime}}{\mathcal X}_{\widetilde{K}}^{\prime,\ast,\lozenge}, $$
where the $\widetilde{K}^{\prime}\subseteq \widetilde{G}^{\prime}(\Z_p)$ are open subgroups and similarly for ${\mathcal X}_{\widetilde{H}^{\prime}}^{\prime}$; in short we make all the analogous definition for Siegel Shimura varieties as we did for our unitary Shimura varieties in subsection \ref{notation for infinite level}. Note that Lemmas \ref{exhibiting a diamond as a quotient} and \ref{torsor} hold for Siegel Shimura varieties as well, with the same proofs. We define compact open subgroups $\widetilde{\Gamma}_{?}(p^{m})^{\prime}\subseteq \widetilde{G}^{\prime}(\Z_p)$ for $?\in \{0,1,\emptyset \}$ analogously to the definitions in subsection \ref{levels}. In particular, we have
$$ \widetilde{\Gamma}_{?}(p^{m}) = \widetilde{G}(\Z_p) \cap \widetilde{\Gamma}_{?}(p^{m})^{\prime} $$
for any $m$ and $?\in \{0,1,\emptyset \}$. We let $\widetilde{\mathbf{1}}^{\prime}\subseteq \widetilde{G}^{\prime}(\Z_p)$ denote the trivial subgroup, and define
$$ \widetilde{P}_{\mu,0}^{\prime} = \bigcap_{m\geq 0}\widetilde{\Gamma}_{0}(p^{m})^{\prime},\,\,\,\, \widetilde{N}_{0}^{\prime}=\bigcap_{m\geq 0}\widetilde{\Gamma}_{1}(p^{m})^{\prime}. $$

\medskip
We start by recalling the anticanonical tower in the Siegel case. In this discussion, we will work over $\Q_p$ instead of $C$ until further notice to simplify referencing, so all Siegel Shimura varieties (of finite or infinite level) are considered to be defined over $\Q_p$ until further notice; we will sometimes add a subscript $\Q_p$ when we wish to emphasize this. Let $0\leq \epsilon <1/2$. The anticanonical locus ${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p)^{\prime}}(\epsilon)_{a}$ of level $\widetilde{\Gamma}_{0}(p)^{\prime}$ and radius of overconvergence $\epsilon$ is (essentially) defined in \cite[Theorem 3.2.15(iii)]{scholze-galois}; this is an open subset of ${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p)^{\prime}}$, defined as the image of the map
$$ {\mathcal X}^{\prime,\ast}(\epsilon) \to {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p)^{\prime}}, $$
where ${\mathcal X}^{\prime,\ast}(\epsilon)$ is the locus where $|Ha|\geq p^{\epsilon}$ and the map sends a principally polarized abelian variety $A$ (with tame level structure) to $(A/Can,A[p]/Can)$ (with the induced tame level structure), where $Can \subseteq A[p]$ is the canonical subgroup. For any closed subgroup $\widetilde{H}^{\prime}\subseteq \widetilde{\Gamma}_{0}(p)^{\prime}$, we define
$$  {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_{a} \colonequals {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p)^{\prime}}(\epsilon)_{a} \times_{{\mathcal X}^{\ast,\prime}_{\widetilde{\Gamma}_{0}(p)^{\prime}}} {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}. $$
When $\widetilde{H}^{\prime}$ is open, we primarily view this as a rigid space.
By \cite[Corollary 3.2.19]{scholze-galois} (see remark below), there is a unique affinoid perfectoid space ${\mathcal X}_{\widetilde{P}_{\mu,0}\cap G^{\prime}(\Z_p), \Q_p}^{\prime,\ast}(\epsilon)_a$ such that
\[
\mathcal{X}^{\prime,\ast}_{\widetilde{P}_{\mu,0}^{\prime}\cap G^{\prime}(\Z_p), \Q_p}(\epsilon)_a\sim \varprojlim_m \mathcal{X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p^m)^{\prime\prime}, \Q_p}(\epsilon)_{a},
\]
where $\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime}$ is the subgroup $\widetilde{\Gamma}_{0}(p^{m})^{\prime}$ given by imposing the condition that the similitude factor is congruent to $1$ modulo $p^{m}$. Moreover, the boundary
\[
{\mathcal Z}^{\prime}_{\widetilde{P}_{\mu,0}^{\prime}\cap G^{\prime}(\Z_p), \Q_p}(\epsilon)_{a} \subseteq {\mathcal X}^{\prime,\ast}_{\widetilde{P}_{\mu,0}^{\prime}\cap G^{\prime}(\Z_p),\Q_p}(\epsilon)_{a}
\]
is strongly Zariski closed, in the sense of~\cite[Definition 2.2.6]{scholze-galois}.

\begin{rem}
The $\Gamma_{0}(p^{n})$-level structures of \cite[Definition 3.1.1]{scholze-galois} are slightly different to level structures $\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime}$ in this paper; the level structure $\Gamma_{0}(p^{\infty})$ corresponds to the kernel of determinant map on $\widetilde{P}_{\mu,0}$ in our notation. We assume that this is a typo and that the intention was to instead let it correspond to the kernel of the similitude map (this is what matches with the arguments of \cite[\S 3]{scholze-galois}). We also remark that the spaces constructed in \cite[\S 3]{scholze-galois} morally live over $\Q_p$, in the sense that they are limits of rigid spaces defined over $\Q_p$, but the limit admits a morphism to $\Q_p^\mathrm{cycl}$ given by the similitude factor, which allows them to be regarded as spaces over $\Q_p^\mathrm{cycl}$. This is the reason for working over $\Q_p$ in the current discussion.
\end{rem}

Going further up, by \cite[Proposition 3.2.34, Theorem 3.2.36]{scholze-galois} there are unique affinoid perfectoid spaces ${\mathcal X}^{\prime,\ast}_{\widetilde{N}_{0}^{\prime},\Q_p}(\epsilon)_a$ and ${\mathcal X}^{\prime,\ast}_{\widetilde{\mathbf{1}}^{\prime},\Q_p}(\epsilon)_a$ such that
\[ {\mathcal X}^{\prime,\ast}_{\widetilde{N}_{0}^{\prime},\Q_p}(\epsilon)_a \sim \varprojlim_{m} {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_1(p^m)^{\prime},\Q_p}(\epsilon)_{a}; \]
\[ {\mathcal X}^{\prime,\ast}_{\widetilde{\mathbf{1}}^{\prime},\Q_p}(\epsilon)_{a} \sim \varprojlim_{m} {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^m)^{\prime},\Q_p}(\epsilon)_{a} . \]
Moreover, the boundaries ${\mathcal Z}^{\prime}_{\widetilde{N}_{0}^{\prime},\Q_p}(\epsilon)_{a} \subseteq {\mathcal X}^{\prime,\ast}_{\widetilde{N}_{0}^{\prime},\Q_p}(\epsilon)_{a}$
and ${\mathcal Z}^{\prime}_{\widetilde{\mathbf{1}}^{\prime},\Q_p}(\epsilon)_{a} \subseteq {\mathcal X}^{\prime,\ast}_{\widetilde{\mathbf{1}}^{\prime},\Q_p}(\epsilon)_{a}$, respectively, are strongly Zariski closed, and functions on ${\mathcal X}^{\prime}_{\widetilde{\mathbf{1}}^{\prime},\Q_p}(\epsilon)_{a}$ extend uniquely to ${\mathcal X}^{\prime,\ast}_{\widetilde{\mathbf{1}}^{\prime},\Q_p}(\epsilon)_{a}$. It will be essential for the arguments of this paper to have a slightly more general result. Before we state and prove this generalization, we recall \cite[Lemma 3.2.24(iii)]{scholze-galois}\footnote{In part because the notation we use is incompatible with the notation used in \cite[Lemma 3.2.24(iii)]{scholze-galois}} which will be used in the proof. For all level structures $\widetilde{H}^{\prime}$, we use ${\mathcal X}^{\prime,gd}_{\widetilde{H}^{\prime}}(\epsilon)_{a}$ and ${\mathcal X}^{\prime,gd}_{\widetilde{H}^{\prime}}$ to denote the good reduction loci in ${\mathcal X}^{\prime}_{\widetilde{H}^{\prime}}(\epsilon)_{a}$ and ${\mathcal X}^{\prime}_{\widetilde{H}^{\prime}}$; these are quasicompact open subspaces (or diamonds).

\begin{lemma}\label{3.2.24} \cite[Lemma 3.2.24(iii)]{scholze-galois}
Let ${\mathcal Y}_{m}^{\ast} \to {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime},\Q_p}(\epsilon)_{a}$ be finite, \'etale away from the boundary, and assume that ${\mathcal Y}^{\ast}_{m}$ is normal and that no irreducible component of ${\mathcal Y}_{m}^{\ast}$ maps to the boundary of ${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime},\Q_p}(\epsilon)_{a}$. In particular, ${\mathcal Y}^{gd}_{m}\colonequals {\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime},\Q_p}(\epsilon)_{a}\times_{{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime},\Q_p}(\epsilon)_{a}}{\mathcal Y}_{m}^{\ast}$ is finite \'etale over ${\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime},\Q_p}(\epsilon)_{a}$. For any $m^{\prime} \geq m$, let ${\mathcal Y}_{m^{\prime}}^{\ast}$ be the normalisation of ${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p^{m^{\prime}})^{\prime\prime},\Q_p}(\epsilon)_{a}\times_{{\mathcal X}^{\ast}_{\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime},\Q_p}(\epsilon)_{a}}{\mathcal Y}_{m}^{\ast}$ and let ${\mathcal Y}_{m^{\prime}}^{gd}$ be the preimage of ${\mathcal Y}_{m}^{gd}$. Let ${\mathcal Y}_{\infty}^{gd}={\mathcal Y}_{m}^{gd} \times_{{\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime},\Q_p}(\epsilon)_{a}}{\mathcal X}^{\prime,gd}_{\widetilde{P}_{\mu,0}^{\prime}\cap G^{\prime}(\Z_p), \Q_p}(\epsilon)_{a}$; this exists as a perfectoid space since ${\mathcal Y}_{m}^{gd} \to {\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}_{0}(p^{m})^{\prime\prime},\Q_p}(\epsilon)_{a}$ is finite \'etale.
The spaces ${\mathcal Y}_{m^{\prime}}^{\ast}$ are affinoid for $m^{\prime}$ sufficiently large, so write ${\mathcal Y}_{m^{\prime}}^{\ast}=\Spa(S_{m^{\prime}},S_{m^{\prime}}^{+})$. Assume further that $S_{\infty} \colonequals H^{0}({\mathcal Y}^{gd}_{\infty},{\mathcal O}_{{\mathcal Y}_{\infty}^{gd}})$ is a perfectoid $\Q_p^{\mathrm{cycl}}$-algebra and define ${\mathcal Y}_{\infty}^{\ast} \colonequals \Spa(S_{\infty},S_{\infty}^{\circ})$. Then ${\mathcal Y}_{\infty}^{\ast} \sim \varprojlim_{m^{\prime}}{\mathcal Y}_{m^{\prime}}^{\ast}$.
\end{lemma}

To simplify notation, we will not write out the subscripts `$\Q_p$' for most of the discussion below until after the proof of Corollary \ref{anticanonical tower at intermediate levels 2 Siegel Qp}, and we will put $\widetilde{P}_{\mu,0}^{\prime\prime} \colonequals \widetilde{P}_{\mu,0}^{\prime} \cap G^{\prime}(\Z_p)$. Returning to the situation of the lemma above and keeping in mind these conventions, we recall that ${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a}$ is proved to be perfectoid via Lemma \ref{3.2.24}. In particular
$$H^{0}({\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a},{\mathcal O}_{{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a}}) = H^{0}({\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a},{\mathcal O}_{{\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a}})$$
is a perfectoid $\Q_p^{\mathrm{cycl}}$-algebra. As ${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^{m})^{\prime}}(\epsilon)_{a} \to {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}}(\epsilon)_{a}$ is finite \'etale by \cite[Lemma 3.2.35]{scholze-galois}), one sees that
$${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a} = {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^{m})^{\prime}}(\epsilon)_{a}\times_{{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}}(\epsilon)_{a}} {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a}$$
is affinoid perfectoid and a direct calculation using the fact that ${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^{m})^{\prime}}(\epsilon)_{a} \to {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{1}(p^{m})^{\prime}}(\epsilon)_{a}$ is finite \'etale shows that
$$ H^{0}({\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a},{\mathcal O}_{{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a}}) = H^{0}({\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a},{\mathcal O}_{{\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a}}),$$
so the latter is affinoid perfectoid.

\begin{prop}\label{anticanonical tower at intermediate levels Siegel} We work over $\Q_p$. Let $\widetilde{K}^{\prime} \subset \widetilde{G}^{\prime}({\mathbb Z}_p)$ be a compact open subgroup. There exists an affinoid perfectoid space
\[
{\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a\sim \varprojlim_{m}{\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{\Gamma}_{0}(p^{m})^{\prime\prime}}(\epsilon)_a .
\]
Moreover, the boundary ${\mathcal Z}^{\prime}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a\subset {\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$ is strongly Zariski closed.
\end{prop}

\begin{proof} We check that the conditions of Lemma \ref{3.2.24} apply to ${\mathcal Y}_m^\ast\colonequals {\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{\Gamma}_0(p^m)^{\prime\prime}}(\epsilon)_a$ for any large enough $m$: the projection map
\[{\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{\Gamma}_0(p^m)^{\prime\prime}}\to {\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_0(p^m)^{\prime\prime}}\]
is finite \'etale away from the boundary, ${\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{\Gamma}_0(p^m)^{\prime\prime}}(\epsilon)_a$ is normal,
and no irreducible component of ${\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{\Gamma}_0(p^m)^{\prime\prime}}(\epsilon)_a$ maps into the boundary.
Note that the space ${\mathcal Y}_{\infty}^{gd}\colonequals {\mathcal X}^{\prime,gd}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$ exists and is perfectoid, since it is the pullback to the perfectoid space ${\mathcal X}^{\prime,gd}_{\widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$ of ${\mathcal X}^{\prime}_{\widetilde{K}^{\prime} \cap \widetilde{\Gamma}_0(p^m)^{\prime\prime}}(\epsilon)_a\to  {\mathcal X}^{\prime}_{\widetilde{\Gamma}_0(p^m)^{\prime\prime}}(\epsilon)_a$,
which is finite \'etale. The last thing we need to show is that
\[
S_\infty'\colonequals H^0({\mathcal X}^{\prime,gd}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a, {\mathcal O}_{{\mathcal X}^{\prime,gd}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a})
\]
is a perfectoid ${\mathbb Q}_p^\mathrm{cycl}$-algebra.

\medskip
To see this, we argue as follows. There exists an integer $m\geq 1$ such that $\widetilde{\Gamma}(p^m)^{\prime}\subset \widetilde{K}^{\prime}$; then
the quotient $H\colonequals \widetilde{K}^{\prime}/\widetilde{\Gamma}(p^m)^{\prime}$ is a finite group. From the discussion preceding this Proposition, we know that ${\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^m)^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$
is affinoid perfectoid and that
$$ S_{\infty} \colonequals H^{0}({\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a},{\mathcal O}_{{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a}}) = H^{0}({\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a},{\mathcal O}_{{\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}(p^{m})^{\prime}\cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_{a}}).$$
We now conclude using~\cite[Prop. 3.6.22]{kedlaya-liu}, since
\[
S_\infty' = (S_\infty)^H,
\]
which follows from the fact that ${\mathcal X}^{\prime,gd}_{\widetilde{\Gamma}(p^m)^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$ is an $H$-torsor over ${\mathcal X}^{\prime,gd}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$. This concludes the proof of the first part of the proposition, using Lemma \ref{3.2.24}.

\medskip
To see that ${\mathcal Z}^{\prime}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a\subset {\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$ is strongly Zariski closed, we note that ${\mathcal Z}^{\prime}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$ is the pullback of ${\mathcal Z}^{\prime}_{\widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a\subset {\mathcal X}^{\prime,\ast}_{\widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$ over the map ${\mathcal X}^{\prime,\ast}_{\widetilde{K}^{\prime} \cap \widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a \to {\mathcal X}^{\prime,\ast}_{\widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$, and use \cite[Lemma 2.2.9]{scholze-galois}.
\end{proof}

We immediately deduce the following generalization.

\begin{cor}\label{anticanonical tower at intermediate levels 2 Siegel Qp} We work over $\Q_p$. Let $\widetilde{H}^{\prime} \subseteq \widetilde{P}_{\mu,0}^{\prime\prime}$ be a closed subgroup. Then the diamond ${\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_a$
is an affinoid perfectoid space, and the boundary ${\mathcal Z}^{\prime}_{\widetilde{H}^{\prime}}(\epsilon)_a\subset {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_a$ is strongly Zariski closed.
\end{cor}

\begin{proof}
Let $\widetilde{H}_{i}^{\prime} \subseteq \widetilde{P}_{\mu,0}^{\prime\prime}$, $i\in I$, be a collection of open subgroups of $\widetilde{P}^{\prime\prime}_{\mu,0}$ containing $\widetilde{H}^{\prime}$ such that $\bigcap_{i\in I}\widetilde{H}_{i} = \widetilde{H}$. We may assume that each $\widetilde{H}_{i}^{\prime}$ is equal to $\widetilde{P}_{\mu,0}^{\prime\prime}\cap \widetilde{K}_{i}^{\prime}$ for some open subgroup $\widetilde{K}_{i}^{\prime}\subseteq \widetilde{G}^{\prime}(\Z_p)$. Then each ${\mathcal X}^{\prime,\ast}_{\widetilde{H}_{i}^{\prime}}(\epsilon)_{a}$ is affinoid perfectoid by Proposition \ref{anticanonical tower at intermediate levels Siegel}, so ${\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_a = \varprojlim_{i}{\mathcal X}^{\prime,\ast}_{\widetilde{H}_{i}^{\prime}}(\epsilon)_a$ is affinoid perfectoid. The boundary ${\mathcal Z}^{\prime}_{\widetilde{H}^{\prime}}(\epsilon)_a$ is the pullback of ${\mathcal Z}^{\prime}_{\widetilde{P}_{\mu,0}^{\prime\prime}}(\epsilon)_a$, hence strongly Zariski closed by \cite[Lemma 2.2.9]{scholze-galois}.
\end{proof}

We now go back to working over $C$, and deduce the following result.

\begin{cor}\label{anticanonical tower at intermediate levels 2 Siegel}
We work over $C$. Let $\widetilde{H}^{\prime} \subseteq \widetilde{P}_{\mu,0}^{\prime}$ be a closed subgroup. Then the diamond ${\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_a$
is an affinoid perfectoid space, and the boundary
\[
{\mathcal Z}^{\prime}_{\widetilde{H}^{\prime}}(\epsilon)_a\subset {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_a
\]
is strongly Zariski closed.
\end{cor}

\begin{proof}
First assume that $\widetilde{H}^{\prime}\subseteq \widetilde{P}_{\mu,0}^{\prime\prime}$. Then
$$ {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_a = \left( {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime},\Q_p}(\epsilon)_a \times_{\Spa(\Q_p)^{\lozenge}} \Spa(\Q_p^\mathrm{cycl})^{\lozenge} \right) \times_{\Spa(\Q_p^\mathrm{cycl})^{\lozenge}} \Spa(C)^{\lozenge} $$
where the omitted ring of integral elements is the power-bounded elements. The first fiber product is affinoid perfectoid by Corollary \ref{anticanonical tower at intermediate levels 2 Siegel Qp} since it is equal to
$$ \varprojlim_{m} \left( {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime},\Q_p}(\epsilon)_a \times_{\Spa(\Q_p)^{\lozenge}} \Spa(\Q_p(\zeta_{p^m}))^{\lozenge} \right);$$
the second fiber product is then a fiber product of affinoid perfectoid spaces, hence affinoid perfectoid. The statement about the boundary follows by pullback, using the map ${\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_a \to {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime},\Q_p}(\epsilon)_a$.

\medskip
For general $\widetilde{H}^{\prime} \subseteq \widetilde{P}_{\mu,0}^{\prime}$, set $\widetilde{H}^{\prime\prime} = \widetilde{H}^{\prime} \cap G^{\prime}(\Z_p)$. Then ${\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime}}(\epsilon)_a$ is a closed union of connected components of ${\mathcal X}^{\prime,\ast}_{\widetilde{H}^{\prime\prime}}(\epsilon)_a$, and the result for $\widetilde{H}^{\prime}$ follows from that for $\widetilde{H}^{\prime\prime}$.
\end{proof}

We now return to our unitary Shimura varieties, and continue to work over $C$ for the rest of this paper. Recall that whenever we have tame levels $\widetilde{K}^{p} \subseteq \widetilde{K}^{p,\prime}$ and (open) levels $\widetilde{K} \subseteq \widetilde{K}^{\prime}$ at $p$ we have a canonical finite morphism $ {\mathcal X}_{\widetilde{K}}^{\ast} \to {\mathcal X}_{\widetilde{K}^{\prime}}^{\prime,\ast} $ which, for $\widetilde{K}^{p,\prime},\widetilde{K}^{\prime}$ sufficiently small, is a closed immersion when restricted to ${\mathcal X}_{\widetilde{K}}$ \cite[Proposition 1.15]{deligne-tshimura}. More generally, the images of ${\mathcal X}_{\widetilde{K}}^{\ast}$ (with its reduced induced rigid space structure) in ${\mathcal X}_{\widetilde{K}^{\prime}}^{\prime,\ast}$ stabilize as $\widetilde{K}^{p,\prime},\widetilde{K}^{\prime}$ shrink, and following \cite[\S 4.1]{scholze-galois} we define the ``ad hoc'' compactification $\overline{{\mathcal X}}_{\widetilde{K}}$ of ${\mathcal X}_{\widetilde{K}}$ to be the image of ${\mathcal X}_{\widetilde{K}}^{\ast}$ in ${\mathcal X}_{\widetilde{K}^{\prime}}^{\prime,\ast}$ for sufficiently small $\widetilde{K}^{p,\prime},\widetilde{K}^{\prime}$. The canonical morphism
$$ {\mathcal X}^{\ast}_{\widetilde{K}} \to \overline{{\mathcal X}}_{\widetilde{K}} $$
is a universal homeomorphism and hence induces an isomorphism of diamonds by \cite[Proposition 10.2.1]{berkeley-notes} and the remarks following it%
\footnote{We remark that it would be possible, with some minor changes to the arguments, to work with the ad hoc compacitifications instead of the minimal compactifications throughout this paper.}.
In particular, it is an isomorphism on topological spaces. For any closed subgroup $\widetilde{H} \subseteq \widetilde{\Gamma}_{0}(p)$, set
$$ {\mathcal X}^{\ast}_{\widetilde{H}}(\epsilon)_{a} \colonequals {\mathcal X}^{\ast}_{\widetilde{H}} \times_{{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p)^{\prime}}}{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p)^{\prime}}(\epsilon)_{a}; $$
$$ \overline{{\mathcal X}}_{\widetilde{H}}(\epsilon)_{a} \colonequals \overline{{\mathcal X}}_{\widetilde{H}} \times_{{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p)^{\prime}}}{\mathcal X}^{\prime,\ast}_{\widetilde{\Gamma}_{0}(p)^{\prime}}(\epsilon)_{a} $$
and ${\mathcal X}_{\widetilde{H}}(\epsilon)_{a}= {\mathcal X}^{\ast}_{\widetilde{H}}(\epsilon)_{a} \cap {\mathcal X}_{\widetilde{H}}$. These are non-empty since the ordinary locus of our unitary Shimura varieties is non-empty. The following is the main result of this section.

\begin{thm}\label{anticanonical tower at intermediate levels 2} Let $\widetilde{H} \subseteq \widetilde{P}_{\mu,0}$ be a closed subgroup. Then ${\mathcal X}^{\ast}_{\widetilde{H}}(\epsilon)_{a}$ is an affinoid perfectoid space over $C$, and the boundary ${\mathcal Z}_{\widetilde{H}}(\epsilon)_a\subset {\mathcal X}^\ast_{\widetilde{H}}(\epsilon)_a$ is strongly Zariski closed.
\end{thm}

\begin{proof}
In this proof we will write out tame levels for the Siegel Shimura varieties that appear. Choose a (countable) shrinking set of compact open subgroups $\widetilde{K}_{i}\subseteq \widetilde{\Gamma}_{0}(p)$ such that $\widetilde{H}= \bigcap_{i}\widetilde{K}_{i}$, and choose shrinking sets of tame levels $\widetilde{K}_{i}^{p,\prime}$ and compact open subgroups $\widetilde{K}^{\prime}_{i}\subseteq \widetilde{\Gamma}_{0}(p)^{\prime}$ such that $\overline{{\mathcal X}}_{\widetilde{K}_{i}} \subseteq {\mathcal X}^{\prime,\ast}_{\widetilde{K}_{i}^{p,\prime}\widetilde{K}_{i}^{\prime}}$. Set $\widetilde{H}^{p,\prime}=\bigcap_{i}\widetilde{K}_{i}^{p,\prime}$, $\widetilde{H}^{\prime}=\bigcap_{i}\widetilde{K}_{i}^{\prime}$ and define
$$ {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{p,\prime}\widetilde{H}^{\prime}}(\epsilon)_{a} \colonequals \varprojlim_{i} {\mathcal X}^{\prime,\ast}_{\widetilde{K}_{i}^{p,\prime}\widetilde{K}_{i}^{\prime}}(\epsilon)_{a}^{\lozenge} = \varprojlim_{i} {\mathcal X}^{\prime,\ast}_{\widetilde{K}_{i}^{p,\prime}\widetilde{H}^{\prime}}(\epsilon)_{a}.$$
The second equality and Corollary \ref{anticanonical tower at intermediate levels 2 Siegel} shows that this is an affinoid perfectoid space with strongly Zariski closed boundary. We have
$${\mathcal X}_{\widetilde{H}}^{\ast}(\epsilon)_{a} = \varprojlim_{i} {\mathcal X}_{\widetilde{K}_{i}}^{\ast}(\epsilon)_{a}^{\lozenge} = \varprojlim_{i} \overline{{\mathcal X}}_{\widetilde{K}_{i}}(\epsilon)_{a}^{\lozenge}. $$
For every $i$, set
$$Y_{i} \colonequals \overline{{\mathcal X}}_{\widetilde{K}_{i}}(\epsilon)_{a} \times_{{\mathcal X}^{\prime,\ast}_{\widetilde{K}_{i}^{p,\prime}\widetilde{K}_{i}^{\prime}}(\epsilon)_{a}} {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{p,\prime}\widetilde{H}^{\prime}}(\epsilon)_{a}. $$
Since $\overline{{\mathcal X}}_{\widetilde{K}_{i}}(\epsilon)_{a} \subseteq {\mathcal X}^{\prime,\ast}_{\widetilde{K}_{i}^{p,\prime}\widetilde{K}_{i}^{\prime}}$ is Zariski closed, $Y_{i} \subseteq  {\mathcal X}^{\prime,\ast}_{\widetilde{H}^{p,\prime}\widetilde{H}^{\prime}}(\epsilon)_{a} $ is Zariski closed and hence affinoid perfectoid with strongly Zariski closed boundary. It follows that ${\mathcal X}_{\widetilde{H}}^{\ast}(\epsilon)_{a} = \bigcap_{i}Y_{i}$ is affinoid perfectoid with strongly Zariski closed boundary, as desired.
\end{proof}

\subsection{The Hodge--Tate period morphism}\label{hodgetatemapsection}
In this subsection we discuss the perfectoid Shimura variety ${\mathcal X}^*_{\widetilde{\mathbf{1}}}$
and the Hodge--Tate period morphism
\[
\pi_{\mathrm{HT}}\colon {\mathcal X}^*_{\widetilde{\mathbf{1}}}\to \mathscr{F}\ell_{\widetilde{G},\mu}.
\]
Recall that, roughly speaking, the Hodge--Tate period morphism measures the relative position of the Hodge--Tate filtration on the
universal abelian variety over the perfectoid Shimura variety.

\subsubsection{The flag varieties $\mathscr{F}\!\ell_{\widetilde{G},\mu}$ and $\mathscr{F}\!\ell_{G,\mu}$}\label{subsubsect:flag_variety}
We first recall the definition of the classical
flag variety $\Flr_{\widetilde{G},\mu}$; for details, see~\cite[\S 2]{caraiani-scholze}.

In~\ref{subsubsect:Sh_datum}, we fixed
a Hodge cocharacter $\mu \colon {\mathbb G}_{m,{\mathbb C}} \to \widetilde{G}_{\mathbb C}$
associated to an element $h \in \widetilde{X}$,
which we will regard as a basepoint of the flag variety.
This choice determines a filtration $\Fil_\bullet(\mu)$ on $\Rep_{\mathbb C}(\widetilde{G}_{\mathbb C})$, or
rather on the underlying category of finite-dimensional $\CC$-vector spaces:
for any $W \in \Rep_{\mathbb C}(\widetilde{G}_{\mathbb C})$ and $k \in {\mathbb Z}$, let
\[ W^k = \{ w \in W \mid \mu(z)w = z^{-k} \cdot w \}. \]
Then $W = \oplus_{k\in{\mathbb Z}} W^k$ and we can set $\Fil_k(W) = \oplus_{k' \leq k}W^{k'}$.

The parabolic $\widetilde{P}_\mu$ is the subgroup scheme of $\widetilde{G}_{\mathbb C}$ fixing $\Fil_\bullet(\mu)$.%
\footnote{This
parabolic is opposite to the standard parabolic, which fixes the \emph{descending} filtration
on $\Rep_{\mathbb C}(\widetilde{G}_{\mathbb C})$ induced by $\mu$.}
Alternatively, it can be described as
\begin{equation}\label{Cparabolic}
\widetilde{P}_\mu = \left\{ g\in G \mid \lim_{t\to 0} \mathrm{ad}(\mu(t))g \text{ exists}\right\}.
\end{equation}
The corresponding Levi subgroup  $\widetilde{M}_\mu\subseteq \widetilde{P}_\mu$
is the centralizer of $\mu$. The conjugacy classes of $\widetilde{P}_\mu$ and $\widetilde{M}_\mu$ are already defined over the reflex field ${\mathbb Q}$. We also remark that the integral PEL datum underlying the construction of the integral models for our Shimura varieties provides us with a natural model of $\widetilde{P}_{\mu}$ defined over ${\mathbb Z}_{(p)}$; see \cite[\S 1.2.5]{lan-thesis} for the general theory.%

The flag variety is then defined as the quotient
$\Flr_{\widetilde{G},\mu}\colonequals \widetilde{G}/\widetilde{P}_\mu$.
It has a canonical model over ${\mathbb Q}$ since both $\widetilde{G}$ and $\widetilde{P}_\mu$ are defined over $\mathbb{Q}$.

\begin{lem}\label{lem:Flag_variety}
  Let $\Grr(n,2n)$ be the Grassmannian parametrizing $n$-dimensional subspaces of a $2n$-dimensional $\overline{\Q}$-vector space.
  Then there is an isomorphism of schemes over $\overline{\Q}$
  \[ \Flr_{\widetilde{G},\mu}\times_{\Spec{\mathbb Q}}\Spec \overline{\Q} \xrightarrow{\sim} \prod_{\iota \in \Psi} \Grr(n,2n). \]
\end{lem}
\begin{proof}
  The parabolic $\widetilde{P}_\mu$, which \textit{a priori} stabilizes an ascending filtration on
$\Rep_{\mathbb C}(\widetilde{G})$, can be determined
as the stabilizer of $\Fil_\bullet(\mu)$ on a single faithful
representation of $\widetilde{G}({\mathbb C})$.
One such representation is $V \otimes_{\mathbb Q} {\mathbb C}$.
We have
\[ V \otimes_{\mathbb Q} {\mathbb C} \simeq \prod_{\iota \in \Psi} V \otimes_{F,\iota} {\mathbb C} \times V \otimes_{F,\iota \circ c} {\mathbb C}. \]
By the proof of Lemma~\ref{lem:Hodge_cocharacter}, $\Fil_\bullet(V \otimes_{\mathbb Q} {\mathbb C})$ is given by
\begin{IEEEeqnarray*}{lCl}
  \Fil_{-2}(V \otimes_{\mathbb Q} {\mathbb C}) &=& \{0\} \\
  \Fil_{-1}(V \otimes_{\mathbb Q} {\mathbb C}) &=& \prod_{\iota \in \Psi} ({\mathbb C}^n \oplus 0^n \times 0^n \oplus {\mathbb C}^n) \subset V \otimes_{\mathbb Q} {\mathbb C} \\
  \Fil_0(V \otimes_{\mathbb Q} {\mathbb C}) &=& V \otimes_{\mathbb Q} {\mathbb C}.
\end{IEEEeqnarray*}
Using the identifications of Lemma~\ref{lem:Hodge_cocharacter},
\[ \widetilde{P}_\mu = \prod_{\iota \in \Psi} \widetilde{P}^\iota_\mu \times {\mathbb G}_{m,{\mathbb C}} \subset \prod_{\iota \in \Psi}\GL_{2n, \CC} \times {\mathbb G}_{m,{\mathbb C}} \simeq \widetilde{G}_{\mathbb C}, \]
where $\widetilde{P}^\iota_\mu$ is the stabilizer of the $n$-dimensional subspace ${\mathbb C}^n \oplus 0^n \subset V \otimes_{F,\iota} {\mathbb C}$;
$\widetilde{P}^\iota_\mu$ consists of all upper triangular block matrices.
This way, we obtain an isomorphism
\[ \Flr_{\widetilde{G},\mu} = \widetilde{G}/\widetilde{P}_\mu \simeq \prod_{\iota \in \Psi} \GL_{2n,\CC} / \widetilde{P}^\iota_\mu \xrightarrow{\sim} \prod_{\iota \in \Psi} \Grr(n,2n). \]
As $\mu$ and the maps in Lemma~\ref{lem:Hodge_cocharacter} are already defined over $\overline{\Q}$, so is this morphism.
\end{proof}
By base changing along the natural inclusion ${\mathbb Q}\subset C$ (respectively $\overline{\Q} \subset C$) and applying the adification functor, we can associate with $\Flr_{\widetilde{G},\mu}$ and $\Grr(n,2n)$ adic spaces $\mathscr{F}\!\ell_{\widetilde{G},\mu}$ and $\mathscr{G}\!r(n,2n)$ over $\Spa(C,\O_C)$.
In the same manner, Lemma~\ref{lem:Flag_variety} induces an isomorphism
\[ \mathscr{F}\!\ell_{\widetilde{G},\mu} \xrightarrow{\sim} \prod_{\iota \in \Psi} \mathscr{G}\!r (n,2n)\]
of adic spaces over $\Spa(C,\O_C)$.

In general, the
construction of the flag variety (in its algebraic or adic incarnations) is functorial in the Shimura datum.
We have
\[
P_\mu \colonequals \widetilde{P}_{\mu}\cap G_{\CC} = \prod_{\iota \in \Psi} \widetilde{P}^{\iota}_{\mu},
\]
which induces an isomorphism of flag varieties
\[
\Flr_{G,\mu}\simeq \Flr_{\widetilde{G},\mu}.
\]
For simplicity, we write $\Flr_{G,\mu}$ for the flag variety for $\widetilde{G}$.

From now on, we will only consider the flag varieties as adic spaces. Consider the product of Pl\"ucker embeddings
\[
\mathscr{F}\!\ell_{G,\mu}\simeq \prod_{\mathfrak{p}}\mathscr{G}\!r(n,2n)\hookrightarrow \prod_{\mathfrak{p}}\mathbb{P}^N,
\]
where $N={2n\choose n}-1$ and the products run over primes $\mathfrak{p}\mid p$ of $F$ which are induced by embeddings $\iota_{\mathfrak{p}}\in \Psi$.
We index the coordinates $s_{\mathfrak{p},J}$ on each $\mathbb{P}^N$
factor by cardinality $n$ subsets $J$ of $\{1,\dots,2n\}$. For such a $J$, we let
\[
\mathscr{F}\!\ell_{\mathfrak{p},J}=\mathscr{G}\!r(n,2n)\cap \{|s_{\mathfrak{p}, J}|\geq |s_{\mathfrak{p},J'}|, \forall J'\subset \{1,\dots,2n\}, |J'|=n\}.
\]
The open subspaces $\prod_{\mathfrak{p}}\mathscr{F}\!\ell_{\mathfrak{p}, J}$ give an affinoid cover of $\mathscr{F}\!\ell_{G,\mu}$.

\subsubsection{The Hodge--Tate period morphism}
We endow the flag variety $\mathscr{F}\!\ell_{G, \mu}$ with the~\emph{right} action of $\widetilde{G}({\mathbb Q}_p)$
which is the inverse of the usual left action, coming from the left action of $\widetilde{G}$ on
the quotient $\widetilde{G}/\widetilde{P}_{\mu}$. Recall also that there is a right action of  $\widetilde{G}({\mathbb Q}_p)$ on the diamond ${\mathcal X}^*_{\widetilde{\mathbf{1}}}$. We also consider the analogous right actions of $G({\mathbb Q}_p)$ on ${\mathcal X}^*_{\mathbf{1}}$ and $\mathscr{F}\!\ell_{G,\mu}$.
Recall our embedding $(\widetilde{G},\widetilde{X}) \hookrightarrow (\widetilde{G}^{\prime},\widetilde{X}^{\prime})$ of Shimura data from the previous subsection. We have a flag variety $\mathscr{F}\!\ell_{\widetilde{G}^{\prime},\mu^{\prime}}$ for $(\widetilde{G}^{\prime},\widetilde{X}^{\prime})$.

\begin{thm}\label{perfectoid Shimura variety and properties 2}
The spatial diamond ${\mathcal X}^*_{\widetilde{\mathbf{1}}}$ is a perfectoid space, and there is a $\widetilde{G}(\Q_p)$-equivariant Hodge--Tate period morphism ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}} \to \mathscr{F}\!\ell_{G,\mu}$ of adic spaces.

\end{thm}

\begin{proof}
The first part follows from \cite[Theorem 4.1.1]{scholze-galois} and the fact that ${\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}= \varprojlim_{\widetilde{K}}{\mathcal X}_{\widetilde{K}}^{\ast,\lozenge}= \varprojlim_{\widetilde{K}}\overline{{\mathcal X}}_{\widetilde{K}}^{\lozenge}$ (where the inverse limit is over all compact open $\widetilde{K}\subseteq \widetilde{G}(\Z_p)$). For the second part, the construction proving \cite[Theorem 2.1.3]{caraiani-scholze} gives a commutative diagram
  \[
    \xymatrix{{\mathcal X}_{\widetilde{\mathbf{1}}} \ar[r]^-{\pi_{\mathrm{HT},\widetilde{G}}} \ar[d] & \mathscr{F}\!\ell_{G,\mu}\ar[d] \\ {\mathcal X}^{\prime,\ast}_{\widetilde{\mathbf{1}}^{\prime}}\ar[r]^-{\pi_{\mathrm{HT},\widetilde{G}^{\prime}}} & \mathscr{F}\!\ell_{\widetilde{G}^{\prime},\mu^{\prime}}}.
    \]
Since ${\mathcal X}_{\widetilde{\mathbf{1}}}$ is dense in ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}$ and $\mathscr{F}\!\ell_{G,\mu} \subseteq \mathscr{F}\!\ell_{\widetilde{G}^{\prime},\mu^{\prime}}$ is Zariski closed, it follows that $\pi_{\mathrm{HT},\widetilde{G}^{\prime}}(|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}|) \subseteq |\mathscr{F}\!\ell_{G,\mu}|$. From this, it follows that ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}} \to \mathscr{F}\!\ell_{\widetilde{G}^{\prime},\mu^{\prime}}$ factors through $\mathscr{F}\!\ell_{G,\mu}$. One way to see this is as follows. First, write $\mathscr{F}\!\ell_{G,\mu} = \bigcap_{i}U_{i}$ where the $U_{i}$ are quasicompact open subsets of $\mathscr{F}\!\ell_{\widetilde{G}^{\prime},\mu^{\prime}}$ containing $\mathscr{F}\!\ell_{G,\mu}$. As $\pi_{\mathrm{HT},\widetilde{G}^{\prime}}(|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}|) \subseteq U_{i}$ for all $i$, we obtain a morphism ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}} \to \varprojlim_{i}U_{i}^{\lozenge}=\mathscr{F}\!\ell_{G,\mu}^{\lozenge}$ of diamonds. Since ${\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}$ is perfectoid, the morphism ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}} \to \mathscr{F}\!\ell_{G,\mu}^{\lozenge}$ arises by diamondification from a unique morphism ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}} \to \mathscr{F}\!\ell_{G,\mu}$ of adic spaces by the definition of the diamondification functor.
\end{proof}

From now on we drop the subscript $\widetilde{G}$ and write $\pi_{\mathrm{HT}}$ for $\pi_{\mathrm{HT},\widetilde{G}}$. Our remaining goal in this subsection is to establish some facts about the geometry of the Hodge--Tate period map. Recall from \S \ref{sec: anticanonical} that notions such as being ordinary (or more generally the valuation of the Hasse invariant), canonical and anti-canonical are compatible for $\widetilde{G}$ and $\widetilde{G}^{\prime}$ as they don't depend on the endomorphism structure.

Let us describe the Hodge--Tate period morphism $\pi_{\mathrm{HT}}$ on geometric points of ${\mathcal X}_{\widetilde{\mathbf{1}}}$. Let $D$ be a complete, algebraically closed extension of $C$ and $x \in {\mathcal X}_{\widetilde{\mathbf{1}}}(D,\O_D)$.
The data parametrized by $x$ includes an abelian variety $A$ of dimension $n[F^+: {\mathbb Q}]$ over $D$ and an isomorphism $\eta_p \colon V \otimes_{\mathbb Q} \Q_p \xrightarrow{\sim} V_p(A)$ which is compatible with $\psi \otimes_{\mathbb Q} \Q_p$ and the $\lambda$-Weil pairing on $V_p(A)$.

The Hodge--Tate filtration on $V_p(A)$ is given by
\[ 0 \to (\Lie A)(1)\to V_p(A)\otimes_{\Q_p} D \to (\Lie A^\vee)^\vee\to 0. \]
As the $\iota \in \Psi$ are already defined over $\overline{\Q}$, there is a canonical isomorphism
\[ V_p(A) \otimes_{\Q_p} D \simeq V \otimes_{\mathbb Q} D \simeq \prod_{\iota \in \Psi}
(V \otimes_{F,\iota} D) \times (V \otimes_{F,\iota \circ c} D). \]
Since the Hodge--Tate filtration is equivariant with respect
to the action of $F$ by endomorphisms, using the
determinant condition we see that the subspaces
\[ (\Lie A)(1)^\iota \colonequals (\Lie A)(1) \cap (V \otimes_{F,\iota} D)
\quad \text{and} \quad (\Lie A)(1)^{\iota\circ c} \colonequals (\Lie A)(1) \cap (V \otimes_{F,\iota\circ c} D) \]
are $n$-dimensional, isotropic, and the latter annihilates the former under the Weil pairing.
Thus, the subspace $(\Lie A)(1)^{\iota\circ c}$
is determined by $(\Lie A)(1)^\iota$ and
\[ \pi_\mathrm{HT}(x) = \left((\Lie A)(1)^\iota\right)_{\iota \in \Psi} \in \prod_{\iota \in \Psi}
\mathscr{G}\!r(n,2n)(D,\O_D) \simeq \mathscr{F}\!\ell_{G,\mu}(D,\O_D). \]

\medskip
The geometric properties we are interested in concern the ordinary locus.  Although we will only need to discuss the ordinary stratum, we begin with a short recollection of the Newton stratification on the flag variety. The general theory of the Newton stratification on Hodge--Tate period domains can be found in \cite[Section 3.5]{caraiani-scholze}. We review the statement for our specific group $\widetilde{G}$.
\medskip

Let $L\colonequals W(\overline{\mathbb{F}}_p)[1/p]$,
and let $\sigma$ be the automorphism of $L$
that lifts the Frobenius $\alpha\mapsto \alpha^p$ on
$\overline{\mathbb{F}}_p$. There is a natural action on
the points of $\widetilde{G}(L)$ induced by $\sigma$-conjugation, i.e.,
the map $g\mapsto hg\sigma(h)^{-1}$ for $g,h\in \widetilde{G}(L)$.
The Kottwitz set $B(\widetilde{G})$ is by definition the set of
$\sigma$-conjugacy classes in $\widetilde{G}(L)$. This set
can be described in terms of the Newton map and the Kottwitz map; see~\cite{kottwitz-isocrystals}
for more details. Furthermore, $B(\widetilde{G})$ admits a natural partial order $\geq$, known as the Bruhat order.

Given the Hodge cocharacter $\mu$ of $\widetilde{G}$, one can define a subset $B(\widetilde{G}, \mu^{-1})\subset B(\widetilde{G})$
of $\mu^{-1}$-admissible elements.
The Newton stratification on $\mathscr{F}\!\ell_{G,\mu}$ is indexed
by elements of $B(\widetilde{G}, \mu^{-1})$.

\begin{prop}[\cite{caraiani-scholze}, Prop. 3.5.7]
There exists a map
\[
b(\cdot)\colon |\mathscr{F}\!\ell_{G,\mu}|\to B(\widetilde{G},\mu^{-1}),
\]
which is upper semicontinuous and maps higher rank points to the same image as their
maximal, rank $1$ generization.
\end{prop}

\begin{proof} The proof uses the classification of $\widetilde{G}$-bundles on
the Fargues--Fontaine curve in~\cite{fargues-fontaine, fargues}, which
is precisely in terms of the set $B(\widetilde{G})$.

The upper semicontinuity follows from the
relationship between vector bundles on the Fargues--Fontaine curve and
$\varphi$-modules over the Robba ring, and from the proof by Kedlaya--Liu
that the Newton map for $\varphi$-modules over
the Robba ring is lower semicontinuous~\cite{kedlaya-liu}.
As this point is not made explicit in~\cite{caraiani-scholze},
we note that the partial order they use for the Newton map is opposite
to the ordering of Newton polygons in the
Bruhat order.
\end{proof}

For any $b\in B(\widetilde{G},\mu^{-1})$, we define
$\mathscr{F}\!\ell_{G,\mu}^b\subseteq \mathscr{F}\!\ell_{G,\mu}$ to be
the preimage of $b$ under the above map. The following is an
immediate corollary to this proposition, also stated in \cite{caraiani-scholze}.

\begin{cor}\label{locally closed strata}
\label{strata}
The strata $\mathscr{F}\!\ell_{G,\mu}^b$ are locally closed in
$\mathscr{F}\!\ell_{G,\mu}$. In fact, the stratum
corresponding to
the basic element is open in $\mathscr{F}\!\ell_{G,\mu}$ and the
strata
\[ \mathscr{F}\!\ell_{G,\mu}^{\ge b}\colonequals \coprod_{b\le b'}\mathscr{F}\!\ell_{G,\mu}^{b'}\]
are closed.
\end{cor}

\begin{remark}\label{compatibility of newton stratifications}
On rank $1$ points and on the good reduction locus ${\mathcal X}^{gd}_{\widetilde{\mathbf{1}}}$, the Newton stratification on $\mathscr{F}\!\ell_{G,\mu}$ is compatible with the Newton stratification on the special fiber of the Shimura variety, which is defined in terms of the isogeny class of the universal $p$-divisible
group with extra structure. Since the restriction of $\pi_{\mathrm{HT}}$ to the
open Shimura variety is surjective\footnote{The surjectivity follows from the non-emptiness of Newton strata and the product formula of~\cite[Section 4]{caraiani-scholze}.}, the Newton strata can be detected
``upstairs'', i.e.\ on the open Shimura variety.
\end{remark}

The $\mu$-ordinary Newton stratum is the one
associated with the unique maximal element of
$B(\widetilde{G},\mu^{-1})$; for PEL moduli spaces this was defined and studied in \cite{wedhorn-thesis}.
On the flag variety, the $\mu$-ordinary Newton stratum is a closed, $0$-dimensional subspace of $\mathscr{F}\!\ell_{G,\mu}$. The fact that it is closed
follows from Corollary~\ref{locally closed strata}, and the dimension computation is~\cite[Prop. 4.2.23]{caraiani-scholze}.
In our situation, the $\mu$-ordinary stratum is ordinary (by~\cite[Thm. 1.6.3]{wedhorn-thesis}). We denote the ordinary stratum by $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{ord}}$. Our aim is to discuss the behavior of the anti-canonical locus under the Hodge--Tate period map. We have the affinoid cover given by $\prod_{\mathfrak{p}} \mathscr{F}\!\ell_{\mathfrak{p},J_{\mathfrak{p}}}$, where each $J_{\mathfrak{p}}\subset \{1,2,\dots, 2n\}$ has cardinality $n$ (recall the Pl\"ucker coordinates $(s_{\mathfrak{p},J})$). We consider the following member of this cover:
$$ \mathscr{F}\!\ell_{G,\mu}^{a}\colonequals \prod_{\mathfrak{p}}\mathscr{F}\!\ell_{\mathfrak{p},\{n+1,\dots,2n\}}.$$
Then we have the following result.

\begin{prop}\label{explicit description of ordinary stratum} We have $
\mathscr{F}\!\ell_{G,\mu}^{\mathrm{ord}}= \mathscr{F}\!\ell_{G,\mu}({\mathbb Q}_p)$.%
\footnote{By $\mathscr{F}\!\ell_{G,\mu}(\Q_p)$, we mean the set of points of $\mathscr{F}\!\ell_{G,\mu}(C)$ whose image in $\Flr_{G,\mu}(C)$ comes from $\Flr_{G,\mu}(\Q_p)$.}
Moreover, $\pi_{\mathrm{HT}}^{-1}(\mathscr{F}\!\ell^{a}_{G,\mu}({\mathbb Q}_p))$ is the closure of the anti-canonical ordinary locus ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(0)_{a}\subseteq {\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}$.
\end{prop}

\begin{proof}
For the first part, there are two possible ways of arguing. In view of Remark~\ref{compatibility of newton stratifications}, the proposition follows from \cite[Lemma 3.3.6]{scholze-galois}) since $\mathscr{F}\!\ell_{G,\mu}(\Q_p)=\mathscr{F}\!\ell_{G,\mu}\cap \mathscr{F}\!\ell_{\widetilde{G}^{\prime},\mu^{\prime}}(\Q_p)$ and ${\mathcal X}_{\widetilde{\mathbf{1}}}(0)={\mathcal X}_{\widetilde{\mathbf{1}}} \cap {\mathcal X}^{\prime}_{\widetilde{\mathbf{1}}^{\prime}}(0)$ where $-(0)$ denotes ordinary loci (one reduces the statement to rank $1$ points, as in \cite[Lemma 3.3.6]{scholze-galois}). The other approach is via the Fargues-Fontaine curve, where it suffices
to show that, if the Hodge--de Rham filtration is defined over
${\mathbb Q}_p$, the corresponding vector bundle has all slopes in
the multiset $\{0,1\}$.

\medskip
The second part then follows from \cite[Lemma 3.3.20]{scholze-galois}, since $\mathscr{F}\!\ell_{G,\mu}^{a}(\Q_p)=\mathscr{F}\!\ell_{G,\mu}\cap W$, where $W$ is the set denoted by $\mathscr{F}\!\ell_{\{g+1,\dotsc,2g\}}(\Q_p)$ in \cite[Lemma 3.3.20]{scholze-galois} (in words, being anticanonical does not depend on the endomorphisms).
\end{proof}

Let us now return to the anticanonical locus, and recall the affinoid $\mathscr{F}\!\ell_{G,\mu}^{a}$ from above. We will be more interested in the affine open subset
$$ \mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}} = \mathscr{F}\!\ell_{G,\mu}\cap \{|s_{\mathfrak{p},\{n+1,\dots, 2n\}}|\not= 0, \forall \mathfrak{p}\}. $$
Here, the superscript stands for ``non-canonical'', and we will refer to it as the non-canonical locus.\footnote{We have chosen this terminology to distinguish it from the ``anti-canonical'' spaces appearing, though we are aware that ``anti-canonical'' might fit better also for these spaces.} To relate $\mathscr{F}\!\ell_{G,\mu}^{a}$ and $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}$, we introduce an element of $G(\Q_p)$. For each $\mathfrak{p}$, let
\[
  \gamma_{\mathfrak{p}}\colonequals \mathrm{diag}(p^{(n)},1^{(n)})\in \mathrm{GL}_{2n}(F_{\mathfrak{p}})\simeq \mathrm{GL}_{2n}({\mathbb Q}_p).
\]
Set $\gamma \colonequals (\gamma_{\mathfrak{p}})_{\mathfrak{p}}\in G({\mathbb Q}_p)$.
\begin{remark}
The cocharacter $\mu$ is defined over $\Q_p$, and
there is a commutative diagram
\[\xymatrix{({\mathbb G}_m)_{\Q_p} \ar[r]^{\mu} \ar@/_1pc/[rr]_{\mu'} & \widetilde{G}_{\Q_p} \ar[r] & \widetilde{G}'_{\Q_p}} \,. \]
Then $\gamma$ is the image of
$\mu(p)$ under a section $\widetilde{G}(\Q_p) \to G(\Q_p)$ of the inclusion
$G \hookrightarrow \widetilde{G}$.  The element that is denoted by
$\gamma$ in the proof of \cite[Thm.~3.3.18(i)]{scholze-galois} is $\mu'(p)$.
\end{remark}
Abusively,
we also consider $\gamma$ as an element of $\widetilde{G}({\mathbb Q}_p)$ or $\widetilde{P}_{\mu}({\mathbb Q}_p)$.

\begin{prop}\label{cover of flag nc}
We have
\[
\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}=\bigcup_{k\in{\mathbb Z}_{\geq 0}}\mathscr{F}\!\ell_{G,\mu}^{a}\cdot\gamma^{k}.
\]
Moreover, the sets $\mathscr{F}\!\ell_{G,\mu}^{a}\cdot \gamma^{-k}$, $k\geq 0$, form a basis of quasicompact open neighborhoods of a point in $\mathscr{F}\!\ell_{G,\mu}^{a}(\Q_p)$.
\end{prop}

\begin{proof}
One needs to check that whenever a point $x\in \mathscr{F}\!\ell_{G,\mu}$ has $|s_{\mathfrak{p},\{n+1,\dots,2n\}}|>0$ for every $\mathfrak{p}$, there exists an integer
$k\geq 0$ such that $x\cdot \gamma^{-k}\in \mathscr{F}\!\ell_{G,\mu}^{\mathrm{a}}$. Considering the action of $\gamma$ on
the Pl\"ucker coordinates, we see it is enough to find an integer
$k\geq 0$ such that
\[
|p^{-k}\cdot s_{\mathfrak{p},\{n+1,\dots, 2n\}}|\geq |s_{\mathfrak{p},J}|, \forall J\subset \{1,\dots,2n\}, |J|=n
\]
for every $\mathfrak{p}$. It is now clear that this can be done. The second assertion also follows from an explicit computation in Pl\"ucker coordinates.
\end{proof}

To finish this section, we discuss the non-canonical locus on the level of Shimura varieties, which we define as
$${\mathcal X}^{*,\mathrm{nc}}_{\widetilde{\mathbf{1}}} \colonequals \pi_{\mathrm{HT}}^{-1}(\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}).$$
The following result will be key for us in section \ref{stratifications}.

\begin{prop}\label{expanding the anticanonical locus} For any sufficiently small $\epsilon >0$, we have
\[
{\mathcal X}^{*,\mathrm{nc}}_{\widetilde{\mathbf{1}}}= \bigcup_{k\in {\mathbb Z}_{\geq 0}} {\mathcal X}^*_{\widetilde{\mathbf{1}}}(\epsilon)_{a} \cdot \gamma^{k}.
\]
\end{prop}

\begin{proof}
By Proposition \ref{explicit description of ordinary stratum}, $\pi_{\mathrm{HT}}^{-1}(\mathscr{F}\!\ell^{a}_{G,\mu}(\Q_p))$ is the closure of ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(0)_{a}$ in ${\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}$. From this, it follows that we can find $\epsilon >0$ and a quasicompact open subset $\mathscr{F}\!\ell_{G,\mu}^{a}(\Q_p) \subseteq U \subseteq \mathscr{F}\!\ell_{G,\mu}$ such that
$$ \pi^{-1}_{\mathrm{HT}}(U) \subseteq {\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a} \subseteq \pi_{\mathrm{HT}}^{-1}(\mathscr{F}\!\ell_{G,\mu}^{a}). $$
As $\mathscr{F}\!\ell_{G,\mu}^{a}\cdot \gamma^{-m} \subseteq U$ for $m$ large enough by the second part of Proposition \ref{cover of flag nc}, the Proposition follows from the first part of Proposition \ref{cover of flag nc}.
\end{proof}

\section{A stratification on the flag variety}\label{stratifications}

In this section, we will investigate the orbits of the action of the parabolic subgroup $P_{\mu}$ on the flag
variety $\mathscr{F}\!\ell_{G,\mu}$ (in fact, it turns out to be advantageous to note that $P_{\mu}$ is conjugate to its opposite $\overline{P}_{\mu}$ and study $\overline{P}_{\mu}$-orbits, cf. Remark \ref{p vs p opp}). In the first two subsections, we briefly review the generalized Bruhat decomposition; see~\cite[\S 5]{borel-tits} for more information. We then study the corresponding stratification of $\mathscr{F}\!\ell_{G,\mu}$, which we refer to as the Bruhat stratification, and its interaction with a certain collection of standard affine open subsets of $\mathscr{F}\!\ell_{G,\mu}$. We then finish by proving that various subsets of our Shimura varieties become perfectoid at intermediate infinite levels. This uses the aforementioned geometry of $\mathscr{F}\!\ell_{G,\mu}$ and the equivariance of the Hodge--Tate period map to ``spread out'' Theorem \ref{anticanonical tower at intermediate levels 2}, and is the key geometric input we need to prove our vanishing results. We remark that our result on the perfectoidness of the non-canonical locus is generalisation of a result of Ludwig \cite{ludwig} in the case of modular curves.

\subsection{Algebraic groups and Weyl groups}\label{algebraic groups and weyl groups}
Let $\mathrm{G}$ be a split connected reductive group over ${\mathbb Q}_p$, and let $\mathrm{T}$ be a maximal split torus of $\mathrm{G}$.
Let $\mathrm{B}$ be a Borel subgroup of $\mathrm{G}$, and let $\overline{\mathrm{B}}$ be the opposite Borel. We denote by $X^*(\mathrm{T})$ the group $\Hom(\mathrm{T}, {\mathbb G}_m)$ of characters of $\mathrm{T}$.  Let $\mathfrak{g}=\Lie(\mathrm{G})$ be the Lie algebra of $\mathrm{G}$. For $\alpha\in X^*(\mathrm{T})$, we put
$$
\mathfrak{g}_{\alpha}\colonequals \{X\in \mathfrak{g} \mid  \Ad(t)X=\alpha(t)X,\forall t\in \mathrm{T}\}
$$
and we define the relative root system $\Phi=\Phi(\mathrm{G},\mathrm{T})$ as
$$
\Phi \colonequals \{\alpha\in X^*(\mathrm{T}) \mid \alpha\neq 0, \mathfrak{g}_{\alpha}\neq 0\}.
$$
We denote by $\Phi^+\subset \Phi$ the subset of positive roots corresponding to $\mathrm{B}$. The Weyl group $W=W(\mathrm{G},\mathrm{T})$ of the root system $\Phi$ is defined as $W=N_{\mathrm{G}}(\mathrm{T})/C_{\mathrm{G}}(\mathrm{T})$, where $N_{\mathrm{G}}(\mathrm{T})$ and $C_{\mathrm{G}}(\mathrm{T})$ are respectively the normalizer and the centralizer of $\mathrm{T}$ in $\mathrm{G}$. We denote by $\Delta$ the set of simple roots with respect to $\mathrm{T} \leq \mathrm{B}$, and denoted by $S=\{s_{\alpha} \mid \alpha\in \Delta\} \subset W$ the set of simple reflections.

For  $I\subset S$, let $W_I$ be the subgroup of $W$ generated by all $s_i \in I$ and define the parabolic subgroup $\mathrm{P}_I$ as
$$
\mathrm{P}_I=\mathrm{B} W_I \mathrm{B}=\cup_{w\in W_I} \mathrm{B}w\mathrm{B}.
$$
For instance, $\mathrm{P}_\varnothing = \mathrm{B}$ and $\mathrm{P}_S = \mathrm{G}$.
The group $\mathrm{P}_I$ is a closed, connected, self-normalizing subgroup of $\mathrm{G}$ containing $\mathrm{B}$. For $I,J\subseteq S$, if $\mathrm{P}_I=\mathrm{P}_J$, then $I=J$. Groups of this form are called standard parabolic subgroups, and every parabolic subgroup is conjugate to a unique standard parabolic subgroup. We let $\overline{\mathrm{P}}_I = \overline{\mathrm{B}} W_I \overline{\mathrm{B}}$ be the parabolic subgroup opposite to $\mathrm{P}_I$. As usual, we put $\Delta_{I}=\{\alpha \in \Delta \mid s_{\alpha}\in I \}$ and $\Phi_{I}=\Phi \cap \sum_{\alpha\in \Delta_{I}}{\mathbb Z} \alpha$; this is the root system of Levi factor $\mathrm{P}_{I}/\mathrm{N}_{I}$ (where $\mathrm{N}_{I}$ is the unipotent radical of $\mathrm{P}_{I}$, see below) and $\Delta_{I}$ are the simple roots with respect to the Borel subgroup $\mathrm{B}_{I}/\mathrm{N}_{I}$.

For $\alpha\in \Phi$, denote by $\mathrm{U}_{\alpha}$ the unipotent subgroup of $\mathrm{G}$ whose Lie algebra $\Lie(\mathrm{U}_\alpha)$ is $\mathfrak{g}_{\alpha}$. For $I\subset S$, the standard parabolic subgroup $\mathrm{P}_I$ admits a Levi decomposition, $$\mathrm{P}_I=\mathrm{L}_I \ltimes \mathrm{N}_I,$$ where
$\mathrm{N}_I\colonequals \prod_{\alpha\in \Phi^+ - \Phi_I} \mathrm{U}_{\alpha}$ is the unipotent radical of $\mathrm{P}_{I}$ and $\mathrm{L}_I=\langle \mathrm{T},\mathrm{U}_{\alpha} \mid \alpha \in \Phi_I\rangle$.

\begin{example}[$\mathrm{G}=\GL_n$] \label{GL_n example part 1}
In this example, we describe everything explicitly in the above discussion for the case of  $\mathrm{G}=\GL_n$ and maximal parabolics. This is standard but we use this opportunity to set up some notation. We take $\mathrm{T}=\mathrm{D}_n$ the subgroup of diagonal matrices, and the group $\mathrm{B}$ to be the subgroup of upper triangular matrices. Associated to the above data, we have
\begin{itemize}
\item $\Phi=\{\chi_{i,j} \mid 1\leq i,j \leq n, i\neq j\}$ and $\Phi^+=\{\chi_{i,j} \mid i<j\}$, where   $\chi_{i,j}\in X^*(\mathrm{T})$ sends each diagonal matrix $\mbox{diag}(t_1,\ldots,t_n)$ to $t_it_j^{-1}\in \GG_m$.

\item The set of simple roots $\Delta$ is $\{\chi_{i,i+1} \mid 1\leq i<n\}$.

\item For $i=1,\ldots, n-1$, the simple reflection $s_i$ corresponding to $\chi_{i,i+1}$ is
$$
s_i=\left(\begin{array}{cccc}
I_{i-1} & & & \\
 & 0 & 1 & \\
 & -1 & 0 & \\
 & & & I_{n-i-1}
\end{array}\right)\cdot \mathrm{T}\in N_{\mathrm{G}}(\mathrm{T}).
$$
Here $I_m$ is the $m\times m$ identity matrix.

\item The Weyl group $W$ is isomorphic to the symmetric group $S_n$. The isomorphism is defined by sending $s_i\in W$ to $(i,i+1)\in S_n$ for $i=1,\ldots, n-1$.
\end{itemize}
Let $I=S-\{s_a\}$ for some $a<n$. Then we have
\begin{itemize}
  \item $W_I=\langle s_i \mid a \neq i <n\rangle\cong S_a\times S_{n-a}$,
  \item $\Phi_I=\{\chi_{i,j} \mid i,j\leq a \mbox{ or } i,j\geq a\}$,
  \item $\mathrm{P}_I=\left\{ \begin{pmatrix} A & *\\ 0 & B \end{pmatrix} \;\ifnum\currentgrouptype=16 \middle\fi|\; A\in \GL_a, B\in \GL_{n-a}\right\}$,
  \item $\overline{\mathrm{P}}_I=\left\{ \begin{pmatrix} A & 0\\ * & B \end{pmatrix} \;\ifnum\currentgrouptype=16 \middle\fi|\; A\in \GL_a, B\in \GL_{n-a}\right\}$, and
  \item $\mathrm{L}_I=\left\{ \begin{pmatrix} A & 0\\ 0 & B \end{pmatrix} \;\ifnum\currentgrouptype=16 \middle\fi|\; A\in \GL_a, B\in \GL_{n-a}\right\}$.
\end{itemize}
\end{example}

\subsection{The generalized Bruhat decomposition}\label{generalized-Bruhat-decomposition}
Let the notation be as in the previous subsection. We first recall the notion of generalized Bruhat decomposition.
The double cosets $\mathrm{P}_J \backslash \mathrm{G}/\mathrm{P}_I$ can be described in terms of certain Weyl group elements. When $\mathrm{G}=\GL_{2n}$, $\mathrm{P}_I$ is the (standard) maximal parabolic with two $n\times n$ blocks, and $\mathrm{P}_J=\mathrm{P}_I$, we describe these elements explicitly in terms of the group of permutations $S_{2n}$ acting on $\{1,\dots, 2n\}$.

Recall that $S$ is the set of simple reflections in $W$ corresponding to the set $\Delta$ of simple roots of $T$. The elements of $S$ generate $W$, and we call the \emph{length} of an element in $w \in W$ the smallest number $\ell$ such that $w$ can be written as $w = s_{i_1}\dotsm s_{i_\ell}$ with $s_i \in S$. We denote the length of $w$ by $\ell(w)$. We let $w_0$ be the longest element of $W$; it has order $2$.

The Bruhat decomposition \cite[Thm. 5.15]{borel-tits} is
\[ \mathrm{G} = \coprod_{w \in W} \mathrm{B} w \mathrm{B} \,, \]
and there is also a generalized form \cite[Cor. 5.20]{borel-tits}
\[ \mathrm{G} = \coprod_{w \in W_J \backslash W / W_I} \mathrm{P}_J w \mathrm{P}_I \,. \]

We will need to compute these double coset representatives in the case where $\mathrm{G}=\GL_{2n}$, $I = J =S-\{s_{n} \}$ and $\mathrm{P}_I$ is the corresponding maximal parabolic described above. To do this, we introduce the following lemma.

\begin{lemma}\label{lemma:double-coset-GL}
  Let $L\colonequals S_n\times S_n$ be the subgroup of $K=S_{2n}$  such that the first copy of $S_n$ permutes the set $\{1,\dotsc, n\}$ and the second copy of $S_n$ permutes the set $\{n+1,\dotsc, 2n\}$.
  Then the double coset space $L\backslash K /L$ contains $n+1$ elements.
  A set of representatives is
  \[ \sigma_k = \prod_{i=1}^k (i,n+i), \quad 0 \leq k \leq n. \]
\end{lemma}
\begin{proof}%
  Two permutations $\sigma,\sigma' \in K$ are in the same coset for the right multiplication by $L$ if and only if $\{\sigma(1),\dotsc,\sigma(n)\} = \{\sigma'(1),\dotsc,\sigma'(n)\}$.
Thus, we can choose the following representatives for $K/L$:
\[ \prod_{i=1}^k (a_i,b_i), \quad 0 \leq k \leq n,\, 1 \leq a_1 < \dotsb < a_k \leq n,\, n+1 \leq b_1 < \dotsb < b_k \leq 2n. \]
Now we consider the action of $L$ on $K/L$ by left multiplication.
Two representatives $\prod_{i=1}^{k_1} (a_i,b_i)$ and $\prod_{i=1}^{k_2} (a_i,b_i)$ are in the same orbit if and only if $k_1=k_2$.
This yields the desired set of representatives for $L\backslash K /L$.
\end{proof}

\begin{example}\label{GL_n example}
  Let $\mathrm{G}=\GL_{2n}$, $\mathrm{T}=\mathrm{D}_{2n}$. Then we know that $W\cong S_{2n}$, $\Delta=\{\chi_{i,i+1} \mid 1\leq 1<2n\}$ and $S=\{s_{\alpha} \mid \alpha=1,\ldots, 2n-1\}$. We take $I=J=S-\{s_n\}$. Then in Example \ref{GL_n example part 1}, we substitute $n$ by $2n$ and we let $a=n$. We obtain:
\begin{itemize}
\item $W_I=\langle s_i \mid n\neq i<2n\rangle\cong S_n\times S_{n}$,
\item $W_I\backslash W/W_I \cong (S_n\times S_n)\backslash S_{2n}/ (S_n\times  S_n)\simeq \left\{\prod_{i=1}^k (i,n+i) \;\ifnum\currentgrouptype=16 \middle\fi|\; 0 \leq k \leq n \right\}$.
\end{itemize}
\end{example}

\subsection{Some results on double cosets}
We will now state some general facts about double cosets that we will need.
These results are most naturally stated using an alternative form of the (generalized) Bruhat decomposition
\[ \mathrm{G} = \coprod_{w \in W} \overline{\mathrm{B}} w \mathrm{B}, \]
\[ \mathrm{G} = \coprod_{w \in W_J \backslash W / W_I} \overline{\mathrm{P}}_J w \mathrm{P}_I \,, \]
which can be obtained from the decompositions mentioned above using the identities
$\overline{\mathrm{B}} = w_0 \mathrm{B} w_0$, $\overline{\mathrm{P}}_J = w_0 \mathrm{P}_{w_{0}Jw_{0}} w_0$ and $W_{w_{0}Jw_{0}}=w_{0}W_{J}w_{0}$. We write $\overline{\mathrm{N}}_{I}$ for the unipotent radical of $\overline{\mathrm{P}}_{I}$.

\begin{lemma} \label{BwPcover}
For any $w \in W$,
\[ \overline{\mathrm{B}} w \mathrm{P}_I \subseteq w \overline{\mathrm{B}} \mathrm{P}_I = w \overline{\mathrm{P}}_I \mathrm{P}_I \,. \]
In particular, translates of $\overline{\mathrm{P}}_I \mathrm{P}_I$ cover $\mathrm{G}$.
\end{lemma}
\begin{proof}
By \cite[Thm.~5.15]{borel-tits},
\[ \overline{\mathrm{B}}w\mathrm{B} = (\overline{\mathrm{B}} \cap w\overline{\mathrm{B}}w^{-1}) w\mathrm{B} \subseteq \overline{\mathrm{B}}w\mathrm{B} \cap w\overline{\mathrm{B}}\mathrm{B} \subseteq w \overline{\mathrm{B}}\mathrm{B} \,. \]
Multiplying on the right by $\mathrm{P}_I$ gives $\overline{\mathrm{B}} w \mathrm{P}_I \subseteq w \overline{\mathrm{B}} \mathrm{P}_I$.
To see that $\overline{\mathrm{B}} \mathrm{P}_I = \overline{\mathrm{P}}_I \mathrm{P}_I$, observe that
\[ \overline{\mathrm{P}}_I \mathrm{P}_I = \overline{\mathrm{N}}_I \mathrm{M}_I \mathrm{P}_I = \overline{\mathrm{N}}_I \mathrm{P}_I \subseteq \overline{\mathrm{B}} \mathrm{P}_I \subseteq \overline{\mathrm{P}}_I \mathrm{P}_I \,. \qedhere \]
\end{proof}

\begin{lemma} \label{stratum dim matches group dim}
For any $w \in W$,
\[ \dim w \overline{\mathrm{P}}_I w^{-1} \cap \overline{\mathrm{N}}_I = \dim \overline{\mathrm{P}}_I w \mathrm{P}_I / \mathrm{P}_I \,. \]
\end{lemma}
\begin{proof}
  The intersection $w\overline{\mathrm{P}}_I w^{-1} \cap \overline{\mathrm{N}}_I$ is a unipotent
group whose set of roots is
\[ w(\Phi^- \cup \Phi_I) \cap (\Phi^- \setminus \Phi_I) = w(\Phi^- \cup \Phi_I) \setminus (\Phi^+ \cup \Phi_I) \,. \]
We have
\begin{IEEEeqnarray*}{rCl}
  \dim \overline{\mathrm{P}}_I w \mathrm{P}_I/\mathrm{P}_I & = & \dim \overline{\mathrm{P}}_I - \dim (\overline{\mathrm{P}}_I \cap w\mathrm{P}_Iw^{-1}) \\ & = & \#((\Phi^- \cup \Phi_I) \setminus w(\Phi^+ \cup \Phi_I)) \\ & = & \#((\Phi^+ \cup \Phi_I) \setminus w(\Phi^- \cup \Phi_I)) \,.
\end{IEEEeqnarray*}
Since $\#(\Phi^+ \cup \Phi_I) = \#(w(\Phi^- \cup \Phi_I))$,
\[ \# \left(w(\Phi^- \cup \Phi_I) \setminus (\Phi^+ \cup \Phi_I)\right) =  \#\left((\Phi^+ \cup \Phi_I) \setminus w(\Phi^- \cup \Phi_I)\right) \,. \qedhere \]
\end{proof}

\begin{remark}\label{p vs p opp} There is a further reason for stating our results in this fashion. We think of $\Flr_{\mathrm{G},I}\colonequals \mathrm{G}/\mathrm{P}_I$ as the flag variety whose associated adic space receives a Hodge--Tate period morphism from a perfectoid Shimura variety (say, of Hodge type, with group split over $\Q_p$). In this scenario, $\mathrm{P}_{I}$ is a parabolic associated with the Hodge--Tate filtration (which determines it up to conjugacy). The ``anti-canonical'' tower of the Shimura variety will live on the Shimura variety of level structure $\overline{\mathrm{P}}_{I}(\Z_p)$ (or a conjugate of it), since it is supposed to parametrize complements of the canonical subgroup,
which split the Hodge--Tate filtration. Thus, to study how the perfectoid structure of the anti-canonical tower spreads out to the whole Shimura variety (either at full infinite level, or some intermediate levels), one is led to studying the $\overline{\mathrm{P}}_{I}$-orbits of $\Flr_{\mathrm{G},I}$. In the cases of interest in this paper, it turns out $\overline{\mathrm{P}}_{I}$ is conjugate to $\mathrm{P}_{I}$, so one can define the anti-canonical tower using $\mathrm{P}_{I}$. This is what we have done in this paper; it has the advantage of matching with \cite{scholze-galois}.
\end{remark}

\medskip
With this said, we will state the following direct consequences of Lemma \ref{BwPcover} and Lemma \ref{stratum dim matches group dim}.

\begin{cor}\label{key properties of stratification}
Assume that $I$ is such that $w_{0}Iw_{0}=I$ and let $w\in W$. Then $\mathrm{B}w\mathrm{P}_{I} \subseteq ww_{0}\mathrm{P}_{I}w_{0}\mathrm{P}_{I}$ and $\dim w\mathrm{P}_{I}w^{-1}\cap \mathrm{N}_{I} = \dim \mathrm{P}_{I}ww_{0}\mathrm{P}_{I}/\mathrm{P}_{I}$. In particular, Weyl group translates of $\mathrm{P}_{I}w_{0}\mathrm{P}_{I}$ cover $\mathrm{G}$.
\end{cor}

\begin{proof}
We have
$$\mathrm{B}w\mathrm{P}_{I} = w_{0}\overline{\mathrm{B}}w_{0}w\mathrm{P}_{I} \subseteq w\overline{\mathrm{P}}_{I}\mathrm{P}_{I} = ww_{0}\mathrm{P}_{I}w_{0}\mathrm{P}_{I}$$
by Lemma \ref{BwPcover}, proving the first part. For the second part, note that
$$ w\mathrm{P}_{I}w^{-1} \cap \mathrm{N}_{I} = w_{0}\left( w_{0}ww_{0}\overline{\mathrm{P}}_{I}w_{0}w^{-1}w_{0} \cap \overline{\mathrm{N}}_{I} \right) w_{0}; $$
$$ \mathrm{P}_{I}ww_{0}\mathrm{P}_{I}/\mathrm{P}_{I} = w_{0}\left( \overline{\mathrm{P}}_{I}w_{0}ww_{0}\mathrm{P}_{I}/\mathrm{P}_{I} \right), $$
and use Lemma \ref{stratum dim matches group dim}. The last statement follows from the first and the Bruhat decomposition.
\end{proof}

As we alluded to above, the generalized Bruhat decomposition induces a decomposition of the flag variety $\Flr_{\mathrm{G},I}= \mathrm{G}/\mathrm{P}_I$ into locally closed subvarieties, which we loosely refer to as (generalized) \emph{Schubert cells}.
For $w \in W_I \backslash W / W_I$ (resp., $w \in W / W_I$), we define
$\Flr_{\mathrm{G},I}^{w} \colonequals \mathrm{P}_I w \mathrm{P}_I / \mathrm{P}_I$
to be the cells of the decomposition
\[
\Flr_{\mathrm{G},I}= \bigsqcup_{w\in W_I\backslash W/W_I}  \Flr_{\mathrm{G},I}^w \,.
\]
The cells $\Flr_{\mathrm{G},I}^{w}$
are locally closed in $\Flr_{\mathrm{G},I}$, and $\Flr_{\mathrm{G},I}^{w_0}$
is open in $\Flr_{\mathrm{G},I}$.

\begin{example}\label{dimension of Schubert cells - algebraic}
Set $\mathrm{G}=\GL_{2n}$ and $I=S-\{s_n\}$; note that $w_{0}Iw_{0}=I$.
In this case, $\Flr_{\mathrm{G},I}$ can be identified
with $\mathrm{Gr}(n, 2n)$.
Set $U_0 \colonequals \Q_p^n \oplus 0 \subset \Q_p^{2n}$.
If $w$ is the product of $\tau(w)$ transpositions
of the form $(i,n+i)$ for $i\in \{1,\dots, n\}$, then we can describe explicitly
\[
  \Flr^w_{\mathrm{G},I}(R) = \{U\in \mathrm{Gr}(n, 2n)(R) \mid \rank_R(U \cap U_{0,R}) = n-\tau(w)\},
\]
for a ${\mathbb Q}_p$-algebra $R$.
From this, one easily sees the closure relations between these Schubert cells:
\[
  \overline{\Flr^w_{\mathrm{G},I}}=\sqcup_{\tau(w')\le \tau(w)}\Flr^{w'}_{\mathrm{G},I}.
\]
We claim that
\[
\dim \Flr_{\mathrm{G},I}^w = \tau(w)(2n-\tau(w)).
\]
Projection onto the last $n$ coordinates induces a surjection
\[
\Flr_{\mathrm{G},I}^w\to \mathrm{Gr}(\tau(w), n)
\]
Each fiber of this map can be identified with an open Schubert cell inside $\mathrm{Gr}(n,n+\tau(w))$.
Thus,
\[
\dim\Flr_{\mathrm{G},I}^w = \tau(w) (n-\tau(w)) + n \tau(w) = \tau(w)(2n-\tau(w)) \,.
\]
\end{example}

\subsection{The Bruhat stratification on $\mathscr{F}\ell_{G,\mu}$}\label{bruhat stratification}
We go back to considering the case of the quasi-split unitary
similitude group $\widetilde{G}$ over ${\mathbb Q}$. Recall that $G$ is the corresponding unitary group and that
$\mathscr{F}\!\ell_{\widetilde{G},\mu} \simeq \mathscr{F}\!\ell_{G,\mu} \colonequals (G/P_{\mu}\otimes_{{\mathbb Q}}C)^{\mathrm{ad}}$.
Recall that we are considering the right action of $G({\mathbb Q}_p)$ on $\mathscr{F}\!\ell_{G,\mu}$
that is the inverse of the usual left action considered above.
Recall that $p$ splits completely in $F$ and thus we have an isomorphism
\[
G({\mathbb Q}_p)\simeq \prod_{\mathfrak{p}} \GL_{2n}({\mathbb Q}_p),
\]
where $\mathfrak{p}$ runs over primes of $F$ dividing $p$ that are induced by $\iota_{\mathfrak{p}}\colon F\hookrightarrow \bar{{\mathbb Q}}_p$ with $\iota_{\mathfrak{p}}\in \Psi$.
Given a prime $\mathfrak{p}$ as above, write  $W_{\mathfrak{p}}$ for the Weyl group of $\GL_{2n}/F_{\mathfrak{p}} = {\mathbb Q}_p$ and $W$
for the Weyl group of $G/{\mathbb Q}_p$; we write $w=(w_{\mathfrak{p}})$ for elements in $W=\prod_{\mathfrak{p}}W_{\mathfrak{p}}$. We let $I$ correspond to the maximal parabolic $P_{\mu}$. We have
\[
W_I\backslash W/W_I = \prod_{\mathfrak{p}\mid p, \iota_{\mathfrak{p}}\in \Psi} W_{\mathfrak{p}, I}\backslash W_{\mathfrak{p}} / W_{\mathfrak{p},I},
\]
where each term on the right-hand side is as in Example~\ref{GL_n example}. The generalized Bruhat decomposition gives the decomposition of $\mathscr{F}\!\ell_{G,\mu}$ into $P_\mu({\mathbb Q}_p)$-orbits
\[
\mathscr{F}\!\ell_{G,\mu} = \bigsqcup_{w\in W_I\backslash W/W_I} \mathscr{F}\!\ell^w_{G,\mu},
\]
by analytifying the corresponding algebraic stratification.
By \cite[Lem.~1.8.6.ii)]{huber-etale}, $\dim \mathscr{F}\!\ell^w_{G,\mu} = \dim \Flr^w_{G,\mu}$.
Example~\ref{dimension of Schubert cells - algebraic} gives the following concrete description of the preimages of the Schubert cells in ${\mathcal X}_{\widetilde{\mathbf{1}}}$ under $\pi_{\mathrm{HT}}$. We remark that each $\mathscr{F}\!\ell_{G,\mu}^{w}$ is partially proper, so it suffices to describe the geometric rank $1$ points of the preimage.

\begin{lemma}\label{moduli description of Schubert cells} Let $D$ be a complete algebraically closed extension of $C$ and let $x$ be a $\Spa(D,{\mathcal O}_D)$-point of ${\mathcal X}_{\widetilde{\mathbf{1}}}$, with corresponding abelian variety $A/D$ and trivialization $\alpha$ of $T_{p}A$. Then, for every $\mathfrak{p}$ as above, we may consider the intersection $U_{A,\mathfrak{p}}$ of the $\mathfrak{p}$-part of the Hodge--Tate filtration
\[
(\Lie A)(1)^{\iota_{\mathfrak{p}}}\subset (T_{\mathfrak{p}}A\otimes_{{\mathbb Z}_p}D)^{\iota_{\mathfrak{p}}} \xrightarrow{\sim} D^{2n}
\]
with the canonical line
\[
U_{0,D}\colonequals D^n \oplus 0 \subset D^{2n}.
\]
If we restrict $\pi_{\mathrm{HT}}$ to  ${\mathcal X}_{\widetilde{\mathbf{1}}}$,
then the preimage of the Schubert cell $\mathscr{F}\!\ell^w_{G,\mu}$ is the relatively partially proper locus whose $\Spa(D,{\mathcal O}_D)$-points are precisely those for which $U_{A,\mathfrak{p}}$ has dimension $n-\tau(w_\mathfrak{p})$ for every $\mathfrak{p}$.
\end{lemma}

\begin{remark} \leavevmode
\begin{enumerate}
\item The open Schubert cell $\mathscr{F}\!\ell_{G,\mu}^{w_{0}}$ is the locus denoted by $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}$ in subsection \ref{hodgetatemapsection}, and hence
contains the image under $\pi_{\mathrm{HT}}$ of the anticanonical locus at level $\widetilde{\mathbf{1}}$.

\item The canonical subspace is the closed stratum $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{id}}$. A $\Spa(D,{\mathcal O}_D)$-point of ${\mathcal X}^{gd}_{\widetilde{\mathbf{1}}}$, with corresponding abelian variety $A/D$ and trivialization $\alpha \colon T_{p}A \to {\mathcal O}_{F}^{2n[F:{\mathbb Q}]}$, is in the preimage of $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{id}}$ if and only if $A$ is ordinary and
\[
\alpha^{-1}({\mathcal O}_{F}^{n[F:{\mathbb Q}]}\oplus 0)
\]
is the canonical subgroup of $A[p^{\infty}]$.

\end{enumerate}
\end{remark}

\subsection{An open cover of $\mathscr{F}\!\ell_{G,\mu}$}\label{open cover of flag variety}

We also consider an open cover of $\mathscr{F}\!\ell_{G,\mu}$ related
to the Bruhat stratification. In particular,
we will consider translates of the open cell $\mathscr{F}\!\ell_{G,\mu}^{w_0}$ by elements of $N_G(T)$.
These translates cover $\mathscr{F}\!\ell_{G,\mu}$ by Lemma \ref{BwPcover}.
The set of translates is in bijection with $W/W_I$.
The key result that relates this open cover with the Bruhat stratification
is Lemma~\ref{finding a J}.

Note that we have the natural projection map $\delta\colon W/W_I\to W_I\backslash W/W_I.$

\begin{remark}\label{coset representatives}
We can give a concrete description of $W/W_I $. First, we have $W/W_I = \prod_{\mathfrak{p}} W_{\mathfrak{p}}/W_{\mathfrak{p},I}$,
where the product runs over primes $\mathfrak{p}\mid p$ of $F$ such that $\iota_{\mathfrak{p}}\in \Psi$.
Each $W_{\mathfrak{p}}/W_{\mathfrak{p},I}$ can be identified with the set $\Sigma_{\mathfrak{p}}$
of cardinality $n$ subsets $J_{\mathfrak{p}}$ of $\{1,2,\dots,2n\}$. (This identification
sends a permutation $\sigma\in S_{2n}\simeq W_{\mathfrak{p}}$
to the subset $\{\sigma(1),\dots,\sigma(n)\} \subset \{1,2,\dots,2n\}$.)
We let $\Sigma = \prod_{\mathfrak{p}} \Sigma_{\mathfrak{p}}$, naturally  identified
with $W/W_I$.

As in the proof of Lemma~\ref{lemma:double-coset-GL}, we can use this concrete description to write down a set of representatives
for $W/W_I$. Set $J_{\mathfrak{p}}\colonequals J_{\mathfrak{p},1}\sqcup J_{\mathfrak{p}, 2}$,
with $J_{\mathfrak{p},1}\subseteq \{1,\dots,n\}$ and $J_{\mathfrak{p},2}\subseteq \{n+1,\dots,2n\}$. We let $w_{J_{\mathfrak{p}}}$ fix $J_{\mathfrak{p},1}$
elementwise, swap $\{1,\dots,n\}\setminus J_{\mathfrak{p},1}$ and $J_{\mathfrak{p},2}$, and fix $\{n+1,\dots,2n\} \setminus J_{\mathfrak{p},2}$
elementwise; it follows that $w_{J_{\mathfrak{p}}}(\{1,\dots,n\})=J_{\mathfrak{p}}$. We set $w_{J}\colonequals (w_{J_{\mathfrak{p}}})_{\mathfrak{p}}$. This coset representative has the property that $w_J^2=\mathrm{id}$.
\end{remark}

Let $e_1,\dots e_{2n}$ denote the standard basis of $C^{2n}$ and let
$U_{J_{\mathfrak{p}}}\subset {\mathbb Q}_p^{2n}$ be the subspace spanned by the $e_i$ with $i\in J_{\mathfrak{p}}$. Let $\mathrm{Gr}(n,2n)^{J_{\mathfrak{p}}}$ be the
open subspace defined by
\[
\mathrm{Gr}(n,2n)^{J_{\mathfrak{p}}}(R)=\{U\in \mathrm{Gr}(n,2n)(R)\mid U\cap U_{J_{\mathfrak{p},R}}=0\}
\]
for a ${\mathbb Q}_p$-algebra $R$. Let $\mathscr{G}\!r(n,2n)^{J_{\mathfrak{p}}}$ be the associated adic space. Define
\[
\mathscr{F}\!\ell_{G,\mu}^J = \prod_{\mathfrak{p}} \mathscr{G}\!r(n,2n)^{J_{\mathfrak{p}}},
\]
an open subset of $\mathscr{F}\!\ell_{G,\mu}$. Equivalently,
\[ \mathscr{F}\!\ell_{G,\mu}^J = \mathscr{F}\!\ell_{G,\mu}^{w_0} \cdot w_J^{-1}. \]
We have the open cover
\[
\mathscr{F}\!\ell_{G,\mu}=\bigcup_{J\in \Sigma}\mathscr{F}\!\ell_{G,\mu}^J.
\]

\begin{lemma}\label{finding a J} Let $w\in W_I\backslash W/W_I$ and $x\in \mathscr{F}\!\ell_{G,\mu}^w$ be a point. Then there exists
$J \in \delta^{-1}(ww_0)$ such that $x \cdot N_0\subset \mathscr{F}\!\ell_{G,\mu}^J$.
\end{lemma}
\begin{proof}
Right multiplication by $w_0$ is a well-defined automorphism of $W_I \backslash W / W_I$ since $w_0 W_I w_0 = W_I$.

By partial properness it suffices to prove the lemma for geometric rank $1$ points; by base change it then suffices to restrict to the case of $(C,{\mathcal O}_{C})$-points, so we only need to consider classical rigid points. Write $B$ for the standard Borel of $G$ in this proof only. In Remark \ref{coset representatives}, the $w_J$ were chosen to be
coset representatives of $W/W_I$. Since $\mathscr{F}\!\ell_{G,I}^{w}=P_{\mu}wP_{\mu}/P_{\mu}$, we can find $w_{1}\in \delta^{-1}(w)$ such that $x\in Bw_{1}P_{\mu}/P_{\mu}$, which implies  that $x \cdot N_{0} \subseteq w_{1}w_{0}P_{\mu}w_{0}P_{\mu}/P_{\mu}=\mathscr{F}\!\ell_{G,\mu}^{w_{0}} \cdot (w_{1}w_{0})^{-1}$ by Corollary \ref{key properties of stratification}.
\end{proof}

Of course, the proof shows that the orbit of $x$ under the entire Borel $B$ is contained in $\mathscr{F}\!\ell_{G,\mu}^{J}$; we have chosen the above formulation since it is the precise statement we will need later. Note also that $\mathscr{F}\!\ell^{\mathrm{nc}}_{G,\mu}= \mathscr{F}\!\ell^J_{G,\mu}$ for $J=\left(\{1,2,\dots,n\}_{\mathfrak{p}}\right)$.

\subsection{Perfectoid strata at intermediate levels}\label{perfectoid strata at intermediate levels}
Choose some $J = (J_{\mathfrak{p}})$ as above, with corresponding Weyl group element $w_J$.
For any integer $m\geq 1$, define the open subgroups
\[
\widetilde{\Gamma}_{1,J}(p^m)\colonequals \left\{(g,r)\in \widetilde{G}({\mathbb Z}_p)\mid (g,r)\in \widetilde{\Gamma}_1(p^m), w_{J_\mathfrak{p}}^{-1} g_\mathfrak{p} w_{J_\mathfrak{p}}\equiv \left(\begin{array}{cc} * & *\\ 0 & * \end{array}\right) \bmod p^m \right\}. \]
and the closed subgroup
$$ \widetilde{N}_{0,J} = \bigcap_{m\geq 0}\widetilde{\Gamma}_{1,J}(p^m). $$
For $J=(\{1, 2, \dots, n\}_{\mathfrak{p}})$, $w_{J}=\mathrm{id}$, so $\widetilde{N}_{0,J}=\widetilde{N}_{0}$. Note that in general, $\widetilde{N}_{0,J}$ is a subgroup of $\widetilde{N}_{0}$ and naturally a $\Z_p$-submodule of $\widetilde{N}_{0}$.
\begin{lemma}\label{ranks} We have $\rank_{{\mathbb Z}_p} \widetilde{N}_{0,J} = \dim \mathscr{F}\!\ell^{w_J w_0}_{G,\mu}$. Moreover, $\widetilde{N}_{0,J}$ is a saturated $\Z_p$-submodule of $\widetilde{N}_{0}$, so $\rank_{{\mathbb Z}_p} \widetilde{N}_{0}/\widetilde{N}_{0,J} = n^{2}\cdot f- \dim \mathscr{F}\!\ell^{w_J w_0}_{G,\mu}$.
\end{lemma}
\begin{proof}
By definition, we have $\widetilde{N}_{0,J}= \left( \widetilde{N} \cap w_{J}\widetilde{P}_{\mu}w_{J}^{-1} \right)(\Z_p)$ (for the natural integral model of the right-hand side inside $\widetilde{G}$) and  $\widetilde{N} \cap w_{J}\widetilde{P}_{\mu}w_{J}^{-1}$ is product of unipotent subgroups $U_{\alpha}$ for a certain subset (depending on $J$) of roots $\alpha$ contained in $\widetilde{N}$. This shows that $\widetilde{N}_{0,J}$ is saturated in $\widetilde{N}_{0}$ and that $\rank_{{\mathbb Z}_p} \widetilde{N}_{0,J} = \dim \widetilde{N} \cap w_{J}\widetilde{P}_{\mu}w_{J}^{-1}$. Thus, by Corollary \ref{key properties of stratification}, $\rank_{{\mathbb Z}_p} \widetilde{N}_{0,J} = \dim \mathscr{F}\!\ell_{G,\mu}^{w_{J}w_{0}}$ as desired. The last statement then follows directly from the first two statements.
\end{proof}

\noindent Let $\widetilde{H} \subseteq \widetilde{P}_{\mu,0}$ be a closed subgroup. The Hodge--Tate period morphism induces the following composition
\[
\pi_{\mathrm{HT}/\widetilde{H}}\colon ({\mathcal X}^*_{\widetilde{H}})_{\mathrm{\acute{e}t}} \to
|{\mathcal X}^*_{\widetilde{H}}|\xrightarrow{\sim} |{\mathcal X}^*_{\widetilde{\mathbf{1}}}|/ \widetilde{H} \to |\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H},
\]
which is a morphism of sites. Note that the stratification $\mathscr{F}\!\ell_{G,\mu} = \sqcup_{w\in W_I \backslash W/W_I} \mathscr{F}\!\ell^w_{G,\mu}$
descends to the quotient $|\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H}$ since $\widetilde{H} \subseteq \widetilde{P}_{\mu,0}$. In particular, the open Schubert cell $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}$
descends to an open stratum $|\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}|/\widetilde{H}$ in $|\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H}$, and we set
$$ {\mathcal X}_{\widetilde{H}}^{\ast,\mathrm{nc}} \colonequals \pi_{\mathrm{HT}/\widetilde{H}}^{-1}\left(|\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}|/\widetilde{H} \right). $$
We will be most interested in the subgroups $\widetilde{N}_{0,J}\subseteq \widetilde{P}_{\mu,0}$. In this case, for any closed subgroup $\widetilde{H}\subseteq \widetilde{N}_{0,J}$,
$|\mathscr{F}\!\ell_{G,\mu}^{J}|/\widetilde{H}$ is an open subset of $|\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H}$.
We put
\[
{\mathcal X}^{*,J}_{\widetilde{H}}\colonequals
\pi_{\mathrm{HT}/\widetilde{H}}^{-1}\left(|\mathscr{F}\!\ell_{G,\mu}^{J}|/\widetilde{H}\right).
\]
This is an open sub-diamond of ${\mathcal X}^*_{\widetilde{H}}$. The main result of this section is that it is a perfectoid space.

We prove this in two steps: first, we show the result for the case $J= (\{1,2,\dots,n\}_{\mathfrak{p}})$, when ${\mathcal X}^{*,J}_{\widetilde{H}} = {\mathcal X}^{*,\mathrm{nc}}_{\widetilde{H}}$. This can be done more generally for all closed $\widetilde{H} \subseteq \widetilde{P}_{\mu,0}$ by adapting an argument of Ludwig from the setting
of modular curves~\cite[Sect. 3.4]{ludwig}.
For a general $J$, we use the action of $w_J$ to translate the
perfectoid structure and deduce the result in general from the result for the non-canonical locus. We use freely the notation from subsection \ref{hodgetatemapsection}, in particular the element $\gamma \in G(\Q_p)$ considered there.

\begin{thm}\label{perfectoid non-canonical stratum} Let $\widetilde{H}\subseteq \widetilde{P}_{\mu,0}$ be a closed subgroup. Then the diamond
  ${\mathcal X}^{*,\mathrm{nc}}_{\widetilde{H}}$ is a perfectoid space. More precisely, $|{\mathcal X}^{*,\mathrm{nc}}_{\widetilde{H}}|$ is covered by the increasing union of quasicompact open subsets $|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\gamma^{k}/\widetilde{H}$ for $k \in {\mathbb Z}_{\geq 0}$ (and sufficiently small $\epsilon >0$), and the corresponding spatial diamonds are affinoid perfectoid with strongly Zariski closed boundary.
\end{thm}

\begin{proof}
We consider the projection map
\[
{\mathcal X}^{*} _{\widetilde{\mathbf{1}}}\to {\mathcal X}^*_{\widetilde{H}},
\]
which by Lemma \ref{exhibiting a diamond as a quotient} identifies $|{\mathcal X}^{*,\mathrm{nc}}_{\widetilde{H}}|$ with $|{\mathcal X}^{*,\mathrm{nc}}_{\widetilde{\mathbf{1}}}|/\widetilde{H}$. By Corollary \ref{expanding the anticanonical locus}, the open subdiamonds corresponding to the open sets $|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\gamma^{k}/\widetilde{H}$ are increasing and cover $|{\mathcal X}^{*,\mathrm{nc}}_{\widetilde{H}}|$. Note here that $|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\gamma^{k}$ is $\gamma^{-k}\widetilde{P}_{\mu,0}\gamma^{k}$-stable and that $\gamma^{-k}\widetilde{P}_{\mu,0}\gamma^{k} \supseteq \widetilde{P}_{\mu,0} \supseteq \widetilde{H}$ (by direct computation), so this quotient makes sense. It remains to prove that these opens are affinoid perfectoid for all $k\geq 0$, with strongly Zariski closed boundary. On the level of topological spaces, we have an isomorphism
$$ \gamma^{-k} \colon |{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\cdot\gamma^{k}/\widetilde{H} \xrightarrow{\sim} |{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|/\gamma^{k}\widetilde{H}\gamma^{-k} $$
which is induced from an isomorphism
$$ \gamma^{-k} \colon {\mathcal X}^{\ast}_{\widetilde{H}} \xrightarrow{\sim} {\mathcal X}^{\ast}_{\gamma^{k} \widetilde{H} \gamma^{-k}}  $$
of diamonds. Since $\gamma^{k}\widetilde{H}\gamma^{-k} \subseteq \gamma^{k}\widetilde{P}_{\mu,0}\gamma^{-k} \subseteq \widetilde{P}_{\mu,0}$, ${\mathcal X}^{\ast}_{\gamma^{k} \widetilde{H} \gamma^{-k}}(\epsilon)_{a}$ is affinoid perfectoid with strongly Zariski closed boundary by Theorem \ref{anticanonical tower at intermediate levels 2} and we may conclude that the subdiamond of ${\mathcal X}^{*, \mathrm{nc}}_{\widetilde{H}}$ corresponding to the open subset $|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\gamma^{k}/\widetilde{H}$ is affinoid perfectoid with strongly Zariski closed boundary, as desired.
\end{proof}

We now consider the case of a general $J\in \Sigma$.

\begin{thm}\label{general perfectoid stratum}\leavevmode Let $\widetilde{H}\subseteq \widetilde{N}_{0,J}$ be a closed subgroup. Then the diamond
  ${\mathcal X}^{*,J}_{\widetilde{H}}$ is a perfectoid space. More precisely, $|{\mathcal X}^{*,J}_{\widetilde{H}}|$ is covered by the increasing union of quasicompact open subsets $|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1}/\widetilde{H}$ for $k \in {\mathbb Z}_{\geq 0}$ (and sufficiently small $\epsilon >0$), and the corresponding spatial diamonds are affinoid perfectoid with strongly Zariski closed boundary.
\end{thm}

\begin{proof} First, note that right multiplication by $w_{J}^{-1}$ induces an isomorphism of diamonds $ {\mathcal X}^{*,\mathrm{nc}}_{w_{J}^{-1}\widetilde{H} w_J} \xrightarrow{\sim} {\mathcal X}^{*,J}_{\widetilde{H}}$. To see this, note that right multiplication by $w_{J}^{-1}$ induces an isomorphism of the
diamonds ${\mathcal X}^*_{w_{J}^{-1}\widetilde{H} w_J}$ and ${\mathcal X}^{*}_{\widetilde{H}}$.
Now it remains to check that multiplication by $w_{J}^{-1}$ sends the $J$-non-canonical locus to the non-canonical locus.
This can be done on the level of topological spaces, thus after using Lemma~\ref{exhibiting a diamond as a quotient}
to identify $|{\mathcal X}^*_{\widetilde{H}}|$ with $|{\mathcal X}^*_{\widetilde{\mathbf{1}}}|/\widetilde{H}$. The claim can then be checked on the flag varieties (using equivariance of the Hodge--Tate period map), and so follows from the definitions. Moreover, this isomorphism identifies $|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\gamma^{k}/w_{J}^{-1}\widetilde{H} w_{J}$ with $|{\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1}/\widetilde{H}$. The theorem then follows from Theorem \ref{perfectoid non-canonical stratum}.
\end{proof}

\noindent We denote $\mathscr{F}\!\ell_{G,\mu}^{a}\cdot\gamma^{k}$ by $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}(k)$. We denote $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}(k)\cdot w_J^{-1}$ by $\mathscr{F}\!\ell_{G,\mu}^J(k)$.
Later, we will also need the following result.

\begin{lemma}\label{standard neighborhoods are stable} The open subset $\mathscr{F}\!\ell_{G,\mu}^J(k)\subset \mathscr{F}\!\ell_{G,\mu}$ is stable under the action of $\widetilde{N}_{0,J}$.
\end{lemma}

\begin{proof} By the definition of $\widetilde{N}_{0,J}$, it is enough to see that $\mathscr{F}\!\ell_{G,\mu}^J(k)$ is stable under $w_J P_{\mu,0}w_{J}^{-1}$ or equivalently that $\mathscr{F}\!\ell_{G,\mu}^{\mathrm{nc}}(k)$ is stable under $P_{\mu}({\mathbb Z}_p)$. As $\gamma^{-k}P_{\mu,0}\gamma^{k} \supseteq P_{\mu,0}$ this reduces us to the case $k=0$, which follows from an explicit computation.
\end{proof}

\section{Vanishing of compactly supported cohomology}\label{vanishing}

In this section we put the ingredients together and prove Theorem \ref{unified main theorem} in the imaginary CM case, which follows from the analogous theorem for our unitary similitude groups. The first subsection is devoted to reducing the vanishing theorem to a statement about the fibers of the Hodge--Tate period map (Theorem \ref{bound on higher direct images}), which is mostly formal using the machinery of \'etale cohomology of diamonds and our results from section \ref{diamonds and cohomology}. We then introduce a technical result about constructing invariant rational neighborhoods of orbits on affinoid adic spaces with a continuous action of a profinite group (Proposition \ref{rational neighborhood}), which we believe is important and interesting in its own right. We conclude by proving Theorem \ref{bound on higher direct images} using the results of section \ref{stratifications}, which finishes the proof of the vanishing theorem.

\subsection{The main result and first reductions}\label{subsect:first-reductions}

From now on, let $d\colonequals \dim {\mathcal X} = n^2\cdot [F:{\mathbb Q}]$ denote the dimension of our Shimura varieties. Our main theorem is:

\begin{thm}\label{main thm} Let $r\in {\mathbb Z}_{\geq 1}$ and let $\widetilde{K} \subseteq \widetilde{G}(\Z_p)$ be an open subgroup. If $i>d$, then
$$ \varinjlim_{m} H^{i}_{c}(X_{\widetilde{K} \cap \widetilde{\Gamma}_{1}(p^{m})}(\CC),{\mathbb Z}/p^{r}{\mathbb Z})=0.$$
\end{thm}

\noindent Here $H_{c}$ denotes compactly supported singular cohomology. A version for the Shimura varieties for $G$ follows immediately, since $H^{i}_{c}(X_{K \cap \Gamma_{1}(p^{m})}(\CC),{\mathbb Z}/p^{r}{\mathbb Z})$ is a direct summand of $H^{i}_{c}(X_{\widetilde{K} \cap \widetilde{\Gamma}_{1}(p^{m})}(\CC),{\mathbb Z}/p^{r}{\mathbb Z})$ compatibly with the transition maps. Here $K = \widetilde{K} \cap G(\Z_p)$. For the applications in this paper, the most important case is $\widetilde{K} = \widetilde{G}(\Z_p)$, and the reader would not lose anything by making this assumption in the proof. On the other hand, our proof allows us to treat general $\widetilde{K}$, so we have opted for this extra generality since it is not clear to us if the case of general $\widetilde{K}$ follows from the special case $\widetilde{K}=\widetilde{G}(\Z_p)$. We also remark that Theorem \ref{main thm} is false in general for usual cohomology; this fact is crucial for our strategy to remove the nilpotent ideal in section \ref{Borel-Serre}.

\begin{cor}\label{main cor}
Let $r\in {\mathbb Z}_{\geq 1}$ and let $K \subseteq G(\Z_p)$ be an open subgroup. If $i>d$, then
$$ \varinjlim_{m} H^{i}_{c}(X_{K \cap \Gamma_{1}(p^{m})}(\CC),{\mathbb Z}/p^{r}{\mathbb Z})=0.$$
\end{cor}

\noindent To prove Theorem \ref{main thm}, note first that it suffices to treat the case $r=1$ by the usual d\'evissage argument. Then, applying the usual string of comparison theorems (between singular cohomology and \'etale cohomology of schemes, and between \'etale cohomology of schemes and \'etale cohomology of adic spaces), we find that Theorem \ref{main thm} is equivalent to the statement that
$$ \varinjlim_{m} H^{i}_{\mathrm{\acute{e}t}}({\mathcal X}_{\widetilde{K} \cap \widetilde{\Gamma}_{1}(p^{m})}^{\ast},j_{!}{\mathbb F}_{p})=0 $$
for $i>d$. Here, and in the rest of this section, we write $j$ for any open immersion ${\mathcal U} \to {\mathcal V}$, where ${\mathcal V}$ is any locally spatial diamond that carries a quasi-pro-\'etale map ${\mathcal V} \to {\mathcal X}^{\ast}_{\widetilde{H}}$ for some closed subgroup $\widetilde{H} \subseteq \widetilde{G}(\Z_p)$, ${\mathcal U} = {\mathcal V} \times_{{\mathcal X}^{\ast}_{\widetilde{H}}}{\mathcal X}_{\widetilde{H}}$ and $j$ is the projection onto the first factor. To proceed from here, the primitive comparison theorem for torsion coefficients \cite[Thm. 3.13]{scholze-survey} gives us
$$ \varinjlim_{m} H^{i}_{\mathrm{\acute{e}t}}({\mathcal X}_{\widetilde{K} \cap \widetilde{\Gamma}_{1}(p^{m})}^{\ast},j_{!}{\mathbb F}_{p})^{a}\otimes_{{\mathbb F}_p}{\mathcal O}_C/p \cong \varinjlim_{m} H^{i}_{\mathrm{\acute{e}t}}({\mathcal X}_{\widetilde{K} \cap \widetilde{\Gamma}_{1}(p^{m})}^{\ast},j_{!}{\mathbb F}_{p}\otimes {\mathcal O}_{{\mathcal X}^{\ast}_{\widetilde{\Gamma}_{1}(p^{m})}}^{+}/p)^{a}. $$

We record the following (more convenient) descriptions of the sheaf appearing on the right-hand side.

\begin{lemma}\label{lower shriek and ideals}
Let $V$ be a rigid space over a nonarchimedean field $K/\Q_p$, or an affinoid perfectoid space over $K$. Let $Z\subseteq V$ be a Zariski closed subset of $V$ and let $U$ be the open complement. Write $j \colon U \hookrightarrow V$ for the open immersion and let ${\mathcal I}^{+}\subseteq {\mathcal O}_{V}^{+}$ be the subsheaf of functions which vanish on $Z$. Then we have natural isomorphisms
$$ (j_{!}{\mathbb F}_{p}) \otimes {\mathcal O}_{V}^{+}/p \cong {\mathcal I}^{+}/p \cong j_{!}({\mathcal O}_{U}^{+}/p). $$
\end{lemma}

\begin{proof}
We start with the first isomorphism. By applying the adjunctions for $j_{!}$ and $\otimes$, the natural map ${\mathbb F}_{p} \to {\mathcal O}_{U}^{+}/p = j^{\ast}({\mathcal I}^{+}/p)$ gives a map $(j_{!}{\mathbb F}_{p}) \otimes {\mathcal O}_{V}^{+}/p \to {\mathcal I}^{+}/p$. This is clearly an isomorphism over $U$, and on $Z$ all stalks on both sides are $0$, so it is an isomorphism on the whole of $V$. For the second isomorphism, adjunction gives a natural map $j_{!}({\mathcal O}_{U}^{+}/p) \to {\mathcal I}^{+}/p$, which is an isomorphism for the same reason as before.
\end{proof}

\noindent For later use, we also explicitly record the following fact, which is implicit in \cite[\S 4.1]{scholze-galois}.

\begin{prop}\label{strongly Zariski closed vanishing}
Let $V$ be an affinoid perfectoid space over a perfectoid field $(K,K^{+})$ over $\Q_p$ and let $Z\subseteq V$ be a strongly Zariski closed subset, with its induced structure of an affinoid perfectoid space. Set $j \colon U=V\setminus Z \hookrightarrow V$. Then $H^{i}_{\mathrm{\acute{e}t}}(V,j_{!}({\mathcal O}_{U}^{+}/p))^{a}=0$ for $i>0$.
\end{prop}

\begin{proof}
Let ${\mathcal I}^{+}\subseteq {\mathcal O}_{V}^{+}$ be the subsheaf of functions vanishing on $Z$. By Lemma \ref{lower shriek and ideals}, $j_{!}({\mathcal O}_{U}^{+}/p)\cong {\mathcal I}^{+}/p$. By the long exact sequence associated with
$$0 \to {\mathcal I}^{+} \to {\mathcal I}^{+} \to {\mathcal I}^{+}/p \to 0,$$
it suffices to show that $H^{i}_{\mathrm{\acute{e}t}}(V,{\mathcal I}^{+})^{a}=0$ for $i>0$. Since $Z\subseteq V$ is strongly Zariski closed, we have a short exact sequence
$$ 0 \to {\mathcal I}^{+a} \to {\mathcal O}^{+a}_{V} \to {\mathcal O}^{+a}_{Z} \to 0 $$
of almost sheaves on $V_{\mathrm{\acute{e}t}}$ by the definition and \cite[Lemma 2.2.9]{scholze-galois}. Taking the long exact sequence and using \cite[Proposition 7.13]{scholze-perfectoid}, we see that $H^{i}_{\mathrm{\acute{e}t}}(V,{\mathcal I}^{+})^{a}=0$ for $i>1$ and that $H^{1}_{\mathrm{\acute{e}t}}(V,{\mathcal I}^{+})^{a}$ is the cokernel of $H^{0}(V,{\mathcal O}^{+}_{V})^{a} \to H^{0}(Z,{\mathcal O}^{+}_{Z})^{a}$, which is $0$ since $Z\subseteq V$ is strongly Zariski closed.
\end{proof}

Keeping Lemma~\ref{lower shriek and ideals} in mind, we apply (the almost version of) Proposition \ref{invlimcoh} to get
$$  \varinjlim_{m} H^{i}_{\mathrm{\acute{e}t}}({\mathcal X}_{\widetilde{K} \cap \widetilde{\Gamma}_{1}(p^{m})}^{\ast},j_{!}({\mathcal O}_{{\mathcal X}_{\widetilde{K} \cap \widetilde{\Gamma}_{1}(p^{m})}}^{+}/p))^{a} \cong H^{i}_{\mathrm{\acute{e}t}}({\mathcal X}_{\widetilde{K} \cap \widetilde{N}_{0}}^{\ast},j_{!}({\mathcal O}_{{\mathcal X}_{\widetilde{K} \cap \widetilde{N}_{0}}}^{+}/p)^{a}), $$
where $({\mathcal O}_{{\mathcal X}_{\widetilde{K} \cap \widetilde{N}_{0}}}^{+}/p)^{a}$ is the almost sheaf on $({\mathcal X}_{\widetilde{K} \cap \widetilde{N}_{0}})_{\mathrm{\acute{e}t}}$ constructed in subsection \ref{structure sheaves}. Here we have implicitly used some results from subsections  \ref{structure sheaves} on the sheaves $({\mathcal O}^{+}/p)^{a}$, namely that $({\mathcal O}^{+}/p)^{a}$ is compatible with the usual construction on rigid spaces and that its construction commutes with pullbacks by quasi-pro-\'etale maps. Furthermore we have used Lemma \ref{shriekbasechange} and Proposition \ref{finite maps}. To avoid notational difficulties in the future we make the following convention: for any quasi-pro-\'etale ${\mathcal V} \to {\mathcal X}$ we write $({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}$ for the almost sheaf on $({\mathcal O}_{{\mathcal V}}^{+}/p)^{a}$ on ${\mathcal V}_{\mathrm{\acute{e}t}}$.
This is reasonable since, by the construction in subsection \ref{structure sheaves}, $({\mathcal O}_{{\mathcal V}}^{+}/p)^{a}$ is the pushfoward of the almost sheaf $({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}$ on ${\mathcal X}_{\mathrm{qpro\acute{e}t}}$ via the natural map ${\mathcal X}_{\mathrm{qpro\acute{e}t}} \to {\mathcal V}_{\mathrm{\acute{e}t}}$.

\medskip
To proceed from here, we will use the morphism
\[
\pi_{\mathrm{HT}/\widetilde{K} \cap \widetilde{N}_{0}} \colon \left({\mathcal X}^*_{\widetilde{K} \cap \widetilde{N}_{0}}\right)_{\mathrm{\acute{e}t}} \to |\mathscr{F}\!\ell_{G,\mu}|/(\widetilde{K} \cap \widetilde{N}_{0})
\]
from subsection \ref{perfectoid strata at intermediate levels}. We have a Leray spectral sequence
$$ E_{2}^{rs}=H^{r}(|\mathscr{F}\!\ell_{G,\mu}|/(\widetilde{K} \cap \widetilde{N}_{0}),R^{s}\pi_{\mathrm{HT}/\widetilde{K} \cap \widetilde{N}_{0},\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}) \implies H^{r+s}_{\mathrm{\acute{e}t}}({\mathcal X}_{\widetilde{K} \cap \widetilde{N}_{0}}^{\ast},j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}). $$
The key result in this section is then the following vanishing result for the stalks of $R^{i}\pi_{\mathrm{HT}/\widetilde{K} \cap \widetilde{N}_0,\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}$:

\begin{thm}\label{bound on higher direct images}
Let $w\in W_{I}\backslash W / W_{I}$ and let $x\in |\mathscr{F}\!\ell_{G,\mu}^{w}|/(\widetilde{K} \cap \widetilde{N}_{0})$. Then we have
$$ R^{i}\pi_{\mathrm{HT}/\widetilde{K} \cap \widetilde{N}_0,\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)_{x}^{a} = 0$$
for $i>d-\dim \mathscr{F}\!\ell_{G,\mu}^{w}$.
\end{thm}

Our main theorem follows rather quickly from Theorem \ref{bound on higher direct images}, using a bound on the cohomological dimension of spectral spaces due to Scheiderer.

\begin{proof}[Proof of Theorem \ref{main thm}]
By the Leray spectral sequence for $\pi_{\mathrm{HT}/\widetilde{K} \cap \widetilde{N}_{0}}$, it suffices to prove that $H^{r}(|\mathscr{F}\!\ell_{G,\mu}|/(\widetilde{K} \cap \widetilde{N}_{0}),R^{s}\pi_{\mathrm{HT}/\widetilde{K} \cap \widetilde{N}_{0},\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a})=0$ for $r+s>d$. Fix $r$ and assume that $s>d-r$. Let $S_{r}$ be the set of $w\in W_{I}\backslash W /W_{I}$ for which $\dim \mathscr{F}\!\ell^w_{G,\mu} < r$, and let $Y_{r}=\bigcup_{w\in S_{r}}\mathscr{F}\!\ell_{G,\mu}^{w}$. Since $\overline{\mathscr{F}\!\ell_{G,\mu}^{w}}= \sqcup_{w^{\prime}\leq w}\mathscr{F}\!\ell_{G,\mu}^{w^{\prime}}$ for any $w\in W_{I}\backslash W/W_{I}$, $Y_{r}$ is an $\widetilde{N}_{0}$-invariant Zariski closed subset of $\mathscr{F}\!\ell_{G,\mu}$ of dimension $<r$. By Proposition \ref{spectral quotient}, $|Y_{r}|/(\widetilde{K} \cap \widetilde{N}_{0}) \subseteq |\mathscr{F}\!\ell_{G,\mu}|/(\widetilde{K} \cap \widetilde{N}_{0})$ is a closed spectral subspace of dimension $<r$.

\medskip
We claim that ${\mathcal F}^{s} \colonequals R^{s}\pi_{\mathrm{HT}/\widetilde{K} \cap \widetilde{N}_0,\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}$ is supported on $|Y_{r}|/(\widetilde{K} \cap \widetilde{N}_{0})$. To see this, let $x\notin |Y_{r}|/(\widetilde{K} \cap \widetilde{N}_{0})$. Then $x\in |\mathscr{F}\!\ell_{G,\mu}^{w}|/(\widetilde{K} \cap \widetilde{N}_{0})$ for some $w$ with $\dim \mathscr{F}\!\ell_{G,\mu}^{w} \geq r$, so by Theorem \ref{bound on higher direct images}, $ {\mathcal F}_{x}^{s} = 0$ since $s>d-r\geq d-\dim \mathscr{F}\!\ell_{G,\mu}^{w}$. This proves that ${\mathcal F}^{s}$ is supported on $|Y_{r}|/(\widetilde{K} \cap \widetilde{N}_{0})$, and it then follows from \cite[Corollary 4.6]{scheiderer} that $H^{r}(|\mathscr{F}\!\ell_{G,\mu}|/(\widetilde{K} \cap \widetilde{N}_{0}),{\mathcal F}^{s})=H^{r}(|Y_{r}|/(\widetilde{K} \cap \widetilde{N}_{0}),{\mathcal F}^{s})=0$, as desired.
\end{proof}

\noindent The rest of this section is devoted to the proof of Theorem \ref{bound on higher direct images}. To conclude this section we state the following more general version of Theorem \ref{main thm}, which is a direct consequence of it.

\begin{cor}[to Theorem \ref{main thm}]
Let $r\in {\mathbb Z}_{\geq 1}$ and let $\widetilde{K}_{m} \subseteq \widetilde{\Gamma}_{1}(p^{m})$ be open subgroups for $m \geq 1$  with $K_{m+1}\subseteq K_{m}$ for all $m$. If $i>d$, then
$$ \varinjlim_{m} H^{i}_{c}(X_{\widetilde{K}_{m}}(\CC),{\mathbb Z}/p^{r}{\mathbb Z})=0.$$
\end{cor}

\subsection{Constructing invariant rational neighborhoods}\label{sec: invariant neighborhoods}

Before we prove Theorem \ref{bound on higher direct images}, we prove an important technical result on profinite group actions on affinoid adic spaces, which we believe is interesting in its own right.

\begin{prop}\label{rational neighborhood}
Let $Y = \Spa(A,A^+)$ be an affinoid adic space,
and let $H$ be a profinite group acting continuously on $A$.
Let $x \in Y$, and let $U \subset Y$ be an $H$-stable
open containing $x$.  Then there exists an $H$-stable open $V \subset U$
containing $x$ that is a rational subset of $Y$.
\end{prop}

\begin{lemma} \label{aoo-open}
Let $A$ be a Huber ring, and let $I=(a_0,...,a_n)$ be a finitely
generated open ideal of $A$.  Then the set $M$ of elements of the form
$\sum_{i=0}^n \lambda_i a_i$ with $\lambda_i \in A^{\circ \circ}$
is open in $A$.
\end{lemma}
\begin{proof}
Since $I$ is open, it contains an ideal of definition $J=(b_0,...,b_m)$
of some ring of definition of $A$.  For each $j \in \{0,...,m\}$,
we can write $b_j = \sum_{i=0}^n c_{ij} a_i$ for some $c_{ij} \in A$.
For some integer $\ell$,
$J^{\ell} c_{ij} \subseteq A^{\circ \circ}$ for all $i,j$.
Then $M \supseteq J^{\ell+1}$, which is open.
\end{proof}

\begin{cor} \label{open stabilizer}
Let $Y = \Spa(A,A^+)$ be an affinoid adic space,
and let $H$ be a profinite group acting continuously on $A$.
If $W \subset Y$ is a rational subset, then the stabilizer of $W$ is open in $H$.
\end{cor}
\begin{proof}
Let $W$ be defined by the inequalities
\[ |a_1|,\dotsc, |a_n| \le |a_0| \ne 0 \]
for some $a_0,...,a_n \in A$ that generate an open ideal.
Define $M$ as in Lemma \ref{aoo-open}.  Since $M$ is open,
there is an open normal subgroup $K$ of $H$ such that
$ka_i - a_i \in M$ for all $k \in K$, $i \in \{ 0,...,n \}$.

For any $x \in W$, $k \in K$, $i \in \{0,...,n\}$,
\[ |ka_i-a_i|_x < \max_{j=0,\dotsc,n} |a_j|_x = |a_0|_x \,. \]
Therefore, by the strong triangle inequality,
\begin{IEEEeqnarray*}{rCl}
|ka_i|_x & \le & \max \{ |ka_i - a_i|_x,|a_i|_x \} \le |a_0|_x \text{, and} \\
|ka_0|_x & = & \max \{|ka_0 - a_0|_x,|a_0|_x \} = |a_0|_x \ne 0.
\end{IEEEeqnarray*}
Hence $x\cdot k \in W$.  So $K$ stabilizes $W$.
\end{proof}

\begin{proof}[Proof of Proposition \ref{rational neighborhood}]
Let $W$ be a rational subset of $Y$ containing $x$ and contained in $U$.
Let $W$ be defined by the inequalities $|a_1|, ..., |a_n| \le |a_0| \ne 0$
for some $a_0,...,a_n \in A$ that generate an open ideal, and define $K$
as in the proof of Corollary \ref{open stabilizer}.

Choose a section (not necessarily a homomorphism) $\sigma\colon H/K \to H$ of the quotient $H \to H/K$.
Let $S$ be the set of $h \in H/K$ such that the $|\sigma(h) a_i|_x$
are not all zero.  From the definition of $K$, we see that
$S$ is independent of the choice of $\sigma$.
Let $\mathscr{S}$ denote the set of functions $S \to \{0,...,n\}$.
For any $f \in \mathscr{S}, h \in H/K$, define
\[ b_{f,h} \colonequals \prod_{s \in S} \sigma(hs) a_{f(s)} \,. \]
The ideal of $A$ generated by the $b_{f,h}$ contains the product of the ideals
$\sigma(s) \cdot (a_0,...,a_n)$ for $s \in S$, and hence is open.

Let $m = \#(H/K)$.
For any $f \in \mathscr{S}$ and $i \in \{1,...,m\}$,
define $e_{f,i}$ to be the $i$th elementary symmetric polynomial in
$(b_{f,h})_{h \in H/K}$.
We observe that
\[ b_{f,h}^{m} = \sum_{i=1}^{m} (-1)^{i-1} e_{f,i} b_{f,h}^{m-i} \,. \]
In particular, the ideal of $A$ generated by the $e_{f,i}$ contains the ideal
generated by the $b_{f,h}^{m}$.  The latter ideal contains the
$\left(\#(\mathscr{S} \times H/K) (m-1) + 1\right)$-st power of the ideal generated by the $b_{f,h}$.
So the $e_{f,i}$ generate an open ideal of $A$.

Choose $\phi \in \mathscr{S}$ so that $\phi(1)=0$ and
for all $s \in S$ and all $i \in \{0,...,n\}$,
\[|\sigma(s) a_i|_x \le |\sigma(s) a_{\phi(s)}|_x  \,. \]
For all $f \in \mathscr{S}$ and $h \in H/K$,
\[|b_{f,h}|_x \le |b_{\phi,1}|_x \,; \]
to see this, note that if $|b_{f,h}|_x \ne 0$, then $hs \in S$ for all $s \in S$ and thus multiplication by $h$ permutes the elements of $S$.
By the theory of Newton polygons, there exists $r \in \{1,...,m\}$
such that
\[ |b_{\phi,1}|_x = |e_{\phi,r}|_x^{1/r} \,. \]
Choose one such $r$.  Then for all $f \in \mathscr{S}$ and all
$i \in \{1,...,m\}$,
\[ |e_{f,i}|_x^{1/i} \le  |e_{\phi,r}|_x^{1/r} \,. \]

Let $V$ be the subset of $Y$ defined by the inequalities
\[ |e_{f,i}|^{1/i} \le |e_{\phi,r}|^{1/r} \ne 0 \quad \forall i \in \{1,...,m\},\, f \in \mathscr{S} \,. \]
Equivalently, $V$ is defined by the inequalities $|e_{f,i}|^{m!/i} \le |e_{\phi,r}|^{m!/r} \ne 0 $.
Since the $e_{f,i}$ generate an open ideal of $A$, the $e_{f,i}^{m!/i}$ do as well, so $V$ is rational.
Moreover, $V$ contains $x$.

Now we check that $V \subseteq \bigcup_{h \in H} W \cdot h \subseteq U$.
Let $y \in V$.  By the theory of Newton polygons, there exists some
$h \in H/K$ so that
\[ |b_{f,h'}|_y \le |b_{\phi,h}|_y \ne 0 \quad \forall f \in \mathscr{S},\, h' \in H/K \,. \]
In particular, by considering the case where $h=h'$ and $f$ and $\phi$ agree except at the identity, we find that
\[ |\sigma(h) a_i|_y \le |\sigma(h) a_0|_y \ne 0 \quad \forall i \in \{0,...,n\} \,. \]
Hence $y \in W \cdot \sigma(h)^{-1}$.

Finally, we check that $V$ is $H$-stable.  Fix $y \in V$.
First, consider, for all $h,h' \in H$,
\[ hb_{f,h'} = \prod_{s \in S} h \sigma(h's) a_{f(s)} = \prod_{s \in S} \left( \sigma(hh's) a_{f(s)} + \left( h \sigma(h's) a_{f(s)} - \sigma(hh's) a_{f(s)} \right) \right) \,. \]
When we expand the product, one of the terms is $b_{f,hh'}$.
Observe that the definition of $K$ implies that for all $i \in \{0,...,n\}$,
\[ h\sigma(h's)a_i - \sigma(hh's)a_i \in \sigma(h'hs)\left(\sum^n_{j=0} A^{\circ\circ} \cdot a_j \right)= \sum^n_{j=0}A^{\circ\circ} \cdot \sigma(h'hs)a_j. \]
Thus, we can bound the norm of the remaining terms using the inequalities
\[ |\sigma(hh's) a_{f(s)}|_y \le \max_j |\sigma(hh's) a_j|_y \,, \]
\[ \left|h \sigma(h's) a_{f(s)} - \sigma(hh's) a_{f(s)} \right| \prec \max_j |\sigma(hh's) a_j|_y \,; \]
here, $\alpha \prec \beta$ means that either
$\alpha < \beta$ or $\alpha = \beta = 0$.
We then find that
\[ |hb_{f,h'} - b_{f,hh'}|_y \prec \prod_{s \in S} \max_j |\sigma(hh's) a_j|_y = \max_{f'} |b_{f',hh'}|_y \,. \]
Since $y \in V$, the $|b_{f',h''}|_y$, where $h''$ ranges over $H$, are not all zero, so
\[ |hb_{f,h'}-b_{f,hh'}|_y < \max_{f',h''} |b_{f',h''}|_y \,. \]
Finally, for all $h \in H$, $f \in \mathscr{S}$, and $i \in \{1,...,m\}$,
a similar argument shows that
\[ |he_{f,i}-e_{f,i}|_y^{1/i} < \max_{f',h'} |b_{f',h'}|_y = \max_{f',i'} |e_{f',i'}|_y^{1/i'} = |e_{\phi,r}|_y^{1/r}  \,. \]
Then the strong triangle inequality implies that for any $h \in H$,
$f \in \mathscr{S}$, and $i \in \{1,...,m\}$,
\[ |he_{f,i}|_y^{1/i} \le |e_{\phi,r}|^{1/r} = |he_{\phi,r}|^{1/r} \ne 0 \,. \]
Hence $y \cdot h \in V$.  So $V$ is $H$-stable.
\end{proof}

\subsection{Proof of Theorem \ref{bound on higher direct images}}\label{sec: proof of main thm}

In this subsection, we prove Theorem~\ref{bound on higher direct images}. To simplify notation, we write $\widetilde{H} \colonequals \widetilde{K} \cap \widetilde{N}_{0}$, $\pi \colonequals \pi_{\mathrm{HT}/\widetilde{K} \cap \widetilde{N}_0}$, ${\mathcal F}^{i} \colonequals R^{i}\pi_{\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}$. Let $w\in W_{I}\backslash W /W_{I}$; write $d(w)=\dim \mathscr{F}\!\ell_{G,\mu}^{w}$ and pick $x\in |\mathscr{F}\!\ell_{G,\mu}^{w}|/\widetilde{H}$. We need to show that ${\mathcal F}^{i}_{x}=0$ for $i > d-d(w)$. By Proposition \ref{topbasechange} and Lemma \ref{shriekbasechange},
$$ {\mathcal F}_{x}^{i} \cong H^{i}_{\mathrm{\acute{e}t}}(\pi^{-1}(x), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}). $$
Recall from Subsection~\ref{structure sheaves} that a point of the topological space underlying a locally spatial diamond is said to be of rank one if it has no proper generizations.
\begin{lemma}\label{reduction to rank one}
It suffices to prove Theorem \ref{bound on higher direct images} for points $x\in |\mathscr{F}\!\ell_{G,\mu}^{w}|/\widetilde{H}$ which are of rank one.
\end{lemma}

\begin{proof}
Let $x\in|\mathscr{F}\!\ell_{G,\mu}^{w}|/\widetilde{H}$ be arbitrary and let $y\in |\mathscr{F}\!\ell_{G,\mu}^{w}|/\widetilde{H}$ be a rank-one generization of $x$ ($|\mathscr{F}\!\ell_{G,\mu}^{w}|/\widetilde{H}$ has finite dimension, so such $y$ exist). We have a natural map of spatial diamonds $\pi^{-1}(y) \to \pi^{-1}(x)$ which induces maps
$$ H^{i}_{\mathrm{\acute{e}t}}(\pi^{-1}(x), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}) \to H^{i}_{\mathrm{\acute{e}t}}(\pi^{-1}(y), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}) $$
for all $i$. These maps are isomorphisms by Lemma \ref{rankonepointsisom}, proving the lemma.
\end{proof}

\noindent From now, we assume that $x\in |\mathscr{F}\!\ell_{G,\mu}^{w}|/\widetilde{H}$ has rank one. Let $\widetilde{x}\in |\mathscr{F}\!\ell_{G,\mu}^{w}|$ be any lift of $x$; this is again a rank one point.
By Lemma \ref{finding a J}, we choose a $J$ with $w_{J}\in \delta^{-1}(ww_{0})$ such that $\widetilde{x}\widetilde{N}_{0} \subseteq |\mathscr{F}\!\ell_{G,\mu}^{J}|$ and we let $x_{J}\in |\mathscr{F}\!\ell_{G,\mu}^{w}|/\widetilde{H}_{J}$ denote the image of $\widetilde{x}$, where $\widetilde{H}_{J} \colonequals \widetilde{H} \cap \widetilde{N}_{0,J}$. Note that $x_{J}$ has no proper generizations in $|\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H}_{J}$, so the orbit $x_{J}(\widetilde{H}/\widetilde{H}_{J})$ is profinite by Lemma \ref{homeomorphism onto orbit}. Write $\pi_{J} \colonequals \pi_{\mathrm{HT}/\widetilde{H}_{J}}$ for the morphism of sites $({\mathcal X}_{\widetilde{H}_{J}}^{\ast})_{\mathrm{\acute{e}t}} \to |\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H}_{J}$, and put $V_{J} \colonequals \pi_{J}^{-1}(x_{J}(\widetilde{H}/\widetilde{H}_{J}))$. $V_{J}$ is naturally a spatial diamond: The underlying map $|\pi_{J}| \colon |{\mathcal X}^{\ast}_{\widetilde{H}_{J}}| \to |\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H}_{J}$ is spectral and $x_{J}(\widetilde{H}/\widetilde{H}_{J})$ can be written as an intersection of quasicompact opens, so $V_{J}$ is an inverse limit of open spatial subdiamonds of ${\mathcal X}_{\widetilde{H}_{J}}^{\ast}$, hence spatial by Lemma \ref{inverselimit}.

\begin{lemma}\label{cover pi^-1(x)}
The natural map $V_{J} \to \pi^{-1}(x)$ is a $v$-cover, and the restriction $V_{J}\cap {\mathcal X}_{\widetilde{H}_{J}} \to \pi^{-1}(x) \cap {\mathcal X}_{\widetilde{H}}$ is an $\widetilde{H}/\widetilde{H}_{J}$-torsor.
\end{lemma}

\begin{proof}
$V_{J}$ is equal to ${\mathcal X}^{\ast}_{\widetilde{H}_{J}}\times_{{\mathcal X}^{\ast}_{\widetilde{H}}}\pi^{-1}(x)$ and the natural map to $\pi^{-1}(x)$ is the projection onto the second factor. Now ${\mathcal X}^{\ast}_{\widetilde{H}_{J}} \to {\mathcal X}_{\widetilde{H}}^{\ast}$ is a (in fact quasi-pro-\'etale) map of spatial diamonds which is surjective on topological spaces by Lemma \ref{exhibiting a diamond as a quotient}, hence a v-cover by \cite[Lemma 12.11]{diamonds}, so the pullback $V_{J} \to \pi^{-1}(x)$ is a v-cover. Moreover, ${\mathcal X}_{\widetilde{H}_{J}} \to {\mathcal X}_{\widetilde{H}}$ is an $\widetilde{H}/\widetilde{H}_{J}$-torsor by Lemma \ref{torsor}, so the pullback $V_{J}\cap {\mathcal X}_{\widetilde{H}_{J}} \to \pi^{-1}(x) \cap {\mathcal X}_{\widetilde{H}}$ is an $\widetilde{H}/\widetilde{H}_{J}$-torsor.
\end{proof}

By this lemma, Theorem \ref{hochschildserre} gives us a spectral sequence
$$ E_{2}^{rs}=H^{r}_{cts}(\widetilde{H}/\widetilde{H}_{J},H^{s}_{\mathrm{\acute{e}t}}(V_{J},j_{!}({\mathcal O}^{+}_{{\mathcal X}}/p)^{a})) \implies H^{r+s}_{\mathrm{\acute{e}t}}(\pi^{-1}(x), j_{!}({\mathcal O}^{+}_{{\mathcal X}}/p)^{a}). $$
Since $\widetilde{H}/\widetilde{H}_{J} \subseteq \widetilde{N}_{0}/\widetilde{N}_{0,J}\cong \Z_p^{d-d(w)}$ as $\Z_p$-modules (using Lemma \ref{ranks}) and the index is finite, we must have $\widetilde{H}/\widetilde{H}_{J} \cong \Z_p^{d-d(w)}$ and hence continuous cohomology for $\widetilde{H}/\widetilde{H}_{J}$ has cohomological dimension $d-d(w)$ (this is presumably well known---it follows e.g.\ from \cite[Proposition 5.2.7]{nsw} and the fact that the Koszul complex of $\Z_p[[\Z_p^{d-d(w)}]]$ resolves the trivial module $\Z_p$). Therefore, to prove that  $H^{i}_{\mathrm{\acute{e}t}}(\pi^{-1}(x), j_{!}({\mathcal O}^{+}_{{\mathcal X}}/p)^{a})=0$ for $i>d-d(w)$ it suffices to show that $H^{s}_{\mathrm{\acute{e}t}}(V_{J},j_{!}({\mathcal O}^{+}_{{\mathcal X}}/p)^{a})=0$ for all $s>0$. To do this, we start by considering the natural map
$$ \pi_{V_{J}} \colon (V_{J})_{\mathrm{\acute{e}t}} \to x_{J}(\widetilde{H}/\widetilde{H}_{J}). $$
Since $x_{J}(\widetilde{H}/\widetilde{H}_{J})$ is profinite, higher cohomology vanishes and we have
$$ H^{s}_{\mathrm{\acute{e}t}}(V_{J},j_{!}({\mathcal O}^{+}_{{\mathcal X}}/p)^{a}) = H^{0}(x_{J}(\widetilde{H}/\widetilde{H}_{J}), R^{s}\pi_{V_{J},\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}). $$
Thus, we need to show that $R^{s}\pi_{V_{J},\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}=0$ for $s>0$, which we can check on stalks. If $y\in x_{J}(\widetilde{H}/\widetilde{H}_{J})$, then
$$ R^{s}\pi_{V_{J},\ast}j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}_{y}\cong H^{s}_{\mathrm{\acute{e}t}}(\pi_{J}^{-1}(y), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}) $$
by Proposition \ref{topbasechange}, so we need to show that the right-hand side vanishes for $s>0$. As $\widetilde{x}$, and hence $x_{J}$, was chosen arbitrarily, without loss of generality $y=x_{J}$.

\medskip
We now apply Proposition \ref{rational neighborhood}. Consider the orbit $\widetilde{x}\widetilde{H}_{J} \subseteq |\mathscr{F}\!\ell_{G,\mu}^{J}|$. By Theorem \ref{general perfectoid stratum}, we may choose $k$ large enough such that $|{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1} \supseteq \pi^{-1}_\mathrm{HT}(\widetilde{x}\widetilde{H}_{J})$ (for a suitable sufficiently small $\epsilon >0$, which we fix). We then choose a large enough $k^{\prime}$ such that $|{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1} \subseteq \pi^{-1}_{\mathrm{HT}}(\mathscr{F}\!\ell_{G,\mu}^{J}(k^{\prime}))$, which we may do by Theorem \ref{general perfectoid stratum} and Lemma \ref{standard neighborhoods are stable}. Note that $\mathscr{F}\!\ell_{G,\mu}^{J}(k^{\prime})$ is affinoid and $\widetilde{N}_{0,J}$-stable by Lemma \ref{standard neighborhoods are stable}, hence $\widetilde{H}_{J}$-stable. By Proposition \ref{rational neighborhood}, we can find a collection $U_{t}$, $t\in T$,
of $\widetilde{H}_{J}$-stable opens of $\mathscr{F}\!\ell_{G,\mu}^{J}(k^{\prime})$ which are rational subsets and
$$ \bigcap_{t\in T}U_{t} = \widetilde{x}\widetilde{H}_{J}; $$
we may and will also assume that $\pi_{\mathrm{HT}}^{-1}(U_{t}) \subseteq |{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1}$ for all $t\in T$. It follows that $\bigcap_{t\in T}|U_{t}|/\widetilde{H}_{J} = x_{J}$ and hence that
$$ H^{s}_{\mathrm{\acute{e}t}}(\pi_{J}^{-1}(x_{J}), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}) = \varprojlim_{t\in T} H^{s}_{\mathrm{\acute{e}t}}(\pi_{J}^{-1}(|U_{t}|/\widetilde{H}_{J}), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}), $$
so it suffices to show that $H^{s}_{\mathrm{\acute{e}t}}(\pi_{J}^{-1}(|U_{t}|/\widetilde{H}_{J}), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a})=0$ for $s>0$ and $t\in T$.

\begin{prop}\label{cohomology vanishing for rational neighborhoods}
$H^{s}_{\mathrm{\acute{e}t}}(\pi_{J}^{-1}(|U_{t}|/\widetilde{H}_{J}), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a})=0$ for $s>0$ and $t\in T$.
\end{prop}

\begin{proof}
Note that we can write
$$ |{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1} = \varprojlim_{m\geq 0} \left( |{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1}/(\widetilde{H}_{J} \cap \widetilde{\Gamma}(p^{m})) \right) $$
and that all spaces appearing are affinoid perfectoid with strongly Zariski closed boundary, by Theorem \ref{general perfectoid stratum}. We get a corresponding inverse limit description
$$ |\pi^{-1}_{\mathrm{HT}}(U_{t})| = \varprojlim_{m} \left( |\pi_{\mathrm{HT}}^{-1}(U_{t})|/(\widetilde{H}_{J}\cap \widetilde{\Gamma}(p^{m})) \right).$$
Note that all spaces here are quasicompact perfectoid spaces and that the bottom space $|\pi_{\mathrm{HT}}^{-1}(U_{t})|/\widetilde{H}_{J}$ is equal to $\pi_{J}^{-1}(|U_{t}|/\widetilde{H}_{J})$. By our choices of $k$ and $k^{\prime}$ and the construction of $U_{t}$, $\pi_{\mathrm{HT}}^{-1}(U_{t})$ is a rational subset of $|{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1}$. As a rational subset in an inverse limit must come from a rational subset at some finite level, there exists an $m$ such that $|\pi_{\mathrm{HT}}^{-1}(U_{t})|/(\widetilde{H}_{J}\cap \widetilde{\Gamma}(p^{m}))$ is a rational subset of $|{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1}/(\widetilde{H}_{J} \cap \widetilde{\Gamma}(p^{m}))$, and hence affinoid perfectoid. Fix such an $m$ and put $V_{m} \colonequals |\pi_{\mathrm{HT}}^{-1}(U_{t})|/(\widetilde{H}_{J}\cap \widetilde{\Gamma}(p^{m}))$ and $G_{m} \colonequals \widetilde{H}_{J}/(\widetilde{H}_{J} \cap \widetilde{\Gamma}(p^{m}))$. Note that $G_m$ is a finite group. The map
$$ V_{m} \to \pi_{J}^{-1}(|U_{t}|/\widetilde{H}_{J}) $$
is a $G_{m}$-equivariant map of perfectoid spaces and is a $G_{m}$-torsor away from the boundary by Lemma \ref{torsor}. By \cite[Theorem 1.2, Theorem 3.5]{hansen}, the quotient $V_{m}/G_{m}$ exists (in the category of adic spaces) and is affinoid perfectoid. We therefore get an induced map
$$ V_{m}/G_{m} \to \pi_{J}^{-1}(|U_{t}|/\widetilde{H}_{J}) $$
which is an isomorphism away from the boundary (since we had a $G_{m}$-torsor away from the boundary). By Lemma \ref{shriekbasechange}, we have
$$ H^{s}_{\mathrm{\acute{e}t}}(\pi_{J}^{-1}(|U_{t}|/\widetilde{H}_{J}), j_{!}({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}) = H^{s}_{\mathrm{\acute{e}t}}(V_{m}/G_{m}, j_{!}({\mathcal O}^{+}_{{\mathcal X}}/p)^{a}) $$
for all $s\geq 0$. Moreover, the boundary of $V_{m}/G_{m}$ is strongly Zariski closed since it is the pullback of the boundary on $|{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}(\epsilon)_{a}|\gamma^{k}w_{J}^{-1}/\widetilde{H}_{J}$. By Proposition \ref{strongly Zariski closed vanishing} $H^{s}_{\mathrm{\acute{e}t}}(V_{m}/G_{m}, j_{!}({\mathcal O}^{+}_{{\mathcal X}}/p)^{a})=0$, which finishes the proof.
\end{proof}

\noindent This finishes the proof of Theorem \ref{bound on higher direct images}, and hence also the proof of Theorem \ref{main thm}.

\section{The Hilbert--Siegel case}\label{Siegel case}
In this section we briefly explain how the arguments of the previous sections adapt to Hilbert--Siegel modular varieties, proving the totally real part of Theorem \ref{unified main theorem}. We let $F/{\mathbb Q}$ be a totally real field with $[F:{\mathbb Q}]=f$ and assume that the prime
$p$ \emph{splits completely} in $F$. As in previous sections, we fix an algebraically closed complete extension $C$ of ${\mathbb Q}_p$ with ring of integers $\O_C$.

\subsection{The Hilbert--Siegel modular variety}
For $n\in {\mathbb Z}_{>0}$, let
\[
J_n \colonequals \left(\begin{array}{cc}
0&I_n\\
-I_n&0\end{array}\right)\in M_{2n}(F)
\]
where $I_n \in M_n(F)$ is the identity matrix.

Let $V\colonequals F^{2n}$ be an $F$-vector space of dimension $2n$.
For the standard choice of basis
$e_1,\ldots,e_{2n}$ of $V$,
$J_n$ determines a non-degenerate alternating form
\[
\psi\colon V\times V\to {\mathbb Q},\quad \psi(x,y)\colonequals \mathrm{Tr}_{F/{\mathbb Q}}(x^tJy).
\]
Let $G = \mathrm{Res}_{F/{\mathbb Q}}\mathrm{Sp}_{2n}$ be the algebraic group over ${\mathbb Q}$ whose $R$-valued points are
\[
G(R)= \{g\in \mathrm{Aut}_{R}(V\otimes_{{\mathbb Q}}R) \;\ifnum\currentgrouptype=16 \middle\fi|\; \psi(gx,gy) = \psi(x,y)\text{ for all }x,y\in V\otimes_{{\mathbb Q}} R\}.
\]
for any ${\mathbb Q}$-algebra $R$.
Let $\widetilde{G}$ be the corresponding group of similitudes.
It is also an algebraic group over ${\mathbb Q}$, given by
\[
\widetilde{G}(R)= \{(g,r)\in \mathrm{Aut}_{R}(V\otimes_{{\mathbb Q}}R)\times R^\times \;\ifnum\currentgrouptype=16 \middle\fi|\; \psi(gx,gy) = r\psi(x,y)\text{ for all }x,y\in V\otimes_{{\mathbb Q}} R\}.
\]

\medskip
We construct the Shimura data attached to the groups
$\widetilde{G}$ and $G$. We remark that
\[
V\otimes_{{\mathbb Q}}{\mathbb R}\simeq \prod_{\iota\colon F\hookrightarrow {\mathbb R}} V\otimes_{F,\iota}{\mathbb R},
\]
where the product is over all embeddings
$\iota\colon F\hookrightarrow {\mathbb R}$. For each $\iota$, we can define an
${\mathbb R}$-algebra homomorphism
\begin{align*}
h_{\iota,0} \colon {\mathbb C}&\to \mathrm{End}_{{\mathbb R}}(V\otimes_{F,\iota}{\mathbb R})\\
z = x+iy&\mapsto\left(\begin{array}{cc}
\mathrm{diag}(x^{(n)})&\mathrm{diag}(y^{(n)})\\
\mathrm{diag}(-y^{(n)})&\mathrm{diag}(x^{(n)})\end{array}\right).
\end{align*}
The different $h_{\iota,0}$ combine into an ${\mathbb R}$-algebra
homomorphism
\[
h_0\colonequals (h_{\iota_1,0},\ldots,h_{\iota_{2n},0})\colon {\mathbb C}\to \prod_{\iota\colon F\hookrightarrow {\mathbb R}} \mathrm{End}_{{\mathbb R}}(V\otimes_{F,\iota}{\mathbb R})\subseteq \mathrm{End}_{{\mathbb R}}(V\otimes_{{\mathbb Q}}{\mathbb R}).
\]
Restricting to ${\mathbb C}^\times$, the morphism $h_0$ induces a
homomorphism of real algebraic groups
$h\colon \mathbb{S}\to \widetilde{G}_{{\mathbb R}}$,
where $\mathbb{S}$ is the Deligne torus.

We denote the
$\widetilde{G}({\mathbb R})$-conjugacy classes of $h$ by $\widetilde{X}$ and let $X$ be a choice of $G({\mathbb R})$-conjugacy class inside $\widetilde{X}$.
The pairs $(\widetilde{G},\widetilde{X})$ and
$(G,X)$ satisfy the axioms of a Shimura datum and a connected Shimura datum, respectively.
For $K\subset G(\AA_f)$ a compact open subgroup, we consider the
(connected, though from now on we will drop this adjective for simplicity) Shimura variety $X_K$ corresponding to the Shimura datum $(G,X)$.
This Shimura variety has dimension $d=f\cdot \frac{n(n+1)}{2}$.
Similarly, we consider the Shimura variety
$X_{\widetilde{K}}$ corresponding to $(\widetilde{G},\widetilde{X})$ and
a compact open subgroup $\widetilde{K}\subset \widetilde{G}(\AA_f)$.
This Shimura variety is of PEL type, also of dimension $d$, and we will refer to it as a \emph{Hilbert--Siegel modular variety}\footnote{This name might perhaps be more suitable for the Shimura varieties attached to ${\rm Res}_{F/{\mathbb Q}}{\rm GSp}_{2n}$.}.
As in Section~\ref{ShimuraGX}, for $K=\widetilde{K}\cap G(\AA_f)$, we have that $X_K$
is an open and closed subset of $X_{\widetilde{K}}$ (in fact it is a connected component).

The goal of this section is to explain how to deduce results analogous to
those in Sections~\ref{recollections}, \ref{stratifications}, and \ref{vanishing} for the Shimura varieties $X_K$
and $X_{\widetilde{K}}$. As in the unitary case, we are interested in
studying the inverse system of Shimura varieties at level $\Gamma_1(p^m)$; this level was
introduced in the unitary case in Section~\ref{levels} and is defined analogously in
the symplectic case.
We continue to drop the tame levels $K^p$ and $\widetilde{K}^p$ from the notation. The main result of this section is the following analogue of Theorem~\ref{main thm}. Here and in the future, we use $G$ and $\widetilde{G}$, respectively, for the natural models over ${\mathbb Z}$ as well.
\begin{thm}\label{main thm - siegel}
  Let $\widetilde{K} \subseteq \widetilde{G}(\Z_p)$ be an open subgroup and let $r \in {\mathbb Z}_{\geq 1}$.
  If $i>d$, then
  \[ \varinjlim_m H^i_c(X_{\widetilde{K} \cap \widetilde{\Gamma}_1(p^m)}(\CC),{\mathbb Z}/p^r{\mathbb Z}) =0. \]
\end{thm}
By passing to connected components, this immediately yields

\begin{cor}\label{main cor - siegel}
  Let $K\subseteq G(\Z_p)$ be an open subgroup and let $r \in {\mathbb Z}_{\geq 1}$.
  If $i>d$, then
  \[ \varinjlim_m H^i_c(X_{K \cap \Gamma_1(p^m)}(\CC),{\mathbb Z}/p^r{\mathbb Z}) = 0. \]
\end{cor}
From now on, we will only use the Shimura varieties for $\widetilde{G}$. We start with a few preparations, briefly indicating how the relevant definitions and results from subsections \ref{3.1} and \ref{subsect: anticanonical tower} carry over to our Hilbert--Siegel modular varieties.

\medskip
As before, the Shimura varieties $X_{\widetilde{K}}$ have minimal compactifications $X^{\ast}_{\widetilde{K}}$, and these have canonical models over the reflex field ${\mathbb Q}$, which we base change to $\Q_p$. When the level is hyperspecial at $p$, we have integral models (over $\Z_p$) of the minimal compactifications (by \cite{lan-thesis}). We consider the adifications of the minimal compactifications over $\Q_p$; these are projective rigid analytic varieties (thought of as adic spaces) and we will denote their base changes to $C$ by ${\mathcal X}^{\ast}_{\widetilde{K}}$.
We let ${\mathcal X}_{\widetilde{K}} \subseteq {\mathcal X}^{\ast}_{\widetilde{K}}$ denote the open part. For $m\geq 1$, we have level subgroups $\widetilde{\Gamma}_{0}(p^{m})$, $\widetilde{\Gamma}_{1}(p^{m})$ (mentioned above) and $\widetilde{\Gamma}(p^{m})$ inside $\widetilde{G}(\Z_p)$ defined analogously to the subgroups denoted by the same symbols in \ref{levels} using the Siegel parabolic and its unipotent radical. As before, we set $\widetilde{P}_{\mu,0} \colonequals \bigcap_{m} \widetilde{\Gamma}_{0}(p^{m})$, $\widetilde{N}_0\colonequals \bigcap_{m}\widetilde{\Gamma}_1(p^m)$ and $\widetilde{\mathbf{1}} \colonequals \bigcap_{m}\widetilde{\Gamma}(p^{m})$; these are closed subgroup of $G({\mathbb Z}_p)$.
As in subsection~\ref{notation for infinite level}, we define (locally) spatial diamonds
\[ {\mathcal X}_{\widetilde{H}}^{?} \colonequals \varprojlim_{\widetilde{H} \subseteq \widetilde{K}} {\mathcal X}^{?,\lozenge}_{\widetilde{K}} \]
for arbitrary closed subgroups $\widetilde{H} \subseteq \widetilde{G}(\Z_p)$ and $?\in \{\emptyset,\ast\}$; the $\widetilde{K}$ run over all open subgroups $\widetilde{H} \subseteq \widetilde{K} \subseteq \widetilde{G}(\Z_p)$. The analogues of Lemmas \ref{exhibiting a diamond as a quotient} and \ref{torsor} hold: we have $|{\mathcal X}_{\widetilde{H}}^{\ast}| \cong |{\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast}|/\widetilde{H}$ and whenever $\widetilde{H}_{1} \subseteq \widetilde{H}_{2}$ is normal, ${\mathcal X}_{\widetilde{H}_{1}} \to {\mathcal X}_{\widetilde{H}_{2}}$ is a $\widetilde{H}_{2}/\widetilde{H}_{1}$-torsor.

\medskip
The group $\widetilde{G}$ embeds into ${\rm GSp}(V)$, where $V$ is viewed as a ${\mathbb Q}$-vector space.
This induces an embedding of $(\widetilde{G},\widetilde{X})$ into a Siegel Shimura datum, which at the level of moduli problems corresponds to forgetting the endomorphisms. As in \ref{sec: anticanonical}, we can use this embedding to define anticanonical loci ${\mathcal X}_{\widetilde{H}}^{\ast}(\epsilon)_{a}$ for any $0 \leq \epsilon <1/2$ and any level $\widetilde{H} \subseteq \widetilde{\Gamma}_{0}(p)$. Then the following analogue of Theorem \ref{anticanonical tower at intermediate levels 2} holds, with the same proof.

\begin{thm}
Let $\widetilde{H} \subseteq \widetilde{P}_{\mu,0}$ be a closed subgroup. Then ${\mathcal X}^{\ast}_{\widetilde{H}}(\epsilon)_{a}$ is an affinoid perfectoid space over $C$, and the boundary ${\mathcal Z}_{\widetilde{H}}(\epsilon)_{a} \subseteq {\mathcal X}^{\ast}_{\widetilde{H}}(\epsilon)_{a}$ is strongly Zariski closed.
\end{thm}

\subsection{The Hilbert--Siegel flag variety}
Given our choice of homomorphism $h$, we consider the corresponding Hodge
cocharacter $\mu\colon \mathbb{G}_{m,\CC}\to \widetilde{G}_{\CC}$, which determines a (Siegel) parabolic subgroup
$\widetilde{P}_{\mu}\subset \widetilde{G}_{\CC}$ with $\widetilde{P}_{\mu}(\Z_p)=\widetilde{P}_{\mu,0}$. This parabolic subgroup is already defined
over the reflex field ${\mathbb Q}$. We define the flag variety
$\mathrm{Fl}_{\widetilde{G},\mu}\colonequals \widetilde{G}/\widetilde{P}_{\mu}$;
it also has a model over ${\mathbb Q}$. This flag variety has a moduli interpretation:
it parametrizes all \emph{Lagrangian} $F$-subspaces $W\subseteq V$, i.e.
those $F$-subspaces of dimension $n$ that satisfy $\psi(v,v) = 0$ for all $v\in W$ for the alternating pairing $\psi$ defined on $V$ in the previous section.

\medskip
We have a closed embedding
\[
\mathrm{Fl}_{\widetilde{G},\mu} \times_{\Spec {\mathbb Q}} \Spec \overline{\Q} \hookrightarrow \prod_{\iota\colon F\hookrightarrow \overline{\Q}}\mathrm{Gr}(n,2n)
\]
where $\mathrm{Gr}(n,2n)$ is the standard Grassmannian
parametrizing all $n$-dimensional subspaces of $V\otimes_{F,\iota}\overline{\Q}$
and the product is over all embeddings $\iota\colon F\hookrightarrow \overline{\Q}$.
We note that we can also consider the flag variety $\mathrm{Fl}_{G,\mu}$
corresponding to $(G, X)$ and that we have a canonical
identification $\mathrm{Fl}_{G,\mu} = \mathrm{Fl}_{\widetilde{G},\mu}$,
so for simplicity of notation we use $\mathrm{Fl}_{G,\mu}$ from now on.
We will be interested in the adic space $\mathscr{F}\!\ell_{G,\mu}\colonequals (\mathrm{Fl}_{G,\mu}\otimes_{{\mathbb Q}}C)^{\mathrm{ad}}$. We have the following analogue of Theorem \ref{perfectoid Shimura variety and properties 2}, which can be proved in the same way using the embedding into the Siegel Shimura datum discussed above.

\begin{thm}\label{perfectoid Shimura variety and properties siegel}
The spatial diamond ${\mathcal X}^*_{\widetilde{\mathbf{1}}}$ is a perfectoid space, and there is a $\widetilde{G}(\Q_p)$-equivariant Hodge--Tate period morphism $\pi_{\mathrm{HT}} \colon {\mathcal X}^{\ast}_{\widetilde{\mathbf{1}}} \to \mathscr{F}\!\ell_{G,\mu}$ of adic spaces.
\end{thm}

Our goal for the remaining part of this subsection is to briefly describe how the results from subsection \ref{hodgetatemapsection} and section \ref{stratifications} carry over to the Hilbert--Siegel setting. We begin by giving the explicit description of the Bruhat stratification on $\mathscr{F}\!\ell_{G,\mu}$. We use the notation introduced in
subsection~\ref{algebraic groups and weyl groups}.
The following is the analogue of Example~\ref{GL_n example part 1}.
\begin{example}[$\mathrm{G}=\Sp_{2n}$]\label{Sp_2n-example-part-1}
  We recall the structure theory of the algebraic group $\mathrm{G} = \Sp_{2n}$ over $\Q_p$.
  We choose the subgroup
  \[ \mathrm{T} = \{ \diag(t_1,\dotsc,t_n,t^{-1}_1,\dotsc,t^{-1}_n) \} \]
  of the group $\mathrm{D}_{2n}$ of $2n$-dimensional diagonal matrices as maximal torus of $\mathrm{G}$.
  As Borel subgroup $\mathrm{B}$, we take the stabilizer of the maximal totally isotropic flag
  \[ 0 \subset \langle e_1 \rangle \subset \langle e_1,e_2 \rangle \subset \dotsb \subset \langle e_1,e_2,\dotsc,e_n \rangle; \]
  concretely, $\mathrm{B}$ consists of all matrices of the form $\left(\begin{smallmatrix}A & C \\ 0 & \left(A^t\right)^{-1}\end{smallmatrix}\right)$, where $A \in \GL_n$ is upper triangular and $C \in \Mat_{n,n}$ such that $AC^t = CA^t$.
  The associated root datum is as follows:
  \begin{itemize}
    \item $\Phi = \{ \chi^{\pm 1}_{i,j} \;\ifnum\currentgrouptype=16 \middle\fi|\; 1 \leq i < j \leq n \} \cup \{ \psi^{\pm 1}_{i,j} \;\ifnum\currentgrouptype=16 \middle\fi|\; 1 \leq i \leq j \leq n \}$ and $\Phi^+ = \{ \chi_{i,j} \,|\, 1 \leq i < j \leq n \} \cup \{ \psi_{i,j} \;\ifnum\currentgrouptype=16 \middle\fi|\; 1 \leq i \leq j \leq n \}$, where $\chi_{i,j},\psi_{i,j} \in X^*(\mathrm{T})$ are given by
    \[
    \chi_{i,j}(\diag(t_1,\dotsc,t_n,t^{-1}_1,\dotsc,t^{-1}_n)) = t_it^{-1}_j
    \]
    and
    \[
    \psi_{i,j}(\diag(t_1,\dotsc,t_n,t^{-1}_1,\dotsc,t^{-1}_n)) = t_it_j.
    \]
    \item $\Delta = \{ \chi_{i,i+1} \;\ifnum\currentgrouptype=16 \middle\fi|\; 1 \leq i < n \} \cup \{ \psi_{n,n} \}$.
    \item For $i = 1,\dotsc,n-1$, the simple reflection $s_i$ for $\chi_{i,i+1}$ corresponds to the coset of the permutation matrix for $(i,i+1)(n+i,n+i+1) \in S_{2n}$.
      The simple reflection $s_n$ for $\psi_{n,n}$ corresponds to the coset of the permutation matrix for $(n,2n) \in S_{2n}$.
    \item $W \simeq S_n \ltimes ({\mathbb Z}/2{\mathbb Z})^n$ is the subgroup of $S_{2n}$ generated by all transpositions $(1,n+1),\dotsc,(n,2n)$ and the symmetric group on $\{1,\dotsc,n\}$.
  \end{itemize}
  Let $I = S \smallsetminus \{s_n\}$. Then
  \begin{itemize}
    \item $W_I \simeq S_n \hookrightarrow S_n \times S_n \subset S_{2n}$ (where the first inclusion is given by the diagonal map),
    \item $\Phi_I = \{ \chi^{\pm 1}_{i,j} \;\ifnum\currentgrouptype=16 \middle\fi|\; 1 \leq i < j \leq n \}$,
    \item $P_I = \left\{ \begin{pmatrix} A & C \\ 0 & (A^t)^{-1} \end{pmatrix} \;\ifnum\currentgrouptype=16 \middle\fi|\; A \in \GL_n, C \in \Mat_{n,n}, AC^t = CA^t \right\}$,
    \item $\overline{P}_I = \left\{ \begin{pmatrix} A & 0 \\ C & (A^t)^{-1} \end{pmatrix} \;\ifnum\currentgrouptype=16 \middle\fi|\; A \in \GL_n, C \in \Mat_{n,n}, AC^t = CA^t \right\}$, and
    \item $L_I = \left\{ \begin{pmatrix} A & 0 \\ 0 & (A^t)^{-1} \end{pmatrix} \;\ifnum\currentgrouptype=16 \middle\fi|\; A \in \GL_n \right\}$.
  \end{itemize}
\end{example}
Next, we transfer the results from Section~\ref{generalized-Bruhat-decomposition}.
\begin{lemma}\label{lemma:double-coset-Sp}
  Let $K \colonequals S_n \ltimes ({\mathbb Z}/2{\mathbb Z})^n \subset S_{2n}$ be the subgroup generated by all transpositions $(1,n+1),\dotsc,(n,2n)$ and the symmetric group on $\{1,\dotsc,n\}$.
  Let $L \colonequals S_n \subset K$.
  Then the double coset space $L \backslash K / L$ contains $n+1$ elements.
  A set of representatives is
  \[ \sigma_k = \prod_{i=1}^k (i, n+i) ,\quad 0 \leq k \leq n. \]
\end{lemma}
\begin{proof}
  We have $K / L \simeq ({\mathbb Z}/2{\mathbb Z})^n$, with the $i$-th factor of $({\mathbb Z}/2{\mathbb Z})^n$ generated by $(i,n+i)$.
  As in Lemma~\ref{lemma:double-coset-GL}, two elements of $K / L$ lie in the same orbit under the left multiplication of $L$ if and only if they have the same length.
  Thus, the products $\prod_{i=1}^k (i, n+i)$ with $0 \leq k \leq n$ form a set of representatives of $L \backslash K / L$.
\end{proof}
\begin{example}\label{Sp_2n-example-part-2}
  In the notation of Example~\ref{Sp_2n-example-part-1},
  \[ W_I \backslash W / W_I \simeq S_n \backslash \bigl(S_n \ltimes ({\mathbb Z}/2{\mathbb Z})^n\bigr) / S_n \simeq \left\{ \prod_{i=1}^k (i, n+i) \;\ifnum\currentgrouptype=16 \middle\fi|\; 0 \leq k \leq n \right\}. \]
\end{example}
As in Example~\ref{dimension of Schubert cells - algebraic}, we explicitly describe the generalized Bruhat decomposition of the flag variety $\Sp_{2n}$.
\begin{example}\label{Sp_2n Schubert cells - algebraic}
  Let $\mathrm{G} = \Sp_{2n}$ and $I = S \smallsetminus \{s_n\}$.
  We identify the flag variety $\Flr_{\mathrm{G},I} = \mathrm{G}/\mathrm{P}_I$ with the locus of totally isotropic subspaces in $\Grr(n,2n)$.
  It admits the generalized Bruhat decomposition
  \[ \Flr_{\mathrm{G},I} = \bigsqcup_{w\in W_I\backslash W/W_I}\Flr^{w}_{\mathrm{G},I}. \]
  Set $U_0 \colonequals \Q_p^n \oplus 0 \subset \Q_p^{2n}$.
  The Schubert cells in this stratification are given by
  \[ \Flr^w_{\mathrm{G},I}(R) = \left\{U \in \mathrm{Gr}(n,2n)(R) \mid U \text{ totally isotropic and } \rank(U \cap U_{0,R}) = n-\tau(w)\right\}, \]
where $0\leq \tau(w) \leq n$ is such that $w$ is the product of $\tau(w)$ transpositions.
  Once more, we have
  \[ \overline{\Flr^w_{\mathrm{G},I}}=\sqcup_{\tau(w')\le \tau(w)}\Flr^{w'}_{\mathrm{G},I}. \]
  Furthermore,
  \[ \dim \Flr^{w}_{\mathrm{G},I} = \frac{\tau(w)(2n-\tau(w)+1)}{2}. \]
  To see this, consider the surjection
  \[ \pi \colon \Flr_{\mathrm{G},I}^w\twoheadrightarrow \Grr(n-\tau(w),n) \]
  which is given on $R$-valued points by $U \mapsto U \cap U_{0,R}$.
  We determine the dimension of the fiber over a point $U' \in \Grr(n-\tau(w),n)(\Q_p)$.
  Since $U'$ is totally isotropic, $(U')^\perp$ must have dimension $n+\tau(w)$.
  Any $U\in \Flr_{\mathrm{G},I}^w(\Q_p)$ with $U\cap U_0 = U'$ corresponds to a Lagrangian subspace $\overline{U}\subseteq (U')^\perp / U'$ such that $\overline{U}\cap (U_0/U') = 0$.
  Therefore, $\pi^{-1}(U')$ is an open Schubert cell in the flag variety for the symplectic space $(U')^\perp / U'$.
  In particular,
  \[ \dim\Flr_{\mathrm{G},I}^w = (n-\tau(w))\tau(w) + \frac{\tau(w)(\tau(w)+1)}{2} = \frac{\tau(w)(2n-\tau(w)+1)}{2}. \qedhere \]
\end{example}
We return to the group $G = \Res_{F/{\mathbb Q}}\Sp_{2n}$.
Having described the Bruhat stratification for the flag variety of ${\rm Sp}_{2n}$ over $\Q_p$, let us now describe the Bruhat stratification on $\mathscr{F}\!\ell_{G,\mu}$; this amounts to taking the $F$-structure into account.
As $p$ splits completely in $F$, we have
\[ G_{\Q_p} = \prod_{\mathfrak{p} \mid p} \Sp_{2n,\Q_p}, \]
where the product ranges over all primes $\mathfrak{p}\mid p$ of $F$.
In this product, $P_\mu$ decomposes as $P_\mu = \prod P_{\mu,\mathfrak{p}}$, where $P_{\mu,\mathfrak{p}} \subset \Sp_{2n,\Q_p}$ denotes the parabolic subgroup stabilizing $\Q_p^n \oplus 0 \subset \Q_p^{2n} \simeq V \otimes_F F_\mathfrak{p}$.
As before, $P_\mu$ and $P_{\mu,\mathfrak{p}}$ define subgroups $W_I$ and $W_{\mathfrak{p},I}$ of the Weyl groups $W$ and $W_\mathfrak{p}$, respectively, and we have
\[
W_I\backslash W/W_I = \prod_{\mathfrak{p}\mid p} W_{\mathfrak{p}, I}\backslash W_{\mathfrak{p}}/W_{\mathfrak{p}, I}.
\]
Example~\ref{Sp_2n-example-part-2} provides a concrete description of the double cosets $W_{\mathfrak{p}, I}\backslash W_{\mathfrak{p}}/W_{\mathfrak{p}, I}$.
Given a prime $\mathfrak{p}\mid p$ of $F$, let $\iota_{\mathfrak{p}} \colon F\hookrightarrow C$ be
the embedding inducing $\mathfrak{p}$. Set $U_{0,C} \colonequals C^n\oplus 0\subset C^{2n}$.
Write an element of $W_I\backslash W/W_I$ as a tuple $w=(w_{\mathfrak{p}})_{\mathfrak{p}}$.
Analytifying the stratification from Example~\ref{Sp_2n Schubert cells - algebraic}, we obtain the Bruhat decomposition
\[ \mathscr{F}\!\ell_{G,\mu} = \bigsqcup_{w \in W_I \backslash W / W_I} \mathscr{F}\!\ell^w_{G,\mu}. \]
The dimension of the Schubert cell $\mathscr{F}\!\ell^{w}_{G,\mu}$ is $\sum_{\mathfrak{p}\mid p} \frac{\tau(w_{\mathfrak{p}})(2n-\tau(w_{\mathfrak{p}})+1)}{2}$.

\medskip
After these observations, we now describe the Hodge--Tate period morphism $\pi_{\mathrm{HT}} \colon {\mathcal X}^*_{\widetilde{\mathbf{1}}} \to \mathscr{F}\!\ell_{G,\mu}$ on geometric points over the open part.
If $D$ is a complete, algebraically closed extension of $C$, a point $x \in {\mathcal X}_{\widetilde{\mathbf{1}}}(D,{\mathcal O}_D)$ gives an abelian variety $A$ of dimension $nf$ over $D$ and a symplectic isomorphism $V \otimes_{\mathbb Q} \Q_p \xrightarrow{\sim} V_p(A)$.
The image of $x$ under $\pi_{\mathrm{HT}}$ is the point of $\mathscr{F}\!\ell_{G,\mu}(D,{\mathcal O}_D) \subset \prod_{\mathfrak{p} \mid p} \mathscr{G}\!r(n,2n)(D,{\mathcal O}_D)$ corresponding to
\[ (\Lie A)(1) \subset V_p(A) \otimes_{\Q_p} D \simeq \prod_{\mathfrak{p} \mid p} V \otimes_{F,\iota_\mathfrak{p}} D \simeq \prod_{\mathfrak{p} \mid p} D^{2n}. \]
This immediately yields the following analogue of Lemma~\ref{moduli description of Schubert cells}.
\begin{lemma}
  Let $D$ be a complete, algebraically closed extension of $C$.
  Let $x$ be a $\Spa(D,{\mathcal O}_D)$-point of ${\mathcal X}_{\widetilde{\mathbf{1}}}$ with corresponding abelian variety $A/D$ and trivialization $V \otimes_{\mathbb Q} \Q_p \xrightarrow{\sim} V_pA$.
  For every prime $\mathfrak{p} \mid p$ of $F$, let $U_{A,\mathfrak{p}}$ be the intersection of
  \[ (\Lie A)(1)^{\iota_\mathfrak{p}} \colonequals (\Lie A)(1) \cap (V \otimes_{F,\iota_\mathfrak{p}} D) \subset V \otimes_{F,\iota_\mathfrak{p}} D \simeq D^{2n} \]
  with the canonical line $U_{0,D}$.
  Then the preimage of $\mathscr{F}\!\ell^w_{G,\mu}$ under $\pi_{\mathrm{HT}}$ in ${\mathcal X}_{\widetilde{\mathbf{1}}}$ is the relatively partially proper locus whose $\Spa(D,{\mathcal O}_D)$-points are precisely those for which $U_{A,\mathfrak{p}}$ has dimension $n-\tau(w_\mathfrak{p})$ for every $\mathfrak{p}$.
\end{lemma}

Let $w_0$ be the longest element of $W$.
As in Section~\ref{open cover of flag variety},
we will consider a cover of $\mathscr{F}\!\ell_{G,\mu}$ by translates of $\mathscr{F}\!\ell_{G,\mu}^{w_0}$,
which are indexed by $W/W_I$.
First, we transfer Remark~\ref{coset representatives} and give a concrete description of $W/W_I$.
\begin{remark}\label{coset representatives Siegel}
  Let $\mathfrak{p} \mid p$.
  Let $\Sigma_\mathfrak{p}$ be the set of subsets $J_\mathfrak{p} \subset \{1,\dotsc,2n\}$ of the form $J_{\mathfrak{p},1} \sqcup J_{\mathfrak{p},2}$, where $J_{\mathfrak{p},1}\subseteq \{1,\dotsc,n\}$ is any subset and
  \[J_{\mathfrak{p},2} = \{j\in \{n+1,\dotsc,2n\} \;\ifnum\currentgrouptype=16 \middle\fi|\; j-n\notin J_{\mathfrak{p},1}\}.\]
  By Example~\ref{Sp_2n-example-part-1}, the Weyl group $W_\mathfrak{p}$ is the subgroup of $S_{2n}$ that stabilizes $\Sigma_\mathfrak{p}$.
  Furthermore, $W_{\mathfrak{p},I}$ is the subgroup of $W_\mathfrak{p}$ that fixes $\{1,\dots,n\}$.
  Hence, $\Sigma_\mathfrak{p} \simeq W_\mathfrak{p}/W_{\mathfrak{p},I}$;
  concretely, this identification is given by associating to $J_\mathfrak{p} \in \Sigma_\mathfrak{p}$ the element $w_{J_\mathfrak{p}}$ which fixes $J_{\mathfrak{p},1}$ elementwise, swaps $\{1,\dotsc,n\} \smallsetminus J_{\mathfrak{p},1}$ and $J_{\mathfrak{p},2}$, and fixes $\{n+1,\dotsc,2n\} \smallsetminus J_{\mathfrak{p},2}$ elementwise.

  Set $\Sigma \colonequals \prod_\mathfrak{p} \Sigma_\mathfrak{p}$.
  Again, $\Sigma \simeq W/W_I$ by identifying $J = (J_\mathfrak{p})_\mathfrak{p}$ with $w_J \colonequals (w_{J_\mathfrak{p}})_\mathfrak{p}$.
\end{remark}
We use the choice of standard basis $e_1,\ldots,e_{2n}$ of $V$ to construct a collection of \emph{standard} Lagrangian subspaces of $V$.
Let $\mathfrak{p}\mid p$ and consider the $C$-vector space $V\otimes_{F,\iota_{\mathfrak{p}}}C$ with the same choice of basis $e_1,\ldots, e_{2n}$.
We associate to each $J_{\mathfrak{p}}$ as in Remark~\ref{coset representatives Siegel} the standard Lagrangian subspace
\[U_{J_{\mathfrak{p}}} = \langle e_j\;|\; i\in J_{\mathfrak{p}}\rangle\subseteq V\otimes_{F,\iota_{\mathfrak{p}}}C.\]

The $U_{J_{\mathfrak{p}}}$ can be used to construct a basic affine open cover
\[ \mathscr{F}\!\ell_{G,\mu} = \bigcup_{J \in \Sigma} \mathscr{F}\!\ell^J_{G,\mu}. \]
Under the embedding into $\prod_{\mathfrak{p}\mid p}\mathrm{Gr}(n,2n)$, define the open subset corresponding to $J = (J_{\mathfrak{p}})_{\mathfrak{p}}$ as
\[\mathrm{Fl}_{G,\mu}^{J} \colonequals \biggl\{(U_\mathfrak{p})_\mathfrak{p} \in \prod_{\mathfrak{p}\mid p}\mathrm{Gr}(n,2n) \;\bigg\vert\; U_{\mathfrak{p}}\ \mathrm{tot.\ isotropic, }\, U_{\mathfrak{p}}\cap U_{J_{\mathfrak{p}}}= 0\biggr\}.\]
Set $\mathscr{F}\!\ell_{G,\mu}^{J}$ to be the associated adic space.
Denote by $\delta \colon W/W_I \to W_I \backslash W /W_I$ the natural projection.
The proof of the following analogue of Lemma~\ref{finding a J} carries over directly.
\begin{lem}\label{finding a J - Siegel}
  Let $w \in W_I \backslash W / W_I$ and $x \in \mathscr{F}\!\ell^w_{G,\mu}$ be a point.
  Then there exists $J \in \delta^{-1}(ww_0)$ such that $x \cdot N_0 \subset \mathscr{F}\!\ell^J_{G,\mu}$.
\end{lem}
As in the unitary case, we define
$$ \mathscr{F}\!\ell_{G,\mu}^\mathrm{nc} \colonequals \mathscr{F}\!\ell_{G,\mu}^{w_{0}} = \mathscr{F}\!\ell_{G,\mu}^{J} $$
for $J=(J_{\mathfrak{p}})_{\mathfrak{p}}$ with $J_{\mathfrak{p}}=\{1,\dots,n\}$ for all $\mathfrak{p}$ and let $\mathscr{F}\!\ell_{G,\mu}^{a}\subseteq \mathscr{F}\!\ell_{G,\mu}^\mathrm{nc}$ be the corresponding affinoid subset (defined by the condition that the reduction of $U_{\mathfrak{p}}$ is disjoint from the reduction of $U_{\{1,\dots,n\}}$ for all $\mathfrak{p}$). If we consider the embedding of $\mathscr{F}\!\ell_{G,\mu}$ into the corresponding adic flag variety for ${\rm Sp}(V)$, then $\mathscr{F}\!\ell_{G,\mu}^{a}$ and $\mathscr{F}\!\ell_{G,\mu}^\mathrm{nc}$ are obtained by intersecting the analogous loci in the flag variety for ${\rm Sp}(V)$ with $\mathscr{F}\!\ell_{G,\mu}$. As in subsection \ref{hodgetatemapsection}, we set
\[
  \gamma_{\mathfrak{p}}\colonequals \mathrm{diag}(p^{(n)},1^{(n)})\in \mathrm{GSp}_{2n}(F_{\mathfrak{p}})\simeq \mathrm{GSp}_{2n}({\mathbb Q}_p)
\]
for all $\mathfrak{p}$ and let $\gamma=(\gamma_{\mathfrak{p}})_{\mathfrak{p}} \in \widetilde{G}(\Q_p)$ (the similitude factor of $\gamma_{\mathfrak{p}}$ is independent of $\mathfrak{p}$, so $\gamma$ lies in $\widetilde{G}(\Q_p)$); we also have $\gamma=\mu(p)$. Then, setting $\mathscr{F}\!\ell_{G,\mu}^\mathrm{nc}(k) \colonequals \mathscr{F}\!\ell_{G,\mu}^{a}\cdot \gamma^{k}$ for $k \in {\mathbb Z}_{\geq 0}$, we have
$$ \mathscr{F}\!\ell_{G,\mu}^\mathrm{nc} = \bigcup_{k \in {\mathbb Z}_{\geq 0}} \mathscr{F}\!\ell_{G,\mu}^\mathrm{nc}(k) $$
and the sets $\mathscr{F}\!\ell_{G,\mu}^{a}\cdot \gamma^{-k}$ form a basis of (quasicompact) open neighborhoods of a (rank one) point in $\mathscr{F}\!\ell_{G,\mu}$; this can be proved exactly as the analogous statement in the unitary case (Proposition \ref{cover of flag nc}) by considering Pl\"ucker coordinates. Turning our attention to the Hodge--Tate period map $\pi_{\mathrm{HT}} \colon {\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast} \to \mathscr{F}\!\ell_{G,\mu}$, we define ${\mathcal X}_{\widetilde{\mathbf{1}}}^{\ast,\mathrm{nc}} \colonequals \pi_{\mathrm{HT}}^{-1}(\mathscr{F}\!\ell_{G,\mu}^\mathrm{nc})$.

\begin{prop}\label{expanding the anticanonical locus siegel} For any sufficiently small $\epsilon >0$, we have
\[
{\mathcal X}^{*,\mathrm{nc}}_{\widetilde{\mathbf{1}}}= \bigcup_{k\in {\mathbb Z}_{\geq 0}} {\mathcal X}^*_{\widetilde{\mathbf{1}}}(\epsilon)_{a} \cdot \gamma^{k}.
\]
\end{prop}

This is proved in the same way as its unitary analogue Proposition \ref{expanding the anticanonical locus}, using the embedding into the Shimura datum for ${\rm GSp}(V)$. Next, we consider the results of subsection \ref{perfectoid strata at intermediate levels}. For each $J \in \Sigma$ as in Remark~\ref{coset representatives Siegel}, we define the closed subgroup of $\widetilde{P}_{\mu,0}$
\[ \widetilde{N}_{0,J} \colonequals \left(\widetilde{N} \cap w_J \widetilde{P}_{\mu} w_J^{-1}\right)(\Z_p) = \left\{(g,r)\in \widetilde{G}({\mathbb Z}_p)\;\ifnum\currentgrouptype=16 \middle\fi|\;
g_\mathfrak{p} = \begin{pmatrix} I_n & * \\ 0 & I_n \end{pmatrix},
w_{J_\mathfrak{p}}^{-1} g_\mathfrak{p} w_{J_\mathfrak{p}}= \begin{pmatrix} * & *\\ 0 & * \end{pmatrix} \right\}. \]
The proof of Lemma~\ref{ranks} applies verbatim to the Hilbert--Siegel case and gives
\begin{lemma}\label{ranks - siegel}
  We have $\rank_{\Z_p} \widetilde{N}_{0,J} = \dim \mathscr{F}\!\ell^{w_J w_0}_{G,\mu}$.
  Moreover, $\widetilde{N}_{0,J}$ is a saturated $\Z_p$-submodule of $\widetilde{N}_{0}$, so $\rank_{\Z_p} \widetilde{N}_0/\widetilde{N}_{0,J} = f \cdot \frac{n(n+1)}{2} - \dim \mathscr{F}\!\ell^{w_J w_0}_{G,\mu}$.
\end{lemma}

If $\widetilde{H} \subseteq \widetilde{G}(\Z_p)$ closed, we may define a morphism of sites
\[
\pi_{\mathrm{HT}/\widetilde{H}}\colon ({\mathcal X}^*_{\widetilde{H}})_{\mathrm{\acute{e}t}} \to
|{\mathcal X}^*_{\widetilde{H}}|\xrightarrow{\sim} |{\mathcal X}^*_{\widetilde{\mathbf{1}}}|/ \widetilde{H} \to |\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H},
\]
using the Hodge--Tate period map $\pi_{\mathrm{HT}}$. If $\widetilde{H} \subseteq \widetilde{N}_{0,J}$ and $J \in \Sigma$, we set
\[ {\mathcal X}^{*,J}_{\widetilde{H}} \colonequals \pi^{-1}_{\mathrm{HT}/\widetilde{H}}(|\mathscr{F}\!\ell^J_{G,\mu}|/\widetilde{H}). \]
Here we note that $\mathscr{F}\!\ell_{G,\mu}^{J}$, and more generally $\mathscr{F}\!\ell_{G,\mu}^{J}(k) \colonequals \mathscr{F}\!\ell_{G,\mu}^\mathrm{nc}(k)\cdot \gamma^{k}$ for $k \geq 0$, is stable under $\widetilde{N}_{0,J}$ by the same argument as in the proof of Lemma \ref{standard neighborhoods are stable}. We then get the following analogue of Theorem \ref{general perfectoid stratum}, with the same proof.
\begin{thm}\label{general perfectoid stratum - siegel}
  Let $\widetilde{H} \subseteq \widetilde{N}_{0,J}$ be a closed subgroup. The diamond ${\mathcal X}^{*,J}_{\widetilde{H}}$ is a perfectoid space.
  More precisely, $|{\mathcal X}^{*,J}_{\widetilde{H}}|$ is covered by the increasing union of quasicompact open subsets $|{\mathcal X}^*_{\widetilde{\mathbf{1}}}(\epsilon)_{a}|\gamma^kw^{-1}_J/\widetilde{H}$ for $k \in {\mathbb Z}_{\geq 0}$ (and sufficiently small $\epsilon >0$), and the corresponding spatial diamonds are affinoid perfectoid with strongly Zariski closed boundary.
\end{thm}

\subsection{The vanishing theorem in the Hilbert--Siegel case}
With the main ingredients in place, the arguments in the proof of Theorem~\ref{main thm} can be easily adapted to prove Theorem~\ref{main thm - siegel}; we will now briefly outline this.

\medskip
Take $\widetilde{K}$ as in the statement of Theorem \ref{main thm - siegel} and set $\widetilde{H} = \widetilde{K} \cap \widetilde{N}_{0}$. The same sequence of comparison theorems as in subsection~\ref{subsect:first-reductions} allows us to consider
\[ H^i_\mathrm{\acute{e}t}\bigl({\mathcal X}^*_{\widetilde{H}},j_!({\mathcal O}^+_{{\mathcal X}}/p)^a\bigr). \]
Here and in what follows, we will use the conventions from subsection~\ref{subsect:first-reductions}: for any level $\widetilde{H} \subseteq \widetilde{G}(\Z_p)$ and any quasi-pro-\'etale ${\mathcal V} \to {\mathcal X}^*_{\widetilde{H}}$, the inclusion of the open part is denoted by $j\colon {\mathcal V} \times_{{\mathcal X}^*_{\widetilde{H}}} {\mathcal X}_{\widetilde{H}} \hookrightarrow {\mathcal V}$, and $({\mathcal O}_{{\mathcal X}}^{+}/p)^{a}$ denotes the almost sheaf $({\mathcal O}_{{\mathcal V}}^{+}/p)^{a}$ on any quasi-pro-\'etale ${\mathcal V} \to {\mathcal X}$.  Moreover, we set $\pi \colonequals \pi_{\mathrm{HT}/\widetilde{H}}$, ${\mathcal F}^i \colonequals R^i\pi_*j_!({\mathcal O}^+_{\mathcal X}/p)^a$, and $d(w) \colonequals \dim \mathscr{F}\!\ell^w_{G,\mu}$.

\medskip
The Schubert cells $\mathscr{F}\!\ell^w_{G,\mu}$ are $\widetilde{H}$-invariant and therefore also give a stratification
\[ |\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H} = \bigsqcup_{w \in W_I \backslash W / W_I} |\mathscr{F}\!\ell^w_{G,\mu}|/\widetilde{H}. \]
The exact same argument as in Subsection~\ref{subsect:first-reductions}, using the Leray spectral sequence
\[ E^{rs}_2=H^r(|\mathscr{F}\!\ell_{G,\mu}|/\widetilde{H},R^s\pi_{\ast}j_!({\mathcal O}_{{\mathcal X}}^+/p)^a) \implies H^{r+s}_{\mathrm{\acute{e}t}}({\mathcal X}_{\widetilde{H}}^*,j_!({\mathcal O}_{{\mathcal X}}^+/p)^a) \]
and Scheiderer's result that the cohomological dimension of a spectral space is bounded above by its Krull dimension, shows that Theorem~\ref{main thm - siegel} results from the next statement.

\begin{thm}\label{vanishing of higher direct images on schubert cells - siegel}
  Let $w\in W_I\backslash W/W_I$ and $x \in |\mathscr{F}\!\ell^w_{G,\mu}|$. Then for all $i > d - d(w)$,
  \[ R^i\pi_{\mathrm{HT}/\widetilde{N}_0,*}j_!({\mathcal O}^+_{\mathcal X}/p)^a_x = 0. \]
\end{thm}

To prove this, we argue precisely as in the proof of Theorem \ref{bound on higher direct images}. By base change and the same reduction argument as in Lemma~\ref{reduction to rank one} via specialization maps, the assertion follows if we show
\[ H^i_\mathrm{\acute{e}t}(\pi^{-1}(x),j_!({\mathcal O}^+_{\mathcal X}/p)^a) = 0 \]
for all rank one points $x\in |\mathscr{F}\!\ell_{G,\mu}^w|/\widetilde{H}$ and all $i>d-d(w)$.

\medskip
Emulating the discussion preceding Lemma~\ref{cover pi^-1(x)}, choose a lift $\widetilde{x}\in |\mathscr{F}\!\ell_{G,\mu}^w|$ of $x$.
By Lemma \ref{finding a J - Siegel}, there exists $J\in \delta^{-1}(ww_0)$ such that
$\widetilde{x}\widetilde{N}_0\subseteq |\mathscr{F}\!\ell_{G,\mu}^J|$.
Set $\widetilde{H}_{J} \colonequals \widetilde{H} \cap \widetilde{N}_{0,J}$ and let $x_J$ be the image of $\widetilde{x}$ in $|\mathscr{F}\!\ell^w_{G,\mu}| / \widetilde{H}_{J}$. Write $\pi_J \colonequals \pi_{\mathrm{HT}/\widetilde{H}_{J}}$ and consider the spatial diamond $V_J \colonequals \pi^{-1}_J(x_J(\widetilde{H}/\widetilde{H}_{J}))$.
As in Lemma~\ref{cover pi^-1(x)}, we see that the natural map $V_J \to \pi^{-1}(x)$ is a v-cover and $V_J \cap {\mathcal X}_{\widetilde{H}_{J}} \to \pi^{-1}(x) \cap {\mathcal X}_{\widetilde{H}}$ an $\widetilde{H}/\widetilde{H}_{J}$-torsor.
By Lemma~\ref{ranks - siegel}, the $\Z_p$-rank of $\widetilde{N}_0/\widetilde{N}_{0,J}$ is $d-d(w)$ and since the $\Z_p$-submodule $\widetilde{H} \subseteq \widetilde{N}_{0}$ has finite index, it follows that the same holds for $\widetilde{H}/\widetilde{H}_{J}$.
Hence, the cohomological dimension for continuous cohomology of $\widetilde{H}/\widetilde{H}_{J}$ is $d-d(w)$.
Using the Hochschild--Serre spectral sequence (Theorem \ref{hochschildserre}) and that $x_J(\widetilde{N}_0/\widetilde{N}_{0,J})$ is profinite, we reduce the assertion as in Subsection~\ref{sec: proof of main thm} to showing that
\[ H^s_\mathrm{\acute{e}t}(\pi^{-1}_J(x_J),j_!({\mathcal O}^+_{\mathcal X}/p)^a) = 0 \]
for all $s > 0$.

\medskip
Next, arguing as in the discussion preceding Proposition~\ref{cohomology vanishing for rational neighborhoods},
we choose a sufficiently small $\epsilon > 0$ and large enough integers $k$ and $k'$ such that
\[ \pi^{-1}_\mathrm{HT}(\widetilde{x}\widetilde{H}_{J}) \subseteq |{\mathcal X}^*_{\widetilde{\mathbf{1}}}(\epsilon)_a|\gamma^kw^{-1}_J \subseteq \pi^{-1}_\mathrm{HT}(\mathscr{F}\!\ell^J_{G,\mu}(k')). \]
Using Proposition~\ref{rational neighborhood}, we find a collection of $\widetilde{H}_{J}$-stable, rational, open subsets $U_t \subseteq \mathscr{F}\!\ell^J_{G,\mu}(k')$, $t \in T$, such that
\[ \bigcap_{t \in T} |U_t|/\widetilde{H}_{J} = x_J \]
and $\pi^{-1}_\mathrm{HT}(U_t) \subseteq |{\mathcal X}^*_{\widetilde{\mathbf{1}}}(\epsilon)_a|\gamma^kw^{-1}_J$.
It thus suffices to prove that
\[ H^s_\mathrm{\acute{e}t}(\pi^{-1}_J(|U_t|/\widetilde{H}_{J}),j_!({\mathcal O}^*_{\mathcal X}/p)^a) = 0 \]
for all $s > 0$ and all $t \in T$.
This is proved in the same way as Proposition~\ref{cohomology vanishing for rational neighborhoods}:
the preimage
\[ V_m \colonequals |\pi^{-1}_\mathrm{HT}(U_t)|/(\widetilde{H}_{J} \cap \widetilde{\Gamma}(p^m)) \subseteq |{\mathcal X}^*_{\widetilde{\mathbf{1}}}(\epsilon)_a|\gamma^k w^{-1}_J/(\widetilde{H}_{J} \cap \widetilde{\Gamma}(p^m)) \]
is already rational for some (large enough) $m \in {\mathbb Z}_{\geq 0}$ and therefore affinoid perfectoid with strongly Zariski closed boundary by Theorem~\ref{general perfectoid stratum - siegel}.
Then
\[ H^s_\mathrm{\acute{e}t}(\pi^{-1}_J(|U_t|/\widetilde{H}_{J}),j_!({\mathcal O}^*_{\mathcal X}/p)^a) = H^s_\mathrm{\acute{e}t}(V_m/G_m,j_!({\mathcal O}^+_{\mathcal X}/p)^a) = 0 \]
(where again $G_m = \widetilde{H}_{J}/(\widetilde{H}_{J} \cap \widetilde{\Gamma}(p^m))$) using Lemma~\ref{shriekbasechange} and Proposition~\ref{strongly Zariski closed vanishing}, since $V_{m}/G_{m} \to \pi_{J}^{-1}(|U_t|/\widetilde{H}_{J})$ is an isomorphism over the open part. This finishes the proof of Theorem \ref{main thm - siegel}.

\section{Eliminating the nilpotent ideal}\label{Borel-Serre}

\subsection{Setup} In this section, we let $n\geq 2$, $F$ be a CM field
and $G$ be one of the following reductive groups over ${\mathbb Q}$.
If $F$ is totally real, we let $G\colonequals \mathrm{Res}_{F/{\mathbb Q}}\mathrm{Sp}_{2n}$.
If $F$ is an imaginary CM field, we let $G$ be
the quasi-split unitary group defined in Section~\ref{subsect:unitary_group}.
In either case, we let $M\colonequals \mathrm{Res}_{F/{\mathbb Q}}\GL_n$ and
$P$ be the maximal Siegel parabolic subgroup of $G$ (that was denoted by $P_{\mu}$
in previous sections). Then $P$ has a Levi decomposition $P=MN$, with $N$ the unipotent radical.

If $\mathrm{G}$ is a connected linear algebraic group over ${\mathbb Q}$,
we consider a space of type $S-{\mathbb Q}$ for $\mathrm{G}$,
in the sense of~\cite[\S 2]{borel-serre} (see also~\cite[\S 3.1]{newton-thorne}). This is a pair consisting of a homogeneous
space $X^{\mathrm{G}}$ for $\mathrm{G}({\mathbb R})$ and a family of Levi subgroups
of $\mathrm{G}_{{\mathbb R}}$ satisfying certain conditions. From~\cite[Lem.~2.1]{borel-serre},
the homogeneous space $X^{\mathrm{G}}$ is determined up to isomorphism. We will
refer to $X^{\mathrm{G}}$ as \emph{the symmetric space} for $\mathrm{G}$.
In this section, we will consider symmetric and locally symmetric spaces spaces for $G$, $P$, $N$, and $M$, which we
index by the corresponding groups. For example, $X^G$ will be the symmetric space
for $G$ and, when $K\subset G(\AA_f)$ is a compact open subgroup,
the locally symmetric space for $G$ at level $K$ is the adelic double quotient
\[
X^G_{K}\colonequals G({\mathbb Q})\backslash \left(X^G\times G(\AA_f)\right)/K.
\]
Similarly, $X^M$ and $X^M_{K_M}$ denote
the symmetric space for $M$ and the
locally symmetric space at level $K_M\subset M(\AA_f)$. We will only consider the
locally symmetric spaces as adelic double quotients and when the level is \emph{neat},
in which case the corresponding locally symmetric spaces are smooth Riemannian manifolds.
For our arguments to go through, we will need a slightly stronger assumption,
namely that the level is \emph{small}, as in~\cite[Def. 5.6]{newton-thorne}.
This implies neatness.  We will consider the singular cohomology of these manifolds (either the usual one
or the cohomology with compact support). These locally symmetric spaces admit
Borel--Serre compactifications, which are compact real manifolds with corners; an important
property states that the embedding
of a locally symmetric space into its Borel--Serre compactification is a homotopy
equivalence.

\begin{lemma}\label{free action} Let $K, K'\subset G(\AA_f)$ be neat compact open subgroups with $K'\subset K$ normal.
The finite group $K/K'$ acts freely on $X^{G,\mathrm{BS}}_{K'}$ with quotient $X^{G,\mathrm{BS}}_{K}$.
\end{lemma}

\begin{proof} On the open parts $X^G_{K'}$ and $X^G_K$, this follows from the definition
of locally symmetric spaces and from neatness. The point is that, when $K$ is neat, $G({\mathbb Q})\backslash \( X^G\times G(\AA_f) \)$ is
a free $K$-space in the sense of~\cite[Def. 2.16]{newton-thorne}. This argument can be extended to the boundary
of the Borel--Serre compactification using~\cite[Lemma 3.10]{newton-thorne}, which gives an explicit description of
the boundary strata.
\end{proof}

The locally symmetric spaces $X^G_{K}$ can be identified with the underlying complex
manifolds associated to the Shimura varieties for $G$ at level $K$; these are the Shimura varieties
considered in Sections~\ref{recollections},~\ref{stratifications}, and~\ref{vanishing} for $F$ imaginary CM
and in Section~\ref{Siegel case} for $F$ totally real.
From now on, set
\[
d\colonequals\frac{1}{2}\mathrm{dim}_{{\mathbb R}}(X^G) = \dim_{\CC}(X^G).
\]
This is the middle degree for the cohomology of $X^G_{K}$.

To describe the class of compact open subgroups, we need to choose a flat, affine group scheme over ${\mathbb Z}$ with generic fiber $M$.
In this case, we take the integral model $\mathrm{Res}_{{\mathcal O}_F/{\mathbb Z}}\GL_n$,
which we still denote by $M$ by an abuse of notation.  Let $K_M\subseteq M(\AA_f)$
be a small compact open subgroup, which satisfies the additional
property that
\[
K_M=\prod_{w}K_{M,w},\ \mathrm{where}\ K_{M,w}\subseteq \GL_n({\mathcal O}_{F,w}),
\]
and where the product runs over primes $w$ of $F$. The corresponding locally symmetric
space $X^M_{K_M}$ is a smooth, orientable
Riemannian manifold of dimension
$d-1$.

Let $p$ be a rational prime which satisfies the following assumption.
\begin{assumption}\label{split completely} The prime $p$ splits completely in the CM field $F$.
\end{assumption}
\noindent
Let $\lambda$ be a Weyl orbit of weights of $M$. This determines an irreducible algebraic representation $\sigma_{\lambda}$ of $M$, which can
be defined over ${\mathbb Q}_p$ (as $M\times_{{\mathbb Q}}{\mathbb Q}_p$ is split). There is a natural $M({\mathbb Z}_p)$-stable
lattice $\sigma^\circ_{\lambda}\subset \sigma_{\lambda}$, known as the dual Weyl module (see~\cite{jantzen} for more details). This gives rise in
the usual way to a local system on $X^M_{K_M}$, which we denote by ${\mathcal V}_{\lambda}$.

Let $\iota\colon \overline{{\mathbb Q}}_p\xrightarrow{\sim} \CC$ be an isomorphism. We let $S$ be a finite set of primes of ${\mathbb Q}$,
containing $p$, all the primes which ramify in $F$, and all the primes where the level $K_M$ is not
hyperspecial. We let $\mathbb{T}^S_{M}$ denote the abstract Hecke algebra for $M$ over ${\mathbb Z}_p$,
defined as the product of spherical Hecke algebras at primes away from $S$
\[
\mathbb{T}^S_{M}\colonequals  \otimes_{l\not\in S,w\mid l} \mathbb{T}_{M,w}, \quad \mathbb{T}_{M,w}
\colonequals {\mathbb Z}_p[\GL_n(F_w)//\GL_n({\mathcal O}_{F,w})],
\]
where $w$ runs over the primes of $F$ above $l\not\in S$.
For such a prime $w$, we let $q_w$ be the cardinality of its residue field and $q_{w}^{1/2}\in \overline{{\mathbb Z}}_p$ denote the inverse image of the positive
square root of $q_{w}$ in $\CC$ under $\iota$. The Satake transform gives a canonical isomorphism
\[
\mathbb{T}_{M,w}[q^{1/2}_{w}]\simeq {\mathbb Z}_p[q_{w}^{1/2}][X^{\pm 1}_1,\dots, X^{\pm 1}_{n}]^{S_{n}},
\]
with $S_n$ the symmetric group on $n$ elements.
For $i=1,\dots, n$, define $T_{i,w}$ to be $q_w^{i(n-i)/2}$ times the $i$-th elementary symmetric polynomial in $X_1,\dots,X_{n}$.

The Hecke algebra $\mathbb{T}^S_{M}$ acts in the usual way on $H^*(X^M_{K_M}, {\mathcal V}_\lambda)$. We consider
the Hecke algebra
\[
\mathbb{T}^S_{M}\left(K_M,\lambda\right)\colonequals \mathrm{Im}\left(\mathbb{T}^S_{M}\to \mathrm{End}_{{\mathbb Z}_p}\left(H^*(X^M_{K_M}, {\mathcal V}_\lambda)\right)\right).
\]
Let $\mathfrak{m}\subset \mathbb{T}^S_{M}\left(K_M,\lambda\right)$ be a maximal ideal. The following is~\cite[Cor.~5.4.3]{scholze-galois}
(with slightly different normalizations, which are consistent with~\cite{newton-thorne}).

\begin{thm}\label{residual Galois rep} There exists a unique continuous semisimple Galois representation
\[
\bar{\rho}_{\mathfrak{m}}\colon \mathrm{Gal}(\overline{F}/F)\to \GL_n(\overline{{\mathbb F}}_p)
\]
such that, for every prime $w$ of $F$ above $l\not\in S$, the characteristic polynomial of $\bar{\rho}_{\mathfrak{m}}(\mathrm{Frob}_w)$ is equal to the image of
\[
P_{M,w}(X) = X^{n} - T_{1,w}X^{n-1}+\dots + (-1)^iq_{w}^{i(i-1)/2}T_{i,w}X^{n-i} +\dots + q_{w}^{n(n-1)/2}T_{n,w}
\]
modulo $\mathfrak{m}$.
\end{thm}

\noindent From now on, we also impose the following assumption on $\mathfrak{m}$, which is known as a \emph{non-Eisenstein} condition.

\begin{assumption}\label{non-Eisenstein} The Galois representation $\bar{\rho}_{\mathfrak{m}}$ is absolutely irreducible.
\end{assumption}

\noindent This has the following consequence.

\begin{lemma}\label{eliminating degree 0} For any $r\in {\mathbb Z}_{\geq 1}$, we have
\[
H^0(X^M_{K_M},{\mathcal V}_{\lambda}/p^r)_{\mathfrak{m}} = 0.
\]
\end{lemma}

\begin{proof}
By \cite[Thm.\ 4.2]{newton-thorne}, the map
$H^0_c(X^M_{K_M},{\mathcal V}_{\lambda}/p^r)_{\mathfrak{m}} \to
H^0(X^M_{K_M},{\mathcal V}_{\lambda}/p^r)_{\mathfrak{m}}$ is an isomorphism.
Every connected component of $X^M_{K_M}$ is noncompact and
${\mathcal V}_{\lambda}/p^r$ is a local system, so
$H^0_c(X^M_{K_M},{\mathcal V}_{\lambda}/p^r)=0$.
\end{proof}

The goal of this section is to prove a
strengthening of~\cite[Thm.~5.4.4]{scholze-galois} and~\cite[Thm.~1.3]{newton-thorne} in our situation.
In order to state the main result, we need to introduce the derived Hecke algebra.\footnote{This is in the sense of~\cite{newton-thorne}, who consider an enhancement of the
usual notion of Hecke algebra living in the derived category, rather than in the sense of
Venkatesh, who considers additional ``derived'' Hecke operators.}

We let $C_\bullet$ be the complex of
singular chains with ${\mathbb Z}$-coefficients valued in
$X^{M}\times M(\AA_f)$; this is a complex of ${\mathbb Z}[M({\mathbb Q})\times M(\AA_f)]$-modules.
We consider $\sigma_\lambda$ as a representation of $M(\AA_f)$ via the projection to the component $M({\mathbb Q}_p)$.
We define the complex
\[
C(K_M,\lambda)\colonequals \mathrm{Hom}_{M({\mathbb Q})\times K_M}(C_\bullet, \sigma^\circ_{\lambda}).
\]
Then $C(K_M,\lambda)$ computes the cohomology of the manifold $X^M_{K_M}$ with coefficients
in the local system $\mathcal{V}_\lambda$
(see, for example, ~\cite[Prop. 6.2]{khare-thorne}).  We will mostly think of the complex $C(K_M,\lambda)$
as an object in the derived category $D({\mathbb Z}_p)$ of complexes of ${\mathbb Z}_p$-modules,
where it is identified with $R\Gamma(X^M_{K_M},\mathcal{V}_{\lambda})$. There is a natural action of
$\mathbb{T}^S_M$ on $C(K_M,\lambda)$.
Consider the Hecke algebra
\[
\mathbb{T}^S_{M}\left(K_M, \lambda\right)^{\mathrm{der}}\colonequals \mathrm{Im}\left(\mathbb{T}^S_{M}\to \mathrm{End}_{D({\mathbb Z}_p)}\left(C(K_M,\lambda)\right)\right).
\]
We can localize this at a maximal ideal $\mathfrak{m}\subset  \mathbb{T}^S_{M}$. The following is the main theorem of this section.

\begin{thm}\label{eliminating nilpotent ideal} Let $p$ be a rational prime which splits completely in $F$ and $\mathfrak{m}$ a non-Eisenstein maximal ideal.
Then there exists a unique continuous Galois
representation
\[
\rho_{\mathfrak{m}}\colon \mathrm{Gal}(\overline{F}/F)\to \GL_n\left(\mathbb{T}^S_{M}\left(K_M,\lambda\right)^{\mathrm{der}}_{\mathfrak{m}}\right)
\]
such that, for every prime $w$ of $F$ above $l\not\in S$, the characteristic polynomial of $\rho_{\mathfrak{m}}(\mathrm{Frob}_w)$ is equal to
\[
P_{M,w}(X) = X^{n} - T_{1,w}X^{n-1}+\dots + (-1)^iq_{w}^{i(i-1)/2}T_{i,w}X^{n-i} +\dots + q_{w}^{n(n-1)/2}T_{n,w}.
\]
\end{thm}

\noindent The proof of Theorem \ref{eliminating nilpotent ideal} will take up the remainder of Section \ref{Borel-Serre}. Note that we have a surjection with nilpotent kernel
\[
\mathbb{T}^S_{M}\left(K_M,\lambda\right)^{\mathrm{der}}\twoheadrightarrow \mathbb{T}^S_{M}\left(K_M,\lambda\right),
\]
so Theorem~\ref{eliminating nilpotent ideal} also gives rise to a Galois representation valued in $\mathbb{T}^S_{M}\left(K_M,\lambda\right)$.

Because $X^M_{K_M}$ has the same homotopy type as its Borel--Serre compactification $X_{K_M}^{M,\mathrm{BS}}$,
the complexes $C(K_M,\lambda)$ are perfect complexes of ${\mathbb Z}_p$-modules.
For $r\geq 1$,
also define
\[
C(K_M,\lambda,r) \colonequals \mathrm{Hom}_{M({\mathbb Q})\times K_M}(C_\bullet, \sigma^\circ_{\lambda}/p^r),
\]
which are perfect complexes of $\Lambda\colonequals {\mathbb Z}/p^r{\mathbb Z}$-modules. When $\lambda = \lambda_{0}$ is the trivial weight, we simply write $C(K_M,r)\colonequals C(K_M,\lambda_0,r)$. For every $r\in {\mathbb Z}_{\geq 1}$, also consider the Hecke algebras
\[
\mathbb{T}^S_{M}\left(K_M, \lambda, r\right)^{\mathrm{der}}\colonequals \mathrm{Im}\left(\mathbb{T}^S_{M}\to \mathrm{End}_{D({\mathbb Z}_p)}\left(C(K_M,\lambda,r)\right)\right).
\]
By~\cite[Lemma 3.12]{newton-thorne}, we have an isomorphism
\[
\mathbb{T}^S_{M}\left(K_M,\lambda\right)^{\mathrm{der}}\xrightarrow{\sim} \varprojlim_{r}\mathbb{T}^S_{M}\left(K_M,\lambda,r\right)^{\mathrm{der}}.
\]
The Galois representation $\rho_{\mathfrak{m}}$ will be constructed as the inverse limit over $r\in {\mathbb Z}_{\geq 1}$ of Galois representations valued in
$\mathbb{T}^S_{M}\left(K_M, \lambda,r\right)^{\mathrm{der}}_{\mathfrak{m}}$.

Set $K_M = K_{M}^pK_{M,p}$, for compact open subgroups
$K_{M}^p\subset M(\AA_f^p)$ and $K_{M,p}\subset M({\mathbb Q}_p)$.
Define the colimit
\[
C(K^p_M, \lambda, r)\colonequals \varinjlim_{K'_{M,p}\subseteq K_{M,p}} C(K^p_{M}K'_{M,p},\lambda,r)
\]
as an object in the category of complexes of $\Lambda$-modules.
We identify $C(K^p_M, \lambda, r)$ with the object it defines in the derived category
of complexes of $\Lambda$-modules $D(\Lambda)$.
The cohomology groups of $C(K^p_M, \lambda, r)$ can be identified with the usual \emph{``completed'' cohomology}
groups introduced by Emerton~\cite{emerton-interpolate}.

A special choice of $\lambda$ will play a role in our arguments, so we will set up some notation to go with it. There is an algebraic character $\psi \colon M \to {\mathbb G}_m$ over $\Z_p$, which is defined on points as the composition
$$ \GL_{n}({\mathcal O}_{F} \otimes_{\Z_p} R) \overset{{\rm det}}{\longrightarrow} ({\mathcal O}_{F} \otimes_{\Z_p}R)^{\times} \overset{{\rm Nm}}{\longrightarrow} R^{\times}, $$
where $R$ is any $\Z_p$-algebra, ${\rm det}$ is the determinant and ${\rm Nm}$ is the norm map. Any algebraic character of $M$ defined over $\Z_p$ is a power of $\psi$. For any $k\in {\mathbb Z}$, we will write $C(K_{M}^{p},k,r) \colonequals C(K_{M}^{p},\psi^{k},r)$ and similarly for the variants at finite level, etc.

Let us now return to a general $\lambda$. The complex
$C(K^p_M, \lambda, r)$ is equipped with a natural action of $M({\mathbb Z}_p)$. From the definition
of the complexes at finite level, it is clear that $C(K^p_M, \lambda, r)$
is a complex of smooth $M({\mathbb Z}_p)$-representations.
We will consider $C(K_M^p,\lambda, r)$ as an object of $D_{\mathrm{sm}}(M({\mathbb Z}_p), \Lambda)$,
the derived category of smooth $M({\mathbb Z}_p)$-representations
with $\Lambda$-coefficients.

By explicit computation, we have a natural ${\mathbb T}_{M}^{S}$- and $M({\mathbb Z}_p)$-equivariant isomorphism
$$ C(K^p_M,\lambda, r) \xrightarrow{\sim} C(K^p_M,r)\otimes_{\Lambda}\sigma_{\lambda}^\circ/p^r $$
of complexes, where the terms in the above equation are the complexes constructed from singular chains defined above (considered as honest (co)chain complexes, not objects of a derived category); this is presumably well known to experts (see for example \cite[Theorem 2.2.17]{emerton-interpolate} for the statement at the level of cohomology). Note here that the action of each of ${\mathbb T}_{M}^{S}$ and $M(\Z_p)$ on the right-hand side is the diagonal action with respect to the natural action on each factor (${\mathbb T}_{M}^{S}$ acts trivially on $\sigma^\circ_{\lambda}/p^r$). We need a slight variation of this, which is proved in exactly the same way.  Let $k\in {\mathbb Z}$ and let $K_{M,p}^{\prime}\subseteq M(\Z_p)$ be a normal open subgroup contained in the principal congruence subgroup $K_{M,p,r}$ of level $r$. Then we have a natural ${\mathbb T}_{M}^{S}$- and $M(\Z_p)$-equivariant isomorphism
\begin{equation}\label{dependence of weight}
C(K^{p}_{M}K_{M,p}^{\prime},\lambda, r) \xrightarrow{\sim} C(K^{p}_{M}K_{M,p}^{\prime},k,r)\otimes_{\Lambda}(\sigma_{\lambda}^\circ/p^r \otimes_{\Lambda}\psi^{-k})
\end{equation}
of complexes. From this, one gets the following proposition.

\begin{prop}\label{going from finite to finite} Keep the notation above and let $K_{M,p}\subseteq M(\Z_p)$ be an arbitrary open subgroup. Then we have a $\mathbb{T}^S_M$-equivariant quasi-isomorphism
\[
C(K^{p}_{M}K_{M,p},\lambda, r) \xrightarrow{\sim} R\Gamma\left( K_{M,p}/K_{M,p}^{\prime},C(K^{p}_{M}K_{M,p}^{\prime},k,r)\otimes_{\Lambda}(\sigma_{\lambda}^\circ/p^r \otimes_{\Lambda}\psi^{-k}) \right)
\]
in $D(\Lambda)$.
\end{prop}
Before proceeding to the proof, we spell out what we mean by ${\mathbb T}_{M}^{S}$-equivariance. There is a natural ring homomorphism (the Hecke action)
$$ {\mathbb T}_{M}^{S} \to \End_{D(\Lambda)}(C(K^{p}_{M}K_{M,p},\lambda, r)), $$
and we are asserting that this homomorphism is equal to the composition of the natural action map
$$ {\mathbb T}_{M}^{S} \to \End_{D(K_{M,p}/K_{M,p}^{\prime},\Lambda)}(C(K^{p}_{M}K_{M,p}^{\prime},k,r)) $$
and the ring homomorphism
$$ \End_{D(K_{M,p}/K_{M,p}^{\prime},\Lambda)}(C(K^{p}_{M}K_{M,p}^{\prime},k,r)) \to \End_{D(\Lambda)}(C(K^{p}_{M}K_{M,p},\lambda, r)) $$
coming from the functor $R\Gamma\left( K_{M,p}/K_{M,p}^{\prime},-\otimes_{\Lambda}(\sigma_{\lambda}^\circ/p^r \otimes_{\Lambda}\psi^{-k})\right)$ and the quasi-isomorphism in the proposition.

\begin{proof} Given the remarks preceding the proof, the quasi-isomorphism in the Proposition follows directly by taking $K_{M,p}/K_{M,p}^{\prime}$-invariants in the isomorphism
$$ C(K^{p}_{M}K_{M,p}^{\prime},\lambda, r) \xrightarrow{\sim} C(K^{p}_{M}K_{M,p}^{\prime},k,r)\otimes_{\Lambda}(\sigma_{\lambda}^\circ/p^r \otimes_{\Lambda}\psi^{-k}), $$
upon noting that these are complexes of $\Lambda[K_{M,p}/K_{M,p}^{\prime}]$-modules which are acyclic for $K_{M,p}/K_{M,p}^{\prime}$-cohomology, and that the invariants of the left-hand side are $C(K^{p}_{M}K_{M,p},\lambda, r)$. We give a brief justification for the acyclicity. As $\Lambda[K_{M,p}/K_{M,p}^{\prime}]$-modules the terms of the complex are direct sums of copies of $\Lambda[K_{M,p}/K_{M,p}^{\prime}] \otimes_{\Lambda} \sigma_{\lambda}^\circ/p^r$ (with the diagonal action), which is isomorphic to $\Lambda[K_{M,p}/K_{M,p}^{\prime}]^{m}$ as a $\Lambda[K_{M,p}/K_{M,p}^{\prime}]$-module (where $m$ is the dimension of $\sigma_{\lambda}$) by a standard untwisting argument. So $\Lambda[K_{M,p}/K_{M,p}^{\prime}] \otimes_{\Lambda} \sigma_{\lambda}^\circ/p^r$ is injective as a $\Lambda[K_{M,p}/K_{M,p}^{\prime}]$-module since $\Lambda[K_{M,p}/K_{M,p}^{\prime}]$ is self-injective. This then implies that (arbitrary) direct sums of copies of $\Lambda[K_{M,p}/K_{M,p}^{\prime}] \otimes_{\Lambda} \sigma_{\lambda}^\circ/p^r$ are acyclic for   $K_{M,p}/K_{M,p}^{\prime}$-cohomology, since $H^{i}(K_{M,p}/K_{M,p}^{\prime},-)$ commutes with (arbitrary) direct sums.

We now sketch the compatibility of actions of ${\mathbb T}_{M}^{S}$; we refer to \cite[pp. 24, 27-28]{newton-thorne} for a general discussion of computing Hecke actions in our situation. We will divide the check into two parts. First, there is an exact functor $V \mapsto V \otimes_{\Lambda}(\sigma_{\lambda}^{\circ}/p^{r}\otimes_{\Lambda}\psi^{-k})$ on the category of $\Lambda[K_{M,p}/K_{M,p}^{\prime}]$-modules, and using equation \ref{dependence of weight} this gives a ring homomorphism
$$ \End_{{\rm Ch}(K_{M,p}/K_{M,p}^{\prime},\Lambda)}(C(K^{p}_{M}K_{M,p}^{\prime},k,r)) \to \End_{{\rm Ch}(K_{M,p}/K_{M,p}^{\prime},\Lambda)}(C(K^{p}_{M}K_{M,p}^{\prime},\lambda,r)) $$
(where ${\rm Ch}(K_{M,p}/K_{M,p}^{\prime},\Lambda)$ denotes the category of cochain complexes of $\Lambda[K_{M,p}/K_{M,p}^{\prime}]$-modules), which is ${\mathbb T}_{M}^{S}$-equivariant in the sense that if we precompose it with the natural map
$$ {\mathbb T}_{M}^{S} \to \End_{{\rm Ch}(K_{M,p}/K_{M,p}^{\prime},\Lambda)}(C(K^{p}_{M}K_{M,p}^{\prime},k,r)), $$
we get the natural map
$$ {\mathbb T}_{M}^{S} \to \End_{{\rm Ch}(K_{M,p}/K_{M,p}^{\prime},\Lambda)}(C(K^{p}_{M}K_{M,p}^{\prime},\lambda,r)) $$
(this follows from the ${\mathbb T}_{M}^{S}$-equivariance of \ref{dependence of weight}). Similarly, taking $K_{M,p}/K_{M,p}^{\prime}$-invariants gives a ${\mathbb T}_{M}^{S}$-equivariant ring homomorphism
$$ \End_{{\rm Ch}(K_{M,p}/K_{M,p}^{\prime},\Lambda)}(C(K^{p}_{M}K_{M,p}^{\prime},\lambda,r)) \to \End_{{\rm Ch}(\Lambda)}(C(K^{p}_{M}K_{M,p},\lambda,r)). $$
One then takes the composition to get a ${\mathbb T}_{M}^{S}$-equivariant ring homomorphism
$$ \End_{{\rm Ch}(K_{M,p}/K_{M,p}^{\prime},\Lambda)}(C(K^{p}_{M}K_{M,p}^{\prime},k,r)) \to \End_{{\rm Ch}(\Lambda)}(C(K^{p}_{M}K_{M,p},\lambda,r)), $$
and then we pass to the derived category (noting that our functors extend to derived categories).
\end{proof}

\subsection{The Borel--Serre compactification}

\subsubsection{The group $G$} We let $G_0$ be either the quasi-split unitary group with respect
to the extension $F/F^+$, if $F$ is imaginary CM, or $\mathrm{Sp}_{2n}/F=F^+$, if $F$
is totally real. In either case, we have $G=\mathrm{Res}_{F^+/{\mathbb Q}}G_0$. We choose a model of $G_0$
over ${\mathcal O}_{F^+}$ and
only consider small compact open subgroups $K\subseteq G(\AA_f)$
satisfying
\[
K=\prod_{\bar{w}}K_{\bar{w}},\ \mathrm{where}\ K_{\bar{w}}\subseteq G_0({\mathcal O}_{F^+,\bar{w}}),
\]
and where the product runs over primes $\bar{w}$ of $F^+$. We obtain a locally
symmetric space $X^G_K$. In this section, we will only consider the trivial local system
$\Lambda={\mathbb Z}/p^r{\mathbb Z}$ on the spaces $X^G_K, X^{G,\mathrm{BS}}_{K}$,
and
\[
\partial X^{G,\mathrm{BS}}_{K}\colonequals  X^{G,\mathrm{BS}}_{K} \setminus X^G_K.
\]
We define $C(K,r)$ and $\partial C(K,r)$ to be the singular chain complexes of $X_{K}^{G,\mathrm{BS}}$ and
$\partial X_{K}^{G,\mathrm{BS}}$ respectively, and  $C_c(K,r)$ to be the complex of singular chains with compact support
of $X_{K}^{G}$ (with coefficients in $\Lambda$).

\subsubsection{Hecke algebras away from $p$ and unnormalized Satake} We also consider $\mathbb{T}^S_{G}$,
the abstract spherical Hecke algebra for $G$ away from $S$. More precisely,
\[
\mathbb{T}^S_G \colonequals \otimes_{l\not\in S, \bar{w}\mid l}\mathbb{T}_{G,\bar{w}}, \quad \mathbb{T}_{G,\bar{w}} = {\mathbb Z}_p\left[G_0(F^+_{\bar{w}})/ /G_0({\mathcal O}_{F^+,\bar{w}})\right],
\]
where the product runs over primes $\bar{w}$ of $F^+$ above a prime $l\not\in S$. The abstract Hecke algebra $\mathbb{T}^S_G$ acts
on the complexes $C(K,r)$, $C_c(K,r)$ and $\partial C(K,r)$.
For $P_0\subset G_0$ the Siegel parabolic and $P \colonequals \mathrm{Res}_{F^+/{\mathbb Q}}P_0$, we define
the abstract spherical Hecke algebra $\mathbb{T}^S_P$ analogously as
\[
\mathbb{T}^S_P \colonequals \otimes_{l\not\in S, \bar{w}\mid l}\mathbb{T}_{P,\bar{w}}, \quad \mathbb{T}_{P,\bar{w}} = {\mathbb Z}_p\left[P_0(F^+_{\bar{w}})/ /P_0({\mathcal O}_{F^+,\bar{w}})\right].
\]

We will give an explicit description of ${\mathbb T}_{G,\bar{w}}$.
Such a description can be found in
\cite[Lem.\ 5.1.6]{scholze-galois} and in
\cite[Prop.-Def. 5.2]{newton-thorne} for $F$ imaginary CM.  We use
a normalization for the Hecke operators that is consistent with the latter
reference but not the former.
If $F$ is imaginary CM,
\[ {\mathbb T}_{G,\bar{w}}[q_{\bar{w}}^{1/2}] \cong {\mathbb Z}_p[q_{\bar{w}}^{1/2}][Y_1^{\pm 1},\dots,Y_{2n}^{\pm 1}]^{S_{2n}} \,. \]
We write $T_{G,\bar{w},i}$ for $q^{i(2n-i)/2}_w$ times the $i$th elementary
symmetric polynomial in $Y_1,\dots,Y_{2n}$.
If $F$ is totally real,
\[ {\mathbb T}_{G,\bar{w}}[q_{\bar{w}}^{1/2}] \cong {\mathbb Z}_p[q_{\bar{w}}^{1/2}][X_1^{\pm 1},\dots,X_{n}^{\pm 1}]^{S_n \ltimes ({\mathbb Z}/2{\mathbb Z})^n} \]
and the unramified endoscopic transfer from $G(F_{\bar{w}})$ to $\GL_{2n+1}(F_{\bar{w}})$ is dual to the map
\[ {\mathbb Z}_p[q_{\bar{w}}^{1/2}][Y_1^{\pm 1},\dots,Y_{2n+1}^{\pm 1}]^{S_{2n+1}} \to
{\mathbb Z}_p[q_{\bar{w}}^{1/2}][X_1^{\pm 1},\dots,X_{n}^{\pm 1}]^{S_n \ltimes ({\mathbb Z}/2{\mathbb Z})^n} \]
that sends $\{Y_1,\dots,Y_{2n+1}\}$ to $\{X_1^{\pm 1},\dots,X_n^{\pm 1},1\}$.
We write $T_{G,\bar{w},i}$ for $q^{i(2n+1-i)/2}_w$ times the $i$th elementary
symmetric polynomial in $Y_1,\dots,Y_{2n+1}$.

We also have
the \emph{unnormalized Satake transform} $\mathbb{T}^S_{G}\to \mathbb{T}^S_M$.
For this, we will use the definition in~\cite[\S 2.2.6]{newton-thorne},
as the composition $r_M\circ r_P$, where
$r_P \colon \mathbb{T}^S_G\to \mathbb{T}^S_{P}$
is given by restriction of functions from $G$ to $P$ (see \S 2.2.3 of~\emph{loc.\ cit.}) and
$r_M \colon \mathbb{T}^S_P\to \mathbb{T}^S_M$ is
given by ``integration along the unipotent fibres'' (see \S 2.2.4 of~\emph{loc.\ cit.}).
Under this morphism, a maximal ideal $\mathfrak{m} \subset \mathbb{T}^S_M$
determines a maximal ideal $\mathfrak{M}\subset \mathbb{T}^S_{G}$.

We give an explicit description of the transform, following
\cite[Lem. 5.2.5]{scholze-galois} and \cite[Prop.-Def. 5.3]{newton-thorne}.
Again, we adopt the normalizations of the latter reference.
If $F$ is imaginary CM, the unnormalized Satake transform is determined by
the map
\[ \Z_p[q_v^{1/2}][Y_1^{\pm 1},\dots,Y_{2n}^{\pm 1}]^{S_{2n}} \to \Z_p[q_v^{1/2}][W_1^{\pm 1},\dots,W_n^{\pm 1},Z_1^{\pm 1},\dots,Z_n^{\pm 1}]^{S_n \times S_n} \]
that sends the set $\{Y_1,\dots,Y_{2n}\}$ to the set $\{q_v^{-n/2} W_1,\dots,q_v^{-n/2} W_n,q_v^{n/2} Z_1^{-1},\dots,q_v^{n/2} Z_n^{-1} \}$.
If $F$ is totally real, the unnormalized Satake transform is determined
by the map
\[ \Z_p[q_v^{1/2}][X_1^{\pm 1},\dots,X_n^{\pm 1}]^{S_n \ltimes ({\mathbb Z}/2{\mathbb Z})^n} \to \Z_p[q_v^{1/2}][W_1^{\pm 1},\dots,W_n^{\pm 1}]^{S_n} \]
that sends the set $\{X_1,\dots,X_n\}$ to the set
$\{q_v^{-(n+1)/2} W_1,\dots,q_v^{-(n+1)/2} W_n \}$.

\subsubsection{The excision distinguished triangle} For $m\in{\mathbb Z}_{\geq 1}$,
consider the congruence subgroups $\Gamma_1(p^m)\subseteq G({\mathbb Z}_p)$ (defined in Section~\ref{recollections} if $F$
is imaginary CM and in Section~\ref{Siegel case} if $F$ is totally real). As $m$ varies, we have a directed system
of exact triangles in the category of complexes of $\Lambda$-modules
\[
C_c(K^p\Gamma_1(p^m), r)\to C(K^p\Gamma_1(p^m), r)\to \partial C(K^p\Gamma_1(p^m), r)\to C_c(K^p\Gamma_1(p^m), r)[1]
\]
such that all the morphisms are also $\mathbb{T}^S_G$-equivariant.
Define
\[
C_{1,c}(K^p,r)\colonequals \varinjlim_{m}C_c(K^p\Gamma_1(p^m), r),
\]
\[ C_{1}(K^p, r)\colonequals \varinjlim_{m}C(K^p\Gamma_1(p^m),r),\]
\[
\partial C_1(K^p, r) \colonequals \varinjlim_{m}\partial C(K^p\Gamma_1(p^m), r).
\]
We may consider these as objects in $D_{\mathrm{sm}}(M(\Z_p),\Lambda)$, where they are homotopy colimits of
the corresponding objects at finite level. We obtain a $\mathbb{T}^S_G$-equivariant distinguished triangle of homotopy colimits
\[
C_{1, c}(K^p, r)\to C_1(K^p, r)\to \partial C_1(K^p, r)\to C_{1,c}(K^p, r)[1]
\]
in $D_{\mathrm{sm}}(M({\mathbb Z}_p),\Lambda)$.
We also consider the congruence subgroups $\Gamma(p^m)\subseteq G({\mathbb Z}_p)$ and define
\[
(\partial)C_{(c)}(K^p, r)\colonequals \varinjlim_{m}(\partial)C_{(c)}(K^p\Gamma(p^m),r).
\]
These are objects in $D_{\mathrm{sm}}(G({\mathbb Z}_p),\Lambda)$.

Let $\tau_{\geq d+1}$ denote the truncation functor
for the usual $t$-structure on any of the derived categories considered in this paper
(for example $D(\Lambda)$ or $D_{\mathrm{sm}}(M(\Z_p),\Lambda)$).
By Corollary~\ref{main cor} if $F$ is imaginary CM and Corollary~\ref{main cor - siegel}
if $F$ is totally real, we have $\tau_{\geq d+1}C_{1, c}(K^p, r)=0$
and thus we obtain a natural, $\mathbb{T}^S_G$-equivariant quasi-isomorphism
\begin{equation}\label{key quasi-isomorphism}
\tau_{\geq d+1}C_1(K^p, r)\xrightarrow{\sim} \tau_{\geq d+1}\partial C_1(K^p, r)
\end{equation}
in $D_{\mathrm{sm}}(M(\Z_p),\Lambda)$.
For $m\in {\mathbb Z}_{\geq 1}$, let
\[
K_{M, p, m}\colonequals \left\{m = (m_{\mathfrak{p}})_{\mathfrak{p}\mid p}\in M({\mathbb Z}_p)\mid m_{\mathfrak{p}}\equiv I_{n}\pmod{p^m}\right\} = \Gamma_1(p^m)\cap M({\mathbb Z}_p).
\]

The upcoming Theorem~\ref{direct summand} is the key result of this section. It states, loosely speaking, that $C(K^p_M,-n, r)[-d]$ is a direct summand of
$\tau_{\geq d+1}C_1(K^p, r)$ after localization at a non-Eisenstein maximal ideal (recall the notation $C(K_{M}^{p},k,r) \colonequals C(K_{M}^{p},\psi^{k},r)$ from the previous subsection), and is a crucial step in our construction of Galois representations. There are two essential differences compared to similar statements used in the arguments of \cite{newton-thorne}. The first is that we work at infinite level as opposed to finite level, and the second is the presence of the shift (and, to a much lesser extent, the twist $-n$). Both cause additional subtleties. To define the idempotent required to realise $C(K^p_M,-n, r)[-d]$ as a direct summand of $\tau_{\geq d+1}C_1(K^p, r)$, we will use ordinary projectors as in Hida theory, so we make some remarks about this before proceeding to Theorem \ref{direct summand}.

The complexes at level $\Gamma_1(p^m)$ that we defined earlier in this subsection carry actions of a natural Hecke operator that we will call $U_p$. In the imaginary CM case, we define $U_{p}$ as the double coset operator corresponding to
\[
\prod_{\iota} \mathrm{diag}(p,\dots,p,1,\dots,1)\in G({\mathbb Q}_p)
\]
where in each matrix $p$ occurs $n$ times on the diagonal and the product runs over  all embeddings $\iota \colon F\hookrightarrow \CC$ with $\iota\in \Psi$.
In the totally real case, we define $U_{p}$ as the double coset operator corresponding to
\[
\prod_{\iota} \mathrm{diag}(p,\dots,p,p^{-1},\dots,p^{-1})\in G({\mathbb Q}_p)
\]
where again in each matrix $p$ occurs $n$ times on the diagonal and the product runs over all embeddings $\iota \colon F\hookrightarrow {\mathbb R}$. The action of $U_p$ is compatible with the transition morphisms between different levels and commutes with the Hecke
action away from $p$. Let ${\rm G}$ be a finite group. On each
perfect complex $C$ of $\Lambda[{\rm G}]$-modules,
with an operator $U\in \mathrm{End}_{D({\rm G},\Lambda)}(C)$, one defines the \emph{ordinary part} $C^\mathrm{ord}$ to be the direct summand of $C$ corresponding to the idempotent $e \colonequals \lim_{k \to \infty}U^{k!}$. We remark that $e$ is well defined since $\mathrm{End}_{D({\rm G},\Lambda)}(C)$ has finite cardinality, and that $C^\mathrm{ord}$ then exists since $D({\rm G},\Lambda)$ is idempotent complete. $C^{{\rm ord}}$ is the maximal direct summand of $C$ in $D(\Lambda)$ on which $U$ acts invertibly. For this construction in a slightly different setting and for further discussion, we refer to ~\cite[\S 2.4]{khare-thorne}. In what follows, we will let the superscript $\ ^\mathrm{ord}$ denote the ordinary part
with respect to the $U_{p}$ operator.

\begin{thm}\label{direct summand} Choose $K^p\subset G(\AA_f^p)$ decomposed in the sense
of~\cite[\S 2.2.4]{newton-thorne} and such that $K^p\cap M(\AA_f^p)=K^p_M$.
Let $\mathfrak{m}\subset \mathbb{T}^S_{M}$ be non-Eisenstein,
with corresponding $\mathfrak{M}\subset \mathbb{T}^S_G$.

Then $C(K^p_M,-n, r)_{\mathfrak{m}}[-d]$ is a direct summand of
$\tau_{\geq d+1}C_1(K^p, r)_{\mathfrak{M}}$ in $D_{\mathrm{sm}}(M({\mathbb Z}_p),\Lambda)$,
equivariant for the Hecke action of $\mathbb{T}^S_G$ on $C_1(K^p,r)_{\mathfrak{M}}$
and the action of  $\mathbb{T}^S_G$ on $C(K^p_M,k, r)_{\mathfrak{m}}[-d]$ via the unnormalized Satake
transform $\mathbb{T}^S_G\to \mathbb{T}^S_M$.
\end{thm}

\begin{proof} By Lemma~\ref{eliminating degree 0}, we have
\[
C(K^p_M,-n, r)_{\mathfrak{m}} = \tau_{\geq 1} C(K^p_M,-n, r)_{\mathfrak{m}}.
\]
By the quasi-isomorphism~\eqref{key quasi-isomorphism}, it suffices to show that $(\tau_{\geq 1} C(K^p_M,-n, r)_{\mathfrak{m}})[-d]$
is a Hecke-equivariant direct summand of $\tau_{\geq d+1}\partial C_1(K^p, r)_{\mathfrak{M}}$.
Keeping track of the degrees, we see that it is enough to show that $C(K^p_M,-n,r)_{\mathfrak{m}}[-d]$
is a Hecke-equivariant direct summand of $\partial C_1(K^p, r)_{\mathfrak{M}}$.

We first show that it is enough to prove the result at finite level.
In $D_{\mathrm{sm}}(M(\Z_p),\Lambda)$, $C(K_M^p,-n,r)$ is the homotopy colimit of $C(K^p_MK_{M,p,m},-n, r)$
and $\partial C_1(K^p, r)$ is the homotopy colimit of $\partial C_1(K^p\Gamma_1(p^m),r)$.
Since the property of being a direct summand in the derived category
is preserved under taking homotopy colimits, we see that it is indeed enough to prove, for every large enough $m\in {\mathbb Z}_{\geq 1}$,
that $C(K^p_MK_{M,p,m},-n, r)_{\mathfrak{m}}[-d]$ is a Hecke-equivariant
direct summand of $\partial C_1(K^p\Gamma_1(p^m),r)_{\mathfrak{M}}$,
compatibly with the transition morphisms between different levels.

We will divide the proof into three parts, as follows.
Let $K(m)\colonequals K^p\Gamma_1(p^m)$.
The boundary $\partial X^{G,\mathrm{BS}}_{K(m)}$ has
a stratification into finitely many strata, labeled by standard rational parabolic subgroups of $G$. (See~\cite[\S 3.1.2]{newton-thorne} for
more details.) The cohomology of the union $X^{G,Q}_{K(m)}$ of strata labeled by a standard parabolic $Q$ is
naturally a $\mathbb{T}^S_G$-module.  The stratum $\XGP$ can be written as
\[ \XGP = P({\mathbb Q}) \backslash \left(X^P \times G(\AA_f) / K(m)\right) \,. \]
We will also consider the open and closed subspace
\[ \XP \colonequals P({\mathbb Q}) \backslash \left(X^P \times P(\AA_f) / (K(m) \cap P(\AA_f))\right) \,. \]
There are natural morphisms
\begin{center}
\begin{tikzcd}
\XM & \arrow[l,two heads] \XP \arrow[r,hook] & \XGP \arrow[r,hook] & \DXG \,.
\end{tikzcd}
\end{center}
Proposition \ref{XG to XGP} shows that
$R\Gamma(\XGP,\Lambda)_{\mathfrak{M}}$
is a direct summand of $\partial C_1(K^p\Gamma_1(p^m),r)_{\mathfrak{M}}$.
Proposition \ref{XP to XGP} shows that
$R\Gamma(\XP,\Lambda)^{\ord}$ is a
direct summand of $R\Gamma(\XGP,\Lambda)$.
Finally, Proposition \ref{XM to XP} shows that
$C(K^p_MK_{M,p,m},-n, r)[-d]$
is quasi-isomorphic to $R\Gamma(\XP,\Lambda)^{\ord}$.
In all cases, we keep track of the Hecke actions and show that the
maps are compatible with the transition morphisms between different levels.
\end{proof}

In the following propositions, note the isomorphisms $P(\Z_p)/(\Gamma_{1}(p^m) \cap P(\Z_p)) \cong M(\Z_p)/K_{M,p,m} \cong M({\mathbb Z}/p^{m}{\mathbb Z})$.

\begin{prop} \label{XG to XGP}
In the notation of the proof of Theorem \ref{direct summand},
$R\Gamma(\XGP,\Lambda)_{\mathfrak{M}}$
is a $\mathbb{T}^S_G$-equivariant direct summand of $\partial C_1(K^p\Gamma_1(p^m),r)_{\mathfrak{M}}$
in $D(M({\mathbb Z}/p^{m}{\mathbb Z}), \Lambda)$, compatibly with the transition morphisms between different levels.
\end{prop}
\begin{proof}
We claim that, for any system of Hecke eigenvalues $\mathfrak{M}_Q\subset \mathbb{T}^S_G$
in the support of $R\Gamma_{(c)}(X^{G,Q}_{K(m}), {\mathbb F}_p)$, the corresponding Galois representation
$\bar{\rho}_{\mathfrak{M}_Q}$ is a direct sum of Galois representations corresponding to
the direct factors of a Levi subgroup of $Q$. This can be proved in the same way as~\cite[Thm. 4.2]{newton-thorne},
which applies to the strata in the Borel--Serre compactification for $\mathrm{Res}_{F/{\mathbb Q}}\GL_n$.

We let $C_c(K(m),P,r)$ denote the
complex of singular cochains with $\Lambda$-coefficients computing $R\Gamma_c(X^{G,P}_{K(m)},\Lambda)$.
By applying the excision distinguished triangle in $D(M({\mathbb Z}/p^{m}{\mathbb Z}), \Lambda)$ repeatedly and the assumption that $\mathfrak{m}$ is
non-Eisenstein (which implies that $\bar{\rho}_{\mathfrak{M}}$ is a direct sum of two absolutely
irreducible $n$-dimensional representations) we deduce that
any contributions from strata corresponding to standard parabolics other than $P$ vanish after localization at $\mathfrak{M}$.
Therefore, $C_c(K_{(m)},P, r)_{\mathfrak{M}}$ is a $\mathbb{T}^S_G$-equivariant direct summand of
$\partial C(K_{(m)}, r)_{\mathfrak{M}}$ in $D(M({\mathbb Z}/p^{m}{\mathbb Z}), \Lambda)$. By the same argument
(again, an analogue of~\cite[Thm. 4.2]{newton-thorne}), the natural map
\[
R\Gamma_c(X^{G,P}_{K(m)},\Lambda)_{\mathfrak{M}} \to
R\Gamma(X^{G,P}_{K(m)},\Lambda)_{\mathfrak{M}}
\]
is a $\mathbb{T}^S_G$-equivariant quasi-isomorphism
in $D(M({\mathbb Z}/p^{m}{\mathbb Z}), \Lambda)$.\footnote{This argument will be expanded in the forthcoming paper~\cite{accghlnstt}.}.
\end{proof}

\begin{prop} \label{XP to XGP}
In the notation of the proof of Theorem \ref{direct summand},
$R\Gamma(\XP,\Lambda)^{\ord}$ is a direct summand
of $R\Gamma(\XGP,\Lambda)$ in $D(M({\mathbb Z}/p^{m}{\mathbb Z}), \Lambda)$, compatibly with the transition maps
between different levels and Hecke-equivariant for the restriction of functions
$r_P \colon \mathbb{T}^S_G \to \mathbb{T}^S_P$.
\end{prop}
\begin{proof}
Since $\XP$ is an open and closed subspace of $\XGP$,
$R\Gamma(\XP,\Lambda)$ is naturally a direct summand of
$R\Gamma(\XGP,\Lambda)$.  However, these direct summands
are not compatible as $m$ varies.  The problem is that for $\ell > m$,
$\XP \times_{\XGP} \XGP[\ell]$ is larger than $\XP[\ell]$.
We will fix this issue by applying ordinary projectors. We write out the proof in the imaginary CM case; the proof in the totally real case is essentially the same (the only difference is in the bookkeeping, since the formula in Lemma \ref{contract} is different for $F$ totally real).

Define
\[ \YGP \colonequals P({\mathbb Q}) \backslash X^P \times P(\AA_f^p) G(\Q_p) / (K(m) \cap P(\AA_f^p) G(\Q_p)) \,. \]
Then $\YGP$ is an open and closed subset of $\XGP$, and moreover
for $\ell > m$, $\YGP[\ell] = \YGP \times_{\XGP} \XGP[\ell]$.  So
$R\Gamma(\YGP,\Lambda)$ is a direct summand of $R\Gamma(\XGP,\Lambda)$ compatibly
with the transition maps between different levels.

We must now define some maps. First, we let $e_m \colon R\Gamma(\YGP,\Lambda)\to R\Gamma(\YGP, \Lambda)$ be the ordinary projector corresponding to $U_p$.
We then define $r_{\ell m} \colon R \Gamma(\YGP[\ell],\Lambda) \to R\Gamma(\YGP[\ell],\Lambda)$ to be the idempotent corresponding to the open and closed subspace $\XP \times_{\YGP} \YGP[\ell] \subset \YGP[\ell]$.
Moving on, we let $\pi^{G,P}_{\ell m} \colon \YGP[\ell] \to \YGP$, $\pi^P_{\ell m} \colon \XP[\ell] \to \XP$ be the projection maps, and finally we let $j_m \colon \XP \hookrightarrow \YGP$ be the natural inclusion map. The map $j_{m}$ induces morphisms
$j_m^* \colon R\Gamma(\YGP,\Lambda) \to R\Gamma(\XP,\Lambda)$ and
$j_{m!} \colon R\Gamma(\XP,\Lambda) \to R\Gamma(\YGP,\Lambda)$.
We observe that for $\ell \ge m$,
\[ j_{\ell!} \circ \pi^{P*}_{\ell m} = r_{\ell \ell} \circ j_{\ell !} \circ \pi^{P*}_{\ell m} = r_{\ell \ell} \circ \pi^{G,P*}_{\ell m} \circ j_{m!} \,. \]

Lemma~\ref{contract} below implies that for all $k \ge m - 1$,
\[
P(\Q_p) \Gamma_1(p) \cdot \left( \Gamma_1(p^{m}) \prod_{\iota}\begin{pmatrix} p^k\cdot I_n & 0 \\ 0 & I_n \end{pmatrix}
\Gamma_1(p^m) \right) \subseteq P(\Q_p) \Gamma_1(p^m) \,,
\]
where the product runs over all embeddings $\iota \colon F\hookrightarrow \CC$ with $\iota\in \Psi$. This in turn implies that
$r_{m 1} \circ U_p^k = r_{m 1} \circ U_p^k \circ r_{mm}$ for
$k \ge m-1$.
It follows that
\[ r_{m 1} \circ e_{m} = r_{m 1} \circ e_{m} \circ r_{mm} \,. \]
Then the morphisms $r_{m1} \circ e_m \circ j_{m!}$ are compatible with the
transition morphisms between different levels, since for $\ell \ge m$,
\begin{IEEEeqnarray*}{Cl}
& r_{\ell 1} \circ e_{\ell} \circ j_{\ell !} \circ \pi^{P*}_{\ell m} \\
= & r_{\ell 1} \circ e_{\ell} \circ r_{\ell \ell} \circ \pi^{G,P*}_{\ell m} \circ j_{m!} \\
= & r_{\ell 1} \circ e_{\ell} \circ \pi^{G,P*}_{\ell m} \circ j_{m!} \\
= & \pi^{G,P*}_{\ell m} \circ r_{m1} \circ e_m \circ j_{m!} \,.
\end{IEEEeqnarray*}

We claim that the composition $j_m^* \circ (r_{m1} \circ e_m \circ j_{m!})$ is the
$U_p$-ordinary projector on $R\Gamma(\XP,\Lambda)$.
The claim implies that
$R\Gamma(\XP,\Lambda)^{\ord}$ is a direct summand
of $R\Gamma(\YGP,\Lambda)$, and hence also
of $R\Gamma(\XGP,\Lambda)$.
To prove the claim, we first observe that $j_m^* \circ r_{m1} = j_m^*$.
To prove that $j_m^* \circ e_m \circ j_{m!}$ is the ordinary projector on $R\Gamma(\XP,\Lambda)$,
it is enough to see that $j_m^*$ is $U_p$-equivariant.
For this, it is enough to show that
\[
P(\Q_p) \Gamma_1(p^m) \prod_{\iota} \begin{pmatrix} p\cdot I_n & 0 \\ 0 & I_n \end{pmatrix} \Gamma_1(p^m) \subseteq P(\Q_p) \Gamma_1(p^m).
\]
This follows from essentially the
same argument as in Lemma~\ref{contract}.

It remains to check that our realization of $R\Gamma(\XP,\Lambda)^{\ord}$
as a direct summand of $R\Gamma(\XGP,\Lambda)$ is compatible with
restriction of functions
$\mathbb{T}^S_G \to \mathbb{T}^S_P$.
There is no difficulty in checking that $R\Gamma(\XP,\Lambda)^{\ord}$
is a $\mathbb{T}^S_P$-equivariant direct summand of $R\Gamma(\YGP,\Lambda)$, since $r_{\ell m}$, $j_{m!}$,
$j_{m}^*$ and $e_m$ are all $\mathbb{T}^S_P$-equivariant.  Checking
that the realization of $R\Gamma(\YGP,\Lambda)$ as a direct summand of
$R\Gamma(\XGP,\Lambda)$ is compatible with the restriction of functions $r_P$
requires more work.

The object $R\Gamma(\YGP,\Lambda)$ of $D(M({\mathbb Z}/p^{m}{\mathbb Z}),\Lambda)$ has a natural action of $\mathbb{T}^S_P$.
Equations (4.2) and (4.3) of~\cite{newton-thorne} show that $r_P^*\left(R\Gamma(\YGP,\Lambda)\right)$
is a $\mathbb{T}^S_G$-equivariant direct summand of $R\Gamma(\XGP,\Lambda)$. Their argument considers a boundary stratum
in the Borel--Serre compactification of the locally symmetric space for $\mathrm{Res}_{F/{\mathbb Q}}\GL_n$, but the same argument applies verbatim to our group $G$.
(We explain this further, making the connection with the formalism and notation of~\cite{newton-thorne}. Set
\[
\mathfrak{X}_P \colonequals P({\mathbb Q})\backslash \left(X^P\times P(\AA_f)\right).
\]
According to the formalism of~\emph{loc.\ cit.}, one can identify $R\Gamma(\XGP,\Lambda)$ as a $\mathbb{T}^S_G$-module
with $R\Gamma_{K(m)}\mathrm{Res}_{G(\AA_f^S)\times K(m)_S}^{G(\AA_f)}R\Gamma_{\mathrm{Ind}^{G(\AA_f)}_{P(A_f)}\mathfrak{X}_P}\Lambda$. Here,
we view the constant sheaf corresponding to $\Lambda$ as a $G(\AA_f)$-equivariant sheaf on $\mathrm{Ind}^{G(\AA_f)}_{P(A_f)}\mathfrak{X}_P$, take cohomology
and then take derived $K(m)$-invariants.  The resulting object is naturally an object in the derived category of $\mathbb{T}^S_G$-modules.
On the other hand, one can identify $R\Gamma(\YGP,\Lambda)$ as a $\mathbb{T}^S_P$-module
with a direct sum of finitely many terms of the form $R\Gamma_{K_P}\mathrm{Res}_{P(\AA_f^S)\times K_{P,S}}^{P(\AA_f)}R\Gamma_{\mathfrak{X}_P}\Lambda$,
with $K_P$ of the form $g \Gamma_1(p^m) g^{-1} K^p\cap P(\AA_f)$. Again, we view the constant sheaf corresponding to $\Lambda$
as a $P(\AA_f)$-equivariant sheaf on $\mathfrak{X}_P$, take cohomology, and then take derived $K_P$-invariants. The resulting object is naturally an
object in the derived category of $\mathbb{T}^S_P$-modules. Combining equations (4.2) and (4.3)
of~\emph{loc.\ cit.} gives us the desired statement.)
\end{proof}

We now state and prove the lemma that was used in the proof of Proposition \ref{XP to XGP}.

\begin{lemma}\label{contract} Let $k \ge 0$ be an integer. When $F$ is imaginary CM, then
\[ P(\Q_p) \Gamma_1(p)\prod_{\iota} \begin{pmatrix} p^k\cdot I_n & 0 \\ 0 & I_n \end{pmatrix} \subseteq P(\Q_p) \Gamma_1(p^{k+1}) \,, \]
where the product runs over all embeddings $\iota \colon F\hookrightarrow \CC$ with $\iota\in \Psi$. When $F$ is totally real, then
\[ P(\Q_p) \Gamma_1(p)\prod_{\iota} \begin{pmatrix} p^k\cdot I_n & 0 \\ 0 & p^{-k} \cdot I_n \end{pmatrix} \subseteq P(\Q_p) \Gamma_1(p^{2k+1}) \,, \]
where the product runs overall embeddings $\iota \colon F\hookrightarrow {\mathbb R}$.
\end{lemma}

\begin{proof}
We explain the proof in the case when $F$ is imaginary CM; then $G({\mathbb Q}_p)$ is a product of $\GL_{2n}({\mathbb Q}_p)$'s,
indexed by embeddings $\iota\in \Psi$ (the proof when $F$ is totally real is essentially the same; we make a few additional remarks the end of this proof). Since both sides of our desired inclusion are products, we may work factor by factor. Therefore, in this proof only, we will abuse notation and write $G(\Q_p)=\GL_{2n}(\Q_p)$ (corresponding to a particular factor) and $P(\Q_p)$ and $\Gamma_{1}(p^m)$ for the projection of those groups onto that same factor (as subgroups of $\GL_{2n}(\Q_p)$ they are independent of the choice of factor). We hope that this will not cause any confusion.

We define a function $h \colon G(\Q_p) \to \mathbb{Z} \cup \{-\infty,\infty\}$ as follows.
Let $g = \begin{pmatrix} A & B \\ C & D \end{pmatrix} \in G(\Q_p)$, where $A,B,C,D$ are $n\times n$ block matrices.
If $D$ is invertible, then we let $h(g)$ be the minimum of
the $p$-adic valuations of the entries of $D^{-1} C$.  Otherwise,
we let $h(g) = -\infty$.  It is not difficult to check that $h$
is invariant under left translation by $P(\Q_p)$, and that
$h \left( g \begin{pmatrix} p^k\cdot I_n & 0 \\ 0 & I_n \end{pmatrix} \right)=h(g)+k$.

We claim that for $m>0$,
\[
P(\Q_p) \Gamma_1(p^m) = \{ g \in G(\Q_p) | h(g) \ge m \} \,.
\]
It is easy to check that for $g \in \Gamma_1(p^m)$, $h(g) \ge m$.
The set $\{ g \in G(\Q_p) | h(g) \ge m \}$ is left $P(\Q_p)$-invariant,
so it must contain $P(\Q_p) \Gamma_1(p^m)$.
Conversely, if $g=\begin{pmatrix} A & B \\ C & D \end{pmatrix}$ satisfies
$h(g) \ge m$, then
\[
g = \begin{pmatrix} A-BD^{-1}C & B \\ 0 & D \end{pmatrix}
\begin{pmatrix} I_n & 0 \\ D^{-1} C & I_n \end{pmatrix} \,,
\]
and the first matrix is in $P(\Q_p)$, while the second is in $\Gamma_1(p^m)$.

Therefore,
\[
P(\Q_p) \Gamma_1(p) \begin{pmatrix} p^k\cdot I_n & 0 \\ 0 & I_n \end{pmatrix} =
P(\Q_p) \Gamma_1(p^{k+1}) \,.
\]

This finishes the proof when $F$ is imaginary CM. When $F$ is totally real, the same proof holds. In that case, everything is a product of ${\rm Sp}_{2n}({\mathbb Q}_p)$'s, we have $h \left( g \begin{pmatrix} p^k\cdot I_n & 0 \\ 0 & p^{-k} \cdot I_n \end{pmatrix} \right)=h(g)+2k$
and the only point that requires checking is that the factorization
\[
g = \begin{pmatrix} A-BD^{-1}C & B \\ 0 & D \end{pmatrix}
\begin{pmatrix} I_n & 0 \\ D^{-1} C & I_n \end{pmatrix} \,,
\]
is valid in ${\rm Sp}_{2n}({\mathbb Q}_p)$. But one checks easily that the first matrix on the right-hand side (and hence the second matrix as well) is in ${\rm Sp}_{2n}({\mathbb Q}_p)$ if $g$ is.
\end{proof}

Before proceeding to Proposition \ref{XM to XP}, we prove a lemma that will be used in the proof, which involves group cohomology for $N(\Z_p)$. The lemma works with continuous group cohomology, whereas we will also need to consider cohomology of $N(\Z_p)$ as a discrete group in the proof of Proposition \ref{XM to XP}. This will not cause any problems, since the natural map
$$ H_{\mathrm{cont}}^{i}(N(\Z_p),A) \to H_{\mathrm{disc}}^{i}(N(\Z_p),A) $$
is an isomorphism for all $i$ and all $N(\Z_p)$-modules $A$ of finite cardinality. This follows from \cite[Theorem 2.10]{fkrs} since $N(\Z_p)\cong \Z_p^{d}$, and we will use this without further comment in what follows (in part to simplify notation; we simply write $H^{i}(N(\Z_p),A)$ in both cases). The isomorphism commutes with any extra structures we might consider on the cohomology groups (for example, if $A$ is a $P(\Z_p)$-module, then both cohomology groups carry natural $M(\Z_p)$-actions).

\begin{lemma}\label{splitting off the top degree} $H^d(N(\Z_p), \Lambda)[-d]$ is a direct summand of $R\Gamma(N({\mathbb Z}_p), \Lambda)$ in $D_{\mathrm{sm}}(M({\mathbb Z}_p), \Lambda)$. Moreover, as an $M(\Z_p)$-representation, $H^d(N(\Z_p), \Lambda)=\psi^{-n}$, where we recall that $\psi$ is the algebraic charcter of $M$ over $\Z_p$ defined by the composing the determinant and the norm map.
\end{lemma}

\begin{proof}
We start with the first part. To prove the first part, it suffices to construct an idempotent
$$ e\in \End_{D_{\mathrm{sm}}(M(\Z_p),\Lambda)}(R\Gamma(N({\mathbb Z}_p), \Lambda))$$
such that $e$ acts as $0$ on $H^i(N({\mathbb Z}_p), \Lambda)$ for $i\neq d$ and as the identity on $H^d(N({\mathbb Z}_p), \Lambda)$, since $D_{\mathrm{sm}}(M(\Z_p),\Lambda)$ is idempotent complete.

Let
$$ \gamma \colonequals \prod_{\iota} \begin{pmatrix} pI_n & 0 \\ 0 & p^{-1}I_n \end{pmatrix} \in M(\Q_p) \subseteq G(\Q_p) $$
where the product runs over all embeddings $\iota \colon F \hookrightarrow {\mathbb R}$ when $F$ is totally real and all embeddings $\iota \colon F\hookrightarrow \CC$ with $\iota\in \Psi$ when $F$ is imaginary CM (we remark that this is not the same $\gamma$ as was considered in earlier parts of the paper). By direct computation, we have $\gamma N(\Z_p)\gamma^{-1} = N(\Z_p)^{p^{2}}\subseteq N(\Z_p)$; this subgroup is normalized by $M(\Z_p)$. Let $\Lambda \to I^{\bullet}$ be an injective resolution of $\Lambda$ as a smooth $P(\Q_p)$-representation; then $(I^{\bullet})^{H}$ represents $R\Gamma(H,\Lambda)$ in $D_{\mathrm{sm}}(M(\Z_p),\Lambda)$ for $H=N(\Z_p),\gamma N(\Z_p)\gamma^{-1}$. We may define a homomorphism
$$ m_{\gamma} \colon R\Gamma(N({\mathbb Z}_p), \Lambda) \to R\Gamma(\gamma N({\mathbb Z}_p)\gamma^{-1}, \Lambda) $$
by termwise multiplication by $\gamma$ from $(I^{\bullet})^{N(\Z_p)}$ to $(I^{\bullet})^{\gamma N(\Z_p) \gamma^{-1}}$. This commutes with the $M(\Z_p)$-actions since $\gamma$ is in the center of $M(\Q_p)$. Moreover, $m_{\gamma}$ is easily checked to be independent of the choice of injective resolution, and it is an isomorphism with inverse $m_{\gamma^{-1}}$ (defined in the same way). Next, as $\gamma N(\Z_p) \gamma^{-1} \subseteq N(\Z_p)$, there is a corestriction map
$$ {\rm cores} \colon R\Gamma(\gamma N({\mathbb Z}_p)\gamma^{-1}, \Lambda) \to  R\Gamma(N({\mathbb Z}_p), \Lambda) $$
given explicitly by $v \mapsto \sum_{n \in N(\Z_p)/\gamma N(\Z_p) \gamma^{-1}}nv $ termwise from $(I^{\bullet})^{\gamma N(\Z_p) \gamma^{-1}}$ to $(I^{\bullet})^{N(\Z_p)}$. Again, one checks easily that this is $M(\Z_p)$-equivariant and independent of the choice of $I^{\bullet}$. We let $h_{\gamma} \colonequals {\rm cores} \circ m_{\gamma} \in \End_{D_{sm}(M(\Z_p),\Lambda)}(R\Gamma(N({\mathbb Z}_p), \Lambda))$ denote the composition. (This is the so-called Hecke action of $\gamma$, in the sense of~\cite[\S 3.3]{emerton-ord}.)

We now analyze the $p$-divisibility of the action of $h_{\gamma}$ on cohomology. Since $m_{\gamma}$ is an isomorphism, this boils down to computing ${\rm cores}$ on cohomology groups, which we may do after restricting $\Lambda$ to an $N(\Z_p)$-representation (using \cite[Proposition 2.1.11]{emerton-ord} and the fact that the definition of ${\rm cores}$ only involves the $N(\Z_p)$-action). So we wish to understand
$$ {\rm cores} \colon H^{i}(\gamma N(\Z_p) \gamma^{-1},\Lambda) \to H^{i}(N(\Z_p),\Lambda) $$
for all $0\leq i\leq d$. Choose an isomorphism $N(\Z_p)\cong \Z_p^{d}$; then $\gamma N(\Z_p) \gamma^{-1} \cong (p^{2}\Z_p)^{d}$ and, using the K\"unneth formula, it will be sufficient to understand
$$ {\rm cores} \colon H^{i}(p^{2}\Z_p,\Lambda) \to H^{i}(\Z_p,\Lambda). $$
We resolve $\Lambda$ by $\Map_{{\rm cont}}(\Z_p,\Lambda) \to \Map_{{\rm cont}}(\Z_p,\Lambda)$ (with the translation action on both terms),
where the map is the difference operator $\Delta(f)(x)=f(x+1)-f(x)$. From the definitions, ${\rm cores}$ is then computed by taking cohomology of the rows of the diagram
\begin{center}
\begin{tikzcd}
\Map({\mathbb Z}/p^{2}{\mathbb Z},\Lambda) \arrow[d,"\mathrm{cores}"] \arrow[r,"\Delta"] & \arrow[d,"\mathrm{cores}"] \Map({\mathbb Z}/p^{2}{\mathbb Z},\Lambda) \\
\Lambda \arrow[r,"0"] & \Lambda.
\end{tikzcd}
\end{center}
Here the top row is the $p^{2}\Z_p$-invariants of $\Map_{{\rm cont}}(\Z_p,\Lambda) \to \Map_{{\rm cont}}(\Z_p,\Lambda)$ and the bottom row is the $\Z_p$-invariants (with the obvious identifications), and ${\rm cores}$ is given by ${\rm cores}(f)=\sum_{i\in {\mathbb Z}/p^{2}{\mathbb Z}}f(i)$. As the kernel of $\Delta \colon \Map({\mathbb Z}/p^{2}{\mathbb Z},\Lambda) \to \Map({\mathbb Z}/p^{2}{\mathbb Z},\Lambda)$ is the constant functions and the image of $\Delta$ is precisely ${\rm Ker}(\mathrm{cores})$, one sees that ${\rm cores}$ is divisible by $p$ (indeed by $p^{2}$) on $H^{0}$'s and is an isomorphism on $H^{1}$'s. Returning to $N(\Z_p)\cong \Z_p^{d}$, the K\"unneth formula now implies that $ {\rm cores} \colon H^{i}(\gamma N(\Z_p) \gamma^{-1},\Lambda) \to H^{i}(N(\Z_p),\Lambda)$ is divisible by $p$ when $i<d$ and is an isomorphism when $i=d$.

It follows that the action of $h_{\gamma}^{m}$ on $H^{i}(N(\Z_p),\Lambda)$ is zero when $i<d$ and the identity when $i=d$, for any $m\geq 1$ divisible by $rp^{r-1}(p-1)$. Fix such an $m$; we have shown that $h_{\gamma}^{m}\in \End_{D_{\mathrm{sm}}(M(\Z_p),\Lambda)}(R\Gamma(N({\mathbb Z}_p), \Lambda))$ gives rise on cohomology to an idempotent with the desired property. Since the natural ring homomorphism
$$ \End_{D_{\mathrm{sm}}(M(\Z_p),\Lambda)}(R\Gamma(N({\mathbb Z}_p), \Lambda)) \to \End_{M(\Z_p)}(H^{\ast}(N({\mathbb Z}_p), \Lambda)) $$
has nilpotent kernel (this follows e.g. by the proof of \cite[Lemma 2.5(2)]{khare-thorne}), the idempotent lifting lemma (see e.g. \cite[Tag 05BU]{stacks-project}) shows that there is an idempotent $e\in \End_{D_{\mathrm{sm}}(M(\Z_p),\Lambda)}(R\Gamma(N({\mathbb Z}_p), \Lambda))$ which reduces to $h_{\gamma}^{m} \in \End_{M(\Z_p)}(H^{\ast}(N({\mathbb Z}_p), \Lambda))$ on cohomology. This finishes the proof of the first part.

\medskip
The second part follows from \cite[Proposition 3.6.2]{emerton-ord}. More precisely, in the notation of that reference, the computation above shows that $H^{d}{\rm Ord}_{P}(\Lambda) =H^{d}(N(\Z_p),\Lambda)$ and hence \emph{loc. cit} shows that $H^{d}(N(\Z_p),\Lambda)$ is isomorphic, as an $M(\Z_p)$-representation, to the inverse of the algebraic character which is denoted by $\alpha$ in \emph{loc. cit}. From the definition on $\alpha$ in \emph{loc. cit}, one computes that $\alpha= \psi^{n}$.
\end{proof}

\begin{prop} \label{XM to XP} In the notation of Theorem \ref{direct summand},
for all $m$,
there is a quasi-isomorphism
$$C(K^p_M K_{M,p,m},-n,r)[-d] \xrightarrow{\sim} R\Gamma(\XP,\Lambda)^{\ord}$$ in $D(M({\mathbb Z}/p^{m}{\mathbb Z}), \Lambda)$,
compatible with the transition maps between different levels, and Hecke-equivariant for the integration
along unipotent fibres map $r_M \colon \mathbb{T}^S_P\to \mathbb{T}^S_M$.
\end{prop}

\begin{proof}
Let
\[
f_m \colon \XP \twoheadrightarrow \XM
\]
be the natural projection. This is a
proper morphism of smooth manifolds (in the sense
that the preimage of any compact set is compact)\footnote{Throughout this proof, we will use the six functor formalism for constructible sheaves
on smooth manifolds; all the functors appearing in the proof are derived functors between
derived categories of constructible sheaves. A general reference for this is~\cite[Ch. II, III]{kashiwara-schapira}.}.

There is a natural quasi-isomorphism
$R\Gamma(\XP,\Lambda) \simeq R\Gamma(\XM,Rf_{m*} \Lambda)$
in $D(M({\mathbb Z}/p^{m}{\mathbb Z}), \Lambda)$.  The formalism of \cite{newton-thorne} allows us to
think of $R\Gamma(X^M_{K_{M,m}},Rf_{m*} \Lambda)$ as an object in the
derived category of $\mathbb{T}^S_M$-modules
and the same arguments as in the proof of~\cite[Thm. 4.2]{newton-thorne}
show that
\begin{equation} \label{unnormalized satake}
R\Gamma(\XP,\Lambda) \simeq r_M^* \left( R\Gamma(\XM,Rf_{m*} \Lambda) \right)
\end{equation}
in the derived category of $\mathbb{T}^S_P$-modules.

We first explain how to think of $R\Gamma(X^M_{K_{M,m}},Rf_{m*} \Lambda)$ as an object in the
derived category of $\mathbb{T}^S_M$-modules.
Let
\[
\mathfrak{X}_M \colonequals M({\mathbb Q})\backslash \left(X^M\times M(\AA_f)\right).
\]
A $\Lambda[K(m) \cap M(\Q_p)]$-module $V$ gives rise to
an $M(\AA_f^S)\times \left(K(m)\cap M(\AA_{f,S})\right)$-equivariant sheaf ${\mathcal V}$ on $\mathfrak{X}_M$.
If we apply the forgetful functor and only think of ${\mathcal V}$ as a $K(m)$-equivariant sheaf on $\mathfrak{X}_M$,
it determines a sheaf ${\mathcal V}_{m}$ on $\XM$.
Similarly, an object in the derived category of
$\Lambda[K(m) \cap M(\Q_p)]$-modules gives rise to an object in the
derived category of sheaves on $\XM$.
In particular, $R\Gamma(K(m) \cap N(\Q_p),\Lambda)$ gives rise
to an object that can be identified canonically with $Rf_{m*} \Lambda$.

We now explain how to endow the cohomology $R\Gamma(\XM, Rf_{m*} \Lambda)$ with a $\mathbb{T}^S_M$-action.
Suppose given a $\Lambda[K(m)\cap M({\mathbb Q}_p)]$-module $V$ and the corresponding
equivariant sheaf ${\mathcal V}$ on $\mathfrak{X}_M$. By taking cohomology and then derived
$K(m)\cap M(\AA_f)$-invariants, we obtain an object $R\Gamma_{K(m)\cap M(\AA_f)}R\Gamma_{\mathfrak{X}_M}{\mathcal V}$
of the derived category of $\mathbb{T}^S_M$-modules
that becomes canonically quasi-isomorphic to $R\Gamma(\XM, {\mathcal V}_m)$ in $D(M({\mathbb Z}/p^{m}{\mathbb Z}),\Lambda)$,
i.e. after forgetting the $\mathbb{T}^S_M$-action. By applying this
composition of functors to $R\Gamma(K(m)\cap N({\mathbb Q}_p), \Lambda)$, we obtain an object in the derived category of $\mathbb{T}^S_M$-modules that
recovers $R\Gamma(\XM, Rf_{m*} \Lambda)$ in $D(M({\mathbb Z}/p^{m}{\mathbb Z}),\Lambda)$ and endows it with a $\mathbb{T}^S_M$-action.
The quasi-isomorphism~\eqref{unnormalized satake} now follows from
the arguments on pages 57 and 58 of~\cite{newton-thorne}.

By Lemma~\ref{splitting off the top degree}, we can split off $H^{d}(N({\mathbb Z}_p),\Lambda)[-d]$ from $R\Gamma(N({\mathbb Z}_p),\Lambda)$ in $D_{\mathrm{sm}}(M({\mathbb Z}_p), \Lambda)$. In the derived category of $M({\mathbb Z}/p^{m}{\mathbb Z})$-equivariant sheaves of $\Lambda$-modules on $\XM$, this amounts to splitting off the top degree $R^df_{m*}\Lambda[-d]$ from $Rf_{m*}\Lambda$.

The quasi-isomorphism
\[
R\Gamma(\XP,\Lambda)\simeq R\Gamma(\XM, Rf_{m*}\Lambda)
\]
is compatible with the transition morphisms between different levels. This can be seen
by applying proper base change ~\cite[Prop. 2.6.7]{kashiwara-schapira} to the Cartesian diagram
\begin{center}
\begin{tikzcd}
\XP[\ell] \arrow[d] \arrow[r,"f_{\ell}"] & \arrow[d] \XM[\ell] \\
\XP \arrow[r,"f_{m}"] & \XM.
\end{tikzcd}
\end{center}
The splitting off of $R^df_{m*}\Lambda[-d]$ from $Rf_{m*}\Lambda$
is also compatible with the transition morphisms between different levels, as
all the splittings are induced from the canonical splitting of
$H^d(N({\mathbb Z}_p),\Lambda)[-d]$ from $R\Gamma(N({\mathbb Z}_p),\Lambda)$. Therefore,
the splitting of $R\Gamma(\XM, R^df_{m*}\Lambda)$ from
$R\Gamma(\XP,\Lambda)[d]$ is compatible with the transition morphisms
between different levels.

Finally, we need to check that $R\Gamma(\XM, R^df_{m*}\Lambda)$ can be identified with
the ordinary part
$R\Gamma(\XM, Rf_{m*}\Lambda)[d]^{\ord}$. Since taking ordinary parts is an exact functor and since
we have distinguished triangles computing $R\Gamma(\XP,\Lambda)$ in terms of
$R\Gamma(\XM,R^if_{m*}\Lambda)$ for $i=0,\dots,d$, it is enough to prove that
$U_p$ acts nilpotently on $R\Gamma(\XM,R^if_{m*}\Lambda)$ whenever $i<d$
and invertibly when $i=d$. We write out the computation when $F$ is imaginary CM; when $F$ is totally real the computation is similar.

Recall that the action of
$U_p$ on $R \Gamma(\XP, \Lambda)$
arises from a correspondence
\[
\XP \xleftarrow{pr_1} \XPC \xrightarrow{pr_2} \XP.
\]
Here
\[
\XPC \colonequals P({\mathbb Q}) \backslash X^P\times P(\AA_f) / (\Gamma_1(p^m) \cap \Gamma^0(p)) K^p \cap P(\AA_f) \,, \]
\[
\Gamma^0(p) = \left\{g=(g_{\mathfrak{p}})\in G({\mathbb Z}_p)\mid g_{\mathfrak{p}}\equiv\begin{pmatrix} * & 0 \\ *& * \end{pmatrix}\pmod{p}\right\},
\]
$pr_2$ is the obvious projection, and $pr_1$ is right multiplication by
$\prod_{\iota}\begin{pmatrix} p\cdot I_n & 0 \\ 0 & I_n \end{pmatrix}$
followed by the obvious projection.
Then $U_p = pr_{2!} \circ pr_1^* = pr_{2*}\circ pr_1^*$.
We have a commutative diagram
\begin{center}
\begin{tikzcd}
\XP \arrow[d, "f_m"] & \arrow[l,"pr_1"] \XPC \arrow[d, "g_m"] \arrow[r,"pr_2"] & \XP \arrow[d, "f_m"] \\
\XM & \arrow[l,"pr_1'"] \XM \arrow[r,"\operatorname{id}"] & \XM
\end{tikzcd},
\end{center}
where $pr_1'$ is an isomorphism and the left square is Cartesian. The action of $U_p$ on $R\Gamma(\XM, Rf_{m*}\Lambda)$ is determined by the isomorphism
$pr_1'$ on $\XM$ and by the morphism $\operatorname{id}_*(pr_1')^*(Rf_{m*}\Lambda)\to Rf_{m*}\Lambda$
defined as follows:
\[
\operatorname{id}_*\circ(pr_1')^*Rf_{m*}\Lambda\simeq \operatorname{id}_*Rg_{m*}pr_1^*\Lambda = Rf_{m*}pr_{2*}pr^*_1\Lambda
\simeq Rf_{m*}pr_{2*}pr^*_2\Lambda  \to Rf_{m*}\Lambda.
\]
The first map is the canonical isomorphism coming from proper base change, i.e.~\cite[Prop. 2.6.7]{kashiwara-schapira}, applied to the left square
in the above diagram. The last map
is the adjunction corresponding to $pr_{2*} = pr_{2!}, pr_2^*=pr_2^!$, cf.~\cite[Thm. 3.1.5, Prop. 3.3.2]{kashiwara-schapira}.

We now compute the effect of this last morphism on stalks.
By~\cite[Lemma 5.2.2]{scholze-galois}, the fibers of $f_m$ and $g_m$
are tori, both isomorphic to $(S^1)^d$. On fibers, the map $pr_2$ is a covering map of degree $p^d$.
We notice that the proper pushforward map
\[
pr_{2!} \colon R^ig_{m*}\Lambda \to R^if_{m*}\Lambda
\]
is $p^{d-i}$ times an isomorphism. (Looking at stalks, the proper pushforward
on the cohomology of the fibers is obtained
by Poincar\'e duality from the usual pushforward on the homology of the fibers. One
notices that the pushforward under the covering map
$(S^1)^d\to (S^1)^d$ of degree $p^d$ is multiplication by $p^i$ on the $i$th
homology degree.) This proves that
$U_p$ acts nilpotently on all the terms with $i<d$
and invertibly on the term corresponding to $i=d$.
\end{proof}

This finishes the proof of Theorem \ref{direct summand}. In applications, where we will need a statement at finite level, we will use the following corollary.

\begin{cor}\label{cor direct summand} Let $K^p$, $K^p_M$, $\mathfrak{m}$ and $\mathfrak{M}$ be as in the statement of Theorem~\ref{direct summand}. For every $m\in {\mathbb Z}_{\geq 1}$, there exists a (large) $m'\in {\mathbb Z}_{\geq 1}$ such that $C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}[-d]$ is a $\mathbb{T}^S_G$-equivariant
direct summand of
\[
R\Gamma\left(K_{M,p,m}, \tau_{\geq d+1}C(K^p\Gamma_1(p^{m'}),r)_{\mathfrak{M}}\right)
\]
in $D(M({\mathbb Z}/p^m{\mathbb Z}), \Lambda)$, where ${\mathbb T}^{S}_{G}$ acts on $C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}[-d]$ via the unnormalized Satake transform ${\mathbb T}_{G}^{S} \to {\mathbb T}_{M}^{S}$.

\end{cor}

\begin{proof} For every $m'\in {\mathbb Z}_{\geq 1}$, set
\[
C^\bullet(m')\colonequals R\Gamma\left(K_{M,p,m}, \tau_{\geq d+1}C(K^p\Gamma_1(p^{m'}),r)_{\mathfrak{M}}\right),
\]
an object in $D(M({\mathbb Z}/p^m{\mathbb Z}), \Lambda)$.
The complex $C_1(K^p,r)_{\mathfrak{M}}$ is the homotopy colimit of the $C(K^p\Gamma_1(p^{m'}),r)_{\mathfrak{M}}$. The truncation functor $\tau_{\geq d+1}$ commutes with homotopy colimits as it is a left adjoint functor. The continuous cohomology $R\Gamma\left(K_{M,p,m},- \right)$ also commutes with homotopy colimits as $K_{M,p,m}$ is a compact $p$-adic group. (We can compute continuous cohomology using injective resolutions in $D_{\mathrm{sm}}(K_{M,p},\Lambda)$ and the homotopy colimit of injective resolutions will be an injective resolution itself, using~\cite[Lemma 2.1.3]{emerton-ord}). By applying $R\Gamma\left(K_{M,p,m},- \right)$ to the statement of Theorem~\ref{direct summand}, we deduce that $C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}[-d]$ is a direct summand of the homotopy colimit $\varinjlim_{m'} C^\bullet(m')$ in $D(M({\mathbb Z}/p^m{\mathbb Z}), \Lambda)$. Since $C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}$ is a perfect complex of $\Lambda\left[M({\mathbb Z}/p^m{\mathbb Z})\right]$-modules, it is a compact object in $D(M({\mathbb Z}/p^m{\mathbb Z}),\Lambda)$, and hence the morphism
\[
C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}[-d] \to \varinjlim_{m'} C^\bullet(m')
\]
comes from a morphism $C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}[-d] \to C^\bullet(m')$ for some (large enough) $m^{\prime}$. This implies that $C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}[-d]$ is a direct summand of $C^\bullet(m')$.
\end{proof}

\subsection{Preliminaries in commutative algebra}

Let $\mathbb{T}$ be a commutative topological $\Lambda$-algebra, with the topology defined by a decreasing sequence of ideals $\dots I_k\subseteq I_{k-1}\subseteq \dots \subseteq I_1\subset \mathbb{T}$ such that $\mathbb{T}/I_k$ is a finite free $\Lambda$-algebra for every $k\in {\mathbb Z}_{\geq 1}$.

\begin{lemma}\label{injective resolution with continuous action}  Let $\mathrm{G}$ be a compact $p$-adic analytic group.
Let $K$ be a bounded below complex of smooth $\mathrm{G}$-representations with $\Lambda$-coefficients and with a continuous action of $\mathbb{T}$ on each term that commutes with the $\Lambda[\mathrm{G}]$-module structure.

There exists a bounded below complex $I$ of injective objects in $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda)$ with a continuous $\mathbb{T}$-action on each term, that commutes with the $\Lambda[G]$-module structure, and such that there is a $\mathbb{T}$-equivariant quasi-isomorphism
$K\xrightarrow{\sim} I$
in $D_{\mathrm{sm}}(\mathrm{G}, \Lambda)$.
\end{lemma}

\begin{proof} First, we construct for every $M\in \mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda)$ with a continuous $\mathbb{T}$-action an injection
\[
M\hookrightarrow I(M)
\]
where $I(M)\in \mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda)$ is an injective object with a continuous $\mathbb{T}$-action.

For each $k\in {\mathbb Z}_{\geq 1}$, let $M_k$
denote the $\Lambda[\mathrm{G}]$-submodule of $M$ on which the $\mathbb{T}$-action factors through $\Lambda_k\colonequals \mathbb{T}/I_{k}$. Since $M$ is a discrete $\mathbb{T}$-module,
we have $M=\varinjlim_{k}M_k$. We will construct $I(M)\colonequals \varinjlim_{k}I(M)_k$ inductively, where each $I(M)_k$ will be an injective object in $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda)$. The forgetful functor from $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G}, \Lambda_k)$ to $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda)$ has as left adjoint the exact functor $\otimes_{\Lambda}\Lambda_k$ (this is exact because $\Lambda_k$ is finite free over $\Lambda$). This means that the forgetful functor preserves injectives, so all the $I(M)_k$ will be injectives in $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda)$. We conclude that $\varinjlim_{k}I(M)_k$ is also an injective object in $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda)$ by~\cite[Lemma 2.1.3]{emerton-ord}. Assume we have already constructed $I(M)_{k-1}$. We explain how to construct $I(M)_k$. First, define $M'_{k}$ to be the pushout $M_k\oplus_{M_{k-1}}I(M)_{k-1}$
in the abelian category $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda_k)$. Note that $M_{k-1}$ injects into both $M_k$ and $I(M)_{k-1}$, so that we have injections $M_k\hookrightarrow M'_k$ and $I(M)_{k-1}\hookrightarrow M'_k$. Let $I(M)_k$ be an injective object in $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda_k)$ such that $M'_{k}\hookrightarrow I(M)_k$. Define $I(M)\colonequals \varinjlim_{k}I(M)_k$.

If we forget about the topology on $\mathbb{T}$, the category $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G}, \mathbb{T})$ is abelian. The full subcategory ${\mathcal A}$ consisting of objects $M$ for which the action map
\[
\mathbb{T}\times M\to M
\]
is continuous, when $\mathbb{T}$ is equipped with the above topology and $M$ is equipped with the discrete topology, is an abelian subcategory.
One way to see this is by noting that $\mathbb{T}$ acts continuously on $M$ if and only if the annihilator ${\rm Ann}_{\mathbb{T}}(m)$ is open in $\mathbb{T}$ for every $m\in M$, and using this criterion it is easy to check that ${\mathcal A}$ is closed under taking kernels and cokernels, contains the zero object and is closed under taking the direct sum of two objects. Let ${\mathcal I}$ denote the subset of objects of ${\mathcal A}$ that are injective after applying the forgetful functor to $\mathrm{Mod}_{\mathrm{sm}}(\mathrm{G},\Lambda)$. The set ${\mathcal I}$ contains the zero object. We have shown above that any object in ${\mathcal A}$ admits an injective morphism to an object of ${\mathcal I}$. The fact that any bounded below complex $K$ with terms in ${\mathcal A}$ admits a quasi-isomorphism to a bounded below complex with terms in ${\mathcal I}$ then follows from~\cite[Tag 05T6]{stacks-project}.
\end{proof}

\begin{remark}%
We remark that we crucially used that the ring $\Lambda[\![\mathrm{G}]\!]$ is Noetherian in the proof. This would fail if we worked with ${\mathcal O}_C/p^r$-coefficients instead of $\Lambda$-coefficients.
\end{remark}

\begin{prop}\label{getting rid of C} Suppose $\mathrm{G}$ is a finite group and $P$ is a perfect complex in $D(\mathrm{G},\Lambda)$ with an action of $\mathbb{T}$. Suppose $I$ is a bounded below complex of injectives in $D(\mathrm{G}, \Lambda)$ with a continuous $\mathbb{T}$-action on each term and such that $P$ is a $\mathbb{T}$-equivariant
direct summand of $I$ in $D(\mathrm{G},\Lambda)$. Then the map
\[
\mathbb{T}\to \mathrm{End}_{D(\mathrm{G},\Lambda)}(P)
\]
is continuous for the discrete topology on the target.\footnote{The proposition and its proof are due to James Newton. We thank him for allowing us to include it here.}
\end{prop}

\begin{proof} We can replace $P$ with a bounded complex of finite projective $\Lambda[\mathrm{G}]$-modules, which are also injective $\Lambda[\mathrm{G}]$-modules since $\Lambda$ is self-injective and $\mathrm{G}$ is a finite group.

The fact that $P$ is a direct summand of $I$ in $D(\mathrm{G},\Lambda)$ implies that we have $\Lambda[\mathrm{G}]$-equivariant morphisms of complexes
\[
f\colon P\to I,
\]
\[
g\colon I\to P
\]
giving the $\mathbb{T}$-equivariant splitting in $D(\mathrm{G},\Lambda)$. (In particular, $g\circ f$ is homotopic to the identity on $P$). For each of the finitely many $n$ such that $P^n\not=0$, we choose generators $x^n_1, \dots, x^n_{k_n}$ of the finitely generated $\Lambda[\mathrm{G}]$-modules $P^n$. Since $\mathbb{T}$ acts continuously on $I^n$, the annihilator in $\mathbb{T}$ of $f(x^n_i)$ is an open ideal for each $i,n$. Taking the intersection over all the finitely many $i$ and $n$, we see that the annihilator in $\mathbb{T}$ of the subcomplex $f(P)\subset I$ is an open ideal.  The fact that the map
\[
\mathbb{T}\to \mathrm{End}_{D(\mathrm{G},\Lambda)}(P)
\]
has open kernel is now an immediate consequence of Lemma~\ref{maps to 0} below.
\end{proof}

\begin{lemma}\label{maps to 0} Suppose $T \in \mathbb{T}$ annihilates $f(P)$. Then $T$ maps
to zero in $\mathrm{End}_{D(\mathrm{G},\Lambda)}(P)$.
\end{lemma}

\begin{proof} Choose a lift $T_P$ of $T$ to an endomorphism of the complex $P$
(such a lift is well-defined up to homotopy). Since $P$ is a complex of injectives, $T_P$ coincides with $g \circ T \circ f$ up to a
$\Lambda[\mathrm{G}]$-linear null homotopy of $P$. Since $T$ annihilates $f(P)$, this shows that $T_P$
is a null homotopy of $P$, which is what we needed to prove.
\end{proof}

\subsection{Constructing the determinants}

As explained above, it suffices to construct a Galois representation
\[
\rho_{\mathfrak{m},r}\colon\mathrm{Gal}(\overline{F}/F)\to \GL_n\left(\mathbb{T}^S_M(K_M,\lambda,r)^{\mathrm{der}}\right).
\]
for every $r\in {\mathbb Z}_{\geq 1}$, with the correct characteristic polynomial at every prime $w$ of $F$ above a prime $l\not \in S$. We will use Chenevier's
notion of a determinant~\cite{chenevier}. Let $G_{F,S}$ denote the Galois group of the maximal extension of $F$ unramified outside primes above $S$.

Let $C$ be a complete, algebraically closed extension of $\overline{{\mathbb Q}}_p$, with a fixed embedding $\overline{{\mathbb Q}}\subset C$. Set $A\colonequals {\mathcal O}_C^a/p^r$. Given a locally symmetric space $X^{G}_K$, that is associated to a Shimura variety over $\overline{{\mathbb Q}}$, we let ${\mathcal X}^{*}_{K}$ be the corresponding minimal compactification of the Shimura variety, viewed as an adic space over $\Spa(C,{\mathcal O}_C)$. We let ${\mathcal I}\subset {\mathcal O}_{{\mathcal X}^*_{K}}$ be the ideal sheaf of the boundary and $\omega_K$ the usual ample line bundle. Fix the tame level $K^p\subset G(\AA_f^p)$. Following ~\cite[Thm. 4.3.1]{scholze-galois}, we fix some sufficiently divisible $m'\in {\mathbb Z}_{\geq 1}$ and define $\mathbb{T}^S_{cl}$ to be $\mathbb{T}^S_G$ equipped with the weakest topology for which all the maps
\[
\mathbb{T}^S_G \to \mathrm{End}_C\left(H^0\left({\mathcal X}^*_{K}, \omega_{K}^{\otimes m'k}\otimes {\mathcal I}\right)\right)
\]
are continuous, for varying $k\in {\mathbb Z}_{\geq 1}$ and $K_p$, where the right-hand side is a finite-dimensional $C$-vector space endowed with the $p$-adic topology. We recall~\cite[Cor. 5.1.11]{scholze-galois}
on the existence of determinants for certain quotients of $\mathbb{T}^S_{cl}$, but with our choice of normalizations.

\begin{thm}\label{existence of determinant} \leavevmode
\begin{enumerate}%
\item Assume $F$ is imaginary CM. For any continuous quotient $\mathbb{T}^S_{cl}\to B$ with $B$ discrete there exists a unique $2n$-dimensional continuous determinant $D$ of $G_{F,S}$ with values in $B$, such that for any prime $w$ of $F$ away from $S$ and above a prime $\bar{w}$ of $F^+$ we have
\[
D(1-X\cdot \mathrm{Frob}_{w}) = X^{2n} - T_{G, \bar{w}, 1}X^{2n-1}+\dots +q^{n(2n-1)}_w T_{G,\bar{w},2n}.
\]
\item  Assume $F$ is totally real. For any continuous quotient $\mathbb{T}^S_{cl}\to B$ with $B$ discrete there exists a unique $2n+1$-dimensional continuous determinant $D$ of $G_{F,S}$ with values in $B$, such that for any prime $\bar{w}$ of $F^+$ away from $S$ we have
\[
D(1-X\cdot\mathrm{Frob}_{w}) = X^{2n+1} - T_{G, \bar{w}, 1}X^{2n}+\dots -q^{(2n+1)n}_{\bar{w}} T_{G,\bar{w},2n+1}.
\]
\end{enumerate}
\end{thm}

\noindent Our starting point is the following result, which is essentially a consequence of~\cite{newton-thorne}.\footnote{At the moment, the arguments in~\cite{newton-thorne} are
not sufficient, as their definition of $\mathbb{T}^S_{cl}$ does not agree with the one in~\cite{scholze-galois}. However, an erratum to~\cite{newton-thorne} will correct this. For the sake of completeness, we include a full argument here. We thank James Newton for providing us with a proof of Theorem~\ref{factors through classical} ahead of time.}

\begin{thm}\label{factors through classical} For every $m\geq 0$, the map
\[
\mathbb{T}^S_{cl}\to \mathrm{End}_{D(M({\mathbb Z}/p^m{\mathbb Z}), \Lambda)}\left(C(K^p\Gamma_1(p^m),r)\right)
\]
is continuous for the discrete topology on the target.
\end{thm}

\begin{proof} Assume first that $F$ is imaginary CM. Lemma 5.23 (and some of the comparisons in Lemma 5.24) of~\cite{newton-thorne} gives a bounded complex $\check{C}$ of smooth $G({\mathbb Z}_p)$-representations with ${\mathcal O}_C/p^r$-coefficients, with a continuous action of $\mathbb{T}^S_{cl}$ on each term and with a quasi-isomorphism
\[
C(K^p,r)\otimes_{\Lambda}A\xrightarrow{\sim} \check{C}^a
\]
in $D_{\mathrm{sm}}(G({\mathbb Z}_p),A)$. Since the functor $(\ )_{!}$ from ${\mathcal O}_{C}^{a}$-modules to ${\mathcal O}_{C}$-modules is exact, we also have a quasi-isomorphism
\[
C(K^p,r)\otimes_{\Lambda}\mathfrak{m}_C/p^r\mathfrak{m}_C\xrightarrow{\sim} \check{C}\otimes_{{\mathcal O}_C/p^r}\mathfrak{m}_C/p^r\mathfrak{m}_C
\]
in $D_{\mathrm{sm}}(G({\mathbb Z}_p),{\mathcal O}_C/p^r)$. We think of this as a quasi-isomorphism in $D_{\mathrm{sm}}(G({\mathbb Z}_p), \Lambda)$
via the forgetful functor.  Note that $\mathbb{T}^S_{cl}$ still acts continuously on each term of $\check{C}\otimes_{{\mathcal O}_C/p^r}\mathfrak{m}_C/p^r\mathfrak{m}_C$,
when the latter is endowed with the discrete topology.

By Lemma~\ref{injective resolution with continuous action} applied to $\mathbb{T}\colonequals \mathbb{T}^S_{cl}\otimes_{{\mathbb Z}_p}\Lambda$ with the induced topology, we can replace $\check{C}\otimes_{{\mathcal O}_C/p^r}\mathfrak{m}_C/p^r\mathfrak{m}_C$ with a quasi-isomorphic bounded below complex $I$ of injective objects in $\mathrm{Mod}_{\mathrm{sm}}(G({\mathbb Z}_p), \Lambda)$ with a continuous
$\mathbb{T}$-action on each term. Let $K_p\subseteq G({\mathbb Z}_p)$ be a compact open subgroup. We have a sequence of quasi-isomorphisms
\[
C(K^pK_p,r)\otimes_{\Lambda}\mathfrak{m}_C/p^r\mathfrak{m}_C\xrightarrow{\sim} R\Gamma\left(K_p, C(K^p,r)\right)\otimes_{\Lambda}\mathfrak{m}_C/p^r\mathfrak{m}_C
\]
\[
\xrightarrow{\sim} R\Gamma\left(K_p, C(K^p,r)\otimes_{\Lambda}\mathfrak{m}_C/p^r\mathfrak{m}_C\right)\xrightarrow{\sim} I^{K_p}
\]
in $D(G({\mathbb Z}_p)/K_p, \Lambda)$. (The first and the third quasi-isomorphisms come by definition. The second quasi-isomorphism can be proved, for example, using the standard acyclic resolution of~\cite[Lemma 2.37]{newton-thorne} for the compact $p$-adic group $K_p$.)

Assume now that $K_{p}\subseteq G(\Z_p)$ is normal, and set $\mathrm{G}\colonequals G({\mathbb Z}_p)/K_p$. Since $I^{K_p}$ is a $\mathbb{T}$-stable subcomplex of $I$, it still has a continuous action of $\mathbb{T}$ on each term. We apply Lemma~\ref{injective resolution with continuous action} again, to the finite group $\mathrm{G}$ and the complex $I^{K_p}$ in order to replace it with a quasi-isomorphic bounded below complex of injective objects $J$ in $D(\mathrm{G},\Lambda)$ with a continuous action of $\mathbb{T}$ on each term. Since $C(K^pK_p,r)$ is a perfect complex of $\Lambda$-modules, we can find a bounded complex of finite projective $\Lambda[\mathrm{G}]$-modules $P$ quasi-isomorphic to it.  Choose $\alpha\in \mathfrak{m}_C\setminus p\mathfrak{m}_C$. We have an injection of $\Lambda$-modules
\[
\Lambda\alpha \hookrightarrow \mathfrak{m}_C/p^r\mathfrak{m}_C
\]
and, since $\Lambda$ is self-injective, this admits a splitting. Thus, $P\otimes_{\Lambda}\Lambda\alpha$ is a $\mathbb{T}$-equivariant direct summand of $P\otimes_{\Lambda}\mathfrak{m}_C/p^r\mathfrak{m}_C\simeq J$ in $D(\mathrm{G},\Lambda)$.
By Proposition~\ref{getting rid of C}, the map
\[
\mathbb{T}\to \mathrm{End}_{D(G,\Lambda)}(P)
\]
is continuous for the discrete topology on the target.

Now take $K_p=\Gamma(p^m)$. We have a $\mathbb{T}^S_{cl}$-equivariant quasi-isomorphism
\[
C(K^p\Gamma_1(p^m),r)\xrightarrow{\sim} R\Gamma\left(N({\mathbb Z}/p^m{\mathbb Z}), C(K^p\Gamma(p^m),r\right))
\]
in $D(M({\mathbb Z}/p^m{\mathbb Z}),\Lambda)$. The map in the statement of the theorem
factors as
\[
\mathbb{T}^S_{cl}\to \mathrm{End}_{D(G({\mathbb Z}/p^m{\mathbb Z}),\Lambda)}\left(C(K^p\Gamma(p^m),r)\right)\to \mathrm{End}_{D(M({\mathbb Z}/p^m{\mathbb Z}), \Lambda)}\left(C(K^p\Gamma_1(p^m),r)\right),
\]
where we have seen above that the first map is continuous and the second map is continuous as both the source and the target have the discrete topology.

The argument when $F$ is totally real is the same, except Lemma 5.23 of~\cite{newton-thorne} needs to be adapted to the $\mathrm{Res}_{F/{\mathbb Q}}\mathrm{Sp}_{2n}$-Shimura varieties defined in Section~\ref{Siegel case}. This can be done in the same way as in the unitary case.
\end{proof}

\begin{prop}\label{big determinant} Let $\chi\colon G_{F,S}\to {\mathbb Z}_p^\times$ be a continuous character of finite odd order, prime to $p$. Let $\lambda$ be a Weyl orbit of weights for $M$. Let $\mathfrak{m}\subset \mathbb{T}^S_M(K_M,\lambda, r)$ be non-Eisenstein.

There exists a continuous group determinant, of dimension $2n$ if $F$ is imaginary CM and of dimension $2n+1$ if $F$ is totally real,
\[
D_{M, \chi}\colon G_{F,S}\to \mathbb{T}^S_M(K_M, \lambda, r)_{\mathfrak{m}}^{\mathrm{der}}
\]
such that for every prime $w$ of $F$ above a rational prime $l\not \in S$, the characteristic polynomial of $D_{M,\chi}(\mathrm{Frob}_{w})$ is as follows.
Set
\[
P^{\vee}_{M,w}(X)\colonequals (-1)^n (q^{n(n-1)/2}_wT_{w,n})^{-1}X^nP_{M,w}(X^{-1}).
\]
\begin{enumerate}
\item
If $F$ is imaginary CM, then the characteristic polynomial is
\[
\chi(\mathrm{Frob}_w)^nP_{M,w}(\chi(\mathrm{Frob}_{w})^{-1}X)\chi(\mathrm{Frob}_{w^c})^{-n}q^{n(2n-1)}_wP^{\vee}_{M,w^c}(q_{w}^{1-2n}\chi(\mathrm{Frob}_{w^c})X).
\]
\item If $F$ is totally real, then the characteristic polynomial is
\[
\chi(\mathrm{Frob}_w)^n P_{M,w}(\chi(\mathrm{Frob}_w)^{-1} X) \chi(\mathrm{Frob}_w)^{-n} q_w^{2n^2} P^{\vee}_{M,w}(q_w^{-2n} \chi(\mathrm{Frob}_w)X)(X-q^n) \,.
\]
\end{enumerate}
\end{prop}

\begin{proof} We first assume $\chi=1$. The key point is to show that the map $\mathbb{T}^S_{cl} \to \End_{D(\Lambda)}(C(K_M,\lambda, r)_{\mathfrak{m}})$ is continuous, when the target is endowed with the discrete topology. This shows that $\mathbb{T}^S_M(K_M,\lambda,r)_{\mathfrak{m}}^{\mathrm{der}}$ is a continuous quotient of $\mathbb{T}^S_{cl}$ that is also discrete. We then obtain the desired determinant by applying Theorem~\ref{existence of determinant}.

We now reduce the question to $\lambda = \psi^{-n}$ for sufficiently small open normal subgroups of $M(\Z_p)$, at the expense of working equivariantly. Recall that
\[
K_{M,p,m}\colonequals \left\{m = (m_{\mathfrak{p}})_{\mathfrak{p}\mid p}\in M({\mathbb Z}_p)\mid m_{\mathfrak{p}}\equiv I_{n}\pmod{p^m}\right\}.
\]
For sufficiently large $m$ we have, by Proposition~\ref{going from finite to finite}, a $\mathbb{T}^S_{cl}$-equivariant
quasi-isomorphism
\[
R\Gamma\left( K_{M,p}/K_{M,p,m},C(K^{p}_{M}K_{M,p,m},-n,r)\otimes_{\Lambda}(\sigma^\circ/p^r \otimes_{\Lambda}\psi^{n}) \right) \xrightarrow{\sim} C(K_M,\lambda,r)
\]
in $D(\Lambda)$, where we think of $C(K^p_{M}K_{M,p,m},-n,r)$ as an element in $D(K_{M,p}/K_{M,p,m},\Lambda)$. The natural map ${\mathbb T}_{cl}^{S} \to \mathrm{End}_{D(\Lambda)}\left(C(K_M,\lambda,r)_{\mathfrak{m}}\right)$ factors (by Proposition \ref{going from finite to finite}) as
\[
\mathbb{T}^S_{cl}\to \mathrm{End}_{D(K_{M,p}/K_{M,p,m},\Lambda)}\left(C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}\right)\to \mathrm{End}_{D(\Lambda)}\left(C(K_M,\lambda,r)_{\mathfrak{m}}\right).
\]
The second map is continuous, since both the source and the target have the discrete topology. It is enough to show that
the first map is continuous. Thus, by allowing $K_{M,p}$ to be arbitrarily large and working equivariantly, we can assume $\lambda = \psi^{-n}$.

The case $\lambda = \psi^{-n}$ follows by combining Corollary~\ref{cor direct summand} with Theorem~\ref{factors through classical}. More precisely, Corollary~\ref{cor direct summand} shows that the natural map
$$\mathbb{T}^S_{cl}\to \mathrm{End}_{D(K_{M,p}/K_{M,p,m},\Lambda)}\left(C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}\right)$$
can be written as a composition
\[
\mathbb{T}^S_{cl}\to \mathrm{End}_{D(K_{M,p}/K_{M,p,m'},\Lambda)}\left(C(K^p\Gamma_1(p^{m'}),r)_{\mathfrak{M}}\right) \to
\]
\[
\to  \mathrm{End}_{D(K_{M,p}/K_{M,p,m},\Lambda)}\left(C(K^p_{M}K_{M,p,m},-n,r)_{\mathfrak{m}}\right)
\]
for some large enough $m^{\prime}$ (we remark that, while the second map is not a ring homomorphism, the composition is the natural ring homomorphism). The second map is continuous since both the source and the target have the discrete topology. The first map is continuous by Theorem~\ref{factors through classical}. Thus, the composition is continuous.

For a general character $\chi$, we now argue as in the proof of~\cite[Prop. 5.8]{newton-thorne}.
\end{proof}

We are now in a position to finally prove Theorem~\ref{eliminating nilpotent ideal}. Indeed, the theorem now follows from Proposition~\ref{big determinant} in the same way as~\cite[Thm. 1.3]{newton-thorne} follows from~\cite[Prop. 5.8]{newton-thorne}. This finishes the proof.

\bibliographystyle{amsalpha}

redpajama_set_name: RedPajamaArXiv