-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIwasawa module computation.txt
613 lines (570 loc) · 19.7 KB
/
Iwasawa module computation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
// Given a real quadratic number field, this function computes the ideal J of the Iwasawa algebra Lambda such that the Iwasawa module associated to the cyclotomic Z_p-extension of the given number field is isomorphic to Lambda/J.
// The input elements are the following:
// disc must be an integer, it is the discriminant of the real quadratic number field, if it is not a discriminant of a quadratic real field a warning is given as result;
// pp must be an odd prime number.
// The options are the following:
// tol must be a positive integer and it is the number of primes rr tested consecutively inside the "prime test cycle" before to accept that we found all the generators of the ideal;
// hptest is a boolean that allows the high precision test with polynomials, i.e., the lower bound for the ideal J; in some case the lower bound is immediate and no high precision test is needed, in these cases this option does not matter, in the other cases the high precision test is necessary to have a proof that the resulting ideal J is the correct ideal (and it is not bigger than the actual ideal), the high precision test could take high amounts of time and memory;
// maxapprox must be a positive integer greater than 2, this option does not matter if hptest is false, maxapprox is the maximum exponent of 10^(-1) for which try to compute the high precision test (i.e., the lower bound for the ideal J), more precisely 10^(-maxapprox) is the precision required to find numerically the integer coefficients of the polynomials during the high precision test.
// The output is a list with 5 elements:
// 1) the discriminant of the real quadratic number field;
// 2) the discriminant modulo p;
// 3) the level where the tower stabilizes;
// 4) an ideal basis of J in the generator T;
// 5) whether the lower bound has been successfully computed or not, if not, the reason is specified: "High precision test not applied" means that hptest is set on false, "Numerical approximation is not enough" means that maxapprox is too low to detect correctly the integer coefficients of the polynomials in the high precision test.
IwaMod:=function(disc, pp : tol:=5, hptest:=true, maxapprox:=5)
// setup
ZZ:=IntegerRing();
Umodp, iUmodp:=UnitGroup(GF(pp));
// generator of units of Z/pZ
pUgen:=iUmodp(Umodp.1);
// setup discriminant
ff:=disc;
fmodp:=ff mod pp;
chiff:=LegendreSymbol(ff,pp);
disctemp:=<ff,-1>;
if (ff gt 1) and ((ff mod 4) eq (0 mod 4)) and ( ( (ZZ!(ff/4) mod 4) eq (2 mod 4) or (ZZ!(ff/4) mod 4) eq (3 mod 4) ) and IsSquarefree(ZZ!(ff/4)) ) then
if ( chiff ne 1 ) then
cn:=ClassNumber(ff);
vv:=Valuation(cn,pp);
if (cn mod pp) eq (0 mod pp) then
disctemp:=<ff,vv>;
else
ZZpkk:=ResidueClassRing(pp^(vv+1));
RRT<T>:=PolynomialRing(ZZpkk,1);
GBIIT:=Basis(ideal<RRT|[1]>);
return [*ff,fmodp,0,GBIIT,true*];
end if;
end if;
elif (ff gt 1) and ((ff mod 4) eq (1 mod 4)) and IsSquarefree(ff) then
if ( chiff ne 1 ) then
cn:=ClassNumber(ff);
vv:=Valuation(cn,pp);
if (cn mod pp) eq (0 mod pp) then
disctemp:=<ff,vv>;
else
ZZpkk:=ResidueClassRing(pp^(vv+1));
RRT<T>:=PolynomialRing(ZZpkk,1);
GBIIT:=Basis(ideal<RRT|[1]>);
return [*ff,fmodp,0,GBIIT,true*];
end if;
end if;
else
return "It is not a discriminant of a quadratic real field";
end if;
disc:=disctemp;
// setup non-square modulo p
if ( fmodp eq (0 mod pp) ) then
ffc:=ZZ!(ff/pp);
if ( (pp mod 4) eq (1 mod 4) ) then
ffk:=ffc;
for bb:=2 to ffc-1 do
if (KroneckerSymbol(ffc,bb) eq -1) then
nsq:=ZZ!(bb);
break;
end if;
end for;
elif ( (pp mod 4) eq (3 mod 4) ) then
ffk:=-ffc;
nsq:=-1;
end if;
else
ffc:=ff;
ffk:=ff;
end if;
// upper bound
// raising level
nn:=0;
if ( chiff eq 1 ) then
kendlev:=2;
else
kendlev:=disc[2]+1;
end if;
testlevel:=false;
testexit:=false;
while not(testlevel) do
nn:=nn+1;
ZZpnn:=ResidueClassRing(pp^(nn+1));
pUgenIm:=(ZZpnn!ZZ!pUgen)^(pp^nn);
polcheck:=false;
if nn eq 1 then
polcheckresult:=false;
end if;
kk:=kendlev;
toltemp:=tol;
enoughapprox:=true;
while not(polcheck) do
if enoughapprox then
// check k-precision
testkprec:=false;
kcount:=1;
while not(testkprec) do
ZZpkk:=ResidueClassRing(pp^kk);
RRT<T>:=PolynomialRing(ZZpkk,1);
if (chiff eq 1) then
omegan:=((T+1)^(pp^nn)-1) div T;
else
omegan:=(T+1)^(pp^nn)-1;
end if;
II:=Ideal(omegan);
bb:=Basis(II);
if (nn eq 1) then
if (chiff eq 1) then
ITest:=RRT;
else
ITest:=ideal<RRT | pp^(disc[2]), T>;
end if;
end if;
if ( kcount eq 1 ) then
IIktest:=RRT;
else
GBktest:=GroebnerBasis(IIktest);
bbktest:=[];
for ee in GBktest do
bbktest:=Append(bbktest,RRT!ee);
end for;
IIktest:=Ideal(bbktest);
end if;
// prime test cycle
primerr:=[];
teststab:=0;
rr:=0;
ii:=0;
mm:=Lcm([ffc,pp^kk]);
while (teststab lt toltemp) do
rr:=1+ii*mm;
if IsPrime(rr) then
primerr:=Append(primerr,rr);
FFr:=GF(rr);
ee:=ZZ!((rr-1)/(pp^kk));
zz:=RootOfUnity(pp^(nn+1), FFr)^(-1);
zf:=RootOfUnity(ffc, FFr);
zk:=RootOfUnity(pp^kk, FFr);
if (zz in FFr) and (zf in FFr) and (zk in FFr) then
UU, iU:=UnitGroup(FFr);
zk:=zk @@ iU;
SS<zk>, iS:=sub<UU | zk>;
GG:=GenericAbelianGroup(SS);
zk:=GG!zk;
fr:=0;
zxl:=[];
KS:=[];
zx:=1;
for xx:=1 to ffc-1 do
zx:=zx*zf;
if ( Gcd(xx,ffc) eq 1 ) then
zxl:=Append(zxl,zx);
KS:=Append(KS,KroneckerSymbol(ffk,xx));
end if;
end for;
for yy:=0 to pp^nn-1 do
zy:=zz;
zln:=1;
zld:=1;
for ss:=1 to pp-1 do
if ( fmodp eq (0 mod pp) ) then
for xx:=1 to #zxl do
zxl[xx]:=zxl[xx]^nsq;
end for;
end if;
zy:=zy^(ZZ!pUgenIm);
for xx:=1 to #zxl do
if ( KS[xx] eq 1 ) then
zln:=zln*(zy-zxl[xx]);
else
zld:=zld*(zy-zxl[xx]);
end if;
end for;
end for;
zl:=zln/zld;
zl:=zl @@ iU;
zl:=ee*zl;
zll:=GG!zl;
fr:=fr+Log(zk,zll)*(T+1)^yy;
zz:=zz^(pp+1);
end for;
if (chiff eq 1) then
fr:=fr div T;
end if;
bb:=Append(bb,fr);
// check whether it seems to have enough generators
JJ:=Ideal(bb);
if (nn eq 1) and (JJ eq ITest) then
II:=JJ;
testkprec:=true;
teststab:=toltemp;
testexit:=true;
polcheckresult:=true;
else
stab:=II eq JJ;
if stab then
teststab:=teststab+1;
else
teststab:=0;
end if;
II:=JJ;
end if;
end if;
end if;
ii:=ii+1;
end while;
// check whether there is enough p-adic approximation
if ( II eq IIktest ) then
testkprec:=true;
else
IIktest:=II;
kk:=kk+1;
kcount:=kcount+1;
end if;
end while;
// check whether the ideal stabilizes at level nn
GBIIT:=GroebnerBasis(II);
GBTest:=GroebnerBasis(ITest);
SS:={};
STest:={};
RRY<Y>:=PolynomialRing(ResidueClassRing(pp^kk),1);
for ii:=1 to #GBIIT do
GBIITRes:=RRY!(GBIIT[ii]);
SS:=SS join {GBIITRes};
end for;
for ii:=1 to #GBTest do
GBTestRes:=RRY!(GBTest[ii]);
STest:=STest join {GBTestRes};
end for;
stablevel:=SS eq STest;
if stablevel then
break;
end if;
if (GBIIT ne [1]) and (hptest) then
// lower bound
// change of generator: X=1+T
RRX<X>:=PolynomialRing(ZZpkk,1);
phiX:=hom<RRT->RRX|X-1>;
GBIIX:=[];
for ii in GBIIT do
GBIIX:=Append(GBIIX,phiX(ii));
end for;
IIX:=Ideal(GBIIX);
GBIIX:=GroebnerBasis(IIX);
// annihilator I-hat
if ( nn gt 1 ) then
nnn:=nn-1;
else
nnn:=nn;
end if;
ZZpnnn:=ResidueClassRing(pp^nnn);
pUgenIm:=(ZZpnnn!ZZ!pUgen)^(pp^nnn);
kkk:=Valuation(ZZ!GBIIX[#GBIIX],pp);
ZZpkkk:=ResidueClassRing(pp^kkk);
RRU<X>:=PolynomialRing(ZZpkkk);
if (chiff eq 1) then
omegan:=(X^(pp^nnn)-1) div (X-1);
else
omegan:=X^(pp^nnn)-1;
end if;
Iw<x>,pi:=quo<RRU | omegan>;
hat:=hom<Iw -> Iw | x^(-1) >;
IIU:=[];
for ii:=1 to (#GBIIX-1) do
IIU:=Append(IIU,hat(pi(GBIIX[ii])));
end for;
RRM<X>:=PolynomialRing(ZZpkkk,1);
phi:=hom<RRU -> RRM | X>;
IIM:=[];
for ii:=1 to #IIU do
IIM:=Append(IIM,phi(IIU[ii] @@ pi));
end for;
if (chiff eq 1) then
omegan:=(X^(pp^nnn)-1) div (X-1);
else
omegan:=X^(pp^nnn)-1;
end if;
MM:=EModule(RRM, 1);
omegan:=MM![omegan];
Iw:=quo<MM | omegan>;
IIhat:=[];
for ii:=1 to #IIM do
IIhat:=Append(IIhat,Iw![IIM[ii]]);
end for;
IIhat:=sub<Iw | IIhat>;
AA:=Annihilator(IIhat);
AAb:=Basis(AA);
AAba:=[];
for ss:=1 to #AAb do
eltemp:=(Iw![AAb[ss]])[1];
if eltemp ne 0 then
AAba:=Append(AAba,eltemp);
end if;
end for;
// precision integer recognition
precint:=10^2;
// minimal polynomials cycle
approximationtest:=0;
apprexp:=2;
while approximationtest eq 0 do
// precision complex field
apprexp:=apprexp+1;
if (apprexp gt maxapprox) then
enoughapprox:=false;
break;
end if;
preccom:=10^apprexp;
CC:=ComplexField(preccom);
RF:=RealField(preccom);
// eta conjugates
eta:=[];
Czz:=Exp(2*Pi(CC)*CC.1/(pp^(nnn+1)));
Czf:=Exp(2*Pi(CC)*CC.1/ffc);
Czxl:=[];
KS:=[];
Czx:=1;
for xx:=1 to ffc-1 do
Czx:=Czx*Czf;
if ( Gcd(xx,ffc) eq 1 ) then
Czxl:=Append(Czxl,Czx);
KS:=Append(KS,KroneckerSymbol(ffk,xx));
end if;
end for;
for uu:=1 to pp^nnn do
Czl:=1;
eg:=1;
if pp eq 3 then
ssub:=1;
else
ssub:=pp-1;
end if;
for ss:=1 to ssub do
Czy:=Czz^(ZZ!eg);
if ( fmodp eq (0 mod pp) ) then
if (ss ne 1) then
for xx:=1 to #Czxl do
Czxl[xx]:=Czxl[xx]^nsq;
end for;
end if;
end if;
Czln:=1;
Czld:=1;
for xx:=1 to #Czxl do
if ( KS[xx] eq 1 ) then
Czln:=Czln*(1-Czy*Czxl[xx]);
else
Czld:=Czld*(1-Czy*Czxl[xx]);
end if;
end for;
Czl:=Czl*Czln/Czld;
eg:=eg*pUgenIm;
end for;
eta:=Append(eta,Czl);
eta:=Append(eta,Czl^(-1));
if uu ne pp^nnn then
Czz:=Czz^(1+pp);
end if;
end for;
// eta minimal polynomial
RRint<Y>:=PolynomialRing(ZZ);
RRcom<y>:=PolynomialRing(CC);
minpoleta:=RRcom!1;
erreta:=10^(-preccom);
for ee in eta do
minpoleta:=minpoleta*(y-ee);
end for;
coefeta:=Coefficients(minpoleta);
polcycle:=0;
while polcycle eq 0 do
for cc in coefeta do
err:=Abs(RF!(Round(cc))-cc);
if err gt erreta then
erreta:=err;
end if;
if err gt 10^(-precint) then
polcycle:=1;
break;
end if;
end for;
if polcycle eq 1 then
break;
end if;
minpoletaZ:=0;
for ii:=1 to #coefeta do
minpoletaZ:=minpoletaZ+ZZ!(Round(coefeta[ii]))*Y^(ii-1);
end for;
// exact root to check
AAgal:=AAba;
exprts:=[];
for ss:=1 to #AAgal do
exprts:=Append(exprts,kkk);
end for;
for ss:=1 to #AAgal do
for jj:=1 to kkk-1 do
divtest,poldiv:=IsDivisibleBy(AAgal[ss],pp^jj);
if ( divtest ) then
exprts[ss]:=exprts[ss]-1;
AAgal[ss]:=poldiv;
else
break;
end if;
end for;
end for;
// epsilon conjugates
alleps:=[];
for ss:=1 to #AAgal do
alleps:=Append(alleps,[]);
end for;
for ss:=1 to #AAgal do
for ww:=1 to #eta do
alleps[ss]:=Append(alleps[ss],CC!1);
end for;
end for;
for ss:=1 to #AAgal do
coef:=Coefficients(AAgal[ss],X);
coefZ:=[];
for ii:=1 to #coef do
if ( ZZ!(coef[ii]) gt ZZ!((pp^exprts[ss]-1)/2) ) then
coefZ[ii]:=(ZZ!coef[ii])-pp^exprts[ss];
else
coefZ[ii]:=(ZZ!coef[ii]);
end if;
end for;
for ww:=1 to #eta do
for aa:=0 to Degree(AAgal[ss]) do
ii:=ZZ!((ww+2*aa) mod #eta);
if ii eq 0 then
ii:=#eta;
end if;
alleps[ss][ww]:=alleps[ss][ww]*eta[ii]^(ZZ!coefZ[aa+1]);
end for;
end for;
end for;
// epsilon minimal polynomial
minpoleps:=[];
erreps:=[];
for ss:=1 to #alleps do
minpoleps:=Append(minpoleps,RRcom!1);
erreps:=Append(erreps,RF!10^(-preccom));
end for;
for ss:=1 to #alleps do
for ee in alleps[ss] do
minpoleps[ss]:=minpoleps[ss]*(y-ee);
end for;
coefeps:=Coefficients(minpoleps[ss]);
for cc in coefeps do
err:=Abs(RF!(Round(cc))-cc);
if err gt erreps[ss] then
erreps[ss]:=err;
end if;
if err gt 10^(-precint) then
polcycle:=1;
break ss;
end if;
end for;
end for;
if polcycle eq 1 then
break;
end if;
minpolepsZ:=[];
for ss:=1 to #alleps do
minpolepsZ:=Append(minpolepsZ,RRint!0);
end for;
for ss:=1 to #alleps do
for ii:=1 to #coefeps do
coefeps:=Coefficients(minpoleps[ss]);
minpolepsZ[ss]:=minpolepsZ[ss]+ZZ!(Round(coefeps[ii]))*Y^(ii-1);
end for;
end for;
// p^k-th roots of epsilon minimal polynomial
allrteps:=[];
for ss:=1 to #alleps do
allrteps:=Append(allrteps,[]);
end for;
for ss:=1 to #alleps do
for ww:=1 to #alleps[ss] do
allrteps[ss]:=Append(allrteps[ss],Root(Real(alleps[ss][ww]),pp^exprts[ss]));
end for;
end for;
minpolrts:=[];
errrts:=[];
for ss:=1 to #allrteps do
minpolrts:=Append(minpolrts,RRcom!1);
errrts:=Append(errrts,RF!10^(-preccom));
end for;
for ss:=1 to #allrteps do
for ee in allrteps[ss] do
minpolrts[ss]:=minpolrts[ss]*(y-ee);
end for;
coefrteps:=Coefficients(minpolrts[ss]);
for cc in coefrteps do
err:=Abs(RF!(Round(cc))-cc);
if err gt errrts[ss] then
errrts[ss]:=err;
end if;
if err gt 10^(-precint) then
polcycle:=1;
break ss;
end if;
end for;
end for;
if polcycle eq 1 then
break;
end if;
minpolrtsZ:=[];
for ss:=1 to #allrteps do
minpolrtsZ:=Append(minpolrtsZ,RRint!0);
end for;
for ss:=1 to #allrteps do
for ii:=1 to #coefrteps do
coefrteps:=Coefficients(minpolrts[ss]);
minpolrtsZ[ss]:=minpolrtsZ[ss]+ZZ!(Round(coefrteps[ii]))*Y^(ii-1);
end for;
end for;
// maximal error
minerr:=[Round(Log(10,erreta))];
for ee:=1 to #erreps do
minerr:=Append(minerr,Round(Log(10,erreps[ee])));
end for;
for ee:=1 to #errrts do
minerr:=Append(minerr,Round(Log(10,errrts[ee])));
end for;
// check polynomial divisibility
for ss:=1 to #allrteps do
pow:=hom<RRint -> RRint | Y^(pp^exprts[ss])>;
polcheck:=IsDivisibleBy(pow(minpolepsZ[ss]),minpolrtsZ[ss]);
polcheckresult:=polcheck;
end for;
polcycle:=1;
approximationtest:=1;
end while;
end while;
if not(polcheck) then
kk:=kk-1;
toltemp:=toltemp+5;
end if;
elif not(hptest) then
polcheck:=true;
polcheckresult:=<false,"High precision test not applied">;
else
polcheck:=true;
end if;
else
polcheck:=true;
polcheckresult:=<false,"Numerical approximation is not enough">;
break;
end if;
end while;
kendlev:=kk;
// output
if not(testexit) then
if stablevel then
testlevel:=true;
return [*ff,fmodp,nn-1,GBIIT,polcheckresult*];
else
ITest:=II;
end if;
elif (GBIIT ne [1]) then
testlevel:=true;
return [*ff,fmodp,nn-1,GBIIT,polcheckresult*];
else
testlevel:=true;
return [*ff,fmodp,nn-1,GBIIT,polcheckresult*];
end if;
end while;
end function;