{{{id=1| x = var('x') K.=NumberField(x^2-x-1) import psage.modform.hilbert.sqrt5.tables as sqrt5 import nosqlite db=nosqlite.Client(DATA+'localdb').db f=open('/home/psharaba/CCL.txt') from psage.ellcurve.minmodel.sqrt5 import canonical_model /// }}} {{{id=22| db.curves.delete() /// }}} {{{id=2| ######################################################### ############# isogeny classes ############### ######################################################### def ap(E,p): return E.change_ring(p.residue_field()).trace_of_frobenius() R. = GF(2)[] def frob(E,p): t = ap(E,p) return ch^2 - ap(E, p)*ch + int(p.norm()) def disc(E, p): t = ap(E, p) return t^2 - 4*p.norm() def isogeny_primes(E, norm_bound, isog_degree_bound): #Returns prime for which E has an isogeny P = [p for p in sqrt5.ideals_of_bounded_norm(norm_bound) if p.is_prime() and E.has_good_reduction(p)] w = set(primes(isog_degree_bound+1)) i = 0 w.remove(2) while len(w) > 0 and i < len(P): d = disc(E, P[i]) w = [ell for ell in w if not (legendre_symbol(d,ell) == -1)] i = i +1 i = 0 while i < len(P): if frob(E,P[i]).is_irreducible(): break i = i+1 if i == len(P): w.insert(0,2) return w def closed_under_multiplication_by_m(E, f, m): """ INPUT: - E -- elliptic curve in *short* Weierstrass form - f -- a polynomial that defines a finite subset S of E[p] that is closed under [-1] - m -- integer m >= 2 coprime to p. We assume that p is odd. OUTPUT: - True if [m]*S = S, and False otherwise. """ K = E.base_field() h = E.multiplication_by_m(m, x_only=True) n = h.numerator(); d = h.denominator() S. = K[] psi = n.parent().hom([x,0]) tau = f.parent().hom([x]) r = tau(f).resultant(psi(n)-Z*psi(d), x) r0 = S.hom([0,f.parent().gen()])(r) return r0.monic() == f.monic() def is_subgroup(E, f, p): """ INPUT: - E -- elliptic curve in *short* Weierstrass form - f -- a polynomial that defines a finite subset S of E[p] that is closed under [-1] - p -- an odd prime OUTPUT: - True exactly if S union {0} is a group. """ m = primitive_root(p) return closed_under_multiplication_by_m(E, f, m) def isogeny_class_computation(E, p): if p != 2: E = E.short_weierstrass_model() F = E.division_polynomial(p).change_ring(K) candidates = [f for f in divisors(F) if f.degree() == (p-1)/2 and is_subgroup(E,f,p)] v = [] w = [] for f in candidates: try: v.append(E.change_ring(K).isogeny(f).codomain()) w.append(f) except ValueError: pass v = [F.change_ring(K).global_minimal_model() for F in v] return v else: w = [Q for Q in E.torsion_subgroup() if order(Q)==2] v = [E.isogeny(E(Q)).codomain() for Q in w] return v def curve_isogeny_vector(E): #Returns isogeny class and adjacency matrix curve_list = [E] i = 0 Adj = matrix(50) ins = 1 norm_bound, isog_degree_bound = 500,500 while i < len(curve_list): isolist = isogeny_primes(curve_list[i],norm_bound, isog_degree_bound) for p in isolist: for F in isogeny_class_computation(curve_list[i],p): bool = True for G in curve_list: if F.is_isomorphic(G): bool = False Adj[i,curve_list.index(G)]=p #if a curve in the isogeny class computation is isom Adj[curve_list.index(G),i]=p #to a curve already in the list, we want a line if bool: curve_list.append(F.global_minimal_model()) Adj[i,ins]=p Adj[ins,i]=p ins += 1 i+=1 Adj = Adj.submatrix(nrows=len(curve_list),ncols=len(curve_list)) return {'curve_list':curve_list, 'adjacency_matrix':Adj, 'norm_bound':norm_bound, 'isog_degree_bound':isog_degree_bound, 'subgroup_checked':True} def compute_isogeny_classes(): if 'isoclass' in db.curves.columns(): #X = db('select weq from curves where isoclass is NULL order by N') # since the isoclasses are all wrong anyways... X = db('select weq from curves order by N') else: X = db('select weq from curves order by N') print "%s left to do"%len(X) def comp(weq): ainvs = weq E = EllipticCurve(K, ainvs) iso = curve_isogeny_vector(E) d = {'isoclass':iso} db.curves.update(d, weq=weq) print d for A in range(len(X)): B=X[A][0] comp(B) print A def isogeny_table(file): X = db.curves.find('N>=1', fields=['N','cond','weq','isoclass'], order_by='N') if isinstance(file, str): file = open(file, 'w') file.write('N cond weq iso_class iso_matrix\n') i = 0 for v in X: if not v.has_key('isoclass'): continue if not v['isoclass'].has_key('subgroup_checked'): print "crap: ", v continue i += 1 iso = v['isoclass'] M = iso['adjacency_matrix'] mat = "matrix(%s,%s)"%(M.nrows(),str(M.list()).replace(' ','')) ainvs=str([list(E.ainvs()) for E in iso['curve_list']]).replace(' ','') s = '%s %s %s %s %s'%(v['N'],v['cond'],v['weq'],ainvs,mat) print i, s file.write(s+'\n') file.flush() /// }}} {{{id=4| f.readline().split() /// ['225', '15', '[a+1,a,a+1,-25*a-25,-119*a-83]'] }}} {{{id=5| for s in f.readlines(): A=s.split() db.curves.insert({'N':int(A[0]), 'cond': A[1], 'weq': A[2]}) /// }}} {{{id=3| %time X = db('select weq from curves order by N') for r1 in range(len(X)): weq1=X[r1][0] weq2=eval(X[r1][0]) E = EllipticCurve(K, weq2) iso = curve_isogeny_vector(E) Tot=iso['curve_list'] India=iso['adjacency_matrix'] hotel=[] for g1 in range(len(Tot)): A=list(Tot[g1].a_invariants()) hotel.append(str(A).replace(' ','')) db.curves.update({'isoclass':str(hotel), 'mtrx': str(India)}, weq=str(weq1)) print hotel print India print weq1 /// ['[a+1,a,a+1,-25*a-25,-119*a-83]', '[a+1,a,a+1,-400*a-400,-6044*a-4433]', '[a+1,a,a+1,0,-4*a-3]', '[a+1,a,a+1,-50*a-50,46*a+47]', '[a+1,a,a+1,175*a+175,1081*a+767]', '[a+1,a,a+1,-675*a-675,11171*a+8547]', '[a+1,a,a+1,-550*a-550,15946*a+12097]', '[a+1,a,a+1,-10800*a-10800,758396*a+571497]', '[a+1,a,a+1,16875*a-55575,-2120029*a+5229447]', '[a+1,a,a+1,-200475*a-128025,52107221*a+32306847]'] [0 2 2 2 0 0 0 0 0 0] [2 0 0 0 0 0 0 0 0 0] [2 0 0 0 0 0 0 0 0 0] [2 0 0 0 2 2 0 0 0 0] [0 0 0 2 0 0 0 0 0 0] [0 0 0 2 0 0 2 2 0 0] [0 0 0 0 0 2 0 0 0 0] [0 0 0 0 0 2 0 0 2 2] [0 0 0 0 0 0 0 2 0 0] [0 0 0 0 0 0 0 2 0 0] [a+1,a,a+1,-25*a-25,-119*a-83] ['[0,a-1,0,-4,-4*a+4]', '[0,a-1,0,-20*a-24,-76*a-52]', '[0,a-1,0,20*a-64,-108*a+236]', '[0,a-1,0,1,0]', '[0,a-1,0,-420*a-224,-4716*a-3012]', '[0,a-1,0,60*a-144,276*a-676]'] [0 2 2 2 0 0] [2 0 0 0 2 2] [2 0 0 0 0 0] [2 0 0 0 0 0] [0 2 0 0 0 0] [0 2 0 0 0 0] [0,a-1,0,-4,-4*a+4] ['[0,1,a+1,-18*a-23,-67*a-57]', '[0,1,a+1,2*a-3,-2*a+1]'] [0 3] [3 0] [0,1,a+1,-18*a-23,-67*a-57] ['[0,a+1,a+1,6*a-30,42*a-49]', '[0,a+1,a+1,1076*a-2020,23185*a-39565]'] [0 3] [3 0] [0,a+1,a+1,6*a-30,42*a-49] ['[1,-a-1,a,4*a-20,27*a-12]', '[1,-a-1,a,59*a-100,-245*a+447]', '[1,-a-1,a,9*a-15,16*a-26]', '[1,-a-1,a,-131*a-20,783*a+285]'] [0 2 2 2] [2 0 0 0] [2 0 0 0] [2 0 0 0] [1,-a-1,a,4*a-20,27*a-12] ['[a+1,a,a,2*a+2,-14*a-11]', '[a+1,a,a,-3*a-3,-9*a-6]'] [0 2] [2 0] [a+1,a,a,2*a+2,-14*a-11] ['[a,a,0,-25*a-53,-155*a-178]', '[a,a,0,-3,-5*a-3]'] [0 2] [2 0] [a,a,0,-25*a-53,-155*a-178] ['[1,-a+1,a+1,-5*a-5,23*a+9]', '[1,-a+1,a+1,175*a-180,416*a-1815]'] [0 3] [3 0] [1,-a+1,a+1,-5*a-5,23*a+9] ['[a+1,-a+1,1,3*a+3,8*a+3]', '[a+1,-a+1,1,-17*a-32,72*a-7]'] [0 2] [2 0] [a+1,-a+1,1,3*a+3,8*a+3] ['[0,-a+1,0,-34*a-33,95*a+63]', '[0,-a+1,0,6*a+7,7*a+7]'] [0 2] [2 0] [0,-a+1,0,-34*a-33,95*a+63] ['[a+1,0,0,-7*a+5,8*a-9]', '[a+1,0,0,148*a-200,880*a-1384]'] [0 3] [3 0] [a+1,0,0,-7*a+5,8*a-9] ['[a,a,0,8*a-15,11*a+17]', '[a,a,0,3*a-195,847*a-500]'] [0 2] [2 0] [a,a,0,8*a-15,11*a+17] ['[0,a+1,a,6*a-7,10*a-15]', '[0,a+1,a,436*a-707,5297*a-8596]'] [0 3] [3 0] [0,a+1,a,6*a-7,10*a-15] ['[a+1,-a-1,1,-93*a-93,-525*a-394]', '[a+1,-a-1,1,-1443*a-1443,-37245*a-27934]', '[a+1,-a-1,1,7*a+7,-45*a-34]', '[a+1,-a-1,1,-343*a-343,3875*a+2906]', '[a+1,-a-1,1,-1668*a-1668,47355*a+35516]', '[a+1,-a-1,1,-2268*a-2268,10875*a+8156]', '[a+1,-a-1,1,-68*a-68,1275*a+956]', '[a+1,-a-1,1,-26668*a-26668,3007355*a+2255516]'] [0 2 2 2 3 0 0 0] [2 0 0 0 0 3 0 0] [2 0 0 0 0 0 3 0] [2 0 0 0 0 0 0 3] [3 0 0 0 0 2 2 2] [0 3 0 0 2 0 0 0] [0 0 3 0 2 0 0 0] [0 0 0 3 2 0 0 0] [a+1,-a-1,1,-93*a-93,-525*a-394] CPU time: 255.27 s, Wall time: 255.65 s }}} {{{id=6| db.curves.find_one() /// {u'mtrx': u'matrix(10,[0,2,2,2,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,2,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,2,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,2,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0])', u'weq': u'[a+1,a,a+1,-25*a-25,-119*a-83]', u'cond': u'15', u'isoclass': u"['[a+1,a,a+1,-25*a-25,-119*a-83]', '[a+1,a,a+1,-400*a-400,-6044*a-4433]', '[a+1,a,a+1,0,-4*a-3]', '[a+1,a,a+1,-50*a-50,46*a+47]', '[a+1,a,a+1,175*a+175,1081*a+767]', '[a+1,a,a+1,-675*a-675,11171*a+8547]', '[a+1,a,a+1,-550*a-550,15946*a+12097]', '[a+1,a,a+1,-10800*a-10800,758396*a+571497]', '[a+1,a,a+1,16875*a-55575,-2120029*a+5229447]', '[a+1,a,a+1,-200475*a-128025,52107221*a+32306847]']", u'N': 225} }}} {{{id=8| test=db('SELECT N, cond,weq,isoclass,mtrx from curves ORDER BY N') /// }}} {{{id=29| test[0] /// (124, u'10*a-4', u'[a+1,a-1,a+1,5*a-16,4*a-21]', u"['[a+1,a-1,a+1,5*a-16,4*a-21]', '[a+1,a-1,a+1,-35*a-56,-260*a-117]', '[a+1,a-1,a+1,-1,-a+1]', '[a+1,a-1,a+1,465*a-1316,8192*a-18821]', '[a+1,a-1,a+1,-3305*a-3646,-139218*a-109925]', '[a+1,a-1,a+1,10*a-21,-33*a+51]']", u'[0 2 3 3 0 0]\n[2 0 0 0 3 3]\n[3 0 0 0 0 2]\n[3 0 0 0 2 0]\n[0 3 0 2 0 0]\n[0 3 2 0 0 0]') }}} {{{id=31| for s in range(len(test)): A=str(test[s][4]).replace('\n','') A=A.replace('][',',') A='('+A.replace(' ',',')+')' B=len(eval(test[s][3])) M=matrix(B,eval(A)) mat = "matrix(%s,%s)"%(M.nrows(),str(M.list()).replace(' ','')) db.curves.update({'mtrx':mat},weq=test[s][2]) /// }}} {{{id=7| for s in range(len(test)): A=test[s] db.curvesU.insert({'N':A[0], 'cond': A[1], 'weq': A[2], 'mtrx': A[4], 'found': 'CL'}) B=eval(A[3]) for t in range(1,len(B)): E=EllipticCurve(K,eval(B[t])) F=canonical_model(E.global_minimal_model()).a_invariants() G=str([F[0],F[1],F[2],F[3],F[4]]).replace(' ','') db.curvesU.insert({'N':A[0], 'cond': A[1], 'weq': G, 'mtrx':A[4], 'found': 'CLI'}) /// }}} {{{id=30| db.curvesU.delete() /// }}} {{{id=9| db.curvesU.find_one(found='CLI') /// {u'found': u'CLI', u'weq': u'[a+1,a,a+1,-400*a-400,-6044*a-4433]', u'cond': u'15', u'mtrx': u'matrix(10,[0,2,2,2,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,2,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,2,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,2,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0])', u'N': 225} }}} {{{id=10| test=db('SELECT N,cond,weq,isoclass,mtrx from curves ORDER BY N') /// }}} {{{id=27| eval(test[0][3])[0] /// '[a+1,a-1,a+1,5*a-16,4*a-21]' }}} {{{id=28| test[0] /// (124, u'10*a-4', u'[a+1,a-1,a+1,5*a-16,4*a-21]', u"['[a+1,a-1,a+1,5*a-16,4*a-21]', '[a+1,a-1,a+1,-35*a-56,-260*a-117]', '[a+1,a-1,a+1,-1,-a+1]', '[a+1,a-1,a+1,465*a-1316,8192*a-18821]', '[a+1,a-1,a+1,-3305*a-3646,-139218*a-109925]', '[a+1,a-1,a+1,10*a-21,-33*a+51]']", u'matrix(6,[0,2,3,3,0,0,2,0,0,0,3,3,3,0,0,0,0,2,3,0,0,0,2,0,0,3,0,2,0,0,0,3,2,0,0,0])') }}} {{{id=12| for s in range(len(test)): A=test[s] B= E=EllipticCurve(K,eval(B[t])) F=canonical_model(E.global_minimal_model()).a_invariants() G1=str([F[0],F[1],F[2],F[3],F[4]]).replace(' ','') db.curves.update({'weq': G1}, weq=B[t]) /// }}} {{{id=13| db.curves.count() /// (232,) }}} {{{id=14| f=open('/home/psharaba/CCLU.txt') /// }}} {{{id=15| list(db.curves.find(weq=f.readline().split()[2])) /// [{u'mtrx': u'matrix(2,[0,3,3,0])', u'weq': u'[0,a+1,a,-9*a-9,-31*a-23]', u'cond': u'-11*a+8', u'isoclass': u"['[0,a+1,a,-9*a-9,-31*a-23]', '[0,a+1,a,a+1,0]']", u'N': 145}] }}} {{{id=16| for r in f.readlines(): A=r.split() db.curves.update({'found':'CL'}, weq=A[2]) /// }}} {{{id=17| len(list(db.curves.find(found='CL'))) /// 63 }}} {{{id=18| len(list(db.curves.find(found='CLI'))) /// 0 }}} {{{id=19| 169+63 /// 232 }}} {{{id=23| test=db('select N,cond,weq,mtrx,found from curvesU ORDER BY N') /// }}} {{{id=26| len(test) /// 48 }}} {{{id=20| def printer(): J=open('/home/psharaba/CCLU.txt','w') for y in test: S=[] for entry in y: s=str(entry) s.replace(' ','') S.append(s) J.write(' '.join(S)+'\n') /// }}} {{{id=24| printer() /// }}} {{{id=32| E[a, -a + 1, 0, 202*a - 329, -1553*a + 2514] /// }}} {{{id=25| E = EllipticCurve(K, [a, -a + 1, 0, 202*a - 329, -1553*a + 2514]).global_minimal_model() F=canonical_model(E) iso = curve_isogeny_vector(E) Tot=iso['curve_list'] India=iso['adjacency_matrix'] hotel=[] for g1 in range(len(Tot)): A=list(Tot[g1].a_invariants()) hotel.append(str(A).replace(' ','')) #db.curves.update({'isoclass':str(hotel), 'mtrx': str(India)}, weq=str(weq1)) print hotel print India print F.a_invariants() /// ['[a,-a+1,0,202*a-329,-1553*a+2514]', '[a,-a+1,0,182*a-329,-1617*a+2694]', '[a,-a+1,0,317*a-519,637*a-1035]', '[a,-a+1,0,-1283*a+2041,2941*a-4683]', '[a,-a+1,0,18877*a-30999,1526253*a-2473275]', '[a,-a+1,0,18617*a-30579,1569409*a-2543091]'] [0 2 3 0 0 0] [2 0 0 3 0 0] [3 0 0 2 3 0] [0 3 2 0 0 3] [0 0 3 0 0 2] [0 0 0 3 2 0] (a + 1, -a, 0, 23*a - 52, -77*a + 146) }}} {{{id=36| hotel[0] /// '[a,-a+1,0,202*a-329,-1553*a+2514]' }}} {{{id=33| curves=[] for s in range(len(hotel)): E=EllipticCurve(K,eval(hotel[s])).global_minimal_model() F=canonical_model(E).a_invariants() G=str([F[0],F[1],F[2],F[3],F[4]]).replace(' ','') curves.append(G) /// }}} {{{id=35| curves /// ['[a+1,-a,0,23*a-52,-77*a+146]', '[1,0,0,-721*a-455,11175*a+6918]', '[a+1,-a,0,28*a-87,a-79]', '[a+1,-a,0,-292*a+233,769*a+113]', '[1,0,0,-9161*a-6570,-534651*a-341043]', '[a+1,-a,0,1348*a-5307,57589*a-160183]'] }}} {{{id=37| /// }}} {{{id=38| /// }}}