Finally in this section, we will let $\mathbb{T}^{\chi,I,\varsigma,Q}$ denote the $\LI$-subalgebra of $\End_{\LI}(M^{\chi,I,\varsigma,Q})$ generated by the image of
Similarly, let $\mathbb{T}^{\chi,I,\varsigma}$ denote the $\LI$-subalgebra of $\End_{\LI}(M^{\chi,I,\varsigma})$ generated by the image of

§.§ Preparation for the Taylor–Wiles method

In this section fix $I \subset S_p$ and let $K_p = K_p(I)$ be the level structure at $v \in S_p$.
Let $X_{K_p K^p_0(Q,R),\Sigma}$, $X_{K_p K^p_1(Q,R),\Sigma}$ denote the compactified Shimura varieties at the respective levels $K_p K^p_0(Q,R)$ and $K_p K^p_1(Q,R)$ with respect to a compatible choice $\Sigma$ of polyhedral cone decompositions (as in <cit.>).
For $v \in Q \cup R$, we have a parabolic subgroup $P_v$ defining a parahoric subgroup $\mathfrak{p}_v \leq \GSp_4(F_v)$ (these are given by the standard Borel subgroup $B$ and Iwahori subgroup respectively in the case $v \in R$).
This parabolic subgroup $P_v$ may be viewed as the subgroup of $\GSp_4$ which preserves a filtration $0 = V_{v,0} \leq \ldots \leq V_{v,n_v}$ of isotropic subspaces of $V$ for some $0 \leq n_v \leq 2$.
Thus from the definition of the moduli problem described in <cit.>,over the interior $Y_{K_p K^p_0(Q,R)}$  we obtain a filtration of $A[v]$ by $k(v)$-group schemes, which we will denote $H_{v,0} \leq \ldots \leq H_{v,n_v}$.
To show the natural map between the compactified Shimura varieties at the respective levels is finite étale we shall be interested in extending the top exterior powers of the graded pieces of these filtrations.

For $v \in Q \cup R$, the group schemes $J_{v,m+1} := \det(H_{v,m+1}/H_{v,m})$ defined over $Y_{K_p K^p_0(Q,R)}$ for $0 \leq m < n_v$ may be extended to rank 1 finite étale $k(v)$-group schemes over $X_{K_p K^p_0(Q,R),\Sigma}$.
Let $J_{v,0}$ denote the constant $k(v)$-group scheme of rank 1 defined over $X_{K_p K^p_0(Q,R),\Sigma}$.
Let $\Xi_Q = \ker(\prod_{v \in Q} C_{L_v}(k(v)) \to \Delta_Q)$.
The map $X_{K_p K^p_1(Q,R),\Sigma} \to X_{K_p K^p_0(Q,R),\Sigma}$ is then finite étale with group $\Delta_Q \times \prod_{v \in R} T(k(v))$ and we can identify $X_{K_p K^p_1(Q,R),\Sigma}$ as the torsor of $\Xi_Q$-orbits of trivialisations of the extended group schemes $J_{v,m}$ for each $v \in Q \cup R$ and $0 \leq m \leq n_v$.

We shall follow an argument along the lines of the proof of <cit.>.
We firstly explain how the second part of the Proposition follows from the first.
We claim that the torsor of $\Xi_Q$-orbits of trivialisations of the extended group schemes $J_{v,m}$ over $Y_{K_p K^p_0(Q,R)}$ is isomorphic to $Y_{K_p K^p_1(Q,R)}$.
If $\{V_{v,i}\}_{0 \leq i \leq n_v}$ is the filtration of $V$ corresponding to the parabolic subgroup $P_v$ then the Levi subgroup $L_v$ is isomorphic to an extension of $\mathbb{G}_m$ (corresponding to the similitude factor) by $\GL_{r_1} \times \ldots \times \GL_{r_{n_v}} \times \Sp_{2 r_0}$  where $r_i = \dim V_{v,i} - \dim V_{v,{i-1}}$ for $1 \leq i \leq n_v$ and $r_0 = 2 - \sum_{i=1}^{n_v} r_i$.
It then follows that the map $P_v \to C_{L_v} \cong \mathbb{G}_m^{\{0,1,\ldots,n_v\}}$ is given by the similitude character onto the $0$-index copy of $\mathbb{G}_m$, and taking determinants of the various $\GL_{r_i}$ factors onto the copy of $\mathbb{G}_m$ indexed by $i$.
Then giving a $\ker(P_v(k(v)) \to C_{L_v}(k(v)))$-orbit of isomorphisms $V \otimes_{\mathcal{O}_F} k(v) \to A[v]$ of $\Pi_1(Y_{K_p K^p_0(Q,R)},\bar{s})$-modules is equivalent to giving a $P_v(k(v))$-orbit, together with isomorphism between $J_{v,m}$ and the trivial $\Pi_1(Y_{K_p K^p_0(Q,R)},\bar{s})$-module $k(v)$ for every $0 \leq m \leq n_v$.
Similarly, giving a $\ker(P_v(k(v)) \to \Delta_Q)$-orbit of such isomorphisms is equivalent to giving a $P_v(k(v))$ orbit, together with a $\Xi_Q$-orbit of isomorphisms $J_{v,m} \to k(v)$, where $\Xi_Q$ acts on the isomorphism indexed by $m$ via the map $C_L(k(v))$ to $k(v)^\times$ onto the factor indexed by $m$.
As in the proof of <cit.> the torsor of $\Xi_Q$-orbits of trivializations and $X_{K_p K^p_1(Q,R),\Sigma}$ are both normal, finite flat over $X_{K_p K^p_0(Q,R),\Sigma}$ and generically equal, so they are isomorphic.

We thus have to show we can extend each $J_{v,m}$.
Just as in the proof of <cit.> we may reduce to the following situation: we have an open immersion of schemes $S \subset T$ together with an abelian scheme $A$ defined over $S$, and a semi-abelian scheme $B$ of constant toric rank defined over $T$ such that $A$ is the quotient of $B$ by a finite free $\mathcal{O}_F$-module on restricting to $S$, as in Mumford's construction.
In that proof we saw that $B[v]$ is already defined as a finite étale group scheme over the whole of $T$, and that $A[v]/B[v]$ is a constant group scheme on $S$.
For $m>0$ write $J_{v,m} = \det(D/C)$, where $C \leq D \leq A[v]$ are étale subgroup schemes defined on $S$.
Then we have the short exact sequence

$$0 \to \frac{D \cap B[v]}{C \cap B[v]} \to \frac{D}{C} \to \frac{D + B[v]}{C + B[v]} \to 0,$$

from which it follows on taking determinants that

$$\det \frac{D}{C} \cong \det (\frac{D \cap B[v]}{C \cap B[v]}) \otimes \det(\frac{D + B[v]}{C + B[v]}).$$

The first tensorand is an exterior power of a subquotient of $B[v]$ defined over $T$, and therefore extends to $T$.
The second tensorand is an exterior power of a subquotient of $A[v]/B[v]$, which is a constant group scheme on $S$ and thus extends to $T$, so we are done.

The following is the direct analogue of <cit.>.

If $I = \emptyset$ then $M^{\chi,I,\varsigma,Q}$ is a finite free $\Lambda_I[\Delta_Q]$-module.
If $\#I = 1$ then $M^{\chi,I,\varsigma,Q}$ is a balanced $\Lambda_I[\Delta_Q]$-module, in the sense of <cit.>.

Having shown Proposition <ref>, the proof is now identical to the proof of <cit.>.

The final result we need about the module $M^{\chi,I,\varsigma,Q}$ for the Taylor–Wiles method to go through is the analogue of <cit.>.

The map $M^{\chi,I,\varsigma,Q} \to M^{\chi,I,\varsigma}$ arising from the inclusion $K_1^p(Q) \subset K^p$ induces an isomorphism $(M^{\chi,I,\varsigma,Q})_{\Delta_Q} \to M^{\chi,I,\varsigma}$.

We again follow the proof of <cit.>.
Recall that the natural map

$$\bigotimes_{\CalO, v \in Q} \CalO[T(F_v)/(T(F_v) \cap \mathfrak{p}_{1,v})]^{W_{L_v}} \to \bigotimes_{\CalO, v \in Q} \CalO[T(F_v)/(T(F_v) \cap \mathfrak{p}_{v})]^{W_{L_v}}$$

induces a bijection on maximal ideals, since $\Delta_Q$ is of $p$-power order.
Let $\Tilde{m}_{0,Q}$ be the maximal ideal corresponding to $\Tilde{m}_{Q}$ under this bijection.
We can then form
$$M^{\chi,I,\varsigma,Q}_{K_0^p(Q)} = \RHom^0_{\Lambda_I}(M^{\bullet,I}_{K_0^p(Q)}, \LI)_{\Tilde{m}^{I,\varsigma,Q},\Tilde{m}_{0,Q},\chi,|.|^2}.$$

From Proposition <ref>, we deduce in the same way as the proof of <cit.> that we have an isomorphism

$$(M^{\chi,I,\varsigma,Q})_{\Delta_Q} \cong M^{\chi,I,\varsigma,Q}_{K_0^p(Q)}.$$

Then to show that there is an isomorphism

$$M^{\chi,I,\varsigma,Q}_{K_0^p(Q)} \cong M^{\chi,I,\varsigma}$$

it suffices to prove by <cit.> that the composition

H^i(M^{\bullet,I}_{K_0^p(Q)} \otimes k)_{\Tilde{m}^{\an,Q},\Tilde{m}_{0,Q}} \to
H^i(M^{\bullet,I}_{K_0^p(Q)} \otimes k)_{\Tilde{m}^{\an,Q}} \to
H^i(M^{\bullet,I}_{K^p} \otimes k)_{\Tilde{m}^{\an,Q}}
\to
H^i(M^{\bullet,I}_{K^p} \otimes k)_{\Tilde{m}^{\an}}

is an isomorphism for every $i$.
The action of the Hecke algebra on the various complexes is described in <cit.>.
If we have compact open subgroups $K' \leq K$ which differ only at places $v \in Q$, then we have the equalities

\begin{align*}
1_{K 1 K'} 1_{K' 1 K} &= [K:K'] \\
1_{K' 1 K} 1_{K 1 K'} &= [K],
\end{align*}

where $[K]$ is the Hecke operator arising from the indicator function on $K$, a $K'$-biinvariant function.
Let $N_i = H^i(M^{\bullet,I}_{K_{\Iw}^p(Q)} \otimes k)_{\Tilde{m}^{\an,Q}}$, viewed as a module over the product of Iwahori–Hecke algebras at places $v \in Q$.
Since $p>2$ it follows that the indices $[K^p:K_{\Iw}^p(Q)]$ and $[K_0^p:K_{\Iw}^p(Q)]$ are units in $k$.
Thus via the above equalities of Hecke operators we can identify $H^i(M^{\bullet,I}_{K^p} \otimes k)_{\Tilde{m}^{\an,Q}}$ (resp. $H^i(M^{\bullet,I}_{K_0^p(Q)} \otimes k)_{\Tilde{m}^{\an,Q}}$) with the image of $N_i$ under the Hecke operator $[K^p]$ (resp. $[K_0^p]$).
This is identification is also compatible with the localizations at the various maximal ideals of the abelian subalgebras of the parahoric and unramified Hecke algebras at places $v \in Q$.
We are done on applying Corollary <ref> since the above composition becomes identified with the isomorphism

([K_0^p(Q)]N_i)_{\Tilde{m}^{\an,Q},\Tilde{m}_{0,Q}} \xrightarrow{\sim} ([K^p(Q)]N_i)_{\tilde{m}^{\an}}

given by the corollary, noting that $\tilde{m}^{\an}$ is defined at places $v \in Q$ by the maximal ideal of the unramified Hecke algebra $\mathcal{O}[X_*(T)]^{W_G}$ corresponding to the $W_G$-orbit of $\bar{g}_v$.

We now state a theorem on the existence of Galois representations associated to a classical weight cuspidal automorphic respresentation $\pi$.
Local-global compatibility will then imply these Galois representations define a class in the image of our deformation functor and that the $\Delta_Q$-action is the expected one arising from the local factors of $\pi$.

Suppose $\pi$ is a cuspidal automorphic representation of $\GSp_4(\mathbb{A}_F)$ of classical weight $\kappa = (k_v,l_v)$ with $k_v \geq l_v > 2$ and $k_v \equiv l_v \mod 2$ for all $v | \infty$ with central character $|.|^2$.
Suppose moreover that $(\pi_f^{K^p_1(Q) K_p(\emptyset)} \otimes \bar{E})^{\chi,|.|^2}_{\Tilde{m}^{I,\varsigma,Q}, \Tilde{m}_Q} \neq 0$.
Then there exists an associated continuous irreducible Galois representation $\rho_{\pi,p}: G_F \to \GSp_4(\bar{E})$ which satisfies, for each finite place $v \nmid p$,

$$\WD(\restr{\rho_{\pi,p}}{G_{F_v}})^{\Fss} \cong \rec_{\GT,p}(\pi_v \otimes |\nu|^{-3/2}).$$

We may conjugate $\rho_{\pi,p}$ to a representation $\rho: G_F \to \GSp_4(\mathcal{O}_{E_\pi})$ where $E_\pi/E$ is some finite extension with ring of integers $\mathcal{O}_{E_\pi}$ and residue field $k_\pi$ such that $\rho$ lifts $\bar{\rho} \otimes_k k_\pi$.

Then for each $v \in Q$ and any such conjugate $\rho$, we have $\rho \in \mathcal{D}_{v,\CalO_{E_\pi}}^{\text{TW}}(\mathcal{O}_{E_{\pi}})$.
The composition $\Delta_v \to (R_{v,\CalO_{E_\pi}}^{\text{TW}})^\times \to \mathcal{O}_{E_\pi}^\times$ coincides with the scalar action of $\Delta_v$ on the space $(\pi_f^{K^p_1(Q) K_p(\emptyset)} \otimes \bar{E})^{\chi,|.|^2}_{\Tilde{m}^{I,\varsigma,Q}, \Tilde{m}_Q}$.

Recall here that $\rec_{\GT,p}$ is the local Langlands correspondence described in Section <ref>.

The existence of $\rho_{\pi,p}$ is stated in <cit.> and to show the desired properties from this we will firstly explain why $\rho_{\pi,p}$ is conjugate to a lift of $\bar{\rho}$.
Continuity of $\rho_{\pi,p}$ implies that it is conjugate to a representation valued in the ring of integers of some such extension of $\mathcal{O}$.
As in the proof of <cit.>, it follows that the reduction of $\rho$ on a dense subset of $G_F$ (given by Frobenius elements at places outside $S_p \cup Q \cup R \cup \{v_0\}$) has characteristic polynomial coinciding with that of $\bar{\rho}$, and so the two residual representations are conjugate in $\GSp_4(k_\pi)$.
Thus we may take such a conjugate $\rho$, lifting $\bar{\rho} \otimes_k k_\pi$.
By absolute irreducibility of $\bar{\rho}$, $\rho$ itself must also be absolutely irreducible and hence the stated local-global compatibility holds by <cit.> again.

Now let $v \in Q$ be a Taylor–Wiles place.
We know that $\pi_v$ satisfies $((\pi_v)^{\mathfrak{p}_{1,v}})_{\tilde{m}_v} \neq 0$.
By Proposition <ref>, we know that $\rec_{\GT,p}(\pi_v)$ is a semisimple Weil–Deligne representation with $\rec_{\GT,p}(\pi_v) = (\chi^\vee \circ \Art_{F_v}^{-1},0)$ for some character $\chi: G(F_v) \to \Qpbar^\times$, with $\pi_v$ an irreducible subquotient of the parabolic induction $i_B^G \chi$.
Note then that $\rec_{\GT,p}(\pi_v \otimes |\nu|^{-3/2})$ equals $((\chi \otimes |\nu|^{-3/2})^\vee \circ \Art_{F_v}^{-1},0)$ by <cit.>.
Hence we are done on applying Proposition <ref>.

There exists a continuous Galois representation $\rho^{\chi,I,\varsigma,Q}: G_F \to \GSp_4(\mathbb{T}^{\chi,I,\varsigma,Q})$ defining a class in $\mathcal{D}_{\chi,Q}^{I,\varsigma}(\mathbb{T}^{\chi,I,\varsigma,Q})$ and such that the composition $\Delta_Q \to (R_{\chi,Q}^{I,\varsigma})^\times \to (\mathbb{T}^{\chi,I,\varsigma,Q})^\times$ defines the same action of $\Delta_Q$ on $M^{\chi,I,\varsigma,Q}$ as the action arising from viewing $\Delta_Q$ as a set of Hecke operators at places in $Q$.
Moreover, we have

* If $v \not\in S_p \cup R \cup \{v_0\} \cup Q$, then $\det(X- \rho^{\chi,I,\varsigma,Q}(\Frob_v)) = Q_v(X)$.

* If $v \in I$, then

\restr{\rho^{\chi,I,\varsigma,Q}}{G_{F_v}}    \cong
\begin{pmatrix}
\lambda_{\Tilde{\alpha}_v} \theta_v & 0 & * & * \\
0 & \lambda_{\Tilde{\beta}_v} \theta_v & * & * \\
0 & 0 & \lambda_{\Tilde{\beta}_v}^{-1} \theta_v^{-1} \varepsilon^{-1} & 0 \\
0 & 0 & 0 & \lambda_{\Tilde{\alpha}_v}^{-1} \theta_v^{-1} \varepsilon^{-1}
\end{pmatrix}

* If $v \in I^c$, then

\restr{\rho^{\chi,I,\varsigma,Q}}{G_{F_v}}    \cong
\begin{pmatrix}
\lambda_{U_{v,1}} \theta_{v,1} & 0 & * & * \\
0 & \lambda_{U_{v,2}/U_{v,1}} \theta_{v,2} & * & * \\
0 & 0 & \lambda_{U_{v,2}/U_{v,1}}^{-1} \theta_{v,2}^{-1} \varepsilon^{-1} & 0 \\
0 & 0 & 0 & \lambda_{U_{v,1}}^{-1} \theta_{v,1}^{-1} \varepsilon^{-1}
\end{pmatrix}    .

We will follow the proof of <cit.> and suppose that $I= \emptyset$ firstly.
Consider the set $W$ of cuspidal automorphic representations $\pi$ of classical weight $\kappa = (k_v,l_v)$ with $k_v \geq l_v \geq 4$ and $k_v \equiv l_v \equiv 2 \text{ or } p+1 \mod 2(p-1)$ such that $e(\emptyset) (\pi_f^{K^p_1(Q) K_p(\emptyset)} \otimes \bar{E})^{\chi,|.|^2}_{\Tilde{m}^{\emptyset,\varsigma,Q}, \Tilde{m}_Q} \neq 0$.
Here $\pi_f$ is the finite part of $\pi$ and $e(\emptyset)$ is the ordinary projector of <cit.>.
For each such $\pi \in W$, we have an associated Galois representation $\rho_{\pi,p}: G_F \to \GSp_4(\CalO_{E_\pi})$, with $\rho_{\pi,p}$ and $\CalO_{E_\pi}$ as in Theorem <ref>.
We have an inclusion

\begin{equation} \label{inclusion of module}
M^{\chi,\emptyset,\varsigma,Q} \subset \prod_{\kappa} \bigoplus_{\pi \in W, \text{wt}(\pi) = \kappa} (e(\emptyset) (\pi_f^{K^p_1(Q) K_p(\emptyset)} \otimes \bar{E})^{\chi,|.|^2}_{\Tilde{m}^{I,\varsigma,Q}, \Tilde{m}_Q})^*
\end{equation}

respecting the actions of the Hecke operators $\Tilde{\mathbb{T}}^{\chi,I,\varsigma,Q}$ at places away from $Q$ and

$$\bigotimes_{\CalO, v \in Q} \CalO[T(F_v)/(T(F_v) \cap \mathfrak{p}_{1,v})]^{W_{L_v}}.$$

The above inclusion allows us to view $\mathbb{T}^{\chi,I,\varsigma,Q}$ as a subalgebra of
$$A = \{(a,(a_\pi)) \in k \times \prod_{\pi \in W} \CalO_{E_\pi} : a_\pi \mod m_{E_\pi} = a\}$$
given by the scalar action of a Hecke operator on the space of localised invariants of $\pi$.

The same construction of the proof of <cit.> yields a lift $\rho^{\chi,I,\varsigma,Q}: G_F \to \GSp_4(\mathbb{T}^{\chi,I,\varsigma,Q})$ when $I = \emptyset$, and the desired properties away from places $v \in Q$ can be proved in the same way.
We can assume from the construction of $\rho^{\chi,I,\varsigma,Q}$ that the composition of $\rho^{\chi,I,\varsigma,Q}$ with the maps $\mathbb{T}^{\chi,I,\varsigma,Q} \to A \to \CalO_{E_\pi}$ will yield a representation conjugate in $\ker(\GSp_4(\CalO_{E_\pi}) \to \GSp_4(k_\pi))$ to $\rho_{\pi,p}$.
This composition will be valued in the ring of integers of a totally ramified extension of $\CalO$ and will satisfy the consequences of Theorem <ref>.
We may write $\mathbb{T}^{\chi,I,\varsigma,Q}$ as an inverse limit of Artinian quotients $\mathbb{T}_n = \mathbb{T}^{\chi,I,\varsigma,Q}/I_n$ where each $\mathbb{T}_n$ can be written as a finite fibre product over $k$ of quotients of some such rings $\CalO_{E_\pi}$.
Then the image of $\rho^{\chi,I,\varsigma,Q}$ in $\GSp_4(\mathbb{T}_n)$ will lie in $\DvTW(\mathbb{T}_n)$ by Lemma <ref>, and hence $\rho^{\chi,I,\varsigma,Q}$ itself will lie in $\DvTW(\mathbb{T}^{\chi,I,\varsigma,Q})$.

For each $\pi \in W$, the composition $\Delta_v \to (\mathbb{T}^{\chi,I,\varsigma,Q})^\times \to \CalO_{E_\pi}^\times$ will also coincide with the action of $\Delta_v$ on $e(\emptyset) (\pi_f^{K^p_1(Q) K_p(\emptyset)} \otimes \bar{E})^{\chi,|.|^2}_{\Tilde{m}^{\emptyset,\varsigma,Q}, \Tilde{m}_Q}$ by Theorem <ref>.
The inclusion <ref> implies that the map $\Delta_v \to (\mathbb{T}^{\chi,I,\varsigma,Q})^\times$ defines an action on $M^{\chi,\emptyset,\varsigma,Q}$ coinciding with the one arising from viewing $\Delta_v \subset \CalO[T(\CalO_{F_v})/(T(\CalO_{F_v}) \cap \mathfrak{p}_{1,v})]^{W_{L_v}}$.

We are now done in the case where $I = \emptyset$.
The case $I \neq \emptyset$ can now be proved by induction on $\#I$ via the same argument of <cit.>.

To finish this section, we will state the analogue of <cit.>, which we will use in proving our modularity results.

Suppose that $\pi$ is cuspidal automorphic representation of $\GSp_4(\mathbb{A}_F)$ of parallel weight 2, and that $\pi$ is ordinary in the sense of <cit.>.
There exists a continuous semisimple Galois representation $\rho_{\pi,p}: G_F \to \GL_4(\Qpbar)$ satisfying

* If $v \nmid p$ is such that $\pi_v$ is unramified, then $\restr{\rho_{\pi,p}}{G_{F_v}}$ is unramified and

\det(X - \rho_{\pi,p}(\Frob_v)) = Q_v(X).

Suppose moreover that $\overline{\rho_{\pi,p}}$ is $\hat{G}$-reasonable and that for each $v|p$, the ordinary Hecke parameters $\alpha_v$ and $\beta_v$ satisfy $\overline{\alpha_v} \neq \overline{\beta_v}$.
Then $\rho_{\pi,p}$ can be conjugated into $\GSp_4(\Qpbar)$ and satisfies

* $\nu \circ \rho_{\pi,p} = \varepsilon^{-1}$

* For each $v \nmid p$, we have

\WD(\restr{\rho_{\pi,p}}{G_{F_v}})^{\text{ss}} \cong \rec_{\GT,p}(\pi_v \otimes | \nu|^{-3/2})^{\text{ss}}

* For each $v | p$, we have

\restr{\rho_{\pi,p}}{G_{F_v}} \cong
\begin{pmatrix}
\lambda_{\alpha_v} \theta_v & 0 & * & * \\
0 & \lambda_{\beta_v} \theta_v & * & * \\
0 & 0 & \lambda_{\beta_v}^{-1}  \varepsilon^{-1} & 0 \\
0 & 0 & 0 & \lambda_{\alpha_v}^{-1}  \varepsilon^{-1}
\end{pmatrix}

This follows from Theorem <ref> and [38] in the same way as in the proof of <cit.>.

§.§ Patching

We are now ready to carry out a patching argument analogous to <cit.>.
Most of the notation and constructions will be similar, so we will firstly highlight the main difference arising from our more general notion of Taylor–Wiles places of Section <ref> in the following lemma.
Let $q = h^1(G_{F,S},\splie_4^\vee(1))$.

There exists $0 \leq t \leq 2q$ such that for every $N \geq 1$ there exists a Taylor–Wiles datum

(Q_N,\{(\hat{T}_v,\hat{B}_v)\}_{v \in Q_N})

of level $N$ with $Q_N$ as in Corollary <ref>, $\#Q_N = q$ and such that $\Delta_{Q_N}$ has $t$ cyclic factors as an abelian group.

We can, for each $N \geq 1$, fix a Taylor–Wiles datum
(Q_N,\{(\hat{T}_v,\hat{B}_v)\}_{v \in Q_N})
of level $N$ with $Q_N$ as in Corollary <ref> and $\#Q_N = q$.
These $(Q_N)_{N \geq 1}$ may induce $p$-groups $\Delta_{Q_N}$ for which the number of cyclic factors may differ with $N$.
The number of such cyclic factors is bounded by $2q$ (since each $\Delta_v$ is the maximal $p$-power quotient of $S(k(v))$, where $S$ is a torus of rank at most $2$), so by the pigeonhole principle we can find an increasing sequence $(N_i)_{i \geq 1}$ for which our $\Delta_{Q_{N_i}}$ all have an equal number $0 \leq t \leq 2q$ of cyclic factors.
Since a Taylor–Wiles datum of level $N$ is also a Taylor–Wiles datum of level $N'$ for $N' \leq N$, we can use our subsequence to obtain Taylor–Wiles data as in the statement of the lemma.

Fix for $N \geq 1$ Taylor–Wiles data
(Q_N,\{(\hat{T}_v,\hat{B}_v)\}_{v \in Q_N})
as in Lemma <ref>, and when $N = 0$ we will take $Q_0 = \emptyset$.
Let $g = t - 4 [F:Q] + \#S - 1$, with $t$ as in Lemma <ref> for our choice of Taylor–Wiles data.
Note that this coincides with the $g$ of Corollary <ref>.
Indeed we have that $z = \dim Z(\GSp_4) = 1$, $n_v$ is the number of cyclic factors in $\Delta_v$ and for each $v | \infty$ we have $h^0(G_{F_v},\splie_4) = 4$, which follows from a straightforward computation using that $\bar{\rho}$ is odd in the sense of <cit.>, as the similitude character is the inverse cyclotomic character.
Set $\Delta_{\infty} = \mathbb{Z}_p^t$ and, for each $N \geq 1$, let $\Delta_N = \Delta_{Q_N}$ and fix a surjection $\Delta_{\infty} \twoheadrightarrow \Delta_N$.
Set $\Delta_0$ to be the trivial group equipped with the unique map from $\Delta_\infty$.

With this notation in place, the rest of the setup will be almost identical to that of <cit.>, but we shall include it for clarity.
We fix $I \subset S_p$ with $\#I \leq 1$ and let $\Lambda = \Lambda_I$.
By enlarging $E$ if required, we suppose that $E$ contains a primitive $p$th root of unity, and that if $p=3$ then $E$ contains a primitive $9$th root of unity.
Then let $\mathcal{T} = \Lambda[(\prod_{v \in S} \widehat{\GSp_4})/ \widehat{\mathbb{G}_m}]$, a power series ring in $11 \#S - 1$ variables over $\Lambda$.
Set $S_{\infty} = \mathcal{T}[[\Delta_{\infty}]]$ and let $\mathbf{a} = \ker(S_{\infty} \to \Lambda)$ be the augmentation ideal.
Fix, for each $v \in R$, a pair of non-trivial characters $\chi_v = (\chi_{v,1},\chi_{v,2})$ as in Section <ref> with $\chi_{v,1} \neq \chi_{v,2}^{\pm 1}$.
In what follows, write $\chi$ for these choice of characters and $1$ for the trivial characters.

Let $N \geq 0$.
We will write $S_N = \mathcal{T}[\Delta_N]$.
Recall the augmented global deformation problems of Section <ref>.
Let $R_N^{1,I,\varsigma} = R_{1,Q_N}^{I,\varsigma}$ and $R_N^{\chi,I,\varsigma} = R_{\chi,Q_N}^{I,\varsigma}$.
Let $R^{1,I,\varsigma,\loc} = R^{S,\loc}_{\mathcal{S}_{1}^{I,\varsigma}}$ and $R^{\chi,I,\varsigma,\loc} = R^{S,\loc}_{\mathcal{S}_{\chi}^{I,\varsigma}}$ be the completed tensor product of deformation rings described in Section <ref>.

There are still canonical isomorphisms

\begin{equation} \label{loc rings iso mod p}
R^{1,I,\varsigma,\loc}/(\lambda) \cong R^{\chi,I,\varsigma,\loc}/(\lambda)
\end{equation}

and, for every $N \geq 0$,

\begin{equation} \label{def rings iso mod p}
R_N^{1,I,\varsigma}/(\lambda) \cong R_N^{\chi,I,\varsigma}/(\lambda).
\end{equation}

For $N \geq 1$, we saw in Section <ref> that our Taylor–Wiles datum give both $R_N^{1,I,\varsigma}$ and $R_N^{\chi,I,\varsigma}$ the structure of a $\Lambda[\Delta_N]$-algebra, and it is easy to see that there are isomorphisms

\begin{align}
R_N^{1,I,\varsigma} \otimes_{\Lambda[\Delta_N]} \Lambda \cong R_0^{1,I,\varsigma} \label{1 ring iso mod delta} \\
R_N^{\chi,I,\varsigma} \otimes_{\Lambda[\Delta_N]} \Lambda \cong R_0^{\chi,I,\varsigma} \label{chi ring iso mod delta}
\end{align}

compatible with the isomorphisms <ref>.

For each $N \geq 0$, fix representatives $\rho_N^{1,I,\varsigma}$ of $\mathcal{D}_{\mathcal{S}_{1,Q_N}^{I,\varsigma}}$ and $\rho_N^{\chi,I,\varsigma}$ of $\mathcal{D}_{\mathcal{S}_{\chi,Q_N}^{I,\varsigma}}$ which are compatible with <ref> and also compatible with the isomorphisms <ref> and <ref>.
As explained in <cit.>, the natural map of functors $\mathcal{D}^S_{\mathcal{S}_{1,Q_N}^{I,\varsigma}} \to \mathcal{D}_{\mathcal{S}_{1,Q_N}^{I,\varsigma}}$ has the structure of a torsor with group $\mathcal{T}$, and our choice of representatives determine an isomorphism $R^{S,\loc}_{\mathcal{S}_{1,Q_N}^{I,\varsigma}} \cong R_N^{1,I,\varsigma} \hat{\otimes}_\Lambda \mathcal{T}$ (and similarly, an isomorphism
$R^{S,\loc}_{\mathcal{S}_{\chi,Q_N}^{I,\varsigma}} \cong R_N^{\chi,I,\varsigma} \hat{\otimes}_\Lambda \mathcal{T}$).
Therefore, we obtain an $R^{1,I,\varsigma,\loc}$-algebra structure on $R_N^{1,I,\varsigma} \hat{\otimes}_\Lambda \mathcal{T}$ and a $R^{\chi,I,\varsigma,\loc}$-algebra structure on $R_N^{\chi,I,\varsigma} \hat{\otimes}_\Lambda \mathcal{T}$, and these are again compatible with <ref> and <ref>.
Now let $R_\infty^{1,I,\varsigma}$ denote the ring of formal power series in $g$ variables over $R^{1,I,\varsigma,\loc}$ and similarly for $R_\infty^{\chi,I,\varsigma}$ over $R^{\chi,I,\varsigma,\loc}$; we then have

\begin{equation} \label{infty rings iso mod p}
R_\infty^{1,I,\varsigma}/(\lambda) \cong R_\infty^{\chi,I,\varsigma}/(\lambda)
\end{equation}

via <ref>.
As in Corollary <ref>, we can find local $\Lambda$-algebra surjections $R_\infty^{1,I,\varsigma} \twoheadrightarrow R_N^{1,I,\varsigma} \hat{\otimes}_\Lambda \mathcal{T}$ and $R_\infty^{\chi,I,\varsigma} \twoheadrightarrow R_N^{\chi,I,\varsigma} \hat{\otimes}_\Lambda \mathcal{T}$, which we may again assume are compatible modulo $(\lambda)$ in the sense of <ref> and <ref>, and with the isomorphisms <ref> and <ref>.

We will apply the patching criterion of <cit.> together with Theorem <ref>, Proposition <ref> and Proposition <ref>.
Before we summarize the main consequences of this in a proposition, we will introduce the following notation.
If $R \in \CNL_{\CalO}$ we will let $R'$ denote the maximal $\CalO$-flat quotient of $R$.

There exists the following data:

* Maps $S_\infty \to R_\infty^{1,I,\varsigma}$ and $S_\infty \to R_\infty^{\chi,I,\varsigma}$ of $\LI$-algebras

* Finite $S_\infty$-modules $M_\infty^{1,I,\varsigma}$ and $M_\infty^{\chi,I,\varsigma}$

* Isomorphisms

\begin{align}
M_\infty^{1,I,\varsigma}/\mathbf{a} \cong M^{1,I,\varsigma} \label{1 module mod a}   \\
M_\infty^{\chi,I,\varsigma}/\mathbf{a} \cong M^{\chi,I,\varsigma} \label{chi module mod a}
\end{align}

* Maps $ R_\infty^{1,I,\varsigma} \to \End_{S_\infty}(M^{1,I,\varsigma})$ and $ R_\infty^{\chi,I,\varsigma} \to \End_{S_\infty}(M^{\chi,I,\varsigma})$ of $S_\infty$-algebras which respect the respective actions of $R_0^{1,I,\varsigma}$ and $R_0^{\chi,I,\varsigma}$ on $M^{1,I,\varsigma}$ and $M^{\chi,I,\varsigma}$

* Isomorphisms $M_\infty^{1,I,\varsigma}/\lambda M_\infty^{1,I,\varsigma} \cong M_\infty^{\chi,I,\varsigma}/\lambda M_\infty^{\chi,I,\varsigma}$ respecting <ref> and $M^{1,I,\varsigma}/\lambda M^{1,I,\varsigma} \cong M^{\chi,I,\varsigma}/\lambda M^{\chi,I,\varsigma}$
respecting <ref>, which are also compatible with <ref> and <ref>.

The modules $M_\infty^{1,I,\varsigma}$ and $M_\infty^{\chi,I,\varsigma}$ satisfy the following properties:

* If $\#I = 0$ then $M_\infty^{1,I,\varsigma}$ and $M_\infty^{\chi,I,\varsigma}$ are free $S_\infty$-modules

* If $\#I = 1$ then $M_\infty^{1,I,\varsigma}$ and $M_\infty^{\chi,I,\varsigma}$ are balanced $S_\infty$-modules, in the sense of <cit.>

* $M_\infty^{1,I,\varsigma}$ (resp. $M_\infty^{\chi,I,\varsigma}$) is a maximal Cohen–Macaulay module over $R_\infty^{1,I,\varsigma}$ (resp. $R_\infty^{\chi,I,\varsigma}$).

The existence of the stated data satisfying properties <ref> and <ref> follows in the same way as in <cit.> with our above setup in place.
In order to satisfy the patching criteria of <cit.>, we are appealing to Theorem <ref>, Proposition <ref> and Proposition <ref>, which are the direct analogues of the corresponding statements of [5].

It remains to show <ref>, which is the statement corresponding to <cit.>.
The same proof would go through, provided we have the analogue of <cit.>:

\begin{equation} \label{numerical coincidence}
\dim (R_\infty^{1,I,\varsigma})' = \dim (R_\infty^{\chi,I,\varsigma})' = \dim S_\infty - \# I.
\end{equation}

The same argument still shows that $S_\infty$ is formally smooth over $\LI$ of relative dimension $t + 11\#S - 1$, while $(R_\infty^{1,I,\varsigma})'$ and $(R_\infty^{\chi,I,\varsigma})'$ are both equidimensional of relative dimension $g + 10\#S + 4[F : Q] - \#I$ over $\LI$.
Since $g = t - 4 [F:Q] + \#S - 1$, the equalities in <ref> hold and we are done.

§.§ Modularity results for abelian surfaces

We can now use the patched modules of Proposition <ref> to prove modularity lifting theorems, by exactly the same methods of [5].
From the work of the previous sections, this amounts to replacing the vastness assumptions on $\bar{\rho}$ by our assumption that $\bar{\rho}$ is $\GSp_4$-reasonable.
The following is the analogue of <cit.>, and is a more precise version of Theorem <ref> stated in the introduction.

Let $F$ be a totally real field in which $p \geq 3$ splits completely.
Suppose that $\rho:G_F \to \GSp_4(\Qpbar)$ is a continuous Galois representation satisfying:

* $\nu \circ \rho = \varepsilon^{-1}$

* $\bar{\rho}$ is $\GSp_4$-reasonable and tidy in the senses of Definition <ref> and Definition <ref>

* For every $v | p$, $\restr{\rho}{G_{F_v}}$ is $p$-distinguished weight $2$ ordinary in the sense of Definition <ref>

* There exists an automorphic representation $\pi$ of $\GSp_4(\mathbb{A}_F)$ of parallel weight 2 and central character $|\cdot|^2$, ordinary in the sense of <cit.>, such that $\overline{\rho_{\pi,p}} \cong \bar{\rho}$, where $\rho_{\pi,p}$ is as in Corollary <ref>.

* For every finite place $v$ of $F$, the representations $\restr{\rho}{G_{F_v}}$ and $\restr{\rho_{\pi,p}}{G_{F_v}}$ are pure.

Then $\rho$ is modular, in the sense that there exists an ordinary automorphic representation $\pi'$ of $\GSp_4(\mathbb{A}_F)$ of parallel weight 2 and central character $|\cdot|^2$ satisfying $\rho_{\pi',p} \cong \rho$.
For every finite place $v$ of $F$ we have full local-global compatibility, in the sense that

\WD(\restr{\rho}{G_{F_v}})^{\Fss} \cong \rec_{\GT,p}(\pi'_v \otimes |\nu|^{-3/2}).

The theorem now follows from Proposition <ref> and Corollary <ref> by the same arguments used to prove <cit.>.
More precisely, one could use the two results mentioned to firstly prove analogues of <cit.> in which vastness of $\bar{\rho}$ is replaced by the assumption that $\bar{\rho}$ is $\GSp_4$-reasonable, from which the theorem would follow by the same proof word for word.

We can now apply Theorem <ref> to deduce a modularity lifting theorem for abelian surfaces.
We recall as in <cit.> that a Galois representation $\rho: G_F \to \GSp_4(\Qpbar)$ is said to be modular if there exists a cuspidal automorphic representation $\pi$ of $\GSp_4(\mathbb{A}_F)$ of parallel weight 2 and central character $|\cdot|^2$ such that $\overline{\rho_{\pi,p}} \cong \bar{\rho}$.
We then say an abelian surface $A/F$ is modular if the associated Galois representation $\rho_{A,l}$ (given by the $l$-adic cohomology group $H^1(A_{\bar{F}},\Qlbar)$) is modular for some prime number $l$.
The following modularity lifting theorem is the analogue of <cit.> with the identical proof via Theorem <ref>.

Let $A/F$ be an abelian surface such that

* $A$ has good ordinary reduction at every $v | p$

* for each $v|p$, the unit root crystalline eigenvalues $\alpha_v,\beta_v$ are distinct modulo $p$

* $A$ admits a polarization of degree prime to $p$.

Suppose that the residual Galois representation $\overline{\rho_{A,p}}$ is such that

* $\overline{\rho_{A,p}}$ is $\GSp_4$-reasonable and tidy

* $\overline{\rho_{A,p}}$ is ordinarily modular: there exists $\pi$ an automorphic representation of $\GSp_4(\mathbb{A}_F)$ for which

* $\pi$ has parallel weight $2$ and central character $|\cdot|^2$

* for every $v|p$, $\pi_v$ is ordinary

* $\overline{\rho_{A,p}} \cong \overline{\rho_{\pi,p}}$

* for every finite place $v$ of $F$, $\rho_{\pi,p}$ is pure.

Then $A$ is modular.

The assumption that $\bar{\rho}$ is tidy is still enforced in the above modularity lifting theorems.
However, due to the other assumptions on $\bar{\rho}$, only a small number of possible images $\Gamma' = \bar{\rho}(G_F)$ are ruled out in practice.
The assumptions that $p$ is unramified in $F$ and that the similitude character is given by $\varepsilon^{-1}$ imply that the image $\Gamma'$ must surject onto $\mathbb{F}_p^\times$ via the similitude character.
The intersection $\Gamma = \bar{\rho}(G_{F(\zeta_p)})$ of $\Gamma'$ with $\Sp_{4}(k)$ must also be absolutely $\GL_4$-irreducible for $\bar{\rho}$ to be $\GSp_4$-reasonable.
When $k = \mathbb{F}_3$, 22 of the 25 such possible images $\Gamma'$ are tidy, as can be seen from Table <ref>.
A similar story holds for $k = \mathbb{F}_5$ and $k = \mathbb{F}_7$ with 65/69 and 86/86 respective possible images being tidy.

Now suppose that $K/F$ is a quadratic extension by a totally real field.
One source of modular mod $p$ Galois representations comes from inductions of representations $\bar{\varrho}:G_K \to \GL_2(\mathbb{F}_q)$ for some small $q$.
While we study these inductions more closely in Section <ref>, we have included the following variation of <cit.> in this section for convenience.
In combination with Theorem <ref> it yields more explicit criteria on the mod $p$ Galois representation of an abelian surface $A/F$ under which we can establish modularity of $A$.

Let $q \in \{5,7,9\}$.
Suppose that $K/F$ is a quadratic extension by a totally real field in which $p$ is unramified and $\bar{\varrho}: G_K \to \GL_2(\mathbb{F}_q)$ is a continuous representation of determinant $\varepsilon^{-1}$ which is semistable ordinary of weight $0$, in the sense of Definition <ref>.
Let $\bar{\rho} = \Ind_{G_K}^{G_F} \bar{\varrho}: G_F \to \GSp_4(\mathbb{F}_q)$ be the induced representation with similitude character $\varepsilon^{-1}$ as in the start of Section <ref>.

* $\bar{\rho}$ is ordinarily modular, in the sense that there exists an automorphic representation $\pi$ of $\GSp_4(\mathbb{A}_F)$ such that

* $\pi$ has parallel weight $2$ and central character $|\cdot|^2$

* for every $v|p$, $\pi_v$ is ordinary

* $\bar{\rho} \cong \overline{\rho_{\pi,p}}$

* for every finite place $v$ of $F$, $\rho_{\pi,p}$ is pure.

* If for every place $v \in S_p$ which splits into places $w,w'$ of $K$ we have

\begin{equation*}
\restr{\bar{\varrho}}{G_{K_w}} \cong
\begin{pmatrix}
\chi_w & * \\
0 & \chi_w^{-1} \varepsilon^{-1}
\end{pmatrix}
\end{equation*}

with $\chi_w$ unramified and not equal to its $\Gal(K/F)$-conjugate then $\bar{\rho}$ is $p$-distinguished weight 2 ordinary.

* Suppose that $\bar{\varrho}(G_{K(\zeta_p)})$ and  $\bar{\rho}(G_{F(\zeta_p)})$ are both absolutely $\GL_n$-irreducible.
If $p=3$ suppose that $\bar{\varrho}$ is valued in $\GL_2(\mathbb{F}_p)$.
If $p=3$ or $p=5$ suppose that $\bar{\rho}(G_F)$ is not isomorphic to the group $C_2.C_2\wr C_4$ of order 128 (group ID 128,77).
Then $\bar{\rho}$ is tidy and $\GSp_4$-reasonable.

As in the proof of <cit.>, it follows from <cit.> that modularity of $\bar{\varrho}$ implies that $\bar{\varrho}$ is the mod $p$ Galois representation attached to an ordinary Hilbert modular form, and that $\bar{\rho}$ is therefore ordinarily modular by automorphic induction.
Modularity of $\bar{\varrho}$ then follows by the known cases of Serre's conjecture stated in <cit.>.
The second part can be proved in the same way as Proposition <ref>.
For the third part, tidiness follows from Lemma <ref> and $\bar{\rho}$ is $\GSp_4$-reasonable by the same computation as in the proof of Proposition <ref>.

§ INDUCTIONS FROM $\GL_2$ AND MODULARITY OF ELLIPTIC CURVES

§.§ Modularity lifting for elliptic curves

Suppose for now that $K/F$ is an arbitrary quadratic extension of number fields and that $\bar{\varrho}: G_K \to \GL_2(\Fpbar)$ is a continuous representation with $\det \bar{\varrho} = \varepsilon^{-1}$.
The induced representation
$$\bar{\rho} = \Ind_{G_K}^{G_F} \bar{\varrho}: G_F \to \GL_4(\Fpbar)$$
may be viewed as taking values in $\GSp_4(\Fpbar)$ with similitude character $\varepsilon^{-1}$.
We recall how this is done in <cit.>.
Let $V$ denote the underlying representation of $\bar{\varrho}$ and let $\sigma \in G_F \setminus G_K$.
Writing $\bar{\rho} = V \oplus \sigma V$ and choosing an arbitrary symplectic form $\wedge$ on $V$, we can extend this form to $V \oplus \sigma V$ by taking $V$ and $\sigma V$ to be orthogonal and by setting $\sigma v_1 \wedge \sigma v_2 = \varepsilon^{-1}(\sigma) v_1 \wedge v_2$.
As noted in <cit.>, this is compatible with formation of restriction of scalars of an elliptic curve $E/K$ in the sense that if $A = \Res_{K/F} E$ has associated mod $p$ Galois representation $\overline{\rho_{A,p}}$ then this is exactly the induction of the mod $p$ Galois representation $\overline{\varrho_{E,p}}$ of determinant $\varepsilon^{-1}$ given by the dual of $E[p]$.

We make some observations about $G$, the image of the induced representation $\bar{\rho}$.
Certainly $G \subset \Delta \rtimes \mathbb{Z}/2\mathbb{Z}$, where
$$\Delta = \{(A,B) \in \GL_2(\mathbb{F}_p) \times  \GL_2(\mathbb{F}_p) | \det A = \det B\} \subset \GSp_4(\mathbb{F}_p)$$

and $\mathbb{Z}/2\mathbb{Z}$ permutes the two factors of $\GL_2(\mathbb{F}_p)$.
The similitude character of $(A,B) \in \Delta$ is easily seen to be equal to $\det A = \det B$.
We then have the following lemma about tidiness of induced representations.

Let $K/F$ be a quadratic extension of number fields with $p \geq 3$ unramified in $K$.
Suppose that $\bar{\varrho}: G_K \to \GL_2(\mathbb{F}_p)$ is a continuous representation with $\det \bar{\varrho} = \varepsilon^{-1}$ such that $\bar{\varrho}(G_{K(\zeta_p)})$ is absolutely irreducible and that the induced representation $\bar{\rho} = \Ind_{G_K}^{G_F} \bar{\varrho}$ is absolutely irreducible.
If $p=3$ or $p=5$ suppose that $\bar{\rho}(G_F)$ is not isomorphic to the group $C_2.C_2\wr C_4$ of order 128 (group ID 128,77).
Then $\bar{\rho}$ is tidy.

Let $G = \bar{\rho}(G_F)$ and $\Gamma = \bar{\varrho}(G_K)$.
By Definition <ref>, $G$ is tidy if there exists $g \in G$ such that $\nu(g) \neq 1$ and for every pair of distinct eigenvalues $\alpha \neq \beta$ of $g$ we have $\frac{\alpha} { \beta} \neq \nu(g)$.
A computation in  gives the result when $p \leq 7$, so suppose throughout the rest of this proof that $p>7$.
Consider $G \cap \Delta = \bar{\rho}(G_K)$, isomorphic to a subgroup of $\Gamma \times \Gamma$ (since $\bar{\varrho}^\sigma(G_K) \cong \Gamma$, where $\Gal(K/F) = \{1,\sigma\}$).
Goursat's lemma states that subgroups of $\Gamma \times \Gamma$ with surjective projections onto the two factors of $\Gamma$ are parameterised by triples

(H_1 \triangleleft \Gamma,H_2 \triangleleft \Gamma, \varphi: \Gamma/H_1 \xrightarrow{\sim} \Gamma/H_2)

with the corresponding subgroup given by

\{(\gamma_1,\gamma_2) \in \Gamma \times \Gamma : \varphi(\gamma_1 H_1) = \gamma_2 H_2\}.

We show tidiness of $G$ by giving a lower bound on the number of elements of $G$ of the form $(\gamma_1,\gamma_2)$, where each $\gamma_i$ is a scalar matrix.

We firstly bound the order of the center of $\Gamma$ by an argument similar to <cit.>.
Since $\det \bar{\varrho} = \varepsilon^{-1}$, we have a surjection

\det: (\Gamma/Z(\Gamma))^{\mathrm{ab}} \to \mathbb{F}_p^\times/\det(Z(\Gamma)).

By the classification of subgroups of $\PGL_2(\mathbb{F}_p)$, the abelianization of $\Gamma/Z(\Gamma)$ must isomorphic to a subgroup of $(\mathbb{Z}/2\mathbb{Z})^2$ since $\Gamma$ acts absolutely irreducibly.
Thus $\det Z(\Gamma)$ must be index $2$ inside $\mathbb{F}_p^\times$.
Therefore, if $p \equiv 1 \mod 4$ we must have $Z(\Gamma) \cong \mathbb{F}_p^\times$ and otherwise we only have that $\# Z(\Gamma) \geq \frac{p-1}{2}$.

Now suppose that $H \triangleleft \Gamma$ is a normal subgroup.
We consider the possibilities for the index of the image of $Z(\Gamma)$ inside of $Z(\Gamma/H)$.
The short exact sequence of groups

\begin{equation} \label{SES of groups}
1 \to Z(\Gamma) H/H \to \Gamma/H \to \Gamma/(Z(\Gamma) H) \to 1
\end{equation}

implies that $[Z(\Gamma/H): Z(\Gamma) H/H] \mid \# Z(\Gamma/(Z(\Gamma) H))$.
Thus we need to compute the possibilities for the center of a quotient of an irreducible subgroup of $\PGL_2(\mathbb{F}_p)$.
If $\Gamma$ is projectively dihedral then any quotient will either be $D_{2n}$ (where $n \geq 1$) or trivial.
Hence in that case $Z(\Gamma/(Z(\Gamma) H))$ is isomorphic to a subgroup of $(\mathbb{Z}/2\mathbb{Z})^2$.
Otherwise, $Z(\Gamma/(Z(\Gamma) H))$ must be trivial unless $\Gamma/Z(\Gamma)$ is isomorphic to either $A_4$ or $S_4$.
In the case of $A_4$, $Z(\Gamma/(Z(\Gamma) H))$ must have order 1 or 3.
In the case of $S_4$, $Z(\Gamma/(Z(\Gamma) H))$ must have order 1 or 2.

Now suppose that $G \cap \Delta$ is defined (on fixing an isomorphism $\Gamma \cong \bar{\varrho}^\sigma(G_K)$) by subgroups $H_1,H_2 \triangleleft \Gamma$ and an isomorphism $\varphi: \Gamma/H_1 \xrightarrow{\sim} \Gamma/H_2$.
Then $\varphi$ restricts to an isomorphism $Z(\Gamma/H_1) \xrightarrow{\sim} Z(\Gamma/H_2)$.
Consider the following diagram

\begin{tikzcd}
&                                               & Z(\Gamma/H_1)                                                                                &                                                            \\
Z(\Gamma) \arrow[r, two heads]               & Q_1 \arrow[ru, " \leq 4"', hook] &                                                                                & \varphi^{-1}(Q_2) \arrow[lu, " \leq 4", hook] \\
Z \arrow[rr, two heads] \arrow[u, "m", hook] &                                               & Q_1 \cap \varphi^{-1}(Q_2) \arrow[ru, hook] \arrow[lu, "m \leq 4", hook] &
\end{tikzcd}

* $Q_i = Z(\Gamma)H_i/H_i$ for $i=1,2$,

* $Z \leq Z(\Gamma)$ is the preimage of $Q_1 \cap \varphi^{-1}(Q_2)$
under the quotient map $Z(\Gamma) \twoheadrightarrow Q_1$,

and where the labels on the arrows describe the index of an inclusion of subgroups.
It follows from the above paragraph that
$$m = [Z(\Gamma): Z] = [Q_1: Q_1 \cap \varphi^{-1}(Q_2)] \leq 4.$$

In the case where $Z(\Gamma/(Z(\Gamma) H_1)) \cong (\mathbb{Z}/2\mathbb{Z})^2$ we claim that $m \leq 2$ (possibly on interchanging $H_1$ and $H_2$).
Indeed, suppose not and note firstly that $\Gamma/(Z(\Gamma) H_1)$ must be isomorphic to $(\mathbb{Z}/2\mathbb{Z})^2$ in order for its center to be order $4$.
The short exact sequence <ref> then gives that $\Gamma/H_1$ is given by an extension of $(\mathbb{Z}/2\mathbb{Z})^2$ by a central subgroup isomorphic to $\mathbb{Z}/k\mathbb{Z}$ for some $k \geq 1$.
We deduce that $Z(\Gamma/H_1)$ is isomorphic to one of

\mathbb{Z}/k \mathbb{Z}, \quad \mathbb{Z}/k \mathbb{Z} \oplus \mathbb{Z}/2\mathbb{Z}, \quad \mathbb{Z}/2k \mathbb{Z} \oplus \mathbb{Z}/2\mathbb{Z} \quad \text{or} \quad \mathbb{Z}/k \mathbb{Z} \oplus (\mathbb{Z}/2\mathbb{Z})^2.

Since $m=4$, the cyclic subgroups $Q_1$ and $\varphi^{-1}(Q_2)$ must both be of index $4$ with intersection of index $16$ (else we could interchange $H_1$ with $H_2$ and get $m \leq 2$).
These subgroups therefore generate $Z(\Gamma/H_1)$.
Since $Z(\Gamma/H_1)$ cannot be generated by two cyclic subgroups of index $4$ when $\# Z(\Gamma/H_1)$ is divisible by $16$ by consideration of the cases above, we deduce that we always have $m \leq 3$.

From the definition of $Z$, for each $A \in Z$ there exists $B \in Z(\Gamma)$ with $g = \diag(A,B) \in G$.
Since $A$ and $B$ are both scalar matrices, we must have $B = \pm A$ in order for the equality $\det A = \det B$ to hold.
Hence if $\alpha \neq \beta$ are distinct eigenvalues of $g$ then their ratio must be $-1$.
Thus if $Z$ is not a $2$-group then $G$ is tidy.
If $Z$ is a $2$-group of order at least $8$ then either $Z$ contains an element with a primitive $8$th root of unity as an eigenvalue or $G$ contains an element of the form $\zeta_4 I$ where $\zeta_4$ is a primitive $4$th root of unity.
We deduce that if the order of $Z$ does not divide 4 then $G$ is tidy.

We saw above that $Z$ is a subgroup of $Z(\Gamma)$ of index at most $3$.
If $p \equiv 3 \mod 4$ then we need $6$ to not be divisible by $p-1$ to guarantee that $\#Z$ does not divide $4$; this holds since $p > 7$.
If $p \equiv 1 \mod 4$ then $Z(\Gamma) \cong \mathbb{F}_p^\times$ and $Z$ is a subgroup of $\mathbb{F}_p^\times$ of index at most $3$.
We therefore need to eliminate the cases that $(p-1) | 8$ or $(p-1)|12$.
Since $p > 5$, the only case left to consider then is when $p=13$ and $\Gamma/Z(\Gamma) \cong A_4$.
Another computation in  shows that all such subgroups are necessarily tidy.

Now continue, as in Section <ref>, to fix $p \geq 3$ a prime which splits completely in a totally real field $F$, and fix a quadratic extension $K/F$ in which $p$ is unramified.
Continue to let $S_p$ denote the set of places of $F$ dividing $p$.
We recall the idea of twisting $\bar{\varrho}: G_K \to \GL_2(\mathbb{F}_p)$ by a quadratic character in order to ensure that the induction $\bar{\rho}$ has sufficiently large image (as in <cit.>), which is the content of the following propositions.

Let $L/K$ be an arbitrary finite extension and $\Sigma \subset \{v \in S_p | v \text{ splits in } K\}$.
There exists a finite extension $H/K$ with the following properties.

* $H/F$ is Galois with group $\Gal(H/F) \cong D_8$, the dihedral group of order 8

* $\Gal(H/K) \cong (\mathbb{Z}/2\mathbb{Z})^2$

* $H$ is the Galois closure over $F$ of a quadratic extension $M/K$

* For each $v | p$, $H/F$ is unramified at $v$

* For each $v | p$, $\Frob_v \in \Gal(H/F)$ is central if and only if $v \in \Sigma$

* $H/K$ is disjoint from $L$.

We follow the proof of <cit.>, with the above statement being a modification only in properties <ref> and <ref>.
In that proof an intermediate extension $F(\sqrt{\beta})$ is introduced, where $\beta = x^2 - \alpha y^2 \not\in (F^*)^2$ for some $x,y \in F$ and $K= F(\sqrt{\alpha})$.
The field $M$ is then taken to be $K(\sqrt{x + y\sqrt{\alpha}})$.

We deviate from this proof by choosing $\beta$ so that, for $v \in S_p$, $\beta \mod v$ is a quadratic residue if and only if $v \in \Sigma$.
We then see that $v \in \Sigma$ will split in the compositum $F(\sqrt{\beta}) \cdot K$, which we saw is the fixed field of the center of $\Gal(H/F)$.
Thus $\Frob_v$ is necessarily central if $v \in \Sigma$ and the remaining parts of the proposition follow in almost the same way by appropriate choice of $x$ and $y$.

Let $\bar{\varrho}: G_K \to \GL_2(\mathbb{F}_p)$ be a continuous representation with determinant $\varepsilon^{-1}$.
Let $L/K$ be such that $\ker(\bar{\varrho}) \cap \ker(\bar{\varrho}^\sigma) = G_L$, where $ \Gal(K/F) = \{1,\sigma\}$.
Let $\Sigma \subset \{v \in S_p | v \text{ splits in } K\}$.
Form the extension $H/K$ as in Proposition <ref>, disjoint from $L/K$.
Let $\delta_{M/K}$ be the character of $G_K$ associated to the arising quadratic extension $M/K$ and let $\bar{\rho} = \Ind_{G_K}^{G_F} (\bar{\varrho} \otimes \delta_{M/K})$.
Suppose that $\bar{\varrho}(G_K) \cap \SL_2(G_K) = \bar{\varrho}(G_{K(\zeta_p)})$ is absolutely irreducible.
Then $\bar{\rho}$ is $\GSp_4$-reasonable.

Let $\Gamma = \bar{\varrho}(G_K)$ and let $G = \bar{\rho}(G_F)$.
We show absolute $\GL_4$-irreducibility of $G \cap \Sp_4(\mathbb{F}_p)$.
Since $\Gamma \cap \SL_2(\mathbb{F}_p)$ is absolutely irreducible, it suffices to note that $\restr{\bar{\rho}}{G_{K(\zeta_p)}}$ is not isomorphic to its conjugate under an element of $\sigma \in G_{F(\zeta_p)} \setminus G_{K(\zeta_p)}$.
This follows, as such a $\sigma$ necessarily acts non-trivially on the character $\delta_{M(\zeta_p)/K(\zeta_p)}$.

We see by Lemma <ref> that $G$ is automatically $\GSp_4$-adequate if $p > 5$, and therefore $\bar{\rho}$ is $\GSp_4$-reasonable by Lemma <ref>.
Hence suppose that $p=3$ or $p=5$ and consider those subgroups $G_{\text{bad}} \subset \GSp_4(\mathbb{F}_p)$ for which

* $G_{\text{bad}} \cap \Sp_4(\mathbb{F}_p)$ is absolutely $\GL_4$-irreducible

* $G_{\text{bad}}$ surjects onto $\mathbb{F}_p^\times$ via the similitude character

* there exists an index 2 subgroup $G_{\text{bad}}' \leq G_{\text{bad}}$ such that $G_{\text{bad}}' \subset \GL_4(\mathbb{F}_p)$ is reducible over $\mathbb{F}_p$

* at least one of the following hold

* $H^1(G_{\text{bad}} \cap \Sp_4(\mathbb{F}_p), \mathbb{F}_p) \neq 0$

* $H^1(G_{\text{bad}} \cap \Sp_4(\mathbb{F}_p),\splie_4) \neq 0$.

Any other possible image will be $\GSp_4$-adequate and hence our $\bar{\rho}$ will still be $\GSp_4$-reasonable.

As computed in , the only failure of vanishing of the above cohomology groups when $p=3$ is the existence of such subgroups $G_{\text{bad}}$ for which $H^1(G_{\text{bad}} \cap \Sp_4(\mathbb{F}_p), \mathbb{F}_p) \neq 0$ (as in all cases $H^1(G_{\text{bad}} \cap \Sp_4(\mathbb{F}_p),\splie_4) = 0$).
By <cit.>, to show that $\bar{\rho}$ is $\GSp_4$-reasonable in these cases, it suffices to check that for every normal subgroup $H_{\text{bad}} \subset G_{\text{bad}} \cap \Sp_4(\mathbb{F}_p)$ of index 3 or index 9 we have $H^1(H_{\text{bad}},\splie_4) = 0$ and $H_{\text{bad}}$ is absolutely $\GL_4$-irreducible.
A further computation shows that this is always the case.

When $p=5$, the failure occurs from subgroups for which $H^1(G_{\text{bad}} \cap \Sp_4(\mathbb{F}_p),\splie_4) \neq 0$, with the other cohomology group vanishing.
A further computation then shows that the image in $\PGSp_4(\mathbb{F}_p)$ of every such subgroup $G_{\text{bad}}$ does not admit a surjective quotient onto $\mathbb{Z}/4\mathbb{Z}$.
It follows, just as in <cit.>, that $\zeta_p$ cannot lie in the fixed field of the adjoint action on $\splie_4$ and that $\bar{\rho}$ is therefore $\GSp_4$-reasonable.

Suppose that $A \in \CNL_{\CalO}$ and $\varrho: G_K \to \GL_2(A)$ is a continuous representation.
We say that $\varrho$ is semistable ordinary of weight $0$ if for every place $w | p$ of $K$ there is an isomorphism

\begin{equation} \label{gl2 ordinary}
\restr{\varrho}{G_{K_w}} \cong
\begin{pmatrix}
\chi_w & * \\
0 & \chi_w^{-1} \varepsilon^{-1}
\end{pmatrix}
\end{equation}

for some unramified character $\chi_w: G_{K_w} \to A^\times$.

Suppose that we are in the setup of Proposition <ref>.
Let $A \in \CNL_\CalO$ and let $\varrho: G_K \to \GL_2(A)$ be a lift of $\bar{\varrho}$ which is semistable ordinary of weight $0$.
For $w | p$, let $\chi_w: G_{K_W} \to A^\times$ denote the character defining the eigenvalue of the image of Frobenius, as in (<ref>) and let
$\overline{\chi_w}: G_{K_w} \to \Fpbar^\times$ be the reduction of $\chi_w$ modulo the maximal ideal of $A$.
$$\Sigma = \{v \in S_p | v = w w' \text{ in } K \text{ and } \overline{\chi_w} \neq (\overline{\chi_{w'}})^\sigma \},$$
where $\sigma \in G_F \setminus G_K$.
Then the induced representation
$$\rho = \Ind_{G_K}^{G_F} (\varrho \otimes \delta_{M/K})$$
is $p$-distinguished weight $2$ ordinary, in the sense of Definition <ref>.

Suppose $v \in S_p$ is inert in $K$ firstly and let $w$ be the unique place of $K$ above $v$.
Then $\restr{\rho}{G_{F_v}} = \Ind^{G_{F_v}}_{G_{K_w}} \restr{(\varrho \otimes \delta_{M/K})}{G_{K_w}}$.
This has the desired form, with the unramified characters defining the diagonal entries being given by the two choices of extensions of $\chi_w$ to $G_{F_v}$ (which differ by a sign on $\Frob_v \in G_{F_v}$).

Now suppose that $v \in S_p$ splits as $v = w w'$ in $K$, so that there are isomorphisms $F_v \cong K_w$ and $F_v \cong K_{w'}$ interchanged via $\sigma$.
Then $\restr{\rho}{G_{F_v}} = \restr{\varrho}{G_{K_w}} \oplus \restr{(\varrho^{\sigma})}{G_{K_w}}$.
This has the required form, provided that the mod $p$ reduction of these summands, $\restr{\bar{\varrho}}{G_{K_w}}$ and $\restr{(\bar{\varrho}^{\sigma})}{G_{K_w}}$, are not isomorphic.
Thus it suffices to show that the characters $\overline{\chi_w} \otimes \restr{ \delta_{M/K}}{G_{K_w}}$ and $(\overline{\chi_{w'}} \otimes \restr{ \delta_{M/K}}{G_{K_{w'}}})^\sigma $ are not equal.
By choice of $\Sigma$, the following are equivalent

* $v \in \Sigma$

* $\restr{\delta_{M/K}}{G_{K_w}} =(\restr{ \delta_{M/K}}{G_{K_{w'}}}) ^\sigma$

* $\overline{\chi_w} \neq (\overline{\chi_{w'}})^\sigma$

and we are therefore done.

Now let $E/K$ be an elliptic curve.
The curve $E$ is said to be modular if there exists a cuspidal automorphic representation $\boldsymbol{\pi}$ of $\GL_2(\mathbb{A}_K)$ of weight 0 (see <cit.>) and trivial central character such that $\varrho_{E,p} \cong \varrho_{\boldsymbol{\pi},p}$.
Here $\varrho_{E,p}$ is the Galois representation given by the $p$-adic cohomology group $H^1(E_{\overline{K}},\Qpbar)$ and the Galois representation $\varrho_{\boldsymbol{\pi},p}$ attached to $\boldsymbol{\pi}$ is as in <cit.>.
Similarly, we say an irreducible representation $\bar{\varrho}: G_K \to \GL_2(\Fpbar)$ is modular if there exists such a $\boldsymbol{\pi}$ as above with $\overline{\varrho} \cong \overline{\varrho_{\boldsymbol{\pi},p}}$.
We also say $\bar{\varrho}$ is ordinarily modular if we can take such a $\boldsymbol{\pi}$ as above which is also semistable weight 0 ordinary, in the sense that there exists, for every place $w|p$ of $K$, a non-zero eigenvector in $\boldsymbol{\pi}_w^{\mathrm{Iw}_w}$ whose eigenvalues under the Hecke operators

\begin{align*}
U_w^1 &= [\mathrm{Iw}_w \diag(\varpi_w,1) \mathrm{Iw}_w] \\
U_w^2 &= [\mathrm{Iw}_w \diag(\varpi_w,\varpi_w) \mathrm{Iw}_w]
\end{align*}

lie in $\Zpbar^\times$ (under our fixed isomorphism $\iota: \mathbb{C} \cong \Qpbar$).
Here $\varpi_w$ is a uniformizer of $K_w$ and $\mathrm{Iw}_w$ is the standard Iwahori subgroup of $\GL_2(K_w)$ given by those matrices in $\GL_2(\CalO_{K_w})$ whose reduction modulo $\varpi_w$ is upper triangular.

We now apply Theorem <ref> to the mod $p$ Galois representation attached to $\Res_{K/F} E$ together with our above results to deduce a modularity lifting theorem for $E$ under mild conditions on the image of $\overline{\varrho_{E,p}}$.
This is an attempt at a generalization of <cit.>.

Let $F$ be a totally real field in which $p \geq 3$ splits completely and let $K/F$ be a quadratic extension in which $p$ is unramified with Galois group $\{1,\sigma\}$.
Let $E/K$ be an elliptic curve and let $\bar{\varrho} = \overline{\varrho_{E,p}}$ be the attached mod $p$ Galois representation of determinant $\varepsilon^{-1}$.
Suppose that the following conditions hold:

* $E$ has ordinary good reduction or multiplicative reduction at every place $w | p$

* $\bar{\varrho}(G_{K(\zeta_p)})$ is absolutely irreducible

* $\bar{\varrho}$ is ordinarily modular

* if $p = 3$ or $p=5$ then order of the subgroup of $\GL_2(\mathbb{F}_p) \times \GL_2(\mathbb{F}_p)$ generated by the image of $\bar{\varrho} \oplus \bar{\varrho}^\sigma$ together with the matrices $\diag(I,-I), \diag(-I,I)$ is not equal to $64$.

Then $E$ is modular.

Since $E$ has ordinary good reduction or multiplicative reduction at every place $w | p$, the representation $\varrho_{E,p}$ is semistable ordinary of weight $0$.
Thus we may form the induction $\bar{\rho} = \Ind_{G_K}^{G_F} (\bar{\varrho} \otimes \delta_{M/K})$ by taking $\Sigma$ as in Proposition <ref> and then taking $M/K$ as in Proposition <ref> for this choice of $\Sigma$ and $\bar{\varrho}$.
This is the mod $p$ reduction of the Galois representation attached to the abelian surface $A = \Res_{K/F} E'$, where $E'/K$ is the quadratic twist of $E$ corresponding to $\delta_{M/K}$.
Modularity of $\rho = \rho_{A,p}$ then implies modularity of $E'$, just as in the proof of <cit.>, and hence modularity of $E$.
So we just have to show that $\rho$ satisfies the hypotheses of Theorem <ref> to deduce modularity of $E$.

We see from Proposition <ref> that $\bar{\rho}$ is $\GSp_4$-reasonable.
By Lemma <ref>, we see that $\bar{\rho}$ is tidy, except possibly if $p \leq 5$ and $\# \bar{\rho}(G_F) = 128$.
The image of $\restr{\bar{\rho}}{G_K}$ is exactly the subgroup of $\GL_2(\mathbb{F}_p) \times \GL_2(\mathbb{F}_p)$ generated by the image of $\bar{\varrho} \oplus \bar{\varrho}^\sigma$ and the matrices $\diag(I,-I), \diag(-I,I)$, since the extensions of $K$ given by the Galois closure of $M/F$ and the fixed field of $\ker(\bar{\varrho} \oplus \bar{\varrho}^\sigma)$ are linearly disjoint by Proposition <ref>.
Since $\bar{\rho}(G_K)$ is an index $2$ subgroup of $\bar{\rho}(G_F)$, it follows from our hypotheses that $\bar{\rho}(G_F)$ does not have order $128$ and $\bar{\rho}$ is therefore tidy.

As in the proof of <cit.> we can find, by automorphic induction and our assumption that $\bar{\varrho}$ is ordinarily modular, a parallel weight 2 automorphic representation $\pi$ of $\GSp_4(\mathbb{A}_F)$ of central character $|\cdot|^2$ which is ordinary at all $v | p$ such that $\overline{\rho_{\pi,p}} \cong \bar{\rho}$ and with $\rho_{\pi,p}$ pure.
By Proposition <ref>, we see that $\rho$ is $p$-distinguished weight $2$ ordinary.
Purity of $\rho$ follows from <cit.>.
Thus all of the hypotheses of Theorem <ref> hold for $\rho$ and we are done.

§.§ Projectively dihedral representations

One case amenable to establishing modularity of $\bar{\varrho}$ directly is when the projective image of $\bar{\varrho}$ is dihedral, in which case we can find a quadratic extension $L/K$ and a character $\bar{\psi}: G_L \to \Fpbar^\times$ such that $\bar{\varrho} \cong \Ind_{G_L}^{G_K} \bar{\psi}$.
We wish to control the Hodge–Tate weights of a lift $\psi: G_L \to \Zpbar^\times$ and use automorphic induction to deduce that $\bar{\varrho}$ is ordinarily modular.
This motivates the following definition.

Let $K/F$ be a quadratic extension of number fields in which $p \geq 3$ is unramified.
We say a continuous Galois representation $\bar{\varrho}: G_K \to~ \GL_2(\Fpbar)$ is CM-compositum induced if $\bar{\varrho}(G_{K(\zeta_p)})$ is absolutely irreducible with $\det \bar{\varrho} = \varepsilon^{-1}$ and there exists

* an imaginary CM quadratic extension $F'/F$, disjoint from $K/F$

* a continuous character $\bar{\psi}: G_L \to \Fpbar^\times$, where $L= F' \cdot K$ is the compositum

such that

* each place $w|p$ of $K$ splits in $L$

* for every place $z | p$ of $L$ there exists an unramified character $\overline{\chi_z}: G_{L_z} \to \Fpbar^\times$ with $\{\restr{\bar{\psi}}{G_{L_z}}, \restr{\bar{\psi}^\sigma}{G_{L_{z}}}\} = \{ \overline{\chi_z}, \overline{\chi_z}^{-1} \varepsilon^{-1} \}$, where $\Gal(L/K) = \{1,\sigma\}$

* $\bar{\varrho} \cong \Ind_{G_L}^{G_K} \bar{\psi}$.

Note that if such an extension $F'/F$ in Definition <ref> exists then it is unique.
There are then two choices of $\bar{\psi}$, which are conjugate under $\sigma$ and whose product is the inverse cyclotomic character.
We also observe that if $k$ is a finite field and $\bar{\varrho}$ is CM-compositum induced and conjugate to a representation valued in $\GL_2(k)$, then $\bar{\psi}$ is also valued in $k^\times$.
Indeed, letting $q = \# k$ we must have $\{\bar{\psi},\bar{\psi}^\sigma \} = \{\bar{\psi}^q,(\bar{\psi}^\sigma)^q \}$ by considering $\restr{\bar{\varrho}}{G_L}$ and the action of Frobenius.
On the other hand we must also have that $\bar{\psi}^\sigma \neq \bar{\psi}^q$ due to condition <ref>.
In particular, there can never exist a CM-compositum induced representation valued in $\GL_2(\mathbb{F}_3)$, since $\bar{\psi}$ would have image of order at most 2 and thus $\bar{\varrho}(G_{K(\zeta_p)})$ would have order at most $4$ (noting that $D_8 \subset \PGL_2(\mathbb{F}_3)$ is irreducible over $\mathbb{F}_3)$.
In what follows, if $\bar{\varrho}$ is CM-compositum induced then we shall use notation as in Definition <ref>.

Suppose that $F$ is a totally real field and $K/F$ is a quadratic extension in which $p \geq 3$ is unramified.
Suppose that $\bar{\varrho}: G_K \to \GL_2(\Fpbar)$ is CM-compositum induced.

* for every place $w | p$ of $K$ there is an isomorphism

\restr{\bar{\varrho}}{G_{K_w}} \cong
\begin{pmatrix}
\overline{\chi_w} & 0 \\
0 & \overline{\chi_w}^{-1} \varepsilon^{-1}
\end{pmatrix}

for some unramified character $\overline{\chi_w}: G_{K_w} \to \Fpbar^\times$

* $\bar{\varrho}$ is ordinarily modular.

If $w | p$ is a place of $K$ then by Definition <ref> $w$ splits in $L$ into places $z,z'$ and we can find an unramified character $\overline{\chi_z}: G_{L_z} \to \Fpbar^\times$ such that $\restr{\bar{\psi}}{G_{L_z}} = \overline{\chi_z}$ and $\restr{\bar{\psi}}{G_{L_{z'}}} = (\overline{\chi_z}^{-1})^\sigma \varepsilon^{-1}$.
It follows that $\bar{\varrho}$ is of the required form for the first part of the proposition.
Next observe that $z$ and $z'$ lie above distinct places of $F'$ (as if $v$, the place of $F$ below $w$, splits completely in $L$ then the action of $\Gal(L/F)$ is transitive on the places of $L$ above $v$, but $\{z,z'\}$ would be an orbit if these places both lie over the same places of $K$ and $F'$).
We claim that we can find an algebraic $p$-adic character $\varphi: G_L \to \Zpbar^\times$ such that $\bar{\varphi}$ differs from $\bar{\psi}$ by a character which is unramified at the places dividing $p$.
Indeed, suppose that for every $\tau: F' \to \Qpbar$ we have $k_\tau \in \{0,1\}$ satisfying $k_{\tau} + k_{\tau \circ c} =1$ with $c \in \Gal(F'/F)$ complex conjugation.
Then we can find a character of $G_{F'}$ with Hodge–Tate weights $\{k_\tau\}_{\tau}$ since $F'/F$ is a quadratic extension of a totally real field by an imaginary CM field (by <cit.>, for example).
Composing such a character with the inclusion $G_L \to G_{F'}$ yields the desired $\varphi$ by our above observation about the places of $L$ dividing $p$ in relation to those of $F'$ and $K$.

Now let $\theta: \Fpbar^\times \to \Zpbar^\times$ be the Teichmuller map and let $\psi = \varphi \cdot \theta(\bar{\psi}/\bar{\varphi})$, an algebraic lift of $\bar{\psi}$.
Let $\psi^\vee : \mathbb{A}_L^\times \to \mathbb{C}^\times$ denote the algebraic Hecke character corresponding to $\psi$.
Then the automorphic induction of $\psi^\vee \otimes |\cdot |^{1/2}$ to $\GL_2(\mathbb{A}_K)$ is a weight $0$ cuspidal automorphic representation $\boldsymbol{\pi}$ with trivial central character for which the attached Galois representation $\varrho_{\boldsymbol{\pi},p}$ lifts $\bar{\varrho}$.
Moreover, for $w|p$ a place of $K$, $\boldsymbol{\pi}_w$ can be identified with $(\psi^\vee_z \otimes | \cdot ~| ^{1/2}) \boxplus (\psi^\vee_{z'} \otimes | \cdot | ^{1/2})$ and we shall distinguish $z$ from $z'$ by supposing that $\restr{\psi}{I_{L_z}}$ is trivial.
Since $\psi^\vee$ is unramified at places dividing $p$ by construction, $\boldsymbol{\pi}_w$ is Iwahori-spherical and there exists an eigenvector whose eigenvalues $u_w^i$ under the operators $U_w^i$ have $p$-adic valuation given by

\begin{align*}
v_p(u_w^1) &= v_p(\iota (\psi^\vee_z \otimes |\cdot|^{1/2}) (\varpi_w)) - \sum_{\tau: K \hookrightarrow \mathbb{C}, \iota \tau = w} \frac{1}{2} \\
v_p(u_w^2) &= v_p( \iota (\psi^\vee_{z'} \otimes |\cdot|^{1/2}) (\varpi_w)) - (\sum_{\tau: K \hookrightarrow \mathbb{C}, \iota \tau = w} -\frac{1}{2}) + v_p(u_w^1)
\end{align*}

by (the proof of) <cit.>.
Here $\iota: \mathbb{C} \xrightarrow{\sim} \Qpbar$ was our fixed choice of isomorphism and we have identified embeddings $K \to \Qpbar$ with places of $K$ dividing $p$.

We compute $v_p( \iota \psi^\vee_{z'}(\varpi_{z'}))$; the computation for $z$ is similar.
Choose $\alpha \in L^\times$ whose valuation is non-zero only at the place $z'$ and equal to some $m > 0$.
Raising $\alpha$ to a sufficiently large power, we can suppose that $\psi^\vee_{v}(\alpha) = 1$ for every finite place $v \neq z'$ and $\psi^\vee_{z'}(\alpha) = \psi^\vee_{z'}(\varpi_{z'}^m)$.
Then $v_p( \iota \psi^\vee_{v}(\alpha)) = - v_p( \iota \psi^\vee_{\infty}(\alpha))$ since $\psi^\vee$ is trivial on $L^\times$.
We have $\psi^\vee_{\infty}(\alpha) = \prod_{\tau: L \to \mathbb{C}} \tau(\alpha)^{n_\tau}$ where $n_{\tau} = -1$ for every $\tau: L \to \mathbb{C}$ inducing the place $z'$ via $\iota$, since we supposed that $\restr{\psi^\vee}{I_{L_{z'}}} = \varepsilon^{-1}$.
We see that
$$v_p(\iota \psi^\vee_{\infty}(\alpha)) = \sum_{\tau: L \hookrightarrow \mathbb{C}} m \cdot (-1)$$
where the sum is over complex embeddings $\tau$ of $L$ whose composition with $\iota$ induces the place $z'$ (as $v_p(\iota(\tau(\alpha))) = 0$ for any $\tau$ not inducing the place $z'$ by choice of $\alpha$).
We deduce that
$$v_p( \iota (\psi^\vee_{z'} \otimes |\cdot|^{1/2}) (\varpi_w)) = - f_w + f_w/2$$
and similarly that
$$v_p( \iota (\psi^\vee_{z} \otimes |\cdot|^{1/2}) (\varpi_w)) = 0 + f_w/2,$$
where $f_w = |K_w:\mathbb{Q}_p|$.
Thus $v_p(u_w^1) = v_p(u_w^2) = 0$, which shows the second point and concludes the proof.

We deduce a modularity theorem for some elliptic curves over $K$ with CM-compositum induced Galois representation.

Let $F$ be a totally real field in which $p \geq 7$ splits completely and let $K/F$ be a quadratic extension in which $p$ is unramified.
Suppose that $E/K$ is an elliptic curve which has ordinary good reduction or multiplicative reduction at every place $w | p$ and that $\overline{\varrho_{E,p}}$ is CM-compositum induced in the sense of Definition <ref>.
Then $E$ is modular.

This follows immediately from Theorem <ref> and Proposition <ref>.

In order to apply Theorem <ref> we required the elliptic curve $E/K$ to have ordinary good reduction or multiplicative reduction at the places dividing $p$.
We show that this automatically holds in some cases when $\overline{\rho_{E,p}}$ is CM-compositum induced.

Let $p \geq 5$ be a prime number with $p \equiv 2 \mod 3$ and let $K/\mathbb{Q}_p$ be a finite unramified extension.
Suppose that $E/K$ is an elliptic curve such that there is an isomorphism

\overline{\varrho_{E,p}} \cong
\begin{pmatrix}
\overline{\chi} & 0 \\
0 & \overline{\chi}^{-1} \varepsilon^{-1}
\end{pmatrix}

over $\mathbb{F}_p$, where $\overline{\chi}: G_K \to \mathbb{F}_p$ is an unramified character.

* if $p \geq 11$ then either $E$ has  multiplicative reduction or ordinary good reduction

* if $p=5$ then either $E$ has multiplicative reduction, or the degree of a minimal totally ramified extension over which $E$ acquires good reduction is either $1$ or $4$ and $E$ acquires ordinary good reduction over this extension.

Let $v$ be the valuation on $K$ and suppose firstly that $v(j(E)) < 0$, so that $E$ has potentially multiplicative reduction.
Then $E$ is the quadratic twist of an elliptic curve $A/K$ with split multiplicative reduction by a quadratic character $\delta: G_K \to \{\pm 1\}$.
The mod $p$ Galois representation of $A$ is, on the one hand, the twist of $\overline{\varrho_{E,p}}$ by $\delta$ and thus can be written as a direct sum of the characters $\overline{\chi} \delta$ and $\overline{\chi}^{-1} \delta \varepsilon^{-1}$.
On the other hand, since $A$ has split multiplicative reduction we have an isomorphism
$$\restr{\overline{\varrho_{A,p}}}{I_K} \cong \begin{pmatrix}
1 & * \\
0 &  \varepsilon^{-1}
\end{pmatrix}.$$

Since $\varepsilon: I_K \to \mathbb{F}_p^\times$ has order $p-1 \geq 4$, we must have that $\delta$ is unramified and that $E$ has multiplicative reduction over $K$.

Now suppose that $E$ does not have (potentially) multiplicative reduction.
The elliptic curve $E$ acquires good reduction on base change to a totally ramified extension $L/K$ of degree $e \in \{1,2,3,4,6\}$, with $E$ having bad reduction on base change to any proper subfield of $L$ containing $K$.
We can take $L = K(\varpi^{1/e})$, where $\varpi$ is any choice of uniformizer for $K$.
We firstly show that $E_L$ has ordinary good reduction.
Suppose not, so that $E_L$ has supersingular reduction.
The same argument as in the proof of <cit.> then shows that either the image of inertia under the dual representation $\overline{\varrho_{E,p}}^{\vee}(I_L)$ contains an element of order $p$, or is the given by matrices of the form

\begin{equation} \label{non split cartan subgroup}
\left\{ \begin{pmatrix}
a & \eta b \\
b & a
\end{pmatrix}^e
| (a,b) \in \mathbb{F}_p^2 \setminus \{(0,0)\} \right\}
\end{equation}

with respect to some basis for $E[p]$ and where $\eta \in \mathbb{F}_p^\times$ is a non-quadratic residue.
By hypothesis, $\overline{\varrho_{E,p}}(I_L)$ does not contain any element of order $p$ and the only scalar matrix it contains is the identity.
On the other hand, the group of matrices <ref> contains a subgroup of scalar matrices of order $p-1$ (since $(p^2-1)/e \geq p-1$, as $p \geq 5$ and $e \leq 6$) which gives a contradiction.

Next we show that $e \in \{1,2,4\}$.
Again we suppose not, so that $e \in \{3,6\}$.
This can only happen when $E$ has a Weierstrass equation of the form
$E: y^2 = x^3 + ax + b$
with $3v(A) > 2v(B)$.
In that case, a Weierstrass equation for the reduction of $E$ modulo $\varpi^{1/e}$ is given by $\tilde{E_L}: y^2 = x^3 + B$ for some $B \in \Fpbar^\times$.
This defines a supersingular elliptic curve by <cit.> since the coefficient of $x^{(p-1)/2}$ in $(x^3+B)^{p-1}$ is zero, as $p \equiv 2 \mod 3$.
We have therefore reached a contradiction since $\tilde{E}_L$ was already shown to be ordinary.

Now suppose that $e \in \{2,4\}$.
Let $K' = K(\varpi^{2/e})$, so that $L/K'$ is a ramified quadratic extension.
Then $E_{K'}$ is the quadratic twist of an elliptic curve $A/K'$ with good reduction.
It follows that

\restr{\overline{\varrho_{A,p}}}{I_{K'}} \cong
\begin{pmatrix}
\delta & 0 \\
0 & \delta \varepsilon^{-1}
\end{pmatrix}

where $\delta: I_{K'} \to \{\pm 1\}$ is the quadratic character arising from $L/K'$.
Firstly suppose that $A$ has supersingular reduction.
Again, the same argument as in <cit.> shows that $\overline{\varrho_{A,p}}^\vee(I_{K'})$ either contains an element of order $p$ or is of the form <ref> where the exponent is $e_{K'/\mathbb{Q}_p} \in \{1,2\}$.
In either case, this gives an immediate contradiction.

We are left with the case that $A$ has ordinary reduction.
The only possibility is that $\delta = \varepsilon^{-1}$ as characters of $I_{K'}$, so we must have $p=5$ and $e = 4$ since $\# \varepsilon(I_{K'}) = 2(p-1)/e$.
We deduce the desired statement when $p=5$.
When $p \geq 11$, we see that $e=1$ so that $E/K$ has good reduction and $\tilde{E}$ was already shown to be ordinary.

Let $p \geq 5$ with $p \equiv 2 \mod 3$.
Let $F$ be a totally real field in which $p$ splits completely and let $K/F$ be a quadratic extension in which $p$ is unramified.
Suppose that $E/K$ is an elliptic curve such that $\overline{\varrho_{E,p}}$ is CM-compositum induced.
If $p=5$ and $E$ has potentially good reduction suppose further that $E$ has good reduction over $K$.
Then $E$ has either ordinary good reduction or multiplicative reduction at every place $w | p$.

This is immediate from Lemma <ref> and Proposition <ref>.

We can also satisfy the constraints on $\bar{\varrho}$ in our modularity lifting theorem arising from tidiness considerations when $p=5$ by imposing a condition on $\bar{\psi}$.

Suppose that $p=5$, $\bar{\varrho}: G_K \to \GL_2(\mathbb{F}_5)$ is CM-compositum induced and let $\tau \in G_F \setminus G_K$.
If $\restr{(\bar{\psi}^2)^\tau}{G_{L(\zeta_5)}} \neq \restr{\bar{\psi}^2}{G_{L(\zeta_5)}}$ then $\bar{\rho} = \Ind_{G_F}^{G_K} (\bar{\varrho} \otimes \delta)$ is tidy whenever $\delta: G_K \to \{\pm 1\}$ is chosen such that $\bar{\rho}$ is absolutely irreducible.

We claim that it suffices to show the order of the image of $\restr{\bar{\rho}}{G_{K(\zeta_5)}} = \restr{\bar{\varrho}}{G_{K(\zeta_5)}} \oplus \restr{\bar{\varrho}^\tau}{G_{K(\zeta_5)}}$ is at least $32$.
Indeed, then $\bar{\rho}(G_F)$ would be order at least $32 \cdot 2 \cdot 4 = 256$, since $\bar{\rho}$ is absolutely irreducible and the similitude character surjects onto $\mathbb{F}_5^\times$.
It follows from Lemma <ref> that $\bar{\rho}$ is then tidy.
Since $\bar{\varrho}(G_{K(\zeta_5)})$ is necessarily of order $8$, it suffices to show that the extensions of $L(\zeta_p)$ cut out by $\restr{\bar{\varrho}}{G_{L(\zeta_5)}}$ and $\restr{\bar{\varrho}^\tau}{G_{L(\zeta_5)}}$ are linearly disjoint.
Since $\restr{\bar{\psi}^\sigma}{G_{L(\zeta_5)}} = \restr{\bar{\psi}^{-1}}{G_{L(\zeta_5)}}$, we just need to show that the extensions of $L(\zeta_5)$ cut out by $\restr{\bar{\psi}}{G_{L(\zeta_5)}}$ and $\restr{\bar{\psi}^\tau}{G_{L(\zeta_5)}}$ are linearly disjoint.
If they were not linearly disjoint, then certainly the squares of both characters would cut out the same quadratic extension of $L(\zeta_5)$, contradicting our hypothesis.

Continue to fix $F$ a totally real field in which $p \geq 5$ splits completely and $K/F$ a quadratic extension in which $p$ is unramified.
We give a construction of some CM-compositum induced representations $\bar{\varrho}: G_K \to \GL_2(\mathbb{F}_p)$.

Let $F'/F$ be the compositum of $F$ with an imaginary quadratic field $N$ which is disjoint from $K$ and in which $p$ splits completely.
Set $L= K \cdot F'$ and $\Gal(L/K) = \{1,\sigma\}$.
We wish to construct characters $\bar{\psi}: G_L \to \mathbb{F}_p^\times$ as in Definition <ref>.
We can find $\bar{\psi}$ such that for every place $z | p$ of $L$ we have $\{\restr{\bar{\psi}}{G_{L_z}}, \restr{\bar{\psi}^\sigma}{G_{L_{z}}}\} = \{1, \varepsilon^{-1} \}$ and $\bar{\psi} \bar{\psi}^\sigma = \varepsilon^{-1}$ by taking the restriction of the mod $p$ reduction of a $p$-adic algebraic character on $G_{F'}$.
We just need $\restr{\bar{\psi}}{G_{L(\zeta_p)}} \neq \restr{\bar{\psi}^\sigma}{G_{L(\zeta_p)}}$ for $\bar{\varrho} = \Ind_{G_L}^{G_K} (\bar{\psi})$ to be CM-compositum induced, so suppose this is not the case.

Suppose that $\bar{\chi}: G_L \to \mathbb{F}_p^\times$ is unramified at every place dividing $p$ and satisfies $\bar{\chi} \bar{\chi}^\sigma = 1$.
Setting $\bar{\varphi} = \bar{\psi} \bar{\chi}$, $\bar{\varrho} = \Ind_{G_L}^{G_K} (\bar{\varphi})$ will be CM-compositum induced provided that $\restr{\bar{\varphi}}{G_{L(\zeta_p)}} \neq \restr{\bar{\varphi}^\sigma}{G_{L(\zeta_p)}}$.
If $\bar{\chi}$ (and hence $\restr{\bar{\chi}}{G_{L(\zeta_p)}}$) has image of order at least $3$ then $\restr{\bar{\varphi}}{G_{L(\zeta_p)}}$ will not be equal to its conjugate, since

$$\restr{\bar{\varphi}^{-1}\bar{\varphi}^\sigma}{G_{L(\zeta_p)}} = \restr{\bar{\psi}^{-1}\bar{\psi}^\sigma}{G_{L(\zeta_p)}} \restr{\bar{\chi}^{-1}\bar{\chi}^\sigma}{G_{L(\zeta_p)}} = \restr{\bar{\chi}^{-2}}{G_{L(\zeta_p)}} \neq 1.$$

We can obtain such a $\bar{\chi}$ by considering a dihedral extension $M/K$ which contains $L$.
If $p \equiv 1 \mod 4$, then similarly to Proposition <ref> we can find an extension $M/L$ for which

* $M/K$ is Galois with $\Gal(M/K) \cong D_8$ and $\Gal(M/L) \cong \mathbb{Z}/4\mathbb{Z}$

* $p$ is unramified in $M$.

If $p \equiv 3 \mod 4$, choose an odd prime $l | (p-1)$.
Then by <cit.> (applied with $k_2$ greater than the number of rational primes which ramify in $F$) we can find a Galois extension $N'/\mathbb{Q}$ containing our imaginary quadratic field $N$ such that

* $\Gal(N'/\mathbb{Q}) = D_{2l}$ and $\Gal(N'/N) \cong \mathbb{Z}/l\mathbb{Z}$

* $p$ is unramified in $N'$

* there exists a rational prime $r$ which is unramified in $K$ and whose ramification index in $N'$ divisible by $l$.

Taking $M = N' \cdot K$, we have $\Gal(M/K) \cong D_{2l}$ with $\Gal(M/L) \cong \mathbb{Z}/l\mathbb{Z}$ and $p$ is unramified in $M$.
Then in either of the above cases let $\bar{\chi}$ be the character corresponding to $\Gal(M/L)$.

Suppose now that $p=5$ and that $\bar{\psi}: G_L \to \mathbb{F}_5^\times$ gives rise to a CM-compositum induced representation.
We show that we can find a $\bar{\varphi}: G_L \to \mathbb{F}_5^\times$ for which the corresponding CM-compositum induced representation has a quadratic twist whose induction will be tidy by Lemma <ref>.
We require that $\restr{(\bar{\varphi}^2)^\tau}{G_{L(\zeta_p)}} \neq \restr{\bar{\varphi}^2}{G_{L(\zeta_p)}}$ where $\tau \in G_F \setminus G_K$.
We suppose that $\restr{(\bar{\psi}^2)^\tau}{G_{L(\zeta_p)}} = \restr{\bar{\psi}^2}{G_{L(\zeta_p)}}$ else we take $\bar{\varphi} = \bar{\psi}$.
We again twist by some surjective $\bar{\chi}: G_L \to \mathbb{F}_5^\times$ which cuts out a dihedral extension $M/K$ in which $p$ is unramified.
By choosing $M/L$ to be disjoint from the extension cut out by $\bar{\psi}$, it will follow that $\bar{\varphi} = \bar{\chi} \bar{\psi}$ still gives rise to a CM-compositum induced representation.
The character $\bar{\chi}^2$ will cut out a quadratic extension $L(\sqrt{\alpha})/L$ for some $\alpha \in L^\times$.
If $\alpha$ is chosen such that $\alpha^\tau \alpha^{-1} \not\in (L(\zeta_5)^\times)^2$ then $\bar{\varphi}$ will have the desired properties and finding such an extension $M/K$ is straightforward.

§.§ Modularity when $p=5$

For now, suppose again that $K$ is an arbitrary number field and that $\bar{\varrho}: G_K \to \GL_2(\mathbb{F}_p)$ is a continuous representation of determinant $\varepsilon^{-1}$.
Let $V$ denote the underlying $\mathbb{F}_p$-vector space of $\bar{\varrho}$ and fix an isomorphism $\iota_0: \bigwedge^2 \bar{\varrho} \cong \mu_p^\vee$.
Let $Y_{\bar{\varrho}}$ denote the uncompactified moduli space of pairs $(E,\iota)$ where $E$ is an elliptic curve and $\iota: V \xrightarrow{\sim} E[p]^\vee$ satisfies $\bigwedge^2 \iota = \iota_0$ via the isomorphism $\bigwedge^2 E[p]^\vee \cong \mu_p^\vee$ coming from the Weil pairing.

Now suppose that $p=5$.
The compactified curve $X_{\bar{\varrho}}$ is isomorphic to $\mathbb{P}^1$ over $K$ (by the same argument as in <cit.>).
We use this to give a notion of a positive density of a subset of $X_{\bar{\varrho}}(K)$.
For $v$ a place of $K$ lying above a place $w$ of $\mathbb{Q}$ define the valuation $||\cdot ||_v$ to equal $| \cdot |_v^{|K_v:\mathbb{Q}_w|}$, where $| \cdot |_v$ extends the usual absolute value on $\mathbb{Q}$ defined by $w$.
Then the absolute height of $[x_0: \ldots : x_n] \in \mathbb{P}^n(K)$ is given by

H([x_0: \ldots : x_n]) = \prod_{v} \max(||x_0||_v,\ldots,||x_n||_v)^{1/|K:\mathbb{Q}|},

where the product is over all places of $K$.
We have the following lemma on the asymptotic behaviour of the number of points of bounded height.

Let $K$ be a number field of degree $d$ over $\mathbb{Q}$ and let $\Sigma$ be a finite set of finite places of $K$.
Consider the subset $S = \{(\alpha:1) \in \mathbb{P}^1(K) | v_w(\alpha) = 0 \text{ for all } w \in \Sigma\}$ of $\mathbb{P}^1(K)$, where $v_w$ denotes the valuation corresponding to the place $w$.
Then there exists a constant $C_\Sigma > 0$ such that

\# \{P \in S | H(P) \leq X\} = C_\Sigma X^{2d} +
\begin{cases}
O(X^d \log X) &\text{ if } d=1\\
O(X^{2d-1}) &\text{ if } d>1.
\end{cases}

where $H$ is the absolute height on $\mathbb{P}^1(K)$.
An explicit value for $C_\Sigma$ is given by

$$C_\Sigma =  \frac{hR}{w \zeta_K(2)} \gamma_{K,2} \prod_{w \in \Sigma}
\frac{(N (\mathfrak{p}_w) - 1)^2}{N (\mathfrak{p}_w)^2 - 1}

* $h$ is the class number of $K$

* $R$ is the regulator of $K$

* $w$ is the number of roots of unity in $K$

* $\zeta_K$ is the Dedekind zeta function of $K$

* $\gamma_{K,2} = \frac{(2^{r_1} (2 \pi)^{r_2})^2 2^r}{|D_K|}$ where

* $r_1$ is the number of real embeddings and $r_2$ is the number of pairs of complex embeddings of $K$

* $r = r_1 + r_2 - 1$

* $D_K$ is the discriminant of $K$

* $N(\mathfrak{p}_w)$ is the norm of the prime ideal corresponding to $w$.

The case where $\Sigma = \emptyset$ is stated in <cit.>.
We show how the lemma follows by the same proof of this case, which was due to Schanuel.
If $P = (x_0:x_1) \in \mathbb{P}^1(K)$ with $x_0,x_1 \in K$ then we let $\mathfrak{a}_P$ denote the fractional ideal of $K$ generated by $x_0,x_1$.
In what follows we say two points in $K^2$ are equivalent if they differ by an element of $\mathcal{O}_K^\times$.
It suffices to show that the same asymptotic, on dividing through by a factor of $h$, holds when restricting only to $P \in \mathbb{P}^1(K)$ for which $\mathfrak{a}_P$ lies in a fixed class in the ideal class group of $K$.
This is the same as fixing an ideal $\mathfrak{a}$ (which we may assume is prime to the prime ideals defined by the places in $\Sigma$) and counting $(x_0,x_1) \in \mathfrak{a}^2$ up to equivalence for which $\mathfrak{a}_P = \mathfrak{a}$, $v_w(x_0) = v_w(x_1) = 0$ and $H(x_0:x_1) \leq X$.
Now suppose we have an asymptotic formula with the same order of leading term and same error term for counting pairs $(x_0,x_1) \in \mathfrak{a}^2$ up to equivalence for which $v_w(x_0) = v_w(x_1) = 0$ and $H(x_0:x_1) \leq X$.
Then by Möbius inversion (see <cit.> for the $\Sigma = \emptyset$ case; in our case we can restrict to sums over integral ideals coprime to $\mathfrak{p}_w$ for $w \in \Sigma$) the same asymptotic will hold for the sum of interest above, but we gain a factor of $\zeta_K(2)^{-1} \prod_{w \in \Sigma} (1 - N \mathfrak{p}_w^{-2})^{-1} $.

For $i \in \{0,1\}$, $w \in \Sigma$ and $X > 0$, let
$$A_{i,w,X} = \{(x_0,x_1) \in \mathfrak{a}^2 | x_i \in \mathfrak{p}_w, H(x_0:x_1) \leq X\},$$

viewed as a subset of the set of such pairs whose height is bounded by $X$ but without any conditions at places in $\Sigma$.
For $T \subset \{0,1\} \times \Sigma$, the asymptotic behaviour of $\# \bigcap_{(i,w) \in T} A_{i,w,X}$ can be computed in exactly the same way as the $T = \emptyset$ computation as in <cit.>, since the size of this intersection is also given by counting the number of lattice points in a homogeneously expanding domain.
The formula <cit.> and the $T= \emptyset$ computation then gives that

\# \bigcap_{(i,w) \in T} A_{i,w,X} = \big(\prod_{(i,w) \in T} N( \mathfrak{p}_w)^{-1}\big) \frac{R \gamma_{K,2}}{w} X^{2d} +
\begin{cases}
O(X^d \log X) &\text{ if } d=1\\
O(X^{2d-1}) &\text{ if } d>1.
\end{cases}$$

A straightforward application of the inclusion-exclusion principle then yields the result.

We state one more fact about $H$ that will be of repeated use.
If $f : \mathbb{P}^1_K \to \mathbb{P}^1_K$ is an isomorphism over $K$ then there exists $C_1,C_2 > 0$ depending only on $f$ such that for every $P \in \mathbb{P}^1(K)$ we have the inequalities

\begin{equation} \label{iso gives bounded height}
C_1 H(P) \leq H(f(P)) \leq C_2 H(P).
\end{equation}

Let $K$ be a number field and let $\bar{\varrho}:G_K \to \GL_2(\mathbb{F}_5)$ be a continuous representation of determinant $\varepsilon^{-1}$.
We say a subset $S \subset X_{\bar{\varrho}}(K)$ has positive density if there exists a constant $C > 0$ such that for every $X$ sufficiently large

\frac{\# \{ P \in S : H(P) \leq X \} }{\# \{ P \in  X_{\bar{\varrho}}(K) : H(P) \leq X \}} \geq C

where $H$ is a height function on $X_{\bar{\varrho}}$ arising from some (equivalently, any by Lemma <ref> and <ref>) isomorphism $X_{\bar{\varrho}} \cong \mathbb{P}^1$ over $K$ via the absolute height on $\mathbb{P}^1$.

The following lemma provides us with a subset of positive density on this modular curve, which we use to deduce a positive density of modular elliptic curves under certain hypotheses.

Let $K$ be a number field such that each place $w|5$ is unramified and every such residue field $k(w)$ is an extension of $\mathbb{F}_5$ of degree at most $2$.
Let $\bar{\varrho}: G_K \to \GL_2(\mathbb{F}_5)$ be a representation of determinant $\varepsilon^{-1}$ such that for each $w|5$,

$$\restr{\bar{\varrho}}{G_{K_w}} \cong \psi_w \oplus \psi_w^{-1} \varepsilon^{-1}$$

with $\psi_w: G_{K_w} \to \mathbb{F}_5^\times$ unramified.

* There exists non-empty $p$-adic open subsets $\Omega_w \subset X_{\bar{\varrho}}(K_w)$ for each place $w|5$ such that if $P \in \Omega_w$ then $E_P$ is an elliptic curve with ordinary good reduction or potentially multiplicative reduction.

* Let $\Sigma$ be a finite set of finite places of $K$ and let $\Omega_w \subset X_{\bar{\varrho}}(K_w)$ be a non-empty $p$-adic open subset for each $w \in \Sigma$. Then
$$\Omega = \{P \in X_{\bar{\varrho}}(K) | P \in \Omega_w \text{ for every } w \in \Sigma\}$$
has positive density in the sense of Definition <ref>.

Let $w|5$ and view $\psi_w$ as a character of $G_{k(w)}$.
We can find an ordinary elliptic curve $\tilde{E}$ over $k(w)$ such that $\tilde{E}[5](\overline{k(w)})$ is isomorphic, as a $G_{k(w)}$-module, to $\mathbb{F}_5[\psi_w^{-1}]$.
Indeed, $\psi_w$ has order dividing $4$ and there are only $4$ possibilities for $\psi_w$; examples are listed in Table <ref> below.
Here when $|k(w): \mathbb{F}_5| = 2$, $\alpha \in k(w)\setminus \mathbb{F}_{5}$ satisfies $\alpha^2 + 4\alpha + 2 = 0$.

Some ordinary elliptic curves over finite fields of characteristic $5$ with specified $5$-torsion

$|k(w): \mathbb{F}_5|$     $\# \psi_w(G_{k(w)})$     $\tilde{E}$
1            1                         $y^2 = x^3+3x$

1            2                         $y^2 = x^3 + 2x$

1            4                         $y^2 = x^3 \pm x$

2           1                         $y^2 = x^3 + 3x$

2           2                         $y^2 = x^3 + x$

2           4                         $y^2 = x^3 + \alpha x$

$y^2 = x^3 + \alpha^3 x$

Now consider the Serre–Tate canonical lifting of $\tilde{E}$ to an elliptic curve $\mathcal{E}$ defined over $\mathcal{O}_{K_w}$.
This has the property that the $p$-divisible group of $\mathcal{E}$ splits as a direct sum of a connected group scheme and an étale group scheme.
Letting $E = \mathcal{E}_{K_w}$, it therefore follows that the action of $G_{K_w}$ on $E[5]^\vee$ is given by a direct sum of characters which must be $\psi_w$ and $\psi_w^{-1} \varepsilon^{-1}$.
Thus $E$ is an elliptic curve over $K_w$ with ordinary good reduction that defines a point of $X_{\bar{\varrho}}(K_w)$.

Consider the modular curve $Y_{\bar{\varrho},\overline{\varrho_{E,7}}}$ parameterising triples $(A,\iota,\iota_7)$ where $A$ is an elliptic curve, $\iota$ is a symplectic isomorphism between $A[5]^\vee$ and $\bar{\varrho}$, and $\iota_7$ is a symplectic isomorphism between $A[7]^\vee$ and $E[7]^\vee$ compatible with the action of Galois.
The natural map $Y_{\bar{\varrho},\overline{\varrho_{E,7}}} \to (Y_{\bar{\varrho}})_{K_w}$ is étale (since after base change by a separable extension the map defines a $\PGL_2(\mathbb{F}_7)$-torsor).
Hence there is an open neighbourhood in the $5$-adic topology of the point of $Y_{\bar{\varrho},\overline{\varrho_{E,7}}}(K_w)$ defined by $E$ which is mapped isomorphically onto an open subset $\Omega_w \subset Y_{\bar{\varrho}}(K_w)$ under the map $Y_{\bar{\varrho},\overline{\varrho_{E,7}}}(K_w) \to Y_{\bar{\varrho}}(K_w)$.
Let $P \in \Omega_w$ define an elliptic curve $A_P$ and suppose that $A_P$ has potentially multiplicative reduction.
Then $A_P$ must in fact have multiplicative reduction over $K$, as the quadratic twist of $A_P$ by a ramified character cannot have the mod $5$ Galois representation of an elliptic curve with split multiplicative reduction.
Now suppose instead that $A_P$ has potentially good reduction. Then since $A_P[7]$ is unramified as a $G_{K_w}$-module, it follows by a variation of the Néron–Ogg–Shafarevich criterion that $A_P$ has good reduction and the reduction $\tilde{A}_P$ is ordinary by Lemma <ref>.
This shows the first part of the lemma.

For the second part, choose an isomorphism $f: X_{\bar{\varrho}} \xrightarrow{\sim} \mathbb{P}^1$ over $K$ such that $P \in X_{\bar{\varrho}}(K)$ lies inside each $\Omega_w$ whenever $f(P) = (x:1)$ has $v_w(x) = 0$ for every $w \in \Sigma$.
It then follows from Lemma <ref> that $\Omega$ has positive density.

Let $F$ be a totally real field in which $5$ splits completely and let $K/F$ be a quadratic extension in which $5$ is unramified.
There exists representations $\bar{\varrho}:~G_K \to \GL_2(\mathbb{F}_5)$ which are CM-compositum induced from a character $\bar{\psi}: G_L \to \mathbb{F}_5^\times$ (see Definition <ref>), where $L/K$ is a quadratic extension, and $\bar{\psi}$ satisfies $\restr{(\bar{\psi}^2)^\tau}{G_{L(\zeta_p)}} \neq \restr{\bar{\psi}^2}{G_{L(\zeta_p)}}$ for $\tau \in G_F \setminus G_K$.
Fix such a representation $\bar{\varrho}$ and suppose that $E/K$ is an elliptic curve for which $\overline{\varrho_{E,5}} \cong \bar{\varrho}$ and that $E$ has ordinary good reduction or multiplicative reduction at every $w|5$.
Then $E$ is modular.
Moreover, the subset of $X_{\bar{\varrho}}(K)$ given by such elliptic curves which in addition do not have complex multiplication nor have $j$-invariant contained in a proper subfield of $K$ is of positive density (in the sense of Definition <ref>).

Such representations $\bar{\varrho}$ were constructed in Example <ref>.
A point $P \in Y_{\bar{\varrho}}(K)$ for which $E_P$ has ordinary good reduction or multiplicative reduction at every $w|5$ is modular by (the proofs of) Theorem <ref>, Lemma <ref> and Proposition <ref>.

We now turn our attention to the positive density statement.
Note that only finitely many points $P \in Y_{\bar{\varrho}}(K)$ correspond to a CM elliptic curve $E_P$.
Indeed, there are only finitely many possible values of $j(E_P) \in K$ and if $Q \in Y_{\bar{\varrho}}(K)$ satisfies $j(E_P) = j(E_Q)$ then $E_Q$ is a twist of $E_P$ which must be equal to $E_P$ since $\overline{\varrho_{E_P,5
}} \cong \overline{\varrho_{E_Q,5
Thus we can ignore the existence of CM elliptic curves in showing the density statement.

Now let $l \neq 5$ be a prime number that splits completely in $K$.
For each place $v$ of $K$ above $l$ we can find non-empty $l$-adic open subsets $\Omega_v \subset X_{\bar{\varrho}}(K_v)$ whose images under the $j$-invariant, $j(\Omega_v) \subset \mathbb{P}^1(\mathbb{Q}_l)$, are pairwise disjoint.
We can therefore find a positive density subset $\Omega \subset X_{\bar{\varrho}}(K)$ such that each point $P \in \Omega$ defines an elliptic curve with ordinary good reduction or multiplicative reduction and whose image in $X_{\bar{\varrho}}(K_v)$ lies in $\Omega_v$ for each $v|l$ by Lemma <ref> (which we may apply by Proposition <ref>).
We are done, since the elliptic curves corresponding to points of $\Omega$ cannot have $j$-invariant contained in a proper subfield of $K$ and were already shown to be modular. (One can also show further that the set of elliptic curves arising from points of $X_{\bar{\varrho}}(K)$ whose $j$-invariant is contained inside a proper subfield of $K$ is of density zero, but we have not done so since it makes no difference for the purpose of this corollary.)

In this appendix we record the output of computations carried out in the computer algebra software , as explained in Section <ref>.

Conjugacy classes of absolutely $\GL_4$-irreducible subgroups $\Gamma \leq \Sp_4(\mathbb{F}_p)$ which are not $\Sp_4$-adequate

$p$     $\#\Gamma$     Label                               $h^1(\Gamma,\splie_4)$     $h^1(\Gamma,\mathbb{F}_p)$     ID

3       96        $D_4.A_4$                           0                          1                              96,202

3       96        $\SL(2,3).C_2^2$                     1                          0                              96,191

3       240       $C_2.S_5$                           1                          0                              240,89

3       384       $Q_8^2.C_6$                         0                          1                              384,618

3       1440      $C_2.A_6.C_2$                       1                          0                              1440,4591

3       1152      $C_2^2.A_4{\rm wrC}_2$              0                          1

5       160       $(C_4.C_2^3):C_5$                   0                          1                              160, 199

5       480       $D_4.A_5$                           1                          0                              480,957

5       480       $(C_2\times {\rm SL}(2,5)):C_2$     1                          0                              480,953

5       720       $S_3\times {\rm SL}(2,5)$           1                          0                              720,417

5       28800     $C_2^2.A_5^2.C_2$                   1                          0

Conjugacy classes of subgroups $\Gamma' \leq \GSp_4(\mathbb{F}_3)$ with $\nu(\Gamma') \neq 1$ for which $\Gamma = \Gamma' \cap \Sp_4(\mathbb{F}_3)$ is absolutely $\GL_4$-irreducible

$\#\Gamma'$     $\#\Gamma$     (A)     (B)      $h^1(\Gamma,\splie_4)$     $h^1(\Gamma,\mathbb{F}_3$)     Adequate     Tidy      Induced     Split-induced
64         32        TRUE     FALSE     0     0     TRUE      TRUE      TRUE      TRUE

64         32        TRUE     FALSE     0     0     TRUE      TRUE      TRUE      TRUE

64         32        TRUE     FALSE     0     0     TRUE      TRUE      TRUE      TRUE

64         32        TRUE     FALSE     0     0     TRUE      TRUE      TRUE      TRUE

80         40        TRUE     TRUE      0     0     TRUE      TRUE      TRUE      FALSE

128        64        TRUE     FALSE     0     0     TRUE      TRUE      TRUE      TRUE

128        64        TRUE     FALSE     0     0     TRUE      TRUE      TRUE      TRUE

128        64        TRUE     FALSE     0     0     TRUE      FALSE     TRUE      TRUE

128        64        TRUE     FALSE     0     0     TRUE      FALSE     TRUE      TRUE

192        96        TRUE     FALSE     1     0     FALSE     TRUE      TRUE      FALSE

192        96        TRUE     FALSE     0     1     FALSE     TRUE      TRUE      TRUE

192        96        TRUE     FALSE     1     0     FALSE     TRUE      TRUE      FALSE

192        96        TRUE     FALSE     0     1     FALSE     TRUE      TRUE      FALSE

192        96        TRUE     FALSE     0     0     TRUE      TRUE      TRUE      TRUE

256        128       TRUE     TRUE      0     0     TRUE      TRUE      TRUE      TRUE

384        192       TRUE     TRUE      0     0     TRUE      TRUE      TRUE      FALSE

480        240       TRUE     TRUE      1     0     FALSE     TRUE      TRUE      FALSE

480        240       TRUE     TRUE      0     0     TRUE      TRUE      TRUE      FALSE

640        320       TRUE     TRUE      0     0     TRUE      FALSE     FALSE     FALSE

768        384       TRUE     TRUE      0     0     TRUE      TRUE      TRUE      TRUE

768        384       TRUE     TRUE      0     1     FALSE     TRUE      TRUE      TRUE

2304       1152      TRUE     TRUE      0     1     FALSE     TRUE      TRUE      TRUE

2880       1440      TRUE     TRUE      1     0     FALSE     TRUE      TRUE      FALSE

3840       1920      TRUE     TRUE      0     0     TRUE      TRUE      FALSE     FALSE

103680     51840     TRUE     TRUE      0     0     TRUE      TRUE      FALSE     FALSE

32         32        TRUE     FALSE     0     0     TRUE      FALSE     TRUE      TRUE

32         32        TRUE     FALSE     0     0     TRUE      FALSE     TRUE      TRUE

32         32        TRUE     FALSE     0     0     TRUE      FALSE     TRUE      TRUE

40         40        TRUE     TRUE      0     0     TRUE      FALSE     TRUE      FALSE

64         64        TRUE     FALSE     0     0     TRUE      FALSE     TRUE      TRUE

64         64        TRUE     FALSE     0     0     TRUE      FALSE     TRUE      TRUE

96         96        TRUE     FALSE     0     1     FALSE     FALSE     TRUE      TRUE

96         96        TRUE     FALSE     1     0     FALSE     FALSE     TRUE      FALSE

96         96        TRUE     FALSE     0     0     TRUE      FALSE     TRUE      TRUE

128        128       TRUE     TRUE      0     0     TRUE      FALSE     TRUE      TRUE

160        160       TRUE     TRUE      0     0     TRUE      FALSE     FALSE     FALSE

192        192       TRUE     TRUE      0     0     TRUE      FALSE     TRUE      FALSE

240        240       TRUE     TRUE      0     0     TRUE      FALSE     TRUE      FALSE

240        240       TRUE     TRUE      1     0     FALSE     FALSE     TRUE      FALSE

320        320       TRUE     TRUE      0     0     TRUE      FALSE     FALSE     FALSE

384        384       TRUE     TRUE      0     0     TRUE      FALSE     TRUE      TRUE

384        384       TRUE     TRUE      0     1     FALSE     FALSE     TRUE      TRUE

1152       1152      TRUE     TRUE      0     1     FALSE     FALSE     TRUE      TRUE

1440       1440      TRUE     TRUE      1     0     FALSE     FALSE     TRUE      FALSE

1920       1920      TRUE     TRUE      0     0     TRUE      FALSE     FALSE     FALSE

51840      51840     TRUE     TRUE      0     0     TRUE      FALSE     FALSE     FALSE

[1]
Patrick B. Allen, Chandrashekhar B. Khare, and Jack A. Thorne.
Modularity of $\PGL_2(F_p)$-representations over totally real
Proceedings of the National Academy of Sciences, 118(33), 2021.

[2]
S. Balaji.
G-valued Potentially Semi-stable Deformation Rings.
University of Chicago, Division of the Physical Sciences, Department
of Mathematics, 2012.

[3]
Alex Bartel.
Large Selmer groups over number fields.
Mathematical Proceedings of the Cambridge Philosophical
Society, 148(1):73–86, Jul 2009.

[4]
Alexis Bouthier and Kestutis Cesnavicius.
Torsors on loop groups and the Hitchin fibration.
Annales Scientifiques de l'École Normale Supérieure,

[5]
George Boxer, Frank Calegari, Toby Gee, and Vincent Pilloni.
Abelian surfaces over totally real fields are potentially modular.
Publications mathématiques de l'IHÉS, pages 1–349,

[6]
Gebhard Böckle, Michael Harris, Chandrashekhar Khare, and Jack A. Thorne.
$\hat{G}$-local systems on smooth projective curves are potentially
Acta Mathematica, Volume 223 (2019)(1):1–111, 2019.

[7]
CJ Bushnell and PC Kutzko.
Smooth representations of reductive p-adic groups: structure theory
via types.
Proceedings of the London Mathematical Society, 77(3):582–634,

[8]
Thomas Barnet-Lamb, Toby Gee, and David Geraghty.
Congruences between Hilbert modular forms: Constructing ordinary
lifts, II.
Mathematical Research Letters, 20:67–72, 2013.

[9]
A. Borel.
Linear Algebraic Groups.
Graduate Texts in Mathematics. Springer New York, 1991.

[10]
Armand Borel and Jacques Tits.
Éléments unipotents et sous-groupes paraboliques de groupes
réductifs. i.
Inventiones mathematicae, 12:95–104, 1971.

[11]
François Bruhat and Jacques Tits.
Groupes réductifs sur un corps local : I. Données radicielles
Publications Mathématiques de l'IHÉS, 41:5–251, 1972.

[12]
I. N. Bernstein and Andrei Zelevinsky.
Induced representations of reductive ${\mathfrak {p}}$-adic groups.
Annales scientifiques de l'École Normale Supérieure, Ser.
4, 10(4):441–472, 1977.

[13]
P. Cartier.
Representations of $p$-adic groups: a survey.
In Automorphic forms, representations and $L$-functions
(Proc. Sympos. Pure Math., Oregon State Univ., Corvallis,
Ore., 1977), Part 1, Proc. Sympos. Pure Math., XXXIII, pages 111–155.
Amer. Math. Soc., Providence, R.I., 1979.

[14]
R.W. Carter.
Finite Groups of Lie Type: Conjugacy Classes and Complex
Pure and Applied Mathematics Series. John Wiley & Sons, 1985.

[15]
B. Conrad, O. Gabber, and G. Prasad.
Pseudo-reductive Groups.
New Mathematical Monographs. Cambridge University Press, 2015.

[16]
Laurent Clozel, Michael Harris, and Richard Taylor.
Automorphy for some l-adic lifts of automorphic mod l Galois
Publications Mathématiques de l'IHÉS, 108:1–181, 2008.

[17]
Brian Conrad.
Reductive group schemes.
Autour des schémas en groupes, 1:93–444, 2014.

[18]
Gary Cornell, Joseph H Silverman, and Glenn Stevens.
Modular forms and Fermat’s last theorem.
Springer Science & Business Media, 2013.

[19]
Laurent Clozel and Jack A Thorne.
Level-raising and symmetric power functoriality, I.
Compositio Mathematica, 150(5):729–748, 2014.

[20]
Henri Darmon, Fred Diamond, and Richard Taylor.
Fermat’s last theorem.
Current developments in mathematics, 1995(1):1–154, 1995.

[21]
M. Demazure and A. Grothendieck.
Schemas en Groupes. Seminaire de Geometrie Algebrique du Bois
Marie 1962/64 (SGA 3).
Springer-Verlag, 1970.

[22]
Fred Diamond and Richard Taylor.
Lifting modular $\mod \ell$ representations.
Duke Mathematical Journal, 74(2):253 – 269, 1994.

[23]
Robert Guralnick, Florian Herzig, and Pham Huu Tiep.
Adequate groups of low degree.
Algebra & Number Theory, 9(1):77–147, 2015.

[24]
Robert Guralnick, Florian Herzig, Richard Taylor, and Jack Thorne.
Adequate subgroups.
J. Inst. Math. Jussieu, 11, 07 2011.

[25]
Alexander Grothendieck.
Technique de descente et théorèmes d'existence en géométrie
algébriques. II. Le théorème d'existence en théorie formelle des
In Séminaire Bourbaki : années 1958/59 - 1959/60, exposés
169-204, number 5 in Séminaire Bourbaki. Société mathématique de
France, 1960.

[26]
Wee Gan and Shuichiro Takeda.
Theta correspondences for $\GSp(4)$.
Representation Theory of the American Mathematical Society, 15,
06 2010.

[27]
Wee Teck Gan and Shuichiro Takeda.
The local Langlands conjecture for $\GSp(4)$.
Annals of Mathematics, 173(3):1841–1882, 2011.

[28]
Robert M Guralnick.
Small representations are completely reducible.
Journal of Algebra, 220(2):531–541, 1999.

[29]
Sebastian Herpel.
On the smoothness of centralizers in reductive groups.
Transactions of the American Mathematical Society,
365(7):3753–3774, 2013.

[30]
Thomas Haines, Robert Kottwitz, and Amritanshu Prasad.
Iwahori-Hecke Algebras.
Journal of the Ramanujan Mathematical Society, 25, No
2:113–145, 2010.

[31]
Marty (https://mathoverflow.net/users/3545/marty).
Fixed points of the weyl group action on a maximal torus and the
center of a reductive group.
MathOverflow, 2018.
URL:https://mathoverflow.net/q/307885 (version: 2018-08-09).

[32]
J.E. Humphreys.
Conjugacy Classes in Semisimple Algebraic Groups.
Conjugacy Classes in Semisimple Algebraic Groups. American
Mathematical Society, 2011.

[33]
Serge Lang.
Fundamentals of Diophantine geometry.
Springer Science & Business Media, 2013.

[34]
Álvaro Lozano-Robledo.
On the field of definition of $ p$-torsion points on elliptic curves
over the rationals.
Mathematische Annalen, 357(1):279–305, 2013.

[35]
George Lusztig.
Affine Hecke Algebras and Their Graded Version.
Journal of the American Mathematical Society, 2(3):599–635,

[36]
Barry Mazur.
Deforming Galois representations.
In Galois Groups over $\mathbb{Q}$, pages 385–437. Springer,

[37]
James S Milne.
Arithmetic duality theorems.
Citeseer, 2006.

[38]
Chung Pang Mok.
Galois representations attached to automorphic forms on
$\mathrm{GL}_2$ over $\mathrm{CM}$ fields.
Compositio Mathematica, 150(4):523–567, 2014.

[39]
Jürgen Neukirch, Alexander Schmidt, and Kay Wingberg.
Cohomology of number fields, volume 323.
Springer Science & Business Media, 2013.

[40]
Stefan Patrikis.
Deformations of Galois representations and exceptional monodromy.
Inventiones mathematicae, 205(2):269–336, Nov 2015.

[41]
Stefan Patrikis.
Variations on a theorem of Tate, volume 258.
American Mathematical Society, 2019.

[42]
R. W. Richardson.
Conjugacy classes of $n$-tuples in Lie algebras and algebraic
Duke Mathematical Journal, 57:1–35, 1988.

[43]
B. Roberts and R. Schmidt.
Local Newforms for GSp(4).
Lecture Notes in Mathematics. Springer Berlin Heidelberg, 2007.

[44]
Nicholas I Shepherd-Barron and Richard Taylor.
Mod 2 and mod 5 icosahedral representations.
Journal of the American Mathematical Society, pages 283–298,

[45]
Stephen Hoel Schanuel.
Heights in number fields.
Bulletin de la Société mathématique de France,
107:433–449, 1979.

[46]
Ralf Schmidt.
Iwahori-spherical representations of GSp(4) and Siegel modular forms
of degree 2 with square-free level.
Journal of the Mathematical Society of Japan, 57(1):259 – 293,

[47]
Joseph H Silverman.
The arithmetic of elliptic curves, volume 106.
Springer, 2009.

[48]
The Stacks project authors.
The stacks project.
<https://stacks.math.columbia.edu>, 2022.

[49]
Jack A. Thorne.
On the automorphy of l-adic Galois representations with small
residual image with an appendix by Robert Guralnick, Florian Herzig, Richard
Taylor and Jack Thorne.
Journal of the Institute of Mathematics of Jussieu,
11(4):855–920, 2012.

[50]
Jack A. Thorne.
On the vanishing of adjoint Bloch–Kato Selmer groups of irreducible
automorphic Galois representations (preprint).

[51]
Marie-France Vigneras.
Pro-p-Iwahori Hecke ring and supersingular $\bar{F}_p$-
Mathematische Annalen, 331:523–556, 03 2005.