Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/interfaces/genus2reduction.py
2599 views
1
r"""
2
Conductor and Reduction Types for Genus 2 Curves
3
4
AUTHORS:
5
6
- Qing Liu and Henri Cohen (1994-1998): wrote genus2reduction C
7
program
8
9
- William Stein (2006-03-05): wrote Sage interface to genus2reduction
10
11
ACKNOWLEDGMENT: (From Liu's website:) Many thanks to Henri Cohen
12
who started writing this program. After this program is available,
13
many people pointed out to me (mathematical as well as programming)
14
bugs : B. Poonen, E. Schaefer, C. Stahlke, M. Stoll, F. Villegas.
15
So thanks to all of them. Thanks also go to Ph. Depouilly who help
16
me to compile the program.
17
18
Also Liu has given me explicit permission to include
19
genus2reduction with Sage and for people to modify the C source
20
code however they want.
21
"""
22
23
########################################################################
24
# Copyright (C) 2006 William Stein <[email protected]>
25
#
26
# Distributed under the terms of the GNU General Public License (GPL)
27
#
28
# http://www.gnu.org/licenses/
29
########################################################################
30
31
32
import os
33
from expect import Expect
34
from sage.structure.sage_object import SageObject
35
36
class Genus2reduction_expect(Expect):
37
def __init__(self, server=None, server_tmpdir=None, logfile=None):
38
Expect.__init__(self,
39
name = 'genus2reduction',
40
prompt = 'enter',
41
command = 'genus2reduction',
42
server = server,
43
server_tmpdir = server_tmpdir,
44
maxread = 10000,
45
restart_on_ctrlc = True,
46
logfile = logfile,
47
verbose_start = False)
48
49
def __getattr__(self, attrname):
50
raise AttributeError
51
52
class ReductionData(SageObject):
53
r"""
54
Reduction data for a genus 2 curve.
55
56
How to read ``local_data`` attribute, i.e., if this
57
class is R, then the following is the meaning of
58
``R.local_data[p]``.
59
60
For each prime number `p` dividing the discriminant of
61
`y^2+Q(x)y=P(x)`, there are two lines.
62
63
The first line contains information about the stable reduction
64
after field extension. Here are the meanings of the symbols of
65
stable reduction :
66
67
(I) The stable reduction is smooth (i.e. the curve has potentially
68
good reduction).
69
70
(II) The stable reduction is an elliptic curve `E` with an
71
ordinary double point. `j` mod `p` is the modular
72
invariant of `E`.
73
74
(III) The stable reduction is a projective line with two ordinary
75
double points.
76
77
(IV) The stable reduction is two projective lines crossing
78
transversally at three points.
79
80
(V) The stable reduction is the union of two elliptic curves
81
`E_1` and `E_2` intersecting transversally at one
82
point. Let `j_1`, `j_2` be their modular
83
invariants, then `j_1+j_2` and `j_1 j_2` are
84
computed (they are numbers mod `p`).
85
86
(VI) The stable reduction is the union of an elliptic curve
87
`E` and a projective line which has an ordinary double
88
point. These two components intersect transversally at one point.
89
`j` mod `p` is the modular invariant of
90
`E`.
91
92
(VII) The stable reduction is as above, but the two components are
93
both singular.
94
95
In the cases (I) and (V), the Jacobian `J(C)` has
96
potentially good reduction. In the cases (III), (IV) and (VII),
97
`J(C)` has potentially multiplicative reduction. In the two
98
remaining cases, the (potential) semi-abelian reduction of
99
`J(C)` is extension of an elliptic curve (with modular
100
invariant `j` mod `p`) by a torus.
101
102
The second line contains three data concerning the reduction at
103
`p` without any field extension.
104
105
106
#. The first symbol describes the REDUCTION AT `p` of
107
`C`. We use the symbols of Namikawa-Ueno for the type of
108
the reduction (Namikawa, Ueno:"The complete classification of
109
fibers in pencils of curves of genus two", Manuscripta Math., vol.
110
9, (1973), pages 143-186.) The reduction symbol is followed by the
111
corresponding page number (or just an indiction) in the above
112
article. The lower index is printed by , for instance, [I2-II-5]
113
means [I_2-II-5]. Note that if `K` and `K'` are
114
Kodaira symbols for singular fibers of elliptic curves, [K-K'-m]
115
and [K'-K-m] are the same type. Finally, [K-K'-1] (not the same as
116
[K-K'-1]) is [K'-K-alpha] in the notation of Namikawa-Ueno. The
117
figure [2I_0-m] in Namikawa-Ueno, page 159 must be denoted by
118
[2I_0-(m+1)].
119
120
#. The second datum is the GROUP OF CONNECTED COMPONENTS (over an
121
ALGEBRAIC CLOSURE (!) of `\GF{p}`) of the Neron
122
model of J(C). The symbol (n) means the cyclic group with n
123
elements. When n=0, (0) is the trivial group (1).
124
``Hn`` is isomorphic to (2)x(2) if n is even and to (4)
125
otherwise.
126
127
Note - The set of rational points of `\Phi` can be computed
128
using Theorem 1.17 in S. Bosch and Q. Liu "Rational points of the
129
group of components of a Neron model", Manuscripta Math. 98 (1999),
130
275-293.
131
132
#. Finally, `f` is the exponent of the conductor of
133
`J(C)` at `p`.
134
135
136
.. warning::
137
138
Be careful regarding the formula:
139
140
.. math::
141
142
\text{valuation of the naive minimal discriminant} = f + n - 1 + 11c(X).
143
144
(Q. Liu : "Conducteur et discriminant minimal de courbes de genre
145
2", Compositio Math. 94 (1994) 51-79, Theoreme 2) is valid only if
146
the residual field is algebraically closed as stated in the paper.
147
So this equality does not hold in general over
148
`\QQ_p`. The fact is that the minimal discriminant
149
may change after unramified extension. One can show however that,
150
at worst, the change will stabilize after a quadratic unramified
151
extension (Q. Liu : "Modeles entiers de courbes hyperelliptiques
152
sur un corps de valuation discrete", Trans. AMS 348 (1996),
153
4577-4610, Section 7.2, Proposition 4).
154
"""
155
def __init__(self, raw, P, Q, minimal_equation, minimal_disc,
156
local_data, conductor, prime_to_2_conductor_only):
157
self.raw = raw
158
self.P = P
159
self.Q = Q
160
self.minimal_equation = minimal_equation
161
self.minimal_disc = minimal_disc
162
self.local_data = local_data
163
self.conductor = conductor
164
self.prime_to_2_conductor_only = prime_to_2_conductor_only
165
166
def _repr_(self):
167
if self.prime_to_2_conductor_only:
168
ex = ' (away from 2)'
169
else:
170
ex = ''
171
if self.Q == 0:
172
yterm = ''
173
else:
174
yterm = '+ (%s)*y '%self.Q
175
s = 'Reduction data about this proper smooth genus 2 curve:\n'
176
s += '\ty^2 %s= %s\n'%(yterm, self.P)
177
s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
178
s += 'Minimal Discriminant (away from 2): %s\n'%self.minimal_disc
179
s += 'Conductor%s: %s\n'%(ex, self.conductor)
180
s += 'Local Data:\n%s'%self._local_data_str()
181
return s
182
183
def _local_data_str(self):
184
s = ''
185
D = self.local_data
186
K = D.keys()
187
K.sort()
188
for p in K:
189
s += 'p=%s\n%s\n'%(p, D[p])
190
s = '\t' + '\n\t'.join(s.split('\n'))
191
return s
192
193
class Genus2reduction(SageObject):
194
r"""
195
Conductor and Reduction Types for Genus 2 Curves.
196
197
Use ``R = genus2reduction(Q, P)`` to obtain reduction
198
information about the Jacobian of the projective smooth curve
199
defined by `y^2 + Q(x)y = P(x)`. Type ``R?``
200
for further documentation and a description of how to interpret the
201
local reduction data.
202
203
EXAMPLES::
204
205
sage: x = QQ['x'].0
206
sage: R = genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
207
sage: R.conductor
208
1416875
209
sage: factor(R.conductor)
210
5^4 * 2267
211
212
This means that only the odd part of the conductor is known.
213
214
::
215
216
sage: R.prime_to_2_conductor_only
217
True
218
219
The discriminant is always minimal away from 2, but possibly not at
220
2.
221
222
::
223
224
sage: factor(R.minimal_disc)
225
2^3 * 5^5 * 2267
226
227
Printing R summarizes all the information computed about the curve
228
229
::
230
231
sage: R
232
Reduction data about this proper smooth genus 2 curve:
233
y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
234
A Minimal Equation (away from 2):
235
y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
236
Minimal Discriminant (away from 2): 56675000
237
Conductor (away from 2): 1416875
238
Local Data:
239
p=2
240
(potential) stable reduction: (II), j=1
241
p=5
242
(potential) stable reduction: (I)
243
reduction at p: [V] page 156, (3), f=4
244
p=2267
245
(potential) stable reduction: (II), j=432
246
reduction at p: [I{1-0-0}] page 170, (1), f=1
247
248
Here are some examples of curves with modular Jacobians::
249
250
sage: R = genus2reduction(x^3 + x + 1, -2*x^5 - 3*x^2 + 2*x - 2)
251
sage: factor(R.conductor)
252
23^2
253
sage: factor(genus2reduction(x^3 + 1, -x^5 - 3*x^4 + 2*x^2 + 2*x - 2).conductor)
254
29^2
255
sage: factor(genus2reduction(x^3 + x + 1, x^5 + 2*x^4 + 2*x^3 + x^2 - x - 1).conductor)
256
5^6
257
258
EXAMPLE::
259
260
sage: genus2reduction(0, x^6 + 3*x^3 + 63)
261
Reduction data about this proper smooth genus 2 curve:
262
y^2 = x^6 + 3*x^3 + 63
263
A Minimal Equation (away from 2):
264
y^2 = x^6 + 3*x^3 + 63
265
Minimal Discriminant (away from 2): 10628388316852992
266
Conductor (away from 2): 2893401
267
Local Data:
268
p=2
269
(potential) stable reduction: (V), j1+j2=0, j1*j2=0
270
p=3
271
(potential) stable reduction: (I)
272
reduction at p: [III{9}] page 184, (3)^2, f=10
273
p=7
274
(potential) stable reduction: (V), j1+j2=0, j1*j2=0
275
reduction at p: [I{0}-II-0] page 159, (1), f=2
276
277
In the above example, Liu remarks that in fact at `p=2`,
278
the reduction is [II-II-0] page 163, (1), `f=8`. So the
279
conductor of J(C) is actually `2 \cdot 2893401=5786802`.
280
281
A MODULAR CURVE:
282
283
Consider the modular curve `X_1(13)` defined by an
284
equation
285
286
.. math::
287
288
y^2 + (x^3-x^2-1)y = x^2 - x.
289
290
291
292
We have::
293
294
sage: genus2reduction(x^3-x^2-1, x^2 - x)
295
Reduction data about this proper smooth genus 2 curve:
296
y^2 + (x^3 - x^2 - 1)*y = x^2 - x
297
A Minimal Equation (away from 2):
298
y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
299
Minimal Discriminant (away from 2): 169
300
Conductor: 169
301
Local Data:
302
p=13
303
(potential) stable reduction: (V), j1+j2=0, j1*j2=0
304
reduction at p: [I{0}-II-0] page 159, (1), f=2
305
306
So the curve has good reduction at 2. At `p=13`, the stable
307
reduction is union of two elliptic curves, and both of them have 0
308
as modular invariant. The reduction at 13 is of type [I_0-II-0]
309
(see Namikawa-Ueno, page 159). It is an elliptic curve with a cusp.
310
The group of connected components of the Neron model of
311
`J(C)` is trivial, and the exponent of the conductor of
312
`J(C)` at `13` is `f=2`. The conductor of
313
`J(C)` is `13^2`. (Note: It is a theorem of
314
Conrad-Edixhoven-Stein that the component group of
315
`J(X_1(p))` is trivial for all primes `p`.)
316
"""
317
def __init__(self):
318
self.__expect = Genus2reduction_expect()
319
320
def _repr_(self):
321
return "Genus 2 reduction program"
322
323
def console(self):
324
genus2reduction_console()
325
326
def raw(self, Q, P):
327
r"""
328
Return the raw output of running the
329
``genus2reduction`` program on the hyperelliptic curve
330
`y^2 + Q(x)y = P(x)` as a string.
331
332
INPUT:
333
334
335
- ``Q`` - something coercible to a univariate
336
polynomial over Q.
337
338
- ``P`` - something coercible to a univariate
339
polynomial over Q.
340
341
342
OUTPUT:
343
344
345
- ``string`` - raw output
346
347
- ``Q`` - what Q was actually input to auxiliary
348
genus2reduction program
349
350
- ``P`` - what P was actually input to auxiliary
351
genus2reduction program
352
353
354
EXAMPLES::
355
356
sage: x = QQ['x'].0
357
sage: print genus2reduction.raw(x^3 - 2*x^2 - 2*x + 1, -5*x^5)[0]
358
a minimal equation over Z[1/2] is :
359
y^2 = x^6-240*x^4-2550*x^3-11400*x^2-24100*x-19855
360
<BLANKLINE>
361
factorization of the minimal (away from 2) discriminant :
362
[2,3;5,5;2267,1]
363
<BLANKLINE>
364
p=2
365
(potential) stable reduction : (II), j=1
366
p=5
367
(potential) stable reduction : (I)
368
reduction at p : [V] page 156, (3), f=4
369
p=2267
370
(potential) stable reduction : (II), j=432
371
reduction at p : [I{1-0-0}] page 170, (1), f=1
372
<BLANKLINE>
373
the prime to 2 part of the conductor is 1416875
374
in factorized form : [2,0;5,4;2267,1]
375
376
Verify that we fix trac 5573::
377
378
sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
379
Reduction data about this proper smooth genus 2 curve:
380
y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
381
...
382
"""
383
from sage.rings.all import QQ
384
R = QQ['x']
385
P = R(P)
386
Q = R(Q)
387
if P.degree() > 6:
388
raise ValueError, "P (=%s) must have degree at most 6"%P
389
if Q.degree() >=4:
390
raise ValueError, "Q (=%s) must have degree at most 3"%Q
391
392
E = self.__expect
393
try:
394
E.eval(str(Q).replace(' ',''))
395
s = E.eval(str(P).replace(' ',''))
396
except RuntimeError:
397
# If something goes wrong genus2reduction often goes into
398
# a bad state, and quitting it fixes things, since next
399
# time it is used, it is started cleanly. See trac 5573.
400
E.quit()
401
raise ValueError, "error in input; possibly singular curve? (Q=%s, P=%s)"%(Q,P)
402
i = s.find('a minimal')
403
j = s.rfind(']')
404
return s[i:j+2], Q, P
405
406
def __call__(self, Q, P):
407
from sage.rings.all import ZZ, QQ
408
from sage.misc.all import sage_eval
409
410
s, Q, P = self.raw(Q, P)
411
raw = s
412
413
if 'the prime to 2 part of the conductor' in s:
414
prime_to_2_conductor_only = True
415
else:
416
prime_to_2_conductor_only = False
417
x = QQ['x'].gen(0)
418
i = s.find('y^2 = ') + len('y^2 = ')
419
j = i + s[i:].find('\n')
420
minimal_equation = sage_eval(s[i:j], locals={'x':x})
421
422
423
s = s[j+1:]
424
i = s.find('[')
425
j = s.find(']')
426
minimal_disc = ZZ(eval(s[i+1:j].replace(',','**').replace(';','*')))
427
428
phrase = 'the conductor is '
429
j = s.find(phrase)
430
assert j != -1
431
k = s[j:].find('\n')
432
prime_to_2_conductor = ZZ(s[j+len(phrase):j+k])
433
434
local_data = {}
435
while True:
436
i = s.find('p=')
437
if i == -1:
438
break
439
j = s[i+2:].find('p=')
440
if j == -1:
441
j = s.find('\n \n')
442
assert j != -1
443
else:
444
j = j + (i+2)
445
k = i + s[i:].find('\n')
446
p = ZZ(s[i+2:k])
447
data = s[k+1:j].strip().replace(' : ',': ')
448
local_data[p] = data
449
s = s[j:]
450
451
return ReductionData(raw, P, Q, minimal_equation, minimal_disc, local_data,
452
prime_to_2_conductor, prime_to_2_conductor_only)
453
454
455
def __reduce__(self):
456
return _reduce_load_Genus2reduction, tuple([])
457
458
# An instance
459
genus2reduction = Genus2reduction()
460
461
def _reduce_load_genus2reduction():
462
return genus2reduction
463
464
import os
465
def genus2reduction_console():
466
os.system('genus2reduction')
467
468
469