The surjectivity follows from Lemma <ref>. We show injectivity. Let $\phi, \phi' \in \AM(G)$ be such that $\phi^{\ad} \approx \phi^{\prime ,\ad}$. We need to show that $\phi \approx \phi'$.

By assumption, there exists $\beta _0 \in \Sha_{G^{\ad}}^{\infty} (\QQ, I_{\phi^{\ad}})$ such that $\phi^{\prime, \ad}$ is conjugate to $(\phi^{\ad}) ^{\beta_0}$. By Lemma <ref>, we have $I_{\phi^{\ad}} \cong I_{\phi}/ Z_G$. By this fact and by Corollary <ref> (applied to $I = I_{\phi}$ and $Z = Z_G$, where $I$ indeed has the same absolute rank as $G$), the natural map
$  \Sha_{G}^{\infty} (\QQ, I_{\phi}) \to    \Sha_{G^{\ad}}^{\infty} (\QQ, I_{\phi^{\ad}}) $ is surjective. Thus we can find $\beta \in \Sha_G^{\infty} (\QQ, I_{\phi})$ lifting $\beta_0$. Then $(\phi^{\beta})^{\ad}$ is conjugate to $\phi^{\prime, \ad}$. (Here $\phi^{\beta}$ is only well defined up to conjugacy, but the ambiguity does not affect the conjugacy class of $(\phi^{\beta})^{\ad}$.) By the transitivity in Lemma <ref>, we have $\phi^{\beta} \approx \phi'$. But $\phi \approx \phi^{\beta}$, so $\phi \approx \phi'$.

We have a natural surjection $\Gamma(\cH)_0 \to \Gamma(\cH^{\ad})_0$.

We can identify $\Gamma(\cH)_0 $ with the group of global sections of the sheaf $\cH/{\approx}$ on $\AM(G)/{\approx}$, and identify $\Gamma(\cH^{\ad})_0 $ with the group of global sections of the sheaf $\cH^{\ad}/{\approx}$ on $\AM(G^{\ad})/{\approx}$. By Lemma <ref>, we identify the spaces $\AM(G)/{\approx}$ and $\AM(G^{\ad})/{\approx}$. It follows from Lemma <ref> that we have a natural surjection $\cH/{\approx} \to \cH^{\ad}/{\approx}$ between sheaves on the identified space. The proposition follows.

Consider two unramified Shimura data $(G,X, p , \cG)$ and $(G_2,X_2, p , \cG_2)$ together with an isomorphism
$$\iota: (G^{\ad}, X^{\ad}) \isom (G_2^{\ad}, X_2^{\ad})$$
between the adjoint Shimura data. Assume that $\iota: G^{\ad} \isom G_2 ^{\ad}$ lifts to a (unique) central isogeny $\tilde \iota: G_{\der} \to G_{2,\der}$, and that $\iota_{\Q_p}: G_{\Q_p}^{\ad} \isom G_{2,\Q_p}^{\ad}$ extends to an isomorphism $\cG^{\ad} \isom \cG_2^{\ad} $.  We still use the symbols $\cH^{\dagger} , \cH^+, \fkH, \cH$ to denote the sheaves on $\AM(G) = \AM(G, X, p, \cG)$ as in <ref>. Their counterparts on $\AM(G_2) = \AM(G_2, X_2, p , \cG_2)$ will be denoted with a subscript $2$. On $\AM(G^{\ad}) = \AM(G^{\ad}, X^{\ad}, p , \cG^{\ad})$ we define the sheaves $\cH^{\dagger,\ad}$, $\cH^{+, \ad}$, $\fkH^{\ad}$, $\cH^{\ad}$ as in <ref>, and on $\AM(G_2^{\ad}) = \AM(G_2^{\ad}, X_2^{\ad}, p, \cG_2^{\ad})$ we have the counterparts denoted with a subscript $2$. Then $\iota$ induces an isomorphism
$$\AM(\iota): \AM(G^{\ad}) \isom \AM(G_2^{\ad})$$
under which the four sheaves on one space are identified with the four on the other respectively.

Let $\mu^{\ab} \in X_*(G^{\ab})$ denote the composite cocharacter
$$\GG_m \xrightarrow{\mu} G_{\Qbar} \to G^{\ab}_{\Qbar}, $$
where $\mu$ is any element of $\dmu_X(\Qbar)$. Clearly $\mu^{\ab}$ is independent of the choice of $\mu$.

Let $\dertau^+ \in \Gamma(\cH^+)_0$, and let $\dertau \in \Gamma(\cH)_0$ be the image of $\dertau^+$. By Proposition <ref>, we have surjections $\Gamma(\cH)_0 \to \Gamma(\cH^{\ad})_0$ and $\Gamma(\cH_2)_0 \to \Gamma(\cH^{\ad})_0$. Let $\dertau_0$ be the image of $\dertau$ in $\Gamma(\cH^{\ad})_0$.

Keep the setting of <ref>. Assume that $\dertau^+$ is tori-rational, and assume that $X_*(G^{\ab})$ is generated by $\mu^{\ab}$ as a $\Gal(\Qbar/\Q)$-module. Then there exists a tori-rational element $\dertau_2 \in \Gamma(\cH_2)_0$ mapping to $\dertau_0$ under the composite map

\begin{align}\label{eq:maps between Gamma}
\Gamma(\cH_2)_0 \to \Gamma(\cH_2^{\ad})_0 \isom  \Gamma(\cH^{\ad})_0,
\end{align}

where the last isomorphism is induced by $\AM(\iota)^{-1}$.

Consider $\phi\in \AM(G)$ and $\phi_2 \in \AM(G_2)$ such that $\AM(\iota)$ sends $\phi^{\ad}\in \AM(G^{\ad})$ to $\phi_2^{\ad} \in \AM(G_2^{\ad})$.  By Lemma <ref>, $\iota$ induces a $\QQ$-isomorphism $I_{\phi}^{\ad} \isom I_{\phi_2}^{\ad}$. Clearly this isomorphism lifts to a unique central isogeny $I_{\phi}^{\dagger} \to I_{\phi_2}^{\dagger}$, and the latter is induced by the central isogeny $\tilde \iota: G_{\der} \to G_{2,\der}$. In particular, we have a natural map $\mathcal H^{\dagger}(\phi) \to \mathcal H^{\dagger}_2(\phi_2)$ induced by $\iota$. By this observation, the same argument as the proof of Proposition <ref> shows that there is a natural map $\Gamma(\cH^{\dagger})_0 \to \Gamma(\cH^{\dagger}_2)_0$ induced by $\iota$.

Recall that the natural map $\Gamma(\cH^{\dagger})_0 \to \Gamma(\cH^+)_0$ is surjective. We fix an element $\dertau^{\dagger} \in \Gamma(\cH^{\dagger})_0$ lifting $\dertau^+ \in \Gamma(\cH^+)_0$. Let $\dertau_2^{\dagger}$ be the image of $\dertau^{\dagger}$ under the natural map $\Gamma(\cH^{\dagger})_0 \to \Gamma(\cH^{\dagger}_2)_0$ in the above paragraph. By construction, $\dertau_2$ is sent to $\dertau_0$ under the map in the proposition. We are left to check that $\dertau_2$ is tori-rational.

Let $\dertau_2 ^{+}$ and $\dertau_2$ be the images of $\dertau_2^{\dagger}$ in $\Gamma(\cH^{+}_2)_0$ and $\Gamma(\cH_2)_0$ respectively.
Let $\phi_2 \in \AM(G_2) $ and let $T_2$ be a maximal torus in $I_{\phi_2}$. We need to show that the image of $\dertau_2(\phi_2)$ in $\coh^1(\A_f,T_2)/\Sha_{G_2}^{\infty} (\Q, T_2)$ is trivial.

By Lemma <ref> we find $\phi \in \AM(G)$ such that $\AM(\iota) (\phi^{\ad}) = \phi_2^{\ad}$. To simplify notation in the rest of the proof we treat $\iota$ as the identity and omit it from the notation. Write $\phi_0$ for $\phi^{\ad}$, which we identify with $\phi_2^{\ad}$. Let $T_0$ be the image of $T_2$ under $I_{\phi_2}\to I_{\phi_0}$, and let $T$
be the preimage of $T_0$ under $I_{\phi} \to I_{\phi_0}$. It follows from Lemma <ref> that $T_0$ (resp. $T$) is a maximal torus in $I_{\phi_0}$ (resp. $I_{\phi}$).
As usual, set

\begin{align*}
T^{\dagger} & : = \ker(T \to G^{\ab}) = T \cap I_{\phi}^{\dagger} \\ T_2^{\dagger} & : = \ker (T_2 \to G_2^{\ab}) = T_2 \cap I_{\phi_2}^{\dagger}.
\end{align*}

Then there is a natural map $u:T^{\dagger}\to T_2^{\dagger}$ induced by the central isogeny $I_{\phi}^{\dagger} \to I_{\phi_2}^{\dagger}$ discussed at the beginning of the proof.

Define the torus $U: = (T \times _{T_0} T_2)^0$. Denote the natural maps $U \to T$ and $U \to T_2$ by $p_1$ and $p_2$ respectively. The inclusion map $T^{\dagger} \hookrightarrow T$ and the composite map $T^{\dagger} \xrightarrow{u} T_2^{\dagger} \hookrightarrow T_2$ together define a map $T^{\dagger} \to U$, which we denote by $\Delta$. Let $V$ be the quotient torus $U/\Delta(T^{\dagger})$. Then we have a commutative diagram with exact rows in the category of tori over $\QQ$:

\begin{align}\label{diag:three rows}
\xymatrix { 1 \ar[r] & T^{\dagger} \ar[r] \ar@{=}[d] & T \ar[r] & G^{\ab} \ar[r] & 1 \\
1 \ar[r] & T^{\dagger} \ar[r]^{\Delta}  \ar[d]^{u} & U \ar[d]^{p_2} \ar[u]_{p_1} \ar[r] & V \ar[u]_{\bar p_1} \ar[d]^{\bar p_2} \ar[r] & 1 \\
1 \ar[r] & T_2^{\dagger} \ar[r] & T_2 \ar[r] & G_2^{\ab} \ar[r] & 1
\end{align}

Here $\bar p_1$ and $\bar p_2$ are induced by $p_1$ and $p_2$ respectively.

We claim that the image of the map $X_*(V) \to X_*(G^{\ab})$ induced by $\bar p_1$ contains $\mu^{\ab}$. To show the claim, let $\mu_T$ be an arbitrary element of $\dmu_X(\Qbar)$ that factors through $T_{\Qbar}$ (which is embedded into $G_{\Qbar}$ via $I_{\phi, \Qbar} \hookrightarrow G_{\Qbar}$). Similarly, pick $\mu_{T_2}\in \dmu_{X_2} (\Qbar)$ that factors through $T_{2,\Qbar
}$. The two cocharacters of $T_{0 , \Qbar}$ induced by $\mu_T$ and $\mu_{T_2}$ respectively are conjugate by $G^{\ad}(\Qbar)$, and are hence in the same orbit under the Weyl group of $(G^{\ad}_{\Qbar}, T_{0,\Qbar})$ (cf. <cit.>). Since the Weyl group of $(G^{\ad}_{\Qbar}, T_{0,\Qbar})$ and that of $(G_{2,\Qbar} , T_{2,\Qbar})$ are canonically isomorphic, we can replace $\mu_{T_2}$ by a Weyl-conjugate and assume that $\mu_T$ and $\mu_{T_2}$ induce the same cocharacter of $T_{0, \Qbar}$. We then obtain from $
\mu_T $ and $\mu_{T_2}$ an element of $X_*(U)$. The image of this element under the composite map $X_*(U) \to X_*(V) \to X_*(G^{\ab})$ is $\mu_T$, by the upper right commutative square in (<ref>). The claim is proved.

By the claim and by our assumption on $X_*(G^{\ab})$, we know that $X_*(V) \to X_*(G^{\ab})$ is surjective.
It follows that the kernel of $\bar p_1: V \to G^{\ab}$ is a torus, which we denote by $V^{\dagger}$. Now it is easy to see that the map $(\bar p_1, \bar p_2): V \to G^{\ab} \times G_2^{\ab}$ is an isogeny between tori over $\Q$. Since $G^{\ab} $ and $G_2^{\ab} $ are both unramified over $\Q_p$, we deduce that $V$ and $V^{\dagger}$ are both unramified tori over $\Q_p$.
Let $\cV$ denote the $\Z_p$-torus extending $V_{\Q_p}$. The kernel of $\cV \to \cG^{\ab}$ is a torus over $\Z_p$, namely the one extending the unramified $\Q_p$-torus $V^{\dagger}_{\Q_p}$. By Lang's theorem applied to that kernel (which is smooth over $\ZZ_p$ and has connected fibers), we know that the map $\cV (\Z_p ) \to \cG^{\ab} (\Z_p)$ is surjective.

Using this surjectivity result and the commutative diagram (<ref>), we see that the natural map

$$ \coh^1(\A_f, T^{\dagger})/ \Sha^{\infty}_{G_{\der}} (\Q, T^{\dagger}) \To \coh^1(\A_f, T_2^{\dagger})/ \Sha^{\infty}_{G_{2,\der}} (\Q, T_2^{\dagger})$$

induced by $u: T^{\dagger} \to T_2^{\dagger}$ descends to a map

\begin{multline*}
\cok \bigg( \cG^{\ab}(\Z_p) \rightarrow \coh^1(\A_f, T^{\dagger})/\Sha_{G_{\der}}^{\infty}(\Q, T^{\dagger}) \bigg) \To  \\ \cok \bigg( \cG_2^{\ab}(\Z_p) \rightarrow \coh^1(\A_f, T_2^{\dagger})/\Sha_{G_{2,\der}}^{\infty}(\Q, T_2^{\dagger}) \bigg).
\end{multline*}

(The point is that the first cokernel does not change if $\cG^{\ab}(\Z_p)$ is replaced by $\cV(\Z_p)$.) From this, we see that tori-rationality of $\dertau^+$ (which is our assumption) implies tori-rationality of $\dertau_2^{+}$. Finally, we apply Lemma <ref> to deduce tori-rationality of $\dertau_2$ from tori-rationality of $\dertau_2^+$.

The significance of Proposition <ref> is that it allows the propagation of the tori-rational condition between the unramified Shimura data $(G,X, p , \cG)$ and $(G_2, X_2, p , \cG_2)$, at least when $X_*(G^{\ab})$ satisfies the technical condition. In <ref> below we shall apply the lemma to an arbitrary $(G_2,X_2, p, \cG_2)$ of abelian type and an auxiliary $(G,X, p , \cG)$ of Hodge type.

§.§ Reformulation of results from [Kis17]

Throughout this subsection, we fix a prime $p$, and fix an unramified Shimura datum $(G_2,X_2, p , \cG_2)$ where $(G_2, X_2)$ is of abelian type. For every Shimura datum $(G,X)$, we have an embedding of fields $E(G,X) \hookrightarrow \Qpbar$ as in <ref>. We denote the completion of $E(G,X)$ with respect to this embedding by $E(G,X)_p$. (In <ref> this was denoted by $E(G,X)_{\fkp}$.)

By a nice lifting of $(G_2, X_2, p , \cG_2)$, we mean an unramified Shimura datum of the form $(G,X, p , \cG)$ together with an isomorphism of Shimura data $\iota: (G^{\ad}, X^{\ad}) \isom (G_2^{\ad}, X_2^{\ad})$ satisfying the following conditions:

* $(G,X)$ is of Hodge type.

* We have $E(G,X)_p = E(G^{\ad}, X^{\ad})_p$.

* $\iota: G^{\ad} \isom G_2 ^{\ad}$ lifts to a (unique) central isogeny $\tilde \iota: G_{\der} \to G_{2,\der}$.

* $\iota_{\Q_p}: G_{\Q_p}^{\ad} \isom G_{2,\Q_p}^{\ad}$ extends to an isomorphism $\cG^{\ad} \isom \cG_2^{\ad} $

A nice lifting exists.

By <cit.>[In <cit.> it is used that every totally real field $F$ admits a totally imaginary quadratic extension $K/F$ such that every prime of $F$ over $p$ splits in $K$. This fact is an immediate consequence of Thm. 5 or Thm. 6 in <cit.>, regardless of the parity of $p$.], there exist a Shimura datum $(G,X)$ and an isomorphism $\iota:(G^{\ad}, X^{\ad}) \isom (G_2^{\ad}, X_2^{\ad})$ satisfying conditions (i), (ii), (iii) in Definition <ref>. The fact that we can extend $(G,X)$ to an unramified Shimura datum $(G,X, p , \cG)$ satisfying condition (iv) is shown in the proof of <cit.>. (The assumption that $p>2$ in loc. cit. is not used for the construction of $\cG$.)

Fix a nice lifting $(G,X, p , \cG, \iota)$ of $(G_2, X_2,p , \cG_2)$. We apply the notation in <ref> to our current $(G,X, p, \cG)$ and $(G_2, X_2 , p , \cG_2)$. Fix a bijection $\bij$ as in Theorem <ref>, and define the corresponding element  $\dertau_{\bij} \in \Gamma(\cH)_0$ as in Definition <ref> and Corollary <ref>. Let $\dertau_2 \in \Gamma(\cH_2)_0$ be an arbitrary element whose image in $\Gamma(\cH^{\ad})_0$ under (<ref>) is equal to that of $\dertau_{\bij}$.

In the setting of <ref>, the statement $\mathsf{LR} (G_2,X_2, p, \cG_2, \dertau_2) $  (see <ref>) holds.

The existence of a canonical smooth integral model having well-behaved $\coh^*_c$ follows from Theorem <ref> and Theorem <ref>. Hence the question is only about the bijection in the statement $\mathsf{LR} (G_2,X_2, p, \cG_2, \dertau_2) $. We first explain why this bijection is essentially proved in <cit.>, at least when $Z_G$ is a torus and $p>2$. We then explain how to remove the last two assumptions.[For the purpose of [53], the assumption that $Z_G$ is a torus is harmless. This is because by <cit.>, for the fixed  $(G_2, X_2, p ,\cG_2)$ one can always choose a nice lifting $(G,X, p ,\cG,\iota)$ such that $Z_G$ is a torus. However, in the current paper we will need to consider choices of $(G,X, p ,\cG)$ which do not necessarily satisfy this condition. See Remark <ref> below.]

For the first part, there are two points that deserve clarification. The first point is that by Proposition <ref>, the elements $\dertau_{\bij} (\phi_0) \in \cH^{\ad}(\phi_0)$, for $\phi_0 \in \AM(G^{\ad})$, are indeed the same as the elements denoted by $\tau$ in <cit.> (except that in loc. cit. $\tau$ is viewed as in $I_{\phi_0}^{\ad}(\A_f)$, instead of $\cH^{\ad}(\phi_0) = \tauhome{\phi_0}$).
The second point is that in <cit.> the following property of the bijection $\bij$ is assumed
(where $\cca$ is defined as in <ref>, with respect to $(G,X,p, \cG)$):

(*) For every $\JJ \in \cca$ , there exists $\fks \in \spd(G,X)$ such that  $\JJ = \JJ_{\fks}$ and $\bij (\JJ) = \II _{\fks}$.

This condition is indeed satisfied by the bijection $\bij' : \cca \isom \ica$ that is implicitly used in [53][In [53] this bijection is not explicitly defined, but it is any bijection as in Remark <ref>. That such a bijection satisfies condition (*) is shown in the proof of <cit.>.], but it may not be satisfied by $\bij$ in our current discussion. Nevertheless, it is clear from the proof of <cit.> that the hypothesis in that proposition can be weakened as follows: Instead of requiring $\JJ$ and $\mathscr I$ to be associated with one same $\fks \in \spd(G,X)$, we only require that $(\II, \JJ)$ is amicable. From this variant of <cit.>, the conclusion of <cit.> easily follows. More specifically, in the proof of <cit.>, instead of applying <cit.> to all pairs $(\JJ ,\mathscr I)$ with $\JJ =\JJ_{T, i ^{\beta}, h}, \mathscr I  = \mathscr I _{T, i^{\beta}, h}$, we apply the above-mentioned variant of <cit.> to all pairs $(\JJ, \mathscr I)$ with arbitrary $\JJ \in \cca$ and $\mathscr I = \bij(\JJ)$. This is valid because $(\JJ, \bij(\JJ))$ is indeed amicable by Theorem <ref>.

We now explain how to remove the assumption that $Z_G$ is a torus, which is made in <cit.>. This assumption comes from <cit.>. As is explained in the proof of that proposition (see especially footnote 24), this assumption can be removed once we know that <cit.> can be generalized to $\Z_p$-group schemes of the form $\cG' = \Res_{\oo_F/ \Z_p} \cG$, where $F/\Q_p$ is an arbitrary finite extension and $\cG$ is a reductive group scheme over $\oo_F$. (The result <cit.> is only proved for reductive group schemes over $\Z_p$, but $\cG'$ is not reductive unless $F/\Q_p$ is unramified.) This desired generalization is provided by Corollary <ref>.

Finally, we explain why the assumption $p>2$ in [53] is no longer needed. In fact, there are two reasons why this assumption is made in [52] and [53]. Firstly, this assumption is made in <cit.>. That this is unnecessary is explained in the proof of <cit.>. (We already mentioned this in <ref>.) Secondly, the assumption $p>2$ is needed for the integral comparison isomorphism (<ref>), which is key to both the papers [52] and [53]. We have already explained in <ref> why $p>2$ is no longer needed for the integral comparison isomorphism.

§.§ Proof of the Langlands–Rapoport–tau  Conjecture

In the following, by a CM field we mean a totally imaginary quadratic extension of a totally real field contained in our fixed $\Qbar$. We denote by $\iota$ the complex conjugation in $\Gal(\Qbar/\Q)$, defined with respect to our fixed embedding $\Qbar \hookrightarrow \CC$. For any $\Q$-torus $T$ and $\mu \in X_*(T)$, we write $E_{\mu}$ for the field of definition of $\mu$ inside $\Qbar$.

Following <cit.>, we consider the category $I$ of pairs $(T,\mu)$, where $T$ is a $\Q$-torus and $\mu \in X_*(T)$, satisfying that $w : = \mu + \iota(\mu)$ is defined over $\Q$ and that $(T/w(\GG_m))_{\RR}$ is anisotropic. By definition, a morphism $(T,\mu) \to (T',\mu')$ in $I$ is a $\Q$-homomorphism $T \to T'$ taking $\mu$ to $\mu'$. For each $(T,\mu)$ in $I$, we know that $T$ is a cuspidal torus since it satisfies condition (ii) in Lemma <ref>. By condition (vii) in that lemma, $T$ splits over a CM or totally real field, so $E_{\mu}$ is either CM or totally real. In the latter case we have $E_{\mu} = \Q$, since $\mu + \iota(\mu)$ is defined over $\Q$ and is equal to $2\mu$.

As in <cit.>, for every $(T,\mu)$ in $I$, there exists an object in $I$ of the form $(S^L, \mu^L)$ which maps to $(T, \mu)$. Here $L$ is a CM field with maximal totally real subfield $L_0$, and $S^L$ is the $\Q$-torus[In  <cit.>, the CM field is denoted by $K$ and our $S^L$ is denoted by $\lix^K S$. We have avoided the usage of $K$, and avoided the notation $\lix^L S$ as this conflicts with the L-group notation.]
$$ \Res_{L/\QQ} \GG_m / \ker (\N_{L_0/\Q} : \Res_{L_0/\QQ}\GG_m \to \GG_m ). $$
The cocharacter $ \mu^L \in X_*(S^L)$ is the one induced by the cocharacter of $\Res_{L/\QQ} \GG_m$ corresponding to the canonical embedding $L \hookrightarrow \ol \QQ$.  In fact, as discussed above, $E_\mu$ is either a CM field or $\Q$. We can take $L$ to any CM field containing $E_{\mu}$, and take the homomorphism $S^L \to T$ to be the one induced by the composite homomorphism

$$ \Res_{L/\QQ} \GG_m \xrightarrow{\Res_{L/\QQ} \mu } \Res_{L/\QQ} T \xrightarrow{\N_{L/\QQ}} T .$$

The fact that the above homomorphism factors through $S^L$ follows easily from the fact that $(T,\mu)$ satisfies the defining conditions for objects in $I$.

Keep the setting and notation of <ref>. There exists nice lifting $(G,X, p ,\cG, \iota)$ of $(G_2,X_2,p ,\cG_2)$ such that $X_*(G^{\ab})$ is generated by $\mu^{\ab}$ as a $\Gal(\Qbar/\Q)$-module. Here $\mu^{\ab}$ is as in <ref>.

The purpose of this lemma is to ensure that the technical assumption on $X_*(G^{\ab})$ in Proposition <ref> can be met, so that we can apply that proposition to propagate the tori-rational condition.

By Lemma <ref> we can find a nice lifting $(G_1, X_1, p, \cG_1, \iota_1)$ of $(G_2, X_2, p , \cG_2)$. Let $\mu_1^{\ab} \in X_*(G_1^{\ab})$ denote the composite cocharacter $\GG_m \xrightarrow{\mu_1} G_{1,\Qbar} \to G_{1,\Qbar}^{\ab}$ where $\mu_1 \in \dmu_{X_1}(\Qbar)$.
Since $(G_1,X_1)$ is of Hodge type, as in the proof of Lemma <ref> we know that the weight cocharacter $w_1$ of $X_1$ is defined over $\QQ$, and that $(Z_{G_1}^0/ w_1(\GG_m))_{\RR}$ is anisotropic. Since $G_1^{\ab}$ is isogenous to $Z_{G_1}^0$ and since $\mu_1^{\ab} + \iota(\mu_1^{\ab}) \in X_*(G_1^{\ab})$ is induced by $w_1 \in X_*(Z_{G_1}^0)$, we know that the pair $(G_1^{\ab}, \mu_1^{\ab})$ is in the category $I$ in <ref>. As discussed in <ref>, the field $E_{\mu_1^{\ab}}$ is either CM or $\QQ$. In the former case, we let $L$ be $E_{\mu_1^{\ab}}$. In the latter case, we let $L$ be an arbitrary imaginary quadratic field in which $p$ splits. We construct the morphism $(S^L ,\mu^L) \to (G_1^{\ab}, \mu_1^{\ab})$ in the category $I$ as in <ref>. Since we have an unramified Shimura datum $(G_1, X_1, p ,\cG_1)$, the torus $G_1^{\ab}$ is unramified over $\Q_p$. Hence every conjugate of the subgroup $\Gamma_{p,0} \subset \Gal(\Qbar/\Q)$ fixes $\mu_1^{\ab}$. It follows that the Galois closure of $E_{\mu_1^{\ab}}/\QQ$ is unramified over $p$, and so is the Galois closure of $L/\QQ$. Hence the torus $S^L$ is unramified over $\Q_p$ since it splits over this Galois closure of $L/\QQ$.

We now view $(S^L,  \mu^L)$ as a Shimura datum $(S^L, \set{h^L})$. (Recall that to specify a Shimura datum for a given torus over $\Q$ is the same as to specify the Hodge cocharacter, which can be an arbitrary cocharacter over $\Qbar$.)	By the paragraph preceding <cit.> and by <cit.>, we know that $S^L$ admits a faithful representation over $\Q$ such that the Hodge structure on that representation determined by $h^L$ is of type $\set{(-1,0), (0,-1)}$. By <cit.>, the last fact implies that $(S^L, \set{h^L})$ is a Shimura datum of Hodge type.

Let $G = G_1 \times_{G_1^{\ab}}  S^L $. Fix an element $h_1 \in X_1$. Note that $h_1$ and $h^L$ induce the same map $\mathbb S \to G_{1,\RR}^{\ab}$. Hence we obtain a homomorphism $h= (h_1, \lix^L h) : \mathbb S \to G_{\RR}$. Let $X$ be the $G(\RR)$-conjugacy class of $h$. It is clear that $X$ is a Shimura datum for $G$.[Here $X$ may depend on the choice of $h_1$, but it does not matter for our proof.] Since $(G_1,X_1)$ and $(S^L, \set{h^L})$ are both of Hodge type, we know that $(G,X)$ is of Hodge type (by taking the direct sum of the faithful symplectic representations of the two factors). There is a canonical identification $\iota: G^{\ad} \cong G_1^{\ad}$ determined by $\iota_1$, under which $X^{\ad}$ is identified with $X_1^{\ad}$. Then $(G,X)$ and $\iota$ satisfy conditions (i) and (iii) in Definition <ref>. Note that $E_{\mu^L}$ is contained in $L$, and the completion of $L$ with respect to $\Qbar \hookrightarrow \Qpbar$ is equal to the completion of $E_{\mu_1^{\ab}}$ with respect to $\Qbar \hookrightarrow \Qpbar$, which is a subfield of $E(G_1,X_1)_p$. It follows that $E(G,X)_p = E(G_1, X_1)_p$. Since $(G_1, X_1)$ satisfies condition (ii) in Definition <ref>, so does $(G,X)$. Since $G_1$ and $S^L$ are both unramified over $\Q_p$, so is $G$. Thus as in the proof of <cit.> we can extend $(G,X)$ to an unramified Shimura datum $(G,X,p, \cG)$ satisfying condition (iv) in Definition <ref>.

We have thus produced a nice lifting $(G,X, p ,\cG, \iota)$ of $(G_2,X_2, p ,\cG_2)$. It remains to show that $X_*(G^{\ab})$ is generated by $\mu^{\ab}$ as a $\Gal(\Qbar/\Q)$-module. Now $G^{\ab}$ is canonically identified with $S^L$, and $\mu^{\ab}$ is identified with $ \mu^L$. It is clear from the definition that $X_*(S^L)$ is generated by $\mu^L$ as a  $\Gal(\Qbar/\Q)$-module.

In the proof of Lemma <ref>, even if $Z_{G_1}$ is a torus, it can happen that $Z_G$ is not a torus. This is why in Theorem <ref> we needed to remove the assumption that $Z_G$ is a torus which is made in <cit.> .

Let $(G_2, X_2 , p , \cG_2)$ be an unramified Shimura datum such that $(G_2,X_2)$ is of abelian type.  Then Conjecture <ref> holds for $(G_2, X_2 , p , \cG_2)$.

We choose a nice lifting $(G,X , p ,\cG,\iota)$ of $(G_2, X_2, p , \cG_2)$ as in Lemma <ref>. We apply the notation in <ref> to our current $(G,X, p, \cG)$ and $(G_2, X_2 , p , \cG_2)$. Fix a bijection $\bij$ as in Theorem <ref> with respect to $(G,X, p ,\cG)$, and define the corresponding element  $\dertau_{\bij} \in \Gamma(\cH)_0$ as in Definition <ref> and Corollary <ref>.  In view of Theorem <ref>, we only need to show that there exists a tori-rational element $\dertau_2 \in \Gamma(\cH_2)_0$ whose image in $\Gamma(\cH^{\ad})_0$  under (<ref>)  is equal to that of $\dertau_{\bij}$.

It is clear that the assignment
$$\AM(G) \ni \phi \longmapsto \bigg(\tau^{\fkH}(\bij(\JJ), \JJ), \tau^{\cH}(\bij(\JJ), \JJ)  \bigg) \in \fkH(\phi) \oplus \cH(\phi) $$
as in <ref>, where $\JJ$ is the conjugacy class of $\phi$,   defines an element $\dertau^+ \in \Gamma(\cH^+)$. By the conditions satisfied by $\bij$ in Theorem <ref> and by Theorem <ref>, we know that $\dertau^+ \in  \Gamma(\cH^+)_0$. Also, by Theorem <ref>, we know that $\dertau^+$ is tori-rational.

It is clear that $\dertau^+$ maps to $\dertau_{\bij}$ under the natural map $\Gamma(\cH^+)_0 \to \Gamma(\cH)_0$. Since $\dertau^+$ is tori-rational and since $X_*(G^{\ab})$ is generated by $\mu^{\ab}$ as a $\Gal(\Qbar/\Q)$-module, the existence of the desired tori-rational $\dertau_2 \in  \Gamma(\cH_2)_0$ follows from Proposition <ref>.

Conjecture <ref> holds for all Shimura varieties of abelian type.

This follows from Theorems <ref> and <ref>.

§ PRELIMINARIES FOR STABILIZATION

§.§ Central character data and the trace formula

To stabilize the point counting formula for Shimura varieties (<ref>) in general, it is necessary to work with fixed central characters.
To this end, we are going to introduce the formalism of central character data following <cit.>.
The point counting formula can be understood through the lens of a particular central character datum, but it is useful to allow flexible central character data to accommodate $z$-extensions during the stabilization process.

The rest of <ref> is devoted to discussing the invariant trace formula with fixed central character. Though this is not logically needed for the stabilization in <ref>, it puts central character data into context, motivates the definition of stable distributions with fixed central characters, and also has an application in <ref> below.

Throughout <ref>, let $G$ be a connected reductive group over $\Q$ with center $Z$. Write $A_Z$ for the maximal $\Q$-split torus in $Z$ and set $A_{Z,\infty}:=A_Z(\R)^0$.

A central character datum for $G$ is a pair $(\fkX,\chi)$, where $\fkX$ is a closed subgroup of $Z(\A)$ containing $A_{Z,\infty}$ such that $Z(\Q)\fkX$ is closed in $Z(\A)$, with a choice of Haar measure on $\fkX$ (often implicit),
and  $\chi:\fkX\ra\C^\times$ a continuous character which is trivial on $\fkX_{\Q}:=\fkX\cap Z(\Q)$.

The two extreme cases where $\fkX=A_{Z,\infty}$ or $\fkX=Z(\A)$ are already interesting, but it is important to allow intermediate groups for our purpose.

Let $\Gamma_{\el}(G)$ denote the set of elliptic conjugacy classes in $G(\Q)$. Given a central character datum $(\fkX,\chi)$. Denote by $\Gamma_{\fkX,\el}(G)$ the set of $\fkX_\Q$-orbits in $\Gamma_{\el}(G)$ with respect to the multiplication action.
Write $\mathrm{Stab}_{\fkX}(\gamma)$ for the stabilizer subgroup of $\fkX_\Q$ fixing $\gamma\in \Gamma_{\el}(G)$. It is not hard to see that $\mathrm{Stab}_{\fkX}(\gamma)$ is finite, for instance by reducing to the case of a product of general linear groups via a (possibly reducible) faithful representation of $G$.

Fix a maximal compact subgroup $K_\infty\subset G(\R)$.
Let $v$ be a place of $\Q$, and $\fkZ$ a closed subgroup of $Z(\Q_v)$.
For a continuous character $\omega:\fkZ\ra \C^\times$ define $\cH(G(\Q_v),\omega^{-1})$ to be the Hecke algebra of smooth functions on $G(\Q_v)$ which transform under $\fkZ$ by $\omega^{-1}$ and have compact support modulo $\fkZ$; we also require $K_\infty$-finiteness if $v=\infty$. Let $\pi$ be an admissible representation of $G(\Q_v)$ which has central character on $\fkZ$ equal to $\omega$. For $f\in \cH(G(\Q_v),\omega^{-1})$ define

\begin{eqnarray}
\pi(f)(u) &:=& \int_{G(\Q_v)/\fkZ} f(g)\pi(g)u \cdot dg,\quad u\in \pi.\nonumber
\end{eqnarray}

The trace of the trace-class operator $\pi(f)$ is denoted by $\tr(f|\pi)$ or $\tr \pi(f)$. The orbital integrals for $f\in \cH(G(\Q_v),\omega^{-1})$ are defined by the same formula as for $\cH(G(\Q_v))$, cf. <ref>.
These definitions obviously extend to the adelic setting.

We recall the invariant distributions

in the classical setup where the central character datum consists of $\fkX=A_{Z,\infty}$ and $\chi_0:A_{Z,\infty}\ra\C^\times$.
First off, $I_{\geom,\chi_0}$ and $I_{\spec,\chi_0}$ are Arthur's invariant distributions given in sections 3 and 4 of [5], respectively. Define $I_{\el,\chi_0}$ to be the $M=G$ part of formula (3.3) and $I_{\disc,\chi_0}$ to be formula (4.4), both referenced to loc. cit. All the four distributions are distributions on $\cH(G(\A),\chi_0^{-1})$.[Arthur defines them as distributions on a certain space of functions on $G(\A)^1$ named $\cH(G(\A)^1)$, but this space is isomorphic to $\cH(G(\A),\chi_0^{-1})$ via the product decomposition $G(\A)= G(\A)^1 \times A_{Z,\infty}$. We do not mention $\cH(G(\A)^1)$ again.]

For $\gamma\in \Gamma_{\el}(G)$, write $I_\gamma$ for the connected centralizer of $\gamma$ in $G$.
We put

\begin{eqnarray*}
T_{\el,\chi_0}(f)&:=&\sum_{\gamma\in \Gamma_{\el}(G)} \iota(\gamma)^{-1}\vol(I_\gamma(\Q)\bs I_\gamma(\A)/A_{Z,\infty}) O_{\gamma}(f), \\
T_{\disc,\chi_0}(f)&:=&\tr(f\,|\, L^2_{\disc,\chi_0}(G(\Q)\bs G(\A))),\quad\quad f\in \cH(G(\A),\chi_0^{-1}).
\end{eqnarray*}

In general $I_{\star}(f)$ is more complicated than $T_{\star}(f)$ for $\star\in \{\el,\disc\}$. Arthur's invariant trace formula is the equality

\begin{equation}\label{e:ArthurITF}
\end{equation}

When $G/Z$ is anisotropic over $\Q$,

\begin{equation}\label{e:ArthurITFanis}
\end{equation}

Next we introduce the trace formula with respect to a fixed character on a closed central subgroup. This must be well known to experts but for the lack of a convenient reference we state the formula here.[Chapter 3.1 of [8] discusses such a variant in the discrete part of the trace formula. Sections 2 and 3 of [7] present both the spectral and geometric expansions of the trace formula with fixed central character on an induced torus. We treat a more general case than loc. cit. but proceed in a similar spirit.]

Let $(\fkX,\chi)$ be a central character datum for $G$. Suppose that $\chi_0:A_{Z,\infty}\ra\C^\times$ is the restriction of $\chi$. We will obtain the $\chi$-versions of the above invariant distributions by averaging.

Let $D$ be a multiplicative group over $\Q$, $A_D$ its maximal $\Q$-split subtorus, and $A_{D,\infty}:=A_D(\R)^0$. Then $D(\Q)\bs D(\A)/A_{D,\infty}$ is compact.

Replacing $D$ by $D^0$, we may assume that $D$ is a torus. Via a closed embedding, we reduce to the case where $D$ is a finite product of tori of the form $\Res_{F/\Q}\GG_m$ for a finite extension $F$ over $\Q$. When $D= \Res_{F/\Q}\GG_m$, the lemma is clear since $F^\times \bs \A_F^1$ is compact, where $\A_F^1$ denotes the group of ideles of norm $1$.

The quotient $\fkX_\Q\bs \fkX/A_{Z,\infty}$ is compact.

This is clear since the inclusion $\fkX\subset Z(\A)$ induces a closed embedding
from $\fkX_\Q\bs \fkX/A_{Z,\infty}$ into $Z(\Q)\bs Z(\A)/A_{Z,\infty}$.	(The image is closed since $ Z(\Q)\fkX$ is closed in $Z(\A)$.)

There is a surjection $\cH(G(\A),\chi_0^{-1})\ra \cH(G(\A),\chi^{-1})$ sending $f$ to the function

$$g\mapsto \ol{f}_\chi(g):=\int_{\fkX/A_{Z,\infty}} f(gz)\chi(z) dz,$$

where the integral converges because $z\mapsto f(gz)$ has compact support in $\fkX/A_{Z,\infty}$.
Given a function $f$ on $G(\A)$ and $z\in Z(\R)$, write $f_z$ for the translated function $g\mapsto f(gz)$. For each $\star\in \{\geom,\spec,\el,\disc\}$ define

\begin{equation}\label{eq:def-of-T_chi}
I_{\star,\chi}(f):=\frac{1}{\vol(\fkX_\Q\bs \fkX/A_{Z,\infty})}\int_{\fkX_\Q\bs \fkX/A_{Z,\infty}} \chi(z) I_{\star,\chi_0}(f_z)dz,\quad f\in \cH(G(\A),\chi_0^{-1}),
\end{equation}

as well as $T_{\el,\chi}$ and $T_{\disc,\chi}$ in a similar manner.
In the special case where $G/Z$ is anisotropic over $\Q$, it is clear from (<ref>) that

$L^2_{\disc,\chi}(G(\Q)\bs G(\A))$
for the discrete spectrum in the $L^2$-space of complex-valued functions $\phi$ on $G(\Q)\bs G(\A)$ such that

* $\phi(gz)=\chi(z)\phi(g)$ for every $g\in G(\A)$ and every $z\in \fkX$,

* $\int_{G(\Q)\bs G(\A)^1/\fkX\cap G(\A)^1}|\phi(g)|^2 dg <\infty$ (for any Haar measure), where $G(\A)^1$ denote the “norm one” subgroup of $G(\A)$ as
defined in <cit.>.

For $f\in \cH(G(\A),\chi_0^{-1})$ the following equalities hold.

\begin{eqnarray*}
T_{\el,\chi}(f)&=&\sum_{\gamma\in \Gamma_{\el,\fkX}(G)} |\mathrm{Stab}_{\fkX}(\gamma)|^{-1}\iota(\gamma)^{-1} \vol(I_\gamma(\Q)\bs I_\gamma(\A)/\fkX) O_{\gamma}(\ol{f}_\chi),
\\		T_{\disc,\chi}(f)&=&\tr (\ol{f}_\chi \,|\, L^2_{\disc,\chi}(G(\Q)\bs G(\A))).
\end{eqnarray*}

We compute $T_{\el,\chi}(f)$ as follows:

\begin{eqnarray*}
& &\int_{\fkX_\Q\bs \fkX/A_{Z,\infty}}\sum_{\gamma\in \Gamma_{\el}(G)}  \chi(z)\iota(\gamma)^{-1} \frac{\vol(I_\gamma(\Q)\bs I_\gamma(\A)/A_{Z,\infty})}{\vol} O_{\gamma z}(f)dz\\
&=&\sum_{\gamma\in \Gamma_{\el}(G)} \int_{\fkX_\Q\bs \fkX/A_{Z,\infty}} \chi(z)\iota(\gamma)^{-1} \vol(I_\gamma(\Q)\bs I_\gamma(\A)/\fkX) O_{\gamma z}(f)dz\\
&=& \sum_{\gamma\in \Gamma_{\el,\fkX}(G)} \frac{\vol(I_\gamma(\Q)\bs I_\gamma(\A)/\fkX)}{|\mathrm{Stab}_{\fkX}(\gamma)| \iota(\gamma)} \int_{\fkX/A_{Z,\infty}} \chi(z) O_{\gamma z}(f)dz\\
&=&\sum_{\gamma\in \Gamma_{\el,\fkX}(G)}  \frac{\vol(I_\gamma(\Q)\bs I_\gamma(\A)/\fkX)}{|\mathrm{Stab}_{\fkX}(\gamma)| \iota(\gamma)} \int_{\fkX/A_{Z,\infty}} O_{\gamma}(\ol{f}_\chi).
\end{eqnarray*}

The equality for $T_{\disc,\chi}(f)$ follows from the following two observations. First, given an admissible representation $\pi$ of $G(\A)$ with central character $\chi_\pi$ on $\fkX$,

$$\int_{\fkX_\Q\bs \fkX/A_{Z,\infty}} \chi(z) \pi(f_z)dz= \pi(f) \int_{\fkX_\Q\bs \fkX/A_{Z,\infty}} \chi(z)\chi_{\pi}^{-1}(z)dz,$$

which equals 0 if $\chi\neq \chi_\pi$ and $\vol(\fkX_\Q\bs \fkX/A_{Z,\infty})\pi(f)$ if $\chi=\chi_\pi$. Second, if $\chi=\chi_\pi$,

\begin{eqnarray}
\pi(\ol{f}_\chi)&=&\int_{G(\A)/\fkX}\pi(g)\int_{\fkX/A_{Z,\infty}} f(gz)\chi(z)dzdg \nonumber\\
&=&\int_{G(\A)/\fkX}\int_{\fkX/A_{Z,\infty}} \pi(gz)f(gz)dz dg = \pi(f).\nonumber
\end{eqnarray}

We record a simplification of the trace formula with fixed central character when the test function is a stable cuspidal function at the real place.

Given a central character datum $(\fkX,\chi)$, suppose that $\fkX=\fkX^\infty\times \fkX_\infty$ with $\fkX^\infty\subset Z(\A_f)$ and $\fkX_\infty\subset Z(\R)$. (In particular $\fkX_\infty$ contains $A_{Z,\infty}$.) Accordingly we decompose $\chi=\chi^\infty\chi_\infty$. We also assume that $G(\R)$ contains a maximal torus which is compact modulo $\fkX_\infty$.

Let $\xi$ be an irreducible algebraic representation of $G_\C$. The inverse of the central character of $\xi$ on $Z(\R)$ is denoted by $\chi_\xi$. Let $\Pi_2(\xi)$ denote the set of isomorphism classes of (irreducible) discrete series representations of $G(\R)$ whose central and infinitesimal characters are the same as those of the contragredient of $\xi$. Define $f_\xi\in \cH(G(\R),\chi^{-1}_\xi)$ to be the sum of pseudocoefficients of $\pi_\infty$ as $\pi_\infty$ runs over $\Pi_2(\xi)$, cf. <cit.>, [16].

A stable cuspidal function on $G(\R)$ (relative to $\fkX_\infty$) is defined to be $f_\infty\in C_{c}^\infty(G(\R),\chi_\infty^{-1})$ such that for every irreducible tempered representation $\pi_\infty$ of $G(\R)$ whose central character restricts to $\chi_\infty$ on $\fkX_\infty$,
we have (i) $\tr \pi_\infty(f_\infty)=0$ unless $\pi_\infty$ is a discrete series representation, and (ii) $\tr \pi_\infty(f_\infty)$ has a constant value as $\pi_\infty$ runs over each discrete series $L$-packet, cf. <cit.>.
An example is $f_\xi$ in the last paragraph. In general, a stable cuspidal function is a finite linear combination of character twists of functions of the form $f_\xi$ (for  different $\xi$'s), up to a function whose orbital integrals are identically zero.

If $f_\infty$ is a stable cuspidal function then

This is proved in <cit.> when $\fkX_\infty=A_{Z,\infty}$. The same proof extends.

When $f_\infty$ is stable cuspidal,
a simple expansion for $I_{\geom,\chi_0}(f)$ is obtained in  <cit.>.
A similar expansion for $I_{\geom,\chi}(f)$ is given in <cit.> for more general central character data.

§.§ Endoscopic data and z-extensions

From here throughout <ref>, let $G$ be a connected reductive group over a local or global field $F$ of characteristic zero.

Langlands–Shelstad <cit.> and Kottwitz–Shelstad <cit.> have defined endoscopic data and related notions in the untwisted and twisted settings. Here we recall the untwisted case as well as a specific kind of local twisted endoscopy (generalizing the unramified base change) as studied in <cit.>.

Let $F,G$ be as above. An endoscopic datum for $G$ is a quadruple $\fke=(H,\cH,s,\eta)$, where

* $H$ is a quasi-split reductive group over $F$,

* $\cH$ is a split extension of $W_F$ by $\hat H$ such that the $L$-action of $W_F$ on $\hat H$ determined by $\cH$ coincides with the $L$-action of the $L$-group $^L H$,

* $s$ is a semi-simple element of $\hat G$,

* $\eta: \cH \ra {}^L G$ is an $L$-morphism inducing an isomorphism $\hat H\cong \Cent(s,\hat G)^0$ (via $\eta$ we view $s$ also as an element of $\hat H$),

such that $\Int(s)\circ \eta=a\cdot \eta$ for a 1-cocycle $a:W_F\ra Z(\hat G)$ which is trivial (resp. locally trivial) if $F$ is local (resp. global). In this case $H$ is said to be an endoscopic group for $G$.

The datum $\fke$ is said to be elliptic if $\eta(Z(\hat H)^\Gamma)^0\subset Z(\hat G)$. When $F$ is non-archimedean, we say that $\fke$ is unramified if $H$ and $G$ are unramified groups over $F$ and if $\eta$ is inflated from an $L$-morphism with respect to the Weil group of $F^{\ur}$ over $F$. An isomorphism from $\fke=(H,\cH,s,\eta)$ to $\fke'=(H',\cH',s',\eta')$ is an element $g\in \hat G$ such that $g \eta(\cH) g^{-1}=\eta'(\cH')$ in $^L G$ and $g s g^{-1}=s'$ in $\hat G/Z(\hat G)$.

Automorphisms of an endoscopic datum $\fke$ induce outer automorphisms of $H$ as in <cit.>. By $\Out_F(\fke)$ we mean the image subgroup of the outer automorphism group $\Out_F(H):=\Aut_F(H)/H_{\textrm{ad}}(F)$. Set

$$\lambda(\fke):=|\Out_F(\fke)|\in \Z_{>0}.$$

The set of endoscopic data is denoted by $E(G)$. Write $E_{\el}(G)$ for the subset of elliptic endoscopic data. Write $\cE(G)$ and $\cE_{\el}(G)$ for the corresponding sets of isomorphism classes.

For $\fke=(H,\cH,s,\eta)\in E(G)$, there exists a canonical injection over $F$

\begin{equation}\label{eq:ZGZH}
Z_G \hra Z_H
\end{equation}

as we now explain. Since an inner twisting induces a canonical isomorphism of centers, we may assume that $G$ is quasi-split over $F$. Choose a maximal torus $T_H$ of $H$ over $F$. Then there exist a maximal torus $T$ of $G$ and an isomorphism $T_H\cong T$, both defined over $F$ <cit.> such that the composite embedding $T\cong T_H \subset H$ is canonical up to $H(\ol F)$-conjugacy. Restricting from $T_H\cong T$, we get the desired map $Z_G\hra Z_H$, which is independent of the choices involved.

If $G_{\der}=G_{\textup{sc}}$ then by <cit.>, every $\fke\in \cE(G)$ is represented by $(H,{}^L H,s,\eta)$, that is, we can take $\cH={}^L H$.  In general there is no guarantee that this is possible, so we use $z$-extensions to reduce to this case.

A $z$-extension of $G$ over $F$ is defined to be a connected reductive group $G_1$ equipped with a short exact sequence

\begin{equation}\label{eq:z-ext-defined}
1 \ra Z_1 \ra G_1 \ra G \ra 1
\end{equation}

such that $G_{1,\der}=G_{1,\sconn}$, $Z_1\subset Z_{G_1}$, and $Z_1\cong \prod_{i\in I} \Res_{F_i/F}\GG_m$ for  finite extensions $F_i$ of $F$ over a finite index set $I$. We also call such a short exact sequence itself a $z$-extension of $G$.

If $F$ is non-archimedean and if $G$ is unramified, then there exists a $z$-extension $G_1$ of $G$ that is unramified.
Similarly, if $F$ is a number field and if $G$ is unramified at a finite set of finite places $S$, then there exists a $z$-extension $G_1$ of $G$ that is  unramified at $S$.

The lemma follows from <cit.>, possibly except the point, pertaining to the global case, that there exists a maximal torus $T$ of $G$ such that $T$ splits over an extension of $F$ unramified at $S$. Let us verify it.

Since $G$ is unramified over $F_v$ for each $v\in S$, so is $G_{\sconn}$. Thus there exists an unramified maximal torus $T_{\sconn,v}$ in $G_{\sconn,F_v}$. Write $T_{\sconn,v}(F_v)_{\textup{rs}}\subset T_{\sconn,v}(F_v)$ for the open subset consisting of regular semi-simple elements.
Then the non-empty subset

$$Y_v:=\bigcup_{g_v\in G_{\sconn}(F_v)} g_v \cdot T_{\sconn,v}(F_v)_{\textup{rs}} \cdot g_v^{-1} \subset  G_{\sconn}(F_v)$$

is open in $G_{\sconn}(F_v)$ by Harish-Chandra's submersion principle [42].
By weak approximation for $G_{\sconn}$, there exists an element $\gamma_0\in G_{\sconn}(F)\cap (\prod_{v\in S} Y_v)$. Let $T'$ denote the connected centralizer in $G_{\sconn}$ of $\gamma_0$. Then $T'$ is unramified at $S$ as it is conjugate to $T_{\sconn,v}$ at each $v\in S$. The obvious image of $T'\times Z_G^0$ in $G$ is then a  maximal torus of $G$ which is unramified at $S$.

Fix a $z$-extension of $G$ as in (<ref>).
For each $\fke=(H,\cH,s,\eta)\in E(G)$, there exists a central extension $1\ra Z_{1}\ra H_1\ra H\ra 1$ over $F$, with $H_1$ connected reductive, such that the induced short exact sequence $1\ra Z_1 \ra Z_{H_1} \ra Z_H\ra 1$ fits in the following row-exact commutative diagram:

$$ \xymatrix{ 1 \ar[r] & Z_{1} \ar[r] \ar@{=}[d] & Z_{G_1} \ar[r] \ar[d] & Z_G \ar[d]^-{\eqref{eq:ZGZH}} \ar[r] & 1
\\ 1 \ar[r] & Z_{1} \ar[r] & Z_{H_1} \ar[r] & Z_H \ar[r] & 1. }$$

Moreover, when $F$ is non-archimedean, we can choose $H_1$ to be unramified if $H$ and $G_1$ are unramified. When $F$ is a number field, $H_1$ can be chosen to be unramified at a finite set of places $S$ if $H$ and $G_1$ are unramified at $S$.

We do not claim that $H_1$ is a $z$-extension of $H$, that is, the derived subgroup of $H_1$ need not be simply connected.

Choose maximal tori $T_H\subset H$ and $T\subset G$ over $F$ together with an isomorphism $T_H\cong T$ over $F$ as in <ref>. We pull back the resulting embedding $Z_H\subset T_H \cong T \subset G$ via the surjection $G_1\rightarrow G$ to obtain the preimage $\tilde Z_1 \subset G_1$ fitting in the exact sequence

\begin{equation}\label{e:ZZZ}
1\ra Z_1\ra \tilde Z_1\ra Z_H\ra 1.
\end{equation}

Recall from <cit.> and the notation therein that $H=H_{\sconn} *_{Z(H_\sconn)} Z_H$. Setting
$H_1:=H_{\sconn} *_{Z(H_\sconn)} \tilde Z_1$,
we have a surjection $H_1\ra H$ induced by $\tilde Z_1\ra Z_H$, whose kernel is identified with $Z_1$. The construction yields $Z_{H_1}=\tilde Z_1$ and the commutative diagram of the lemma.

Let $F$ be a local or global field of characteristic $0$.
Fix a $z$-extension of $G$ as in (<ref>).
Let us explain how each $\fke=(H,\cH,s,\eta)\in E(G)$ gives rise to an endoscopic datum for $G_1$.

Fix inner twistings to quasi-split inner forms $H_{\ol F}\cong H^*_{\ol F}$ and $G_{\ol F}\cong G^*_{\ol F}$ together with $F$-pinnings for $H^*$ and $G^*$. Along the central extension $H_1\ra H$ provided by the preceding lemma, we can lift inner twistings to obtain $H_{1,\ol F}\cong H_{1,\ol F}^*$ and $G_{1,\ol F}\cong G_{1,\ol F}^*$ as well as $F$-pinnings for $H_1^*$ and $G_1^*$. As explained in <cit.>, we obtain
$\Gamma$-equivariant maps $\hat H\ra \hat H_1$, $\hat G\ra \hat G_1$, $\hat H_1\ra \hat Z_1$, and $\hat G_1\ra \hat Z_1$. We will consider the natural extension of the last three maps to $L$-morphisms $\zeta_{G_1}:{}^L G\ra {}^L G_1$, $^L H_1\ra {}^L Z_1$, and $^L G_1 \ra {}^L Z_1$, respectively. (As for $\hat H\ra \hat H_1$, we have $\zeta_{H_1}$ in the lemma below.) The composition $\hat H\ra \hat G\ra \hat G_1$ factors through the embedding $\hat H \ra \hat H_1$ to yield the following commutative diagram.

\begin{equation}\label{e:H-H_1-G-G_1}
\xymatrix{ \hat H \ar[r] \ar[d]  & {}\hat H_1 \ar[d] \\ \hat G \ar[r] & \hat G_1}
\end{equation}

Maintain the notation of <ref>.

* The embedding $\hat H \hra \hat H_1$ can be extended to an $L$-morphism $\zeta_{H_1}:\cH\ra {}^L H_1$ such that $\zeta_{H_1}$ induces a homeomorphism from $\cH$ onto its image.

* There exists an $L$-morphism $\eta_1:{}^L H_1\ra {}^L G_1$ such that the following is a commutative diagram extending (<ref>).

$$ \xymatrix{ \cH \ar[r]^-{\zeta_{H_1}} \ar[d]^-{\eta} & {}^L H_1 \ar[d]^-{\eta_1} \\ ^L G \ar[r]^-{\zeta_{G_1}} & ^L G_1}$$

* The quadruple $\fke_1:=(H_1,{}^L H_1,s_1,\eta_1)$, with $s_1:=\zeta_{G_1}(s)$, is an endoscopic datum for $G_1$. The isomorphism class of $\fke_1$ is independent of the choices in (i) and (ii).

To verify (i), consider the split extension of $\hat H_1$ by $W_F$ given by $\cH_1:=(Z(\hat H_1)\rtimes \cH)/Z(\hat H)$, where $Z(\hat H)$ embeds in the semi-direct product diagonally. The assignment $h\mapsto (1\rtimes h)$ induces an embedding $\cH\hra \cH_1$ extending the map $\hat H\hra \hat H_1$. As remarked in <ref>, $\cH_1\cong {}^L H_1$ since $G_{1,\textup{sc}}=G_{1,\der}$, so we obtain the desired map $\zeta_{H_1}$ by composition. Let us verify (ii). Since $G_{1,\textup{sc}}=G_{1,\der}$, we can extend $\hat H_1\ra \hat G_1$ to $\eta_0:{}^L H_1\ra {}^L G_1$ by <cit.>. The two $L$-morphisms $\zeta_{G_1}\eta$ and $\eta_0\zeta_{H_1}$ differ by a 1-cocycle $a:W_F\ra C$, where $C:=\Cent(\hat H,\hat G_1)$. Clearly $Z(\hat H_1)\subset C$. We also note that $Z(\hat H_1)\cap (C\cap \hat G)=Z(\hat H_1)\cap \hat G=Z(\hat H)$. Thus

$$\hat Z_1=Z(\hat H_1)/Z(\hat H)\subset C/C\cap \hat G \subset \hat G_1/\hat G=\hat Z_1,$$

implying that $C=Z(\hat H_1)$.
As $a$ is valued in $Z(\hat H_1)$, one can twist $\eta_0$ by $a$ to obtain $\eta_1$, which then makes the diagram commute.	Lastly (iii) is a routine check.

Given a central extension $H_1$ of $H$ as above, choose a splitting $W_F\ra \cH$ to consider the composition

$$W_F \ra \cH \xrightarrow{\zeta_{H_1}} {}^L H_1 \ra {}^L Z_1.$$

Write $\lambda_1:Z_1(F)\ra \C^\times$ if $F$ is local, or $\lambda_{1}:Z_1(F)\bs Z_1(\A_F)\ra \C^\times$ if $F$ is global, for the corresponding continuous character, which is independent of the choice of splitting. This character naturally shows up in endoscopic transfer.

We show that the assignment $\fke\ra \fke_1$ admits an inverse map.

The map $\fke\mapsto \fke_1$ defined by Lemma <ref> induces a bijection from $\mathcal E(G)$ onto $\mathcal E(G_1)$.

The injectivity is easy to see since $\hat G_1$ is generated by $\hat G$ and $Z(\hat G_1)$.

To prove the surjectivity, let $\fke_1=(H_1,{}^L H_1,s_1,\eta_1)\in E(G_1)$.
Replacing $\fke_1$ by an isomorphic datum, we may assume that $\eta_1(W_F)$ lies in the subgroup $^L G$ of $^L G_1$. Indeed, consider the exact sequence of continuous cohomology

$$\coh^1(W_F,\hat G) \ra \coh^1(W_F,\hat G_1)\ra \coh^1(W_F,\hat Z_1).$$

The image of $\eta_1$ under the second map lifts to a 1-cocycle $c$ valued in $Z(\hat G_1)$, up to a 1-coboundary, via the map $\coh^1(W_F,Z(\hat G_1))\ra \coh^1(W_F,\hat Z_1)$, which is surjective by <cit.>. Then $c\cdot \eta_1$ comes from a 1-cocycle valued in $\hat G$ up to a 1-coboundary.

We define $H$ to be the cokernel of the composite map $Z_1\hra Z_{G_1}\hra Z_{H_1}\hra H_1$.
We can write $s_1=sz$ for some $s\in \hat G$ and $z\in Z(\hat G_1)$. By pulling back $\eta_1:{}^L H_1\ra {}^L G_1$ via $^L G\hookrightarrow {}^L G_1$, we obtain an injection $\eta:\cH\ra {}^L G$ and see that $\cH$ is a split extension of $W_F$ by $\hat H$ (as $\cH$ is generated by $\eta_1(W_F)$ and $\hat H$).

It is enough to verify that $\fke:=(H,\cH,s,\eta)$ is an endoscopic datum for $G$, since it would then be obvious that $\fke\mapsto\fke_1$ by construction, and we will be done. The main point to show is that $\Int(s)\circ \eta=a\eta$ with trivial (resp. locally trivial) 1-cocycle $a:W_F\ra Z(\hat G)$ if $F$ is local (resp. global). Let us check this when $F$ is global as the local case is only simpler. Since $\fke_1\in \cE(G_1)$ we know that $\Int(s)\circ \eta_1=\Int(s_1)\circ \eta_1=a_1\eta_1$ with a locally trivial 1-cocycle $a_1:W_F\ra Z(\hat G_1)$. Since $\eta_1(W_F)\subset \hat G$ we have that $a_1(W_F)\subset Z(\hat G_1)\cap \hat G=Z(\hat G)$ and that $\Int(s)\circ \eta=a_1\eta$. As $G_1$ is a $z$-extension of $G$, the map $\coh^1(W_{F_v},Z(\hat G))\ra \coh^1(W_{F_v},Z(\hat G_1))$ is injective at each place $v$ (e.g., by <cit.>). Hence $a_1$ is locally trivial as a cocycle valued in $Z(\hat G)$.

From here until the end of <ref>, $F$ is assumed to be non-archimedean. Write $F_m$ for the unramified extension of $F$ of degree $m\in \Z_{\ge 1}$ in a fixed algebraic closure $\ol F$. Denote by $\sigma\in \Gal(F_m/F)$ the arithmetic Frobenius generator. Fix a $z$-extension $1\ra Z_1\ra G_1\ra G\ra 1$. Set $R:=\Res_{F_m/F} G$ and $R_1:=\Res_{F_m/F} G_1$. Write $\theta$ (resp. $\theta_1$) for the automorphism of $R$ (resp. $R_1$) induced by $\sigma$. Identify

$$\hat R=\hat G^{\Hom(F_m,\ol{F})}= \prod_{j=0}^{m-1} \hat G$$

such that the $j$-th component corresponds to the inclusion $F_m\subset \ol{F}$ precomposed by $\sigma^j$, and similarly for $\hat R_1$. There are unique embeddings $i:{}^L G\hra {}^L R$ and $i_1:{}^L G_1\hra {}^L R_1$ such that the maps are diagonal embeddings on the dual groups and the identity map on the Weil groups.

The following is a variant of Lemma <ref>. In practice $G_1$ and $H_1$ over $F$ will come from central extensions over $\Q$ independently of $m$. By contrast, the extensions $G'_1$ and $H'_1$ below depend on $m$ and will be considered only in a local setting.

Suppose that $G$ and $\fke=(H,\cH,s,\eta)$ are unramified. Consider $z$-extensions $1\ra Z_{1}\ra G_1\ra G\ra 1$ and $1\ra Z_{1}\ra H_1\ra H\ra 1$ as constructed in Lemma <ref> (disregarding the last assertion) such that $G_1$ and $H_1$ are unramified. Let $F'/F$ be a finite unramified extension. Then there exist

* a $z$-extension $1\ra Z'_1\ra G'_1\ra G\ra 1$ such that $Z'_1\cong \prod_{j\in J}\Res_{F'_j/F}\GG_m$ with $J$ a finite index set and $F'_j \supset F'$, and

* a central extension $1\ra Z'_1\ra H'_1\ra H\ra 1$ arising from (i) as in Lemma <ref>,

such that $G'_1$ and $H'_1$ are unramified over $F$, and such that
there is a commutative diagram with an injective middle vertical arrow

\begin{equation}\label{eq:z-ext2}
\xymatrix{ 1 \ar[r] & Z_1 \ar[r] \ar[d] & G_1 \ar[r] \ar@{^(->}[d] & G \ar@{=}[d] \ar[r] & 1
\\ 1 \ar[r] & Z'_1 \ar[r] & G'_1 \ar[r] &G \ar[r] & 1 },
\end{equation}

as well as the analogous diagram with $H,H_1,H'_1$ in place of $G,G_1,G'_1$.

We have $Z_1\cong \prod_{j\in J} \Res_{E_j/F}\GG_m$ for finite unramified extensions $E_j/F$. Take $Z'_1:=\prod_{j\in J} \Res_{E_jF'/F}\GG_m$. Along the canonical inclusion $Z_1\hra Z'_1$, we make a pushout diagram from the top row of Lemma <ref> as follows:

$$ \xymatrix{ 1 \ar[r] & Z_1 \ar[r] \ar[d] & Z_{G_1} \ar[r] \ar[d] & Z_G \ar@{=}[d] \ar[r] & 1
\\ 1 \ar[r] & Z'_1 \ar[r] & Z_{G_1}' \ar[r] & Z_G \ar[r] & 1 }$$

With the bottom row in place of (<ref>) we construct a $z$-extension $1\ra Z'_1 \ra G'_1\ra G \ra 1$ such that $Z_{G'_1}=Z_{G_1}'$ as in the proof of Lemma <ref>. By construction, we have (i) and (<ref>).
Applying Lemma <ref> to $G'_1$, we obtain (ii).
Since $Z_{H_1}$ and $Z_{H'_1}$ are preimages of $Z_H\subset G$ under $G_1\rightarrow G$ and $G'_1\rightarrow G$, we have $Z_{H_1}\subset Z_{H'_1}$. This in turn induces $H_1=H_{\textup{sc}} *_{Z(H_{\textup{sc}})} Z_{H_1} \subset H'_1=H_{\textup{sc}} *_{Z(H_{\textup{sc}})} Z_{H'_1}$. With this inclusion as the middle vertical arrow, we see that there is a commutative diagram analogous to (<ref>) for $H,H_1,H'_1$.

Under a temporary assumption on $\fke=(H,\cH,s,\eta)\in E(G)$ that

$$s\in Z(\hat H)^{\Gamma_F}$$

(in general $s\in Z(\hat H)^{\Gamma_F} Z(\hat G)$), we construct some twisted endoscopic data to be used in the stabilization (<ref>). Put $\tilde s:=(s,1,...,1)\in \hat R$,  which lies in $\cZ:=\Cent(i\eta(\cH),\hat R)$. Define the $L$-morphism $\tilde \eta: \cH\ra {}^L R$ to be the twist of $i\eta$ by the unramified 1-cocycle $a:W_F\ra \cZ$ mapping $\sigma$ to $\tilde s$. Then $\tilde\fke=(H,\cH,\tilde s, \tilde \eta)$ is checked to be a twisted endoscopic datum  for $(R,\theta)$, cf.  <cit.> or <cit.>. Replacing $\fke$ by $\fke_1$ (noting that the temporary assumption is still satisfied for $\fke_1$, i.e., $s_1\in Z(\hat H_1)^{\Gamma_F}$) we construct a twisted endoscopic datum $\tilde\fke_1=(H_1,{}^L H_1,\tilde s_1,\tilde \eta_1)$ for $(R_1,\theta_1)$. With $H'_1$ playing the role of $H_1$, we also construct $\fke'_1$ and $\tilde\fke'_1$.

§.§ Cohomological lemmas

Let $F$, $G$, and $\fke$ be as in <ref>. (The field $F$ is either local or global.) Take a $z$-extension $G_1$ as in Lemma <ref>. By Hilbert 90 the map $G_1(F)\ra G(F)$ is onto. Let $\gamma\in G(F)_{\semi}$ and choose a lift $\gamma_1\in G_1(F)$. We have a commutative diagram of reductive groups

\xymatrix{ 1 \ar[r] & Z_{1} \ar[r] \ar@{=}[d] & I_{\gamma_1} \ar[r] \ar[d] & I_{\gamma} \ar[r] \ar[d] & 1\\ 1 \ar[r] & Z_{1} \ar[r] & G_1 \ar[r] & G \ar[r] & 1,}

which gives rise to a $\Gamma$-equivariant commutative diagram by <cit.>:

\begin{equation}\label{e:xymatrix-Z-I-G}
\xymatrix{ 1 \ar[r] & Z(\hat I_{\gamma}) \ar[r]  & Z(\hat I_{\gamma_1}) \ar[r]  &  \hat Z_{1}\ar[r]  & 1\\ 1 \ar[r] & Z( \hat G ) \ar[r] \ar[u] & Z( \hat G_1 ) \ar[u] \ar[r] &  \hat Z_{1} \ar[r] \ar@{=}[u] & 1.}
\end{equation}

In particular we get a $\Gamma$-equivariant isomorphism
$$Z(\hat I_\gamma)/Z(\hat G)\cong Z(\hat I_{\gamma_1})/Z(\hat G_1). $$

We have

* If $F$ is global or local, there is a canonical isomorphism

$$\fkK(I_\gamma/F)\cong \fkK(I_{\gamma_1}/F).$$

* If $F$ is local non-archimedean, there is a canonical bijection

$$\fkD(I_{\gamma_1},G_1;F)\cong \fkD(I_{\gamma},G;F).$$

Let us check (i) in the global case. We obtain the following commutative diagram from <cit.> and diagram (<ref>):

$$\xymatrix{ \pi_0((Z(\hat I_\gamma)/Z(\hat G))^{\Gamma_F}) \ar[r]  \ar[d]^-{\sim} & \coh^1(F,Z(\hat G)) \ar[d] \\ \pi_0((Z(\hat I_{\gamma_1})/Z(\hat G_1))^{\Gamma_F}) \ar[r] & \coh^1(F,Z(\hat G_1)). }$$

The left vertical map is an isomorphism. The right vertical map is injective by <cit.> since $\hat {Z}_1^{\Gamma_F}$ is connected (a product of copies of $\C^\times$).
Further observe that the injective right vertical map induces an isomorphism $\ker^1(F,Z(\hat G))\cong \ker^1(F,Z(\hat G_1))$. To see this, notice that the cokernel is mapped injectively into $\ker^1(F,\hat Z_1)$, which is trivial since $Z_1$ is a product of induced tori.
Since $\fkK(I_\gamma/F)$ (resp. $\fkK(I_{\gamma_1}/F)$) is the preimage of $\ker^1(F,Z(\hat G))$ (resp. $\ker^1(F,Z(\hat G_1))$) under the top (resp. bottom) horizontal arrow, the left vertical map induces the desired isomorphism of (i). In the case of local fields, the same argument works if we replace the $\ker^1$-groups with the trivial group.

For (ii) consider the following commutative diagram of pointed sets (or of abelian groups by identifying $\coh^1$ with $\coh^1_{\ab}$)

$$\xymatrix{&& 1\ar[d] & 1\ar[d] \\
1 \ar[r] & \fkD(I_{\gamma_1},G_1;F) \ar[d] \ar[r] & \coh^1(F,I_{\gamma_1}) \ar[d] \ar[r] & \coh^1(F,G_1) \ar[d]\\ 1 \ar[r] & \fkD(I_{\gamma},G;F)  \ar[r]  & \coh^1(F,I_{\gamma})  \ar[r]  \ar[d]& \coh^1(F,G) \ar[d] \\
&& \coh^2(F,Z_{1}) \ar@{=}[r] & \coh^2(F,Z_{1}),}$$

where the middle and right columns come from the exact sequences preceding the lemma and the fact that $\coh^1(F,\cdot)=\coh^1_{\ab}(F,\cdot)$ when $F$ is non-archimedean (see <ref>). Assertion (ii) now follows from a diagram chase.

Let $(G,X)$ be a Shimura datum.
We study Kottwitz parameters and their invariants with respect to a $z$-extension
$1\ra Z_1 \ra G_1 \ra G\ra 1$ over $\Q$.
Let $T\subset G_{\R}$ be an elliptic maximal torus.
There exists $h\in X$ such that $\mu_h:\GG_m\ra G_\C$ factors through $T_{\C}$.
In the notation of <ref>, $\mu_h\in \dmu_X(\C)$.
Write $T_1\subset G_{1,\R}$ for the preimage of $T$. Then $\mu_h:\GG_m\ra T_\C$ lifts to a cocharacter $\mu_1:\GG_m\ra T_{1,\C}$, which we fix henceforth and view also as a cocharacter of $G_1$ over $\C$. As noted in <cit.>, the conjugacy class of $\mu_1$ comes from a Shimura datum $(G_1,X_1)$ for a suitable $X_1$, that is, $\mu_1\in \dmu_{X_1}(\C)$.
In particular the discussion of cohomological invariants (<ref>–<ref>) applies to $(G_1,X_1)$ and $\mu_1$.

Let $\gamma_{0,1}\in G_1(\A_f^p)$ and $\gamma_{0}\in G(\A_f^p)$ such that $\gamma_{0,1}$ maps to $\gamma_0$. Write $I_{0,1}$ and $I_0$ for the connected centralizers of $\gamma_{0,1}$ and $\gamma_0$ in $G_1$ and $G$ over $\A_f^p$, respectively.

Suppose that $\gamma_0\in G(\A_f^p)$ is the image of an element $\gamma_{0,1}\in G_1(\A_f^p)_{\textup{ss}}$. Then the natural map $\fkD(I_{0,1},G_1;\A_f^p)\ra \fkD(I_0,G;\A_f^p)$ is a bijection.

This follows from (<ref>) and part (ii) of Lemma <ref>.

Now consider a $z$-extension $1\ra Z_1 \ra G_1 \ra G\ra 1$ over $\Q_p$ (which need not come from $\Q$-groups via base change). Let $\mu:\GG_m\ra G_{\Qpbar}$ be a cocharacter over $\Qpbar$. Let $\gamma_{0,1}\in G_1(\Q_p)_{\textup{ss}}$, and $\gamma_0\in G(\Q_p)$ the image of $\gamma_{0,1}$. As usual, $I_0$ and $I_{0,1}$ are the connected centralizers of $\gamma_0$ and $\gamma_{0,1}$ in $G$ and $G_1$ over $\Q_p$, respectively. Fix a level $n\in \Z_{>0}$.

Denote by $\fkD_n(\gamma_0,G;\Q_p)$ the set of all $[b]\in \B(I_{0})$ satisfying condition KP1 of Definition <ref> with the given $\gamma_0$ and $n$. (Here we do not require $\textbf{KP0}$, which  will come into play in Corollary <ref> below.) This means that for some (thus every) representative $b\in I_0(\LL)$ of $[b]$, there exists $c\in G(\LL)$ such that
$$c^{-1} \gamma_0 c = c^{-1} b \sigma( b) \cdots {\sigma^{n-1}} (b) {\sigma^n}(c). $$

Given $[b]\in \fkD_n(\gamma_0,G;\Q_p)$, we will often write $\delta_{[b]}\in  G(\Q_{p^n})$ for the element arising from $[b]$ (well defined up to $\sigma$-conjugacy in $G(\Q_{p^n})$) as in Lemma <ref>. Then $\gamma_0$ is a degree $n$ norm of $\delta_{[b]}$.

Likewise we define $\fkD_n(\gamma_{0,1},G_1;\Q_p)$. The natural map $I_{0,1}\ra I_0$ induces a map

\begin{equation}\label{eq:D01-to-D0}
\fkD_n(\gamma_{0,1},G_1;\Q_p)
\To  \fkD_n(\gamma_{0},G;\Q_p).
\end{equation}

Let $\gamma_0,\gamma_{0,1}$ be as above. Suppose that $Z_1\cong \prod_{j\in J} \Res_{F_j/\Q_p}\GG_m$ with all $F_j$ containing $\Q_{p^n}$ and $J$ a finite index set.
Then the map (<ref>) is a bijection.

The map (<ref>) fits in the following commutative diagram

$$\xymatrix{ \fkD_n(\gamma_{0,1},G_1;\Q_p) \ar@{^(->}[r] \ar[d]_{\eqref{eq:D01-to-D0}} & \B(I_{0,1}) \ar[r] \ar[d]& \B(R_1) \ar[d] \\
\fkD_n(\gamma_{0},G;\Q_p) \ar@{^(->}[r] & \B(I_{0}) \ar[r]  & \B(R),}$$

where the vertical maps are induced by the natural maps $I_{0,1}\ra I_0$ and $R_1\ra R$.

We may assume that $\fkD_n(\gamma_{0},G;\Q_p)$ is non-empty since the lemma is vacuously true otherwise.
We claim that $\fkD_n(\gamma_{0,1},G_1;\Q_p)$ is also non-empty. To see this, fix $[b]\in \fkD_n(\gamma_{0},G;\Q_p)$ and pick a lift $\delta'_1\in G_1(\Q_{p^n})$ of $\delta_{[b]}$. Let $\gamma'_{0,1}\in G_1(\Q_p)$ be a degree $n$ norm of $\delta'_1$. Then the norm of $z\delta'_1$ is $z{}^\sigma z \cdots {}^{\sigma^{n-1}} z \gamma'_{0,1}$ with $z\in Z_1(\Q_{p^n})$. The norm map $Z_1(\Q_{p^n})\ra Z_1(\Q_p)$ is onto by the hypothesis on $Z_1$, so we may choose $z$ such that $\gamma_{0,1}$ is a norm of $\delta_1:=z\delta'_1$. This implies that there is $c_1\in G_1(\LL)$ such that $c_1^{-1} \gamma_{0,1} c_1 = \delta_1 {}^\sigma \delta_1 \cdots {}^{\sigma^{n-1}} \delta_1$.  Setting $b_1:=c_1\delta_1 {}^\sigma c_1^{-1}$, we see that $b_1\in I_{0,1}(\breve \Q_p)$ (since $G_1$ has simply connected derived subgroup) and that $[b_1]\in \fkD_n(\gamma_{0,1},G_1;\Q_p)$, proving the claim.

We fix $[b]$, $\delta_1$, and $[b_1]$ as in the last paragraph. In particular $\delta_1$ maps to $\delta:=\delta_{[b]}$, and $[b_1]$ to $[b]$.
By Corollary <ref>, $[b_1]\in \B(I_{0,1})$ and $[b]\in \B(I_0)$ are basic.  Define $\fkD([b_1],R_1)$ to be the set of basic elements $[b'_1]\in \B(I_{0,1})$ such that $\kappa_{I_{0,1}}([b'_1])-\kappa_{I_{0,1}}([b_1])$ lies in $\ker(\pi_1(I_{0,1})_{\Gamma_p,\tors}\to \pi_1(R_1)_{\Gamma_p,\tors})$. Define $\fkD([b],R)$ exactly in the same way with $I_0$ and $R$ in place of $I_{0,1}$ and $R_1$.

We claim that $\fkD_n(\gamma_{0},G;\Q_p)$ is a subset of $\fkD([b],R)$. Indeed, consider an element $[b']\in \fkD_n(\gamma_{0},G;\Q_p)$, which gives rise to $\delta'\in G(\Q_{p^n})$ as in Lemma <ref>. Corollary <ref> implies that $\kappa_{I_{0,1}}([b'_1])-\kappa_{I_{0,1}}([b_1])$ is a torsion element in $\pi_1(I_{0,1})_{\Gamma_p}$ via the right half of the commutative diagram on <cit.>. We know from Lemma <ref> that $\delta$ and $\delta'$ have the same norm, implying that $\delta$ and $\delta'$ are stably $\sigma$-conjugate by <cit.>. Therefore $[\delta]$ and $[\delta']$ are equal in $\B(R)$. Since $b$ and $b'$ are $\sigma$-conjugate to $\delta$ and $\delta'$ in $G(\LL)$, respectively, it follows that $[b]=[b']$ in $\B(R)$. Hence $\kappa_{I_{0}}([b'])$ and $\kappa_{I_{0}}([b])$ have the same image in $\pi_1(R)_{\Gamma_p}$, completing the proof of the claim.

What we have shown is summarized in the following commutative diagram.

\begin{equation}\label{eq:D0,1-D_0}
\xymatrix{ \fkD_n(\gamma_{0,1},G_1;\Q_p) \ar@{^(->}[r] \ar[d] & \fkD([b_1],R_1) \ar[d]^-{\mathrm{bij}.}  \\
\fkD_n(\gamma_{0},G;\Q_p) \ar@{^(->}[r] & \fkD([b],R)}
\end{equation}

The right vertical map is a bijection by the proof of <cit.>. (This relies on the assumption of the lemma on  $Z_1$.) Indeed, the proof there shows a canonical bijection from
$$\ker(\coh^1(\Q_p,I_{\delta_1})\ra \coh^1(\Q_p,R_1))$$
$$\ker(\coh^1(\Q_p,I_{\delta})\ra \coh^1(\Q_p,R)), $$
but this is exactly the right vertical map above via the functorial bijection between $\coh^1(\Q_p,H)$ and $\pi_1(H)_{\Gamma_p,\tors}$ for an arbitrary connected reductive group $H$ over $\Q_p$, cf. <cit.> and <cit.>.

Now we verify that the top horizontal map in (<ref>) is a bijection. As we have seen in the last paragraph, $\fkD([b_1],R_1)$ is in a canonical bijection with $\ker(\coh^1(\Q_p,I_{\delta_1})\ra \coh^1(\Q_p,R_1))$, which in turn is canonically bijective onto the set of $\sigma$-conjugacy classes in the stable $\sigma$-conjugacy class of $\delta_1$ in $G_1(\Q_{p^n})$. Recall that $\gamma_{0,1}$ is a norm of $\delta_1$. Therefore each $\delta'_1\in G_1(\Q_{p^n})$ stably $\sigma$-conjugate to $\delta_1$ gives rise to an element of $\fkD_n(\gamma_{0,1},G_1;\Q_p)$ as described in the second paragraph of the proof of the current lemma (more detailed on p. 167 of [65]). It is routine to check that this map gives the inverse of the top horizontal map in (<ref>).

Going back to diagram (<ref>), it is now clear that the left vertical map (as well as the lower horizontal map) is a bijection.

Assume that $\fkD_n(\gamma_{0},G;\Q_p)$ is non-empty. Then the map
$[b]\mapsto \delta_{[b]}$ gives a surjection from $\fkD_n(\gamma_{0},G;\Q_p)$ onto the set of $\sigma$-conjugacy classes in
the stable $\sigma$-conjugacy class in $G(\Q_{p^n})$ whose norm is $\gamma_0$.
If $G$ has simply connected derived subgroup then this map is a bijection.

Thanks to Lemma <ref>, we can choose a $z$-extension $G_1$ such that the condition on $Z_1$ in Lemma <ref> is satisfied.
Then the corollary follows from  the bijectivity of the lower horizontal map of (<ref>), together with the interpretation of $\fkD([b],R)$ in terms of $\sigma$-conjugacy classes below (<ref>).

Now we turn to the real place.
Let $(G,X)$ and $(G_1,X_1)$ be as in <ref>.
Following <ref> and <ref>, for each elliptic element $\gamma_0\in G(\R)$, we have $\tilde\beta_\infty(\gamma_0)\in \pi_1(I_0)=X^*(Z(\hat I_0))$ mapping to $[\mu]\in \pi_1(G)$ for any $\mu\in \dmu_X(\Qbar)$. The definition involves an extra choice, but the restriction of $\tilde\beta_\infty(\gamma_0)$ to $Z(\hat I_0)^{\Gamma_\infty}Z(\hat G)$ is independent of the choice. Analogously, for each elliptic element $\gamma_{0,1}\in G_1(\R)$, we have $\tilde\beta_\infty(\gamma_{0,1})\in  \pi_1(I_{0,1})=X^*(Z(\hat I_{0,1}))$ mapping to $[\mu_1]\in \pi_1(G_1)$ with $\mu_1\in \dmu_{X_1}(\Qbar)$.

Assume that $\gamma_{0,1}\in G_1(\R)$ and $\gamma_0\in G(\R)$ are elliptic elements such that $\gamma_{0,1}$ maps to $\gamma_0$. Then the image of $\tilde\beta_\infty(\gamma_{0,1})$ under the natural map $\pi_1(I_{0,1}) \ra \pi_1(I_{0})$ coincides with $\tilde\beta_\infty(\gamma_0)$ on $Z(\hat I_0)^{\Gamma_\infty}Z(\hat G)$.

In <ref> and <ref> (adapted to $(G_1,X_1)$), choose any $\R$-elliptic maximal torus $T_1\subset G_1$ and $h_1\in X_1$ factoring through $T_1$ to define $\tilde\beta_\infty(\gamma_{0,1})$. Take $T\subset G$ and $h\in X$ to be the images of $T_1$ and $h_1$ in the definition of $\tilde\beta_\infty(\gamma_0)$.
Then the lemma is true on the nose.

§.§ Langlands–Shelstad–Kottwitz transfer

Let $F$, $G$, and $\fke=(H,\cH,s,\eta)$ be as in Definition <ref>.
Throughout <ref>, assume $F$ to be a local field (of characteristic $0$).
Let $\psi:G^*_{\ol F}\ra G_{\ol F}$ be an inner twisting of $F$-groups with $G^*$ quasi-split over $F$. We will use the following notation for $G$ (and likewise for other reductive groups).

* $\Gamma(G)=\Gamma(G(F))$ is the set of semi-simple $G(F)$-conjugacy classes in $G(F)$,

* $\Sigma(G)=\Sigma(G(F))$ is the set of stable semi-simple conjugacy classes in $G(F)$,

* $\cH(G)=\cH(G(F))$ and $\cH(G,\omega^{-1})=\cH(G(F),\omega^{-1})$ as in <ref>,

* When $F$ is non-archimedean and $G$ is unramified, we fix a hyperspecial subgroup $K\subset G(F)$ and define $\cH^{\ur}(G)\subset \cH(G)$ and $\cH^{\ur}(G,\omega^{-1}) \subset \cH(G,\omega^{-1})$ to be the subalgebra consisting of $K$-bi-invariant functions.

We explain the transfer of conjugacy classes in endoscopy following <cit.>. See also <cit.>.

Let $\gamma_H\in H(F)_{\semi}$. Choose a maximal torus $T_H$ of $H$ over $F$ containing $\gamma_H$. There exists a canonical $G^*(\ol{F})$-conjugacy class of embeddings $j:T_H\ra G^*$ over $\ol F$. Fix a choice of $j$ and put $T^*:=j(T_H)$. Denoting the set of absolute roots of $T_H$ in $H$ (resp. $T^*$ in $G^*$) by $R(T_H,H)$ (resp. $R(T^*,G^*)$), we have $R(T_H,H)\subset R(T^*,G^*)$. The element $\gamma_H$ is said to be $(G,H)$-regular if $\alpha(\gamma_H)\neq 1$ for all $\alpha\in R(T^*,G^*)\backslash R(T_H,H)$. The definition depends only on the $H(\ol{F})$-conjugacy class of $\gamma_H$ and not on the extra choices. The $(G,H)$-regular subset of $H(F)_{\semi}$ and $\Sigma(H)$ will be denoted by $H(F)_{(G,H)\text{-} \reg}$ and $\Sigma(H)_{(G,H)\text{-} \reg}$, respectively.

Let $\gamma_H\in H(F)_{(G,H)\text{-} \reg}$. The $\ol{F}$-embedding $\psi\circ j:T_H\ra G$ is canonical up to $G(\ol{F})$-conjugacy, so $\gamma_H$ determines a semi-simple $G(\ol{F})$-conjugacy class in $G(\ol{F})$ defined over $F$.  If this conjugacy class contains an element $\gamma$ of $G(F)$, then we take the stable conjugacy class of $\gamma$ to be the image of $\gamma_H$. Otherwise the image of $\gamma_H$ is formally denoted by the empty set symbol $\emptyset$.
(Such a $\gamma$ always exists by <cit.> if $G$ is quasi-split and has simply connected derived subgroup, but not in general.)
To summarize, we obtain a map

\begin{equation}\label{e:Sigma(H)-Sigma(G)}
\Sigma(H)_{(G,H)\text{-} \reg} \To \Sigma(G)\cup \{\emptyset\}.
\end{equation}

We say that $\gamma_H$ and $\gamma\in G(F)_{\semi}$ have matching conjugacy classes, or simply that $\gamma$ is an image of $\gamma_H$. If the centralizer of $\gamma$ in $G$ is connected (e.g., if $G_{\der}=G_{\sconn}$) then the centralizer of $\gamma_H$ in $H$ is also connected by <cit.>.

If $G_1$ and $H_1$ are as in (<ref>) and Lemma <ref>, then the above construction can be performed for $G_1$ and $H_1$ in place of $G$ and $H$. This is visibly compatible with the surjections $G_1\rightarrow G$ and $H_1\rightarrow H$, leading to the following commutative diagram (where the symbol $\emptyset$ maps to itself under the right vertical map).

\xymatrix{
\Sigma(H_1)_{(G_1,H_1)\text{-} \reg} \ar[r]\ar[d] & \Sigma(G_1)\cup \{\emptyset\} \ar[d] \\
\Sigma(H)_{(G,H)\text{-} \reg} \ar[r] & \Sigma(G)\cup \{\emptyset\}

By slight abuse of language (as $H_1$ is not an endoscopic group of $G$), $\gamma\in G(F)_{\semi}$ is said to be an image of $\gamma_{H_1}\in H_1(F)_{(G_1,H_1)\text{-} \reg}$ if the stable conjugacy class of $\gamma_{H_1}$ maps to that of $\gamma$ in the above diagram.

We introduce $\kappa$-orbital integrals, of which stable orbital integrals are the special case.
Let us assume that $F$ is local for convenience. The main definitions here extend to the adelic setting in the obvious manner.

Let $\gamma\in G(F)_{\semi}$ and $x\in G(\ol{F})$. Suppose that $\gamma_x:=x^{-1}\gamma x\in G(F)$ and $x \rho(x)^{-1}\in I_\gamma(\ol{F})$ for every $\rho\in \Gamma_F$. Then $x$ and the 1-cocycle $\rho\mapsto x \rho(x)^{-1}$ define an element of $\coh^0(F,I_\gamma\bs G)$, to be denoted by $\dot x$. The map $x\mapsto \gamma_x$ factors through $\coh^0(F,I_\gamma\bs G)$, namely there is an induced map

$$\coh^0(F,I_\gamma\bs G)\To G(F),\quad \dot x\longmapsto \gamma_{\dot x}.$$

Recall that there is a short exact sequence

$$1\ra I_\gamma(F)\bs G(F)\ra \coh^0(F,I_\gamma\bs G) \ra \fkD(I_\gamma,G;F) \ra 1,$$

coming from a long exact sequence. Given Haar measures on $I_\gamma(F)$ and $G(F)$ and the counting measure on $\fkD(I_\gamma,G;F)$, there is a unique way to equip $\coh^0(F,I_\gamma\bs G)$ with a compatible measure. The map $\dot x\mapsto \gamma_{\dot x}$ induces a map

$$\fkD(I_\gamma,G;F)\To \Gamma(G),\qquad [x]\longmapsto \gamma_{[x]},$$

whose image consists of conjugacy classes in the stable conjugacy class of $\gamma$. If $G_\gamma=\Cent(\gamma,G)$ is connected (so that it equals $I_\gamma$) then $[x]\mapsto \gamma_{[x]}$ is a bijection onto the image. In general the fiber over the conjugacy class of $\gamma'\in G(F)$ (stably conjugate to $\gamma$) is in bijection with $\ker(\coh^1(F,I_{\gamma'})\ra \coh^1(F,G_{\gamma'}))$.
Recall the map $\fkD(I_\gamma,G;F)\ra \fkE(I_\gamma,G;F)=\fkK(I_\gamma/F)$ from <ref>. Thus we have a pairing

$$\lg \cdot,\cdot \rg: ~\fkD(I_\gamma,G;F)\times \fkK(I_\gamma/F)\To \C^\times.$$

Given $\kappa\in \fkK(I_\gamma/F)$ and $f\in \cH(G)$ we define the $\kappa$-orbital integral of $\gamma$ by

\begin{eqnarray}
\int_{\coh^0(F,I\backslash G)} e(I_{\gamma_{\dot x}})\lg \dot x,\kappa\rg O^{G(F)}_{\gamma_{\dot x}}(f) d\dot x\nonumber\\
&=&	\sum_{[x]\in \fkD(I_\gamma,G;F)} e(I_{\gamma_{[x]}})\lg [x],\kappa\rg O^{G(F)}_{\gamma_{[x]}}(f).
\nonumber
\end{eqnarray}

When $\kappa$ is trivial, one has the stable orbital integral

The superscript $G(F)$ will be omitted if there is no danger of confusion. The above definition of $\kappa$-orbital integrals works verbatim for $f\in \cH(G(F),\omega^{-1})$.

We recall the Langlands–Shelstad transfer in the local untwisted case. See <ref> below for the twisted case.

When $\cH={}^L H$ in the endoscopic datum (this assumption will be removed via $z$-extensions), Langlands–Shelstad [93, 94] define the transfer factor

$$\Delta(\cdot,\cdot): H(F)_{(G,H)\text{-} \reg}\times G(F)_{\semi} \To \C$$

which vanishes on $(\gamma_{H},\gamma)$ unless $\gamma$ is an image of $\gamma_{H}$.

When $G$ is quasi-split, the canonical  transfer factor $\Delta_0$ was given by Langlands–Shelstad depending only on a choice of $F$-pinning for $G$. Another natural normalization in the quasi-split case is the Whittaker normalization in <cit.>. While there is no direct analogue of either when $G$ is not quasi-split, the Whittaker normalization can be extended to $G$ given a suitable rigidification of an inner twisting of $G$ against its quasi-split inner form. See [47, 48] for Kaletha's notion of rigid inner forms and a discussion of other rigidifications. In this paper, we do not attempt to choose a rigidification or a canonical normalization of transfer factor at every place. However when $G$ is defined over $\Q$, we may and will always choose a global normalization as in <cit.> so that the product formula (Corollary 6.4.B therein) holds true.

In fact there are more than one sign conventions for (untwisted and twisted) transfer factors as explained in [72]. We work with the factor $\Delta'$ in loc. cit., which coincides with the one in [65] (see p. 178 therein) but differs from the definition of [93] by the map $(H,\cH,s,\eta)\mapsto(H,\cH,s^{-1},\eta)$. The reason for our choice is that the former is better suited for extension to the twisted setting.

There exists a smooth character $\lambda_H:Z_G(F)\ra \C^\times$ such that

\begin{equation}\label{eq:trans-Z-equiv}
\Delta(z\gamma_H,z\gamma) = \lambda_H(z) \Delta(\gamma_H,\gamma),\qquad z\in Z_G(F).
\end{equation}

This is <cit.>. We can describe $\lambda_H$ explicitly on $Z_G^0(F)$ as follows.

When $\cH={}^L H$, the restriction of $\lambda_H$ to $Z_G^0(F)$ corresponds to the composite Langlands parameter

$$W_F \ra {}^L H \stackrel{\eta}{\ra} {}^L G \stackrel{\zeta}{\ra} {}^L Z_G^0,$$

where the first map is the distinguished splitting, and $\zeta$ is dual to the inclusion $Z_G^0\hra G$.

Consider $\gamma_H\in H(F)$, $\gamma\in G(F)$, and maximal tori $T\subset G$ and $T_H\subset H$ as in <cit.>. In particular we are given an isomorphism $i:T\cong T_H$, inducing an isomorphism $^L i: {}^L T_H\cong {}^L T$.
They construct $L$-morphisms $\xi_{T_H}: {}^L T_H \ra {}^L H$ and $\xi: {}^L T \ra {}^L G$ (depending on some additional choices) as well as a 1-cocycle $\mathbf{a}:W_F\ra \hat T_H$ such that $\eta \xi_{T_H}=\mathbf{a}\cdot \xi_T {}^L i$ as $L$-morphisms from $^L T_H$ to $^L G$. Restricting the equality via the splitting $W_F\ra {}^L T_H$, we obtain

\begin{equation}\label{eq:trans-factor-equiv}
\eta(\xi_{T_H}(w)) = \mathbf{a}(w) \xi_T(w) \in {}^L G,\qquad w\in W_F.
\end{equation}

The first paragraph of <cit.> tells us that $\lambda_H|_{Z_G^0(F)}$ corresponds to $\mathbf{a}$ composed with $\hat T_H \cong\hat T \rightarrow \hat Z_G^0$, which is dual to $Z_G^0\subset T \cong T_H$. To prove the lemma, it is thus enough to verify that the composite map in the lemma is $w\mapsto \zeta(\mathbf{a}(w))\rtimes w$.

To this end, write $\xi_{T_H}(w)=b(w)\rtimes w$ and $\xi_T(w)=c(w)\rtimes w$. From the construction of $\xi_T$ in <cit.>, it follows that $\zeta(c(w))=1$.  Indeed, the two main points are that the image of every morphism $\SL_2\ra \hat G$ maps trivially in $\hat Z_G^0$ (thus also $n(\omega_T(\sigma))$ therein) and that the coroots of $\hat G$ map trivially in $\hat Z_G^0$ (thus also $r_p(w)$ therein). Similarly, $b(w)$ maps to $1\in \hat Z_H^0$, so  $\zeta(b(w))=1$. Now we apply $\zeta$ to (<ref>) to see that
$\zeta(\eta(w))=\zeta(\mathbf{a}(w))\rtimes w$, as desired.

We introduce transfer factors in general by reducing to the case $G_{\der}=G_{\textup{sc}}$, in which case we can always assume that $\cH={}^L H$, cf. <ref> and <ref>.
Let $\fke=(H,\cH,s,\eta)\in E(G)$. Take a $z$-extension $1\ra Z_1\ra G_1\ra G\ra 1$ and define $\fke_1=(H_1,{}^L H_1,s_1,\eta_1)\in E(G_1)$ as in <ref>.
Then we have $\Delta(\gamma_{H_1},\gamma_1)\in \C$ defined on $\gamma_{H_1}\in H_1(F)_{(G_1,H_1)\text{-} \reg}$ and $\gamma_1\in G_1(F)_{\semi}$. Langlands–Shelstad define

$$\Delta(\cdot,\cdot): H_1(F)_{(G_1,H_1)\text{-} \reg}\times G(F)_{\semi} \To \C$$

as follows. Set $\Delta(\gamma_{H_1},\gamma)=0$ unless $\gamma$ is an image of $\gamma_{H_1}$ (<ref>), that is, unless $\gamma$ lifts to $\gamma_1\in G_1(F)$ which is an image of $\gamma_{H_1}$, in which case $\Delta(\gamma_{H_1},\gamma):=\Delta(\gamma_{H_1},\gamma_1)$. By (<ref>),

$$ \Delta(z\gamma_{H_1},\gamma) = \lambda_{H_1}(z) \Delta(\gamma_{H_1},\gamma),\qquad z\in Z_{G_1}^0(F).$$

Notice that $Z_1\subset Z_{G_1}^0$. Lemma <ref> implies that $\lambda_{H_1}|_{Z_1(F)}=\lambda_1$, where $\lambda_1$ was given in <ref>. (This is also checked in <cit.>.)

Keep on assuming that $F$ is a local field. We state the Langlands–Shelstad transfer and the fundamental lemma for connected reductive groups $G_1$ with $G_{1,\der}=G_{1,\textup{sc}}$. Let $\fke_1=(H_1,{}^L H_1,s_1,\eta_1)\in E(G_1)$.
If $G_1$ and $\fke_1$ are unramified, then $\eta_1$ induces a $\C$-algebra map via the Satake transform:

\begin{equation}\label{eq:eta1}
\eta_1^*: \cH^{\ur}(G_1)\To \cH^{\ur}(H_1).
\end{equation}

For each $f_1\in \cH(G_1)$, there exists $f_1^{H_1}\in \cH(H_1)$ enjoying the following property: If $\gamma_{H_1}\in H_1(F)_{(G_1,H_1)\text{-} \reg}$ has no image in $G_1(F)_{\semi}$ then $SO_{\gamma_{H_1}}(f_1^{H_1})=0$. If $\gamma_{H_1}$ has an image $\gamma_1\in G(F)_{\semi}$ then

\begin{equation}\label{eq:FL}
SO_{\gamma_{H_1}}(f^{H_1}_1) =
\sum_{[x]\in \fkD(I_{\gamma_1},G_1;F)} e(I_{\gamma_{1,[x]}}) \Delta(\gamma_{H_1},\gamma_{1,[x]}) O_{\gamma_{1,[x]}}(f_1) .
\end{equation}

Moreover, the fundamental lemma (FL) holds true, i.e., if $G_1$ and $\fke_1$ are unramified and if $f_1\in \cH^{\ur}(G_1)$ then the above holds with $f^{H_1}_1=\eta_1^* f_1$.

The second assertion (FL) follows from work of Ngô as well as Cluckers-Loeser, Hales, and Waldspurger  [19, 40, 111, 144]. The first assertion (the transfer conjecture) is implied by FL [143].

Let us adapt Proposition <ref> to the setting with fixed central characters.
Let $\fkX$ be a closed subgroup of $Z(F)$ and $\chi:\fkX\ra \C^\times$ a continuous character. We view $\fkX$ also as a closed subgroup of $Z_H(F)$ via $Z\hra Z_H$. Denote by $\fkX_{H_1}$ and $\fkX_1$ the preimages of $\fkX$ under $H_1(F)\rightarrow H(F)$ and $G_1(F)\rightarrow G(F)$, respectively, so that $\fkX_{H_1}\cong \fkX_1$ canonically. Choose compatible Haar measures on $\fkX_{H_1}$ and $\fkX_1$. Let $\chi_1$ denote the character of $\fkX_{H_1}$ or $\fkX_{1}$ pulled back from $\chi:\fkX\ra \C^\times$.
Restricting $\lambda_{H_1}$ as in <ref>, we obtain another character

By slight abuse of notation, we will often denote the above still by $\lambda_{H_1}$ (as we will not consider $\lambda_{H_1}$ on a larger domain). In the special case when $\fkX=\{1\}$, notice that $\fkX_1=\fkX_{H_1}=Z_1(F)$, $\chi_1=1$, and $\lambda_{H_1}=\lambda_1$.

If $F$ is non-archimedean, $\chi:\fkX\ra \C^\times$ is said to be unramified if the character is trivial on the maximal compact subgroup of $\fkX$. The same definition works with $\fkX_{H_1}$ in place of $\fkX$. When $G$, $\fke$, $\chi$, and the $z$-extension $G_1$ are unramified, we have $G_1$ and $\fke_1$ also unramified. In this case, the map $\eta_1^*:\cH^{\ur}(G_1)\ra \cH^{\ur}(H_1)$ from (<ref>) is averaged to give a map

\begin{equation}\label{eq:eta1-variant}
\cH^{\ur}(G,\chi^{-1})\To \cH^{\ur}(H_1,\chi_1^{-1}\lambda_{H_1})
\end{equation}

as follows. Let $f_1\in \cH^{\ur}(G_1)$ be any lift of $f$ along the natural surjective map, where the first arrow is averaging against $\chi_1$:

$$\cH^{\ur}(G_1)\rightarrow\cH^{\ur}(G_1,\chi_1^{-1}) \cong \cH^{\ur}(G,\chi^{-1}).$$

For $z\in \fkX_{H_1}$, write $f_{1,z}(h):=f_1(zh)$.
Define a function $f^{H_1}$ on $H_1(F)$ by
$$f^{H_1}(h):=\int_{\fkX_{H_1}} \chi_{1}(z)\eta_1^*f _{1,z}(h) dz=\int_{\fkX_{H_1}} \chi_1(z)\lambda^{-1}_{H_1}(z) \eta_1^*f _{1}(zh) dz.$$

Then $f^{H_1}$ belongs to  $\cH^{\ur}(H_1,\chi_1^{-1}\lambda_{H_1})$ and is independent of the choice of $f_1$. The resulting map (<ref>) is again denoted by $\eta_1^*$ as there is little danger of confusion.

For each $\chi:\fkX\ra \C^\times$ and $f\in \cH(G,\chi^{-1})$, there exists

$$f^{H_1}\in \cH(H_1,\chi_1^{-1}\lambda_{H_1})$$

such that for every $\gamma_{H_1}\in H_1(F)_{(G_1,H_1)\text{-} \reg}$, if $\gamma\in G(F)_{\semi}$ is an image of $\gamma_{H_1}$ then

$$ SO^{H_1(F)}_{\gamma_{H_1}}(f^{H_1})=\sum_{[x]\in \fkD(I_\gamma,G;F)} e(I_{\gamma_{[x]}}) \Delta(\gamma_{H_1},\gamma_{[x]}) O^{G(F)}_{\gamma_{[x]}}(f).$$

If $\gamma_{H_1}$ admits no image in $G(F)$ then $ SO^{H_1(F)}_{\gamma_{H_1}}(f^{H_1})=0$.

Moreover when $F$ is non-archimedean, if $G_1$, $\fke$, and $\chi$ are unramified, and if $f\in \cH^{\ur}(G,\chi^{-1})$, then $\chi_1,\lambda_{H_1}|_{\fkX_{H_1}}$ are unramified and the above holds true with

Given $f\in \cH(G,\chi^{-1})$, choose a lifting $f_1\in\cH(G_1)$ under the surjective composite map
$\cH(G_1) \rightarrow \cH(G_1,\chi_1^{-1})=\cH(G,\chi^{-1})$.
Let $ f_1^{H_1}\in \cH(H_1)$ be a transfer of $f_1$ as in Proposition <ref>. 	 Define $f^{H_1}\in \cH(H_1,\chi_1^{-1}\lambda_{H_1})$ by

$$f^{H_1}(\gamma_{H_1}):=\frac{1}{\vol(\fkX_{H_1})} \int_{\fkX_{H_1}} f^{H_1}_1 (z\gamma_{H_1}) \chi_1(z)\lambda_{H_1}^{-1}(z)dz,\quad \gamma_{H_1}\in H_1(F),$$

so that for $\gamma_{H_1}\in H_1(F)_{\semi}$,

\begin{equation}\label{eq:SO-average}
SO_{\gamma_{H_1}}(f^{H_1})=\frac{1}{\vol(\fkX_{H_1})} \int_{\fkX_{H_1}} \chi_1(z)\lambda_{H_1}^{-1}(z) SO_{z_1\gamma_{H_1}}( f^{H_1}_1 ) dz.
\end{equation}

If $\gamma_{H_1}$ has no image in $G(F)$ then it has no image in $G_1(F)$ either, so $SO_{\gamma_{H_1}}(f^{H_1})$ vanishes.
Otherwise, let $\gamma_1\in G_1(F)$ be an image of  $\gamma_{H_1}$. Then $z\gamma_1$ is an image of $z\gamma_{H_1}$ for each $z\in \fkX_{H_1}$. Applying Proposition <ref> to (<ref>), we see that $SO_{\gamma_{H_1}}(f^{H_1})$ equals

$$\int_{\fkX_{H_1}} \frac{\chi_1(z)}{\vol(\fkX_{H_1})} \sum_{[x]\in \fkD(I_{\gamma_1},G_1;F)} e(I_{\gamma_{1,[x]}}) \frac{\Delta(z\gamma_{H_1},z\gamma_{1,[x]})}{\lambda_{H_1}(z)} O_{z\gamma_{1,[x]}}(f_1) dz,$$

Lemma <ref> gives a bijection $\fkD(I_{z\gamma_{1}},G_1;F)=\fkD(I_{\gamma_{1}},G_1;F)\cong \fkD(I_{\gamma},G;F)$.
(We view $[x]$ also as an element of $\fkD(I_{z\gamma_{1}},G_1;F)$ or $\fkD(I_{\gamma},G;F)$.)
By definition and (<ref>), we have
$$\Delta(z\gamma_{H_1},z\gamma_{1,[x]})=\Delta(z\gamma_{H_1},\gamma_{[x]})= \lambda_{H_1}(z) \Delta(\gamma_{H_1},\gamma_{[x]}),\qquad z\in \fkX_{H_1}.$$

By <cit.> $e(I_{\gamma_{1,[x]}})=e(I_{\gamma_{[x]}})$. All in all, as the sums run over $[x]\in \fkD(I_\gamma,G;F)$ below,

\begin{eqnarray}
SO_{\gamma_{H_1}}(f^{H_1})	&=& \sum_{[x]} e(I_{\gamma_{[x]}}) \Delta(\gamma_{H_1},\gamma_{[x]})
\left(\frac{1}{\vol(\fkX_{1})}\int_{\fkX_1} \chi_1(z)O_{z\gamma_{1,[x]}}(f_1)dz\right) \nonumber
\\ &=& \sum_{[x]} e(I_{\gamma_{[x]}}) \Delta(\gamma_{H_1},\gamma_{[x]}) O_{\gamma_{[x]}}(f). \nonumber
\end{eqnarray}

It remains to prove the last assertion when $G$, $\fke_1$, and $\chi$ are unramified. Let $z$ be an element in the maximal compact subgroup of $\fkX_{H_1}$. In the notation above, if $f_1$ is replaced with a translate $f_{1,z}$ then $f^{H_1}$ is multiplied by $\lambda_{H_1}(z)$ according to <ref>. On the other hand, $f_1$ is unchanged if translated by $z$ since $f_1$ is in the unramified Hecke algebra. Combining the two facts, we see that the stable orbital integrals of $f^{H_1}$ do not change values under multiplication by $\lambda_{H_1}(z)$. Therefore $\lambda_{H_1}$ is unramified. The fact that we can take $f^{H_1}=\eta_1^*(f)$ follows from the earlier part of the current proof, where we can pick $f_1\in \cH^{\ur}(G_1)$ and choose $f_1^{H_1}$ to be the image of $f_1$ under (<ref>).

Here we work out a small generalization of some results in local twisted endoscopy by Morel and Kottwitz <cit.> to the setting where $\cH$ in the endoscopic datum cannot be taken to be an $L$-group.
We put ourselves in the setting of <ref> with $F=\Q_p$.
Let $\fke=(H,\cH,s,\eta)\in E(G)$, which gives rise to $\fke_1=(H_1,{}^L H_1,s_1,\eta_1)\in E(G_1)$ as in Lemma <ref>. We make an additional hypothesis that

$$s\in Z(\hat H)^{\Gamma_p}.$$

The group $G$ is assumed quasi-split over $\Q_p$ so that <cit.> applies.
If $G$ and $H$ are unramified (which we are not assuming) then we may and will choose $G_1$ and $H_1$ to be also unramified.

In twisted endoscopy, the norm map is defined by Kottwitz and Shelstad [71] for strongly regular elements and by Labesse [76] for elliptic elements (which may not be strongly regular). The norm map in untwisted endoscopy is simply the transfer of conjugacy classes as in <ref>. In the special case of base change, Kottwitz [58] defines the norm map for general elements. (These norm maps  coincide when there are more than one definitions available in a given setting.) For our purpose, we define the norm map from $R_1(\Q_p)$ to $H_1(\Q_p)$ to be the degree $n$ base change norm from $R_1(\Q_p)$ to $G_1(\Q_p)$ followed by the transfer of semi-simple conjugacy classes (<ref>) from $G_1(\Q_p)$ to $H_1(\Q_p)$. It is an exercise to check that this is consistent with the norm map by Kottwitz–Shelstad and Labesse.

Let $\delta_1\in  G_1(\Q_{p^n})=R_1(\Q_p)$. It has a degree $n$ norm $\gamma_{0,1}\in G_1(\Q_p)$. We assume $\gamma_{0,1}$ to be semi-simple. Then $\delta_1$ corresponds to $[b_1]\in \fkD_n(\gamma_{0,1},G_1;\Q_p)$ according to Corollary <ref>. So we write $\delta_{[b_1]}$ for $\delta_1=\delta_{[b_1]}$. Recall $\beta_p(\gamma_{0,1},[b_1])=\kappa_{I_{0,1}}([b_1])$.
Suppose that $\gamma_{H_1}\in H_1(\Q_p)_{\semi}$ is a norm of $\delta_1$. Then $\gamma_{0,1}$ is an image of $\gamma_{H_1}$.

When $\gamma_{H_1}$ is strongly $G_1$-regular (equivalently when $\gamma_{0,1}$ is strongly regular), Kottwitz <cit.> proved that

\begin{equation}\label{e:tw-trans-fac-at-p}
\Delta_0(\gamma_{H_1},\delta_{[b_1]})=\Delta_0(\gamma_{H_1},\gamma_{0,1}) \lg \beta_p(\gamma_{0,1},[b_1]),s_1\rg,
\end{equation}

where we have taken the sign correction of <cit.> into account.
To make sense of the pairing, we view $s_1\in Z(\hat H_1)^{\Gamma_p}$ as an element of $Z(\hat I_{0,1})^{\Gamma_p}$ via $Z(\hat H_1)^{\Gamma_p}\subset Z(\hat I_{\gamma_{H_1}})^{\Gamma_p} = Z(\hat I_{0,1})^{\Gamma_p}$, cf. <cit.>.

When $\gamma_{H_1}$ is $(G_1,H_1)$-regular but not strongly $G_1$-regular, we take (<ref>) as the definition of $\Delta_0(\gamma_{H_1},\delta_{[b_1]})$, cf. <cit.>.

Let $\gamma_0\in G(\Q_p)$ and $[b]\in \fkD_n(\gamma_{0},G;\Q_p)$ be the images of $\gamma_{0,1}$ and $[b_1]$, respectively.
Then $[b]$ gives rise to $\delta_{[b]}\in G(\Q_{p^n})$ via Corollary <ref>, and $\gamma_0$ is a degree $n$ norm of $\delta_{[b]}$. If the hypothesis on $Z_1$ in Lemma <ref> is satisfied, and if $[b_1]\in\fkD_n(\gamma_{0,1},G_1;\Q_p)$ and $[b]\in \fkD_n(\gamma_{0},G;\Q_p)$ correspond under the bijection of that lemma, then the $\sigma$-conjugacy class of $\delta_{[b_1]}$ maps to that of $\delta_{[b]}$.
We defined $\beta_p(\gamma_{0},[b])$ to be $\kappa_{I_{0}}([b])$, which equals the image of $\beta_p(\gamma_{0,1},[b_1])$. Thus we have

$$\lg \beta_p(\gamma_{0,1},[b_1]),s_1\rg=\lg \beta_p(\gamma_{0},[b]),s\rg.$$

In case $G_1$ and $\fke$ are unramified, the twisted datum $\tilde\fke_1=(H_1,\cH_1,\tilde s_1, \tilde \eta_1)$ of <ref> is also unramified, and $\tilde\eta_1$
induces $\C$-algebra morphisms

$$\cH^{\ur}(R_1)\ra \cH^{\ur}(H_1)\quad\mbox{and}\quad\cH^{\ur}(R)\ra \cH^{\ur}(H_1,\lambda_{H_1})$$

as in the untwisted case, cf. <ref> and <ref>. By slight abuse of notation we call both maps $\tilde\eta_1^*$.
The following is a twisted analogue of Proposition <ref>.

Let $f\in \cH(R(\Q_p))$. Then there exists $f^{H_1}\in \cH(H_1,\lambda_{H_1})$ such that the following holds:
Let $\gamma_{H_1}\in H_1(\Q_p)_{(G_1,H_1)\textup{-reg}}$. We have $SO_{\gamma_{H_1}}(f^{H_1})=0$ if $\gamma_{H_1}$ is not a norm from $R_1(\Q_p)$. If $\gamma_{H_1}$ is a norm of $\delta_1\in R_1(\Q_p)=G_1(\Q_{p^n})$ then whenever $\gamma_{0}\in G(\Q_p)$ is an image of $\gamma_{H_1}$, we have

\begin{equation}\label{e:tw-orb-id}
SO_{\gamma_{H_1}}(f^{H_1})=\Delta_0(\gamma_{H_1},\gamma_0) \sum_{[b]\in \fkD_n(\gamma_0,G;\Q_p)} e(I_{\delta_{[b]}})  \lg \beta_p(\gamma_{0},[b]),s\rg TO_{\delta_{[b]}}(f).
\end{equation}

Moreover if $G_1$ and $\fke$ are unramified, and if $f\in \cH^{\ur}(R)$ then the above is true for $f^{H_1}=\tilde\eta_1^* (f)\in \cH^{\ur}(H_1,\lambda_{H_1})$.

In the essential case when $G_1$ and $\fke$ are unramified with $f$ in the unramified Hecke algebra, if $\gamma_{H_1}$ is restricted to be a strongly $G_1$-regular element, the proposition is a special case of the twisted fundamental lemma (TFL) for the full unramified Hecke algebra. When the residue characteristic $p$ is large, TFL for the unit element is true thanks to Ngô, Waldspurger, Cluckers-Loeser, and others ([111, 145] with [144] or [19]). For general elements of unramified Hecke algebras, including the case of small $p$, TFL was recently established by Lemaire, Moeglin, and Waldspurger [90] and [97]. Note that TFL states an orbital integral identity only for strongly regular elements; in fact the twisted transfer factors are not defined for other elements in general. However we want an orbital integral identity for $(G_1,H_1)$-regular semi-simple elements which may not be strongly regular. The transfer factors for such elements are available in our setting, and Proposition <ref> is proved for such elements in <cit.>, under the hypotheses that $G_{\der}=G_{\sconn}$ and that $\cH={}^L H$ in the endoscopic datum.
So the point of our proof below is to remove the hypotheses of [108].
The basic idea is to employ $z$-extensions, but there is a technical problem: no single $z$-extension $G_1$ satisfies the assumption of Lemma <ref> for all (sufficiently large) $n$. We choose an auxiliary $z$-extension as in Lemma <ref> to get around the issue.

We present a proof when $G_1$ and $\fke$ are unramified assuming that $f\in \cH^{\ur}(R)$.
The general case will be taken care of in the last paragraph of this proof.

Put $\tilde Z_1:=\Res_{\Q_{p^n}/\Q_p} (Z_1)_{\Q_{p^n}}$. Choose $f_1$ to be any preimage of $f$ under the averaging map $\cH^{\ur}(R_1)\rightarrow \cH^{\ur}(R)$ over $\ker(R_1(\Q_p)\ra R(\Q_p))=\tilde Z_1(\Q_p)$. Suppose that $z\gamma_{H_1}$ is not a norm from $R_1(\Q_p)$ for any $z\in Z_1(\Q_p)$. Then <cit.>  tells us that $SO_{z\gamma_{H_1}}(\tilde\eta_1^*(f_1))=0$. Hence

$$SO_{\gamma_{H_1}}(\tilde\eta_1^*(f))=\int_{Z_1(\Q_p)} \lambda^{-1}_{H_1}(z) SO_{z\gamma_{H_1}}(\tilde\eta_1^*(f_1))dz=0.$$

Now assume the existence of $z\in Z_1(\Q_p)$ such that $\gamma'_{H_1}:=z\gamma_{H_1}$ is a norm of some element $\delta'_1\in R_1(\Q_p)$.
Let $\gamma_{0,1}\in G_1(\Q_p)$ be an image of $\gamma'_{H_1}$. (Such a $\gamma_{0,1}$ exists since $G_1$ is quasi-split and has simply connected derived subgroup, cf. <cit.>.) Write $\gamma_H\in H(\Q_p)$ and $\gamma_0\in G(\Q_p)$ for the respective images of $\gamma_{H_1}$ and $\gamma_{0,1}$. Take central extensions $G'_1$ and $H'_1$ as in Lemma <ref> and write $Z'_1$ for the common kernel of the surjections $G'_1\rightarrow G$ and $H'_1\rightarrow H$. Thus $Z'_1\cong \prod_{i=1}^r \Res_{F_i/\Q_p}\GG_m$ for $r\in \Z_{\ge 1}$ and $F_i\supset \Q_{p^n}$.
$$\tilde Z'_1:=\Res_{\Q_{p^n}/\Q_p}(Z'_1)_{\Q_{p^n}}\cong \prod_{i=1}^r \prod_{\Q_{p^n}\hra F_i} \Res_{F_i/\Q_p}\GG_m,$$

where the second product runs over the set of $\Q_p$-embeddings. Fix an embedding $\Q_{p^n}\hra F_i$ for each $i$ and define $Y_{1}$ to be the subtorus of $\tilde Z'_1$ whose components outside the set of fixed embeddings are trivial. The Frobenius automorphism $\sigma\in \Gal(\Q_{p^n}/\Q_p)$ acts on $\tilde Z'_1$ by permuting the $\Q_p$-embeddings.

The norm map $N:\tilde Z'_1(\Q_p)\ra Z'_1(\Q_p)$ is obviously onto and restricts to an isomorphism

$$N:Y_1(\Q_p)\isom Z'_1(\Q_p).$$

From $\fke$, we have $\fke'_1=(H'_1,{}^L H'_1,s'_1,\eta'_1)\in E(G_1)$ as in Lemma <ref>. Since $s\in Z(\hat H)^\Gamma$ we have that $s'_1\in Z(\hat H'_1)^\Gamma$. One builds a twisted endoscopic datum $\tilde\fke'_1$ for $(R'_1,\theta'_1)$ as in <ref> and <ref>.

Choose $f'_1\in \cH^{\ur}(R'_1)$ to be a preimage of $f$ under the averaging surjection $ \cH^{\ur}(R'_1)\rightarrow \cH^{\ur}(R)$.
We have

$$(\tilde\eta'_1)^*(f'_1)\in \cH^{\ur}(H'_1),\qquad f^{H'_1}:=(\tilde\eta'_1)^*(f)\in \cH^{\ur}(H'_1,\lambda_{H'_1}).$$

The inclusion $H_1\hra H'_1$ induces an isomorphism $\cH^{\ur}(H_1,\lambda_{H_1})\cong \cH^{\ur}(H'_1,\lambda_{H'_1})$
since the character $\lambda_{H'_1}$ restricts to $\lambda_{H_1}$.
The functions $f^{H'_1}$ and $f^{H_1}$ correspond under the isomorphism. Clearly

$$SO_{\gamma'_{H_1}}(f^{H'_1})= SO_{\gamma'_{H_1}}(f^{H_1})=SO_{\gamma_{H_1}}(f^{H_1}).$$

By <cit.>,

\begin{equation}\label{eq:Mor10-951-A314}
SO_{\gamma'_{H_1}}((\tilde\eta'_1)^*(f'_1))=\sum_{\delta'_1} e(I_{\delta'_1}) \Delta_0(\gamma'_{H_1},\delta'_1) TO_{\delta'_1}(f'_1),
\end{equation}

where the sum runs over a set of representatives for the $\sigma$-conjugacy classes in $G'_1(\Q_{p^n})=R'_1(\Q_p)$ whose norm is $\gamma_{0,1}$. (Here we view $\gamma'_{H_1}$ and $\gamma_{0,1}$ as elements of $H'_1(\Q_p)$ and $G'_1(\Q_p)$ via $H_1\subset H'_1$ and $G_1\subset G'_1$.) Let $\delta\in R(\Q_p)$ denote the image of $\delta'_1$, and $y\in \tilde Z'_1(\Q_p)$ an arbitrary element. We collect the following facts.

* the set of representatives $\delta'_1$ in the sum is in bijection with $\fkD_n(\gamma_{0,1},G'_1;\Q_p)$, and also with $\fkD_n(\gamma_0,G;\Q_p)$ (Lemma <ref> and Corollary <ref>),

* $e(I_{y\delta'_1})=e(I_\delta)$ by <cit.>,

* $N(y)\gamma_{0,1}$ (resp. $N(y)\gamma'_{H_1}$) is a norm of $y\delta'_1$ in $G'_1$ (resp. $H'_1$),

* (<ref>) holds with $N(y)\gamma_{0,1}$ and $N(y)\gamma'_{H_1}$ in place of $\gamma_{0,1}$ and $\gamma'_{H_1}$,

* $\Delta_0(N(y)\gamma'_{H_1},y\delta'_1)=\lambda_{H'_1}(N(y))\Delta_0(\gamma'_{H_1},\delta'_1)$ by <cit.>,[Unlike the formula in loc. cit., we do not put an inverse over $\lambda_{H'_1}$ since we are following the convention for $\Delta'$ in [72], which inverts $\Delta_{III}$ in [71].]

* $\Delta_0(\gamma'_{H_1},\gamma_{0,1})$ remains the same whether it is viewed with respect to the transfer between $H'_1$ and $G'_1$ or between $H_1$ and $G_1$.[To see this, one reduces to the strongly regular case by <cit.> and <cit.>. The same $a$-data and $\chi$-data may be chosen in the two cases to compare transfer factors, as the centralizer of $\gamma_{0,1}$ determines the same root system in $G_1$ and $G'_1$ respectively. Then one sees that each of $\Delta_{I}$, $\Delta_{II}$, $\Delta_{III_1}$, $\Delta_{III_2}$, and $\Delta_{IV}$ is the same by inspecting the definition in <cit.>.]

Putting all this together, we deduce that $	SO_{\gamma'_{H_1}}(f^{H'_1})$ equals

\begin{eqnarray}
&&\int_{Z'_1(\Q_p)} \lambda^{-1}_{H'_1}(z') SO_{z'\gamma_{H'_1}}((\tilde\eta'_1)^*(f'_1))dz'\nonumber\\
&=&\int_{Y_1(\Q_p)}\lambda^{-1}_{H'_1}(y) \sum_{\delta'_1} e(I_{y\delta'_1}) \Delta_0(N(y)\gamma'_{H_1},y\delta'_1) TO_{y\delta'_1}(f'_1)dy.\nonumber\\
&=&\sum_{\delta'_1} e(I_{\delta'_1}) \Delta_0(\gamma'_{H_1},\delta'_1) \int_{Y_1(\Q_p)}TO_{y\delta'_1}(f'_1)dy.\nonumber\\
&=&\sum_{[b'_1]\in \fkD_n(\gamma_{0,1},G'_1;\Q_p)} e(I_{\delta_{[b'_1]}}) \Delta_0(\gamma'_{H_1},\gamma_{0,1}) \lg \beta_p(\gamma_{0,1},[b'_1]),s'_1\rg TO_{\delta_{[b]}}(f).\nonumber\\
&=&\sum_{[b]\in \fkD_n(\gamma_0,G;\Q_p)} e(I_{\delta_{[b]}})\Delta_0(\gamma_{H_1},\gamma_{0}) \lg \beta_p(\gamma_{0},[b]),s\rg  TO_{\delta_{[b]}}(f).\nonumber
\end{eqnarray}

This finishes the proof in the unramified case.

The general case (when either $G_1$ or $\fke$ is ramified) works in the same way. If $z\gamma_{H_1}$ is not a norm from $R_1(\Q_p)$ for any $z\in Z_1(\Q_p)$ then $SO_{\gamma_{H_1}}(f^{H_1})=0$ as before. Otherwise we assume that $\gamma'_{H,1}:=z\gamma_{H,1}$ is a norm for some $z$. Then we repeat the preceding argument, with the difference occurring in the choice of $f^{H'_1}$. Namely by <cit.>, there exists $f^{H'_1}\in \cH(H'_1(\Q_p))$ such that (<ref>) holds true with $f^{H'_1}$ in place of $(\tilde\eta'_1)^*(f'_1)$, and such that $SO_{\gamma'_{H_1}}(f^{H'_1})=0$ if $\gamma$ is not a norm. Setting $f^{H'_1}(h'):=\int_{Z_{H'_1}(\Q_p)} \lambda^{-1}_{H'_1}(z') f^{H'_1}(z'h') dz'$, we see from the above computation that Proposition <ref> holds. The proof is complete.

The last part of Proposition <ref> can be slightly generalized, following <cit.>. Assume that $H$ and $G$ are unramified, thus choose $H_1$ and $G_1$ to be unramified, but allow $\fke_1$ to be ramified. In that case, one can write $\eta_1=c \cdot \eta^\circ_1$ with a continuous 1-cocycle $c:W_{\Q_p}\ra Z(\hat H_1)$ such that $(H_1,\cH_1,s_1,\eta^\circ_1)$ is unramified.  (To see this, apply <cit.> for an unramified extension to find $\eta^\circ_1$, and observe that $\eta_1$ and $\eta^\circ_1$ must differ by a continuous 1-cocycle valued in $Z(\hat H_1)$.) Via local class field theory, $c$ determines a smooth character $\chi_c:H_1(\Q_p)\ra \C^\times$. Writing $f^{H_1,\circ}:=\tilde\eta^{\circ,*}_1(f)$, we see that $f^{H_1}:=\chi_c \cdot f^{H_1,\circ}$ satisfies the desired condition of Proposition <ref>. This follows from the fact that $\Delta_0(\gamma_{H_1},\gamma_{0,1})$ gets multiplied by $\chi_c(\gamma_{H,1})$ when changing from $\eta^\circ_1$ to $\eta_1$. (This factor comes from $\Delta_2$ in <cit.> as the 1-cocycle $a$ there is replaced with $ac$.)

In the setting of Proposition <ref>, assume that $G$ is unramified over $\Q_p$ and $f\in \cH^{\ur}(R(\Q_p))$. If $H$ is ramified over $\Q_p$ then we can take $f^{H_1}=0$ (i.e., the right hand side of (<ref>) always vanishes).

The untwisted analogue of this proposition is proven in <cit.>. We adapt this proof, referred to as “loc. cit.” below, to our twisted setting. (A proof in the twisted case is alluded to on p. 189 of [65]. We are elaborating on the details.) We write $G'$ for the group $G_1$ in loc. cit., as we reserve the symbol $G_1$ to stand for a $z$-extension.
Via $z$-extensions we reduce to the case where $G_{\der}=G_{\sconn}$ and $\cH={}^L H$. Recall we are also assuming $s\in Z(\hat H)^{\Gamma_p}$.

Fix $[b]\in \fkD_n(\gamma_0,G;\Q_p)$ and a representative $b\in G(\LL)$ of $[b]$. Fix $c\in G(\LL)$ as in  condition KP1 of Definition <ref> so that
$c^{-1}\gamma_0 c = \delta \sigma(\delta) \cdots {\sigma^{n-1}} ( \delta) $
with $\delta=c^{-1} b\sigma (c) \in G(\Q_{p^n})$ (which is also denoted $\delta_{[b]}$). As in the proof of Lemma <ref>, the following sets are in natural bijections with each other:

* the set of $\sigma$-conjugacy classes in the stable $\sigma$-conjugacy class of $\delta$,

* $\ker(H^1(\Q_p,I_\delta)\ra H^1(\Q_p,R))$, and

* $\fkD_n(\gamma_0,G;\Q_p)$.

To go from (i) to (ii), let $\delta' = x \delta \theta(x)^{-1}$ with $x\in R(\Qpbar)$, where $\theta$ denotes the automorphism of $R$ induced by $\sigma\in \Gal(\Q_{p^n}/\Q_p)$. Sending $ \delta'$ to the cocycle $z_{\delta,\delta'}:\tau\mapsto x^{-1} \lix{^\tau} x$ induces the bijection from (i) onto (ii). To go from (i) to (iii), take
$c'\in G(\LL)$ such that
$(c')^{-1}\gamma_0 c' = \delta' \sigma(\delta') \cdots {\sigma^{n-1}} ( \delta') $.
Then we send $\delta'$ to $[c' \delta' \sigma(c')^{-1}]\in B(I_0)$, which lies in the set (iii).
Moreover we have the following compatibility: it follows from the bottom commutative diagram in <cit.> (with $I_\delta$ and $I_0$ in place of $J^h$ and $H$ there, and the cocycle $h$ determined by $\sigma\mapsto c\delta \sigma(c)^{-1}$) that the image of $z_{\delta,\delta'}$ under the composite map

$$H^1(\Q_p,I_\delta) \cong \pi_1(I_\delta)_{\Gamma_p,\tors}\cong \pi_1(I_0)_{\Gamma_p,\tors}\hra  \pi_1(I_0)_{\Gamma_p}$$

coincides with the image of $[b']-[b]$ under the composite map

$$\fkD_n(\gamma_0,G;\Q_p)\hra \B(I_0) \xrightarrow{\kappa_{I_0}} \pi_1(I_0)_{\Gamma_p}.$$

Write $\textup{inv}(\delta,\delta')$ for the image in $\pi_1(I_0)_{\Gamma_p}$.
With the preparation so far, we follow loc. cit. to construct an exact sequence of unramified reductive groups over $\Q_p$

$$1 \ra G \ra G' \ra C \ra 1,$$

where $C$ is a non-trivial unramified torus. Define $R':=\Res_{\Q_{p^n}/\Q_p} G'$. Via the dual map $\hat G'\ra \hat G$, we can pull-back $\eta: \hat H \ra \hat G$ to define $\hat H'$ equipped with an embedding $\hat H' \hookrightarrow \hat G'$. We equip $\hat H'$ with a $\Gamma_p$-action as in loc. cit.

Write $I'_{\delta}$ for the connected $\sigma$-centralizer of $\delta$ in $R'$. As in loc. cit. we have an exact sequence
$1\ra I_\delta \ra I'_\delta \ra C \ra 1$, whose dual exact sequence fits in the following commutative diagram, where rows are $\Gamma_p$-equivariant and exact:

1 \ar[r] & \hat C \ar@{=}[d]  \ar[r] & Z(\hat H') \ar[d] \ar[r] & Z(\hat H) \ar[r] \ar[d] & 1\\
1 \ar[r] & \hat C  \ar[r] & Z(\hat I'_\delta) \ar[r] & Z(\hat I_\delta) \ar[r] & 1

We have $s\in Z(\hat H)^{\Gamma_p}\subset Z(\hat I_{\delta})^{\Gamma_p}$. Write $\chi_s$ for the image of $s$ in $H^1(\Q_p,\hat C)$ under the connecting homomorphism arising from the first row. Then $\chi_s$ determines a smooth character $C(\Q_p)\ra \C^\times$, still denoted by $\chi_s$. As in the proof of <cit.>, the character $\chi_s$ is ramified, i.e., non-trivial on $C(\Z_p)$. (As $C$ is unramified, it extends uniquely to a $\Z_p$-torus.) This is crucial for our proof.

Now consider $g_1\in G'(\Q_p)$ and put $ \delta' := g_1 \delta  \theta( g_1)^{-1}=g_1 \delta g_1^{-1}\in G(\Q_{p^n})$. We claim that $\delta'$ is stably $\sigma$-conjugate to $\delta$. Indeed, writing $c_1\in C(\Q_p)$ for the image of $g_1$, take a lift $g_2\in I'_{\delta}(\LL)$ of $c_1^{-1}$ via the surjection $I'_{\delta}\ra C$. Set $g:=g_1 g_2 \in R(\LL)$. Then we have $\delta'= g \delta  \theta( g)^{-1}$, which proves the claim.

Let $[b']$ denote the image of $\delta'$ under the bijection from (i) to (iii) above.
Then we assert that

$$\langle \beta_p(\gamma_{0},[b']),s\rangle \langle \beta_p(\gamma_{0},[b]),s\rangle ^{-1}
= \langle \textup{inv}(\delta,\delta'),s\rangle= \chi_s(c_1^{-1}).$$

The first equality follows from the aforementioned compatibility. The second equality
comes from <cit.> (applied to $I=C$ and $G=I_\delta$),
where the image of $c_1^{-1}$ in $H^1(\Q_p,I_\delta)$ is represented by the cocycle $z_{\delta,\delta'}$. Indeed, after applying the injection from $H^1(\Q_p,I_\delta)$ into $B(I_\delta)=H^1(W_{\Q_p},I_\delta(\ol{\breve{\Q_p}}))$, they are represented by the same cocycle since $ g_2^{-1} {}^\tau g_{2}=g^{-1} {}^\tau g$ for $\tau\in W_{\Q_p}$.

For $f\in \cH^{\ur}(G(\Q_p))$, define $f_0\in \cH^{\ur}(G(\Q_p))$ by $f(g_1 x g_1^{-1})$ with $g_1$ as above. (The analogue of $f_0$ is denoted by $f_1$ in loc. cit.)
Write $f^H$ and $f_0^H$ for their twisted transfers to $H$. On the one hand, we have $f=f_0$ by the argument of loc. cit., so we can take $f^H=f_0^H$. On the other hand, comparing the right hand sides of (<ref>), we have

SO_{\gamma_H}(f_0^H) = \langle \beta_p(\gamma_{0},[b']),s\rangle \langle \beta_p(\gamma_{0},[b]),s\rangle ^{-1} SO_{\gamma_H}(f^H)= \chi_s(c_1^{-1})SO_{\gamma_H}(f^H)

if $\gamma_H$ is a norm of some $\delta$ as above, and $SO_{\gamma_H}(f^H)=0$ if $\gamma_H$ is not a norm of any such $\delta$. In order to verify that the stable orbital integral of $f^H$ is identically zero, it is thus enough to exhibit a suitable $c_1$ such that $\chi_s(c_1^{-1})\neq 1$.

To this end, let  $T$ be a maximally split maximal $\Q_p$-torus in $G$, and take $T'$ to be the centralizer of $T$ in $G'$. The resulting exact sequence of unramified tori

$$1 \ra T \ra T' \ra C \ra 1$$

extends uniquely to an exact sequence of tori over $\Z_p$, with $1\ra T(\Z_p)\ra T'(\Z_p)\ra C(\Z_p)\ra 1$ exact.
Fix any $c_1\in C(\Z_p)$ such that $\chi_s(c_1)\neq 1$ and choose $g_1\in T'(\Z_p)$ to be a lift of $c_1$.
Running through the above argument, we conclude that the stable orbital integral of $f^H$ vanishes everywhere.

Finally we drop the assumption that $s\in Z(\hat H)^{\Gamma_p}$ and consider the general case where $s\in Z(\hat H)^{\Gamma_p}Z(\hat G)$.
Write $s=s's''$ with $s'\in Z(\hat H)^{\Gamma_p}$ and $s''\in Z(\hat G)$. As in <ref>, $(H,\cH,s',\eta)\in E(G)$ yields a twisted endoscopic datum $(H_1,{}^L H_1,\tilde s'_1,\tilde \eta'_1)$ for $(R,\theta)$, with $s'$ playing the role of $s$.

Consider the setting of  <ref>, where $\phi_n\in \cH^{\ur}(R(\Q_{p}))$ was introduced. If $\fke_1$ is unramified, then take $f_n^{H_1}:=\mu^{-1}(s'')\tilde\eta_1^{\prime,*} (\phi_n)$. If $H$ is unramified but $\fke_1$ is ramified, then we take $f_n^{H_1}$ as in <ref>. If $H$ (thus also $H_1$) is ramified over $\Q_p$ then take $f_n^{H_1}:=0$. We check that Proposition <ref> extends to this case.

Let $\gamma_{H_1}\in H_1(\Q_p)_{(G_1,H_1)\textup{-reg}}$. We have $SO_{\gamma_{H_1}}(f_n^{H_1})=0$ if $\gamma_{H_1}$ is not a norm from $R_1(\Q_p)$. If $\gamma_{H_1}$ is a norm of $\delta_1\in R_1(\Q_p)$ then denoting by $\gamma_{0}\in G(\Q_p)$ an image of $\gamma_{H_1}$, we have

SO_{\gamma_{H_1}}(f_n^{H_1})=\sum_{[b]\in \fkD_n(\gamma_0,G;\Q_p)} e(I_{\delta_{[b]}}) \Delta_0(\gamma_{H_1},\gamma_{0}) \lg \tilde \beta_p(\gamma_{0},[b]),s\rg TO_{\delta_{[b]}}(\phi_n),

where the summand is understood to be zero if $TO_{\delta_{[b]}}(\phi_n)=0$.
If $TO_{\delta_{[b]}}(\phi_n)\neq~0$ then $[b]$ satisfies KP0 and KP1 in Definition <ref> so $\tilde \beta_p(\gamma_{0},[b])$ is well defined as explained in <ref>.

By definition $[b]\in \fkD_n(\gamma_0,G;\Q_p)$ always satisfies KP1. Let $\mu \in \dmu_X^{\cG}$ as in <ref>.
If $TO_{\delta_{[b]}}(\phi_n)\neq 0$ for some $[b]\in \fkD_n(\gamma_0,G;\Q_p)$ then $X_{-\mu}(\delta_{[b]})$ is non-empty by  definition (<ref>), so $[\delta_{[b]}]\in \B(G,-\mu)$ by [119]. Since $[b]=[\delta_{[b]}]$ in $\B(G)$, we see that KP0 holds true.

$$ \lg \tilde \beta_p(\gamma_{0},[b]),s\rg =\mu^{-1}(s'')  \lg \tilde \beta_p(\gamma_{0},[b]),s'\rg = \mu^{-1}(s'')  \lg  \beta_p(\gamma_{0},[b]),s'\rg.$$

(The second equality holds because $s'\in Z(\hat H)^{\Gamma_p}\subset Z(\hat I_0)^{\Gamma_p}$ and $\beta_p(\gamma_{0},[b])$ is an element of $\pi_1(I_0)_{\Gamma_p}$.)
Now the proof follows from Proposition <ref> with $\phi_n$ and $s'$ in place of $f$ and $s$, respectively, as $\mu^{-1}(s'')\in \C^\times$ cancels out.

§ STABILIZATION

We return to the point counting formula for Shimura varieties. Taking Conjecture <ref> for granted, we carry out the stabilization of the formula (<ref>), with a view towards a representation-theoretic description of the cohomology.

§.§ Initial steps

We start by fixing a central character datum, rewrite the coefficients in (<ref>), and apply a Fourier transform on the finite abelian group $\fkK(I_0/\Q)$.

We freely use the setting of <ref>. Throughout stabilization, we fix an unramified Shimura datum $(G,X,p,\cG)$, which determines $K_p=\cG(\Z_p)$, and an open compact subgroup $K^p\subset G(\A_f^p)$ such that $K=K_pK^p$ is a neat subgroup.

Recall that $Z$ is the center of $G$. We endow $A_{Z,\infty}=A_{G,\infty}$, which is isomorphic to a finite product of copies of $\R^\times_{>0}$, with the standard multiplicative Haar measure.
Fix Haar measures on $Z(\A_f)$ and $Z(\R)$, thereby also on $\fkX:=(Z(\A_f)\cap K)\cdot Z(\R)$ and $\fkX_{\Q}\bs \fkX/ A_{Z,\infty}$, relative to the counting measure on $\fkX_{\Q}$ (which is discrete and compact in $ \fkX/ A_{Z,\infty}$). With respect to the set of places of $\Q$, we have the decomposition $\fkX=\fkX^{p,\infty} \fkX_p \fkX_\infty$.
We put a Haar measure on $Z(\Q)\bs Z(\A)/\fkX$ via the following exact sequence of topological groups

$$1\ra \fkX_{\Q}\bs \fkX/ A_{Z,\infty} \ra Z(\Q)\bs Z(\A)/A_{Z,\infty} \ra Z(\Q)\bs Z(\A)/\fkX \ra 1,$$

where the space in the middle is given the Tamagawa measure.

We promote $\fkX$ to a central character datum $(\fkX,\chi)$ by defining the finite part $\chi^\infty$ to be trivial on $Z(\A_f)\cap K$ and the infinite part $\chi_\infty:=\omega_{\xi}^{-1}$, where $\omega_{\xi}$ is the central character of $\xi$ on $Z(\R)$.

For a connected reductive subgroup $G_0$ of $G$ over $\Q$ containing $Z$ such that $A_{G_0}=A_Z$, we use the quotient measure to define

$$\tau_\fkX(G_0):=\vol(G_0(\Q)\bs G_0(\A)/\fkX)$$

by viewing the double coset space as the quotient of $G_0(\Q)\bs G_0(\A)/A_{G_0,\infty}$ by $\fkX_\Q\bs \fkX/A_{Z,\infty}$, where the former is equipped with the Tamagawa measure and the latter with the measure explained above. For any inner form $G_0'$ of $G_0$ over $\Q$ we make sense of $\tau_\fkX(G_0')$ by transporting the measure. Since the Tamagawa volumes are equal for $G_0$ and $G_0'$ by [64], we have $\tau_\fkX(G_0)=\tau_\fkX(G_0')$.

Once and for all, fix a $z$-extension $G_1$ of $G$ over $\Q$ which is unramified over $\Q_p$. This is possible by Lemma <ref> (recalling that $G$ is unramified over $\Q_p$). Write $\fkX_1\subset Z_{G_1}(\A)$ for the preimage of $\fkX$ under $G_1\rightarrow G$.
Write $\chi_1$ for the pull-back of $\chi$ to $\fkX_1$ (thus the finite part of $\chi_1$ is trivial). Then $(\fkX_1,\chi_1)$ is a central character datum for $G_1$, and $\fkX_1=\fkX_1^{p,\infty} \fkX_{1,p}\fkX_{1,\infty}$ analogously as the decomposition of $\fkX$.
We put the unique Haar measure on $ \fkX_1$, and thus also on $\fkX_{1,\Q} \backslash \fkX_1/A_{G_1,\infty}$ similarly as above, such that

\begin{equation}\label{eq:Haar-measure-on-X1}
\vol(\fkX_{1,\Q} \backslash \fkX_1/A_{G_1,\infty})/\vol(\fkX_{\Q} \backslash \fkX/A_{G,\infty})
\end{equation}

so that

\begin{equation}\label{eq:tauG1=tauG}
\tau_{\fkX_1}(G_1)=\tau_{\fkX}(G).
\end{equation}

Let $\fkc=(\gamma_0,a,[b])\in \KP_{\adm}(p^n)$ for some $n\in\Z_{\ge1}$. Recall from <ref> that $\fkc$ determines an inner form $I_v$ of $I_0$ over $\Q_v$. Note that $I_p$ depends only on $\gamma_0$ and $[b]$ (not on $a$). Since $I_\infty$ is always a compact-mod-center inner form of $I_{0,\R}$ we often write $I_0^{\cpt}$ for $I_\infty$. If the Kottwitz invariant $\alpha(\fkc)$ (defined in <ref>) vanishes, then we have an inner form $I$ of $I_0$ over $\Q$ which localizes to $I_v$ at each $v$ (Proposition <ref>). We defined the constants $c_1(\fkc,K^p,di_p di^p)$ and $c_2(\gamma_0)$ in <ref>.

If $\alpha(\fkc)$ vanishes, then

$$c_1(\fkc,K^p,di_p di^p)c_2(\gamma_0)=\tau_{\fkX}(G)\cdot  |\fkK(I_0/\Q)|\cdot \vol(Z(\R)\bs I_{\infty}(\R))^{-1}.$$

With the choice of measures as above,

\begin{eqnarray}
c_1(\fkc,K^p,di_p di^p)&=&\vol(I(\Q)\bs I(\A)/Z_K I_\infty(\R))\nonumber \\
&=&\frac{\vol(I(\Q)\bs I(\A)/Z_K Z(\R))}{\vol(Z(\R)\bs I_\infty(\R))}=\frac{\tau_{\fkX}(I_0)}{\vol(Z(\R)\bs I_\infty(\R))}.
\nonumber
\end{eqnarray}

On the other hand one deduces as in <cit.> that

$$c_2(\gamma_0)=\tau(I_0)^{-1}\tau(G)|\fkK(I_0/\Q)| = \tau_{\fkX}(I_0)^{-1}\tau_{\fkX}(G)|\fkK(I_0/\Q)|.$$

We conclude by taking product of the two equations.

Let $\fkc=(\gamma_0,a,[b])\in \KP_{\adm}(p^n)$. Define $e(\fkc):=\prod_v e(I_v) \in \{\pm1\}$, the product of  Kottwitz signs over all places. If $\alpha(\fkc)$ vanishes, then $e(\fkc)=1$ since $I_v$'s come from a $\Q$-group $I$. Hence

\begin{equation}\label{e:finite-Fourier}
\sum_{\kappa\in \fkK(I_0/\Q)} e(\fkc)\lg \alpha(\fkc),\kappa\rg=\left\{ \begin{array}{cl}
|\fkK(I_0/\Q)|, & \mbox{if}~\alpha(\fkc)=0,\\
0, & \mbox{otherwise}.\end{array}\right.
\end{equation}

Applying Lemma <ref> and (<ref>) to (<ref>), we have

\begin{equation}\label{e:initial-steps} T(\Phi_{\mathfrak p}^m, f^p dg^p)
= \tau_\fkX(G)\sum_{\gamma_0\in \Sigma_{\fkX,\RR \text{-} \el}(G)}\ol\iota_G(\gamma_0)^{-1}\sum_{\kappa\in \fkK(I_0/\Q)} \sum_{(a,[b])} N(\gamma_0,\kappa,a,[b]),
\end{equation}

where the third sum runs over $\fkD(I_0,G;\A_f^p)\times \fkD_n(\gamma_0,G;\Q_p)$ and

\begin{equation}
N(\gamma_0,\kappa,a,[b])=\lg \alpha(\gamma_0,a,[b]),\kappa\rg e(\gamma_0,a,[b]) \frac{O_{\gamma_{a}}(f^p) TO_{\delta_{[b]}}(\phi_n) \tr \xi(\gamma_0)}{\vol(Z(\R)\bs I_\infty(\R))}.\nonumber
\end{equation}

This is straightforward possibly except for the following point. In (<ref>), every $\fkc = (\gamma_0,a,[b])$ is a $p^n$-admissible Kottwitz parameter. In the formula above, since condition KP0 is not imposed on $[b]\in \fkD_n(\gamma_0,G;\Q_p)$, a priori $(\gamma_0,a,[b])$ may not be a Kottwitz parameter. The necessary observation is that $[b]$ satisfies KP0 as soon as $\delta_{[b]}$ lies in the support of $\phi_n$.

§.§ Local transfer of orbital integrals

Here we prove adelic orbital integral identities for each $\fke=(H,\cH,s,\eta)\in E_{\el}(G)$. The fixed $z$-extension $G_1$ (which is unramified over $\Q_p$) gives rise to a central extension $H_1$ of $H$ via Lemma <ref>. In particular, if $H$ is unramified over $\Q_p$ then so is $H_1$.
As before, $\fkX_{H_1}$ is the preimage of $\fkX\subset Z_G(\A)\subset Z_H(\A)$ under $Z_{H_1}\rightarrow Z_H$.
We have a continuous character $Z^0_{G_1}(\Q)\bs Z^0_{G_1}(\A)\ra \C^\times$ corresponding to the global parameter
$W_{\Q}\ra {}^L H_1 \stackrel{\eta_1}{\ra} {}^L G_1 \ra {}^L Z_{G_1}^0$ as in Lemma <ref>. Restricting to $\fkX_1$, we obtain a character

\begin{equation}\label{eq:lambdaH1}
\lambda_{H_1}:\fkX_{1,\Q}\backslash \fkX_{1}\To  \C^\times,
\end{equation}

which can be viewed as a character of $\fkX_{H_1}$ via $\fkX_1\cong \fkX_{H_1}$. According as $\fkX_1=\fkX_1^{p,\infty}\fkX_{1,p}\fkX_{1,\infty}$ we decompose $\lambda_{H_1}=\lambda_{H_1}^{p,\infty}\lambda_{H_1,p}\lambda_{H_1,\infty}$. With the Haar measure on $\fkX_1$ transferred to $\fkX_{H_1}$ via the isomorphism, the analogue of (<ref>) holds.

We have $\tau_{\fkX_{H_1}}(H_1) = \tau_{\fkX}(H)$.

Once we prove that $\tau(G_1)/\tau(G)=\tau(H_1)/\tau(H)$, the lemma follows in the same way as (<ref>) is implied by (<ref>).
By <cit.> ($\tau_1(\cdot)$ therein is $\tau(\cdot)$ by [64]), we have

\begin{align*}
\tau(G_1)/\tau(G) &=\left|\cok(X_*( Z(\hat G_1))^\Gamma \ra X_*( \hat Z_1)^\Gamma)\right|,\\
\tau(H_1)/\tau(H)&=\left|\cok(X_*( Z(\hat H_1))^\Gamma \ra X_*( \hat Z_1)^\Gamma)\right|.
\end{align*}

So it is enough to show that the two cokernels are isomorphic.
Consider the commutative diagram below, where the rows are coming from the exact sequence of <cit.>.

$$ \xymatrixcolsep{1.6pc} \xymatrix{
1 \ar[r] &  X_*(Z(\hat G))^\Gamma \ar[r]^-{i_G} \ar@{^(->}[d] &  X_*(Z(\hat G_1))^\Gamma \ar[r] \ar@{^(->}[d] & X_*(\hat Z_1)^\Gamma  \ar@{=}[d]  \\
1 \ar[r] &  X_*(Z(\hat H))^\Gamma \ar@{->>}[d]  \ar[r]^-{i_H} &  X_*(Z(\hat H_1))^\Gamma \ar[r] \ar@{->>}[d]  &  X_*(\hat Z_1)^\Gamma \\
& X_*({Z(\hat H)}/{Z(\hat G)})^\Gamma \ar@{=}[r] & X_*({Z(\hat H_1)}/{Z(\hat G_1)})^\Gamma

We obtain $\cok i_G\cong \cok i_H$ by diagram chase, and thereby the two cokernels above are isomorphic.

For the moment we assume that $s\in Z(\hat H)^{\Gamma_p}$, and we are going to drop this assumption in <ref> below.
By Proposition <ref> there exists a transfer
$$f^{H_1,p,\infty}\in \cH(H_1(\A_f^{p,\infty}), \chi_1^{-1}\lambda_{H_1}^{p,\infty})$$
of $f^{p,\infty}\in \cH(G(\A_f^p){\sslash} K^p)$ with the following property. For each
$$\gamma_{H_1}\in H_1(\A_f^p)_{(G_1,H_1)\textup{-reg}},$$
if it has no image in $G_1(\A_f^p)_{\semi}$ then $ SO_{\gamma_{H_1}}(f^{H_1,p,\infty})=0$.
If there exists an image $\gamma_{0,1}\in G_1(\A_f^p)_{\semi}$ of $\gamma_{H_1}$, then writing $\gamma_0\in G(\A_f^p)$ for the projection of $\gamma_{0,1}$, we have

\begin{eqnarray}
SO_{\gamma_{H_1}}(f^{H_1,p,\infty})&=&\sum_{a_1} e(a_1) \Delta(\gamma_{H_1},\gamma_{0,1,a_1}) O_{\gamma_{0,1, a_1}}(f^{p,\infty})
\label{e:SO-away-p-infty}\nonumber\\
&=& \sum_{a_1}  e(a_1) \Delta(\gamma_{H_1},\gamma_{0,1}) \lg  \beta^{p,\infty}(\gamma_{0,1},a_1) ,s_1 \rg O_{\gamma_{0,1, a_1}}(f^{p,\infty})\nonumber \\
&=& \sum_{a} \left(\prod_{v\neq p,\infty} e(I_v)\right) \Delta(\gamma_{H_1},\gamma_{0,1}) \lg  \beta^{p,\infty}(\gamma_{0},a) ,s \rg O_{\gamma_{0, a}}(f^{p,\infty}),
\end{eqnarray}

where the sums for $a_1$ and $a$ run over $\fkD(I_{0,1},G_1;\A_f^p)$ and $\fkD(I_{0},G;\A_f^p)$  respectively. Recall that $\beta^{p,\infty}(\cdot,\cdot)$ was introduced in <ref>.
The second equality above follows from a basic property of transfer factors regarding the change of $\gamma_{0,1}$ within its stable conjugacy class as stated in <cit.>, which can be proved by arguing as in the proof of <cit.> in the $G_1$-regular case and extended to the $(G_1,H_1)$-regular case by [94].

From <ref> and Corollary <ref>, we obtain $f^{H_1}_{p}\in \cH(H_1(\Q_p),\lambda_{H_1,p})$ (renaming $f^{H_1}_n$) with the following property. Let $\gamma_{H_1}\in H_1(\Q_p)_{(G_1,H_1)\textup{-reg}}$. If $\gamma_{H_1}$ is not a norm from an element of $R_1(\Q_p)$ then $SO_{\gamma_{H_1}}(f^{H_1}_p)=0$. If it is a norm, there exists $\gamma_{0,1}\in G_1(\Q_p)$ whose conjugacy class matches $\gamma_{H_1}$. Writing $\gamma_0\in G(\Q_p)$ for the projection of $\gamma_{0,1}$, we have

\begin{equation}\label{e:SO-p}
SO_{\gamma_{H_1}}(f^{H_1}_p)=\sum_{[b]\in \fkD_n(\gamma_0,G;\Q_p)} e(I_{\delta_{[b]}}) \Delta_0(\gamma_{H_1},\gamma_{0,1}) \lg \tilde \beta_p(\gamma_0,[b]), s \rg TO_{\delta_{[b]}}(\phi_n).
\end{equation}

By definition $I_{\delta_{[b]}}=I_p$ if $[b]$ comes from $\fkc=(\gamma_0,a,[b])\in \KP_{\adm}(p^n)$.
Thanks to Proposition <ref> we may and will take $f^{H_1}_p=0$ if $H$ is ramified over $\Q_p$.

Our starting point for real orbital integrals is the argument of <cit.> based on Shelstad's real endoscopy [125] and the pseudo-coefficients of  Clozel–Delorme [16]. We incorporate central characters and $z$-extensions.

We have the characters $\chi_{1,\infty}$ and $\lambda_{H_1,\infty}$ on $\fkX_{H_1,\infty}$. We will drop $\infty$ from the subscript and write $\lambda_{H_1}$ and $\chi_1$ when the context is clearly local archimedean. Let $\xi_1$ be the irreducible representation of $G_1$ obtained from $\xi$ via the surjection $G_1\rightarrow G$.
As in <ref>, fix a Shimura datum $(G_1,X_1)$ and $\mu_1\in \dmu_{X_1}(\Qbar)$. For each elliptic $\gamma_{0,1}\in G_1(\R)$ we have an element $\tilde\beta_\infty(\gamma_{0,1})\in \pi_1(I_{0,1})$ which maps to $[\mu_1]\in \pi_1(G_1)$, cf. <ref>.

We simply set $f^{H_1}_\infty:=0$ if elliptic maximal tori of $G_{\R}$ do not come from those of $H_{\R}$ via transfer (equivalently, if elliptic maximal tori of $G_{1,\R}$ do not come from those of $H_{1,\R}$). In particular $f^{H_1}_\infty=0$ if $H_{\R}$ contains no elliptic maximal tori. From now on, we assume that $H_{\R}$ contains elliptic maximal tori and they transfer to elliptic maximal tori of $G_{\R}$. In particular $Z_{G_{\R}}^0$ and $Z_{H_{\R}}^0$ have the same $\R$-rank.

Following Kottwitz, we construct a smooth function $f^{H_1}_\infty$ on $H_1(\R)$ that is compactly supported modulo center, by taking a suitable finite linear combination of pseudo-coefficients of discrete series representations (explicitly as on page 186 of [65] with our $H_1$ and $G_1$ playing the roles of his $H$ and $G$) such that the following hold:
if $\gamma_{H_1}\in H_1(\R)_{\semi}$ is elliptic and $(G_1,H_1)$-regular, which by the above assumption has an elliptic element $\gamma_{0,1}\in G_1(\R)_{\semi}$ as image, then

\begin{equation}\label{e:terms-infty-1}
SO_{\gamma_{H_1}}(f^{H_1}_\infty)=\frac{ e(I_{0,1}^{\cpt})\lg \tilde\beta_\infty(\gamma_{0,1}),s_1\rg \Delta_\infty(\gamma_{H_1},\gamma_{0,1})
\tr \xi_1(\gamma_{0,1})}{\vol(Z_{G_1}(\R)\bs I_{0,1}^{\cpt}(\R))},
\end{equation}

whereas if $\gamma_{H_1}$ is non-elliptic and $(G_1,H_1)$-regular then $SO_{\gamma_{H_1}}(f^{H_1}_\infty)=0$.  If $\gamma_{H_1}\in H_1(\R)_{\semi}$ is not $(G_1,H_1)$-regular, then by <cit.> adapted to our setting we have
The $\chi_1^{-1}\lambda_{H_1}$-equivariance of $f^{H_1}_\infty$ follows from (<ref>) and the equivariance of transfer factors (<ref>), recalling that the central character of $\xi_1$ is $\chi_1^{-1}$.

We claim that if $\gamma_{H_1}$ is elliptic and $(G_1,H_1)$-regular then (<ref>) implies that

\begin{equation}\label{e:terms-infty-2}
SO_{\gamma_{H_1}}(f^{H_1}_\infty)= \frac{e(I_{0}^{\cpt}) \lg \tilde\beta_\infty(\gamma_{0}),s\rg \Delta_\infty(\gamma_{H_1},\gamma_{0}) \tr \xi(\gamma_0)}{ \vol(Z_G(\R)\bs I_0^{\cpt}(\R))},
\end{equation}

where $\gamma_0$ is the image of $\gamma_{0,1}$ in $G(\R)$. It is routine to check term-by-term equalities between the right hand sides of (<ref>) and (<ref>). We illustrate the idea by showing that $\lg \tilde\beta_\infty(\gamma_{0,1}),s_1\rg=\lg \tilde\beta_\infty(\gamma_{0}),s\rg$, leaving the rest to the reader. Let us write $s$ for $s_1$ since the latter is the image of $s$ under the inclusion $\hat G\ra \hat G_1$. We have a decomposition $s=s's''$ with $s'\in Z(\hat H)^{\Gamma_\infty}$ and $s''\in Z(\hat G)$. By definition (<cit.>) the character $\tilde\beta_\infty(\gamma_0)$ (resp. $\tilde\beta_\infty(\gamma_{0,1})$) restricts to a character on $Z(\hat I_0)^{\Gamma_\infty}$ (resp. $Z(\hat I_{0,1})^{\Gamma_\infty}$) and a character on $Z(\hat G)$ (resp. $Z(\hat G_1)$), each of which is determined by $\mu$ (resp. $\mu_1$). They are related via the following commutative diagrams, from which it is obvious that $\lg \tilde\beta_\infty(\gamma_{0,1}),s's''\rg = \lg \tilde\beta_\infty(\gamma_{0}),s's''\rg$.

$$\xymatrix{ s'\in Z(\hat H)^{\Gamma_\infty} \ar[r] \ar[d] & Z(\hat I_0)^{\Gamma_\infty} \ar[r]^-{\tilde\beta_\infty(\gamma_0)} \ar[d] & \C^\times & s''\in Z(\hat G) \ar[r]^-{\tilde\beta_\infty(\gamma_0)} \ar[d] & \C^\times \\  Z(\hat H_1)^{\Gamma_\infty} \ar[r] & Z(\hat I_{0,1})^{\Gamma_\infty} \ar[ur]_-{\tilde\beta_\infty(\gamma_{0,1})} & & Z(\hat G_1) \ar[ur]_-{\tilde\beta_\infty(\gamma_{0,1})}}$$

So far we have constructed the function $f^{H_1}:=f^{H_1,p,\infty}f^{H_1}_p f^{H_1}_\infty$ on $H_1(\adele)$.
If $H$ is ramified over $\Q_p$ or if elliptic tori of $G_{\R}$ do not come from those of $H_{\R}$, then we have $f^{H_1}=0$ since $f^{H_1}_p=0$ or $f^{H_1}_\infty=0$ in each case. When neither is the case,
$f^{H_1}$ depends only on the image of $s$ modulo $Z(\hat G)$. To see this, suppose that $s$ is replaced with $sz$ for $z\in Z(\hat G)$. Then $f^{H_1,p,\infty}$ as well as the identity (<ref>) remains unchanged as $\prod_{v\neq p,\infty}\tilde\beta_v(\gamma_0,a)$ is trivial on $Z(\hat G)$. The function $f^{H_1}_p$ is multiplied by $\mu(z)^{-1}$ according to <ref>. Since $\lg \tilde\beta_\infty(\gamma_0),s\rg$ is the only term in  (<ref>)
to change and it is multiplied by $\lg \tilde\beta_\infty(\gamma_0),z\rg=\mu(z)$, the function $f^{H_1}_\infty$ is multiplied by  $\mu(z)$ to keep (<ref>) valid. All in all, $f^{H_1}$ indeed remains invariant.

Let us summarize the above results in terms of adelic orbital integral identities. To this end, we slightly extend the definition of $N(\gamma_0,\kappa,a,[b])$ in <ref> from rational to adelic elements. Let $\fke=(H,\cH,s,\eta)\in \cE_{\el}(G)$.
Let $\gamma_0\in G(\A)$ and suppose that $\gamma_0$ is an image of $\gamma_{H_1}\in H_1(\A)_{(G_1,H_1)\textup{-reg}}$ at every place $v$. Define a similar quantity $N'(\gamma_{0},\gamma_{H_1},s, a ,[b])$ for $s\in Z(\hat H)$, $a\in \fkD(I_0,G;\A_f^p)$, and $[b]\in \fkD_n(\gamma_0,G;\Q_p)$ by

\begin{multline*}
N'(\gamma_{0},\gamma_{H_1},s, a ,[b]) =  \lg \tilde\beta^{p,\infty}(\gamma_0,a),s\rg \lg \tilde\beta_p(\gamma_0,[b]),s \rg \lg \tilde\beta_\infty(\gamma_0),s\rg \Delta_\A(\gamma_{H_1},\gamma_{0})  \\ \times O_{\gamma_{a}}(f^p) TO_{\delta_{[b]}}(\phi_n) \tr \xi(\gamma_0) \vol(Z(\R)\bs I_\infty(\R))^{-1}.
\end{multline*}

To compare with (<ref>), if $\gamma_0\in G(\Q)_{\R\textup{-ell}}$ then

\begin{equation}\label{eq:N'=N}
\end{equation}

by definition of
$\alpha(\gamma_0,a,[b])$ and the product formula that $\Delta_\A(\gamma_{H_1},\gamma_{0})=1$.

Let $\gamma_{H_1}\in H_1(\A)_{(G_1,H_1)\textup{-reg}}$. If $\gamma_{0}\in G(\A)_{\semi}$ is $\R$-elliptic and an image of $\gamma_{H_1}$ at every place $v$ then

$$SO_{\gamma_{H_1}}(f^{H_1})=\sum_{a\in \fkD(I_0,G;\A_f^p) \atop [b]\in \fkD_n(\gamma_0,G;\Q_p)} N'(\gamma_{0},\gamma_{H_1},s,a,[b]).$$

If no $\R$-elliptic $\gamma_{0}\in G(\A)_{\semi}$ is an image of $\gamma_{H_1}$ then
If $\gamma_{H_1}\in H_1(\Q)_{\semi}$ is not $(G_1,H_1)$-regular then again $SO_{\gamma_{H_1}}(f^{H_1})=0$.

If elliptic maximal tori of $G_{\R}$ do not come from those of $H_{\R}$ then no $\R$-elliptic element of $G(\R)$ is an image of an element of $H(\R)$. Then $f^{H_1}_\infty=0$ by construction, so the lemma holds. If $\gamma_{H_1,\infty}$ is not $(G_1,H_1)$-regular then we saw $SO_{\gamma_{H_1,\infty}}(f^{H_1}_\infty)=0$, so in particular $SO_{\gamma_{H_1}}(f^{H_1})=0$ for non-$(G_1,H_1)$-regular elements $\gamma_{H_1}\in H_1(\Q)_{\semi}$.

From now on, let $\gamma_{H_1}\in H_1(\A)_{(G_1,H_1)\textup{-reg}}$, and assume that elliptic maximal tori of $G_{\R}$ come from those of $H_{\R}$. If $\gamma_{H_1}$ is not $\R$-elliptic (or equivalently if $\gamma_{H_1}$ has no image in $G(\R)_{\el}$) then
$SO_{\gamma_{H_1,\infty}}(f^{H_1}_\infty)=0$ by <cit.> (asserting that the orbital integrals of pseudocoefficients of discrete series representations are supported on elliptic elements). Thus the lemma is verified is this case.
If $\gamma_{H_1,v}$ does not have an image in $G_1(F_v)_{\semi}$ at some finite place $v$ then $SO_{\gamma_{H_1}}(f^{H_1}_v)=0$ by <ref> and <ref> so the lemma is again true.
In the remaining case, there exists $\gamma_{0}$ as in the lemma.
Then the desired equality follows from (<ref>), (<ref>), and (<ref>).

§.§ Final steps

Resuming from the formula (<ref>),
we apply the adelic transfer of orbital integrals to finish stabilization.
To re-parametrize the sum over $(\gamma_0,\kappa)$ in (<ref>),
consider the set of equivalence classes

\mid \gamma_0\in G(\Q)_{\el},~\kappa\in \fkK(I_0/\Q)\}/{\sim},$$

where $(\gamma_0,\kappa)\sim(\gamma'_0,\kappa')$ if there exists $g\in G(\ol\Q)$ such that (i) $g \gamma_0 g^{-1}=\gamma'_0$, (ii) $g^{-1}{}^{\tau}g\in I_0(\ol{\Q})$ for every $\tau\in \Gamma$, and (iii) the inner twisting $I_{0,\ol \Q}\cong I_{\gamma'_0,\ol \Q}$ induced by $\mathrm{Int}(g)$ carries $\kappa$ to $\kappa'$. Define another set of equivalence classes

$$\cE\Sigma_{\el}(G):=\{(\fke,\gamma_H):~\fke=(H,\cH,s,\eta)\in E_{\el}(G),~\gamma_H\in \Sigma_{\el}(H)_{(G,H)\text{-} \reg}\}/{\sim},$$

where $\Sigma_{\el}(H)_{(G,H)\text{-} \reg}$ is the set of stable conjugacy classes of $(G,H)$-regular semi-simple elements of $H(\Q)$, and $(\fke,\gamma_H)\sim(\fke',\gamma'_H)$ if there is an isomorphism between endoscopic data $\fke=(H,\cH,s,\eta)$ and $ \fke'=(H',\cH',s',\eta')$ such that $\gamma_H$ is carried to $\gamma'_H$. (In particular $(\fke,\gamma_H)\sim (\fke,\gamma'_H)$ if there is an outer automorphism of $\fke$ mapping $\gamma_H$ to $\gamma'_H$.) Define an analogous set with the obvious surjection

\begin{equation}\label{e:cEtilde-to-cE}
\cE\Sigma^\sim_{\el}(G):=\left\{(\fke,\gamma_H) \mid \begin{array}{c}\fke=(H,\cH,s,\eta)\in \cE_{\el}(G),\\\gamma_H\in \Sigma_{\el}(H)_{(G,H)\text{-} \reg}\end{array}  \right\}
\rightarrow \cE\Sigma_{\el}(G).
\end{equation}

The outer automorphism group $\Out_F(\fke)$ acts transitively on each fiber of the map.
Let us define a map

$$\tilde\fkE:\cE\Sigma^\sim_{\el}(G)\To \Sigma\fkK_{\el}(G)\cup \{\emptyset\}.$$

We explained in <ref> how
$(\fke,\gamma_H)$ determines either a stable conjugacy class of $\gamma_0\in G(\Q)$ or $\emptyset$ (when there is no matching conjugacy class in $G(\Q)$).
In the latter case, set $\tilde\fkE:(\fke,\gamma_H)\mapsto \emptyset$. In the former, we map $(\fke,\gamma_H)$ to $(\gamma_0,\kappa)$, where $\kappa\in \fkK(I_0/\Q)$ is determined by the image of $s$ under the composition $Z(\hat H)\hra Z(\hat I_{\gamma_H}) \cong Z(\hat I_0)$. Here the canonical isomorphism comes from the fact that $I_0$ is an inner form of $I_{\gamma_H}$.  The ellipticity of $\gamma_0$ follows from that of $\gamma_H$. Letting $Z(\Q)$ act on each of $\Sigma_{\el}(G)$ and $\Sigma_{\el}(H)$ by multiplication, we see that $\tilde\fkE$ is $Z(\Q)$-equivariant.

By <cit.>, when $G_{\der}=G_{\sconn}$, the map $\tilde\fkE$ factors through a unique map $\fkE:\cE\Sigma^\sim_{\el}(G)\ra  \cE\Sigma_{\el}(G)$, and the image of $\tilde\fkE$ contains $\Sigma\fkK_{\el}(G)$. When $G_{\der}$ is not simply connected, write $\tilde\fkE_1$ and $\fkE_1$ for the analogous maps for the $z$-extension $G_1$. We have a commutative diagram (a priori without $\fkE$)

\begin{equation}\label{eq:ESigma-SigmaK}
\xymatrix{
\cE\Sigma^\sim_{\el}(G_1) \ar@{->>}[r] \ar[d] & \cE\Sigma_{\el}(G_1) \ar[r]^-{\fkE_1} \ar[d] & \Sigma\fkK_{\el}(G_1)\cup \{\emptyset\} \ar[d]\\
\cE\Sigma^\sim_{\el}(G<EMAIL_ADDRESS>\fkE}  \ar@{->>}[r] & \cE\Sigma_{\el}(G) \ar@{-->}[r]^-{\exists!\, \fkE}   & \Sigma\fkK_{\el}(G)\cup \{\emptyset\},
\end{equation}