Some cases of Serre's uniformity problem

We show that if $E/\mathbb{Q}$ is an elliptic curve without complex multiplication and for which there is a prime $q$ such that the image of $\bar{\rho}_{E,q}$ is contained in the normaliser of a split Cartan subgroup of $\rm{GL}_2(\mathbb{F}_q)$, then $\bar{\rho}_{E,p}$ surjects onto $\rm{GL}_2(\mathbb{F}_p)$ for every prime $p>37$. This result complements a previous result by the author. We also prove analogue results for certain families of $\mathbb{Q}$-curves, building on results of Ellenberg (2004) and Le Fourn (2016).


Introduction
Let K be a number field and E an elliptic curve defined over K. Given a prime number p, we will denote the mod p Galois representation obtained from the Galois action on the ptorsion points of E(K) (whereK is an algebraic closure of K) byρ E,p . The image of this representation is contained in GL(E[p]), which is (non-canonically) isomorphic to GL 2 (F p ). We will often implicitly make a choice of an F p -basis for E [p] and regardρ E,p as having image contained in GL 2 (F p ). Throughout this paper, we will say thatρ E,p is surjective if its image is the whole of GL 2 (F p ). The question of determining under what conditions these representations are surjective is very important in modern number theory. One of the earliest and most striking results in this area is due to Serre. . Let K be a number field and let E be an elliptic curve defined over K and without complex multiplication. There exists a constant C E,K such that ρ E,p is surjective for every prime p > C E,K .
Serre's uniformity problem (see section 4.3 of [16]) asks to what extent the constant C E,K of the theorem above is dependent on E. More precisely, it asks whether there exists a constant C K depending only on K such that, given an elliptic curve E defined over K and without complex multiplication, the residual mod p Galois representationρ E,p is surjective for every prime p > C K . An affirmative answer to this question would be likely to yield important applications in the study of certain Diophantine equations, as the work of Darmon and Merel [6] shows.
The most studied and most well understood case is, naturally, the one where K = Q. The strongest result we have to this date is the following. 3,11,12,16]). Let E be an elliptic curve defined over Q and without complex multiplication. Let p be a prime number strictly larger than 37. Ifρ E,p is not Date: October 24, 2018. 1 surjective, then its image is contained in the normaliser of a non-split Cartan subgroup of GL 2 (F p ).
In [10], the author showed that the normaliser of a non-split Cartan case cannot occur for primes p > 37 if an elliptic curve as in the theorem above admits a non-trivial cyclic isogeny defined over Q. . Let E be an elliptic curve defined over Q and without complex multiplication. Suppose that E admits a non-trivial cyclic isogeny defined over Q. Thenρ E,p is surjective for every prime p > 37.
Another way of saying that an elliptic curve defined over a number field K admits a non-trivial cyclic isogeny defined over K is by saying that there exists a prime q for which the image ofρ E,q : G K → GL 2 (F q ) is contained in a Borel subgroup of GL 2 (F q ). It is then natural to ask whether we can obtain results of the same kind if we replace "Borel subgroup" by another maximal subgroup of GL 2 (F q ). In the first part of this paper, we show that the same result holds if this maximal subgroup is chosen to be the normaliser of a split Cartan. More precisely, we show the following theorem.
Theorem 1. 4. Let E/Q be an elliptic curve without complex multiplication. Suppose that there exists a prime q for which the image ofρ E,q is contained in the normaliser of a split Cartan subgroup of GL 2 (F q ). Thenρ E,p is surjective for every p > 37.
Note that it follows from the work of Bilu, Parent and Rebolledo [3] that there are only finitely many primes q for which there exists a non-CM elliptic curve defined over Q such that the image ofρ E,q is contained in the normaliser of a split Cartan subgroup of GL 2 (F q ). More precisely, they show that q ∈ {2, 3, 5, 7, 13}. Moreover, by the recent work of Balakrishnan, Dogra, Müller, Tuitman and Vonk [1], the prime 13 is not on this list, and the list is reduced to {2, 3, 5, 7}.
In order to prove this theorem, we follow the same strategy employed to prove Theorem 1.3, namely, we start by showing that if E is an elliptic curve satisfying the conditions of Theorem 1.4 and such that the image ofρ E,p is contained in the normaliser of a non-split Cartan subgroup for some prime p ≥ 11, then its j-invariant is integral. Proposition 1.5. Let E/Q be an elliptic curve without complex multiplication. Suppose that there exists a prime p ≥ 11 for which the image of the residual Galois representation ρ E,p is contained in the normaliser of a non-split Cartan subgroup of GL 2 (F p ). Suppose, moreover, that there exists a prime q different from p such that the image ofρ E,q is contained in the normaliser of a split Cartan subgroup of GL 2 (F q ). Then the j-invariant of E is integral.
This result is proven an adaptation of Mazur's formal immersion argument (see [11,12]). By Theorem 1.2, the only elliptic curves which could consitute a contradiction to Theorem 1.4 are those for which there exists a prime p > 37 such that the image ofρ E,p is contained in the normaliser of a non-split Cartan, and so they must all have integral j-invariants. Using explicit parametrisations of the j-invariant maps for X 0 (q), where q is an element of the set {2, 3, 5, 7}, we find out that there are only finitely many Q-points of X 0 (q) with integral j-invariant. Moreover, we are able to compute all the possible jinvariants. As any two elliptic curves with the same j-invariant are related to each other by a quadratic twist as long as their j-invariant is not 0 nor 1728, surjectivity only depends on the j-invariant, and so our problem is reduced to computing the largest non-surjective prime for a finite set of elliptic curves.
The second part of this paper is devoted to Q-curves. Let us just recall a few definitions before proceeding. Let E be an elliptic curve defined over a Galois number field K. Given an element σ ∈ Gal(K/Q), we will denote by σ E the Galois conjugate of E by σ. Recall that E is said to be a Q-curve if, for each σ ∈ Gal(K/Q), there exists an isogeny µ σ : σ E → E. If E/K is a Q-curve, we shall say that it is completely defined over K if all of the isogenies µ σ can be chosen in such a way that they are all defined over K. The main results of this paper make reference to some representations attached to Q-curves that, following the notation introduced by Ellenberg [7,8], we will denote by Pρ E,p . Despite the notation, these are not, in general, simply the projectivisations ofρ E,p (the projectivisation ofρ E,p is, by definition, the composition ofρ E,p with the canonical projection GL 2 (F p ) → PGL 2 (F p )); in fact, Pρ E,p is defined on the whole of G Q , and not only on G K , where K is the number field over which E is defined. However, there is a close relation between Pρ E,p andρ E,p : if Pρ E,p stands for the projectivisation ofρ E,p , then Pρ E,p is isomorphic to Pρ E,p | G K . For a brief review of the definition of Pρ E,p , we refer the reader to section 2. When K is a quadratic field, we say that a Q-curve completely defined over K is of degree d if there exists an isogeny µ σ : σ E → E defined over K and of degree d and there exists no other isogeny between σ E and E of smaller degree, where σ ∈ Gal(K/Q) is the non-trivial element.
The main objective of the second part of the paper is to prove the following results (which are analogues of Theorem 1.3 and Theorem 1.4). Theorem 1.6. Let K be a quadratic field and let d be a square-free integer. There exists a constant C K,d satisfying the following property. If E is a Q-curve completely defined over K, of degree d, without complex multiplication and for which there exists a prime q ∤ d such that the image of Pρ E,q is contained in a Borel subgroup of PGL 2 (F q ), then Pρ E,p surjects onto PGL 2 (F p ) for every p > C K,d . Theorem 1.7. Let K be a quadratic field and let d / ∈ {2, 3, 5, 7, 13} be a square-free integer. There exists a constant C K,d satisfying the following property. If E is a Q-curve completely defined over K, of degree d, without complex multiplication and for which there exists a prime q ∤ d such that the image of Pρ E,q is contained in the normaliser of a split Cartan subgroup of PGL 2 (F q ), then Pρ E,p surjects onto PGL 2 (F p ) for every p > C K,d .
Most of the proof of these two theorems will use arguments of the same type of those used to prove Theorem 1.4 and described above. In particular, borrowing some ideas of Ellenberg [8], we will show the following. Proposition 1.8. Let K be a quadratic number field and let d be a square-free positive integer. Let E be a Q-curve completely defined over K, of degree d and without complex multiplication. Suppose that p and q are distinct primes not dividing d such that the image of Pρ E,p is contained in the normaliser of a non-split Cartan subgroup of PGL 2 (F p ) and that the image of Pρ E,q is contained in a Borel subgroup of PGL 2 (F q ). Suppose, moreover, that p ≥ 11. Then the j-invariant of E is in O K , where O K stands for the ring of integers of K.
We remark that if q ≥ 11 and q = 13, 17, 41, a much stronger result has been proven by Le Fourn [9,Proposition 3.3]. For the proof of Theorem 1.7, we will actually use the following result from [9]. Proposition 1.9 ([9, Proposition 3.6]). Let K be a quadratic field and let p = 11 or p > 13 be a prime. Suppose that E is a Q-curve of square-free degree d coprime to p such that the image of Pρ E,p is contained in the normaliser of a split Cartan subgroup. Then j(E) ∈ O K .
Finally, we would like to mention a theorem that will be used as an auxiliary result in the proof of Theorem 1.6, but which is interesting in its own right. Theorem 1.10. Let K be a quadratic number field and d a positive square-free integer. There exists a constant C K,d satisfying the following property. Let E/K be a Q-curve completely defined over K, of degree d and without complex multiplication. If p ∤ d is a prime for which the image of Pρ E,p is contained in a Borel subgroup of PGL 2 (F p ), then p ≤ C K,d . Moreover, if we restrict ourselves to the case where p ≡ 1 (mod 4), then the constant C K,d can be chosen to be where c is the narrow class number of K and f is the residual degree of a prime of K lying above 2 (which is independent of the prime above 2 chosen). In particular, when p ≡ 1 (mod 4), the constant C K,d is actually independent from d.
The reader is referred to the paper of Le Fourn [9], where results of a similar nature are proven. Specifically, in [9, Corollary 5.1], Le Fourn gives a bound for such primes that depends not only on the quadratic number field K, but also on the elliptic curve itself. However, by restricting himself to the cases where K is imaginary quadratic, he is able to give the absolute bound of 2 · 10 13 for the size of such primes (this is [9,Theorem 5.4]). In comparison, Theorem 1.10 shows the existence of a bound depending only on the quadratic number field K and on d, regardless of whether K is real or imaginary.
As a final remark, we would like, once again, to draw the reader's attention to the papers of Ellenberg [8] and Le Fourn [9]. In [8], Ellenberg shows that if K is an imaginary quadratic field and d ≥ 2 is a square-free integer, then there exists a constant C K,d such that, given a Q-curve E completely defined over K, of degree d and without complex multiplication, either Pρ E,p surjects onto PGL 2 (F p ) for every prime p > C K,d , or E has potentially godd reduction at every prime of K of characteristic not dividing 6. The arguments appearing in the Q-curve section of this paper will be based on some of his ideas. In [9], Le Fourn improves on the results of Ellenberg and gives an upper bound depending only on the discriminant of K (still assumed to be imaginary quadratic) and on the degree of the Qcurve for the largest non-surjective prime associated to E. One peculiarity of their results is that they need the degree of the Q-curve to be ≥ 2, i.e., they do not prove anything for elliptic curves defined over Q. In this paper, we will start by proving Theorem 1.4, which is the analogue of Theorem 1.7 for elliptic curves defined over Q, i.e., Q-curves of degree 1.
Acknowledgements. I want to express my gratitute to Filip Najman, Marusia Rebolledo and Samir Siksek for their time, patience and their valuable suggestions, which greatly helped me during the process of writing up this article. I also want to thank the referee for his corrections. Finally, I am also indebted to the Max Planck Institute for Mathematics, in Bonn, both for the financial support and for the excellent working environment.

Galois representations of Q-curves
We follow the approach of Ellenberg [7]. For a more conceptual and complete treatment of the material in this section, the reader is referred to [15]. However, the description given here will suffice for the most part of the present article. Results from [15] will only be used in the proof of Theorem 1.10.
Let K be a Galois number field. Let E be a Q-curve defined (but not necessarily completely defined) over K. Assume, moreover, that E does not have complex multiplication. For each σ ∈ Gal(Q/Q), choose an isogeny µ σ : σ E → E. Note that if the restriction of σ to K is the trivial automorphism, then σ E = E, and, in this case, we can choose µ σ to be the identity. We will always assume that we make this choice and that, moreover, if two elements σ, τ ∈ Gal(Q/Q) restrict to the same automorphism of K, then µ σ = µ τ . Since E does not have complex multiplication, we have EndQ(E) ⊗ Q = Q. Therefore, given σ, τ ∈ Gal(Q/Q), the element whereμ στ stands for the dual isogeny of µ στ , can be regarded as an element of Q × . Given, a prime number p, let T p (E) be the p-adic Tate module of E. Define the function (which, in general, is not a homomorphism) ̟ E,p : G Q → GL(T p (E)) ∼ = GL 2 (Q p ) in the following manner: given P ∈ T p (E) and σ ∈ G Q , we impose that ̟ E,p (σ)(P ) = µ σ ( σ P ).
Remark. Note that σ P ∈ σ E(K). So, if σ does not restrict to the trivial automorphism of K, we may have σ P / ∈ E(K).
It is straightforward to check that the action of Thus, ̟ E,p gives rise to a well-defined homomorphism Pρ E,p : G Q → PGL 2 (Q p ). If p does not divide the degree of any µ σ , the construction of Pρ E,p is identical to this.

The case of elliptic curves over Q
The aim of this section is to prove Proposition 1.5 and Theorem 1.4. But before starting to prove the aforementioned results, let us introduce some notation and terminology that will be used throughout the paper. Table 2 contains a summary of facts and notation that we will need.
Recall that a subgroup Γ of SL 2 (Z) is called a congruence subgroup if there exists a positive integer N such that it contains In Table 1 we list some of the congruence subgroups that will appear more frequently during the course of this paper. In this table, N stands for a positive integer, p for an odd prime number, and r p for the natural reduction map SL 2 (Z) → SL 2 (F p ). Moreover, given an odd prime number p, we fix a non-split Cartan subgroup C ns (p) of GL 2 (F p ) and write C + ns (p) for its normaliser. Table 1. Some congruence subgroups of SL 2 (Z).
We will work with modular curves obtained as quotients of the extended upper half plane H * by one of the congruence subgroups above or by some intersections of them. In fact, for any congruence subgroup Γ that we will work with, it can be shown that the Riemann surface Γ\H * descends to an algebraic curve defined over Q. The point on this curve corresponding to i∞ will be known as the cusp at infinity and will be denoted by ∞. In the following table we set up some terminology and summarise some of the facts concerning to these modular curves that will reveal to be useful later.

Congruence subgroup
Modular curve Table 2. Some modular curves.
With the notation set up, we are now ready to prove the results we will need. We start by noting that if E is an elliptic curve defined over Q and without complex multiplication, then the values of q for which the image ofρ E,q is contained in the normaliser of a split Cartan subgroup of GL 2 (F q ) are very restricted. In fact, we have the following result.
Theorem 3.1 (Bilu-Parent-Rebolledo [3]). Let E/Q be an elliptic curve without complex multiplication. Then, if q is a prime such that q = 11 or q ≥ 17, the image ofρ E,q cannot be contained in the normaliser of a split Cartan subgroup of GL 2 (F q ).
Recently, Balakrishnan, Dogra, Müller, Tuitman and Vonk [1] showed that the only Q-rational points of X + sp (13) are its cusps, thus proving the following theorem. Theorem 3.2 ([1, Theorem 1.1]). Let E/Q be an elliptic curve without complex multiplication. Then the image ofρ E,13 is not contained in the normaliser of a split Cartan subgroup of GL 2 (F 13 ).
Therefore, we are reduced to considering the cases where q ∈ {2, 3, 5, 7}, i.e., the cases where the genus of X + sp (q) is 0. However, further ahead, we will need some of the results in this section to hold in the case q = 13 as well. In fact, Theorem 3.2 will only be used in the proof of Theorem 1.4 in order to obtain the explicit bound of 37 (see Theorem 1.4 below); up until then, we will always assume that q ∈ {2, 3, 5, 7, 13}. We remark that these are precisely the primes q for which X 0 (q) has genus 0, a fact that plays an important role in the proof of Proposition 3.6.
The following is a more general version of [10, Proposition 2.2]. We will need this general form later. . Let K be a number field of degree n and let E be an elliptic curve defined over K. Let p be a prime such that the image ofρ E,p is contained in the normaliser of a non-split Cartan subgroup of GL 2 (F p ). If E has potentially multiplicative reduction at a prime λ not dividing p, then N K/Q (λ) 2 ≡ 1 (mod p). Moreover, if p > 2n + 1, then E has potentially good reduction at every prime of K dividing p.
Proof. Given a prime λ of K, write K λ for the completion of K at λ. LetK andK λ be algebraic closures of K and K λ , respectively. Fix an embeddingK ֒→K λ . This induces an embedding of absolute Galois groups G K λ ֒→ G K , which amounts to a choice of a decomposition subgroup of G K over λ. Now, suppose that E has potentially multiplicative reduction at λ. Then we know that E /K λ is a twist of a Tate curve E q , q ∈ K × λ . Let ψ be the character associated to this twist. It is well-known that ψ is either trivial or quadratic. Therefore, we haveρ where χ p : G K λ → F × p stands for the mod p cyclotomic character. As a Cartan subgroup of GL 2 (F p ) is an index 2 subgroup of its normaliser,ρ E,p (σ) 2 is an element of a non-split Cartan subgroup of GL 2 (F p ) for every σ ∈ G Kp . Moreover, since ψ is at most quadratic, the eigenvalues ofρ E,p (σ) 2 are χ p (σ) 2 and 1. However, the eigenvalues of an element of a non-split Cartan subgroup are F p -conjugate. This means that χ p (σ) 2 = 1 for every σ ∈ G K λ .
If λ does not divide p, then this means that N K/Q (λ) 2 ≡ 1 (mod p), as the statement of the proposition predicts.
In order to simplify notation, we will write X −,+ sp,ns (q, p) for the curve X sp (q) × X(1) X + ns (p), X +,+ sp,ns (q, p) for the curve X + sp (q) × X(1) X + ns (p), and X + 0,ns (N, p) for the curve X 0 (N ) × X(1) X + ns (p), where N is a positive integer. These three curves correspond to certain quotients of the extended upper half plane: there is an analytic isomorphism between X −,+ sp,ns (q, p)(C) and the quotient of H * by Γ sp (q) ∩ Γ + ns (p), another one between X +,+ sp,ns (q, p)(C) and the quotient of H * by Γ + sp (q) ∩ Γ + ns (p), and another between X + 0,ns (N, p)(C) and the quotient of In what follows, we will write w q 2 for the involution of X + 0,ns (q 2 , p) arising from the Atkin-Lehner involution of X 0 (q 2 ) (recall that the moduli intepretation of the Atkin-Lehner involution of X 0 (q 2 ) is as follows: a point of X 0 (q 2 ) represented by (E, ϕ) -where E is an elliptic curve and ϕ : E → E ′ is an isogeny of degree q 2 -is mapped to (E ′ ,φ), whereφ stands for the dual isogeny of ϕ).
Remark. Even though there exists an isomorphism between X 0 (q 2 ) and X sp (q), this is not enough to conclude Lemma 3.4, because this isomorphism does not preserve j-invariants.
Proof. Even though the existence of an isomorphism between X −,+ sp,ns (q, p) and X + 0,ns (q 2 , p) cannot be directly proven by appealing to the isomorphism between X 0 (q 2 ) and X sp (q), the proofs of the existence of these two isomorphisms are essentially the same. Indeed, start by identifying X + 0,ns (q 2 , p)(C) with the Riemann surface Γ 0 (q 2 ) ∩ Γ + ns,1 (p)\H * , where Γ + ns,1 (p) is r −1 p (C 1 ∩SL 2 (F p )) for some normaliser C 1 of a non-split Cartan subgroup of GL 2 (F p ) (recall that r p : SL 2 (Z) → SL 2 (F p ) stands for the reduction modulo p). Similarly, we identify X −,+ sp,ns (q, p)(C) with the Riemann surface Γ sp (q) ∩ Γ + ns (p)\H * . Set Γ := Γ 0 (q 2 ) ∩ Γ + ns,1 (p) and define The Riemann surface QΓQ −1 \H * corresponds to the C-points of an algebraic curve X 2 . The isomorphism between X + 0,ns (q, p)(C) and X 2 (C) just defined can be seen to descend to an isomorphism defined over Q. Therefore, we have a Q-isomorphism between X + 0,ns (q, p) and X 2 . Now, we can define an isomorphism between X 2 and X −,+ sp,ns (q, p) by a simple F p -base change. In a more formal way, we note that if g ∈ GL 2 (F p ) is such that gC 2 g −1 = C 1 , and if X(p) denotes the modular curve parametrising elliptic curves with full p-torsion, then the automorphism of X(p) defined by multiplication by g induces a Q-isomorphism C 2 \X(p) → C 1 \X(p). Moreover, this isomorphism preserves j-invariants. Since we have there is a Q-isomorphism from X 2 to X −,+ sp,ns (q, p). The isomorphism θ is obtained by composing this isomorphism with the isomorphism from X + 0,ns (q, p) to X 2 defined above. The statement relating the involutions of X −,+ sp,ns (q, p) and X + 0,ns (q, p) with the isomorphism θ can be achieved by looking at the moduli interpretation of θ.
Remark. The moduli intepretation of the isomorphism θ is given as follows. A C-point in X −,+ sp,ns (q, p) is represented by a tuple (E, ϕ 1 , ϕ 2 , n), where ϕ 1 : E → E 1 and ϕ 2 : E → E 2 are two independent isogenies of degree q and n is a necklace (for the definition of a necklace, see [14]). The image of this point under θ is represented by the tuple (E 1 , ϕ 2 •φ 1 , ϕ 1 (n)), whereφ 1 stands for the dual isogeny of ϕ 1 , and ϕ 1 (n) is the necklace in E 1 obtained as the image of the necklace n via ϕ 1 .
The curve X + 0,ns (q 2 , p) comes equipped with two "degeneracy maps" d 1 , d 2 : X + 0,ns (q 2 , p) → X + 0,ns (q, p) coming from the degeneracy maps from X 0 (q 2 ) to X 0 (q). Let us briefly recall that the moduli interpretations of these degeneracy maps from X 0 (q 2 ) to X 0 (q) are as follows: a point in X 0 (q 2 ) represented by (E, C) -where E is an elliptic curve and C is a cyclic subgroup of E(C) of order q 2 -is mapped by one of the degeneracy maps to (E, C[q]), and by the other to (E/C[q], C/C[q]). The maps d 1 and d 2 satisfy the relations where w q is the involution X 0,ns (q, p) coming from the Atkin-Lehner involution of X 0 (q). Let J + 0,ns (q, p) stand for the Jacobian of X + 0,ns (q, p). Adapting to our case a morphism from X + 0 (q 2 ) to J 0 (q) that appears in section 3 of [12] and in [13], we define g : X + 0,ns (q 2 , p) → J + 0,ns (q, p) by mapping a point P to the class of d 1 (P )−d 2 (P ). By abuse of notation, we shall denote by w q the involution of J + 0,ns (q, p) induced by the involution w q of X + 0,ns (q, p). Equations (3.1) give us the following equality: Consider the abelian subvariety B of J + 0,ns (q, p) defined by B := (1 + w q )J + 0,ns (q, p). Define J := J + 0,ns (q, p)/B and let π be the canonical projection from J + 0,ns (q, p) to J. From equation (3.2) and Lemma 3.4, we conclude that π • g factors through X +,+ sp,ns (q, p). Thus, we have the following commutative diagram: Table 2). Note that π • g(∞) = 0.
Proposition 3.5. There exists a non-trivial optimal quotient A of J + 0,ns (q, p) such that A(Q) is finite and the kernel of the canonical projection π ′ : J + 0,ns (q, p) → A is stable under the Hecke operators T ℓ , ℓ prime = p. Moreover, π ′ factors through π.
Proof. The first part of the proposition has been proved in [6, Proposition 7.1] (even though this is only stated for the case where q = 2, 3, it is not hard to see that the same argument shows that the result holds for q ∈ {2, 3, 5, 7, 13}). In order to see that π ′ factors through π, note that A is defined to be the winding quotient of the new part of J + 0,ns (q, p) (see [6]). Since 1 + w q is an element of the winding ideal, it follows from the definition of J and π that π ′ factors through π.
Let h denote the composition of π • g with the natural projection from J to A. Now, let O be the ring of integers of Q(ζ p ) + and define R := O[1/2qp]. Given a curve X defined over Q, we shall write X /R for the minimal regular model of X over R. Similarly, given an abelian variety B, we shall write B /R for the Néron model of B over R. With this notation, the morphism h extends to a morphism X + 0,ns (q 2 , p) /R → A /R . By abuse of notation, we shall refer to this morphism by h as well.
Before stating our next result, let us recall the definition of formal immersion. Let S 1 and S 2 be two schemes and let f : S 1 → S 2 be a morphism. Let x be a point in S 1 and define y := f (x). WriteÔ S 1 ,x andÔ S 2 ,y for the formal completions of the local rings of S 1 and S 2 at x and y, respectively. We say that f is a formal immersion at x if the induced morphismf x :Ô S 2 ,y →Ô S 1 ,x is surjective. Now, let A be a Dedekind domain and suppose that S 1 and S 2 are schemes over Spec(A). Let x be a section (over A) of S 1 , and let y be the section of S 2 which corresponds to the image of x. We will say that f is a formal immersion at x if f is a formal immersion at x p for every non-zero prime ideal p of A, where x p stands for the special fibre of x at p. Proposition 3.6. The morphism h is a formal immersion at ∞ /R , where ∞ /R stands for the section over R defined by ∞.
Proof. The proof of this result is standard (see, for example, [12]). Indeed, let λ be a prime of K := Q(ζ p ) + not dividing 2qp. Let F λ denote the residue field at λ of Q(ζ p ) + . Write Cot ∞ (X + 0,ns (q 2 , p) /F λ ) for the cotangent space of X + 0,ns (q 2 , p) /F λ at ∞ /F λ . In a similar manner, write Cot(J + 0,ns (q, p) /F λ ) for the cotangent space of J + 0,ns (q, p) /F λ at 0 /F λ , and the same thing goes for Cot(A). Showing that h is a formal immersion at ∞ /F λ is equivalent to showing that the map Cot(A /F λ ) → Cot ∞ (X + 0,ns (q 2 , p) /F λ ) is surjective. As the characteristic of λ is different from 2, Cot(A /F λ ) injects into Cot(J + 0,ns (q, p) /F λ ) (see [12,Corollary 1.1]). Since A is non-trivial, there exists a non-trivial element f ∈ Cot(A /F λ ). Regarding f as an element of Cot(J + 0,ns (q, p) /F λ ), let be the q-expansion of f . The image of f in Cot ∞ (X + 0,ns (q 2 , p) /F λ ) is a 1 (f ), as can be easily checked. If a 1 (f ) = 0 (in F λ ), then we are done. Suppose, for the sake of contradiction, that a 1 (f ) = 0 and a 1 (T ℓ f ) = 0 for every prime ℓ = p. Now, a 1 (T ℓ f ) = a ℓ (f ), which yields that a n (f ) = 0 for every n coprime to p. Thus, Therefore, f is the reduction modulo λ of a cusp form in S 2 (Γ 0 (q)). However, since q ∈ {2, 3, 5, 7, 13}, this vector space is trivial, which is a contradiction.
Corollary 3.7. The morphism X +,+ sp,ns (q, p) /R → A /R is a formal immersion at ∞ /R . Proof of Proposition 1.5. Once again, the argument is standard. We start by noting that, given a Q-rational point P of X +,+ sp,ns (q, p), its image Q in A is torsion, because the morphisms are defined over Q and A has finite Mordell-Weil group. Let ℓ be a prime congruent to ±1 mod p (as p ≥ 11, Proposition 3.3 asserts that these are the only primes we have to worry about). Since p ≥ 11, we have ℓ > 2. Note that, since ℓ ≡ ±1 (mod p), ℓ is inert in Q(ζ p ) + . LetÃ stand for the special fibre of the Néron model of A over Z ℓ . It is well-known that the reduction map gives us an injection Tors(A(Q)) ֒→Ã(F ℓ ). Therefore, writingQ for the reduction of Q modulo ℓ, we haveQ = 0 inÃ(F ℓ ) if, and only if, Q = 0.
Suppose that E has potentially multiplicative reduction at ℓ. Then it gives rise to a Q-rational point P in X +,+ sp,ns (q, p) which meets one of the cusps at the fibre at ℓ. By choosing appropriate bases for GL 2 (F q ) and GL 2 (F p ), we may assume that this cusp is ∞. Therefore, writing, as above, Q for the image of P in A, we find thatQ = 0. Hence, by the observation of the previous paragraph, Q = 0. Since the morphism X +,+ sp,ns (q, p) /R → A /R is a formal immersion at ∞ /R in characteristic ℓ, and as P meets ∞ at the fibre of ℓ, we must have P = ∞, which is a contradiction.
We are finally ready to prove Theorem 1.4.
Proof of Theorem 1.4. We will make use of Proposition 1.5. The argument used here is analogous to the one used in the proof of [10, Theorem 1.1]. Suppose that E/Q and q are as in the statement of Theorem 1.4. Due to Theorem 3.2, we can restrict ourselves to the case q ∈ {2, 3, 5, 7}. Moreover, as the normalisers of non-split Cartan subgroups of GL 2 (F 2 ) are precisely its Borel subgroups, and as the case of Borel subgroups has already been treated by Theorem 1.3, we can assume that q ∈ {3, 5, 7}. Suppose that there exists a prime p > 37 for whichρ E,p is not surjective. Then the image ofρ E,p must be contained in the normaliser of a non-split Cartan subgroup of GL 2 (F p ). Proposition 1.5 now yields that the j-invariant of E must be integral. Therefore, the elliptic curve E gives rise to a Q-rational point in X + sp (q) with integral j-invariant. By an appropriate choice of uniformisers, the j-invariant map j : X + sp (q) → P 1 can be explicitly described by one of the equations of Table 3 (the source of these equations is [5, p. 68 Table 3. Equations for the j-invariants of X + sp (q).
Resorting to these equations, we are able to verify that there are only finitely many Q-rational points in X + sp (q) with integral j-invariants. Moreover, the finitely many jinvariants associated to these points can be extracted from these equations: these are −12288000, −884736, −32768, −5000, −1728, 0, 1728, 8000, 54000 and 287496. Of these, the only ones corresponding to elliptic curves without complex multiplication are −5000 and −1728. Thus, j(E) ∈ {−5000, −1728}.
An example of an elliptic curve with j-invariant −5000 is the one given by the equation and an example of an elliptic curve with j-invariant −1728 is the one given by Upon consultation on the LMFDB database [19] -where information about the image of mod p Galois representations of elliptic curves was obtained using a method of Sutherland [18] -, we can observe that, if p > 37, the representationsρ E 1 ,p andρ E 2 ,p are both surjective. Recalling that any two elliptic curves without complex multiplication and sharing the same j-invariant are quadratic twists of each other, we conclude thatρ E,p is surjective for every prime p > 37, yielding a contradiction.
It is worth highlighting that Theorem 3.2 is only needed here to obtain an explicit upper bound for the non-surjective primes (which turns out to be 37). If we were only interested in showing that there exists a constant C such thatρ E,p is surjective for every prime p > C and every elliptic curve E satisfying the conditions of Theorem 1.4, then this could be achieved via Siegel's theorem as follows. Since the j-invariant map j : X + sp (13) → P 1 has more than two distinct points mapping to the point at infinity of P 1 , Siegel's theorem asserts that there are only finitely many points in X + sp (13)(Q) whose j-invariant is integral.
Therefore, even without assuming that all the Q-rational points of X + sp (13) are cuspidal or CM-points, we are still able to conclude that there are only finitely many isomorphism classes of elliptic curves satisfying the conditions of Theorem 1.4 and admitting a prime p > 37 for which the Galois representationρ E,p is not surjective (recall that, under these conditions, the j-invariant of such an elliptic curve must be integral). We can now use Theorem 1.1 and the fact that, for elliptic curves without complex multiplication, the surjectivity of the Galois representation only depends on its isomorphism class to conclude the existence of our constant C.

The case of Q-curves
We start by proving Theorem 1.10. Let us just remark that if K is a quadratic field and E/K is an elliptic curve completely defined over K and of degree 1, then E is defined over Q. But theorems 1.6, 1.7 and 1.10 are already known to hold when E is defined over Q (Theorem 1.7 for elliptic curves over Q is simply Theorem 1.4, which we have just proved). Therefore, in everything that follows, whenever we speak of a Q-curve, we will mean a Q-curve that is not defined over Q. In the terminology of [9], these are known as strict Q-curves.

4.1.
Proof of Theorem 1.10. In order to obtain Theorem 1.10 from the proposition above, we will use the following result of Le Fourn.

Proposition 4.1 ([9, Proposition 3.3]).
Let K be a quadratic field and let E be a Q-curve completely defined over K and of square-free degree d. Assume, moreover, that the image of Pρ E,p is contained in a Borel subgroup of PGL 2 (F p ) for some prime p = 11 or p ≥ 17 such that p ∤ d. Then j(E) ∈ O K . The proof will be essentially an adaptation of an argument due to Mazur that can be found in sections 5, 6 and 7 of [12].
From now to the end of this section, K will be a quadratic number field, E/K will be a Q-curve completely defined over K, of square-free degree d ≥ 2 and without complex multiplication, and p ≥ 13 will be a prime number such that p ∤ d and for which the image of Pρ E,p is contained in a Borel subgroup of PGL 2 (F p ). We will assume that p does not ramify in K. Consider the Galois representationρ E,p : G K → GL 2 (F p ). As the image of Pρ E,p is contained in a Borel subgroup of PGL 2 (F p ), we can choose a basis P, Q of E[p](K) such that P is a cyclic subgroup of E(K) defined over K (i.e., τ ( P ) = P for every τ ∈ G K ). With respect to this basis, the representationρ E,p : G K → GL 2 (F p ) has the shape φ * 0 ϕ , where φ and ϕ are two characters G K → F × p . Lemma 4.2. Let p be a prime of K dividing p. Then there exists a unique element k ∈ Z/(p − 1)Z and a character α : G K → F × p unramified at p such that φ = αχ k p , where χ p stands for the mod p cyclotomic character.
Proof. Let G p be a decomposition subgroup of G K associated to p and let O p denote the ring of integers of K p , the completion of K at p. The Artin map of class field theory gives us a continuous homomorphism O × p → G ab p , from where we obtain another continuous map O × p → F × p by composition with φ| Gp . Using the assumption that p does not ramify in K, it is easy to see that every continuous homomorphism O × p → F × p must factor through N : O × p → Z × p , where N stands for the norm map. The result now follows from the fact that every continuous homomorphism Z × p → F × p is a power of the cyclotomic character (where we identify Z × p with the inertia subgroup of Gal(Q ab p /Q p ) via local class field theory). Let p be a prime of K lying above p. We now know thatρ E,p has the shape where α is some character unramified at p. If p remains prime in K, then, trivially, α is unramified at every prime of K lying above p. The next lemma asserts that this is also true even if p splits.
Lemma 4.3. Using the above notation, α is unramified at every prime of K lying above p.
Proof. This is only true because we are assuming that the image of Pρ E,p is contained in a Borel subgroup of PGL 2 (F p ). Let us start by recalling the notation introduced in Section 2. For each element τ ∈ G Q , we have a K-isogeny µ τ : τ E → E satisfying the following conditions: if the restriction of τ to K is the trivial automorphism of K, then µ τ is the identity; if, on the other hand, the restriction of τ to K is the non-trivial automorphism of K, then µ τ has degree d and, moreover, if τ ′ ∈ G Q is another element restricting to the non-trivial automorphism of K, then µ τ = µ τ ′ . Note that as the image of Pρ E,p is contained in a Borel subgroup of PGL 2 (F p ), we have µ τ ( τ P ) ∈ P for every τ ∈ G Q . As the result trivially holds when p remains prime in K, and as we are assuming that p does not ramify in K, we will assume that p splits in K. If this is the case, let q be the other prime of K lying above p. Let σ ∈ G Q be an element which restricts to the non-trivial automorphism of K. If D p is a decomposition subgroup of G K over p, then D q := σD p σ −1 is a decomposition subgroup of G K over q. Moreover, if I p and I q denote the corresponding inertia subgroups, we have I q = σI p σ −1 . Therefore, every element of I q can be uniquely written in the form στ σ −1 with τ ∈ I p . Let τ ∈ I p . As any τ ∈ I p acts as χ p (τ ) k on P , and as µ σ ( σ P ) ∈ P , we get for every τ ∈ I p . Therefore, the restriction of φ to I q is χ k p , proving that φ = αχ k p for some character α : G K → F × p unramified at every prime dividing p. Lemma 4.4. Using the above notation, there are integers e | 12 and a, b ∈ {0, . . . , e} such that Proof. We know that E has potentially good reduction at p. Therefore, after taking a field extension L of K p with ramification degree dividing 12, but at most 6, the curve E acquires good reduction at p. Let e denote the absolute ramification degree of L. As we are assuming that p does not ramify in K, the integer e is the ramification degree of L over K p . Let I p and I L denote the inertia subgroups of G Kp and G L , respectively, and let I t p and I t L denote the respective tame inertia groups. Of course, φ and ϕ factor through I t p . Let θ denote the fundamental character of level 1 for I L . We have χ p = θ e . Therefore, φ| I L = θ ek and ϕ| I L = θ e(1−k) . By a theorem of Raynaud, there are integers a, b ∈ {0, . . . , e} such that ek ≡ a (mod p − 1) and e(1 − k) ≡ b (mod p − 1).
Following the notation of Mazur [12], we set m := (p − 1)/2, n := num((p − 1)/12) and t := m/n. Consider the finite flat cyclic covering X 1 (p) /S → X 0 (p) /S of degree (p − 1)/2. There is an intermediate cover X 1 (p) /S → X 2 (p) /S → X 0 (p) /S . The only properties of the covering X 2 (p) /S → X 0 (p) /S that we are going to use are the following: it is a finiteétale morphism of smooth S-schemes and its Galois group is isomorphic to the cyclic group Z/nZ, where n := num((p − 1)/12). This yields that the degree of X 1 (p) → X 2 (p) is t.
Our curve E gives rise to a point x = [(E, C p )] ∈ X 0 (p)(K). As all the coverings are cyclic, there exists a finite abelian extension L/K for which there is a point y = [(E ′ , P ′ )] ∈ X 1 (p)(L) mapping to x. Moreover, as X 2 (p) /S → X 0 (p) /S is finiteétale, the ramification degree of L/K at any prime of characteristic different from p divides t, and so it also divides 6. Now, as y maps to x, there is an L-isomorphism f : E → E ′ mapping C p to P ′ . The L-isomorphism f is associated to an element of H 1 (Gal(L/K), Aut L (E)). However, Aut L (E) = {±1}, as E does not have complex multiplication. Therefore, given a prime λ of K of characteristic different from p, we find that α t | I λ is a quadratic character, yielding that α 2t is unramified at λ. As we already know that α is unramified at any prime of characteristic p, we get the result.
Let us just review what we have so far. The mod p Galois representationρ E,p has the shape αχ k where χ p is the mod p cyclotomic character, α is a character such that α 2t is unramified everywhere, and k satisfies the properties listed in Lemma 4.4. Let λ be a prime of K of characteristic different from p. Write G λ for a decomposition subgroup of G K over λ. Let α λ denote the restriction of the character α to G λ . As in section 6 of [12], we are going to split it in its ramified and unramified part. From local class field theory, we have a (non-unique) decomposition where O λ denotes the ring of integers of K λ . Sticking to the notation of Mazur, we write α λ = γ λ · b λ , where the character γ λ factors through O × λ in the decomposition above and b λ is unramified. Lemma 4.5 implies that γ λ has order dividing 2t. Let L denote the splitting field of γ λ . This is a totally ramified extension of K λ of degree dividing 2t.
Lemma 4.6. Using the above notation, the elliptic curve E has good reduction over L.
Proof. Suppose, for the sake of contradiction, that E does not have good reduction over L. Let F q denote the residue field of K (q being its size) andẼ/F q denote the special fibre of the Néron model of E over O L (as L is totally ramified, the residue field of L is that of K). Note that we haveρ Let F be the splitting field of b λ χ k p . Then F is an unramified extension of L and E(F ) has a p-torsion point. Moreover, as Néron models are stable underétale base change, the special fibre of the Néron model of E over O F isẼ /F F , where O F is the ring of integers of F and F F is its residuel field. We conclude that there is a p-torsion point inẼ(F F ), which is clearly impossible when E has bad reduction at L. Therefore, E acquires good reduction at L.
As a consequence,ρ E,p | Gal(L/L) factors through Gal(L unr /L). The Galois group Gal(L unr /L) is generated by the Frobenius automorphism Frob λ .
where q is the size of the residue field of K λ and Tr(Frob λ ) ∈ Z is the trace of the action of the Frobenius element of Gal(L unr /L) on the p-adic Tate module of E.
Case (1) yields 6k ≡ 3 (mod p − 1), which is not possible, as p is odd. For similar reasons, we cannot have case (3): here we would be forced to have 2k ≡ 1 (mod p − 1). We are only left with case (2). In this case, we obtain the congruence 4k ≡ 2 (mod p − 1). If p ≡ 1 (mod 4), this is not possible. Thus, in this case, we must have 2 · q 6c < q rca + q rcb .
Let us now turn to the case where p ≡ 3 (mod 4). As we have seen in the proof above, if we are not in any of the cases (1), (2) or (3), then we obtain the bound 2 6f c+1 (2 6f c + 1). We therefore assume we are in one of these cases. Again, (1) and (3) cannot occur, so let us assume we are in case (2). In other words, we are going to assume, from now on, that r = 3, e = 4 and a = b = 2. As observed above, this yields 2k ≡ 1 (mod m) (where, recall, m was defined to be (p − 1)/2), and, moreover, t = 1 or t = 3. Analogously to what is done in [12], the aim of what follows is to show that every prime 5 ≤ ℓ < p/4 unramified in K and such that ℓ ∤ d satisfies ℓ p = −1.
After this has been proven, an application of Minkowski's bound for the norm of ideals in a class of the ideal class group will yield the theorem (cf. section 7 of [12]).
Before proceeding, let us make a remark that will be useful later on. Note that, as a consequence of E not having complex multiplication, we have µ σ • σ µ σ = d or −d, where σ ∈ G Q restricts to the non-trivial automorphism of K.
Lemma 4.8. Let K ′ be a quadratic extension of K. Let E ′ be a K ′ -twist of E, and let g : All of these statements are easy to prove. If E ′ is a trivial twist (i.e., if it is Kisomorphic to E), then the result is trivial. Suppose then that this is not the case. Consider the map τ → g −1 ( τ g), τ ∈ Gal(K ′ /K). This is a 1-cocycle Gal(K ′ /K) → Aut K ′ (E K ′ ). As E does not have complex multiplication, Aut K ′ (E K ′ ) = {±1}, and so Thus, τ → g −1 ( τ g) is a quadratic character Gal(K ′ /K) → {±1}. As we are assuming that E ′ is not a trivial twist, we conclude that τ g = −g if τ ∈ Gal(K ′ /K) is the non-trivial element. Similarly, τ ( σ g) = − σ g for every σ ∈ G Q . Therefore, As a consequence of this lemma, we may assume, after taking an appropriate quadratic twist if needed, that E satisfies one of the following statements: (A) µ σ • σ µ σ = d and b λ (Frob λ ) = −1 for every prime λ of K of residual degree 2 and of odd characteristic < p/4; (B) µ σ • σ µ σ = −d and b λ (Frob λ ) = 1 for every prime λ of K of residual degree 2 and of odd characteristic < p/4.
In order to treat the case where p ≡ 3 (mod 4), we will resort to some general theory that can be consulted in [15].
Let A/Q be the abelian surface defined by A := Res K/Q (E). This is a Q-simple abelian variety of GL 2 -type.
depending on whether µ σ • σ µ σ = d or −d, respectively (see section 7 of [15]). Let q be a prime of F over p. If we denote by ρ E,p the Galois representation of E obtained by the Galois action on the Tate module V p (E) := T p (E) ⊗ Q p , then we have where ρ A,q stands for the Galois representation obtained from the Galois action on V q (A) := V p (A) ⊗ F ⊗Qp F q (recall that V p (A) is free of rank 2 over F ⊗ Q p ). The reduction of ρ A,q modulo q is well-defined up to semi-simplification, so we are going to denote bȳ this semi-simplified reduction. If we writeρ ss E,p for the semi-simplification ofρ E,p , then ρ A,q | G K is isomorphic toρ ss E,p . It can be easily verified that the condition that the image of Pρ E,p is contained in a Borel subgroup of PGL 2 (F p ) implies that the image ofρ A,q is contained in a Borel subgroup of GL 2 (F q ), and so is contained in a split Cartan, asρ A,q is semi-simple (see section 6 of [15] and, in particular, [15,Lemma 6.4]).
Let us just mention a standard lemma that will be useful later. This is just a special case of [4,Chapitre III,9.4,Proposition 6], but it suffices for our purposes.
As p is unramified in K, and asρ A,q | G K is isomorphic toρ ss E,p , we find that for some character β : G Q → F × q unramified at p such that β| G K = α, and where θ : G Q → GL 2 (F q ) is a quadratic character defined as follows: if σ ∈ G Q restricts to the non-trivial automorphism of K, then otherwise, the image is 1 (see section 7 of [15]). In particular, if µ σ • σ µ σ = d, then F is real and θ = 1.
Notation. In order to simplify exposition, from here on, given a rational prime ℓ, we are going to assume we have fixed an embeddingQ ֒→Q ℓ . This amounts to choosing a decomposition subgroup G ℓ of G Q over ℓ. Moreover, every number field L will be regarded as subfields ofQ, so that, given a prime λ of L dividing ℓ, we have an embedding of the decomposition subgroup G λ of L over λ into G ℓ . Similarly, algebraic extensions of Q ℓ will be regarded as subfields ofQ ℓ .
In what follows, λ will be a prime of K and ℓ will be the rational prime lying below λ. We will further assume that 5 ≤ ℓ < p/4, ℓ ∤ d and that ℓ does not ramify in K. Moreover, we will assume that p is large enough so that it does not ramifiy in F . Write β ℓ for the restriction of β to G ℓ . As we did before, we can resort to class field theory to (non-uniquely) decompose G ab ℓ as G ab ℓ ∼ = Z × ℓ ×Ẑ, and we obtain a decomposition β ℓ = η ℓ ·δ ℓ , where η ℓ factors through Z × ℓ and δ ℓ is unramified. Let L ′ be the splitting field of η ℓ . It is a totally ramified extension of Q ℓ . Moreover, if we keep writing L for the splitting field of γ λ over K λ in the decomposition of G ab λ , it can be easily checked that L is an unramified extension of L ′ of degree equal to that of K λ /Q ℓ . Therefore, the degree of L ′ /Q ℓ is the same as the degree of L/K λ . In particular, it divides 2t. Lemma 4.10. Using the above notation, β 4t = 1. Moreover, if ℓ splits in K, then β 2t ℓ = 1. Proof. Recall that β| G K = α, and that α 2t is unramified at every prime of K (see Lemma 4.5). We claim that β 4t is unramified everywhere.
As β 4t is a character defined on G Q , it follows that it is trivial, which proves the first part of the lemma.
Lemma 4.11. Using the above notation, A acquires good reduction over L ′ .
Proof. Denoting the absolute Galois group of L ′ by G L ′ , what we have to show is that ρ A,p | G L ′ is unramified, where ρ A,p is the Galois representation of the Tate module V p (A) of A. As L is unramified over L ′ , it is enough to show that ρ A,p | G L is unramified. Since A is the Weil restriction of E from K to Q, and noting that K ⊆ L, we see that ρ A,p | G L is the direct sum of the Galois representations (restricted to G L ) associated to V p (E) and V p ( σ E), where σ ∈ Gal(K/Q) is non-trivial. As these two representations are isomorphic, it is therefore enough to show that ρ E,p | G L is unramified. But we already know from Lemma 4.6 that E has good reduction over L, which yields that ρ E,p | G L is unramified, finishing the proof of the lemma.
As a consequence, ρ A,q | G L ′ factors through Gal((L ′ ) unr /L ′ ). Writing Frob ℓ for the Frobenius element of Gal((L ′ ) unr /L ′ ), we obtain a result analogous to Lemma 4.7: where a ℓ ∈ O F stands for the trace of ρ A,q (Frob ℓ ). If we denote by P ℓ (T ) the characteristic polynomial of ρ A,q (Frob ℓ ) (which has coefficients in F ), then Lemma 4.9 asserts that N F/Q (P ℓ (T )) is precisely the characteristic polynomial of ρ A,p (Frob ℓ ). As all the roots of the characteristic polynomial of ρ A,p (Frob ℓ ) have complex size √ ℓ (independently of the embedding into C chosen), we conclude that |a ℓ | ≤ 2 √ ℓ for every embedding of F into C.
Taking norms from F to Q, and recalling that ℓ 2k ≡ ℓ (mod p), we get As |a ℓ | ≤ 2 √ ℓ for every embedding of F in C and as ℓ < p/4, we conclude that we must have ℓ = N F/Q (a ℓ ) or 4ℓ = N F/Q (a ℓ ). In any case, v ℓ (N F/Q (a ℓ )) = 1, which is only possible if ℓ ramifies in F . However, , and ℓ is an odd prime not dividing d, so we obtain a contradiction. Therefore, if 3 ≤ ℓ < p/4, ℓ ∤ d and if ℓ splits in K, then ℓ is not a quadratic residue modulo p.
Recalling that ℓ 2k ≡ ℓ (mod p), and after taking norms from F to Q in the appropriate cases, the three cases above give 4ℓ ≡ N F/Q (a ℓ ) (mod p) or ℓ ≡ N F/Q (a ℓ ) (mod p) or − 3ℓ ≡ N F/Q (a ℓ ) (mod p).
Using the same kind of arguments we used above, we conclude that v ℓ (N F/Q (a ℓ )) = 1, implying that ℓ ramifies in F (recall that we are assuming that ℓ > 3), which it does not. We omit the proof of the case where ℓ remains prime in K and (B) holds, as it is treated in a similar manner to the case where (A) holds, except that now we have θ(Frob ℓ ) = −1.
We conclude that if ℓ is a prime satisfying 5 ≤ ℓ < p/4, ℓ ∤ d and if ℓ does not ramify in K, then ℓ is not a quadratic residue modulo p. In other words, ℓ remains prime in Q( √ −p).
If m d is the number of prime divisors of d and m K is the number of rational primes that ramify in K, then the number of primes < p/4 which do not remain prime in Q( √ −p) is ≤ m d + m K + 2. Therefore, there is an integer M K,d depending only of K and d such that the number of classes of the ideal class group of Q( √ −p) represented by an integral ideal of norm < p/4 is ≤ M K,d . However, a well-known result of Minkowski states that each class of the ideal class group is represented by an integral ideal of norm < 2 √ p/π, which is a number smaller than p/4. This means that the class number of Q( √ −p) is bounded above by M K,d . As there are only finitely many imaginary quadratic fields of a given class number, we conclude that p can only be one of finitely many possibilities which only depend on K and d. Theorem 1.10 follows.

4.2.
The Borel case. The aim of this section is to provide a proof of Proposition 1.8 and Theorem 1.6. The arguments used to prove Proposition 1.8 follow closely those of Ellenberg [8].
Let p and q be as in the statement of Proposition 1.8. Define Z d,0 (q, p) := X 0 (d) × X(1) X + 0,ns (q, p). Lemma 4.12. Let w d denote the involution of Z d,0 (q, p) induced by the Atkin-Lehner involution of X 0 (d). Let E be a Q-curve as in the statement of Proposition 1.8. Then E gives rise to a K-point P in Z d,0 (q, p) satisfying w d P = σ P for every σ ∈ G Q restricting to the non-trivial element of Gal(K/Q).
Proof. The proof of this result is identical to the proof of [8, Proposition 2.2].
As in [8], we are going to consider a suitable quadratic twist of Z d,0 (q, p) whose Q-rational points will correspond to Q-curves completely defined over K, of degree d, without complex multiplication and with level structures at q and p corresponding to the curve X + 0,ns (q, p) (i.e., Q-curves satisfying the conditions of Proposition 1.8).
These two maps are defined over L := K(ζ p + ζ −1 p ). We finally set h := h 1 + h 2 . Denote by O L the ring of integers of L and define R := O L [1/6qp]. Using the notation of section 3, h can be extended to a morphism Z ψ d,0 (q, p) /R → A /R . By abuse of notation, we shall denote this morphism by h as well.
In what follows, the point at infinity of Z ψ d,0 (q, p) is, of course, defined to be the image of the point at infinity of Z d,0 (q, p) via ϕ. . For the convenience of the reader, we will present the proof here. We first note that it is enough to show that the morphism γ := γ 1 + γ 2 is a formal immersion at ∞ /R . Let λ be a prime ideal of R and let F λ be the associated residue field. Writing Cot(A /F λ ) for the cotangent space of A /F λ at 0, and Cot ∞ (Z d,0 (q, p) /F λ ) for the cotangent space of Z d,0 (q, p) /F λ at ∞ /F λ , it is enough to show that the map induced by γ is surjective. Recall that, by definition, γ 1/F λ factors as