Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
8820 views
1
r"""
2
Surjectivity of Galois Representations for Elliptic Curves over Number Fields.
3
4
This file contains the code to compute for which primes the Galois
5
representation attached to an elliptic curve (over an arbitrary
6
number field) is surjective. The functions in this file are called by
7
the is_surjective and non_surjective methods in ell_number_field.py.
8
9
EXAMPLES::
10
11
sage: K = NumberField(x**2 - 29, 'a'); a = K.gen()
12
sage: E = EllipticCurve([1, 0, ((5 + a)/2)**2, 0, 0])
13
sage: rho = E.galois_representation()
14
sage: rho.is_surjective(29) # Cyclotomic character not surjective.
15
False
16
sage: rho.is_surjective(31) # See Section 5.10 of [Serre72].
17
True
18
sage: rho.non_surjective() # long time (4s on sage.math, 2014)
19
[3, 5, 29]
20
21
sage: E = EllipticCurve_from_j(1728).change_ring(K) # CM
22
sage: E.galois_representation().non_surjective() # long time (2s on sage.math, 2014)
23
[0]
24
25
AUTHORS:
26
27
- Eric Larson (2012-05-28): initial version.
28
29
REFERENCES:
30
31
[Serre72] Serre. ``Proprietes Galoisiennes des Points d'Ordre Fini des Courbes
32
Elliptiques.'' Inventiones mathematicae, 1972.
33
"""
34
35
#*****************************************************************************
36
# Copyright (C) 2012 Eric Larson <[email protected]>
37
#
38
# Distributed under the terms of the GNU General Public License (GPL)
39
# as published by the Free Software Foundation; either version 2 of
40
# the License, or (at your option) any later version.
41
# http://www.gnu.org/licenses/
42
#*****************************************************************************
43
44
45
from sage.structure.sage_object import SageObject
46
from sage.rings.number_field.number_field import NumberField
47
from sage.schemes.elliptic_curves.cm import cm_j_invariants
48
from sage.rings.rational_field import QQ
49
from sage.modules.free_module import VectorSpace
50
from sage.rings.finite_rings.constructor import GF
51
from sage.rings.integer import Integer
52
from sage.misc.functional import cyclotomic_polynomial
53
from sage.rings.arith import legendre_symbol
54
55
56
class GaloisRepresentation(SageObject):
57
r"""
58
The compatible family of Galois representation
59
attached to an elliptic curve over a number field.
60
61
Given an elliptic curve `E` over a number field `K`
62
and a rational prime number `p`, the `p^n`-torsion
63
`E[p^n]` points of `E` is a representation of the
64
absolute Galois group `G_K` of `K`. As `n` varies
65
we obtain the Tate module `T_p E` which is a
66
a representation of `G_K` on a free `\ZZ_p`-module
67
of rank `2`. As `p` varies the representations
68
are compatible.
69
70
EXAMPLES::
71
72
sage: K = NumberField(x**2 + 1, 'a')
73
sage: E = EllipticCurve('11a1').change_ring(K)
74
sage: rho = E.galois_representation()
75
sage: rho
76
Compatible family of Galois representations associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in a with defining polynomial x^2 + 1
77
"""
78
79
80
def __init__(self, E):
81
r"""
82
83
see ``GaloisRepresentation`` for documentation
84
85
EXAMPLES::
86
87
sage: K = NumberField(x**2 + 1, 'a')
88
sage: E = EllipticCurve('11a1').change_ring(K)
89
sage: rho = E.galois_representation()
90
sage: rho
91
Compatible family of Galois representations associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in a with defining polynomial x^2 + 1
92
sage: loads(rho.dumps()) == rho
93
True
94
"""
95
self.E = E
96
97
98
def __repr__(self):
99
r"""
100
string representation of the class
101
102
EXAMPLES::
103
104
sage: K = NumberField(x**2 + 1, 'a')
105
sage: E = EllipticCurve('11a1').change_ring(K)
106
sage: rho = E.galois_representation()
107
sage: rho
108
Compatible family of Galois representations associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in a with defining polynomial x^2 + 1
109
"""
110
return "Compatible family of Galois representations associated to the " + repr(self.E)
111
112
113
def __eq__(self,other):
114
r"""
115
Compares two Galois representations.
116
We define two compatible families of representations
117
attached to elliptic curves to be isomorphic if the curves are equal
118
119
EXAMPLES::
120
121
sage: K = NumberField(x**2 + 1, 'a'); a = K.gen()
122
sage: rho1 = EllipticCurve_from_j(1 + a).galois_representation()
123
sage: rho2 = EllipticCurve_from_j(2 + a).galois_representation()
124
sage: rho1 == rho1
125
True
126
sage: rho1 == rho2
127
False
128
sage: rho1 == 42
129
False
130
"""
131
if not type(self) == type(other):
132
return False
133
return self.E.is_isomorphic(other.E)
134
135
136
def elliptic_curve(self):
137
r"""
138
The elliptic curve associated to this representation.
139
140
EXAMPLES::
141
142
sage: K = NumberField(x**2 + 1, 'a'); a = K.gen()
143
sage: E = EllipticCurve_from_j(a)
144
sage: rho = E.galois_representation()
145
sage: rho.elliptic_curve() == E
146
True
147
"""
148
return self.E
149
150
151
def non_surjective(self, A=100):
152
r"""
153
Returns a list of primes `p` including all primes for which the mod-`p`
154
representation might not be surjective.
155
156
INPUT:
157
158
* ``A`` - int (a bound on the number of traces of Frobenius to use
159
while trying to prove surjectivity).
160
161
OUTPUT:
162
163
- ``list`` - A list of primes where mod-`p` representation is very likely
164
not surjective. At any prime not in this list, the representation is
165
definitely surjective. If E has CM, the list [0] is returned.
166
167
EXAMPLES::
168
169
sage: K = NumberField(x**2 - 29, 'a'); a = K.gen()
170
sage: E = EllipticCurve([1, 0, ((5 + a)/2)**2, 0, 0])
171
sage: rho = E.galois_representation()
172
sage: rho.non_surjective() # See Section 5.10 of [Serre72].
173
[3, 5, 29]
174
sage: K = NumberField(x**2 + 3, 'a'); a = K.gen()
175
sage: E = EllipticCurve([0, -1, 1, -10, -20]).change_ring(K) # X_0(11)
176
sage: rho = E.galois_representation()
177
sage: rho.non_surjective() # long time (4s on sage.math, 2014)
178
[3, 5]
179
sage: K = NumberField(x**2 + 1, 'a'); a = K.gen()
180
sage: E = EllipticCurve_from_j(1728).change_ring(K) # CM
181
sage: rho = E.galois_representation()
182
sage: rho.non_surjective()
183
[0]
184
sage: K = NumberField(x**2 - 5, 'a'); a = K.gen()
185
sage: E = EllipticCurve_from_j(146329141248*a - 327201914880) # CM
186
sage: rho = E.galois_representation()
187
sage: rho.non_surjective() # long time (3s on sage.math, 2014)
188
[0]
189
"""
190
try:
191
return _non_surjective(self.E, A)
192
except ValueError:
193
return [0]
194
195
def is_surjective(self, p, A=100):
196
r"""
197
Returns True if the mod-p representation is (provably) surjective
198
onto `Aut(E[p]) = GL_2(\mathbb{F}_p)`.
199
200
False if it is (probably) not.
201
202
INPUT:
203
204
* ``p`` - int - a prime number.
205
206
* ``A`` - int - a bound on the number of traces of Frobenius to use
207
while trying to prove surjectivity.
208
209
EXAMPLES::
210
211
sage: K = NumberField(x**2 - 29, 'a'); a = K.gen()
212
sage: E = EllipticCurve([1, 0, ((5 + a)/2)**2, 0, 0])
213
sage: rho = E.galois_representation()
214
sage: rho.is_surjective(29) # Cyclotomic character not surjective.
215
False
216
sage: rho.is_surjective(7) # See Section 5.10 of [Serre72].
217
True
218
219
If `E` is defined over `\QQ`, then the exceptional primes for `E_{/K}`
220
are the same as the exceptional primes for `E`, except for those primes
221
that are ramified in `K/\QQ` or are less than `[K:\QQ]`::
222
223
sage: K = NumberField(x**2 + 11, 'a')
224
sage: E = EllipticCurve([2, 14])
225
sage: rhoQQ = E.galois_representation()
226
sage: rhoK = E.change_ring(K).galois_representation()
227
sage: rhoQQ.is_surjective(2) == rhoK.is_surjective(2)
228
False
229
sage: rhoQQ.is_surjective(3) == rhoK.is_surjective(3)
230
True
231
sage: rhoQQ.is_surjective(5) == rhoK.is_surjective(5)
232
True
233
"""
234
235
return (_exceptionals(self.E, [p], A) == [])
236
237
238
def _non_surjective(E, patience=100):
239
r"""
240
Returns a list of primes `p` including all primes for which the mod-`p`
241
representation might not be surjective.
242
243
INPUT:
244
245
- ``E`` - EllipticCurve (over a number field).
246
247
- ``A`` - int (a bound on the number of traces of Frobenius to use
248
while trying to prove surjectivity).
249
250
OUTPUT:
251
252
- ``list`` - A list of primes where mod-`p` representation is very likely
253
not surjective. At any prime not in this list, the representation is
254
definitely surjective. If E has CM, a ValueError is raised.
255
256
EXAMPLES::
257
258
sage: K = NumberField(x**2 - 29, 'a'); a = K.gen()
259
sage: E = EllipticCurve([1, 0, ((5 + a)/2)**2, 0, 0])
260
sage: sage.schemes.elliptic_curves.gal_reps_number_field._non_surjective(E) # See Section 5.10 of [Serre72].
261
[3, 5, 29]
262
sage: E = EllipticCurve_from_j(1728).change_ring(K) # CM
263
sage: sage.schemes.elliptic_curves.gal_reps_number_field._non_surjective(E)
264
Traceback (most recent call last):
265
...
266
ValueError: The curve E should not have CM.
267
"""
268
269
E = _over_numberfield(E)
270
K = E.base_field()
271
272
bad_primes = set([2, 3, 5, 7, 11, 13, 17, 19])
273
# The possible primes l unramified in K/QQ for which the image of the mod l
274
# Galois representation could be contained in an exceptional subgroup.
275
276
# Find the places of additive reduction.
277
SA = []
278
for P, n in E.conductor().factor():
279
if n > 1:
280
SA.append(P)
281
# TODO: All we really require is a list of primes that include all
282
# primes at which E has additive reduction. Perhaps we can speed
283
# up things by doing something less time-consuming here that produces
284
# a list with some extra terms? (Of course, the longer this list is,
285
# the slower the rest of the computation is, so it is not clear that
286
# this would help...)
287
288
for l in K.discriminant().prime_factors():
289
bad_primes.add(l)
290
291
for l in _possible_normalizers(E, SA):
292
bad_primes.add(l)
293
294
for l in _semistable_reducible_primes(E):
295
bad_primes.add(l)
296
for P in SA:
297
bad_primes.add(P.residue_field().characteristic())
298
299
return _exceptionals(E, list(bad_primes), patience)
300
301
302
def _exceptionals(E, L, patience=1000):
303
r"""
304
Determine which primes in L are exceptional for E, using Proposition 19
305
of Section 2.8 of Serre's ``Proprietes Galoisiennes des Points d'Ordre
306
Fini des Courbes Elliptiques'' [Serre72].
307
308
INPUT:
309
310
- ``E`` - EllipticCurve - over a number field.
311
312
- ``L`` - list - a list of prime numbers.
313
314
- ``patience`` - int (a bound on the number of traces of Frobenius to
315
use while trying to prove surjectivity).
316
317
OUTPUT: list - The list of all primes l in L for which the mod l image
318
might fail to be surjective.
319
320
EXAMPLES::
321
322
sage: K = NumberField(x**2 - 29, 'a'); a = K.gen()
323
sage: E = EllipticCurve([1, 0, ((5 + a)/2)**2, 0, 0])
324
sage: sage.schemes.elliptic_curves.gal_reps_number_field._exceptionals(E, [29, 31])
325
[29]
326
"""
327
328
E = _over_numberfield(E)
329
K = E.base_field()
330
331
output = []
332
333
L = list(set(L)) # Remove duplicates from L.
334
335
for l in L:
336
if l == 2: # c.f. Section 5.3(a) of [Serre72].
337
if (E.j_invariant() - 1728).is_square():
338
output.append(2)
339
elif not E.division_polynomial(2).is_irreducible():
340
output.append(2)
341
342
elif l == 3: # c.f. Section 5.3(b) of [Serre72].
343
if K(-3).is_square():
344
output.append(3)
345
elif not (K['x'].gen()**3 - E.j_invariant()).is_irreducible():
346
output.append(3)
347
elif not E.division_polynomial(3).is_irreducible():
348
output.append(3)
349
350
elif (K.discriminant() % l) == 0:
351
if not K['x'](cyclotomic_polynomial(l)).is_irreducible():
352
# I.E. if the action on lth roots of unity is not surjective
353
# (We want this since as a galois module, \wedge^2 E[l]
354
# is isomorphic to the lth roots of unity.)
355
output.append(l)
356
357
for l in output:
358
L.remove(l)
359
if 2 in L:
360
L.remove(2)
361
if 3 in L:
362
L.remove(3)
363
364
# If the image is not surjective, then it is contained in one of the
365
# maximal subgroups. So, we start by creating a dictionary between primes
366
# l in L and possible maximal subgroups in which the mod l image could
367
# be contained. This information is stored as a triple whose elements
368
# are True/False according to whether the mod l image could be contained
369
# in:
370
# 0. A borel or normalizer of split Cartan subgroup.
371
# 1. A nonsplit Cartan subgroup or its normalizer.
372
# 2. An exceptional subgroup of GL_2.
373
374
D = {}
375
for l in L:
376
D[l] = [True, True, True]
377
378
for P in K.primes_of_degree_one_iter():
379
try:
380
trace = E.change_ring(P.residue_field()).trace_of_frobenius()
381
except ArithmeticError: # Bad reduction at P.
382
continue
383
384
patience -= 1
385
386
determinant = P.norm()
387
discriminant = trace**2 - 4 * determinant
388
389
unexc = [] # Primes we discover are unexceptional go here.
390
391
for l in D.iterkeys():
392
tr = GF(l)(trace)
393
det = GF(l)(determinant)
394
disc = GF(l)(discriminant)
395
396
if tr == 0:
397
# I.E. if Frob_P could be contained in the normalizer of
398
# a cartan subgroup, but not in the cartan subgroup.
399
continue
400
401
if disc == 0:
402
# I.E. If the matrix might be non-diagonalizable over F_{p^2}.
403
continue
404
405
if legendre_symbol(disc, l) == 1:
406
# If the matrix is diagonalizable over F_p, it can't be
407
# contained in a non-split cartan subgroup. Since we've
408
# gotten rid of the case where it is contained in the
409
# of a nonsplit cartan subgroup but not the cartan subgroup,
410
D[l][1] = False
411
else:
412
# If the matrix is not diagonalizable over F_p, it can't
413
# be contained borel subgroup.
414
D[l][0] = False
415
416
if det != 0: # c.f. [Serre72], Section 2.8, Prop. 19
417
u = trace**2 / det
418
if u not in (1, 2, 4) and u**2 - 3 * u + 1 != 0:
419
D[l][2] = False
420
421
422
if D[l] == [False, False, False]:
423
unexc.append(l)
424
425
for l in unexc:
426
D.pop(l)
427
unexc = []
428
429
if (D == {}) or (patience == 0):
430
break
431
432
for l in D.iterkeys():
433
output.append(l)
434
435
output.sort()
436
return output
437
438
439
def _over_numberfield(E):
440
r"""Return `E`, defined over a NumberField object. This is necessary
441
since if `E` is defined over `\QQ`, then we cannot use SAGE commands
442
available for number fields.
443
444
INPUT:
445
446
- ``E`` - EllipticCurve - over a number field.
447
448
OUTPUT:
449
450
- If `E` is defined over a NumberField, returns E.
451
452
- If `E` is defined over QQ, returns E defined over the NumberField QQ.
453
454
EXAMPLES::
455
456
sage: E = EllipticCurve([1, 2])
457
sage: sage.schemes.elliptic_curves.gal_reps_number_field._over_numberfield(E)
458
Elliptic Curve defined by y^2 = x^3 + x + 2 over Number Field in a with defining polynomial x
459
"""
460
461
K = E.base_field()
462
463
if K == QQ:
464
x = QQ['x'].gen()
465
K = NumberField(x, 'a')
466
E = E.change_ring(K)
467
468
return E
469
470
471
def _tr12(tr, det):
472
r"""Compute `X^{12} + Y^{12}` given `X + Y` and `X * Y`.
473
474
INPUT:
475
476
- ``tr`` - The value of `X + Y`.
477
478
- ``det`` - The value of `X * Y`.
479
480
OUTPUT: The value of `X^{12} + Y^{12}`.
481
482
EXAMPLES::
483
484
sage: from sage.schemes.elliptic_curves.gal_reps_number_field import *
485
sage: X, Y = QQ['X, Y'].gens()
486
sage: sage.schemes.elliptic_curves.gal_reps_number_field._tr12(X + Y, X * Y)
487
X^12 + Y^12
488
"""
489
490
det3 = det**3
491
return ((tr * (tr**2 - 3 * det))**2 - 2 * det3)**2 - 2 * det3**2
492
493
494
def _semistable_reducible_primes(E):
495
r"""Find a list containing all semistable primes l unramified in K/QQ
496
for which the Galois image for E could be reducible.
497
498
INPUT:
499
500
- ``E`` - EllipticCurve - over a number field.
501
502
OUTPUT: list - A list of primes, which contains all primes l unramified
503
in K/QQ, such that E is semistable at all primes lying
504
over l, and the Galois image at l is reducible. If E has
505
CM defined over its ground field, a ValueError is raised.
506
507
EXAMPLES::
508
509
sage: E = EllipticCurve([0, -1, 1, -10, -20]) # X_0(11)
510
sage: 5 in sage.schemes.elliptic_curves.gal_reps_number_field._semistable_reducible_primes(E)
511
True
512
"""
513
514
E = _over_numberfield(E)
515
K = E.base_field()
516
deg_one_primes = K.primes_of_degree_one_iter()
517
518
bad_primes = set([]) # This will store the output.
519
520
# We find two primes (of distinct residue characteristics) which are
521
# of degree 1, unramified in K/Q, and at which E has good reduction.
522
# Both of these primes will give us a nontrivial divisibility constraint
523
# on the exceptional primes l. For both of these primes P, we precompute
524
# a generator and the trace of Frob_P^12.
525
526
precomp = []
527
last_char = 0 # The residue characteristic of the most recent prime.
528
529
while len(precomp) < 2:
530
P = deg_one_primes.next()
531
532
if not P.is_principal():
533
continue
534
535
det = P.norm()
536
if det == last_char:
537
continue
538
539
if P.ramification_index() != 1:
540
continue
541
542
try:
543
tr = E.change_ring(P.residue_field()).trace_of_frobenius()
544
except ArithmeticError: # Bad reduction at P.
545
continue
546
547
x = P.gens_reduced()[0]
548
549
precomp.append((x, _tr12(tr, det)))
550
last_char = det
551
552
x, tx = precomp[0]
553
y, ty = precomp[1]
554
555
Kgal = K.galois_closure('b')
556
maps = K.embeddings(Kgal)
557
558
for i in xrange(2 ** (K.degree() - 1)):
559
## We iterate through all possible characters. ##
560
561
# Here, if i = i_{l-1} i_{l-2} cdots i_1 i_0 in binary, then i
562
# corresponds to the character prod sigma_j^{i_j}.
563
564
phi1x = 1
565
phi2x = 1
566
phi1y = 1
567
phi2y = 1
568
569
# We compute the two algebraic characters at x and y:
570
for j in xrange(K.degree()):
571
if i % 2 == 1:
572
phi1x *= maps[j](x)
573
phi1y *= maps[j](y)
574
else:
575
phi2x *= maps[j](x)
576
phi2y *= maps[j](y)
577
i = int(i/2)
578
579
# Any prime with reducible image must divide both of:
580
gx = phi1x**12 + phi2x**12 - tx
581
gy = phi1y**12 + phi2y**12 - ty
582
583
if (gx != 0) or (gy != 0):
584
for prime in Integer(Kgal.ideal([gx, gy]).norm()).prime_factors():
585
bad_primes.add(prime)
586
587
continue
588
589
## It is possible that our curve has CM. ##
590
591
# Our character must be of the form Nm^K_F for an imaginary
592
# quadratic subfield F of K (which is the CM field if E has CM).
593
# We compute F:
594
595
a = (Integer(phi1x + phi2x)**2 - 4 * x.norm()).squarefree_part()
596
597
y = QQ['y'].gen()
598
F = NumberField(y**2 - a, 'a')
599
600
# Next, we turn K into relative number field over F.
601
602
K = K.relativize(F.embeddings(K)[0], 'b')
603
E = E.change_ring(K.structure()[1])
604
605
## We try to find a nontrivial divisibility condition. ##
606
607
patience = 5 * K.absolute_degree()
608
# Number of Frobenius elements to check before suspecting that E
609
# has CM and computing the set of CM j-invariants of K to check.
610
# TODO: Is this the best value for this parameter?
611
612
while 1:
613
P = deg_one_primes.next()
614
615
if not P.is_principal():
616
continue
617
618
try:
619
tr = E.change_ring(P.residue_field()).trace_of_frobenius()
620
except ArithmeticError: # Bad reduction at P.
621
continue
622
623
x = P.gens_reduced()[0].norm(F)
624
div = (x**12).trace() - _tr12(tr, x.norm())
625
626
patience -= 1
627
628
if div != 0:
629
# We found our divisibility constraint.
630
631
for prime in Integer(div).prime_factors():
632
bad_primes.add(prime)
633
634
# Turn K back into an absolute number field.
635
636
E = E.change_ring(K.structure()[0])
637
K = K.structure()[0].codomain()
638
639
break
640
641
if patience == 0:
642
# We suspect that E has CM, so we check:
643
f = K.structure()[0]
644
if f(E.j_invariant()) in cm_j_invariants(f.codomain()):
645
raise ValueError, "The curve E should not have CM."
646
647
L = list(bad_primes)
648
L.sort()
649
return L
650
651
652
def _possible_normalizers(E, SA):
653
r"""Find a list containing all primes `l` such that the Galois image at `l`
654
is contained in the normalizer of a Cartan subgroup, such that the
655
corresponding quadratic character is ramified only at the given primes.
656
657
INPUT:
658
659
- ``E`` - EllipticCurve - over a number field K.
660
661
- ``SA`` - list - a list of primes of K.
662
663
OUTPUT:
664
665
- list - A list of primes, which contains all primes `l` such that the
666
Galois image at `l` is contained in the normalizer of a Cartan
667
subgroup, such that the corresponding quadratic character is
668
ramified only at primes in SA.
669
670
- If `E` has geometric CM that is not defined over its ground field, a
671
ValueError is raised.
672
673
EXAMPLES::
674
675
sage: E = EllipticCurve([0,0,0,-56,4848])
676
sage: 5 in sage.schemes.elliptic_curves.gal_reps_number_field._possible_normalizers(E, [ZZ.ideal(2)])
677
True
678
"""
679
680
E = _over_numberfield(E)
681
K = E.base_field()
682
SA = [K.ideal(I.gens()) for I in SA]
683
684
x = K['x'].gen()
685
selmer_group = K.selmer_group(SA, 2) # Generators of the selmer group.
686
687
if selmer_group == []:
688
return []
689
690
V = VectorSpace(GF(2), len(selmer_group))
691
# We think of this as the character group of the selmer group.
692
693
traces_list = []
694
W = V.zero_subspace()
695
696
deg_one_primes = K.primes_of_degree_one_iter()
697
698
while W.dimension() < V.dimension() - 1:
699
P = deg_one_primes.next()
700
701
k = P.residue_field()
702
703
defines_valid_character = True
704
# A prime P defines a quadratic residue character
705
# on the Selmer group. This variable will be set
706
# to zero if any elements of the selmer group are
707
# zero mod P (i.e. the character is ramified).
708
709
splitting_vector = [] # This will be the values of this
710
# character on the generators of the Selmer group.
711
712
for a in selmer_group:
713
abar = k(a)
714
if abar == 0:
715
# Ramification.
716
defines_valid_character = False
717
break
718
719
if abar.is_square():
720
splitting_vector.append(GF(2)(0))
721
else:
722
splitting_vector.append(GF(2)(1))
723
724
if not defines_valid_character:
725
continue
726
727
if splitting_vector in W:
728
continue
729
730
try:
731
Etilde = E.change_ring(k)
732
except ArithmeticError: # Bad reduction.
733
continue
734
735
tr = Etilde.trace_of_frobenius()
736
737
if tr == 0:
738
continue
739
740
traces_list.append(tr)
741
742
W = W + V.span([splitting_vector])
743
744
bad_primes = set([])
745
746
for i in traces_list:
747
for p in i.prime_factors():
748
bad_primes.add(p)
749
750
# We find the unique vector v in V orthogonal to W:
751
v = W.matrix().transpose().kernel().basis()[0]
752
753
# We find the element a of the selmer group corresponding to v:
754
a = 1
755
for i in xrange(len(selmer_group)):
756
if v[i] == 1:
757
a *= selmer_group[i]
758
759
# Since we've already included the above bad primes, we can assume
760
# that the quadratic character corresponding to the exceptional primes
761
# we're looking for is given by mapping into Gal(K[\sqrt{a}]/K).
762
763
patience = 5 * K.degree()
764
# Number of Frobenius elements to check before suspecting that E
765
# has CM and computing the set of CM j-invariants of K to check.
766
# TODO: Is this the best value for this parameter?
767
768
while 1:
769
P = deg_one_primes.next()
770
771
k = P.residue_field()
772
773
if not k(a).is_square():
774
try:
775
tr = E.change_ring(k).trace_of_frobenius()
776
except ArithmeticError: # Bad reduction.
777
continue
778
779
if tr == 0:
780
patience -= 1
781
782
if patience == 0:
783
# We suspect E has CM, so we check:
784
if E.j_invariant() in cm_j_invariants(K):
785
raise ValueError, "The curve E should not have CM."
786
787
else:
788
for p in tr.prime_factors():
789
bad_primes.add(p)
790
791
bad_primes = list(bad_primes)
792
bad_primes.sort()
793
return bad_primes
794
795
796