Path: blob/master/src/sage/interfaces/genus2reduction.py
8814 views
r"""1Conductor and Reduction Types for Genus 2 Curves23AUTHORS:45- Qing Liu and Henri Cohen (1994-1998): wrote genus2reduction C6program78- William Stein (2006-03-05): wrote Sage interface to genus2reduction910ACKNOWLEDGMENT: (From Liu's website:) Many thanks to Henri Cohen11who started writing this program. After this program is available,12many people pointed out to me (mathematical as well as programming)13bugs : B. Poonen, E. Schaefer, C. Stahlke, M. Stoll, F. Villegas.14So thanks to all of them. Thanks also go to Ph. Depouilly who help15me to compile the program.1617Also Liu has given me explicit permission to include18genus2reduction with Sage and for people to modify the C source19code however they want.20"""2122########################################################################23# Copyright (C) 2006 William Stein <[email protected]>24#25# Distributed under the terms of the GNU General Public License (GPL)26#27# http://www.gnu.org/licenses/28########################################################################293031import os32from expect import Expect33from sage.structure.sage_object import SageObject3435class Genus2reduction_expect(Expect):36def __init__(self, server=None, server_tmpdir=None, logfile=None):37Expect.__init__(self,38name = 'genus2reduction',39prompt = 'enter',40command = 'genus2reduction',41server = server,42server_tmpdir = server_tmpdir,43maxread = 10000,44restart_on_ctrlc = True,45logfile = logfile,46verbose_start = False)4748def __getattr__(self, attrname):49raise AttributeError5051class ReductionData(SageObject):52r"""53Reduction data for a genus 2 curve.5455How to read ``local_data`` attribute, i.e., if this56class is R, then the following is the meaning of57``R.local_data[p]``.5859For each prime number `p` dividing the discriminant of60`y^2+Q(x)y=P(x)`, there are two lines.6162The first line contains information about the stable reduction63after field extension. Here are the meanings of the symbols of64stable reduction :6566(I) The stable reduction is smooth (i.e. the curve has potentially67good reduction).6869(II) The stable reduction is an elliptic curve `E` with an70ordinary double point. `j` mod `p` is the modular71invariant of `E`.7273(III) The stable reduction is a projective line with two ordinary74double points.7576(IV) The stable reduction is two projective lines crossing77transversally at three points.7879(V) The stable reduction is the union of two elliptic curves80`E_1` and `E_2` intersecting transversally at one81point. Let `j_1`, `j_2` be their modular82invariants, then `j_1+j_2` and `j_1 j_2` are83computed (they are numbers mod `p`).8485(VI) The stable reduction is the union of an elliptic curve86`E` and a projective line which has an ordinary double87point. These two components intersect transversally at one point.88`j` mod `p` is the modular invariant of89`E`.9091(VII) The stable reduction is as above, but the two components are92both singular.9394In the cases (I) and (V), the Jacobian `J(C)` has95potentially good reduction. In the cases (III), (IV) and (VII),96`J(C)` has potentially multiplicative reduction. In the two97remaining cases, the (potential) semi-abelian reduction of98`J(C)` is extension of an elliptic curve (with modular99invariant `j` mod `p`) by a torus.100101The second line contains three data concerning the reduction at102`p` without any field extension.103104105#. The first symbol describes the REDUCTION AT `p` of106`C`. We use the symbols of Namikawa-Ueno for the type of107the reduction (Namikawa, Ueno:"The complete classification of108fibers in pencils of curves of genus two", Manuscripta Math., vol.1099, (1973), pages 143-186.) The reduction symbol is followed by the110corresponding page number (or just an indiction) in the above111article. The lower index is printed by , for instance, [I2-II-5]112means [I_2-II-5]. Note that if `K` and `K'` are113Kodaira symbols for singular fibers of elliptic curves, [K-K'-m]114and [K'-K-m] are the same type. Finally, [K-K'-1] (not the same as115[K-K'-1]) is [K'-K-alpha] in the notation of Namikawa-Ueno. The116figure [2I_0-m] in Namikawa-Ueno, page 159 must be denoted by117[2I_0-(m+1)].118119#. The second datum is the GROUP OF CONNECTED COMPONENTS (over an120ALGEBRAIC CLOSURE (!) of `\GF{p}`) of the Neron121model of J(C). The symbol (n) means the cyclic group with n122elements. When n=0, (0) is the trivial group (1).123``Hn`` is isomorphic to (2)x(2) if n is even and to (4)124otherwise.125126Note - The set of rational points of `\Phi` can be computed127using Theorem 1.17 in S. Bosch and Q. Liu "Rational points of the128group of components of a Neron model", Manuscripta Math. 98 (1999),129275-293.130131#. Finally, `f` is the exponent of the conductor of132`J(C)` at `p`.133134135.. warning::136137Be careful regarding the formula:138139.. math::140141\text{valuation of the naive minimal discriminant} = f + n - 1 + 11c(X).142143(Q. Liu : "Conducteur et discriminant minimal de courbes de genre1442", Compositio Math. 94 (1994) 51-79, Theoreme 2) is valid only if145the residual field is algebraically closed as stated in the paper.146So this equality does not hold in general over147`\QQ_p`. The fact is that the minimal discriminant148may change after unramified extension. One can show however that,149at worst, the change will stabilize after a quadratic unramified150extension (Q. Liu : "Modeles entiers de courbes hyperelliptiques151sur un corps de valuation discrete", Trans. AMS 348 (1996),1524577-4610, Section 7.2, Proposition 4).153"""154def __init__(self, raw, P, Q, minimal_equation, minimal_disc,155local_data, conductor, prime_to_2_conductor_only):156self.raw = raw157self.P = P158self.Q = Q159self.minimal_equation = minimal_equation160self.minimal_disc = minimal_disc161self.local_data = local_data162self.conductor = conductor163self.prime_to_2_conductor_only = prime_to_2_conductor_only164165def _repr_(self):166if self.prime_to_2_conductor_only:167ex = ' (away from 2)'168else:169ex = ''170if self.Q == 0:171yterm = ''172else:173yterm = '+ (%s)*y '%self.Q174s = 'Reduction data about this proper smooth genus 2 curve:\n'175s += '\ty^2 %s= %s\n'%(yterm, self.P)176s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation177s += 'Minimal Discriminant (away from 2): %s\n'%self.minimal_disc178s += 'Conductor%s: %s\n'%(ex, self.conductor)179s += 'Local Data:\n%s'%self._local_data_str()180return s181182def _local_data_str(self):183s = ''184D = self.local_data185K = D.keys()186K.sort()187for p in K:188s += 'p=%s\n%s\n'%(p, D[p])189s = '\t' + '\n\t'.join(s.split('\n'))190return s191192class Genus2reduction(SageObject):193r"""194Conductor and Reduction Types for Genus 2 Curves.195196Use ``R = genus2reduction(Q, P)`` to obtain reduction197information about the Jacobian of the projective smooth curve198defined by `y^2 + Q(x)y = P(x)`. Type ``R?``199for further documentation and a description of how to interpret the200local reduction data.201202EXAMPLES::203204sage: x = QQ['x'].0205sage: R = genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)206sage: R.conductor2071416875208sage: factor(R.conductor)2095^4 * 2267210211This means that only the odd part of the conductor is known.212213::214215sage: R.prime_to_2_conductor_only216True217218The discriminant is always minimal away from 2, but possibly not at2192.220221::222223sage: factor(R.minimal_disc)2242^3 * 5^5 * 2267225226Printing R summarizes all the information computed about the curve227228::229230sage: R231Reduction data about this proper smooth genus 2 curve:232y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5233A Minimal Equation (away from 2):234y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855235Minimal Discriminant (away from 2): 56675000236Conductor (away from 2): 1416875237Local Data:238p=2239(potential) stable reduction: (II), j=1240p=5241(potential) stable reduction: (I)242reduction at p: [V] page 156, (3), f=4243p=2267244(potential) stable reduction: (II), j=432245reduction at p: [I{1-0-0}] page 170, (1), f=1246247Here are some examples of curves with modular Jacobians::248249sage: R = genus2reduction(x^3 + x + 1, -2*x^5 - 3*x^2 + 2*x - 2)250sage: factor(R.conductor)25123^2252sage: factor(genus2reduction(x^3 + 1, -x^5 - 3*x^4 + 2*x^2 + 2*x - 2).conductor)25329^2254sage: factor(genus2reduction(x^3 + x + 1, x^5 + 2*x^4 + 2*x^3 + x^2 - x - 1).conductor)2555^6256257EXAMPLE::258259sage: genus2reduction(0, x^6 + 3*x^3 + 63)260Reduction data about this proper smooth genus 2 curve:261y^2 = x^6 + 3*x^3 + 63262A Minimal Equation (away from 2):263y^2 = x^6 + 3*x^3 + 63264Minimal Discriminant (away from 2): 10628388316852992265Conductor (away from 2): 2893401266Local Data:267p=2268(potential) stable reduction: (V), j1+j2=0, j1*j2=0269p=3270(potential) stable reduction: (I)271reduction at p: [III{9}] page 184, (3)^2, f=10272p=7273(potential) stable reduction: (V), j1+j2=0, j1*j2=0274reduction at p: [I{0}-II-0] page 159, (1), f=2275276In the above example, Liu remarks that in fact at `p=2`,277the reduction is [II-II-0] page 163, (1), `f=8`. So the278conductor of J(C) is actually `2 \cdot 2893401=5786802`.279280A MODULAR CURVE:281282Consider the modular curve `X_1(13)` defined by an283equation284285.. math::286287y^2 + (x^3-x^2-1)y = x^2 - x.288289290291We have::292293sage: genus2reduction(x^3-x^2-1, x^2 - x)294Reduction data about this proper smooth genus 2 curve:295y^2 + (x^3 - x^2 - 1)*y = x^2 - x296A Minimal Equation (away from 2):297y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561298Minimal Discriminant (away from 2): 169299Conductor: 169300Local Data:301p=13302(potential) stable reduction: (V), j1+j2=0, j1*j2=0303reduction at p: [I{0}-II-0] page 159, (1), f=2304305So the curve has good reduction at 2. At `p=13`, the stable306reduction is union of two elliptic curves, and both of them have 0307as modular invariant. The reduction at 13 is of type [I_0-II-0]308(see Namikawa-Ueno, page 159). It is an elliptic curve with a cusp.309The group of connected components of the Neron model of310`J(C)` is trivial, and the exponent of the conductor of311`J(C)` at `13` is `f=2`. The conductor of312`J(C)` is `13^2`. (Note: It is a theorem of313Conrad-Edixhoven-Stein that the component group of314`J(X_1(p))` is trivial for all primes `p`.)315"""316def __init__(self):317self.__expect = Genus2reduction_expect()318319def _repr_(self):320return "Genus 2 reduction program"321322def console(self):323genus2reduction_console()324325def raw(self, Q, P):326r"""327Return the raw output of running the328``genus2reduction`` program on the hyperelliptic curve329`y^2 + Q(x)y = P(x)` as a string.330331INPUT:332333334- ``Q`` - something coercible to a univariate335polynomial over Q.336337- ``P`` - something coercible to a univariate338polynomial over Q.339340341OUTPUT:342343344- ``string`` - raw output345346- ``Q`` - what Q was actually input to auxiliary347genus2reduction program348349- ``P`` - what P was actually input to auxiliary350genus2reduction program351352353EXAMPLES::354355sage: x = QQ['x'].0356sage: print genus2reduction.raw(x^3 - 2*x^2 - 2*x + 1, -5*x^5)[0]357a minimal equation over Z[1/2] is :358y^2 = x^6-240*x^4-2550*x^3-11400*x^2-24100*x-19855359<BLANKLINE>360factorization of the minimal (away from 2) discriminant :361[2,3;5,5;2267,1]362<BLANKLINE>363p=2364(potential) stable reduction : (II), j=1365p=5366(potential) stable reduction : (I)367reduction at p : [V] page 156, (3), f=4368p=2267369(potential) stable reduction : (II), j=432370reduction at p : [I{1-0-0}] page 170, (1), f=1371<BLANKLINE>372the prime to 2 part of the conductor is 1416875373in factorized form : [2,0;5,4;2267,1]374375Verify that we fix trac 5573::376377sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)378Reduction data about this proper smooth genus 2 curve:379y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2380...381"""382from sage.rings.all import QQ383R = QQ['x']384P = R(P)385Q = R(Q)386if P.degree() > 6:387raise ValueError, "P (=%s) must have degree at most 6"%P388if Q.degree() >=4:389raise ValueError, "Q (=%s) must have degree at most 3"%Q390391E = self.__expect392try:393E.eval(str(Q).replace(' ',''))394s = E.eval(str(P).replace(' ',''))395except RuntimeError:396# If something goes wrong genus2reduction often goes into397# a bad state, and quitting it fixes things, since next398# time it is used, it is started cleanly. See trac 5573.399E.quit()400raise ValueError, "error in input; possibly singular curve? (Q=%s, P=%s)"%(Q,P)401i = s.find('a minimal')402j = s.rfind(']')403return s[i:j+2], Q, P404405def __call__(self, Q, P):406from sage.rings.all import ZZ, QQ407from sage.misc.all import sage_eval408409s, Q, P = self.raw(Q, P)410raw = s411412if 'the prime to 2 part of the conductor' in s:413prime_to_2_conductor_only = True414else:415prime_to_2_conductor_only = False416x = QQ['x'].gen(0)417i = s.find('y^2 = ') + len('y^2 = ')418j = i + s[i:].find('\n')419minimal_equation = sage_eval(s[i:j], locals={'x':x})420421422s = s[j+1:]423i = s.find('[')424j = s.find(']')425minimal_disc = ZZ(eval(s[i+1:j].replace(',','**').replace(';','*')))426427phrase = 'the conductor is '428j = s.find(phrase)429assert j != -1430k = s[j:].find('\n')431prime_to_2_conductor = ZZ(s[j+len(phrase):j+k])432433local_data = {}434while True:435i = s.find('p=')436if i == -1:437break438j = s[i+2:].find('p=')439if j == -1:440j = s.find('\n \n')441assert j != -1442else:443j = j + (i+2)444k = i + s[i:].find('\n')445p = ZZ(s[i+2:k])446data = s[k+1:j].strip().replace(' : ',': ')447local_data[p] = data448s = s[j:]449450return ReductionData(raw, P, Q, minimal_equation, minimal_disc, local_data,451prime_to_2_conductor, prime_to_2_conductor_only)452453454def __reduce__(self):455return _reduce_load_Genus2reduction, tuple([])456457# An instance458genus2reduction = Genus2reduction()459460def _reduce_load_genus2reduction():461return genus2reduction462463import os464def genus2reduction_console():465os.system('genus2reduction')466467468469