Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/modular/abvar/homology.py
8820 views
1
r"""
2
Homology of modular abelian varieties
3
4
Sage can compute with homology groups associated to modular abelian
5
varieties with coefficients in any commutative ring. Supported
6
operations include computing matrices and characteristic
7
polynomials of Hecke operators, rank, and rational decomposition as
8
a direct sum of factors (obtained by cutting out kernels of Hecke
9
operators).
10
11
AUTHORS:
12
13
- William Stein (2007-03)
14
15
EXAMPLES::
16
17
sage: J = J0(43)
18
sage: H = J.integral_homology()
19
sage: H
20
Integral Homology of Abelian variety J0(43) of dimension 3
21
sage: H.hecke_matrix(19)
22
[ 0 0 -2 0 2 0]
23
[ 2 -4 -2 0 2 0]
24
[ 0 0 -2 -2 0 0]
25
[ 2 0 -2 -4 2 -2]
26
[ 0 2 0 -2 -2 0]
27
[ 0 2 0 -2 0 0]
28
sage: H.base_ring()
29
Integer Ring
30
sage: d = H.decomposition(); d
31
[
32
Submodule of rank 2 of Integral Homology of Abelian variety J0(43) of dimension 3,
33
Submodule of rank 4 of Integral Homology of Abelian variety J0(43) of dimension 3
34
]
35
sage: a = d[0]
36
sage: a.hecke_matrix(5)
37
[-4 0]
38
[ 0 -4]
39
sage: a.T(7)
40
Hecke operator T_7 on Submodule of rank 2 of Integral Homology of Abelian variety J0(43) of dimension 3
41
"""
42
43
###########################################################################
44
# Copyright (C) 2007 William Stein <[email protected]> #
45
# Distributed under the terms of the GNU General Public License (GPL) #
46
# http://www.gnu.org/licenses/ #
47
###########################################################################
48
49
50
from sage.modular.hecke.all import HeckeModule_free_module
51
from sage.rings.all import Integer, ZZ, QQ
52
from sage.rings.commutative_ring import is_CommutativeRing
53
54
import abvar
55
56
# TODO: we will probably also need homology that is *not* a Hecke module.
57
58
class Homology(HeckeModule_free_module):
59
"""
60
A homology group of an abelian variety, equipped with a Hecke
61
action.
62
"""
63
def hecke_polynomial(self, n, var='x'):
64
"""
65
Return the n-th Hecke polynomial in the given variable.
66
67
INPUT:
68
69
70
- ``n`` - positive integer
71
72
- ``var`` - string (default: 'x') the variable name
73
74
75
OUTPUT: a polynomial over ZZ in the given variable
76
77
EXAMPLES::
78
79
sage: H = J0(43).integral_homology(); H
80
Integral Homology of Abelian variety J0(43) of dimension 3
81
sage: f = H.hecke_polynomial(3); f
82
x^6 + 4*x^5 - 16*x^3 - 12*x^2 + 16*x + 16
83
sage: parent(f)
84
Univariate Polynomial Ring in x over Integer Ring
85
sage: H.hecke_polynomial(3,'w')
86
w^6 + 4*w^5 - 16*w^3 - 12*w^2 + 16*w + 16
87
"""
88
return self.hecke_matrix(n).charpoly(var)
89
90
91
class Homology_abvar(Homology):
92
"""
93
The homology of a modular abelian variety.
94
"""
95
def __init__(self, abvar, base):
96
"""
97
This is an abstract base class, so it is called implicitly in the
98
following examples.
99
100
EXAMPLES::
101
102
sage: H = J0(43).integral_homology()
103
sage: type(H)
104
<class 'sage.modular.abvar.homology.IntegralHomology_with_category'>
105
106
TESTS::
107
108
sage: H = J0(43).integral_homology()
109
sage: loads(dumps(H)) == H
110
True
111
"""
112
if not is_CommutativeRing(base):
113
raise TypeError, "base ring must be a commutative ring"
114
HeckeModule_free_module.__init__(
115
self, base, abvar.level(), weight=2)
116
self.__abvar = abvar
117
118
def __cmp__(self, other):
119
r"""
120
Compare self to other.
121
122
EXAMPLE::
123
124
sage: J0(37).integral_homology() == J0(41).integral_homology()
125
False
126
sage: J0(37).integral_homology() == J0(37).rational_homology()
127
False
128
sage: J0(37).integral_homology() == loads(dumps(J0(37).integral_homology()))
129
True
130
"""
131
132
if not isinstance(other, Homology_abvar):
133
return cmp(type(self), type(other))
134
else:
135
return cmp((self.abelian_variety(), self.base_ring()), (other.abelian_variety(), other.base_ring()))
136
137
def _repr_(self):
138
"""
139
Return string representation of self. This must be defined in the
140
derived class.
141
142
EXAMPLES::
143
144
sage: H = J0(43).integral_homology()
145
sage: from sage.modular.abvar.homology import Homology_abvar
146
sage: Homology_abvar._repr_(H)
147
Traceback (most recent call last):
148
...
149
NotImplementedError: please override this in the derived class
150
"""
151
raise NotImplementedError, "please override this in the derived class"
152
153
def gens(self):
154
"""
155
Return generators of self.
156
157
This is not yet implemented!
158
159
EXAMPLES::
160
161
sage: H = J0(37).homology()
162
sage: H.gens() # this will change
163
Traceback (most recent call last):
164
...
165
NotImplementedError: homology classes not yet implemented
166
"""
167
raise NotImplementedError, "homology classes not yet implemented"
168
169
def gen(self, n):
170
"""
171
Return `n^{th}` generator of self.
172
173
This is not yet implemented!
174
175
EXAMPLES::
176
177
sage: H = J0(37).homology()
178
sage: H.gen(0) # this will change
179
Traceback (most recent call last):
180
...
181
NotImplementedError: homology classes not yet implemented
182
"""
183
raise NotImplementedError, "homology classes not yet implemented"
184
185
def abelian_variety(self):
186
"""
187
Return the abelian variety that this is the homology of.
188
189
EXAMPLES::
190
191
sage: H = J0(48).homology()
192
sage: H.abelian_variety()
193
Abelian variety J0(48) of dimension 3
194
"""
195
return self.__abvar
196
197
def ambient_hecke_module(self):
198
"""
199
Return the ambient Hecke module that this homology is contained
200
in.
201
202
EXAMPLES::
203
204
sage: H = J0(48).homology(); H
205
Integral Homology of Abelian variety J0(48) of dimension 3
206
sage: H.ambient_hecke_module()
207
Integral Homology of Abelian variety J0(48) of dimension 3
208
"""
209
return self
210
211
def free_module(self):
212
"""
213
Return the underlying free module of this homology group.
214
215
EXAMPLES::
216
217
sage: H = J0(48).homology()
218
sage: H.free_module()
219
Ambient free module of rank 6 over the principal ideal domain Integer Ring
220
"""
221
try:
222
return self.__free_module
223
except AttributeError:
224
M = self.base_ring()**self.rank()
225
self.__free_module = M
226
return M
227
228
def hecke_bound(self):
229
r"""
230
Return bound on the number of Hecke operators needed to generate
231
the Hecke algebra as a `\ZZ`-module acting on this
232
space.
233
234
EXAMPLES::
235
236
sage: J0(48).homology().hecke_bound()
237
16
238
sage: J1(15).homology().hecke_bound()
239
32
240
"""
241
return self.__abvar.modular_symbols(sign=1).hecke_bound()
242
243
def hecke_matrix(self, n):
244
"""
245
Return the matrix of the n-th Hecke operator acting on this
246
homology group.
247
248
INPUT:
249
250
251
- ``n`` - a positive integer
252
253
254
OUTPUT: a matrix over the coefficient ring of this homology group
255
256
EXAMPLES::
257
258
sage: H = J0(23).integral_homology()
259
sage: H.hecke_matrix(3)
260
[-1 -2 2 0]
261
[ 0 -3 2 -2]
262
[ 2 -4 3 -2]
263
[ 2 -2 0 1]
264
265
The matrix is over the coefficient ring::
266
267
sage: J = J0(23)
268
sage: J.homology(QQ[I]).hecke_matrix(3).parent()
269
Full MatrixSpace of 4 by 4 dense matrices over Number Field in I with defining polynomial x^2 + 1
270
"""
271
raise NotImplementedError
272
273
def rank(self):
274
"""
275
Return the rank as a module or vector space of this homology
276
group.
277
278
EXAMPLES::
279
280
sage: H = J0(5077).homology(); H
281
Integral Homology of Abelian variety J0(5077) of dimension 422
282
sage: H.rank()
283
844
284
"""
285
return self.__abvar.dimension() * 2
286
287
def submodule(self, U, check=True):
288
r"""
289
Return the submodule of this homology group given by `U`,
290
which should be a submodule of the free module associated to this
291
homology group.
292
293
INPUT:
294
295
296
- ``U`` - submodule of ambient free module (or
297
something that defines one)
298
299
- ``check`` - currently ignored.
300
301
302
.. note::
303
304
We do *not* check that U is invariant under all Hecke
305
operators.
306
307
EXAMPLES::
308
309
sage: H = J0(23).homology(); H
310
Integral Homology of Abelian variety J0(23) of dimension 2
311
sage: F = H.free_module()
312
sage: U = F.span([[1,2,3,4]])
313
sage: M = H.submodule(U); M
314
Submodule of rank 1 of Integral Homology of Abelian variety J0(23) of dimension 2
315
316
Note that the submodule command doesn't actually check that the
317
object defined is a homology group or is invariant under the Hecke
318
operators. For example, the fairly random `M` that we just
319
defined is not invariant under the Hecke operators, so it is not a
320
Hecke submodule - it is only a `\ZZ`-submodule.
321
322
::
323
324
sage: M.hecke_matrix(3)
325
Traceback (most recent call last):
326
...
327
ArithmeticError: subspace is not invariant under matrix
328
"""
329
return Homology_submodule(self, U)
330
331
332
class IntegralHomology(Homology_abvar):
333
r"""
334
The integral homology `H_1(A,\ZZ)` of a modular
335
abelian variety.
336
"""
337
def __init__(self, abvar):
338
"""
339
Create the integral homology of a modular abelian variety.
340
341
INPUT:
342
343
344
- ``abvar`` - a modular abelian variety
345
346
347
EXAMPLES::
348
349
sage: H = J0(23).integral_homology(); H
350
Integral Homology of Abelian variety J0(23) of dimension 2
351
sage: type(H)
352
<class 'sage.modular.abvar.homology.IntegralHomology_with_category'>
353
354
TESTS::
355
356
sage: loads(dumps(H)) == H
357
True
358
"""
359
Homology_abvar.__init__(self, abvar, ZZ)
360
361
def _repr_(self):
362
"""
363
String representation of the integral homology.
364
365
EXAMPLES::
366
367
sage: J0(23).integral_homology()._repr_()
368
'Integral Homology of Abelian variety J0(23) of dimension 2'
369
"""
370
return "Integral Homology of %s"%self.abelian_variety()
371
372
def hecke_matrix(self, n):
373
"""
374
Return the matrix of the n-th Hecke operator acting on this
375
homology group.
376
377
EXAMPLES::
378
379
sage: J0(48).integral_homology().hecke_bound()
380
16
381
sage: t = J1(13).integral_homology().hecke_matrix(3); t
382
[ 0 0 2 -2]
383
[-2 -2 0 2]
384
[-2 -2 0 0]
385
[ 0 -2 2 -2]
386
sage: t.base_ring()
387
Integer Ring
388
"""
389
n = Integer(n)
390
return self.abelian_variety()._integral_hecke_matrix(n)
391
392
def hecke_polynomial(self, n, var='x'):
393
"""
394
Return the n-th Hecke polynomial on this integral homology group.
395
396
EXAMPLES::
397
398
sage: f = J0(43).integral_homology().hecke_polynomial(2)
399
sage: f.base_ring()
400
Integer Ring
401
sage: factor(f)
402
(x + 2)^2 * (x^2 - 2)^2
403
"""
404
n = Integer(n)
405
M = self.abelian_variety().modular_symbols(sign=1)
406
f = (M.hecke_polynomial(n, var)**2).change_ring(ZZ)
407
return f
408
409
class RationalHomology(Homology_abvar):
410
r"""
411
The rational homology `H_1(A,\QQ)` of a modular
412
abelian variety.
413
"""
414
def __init__(self, abvar):
415
"""
416
Create the rational homology of a modular abelian variety.
417
418
INPUT:
419
420
421
- ``abvar`` - a modular abelian variety
422
423
424
EXAMPLES::
425
426
sage: H = J0(23).rational_homology(); H
427
Rational Homology of Abelian variety J0(23) of dimension 2
428
429
TESTS::
430
431
sage: loads(dumps(H)) == H
432
True
433
"""
434
Homology_abvar.__init__(self, abvar, QQ)
435
436
def _repr_(self):
437
"""
438
Return string representation of the rational homology.
439
440
EXAMPLES::
441
442
sage: J0(23).rational_homology()._repr_()
443
'Rational Homology of Abelian variety J0(23) of dimension 2'
444
"""
445
return "Rational Homology of %s"%self.abelian_variety()
446
447
def hecke_matrix(self, n):
448
"""
449
Return the matrix of the n-th Hecke operator acting on this
450
homology group.
451
452
EXAMPLES::
453
454
sage: t = J1(13).homology(QQ).hecke_matrix(3); t
455
[ 0 0 2 -2]
456
[-2 -2 0 2]
457
[-2 -2 0 0]
458
[ 0 -2 2 -2]
459
sage: t.base_ring()
460
Rational Field
461
sage: t = J1(13).homology(GF(3)).hecke_matrix(3); t
462
[0 0 2 1]
463
[1 1 0 2]
464
[1 1 0 0]
465
[0 1 2 1]
466
sage: t.base_ring()
467
Finite Field of size 3
468
"""
469
n = Integer(n)
470
return self.abelian_variety()._rational_hecke_matrix(n)
471
472
def hecke_polynomial(self, n, var='x'):
473
"""
474
Return the n-th Hecke polynomial on this rational homology group.
475
476
EXAMPLES::
477
478
sage: f = J0(43).rational_homology().hecke_polynomial(2)
479
sage: f.base_ring()
480
Rational Field
481
sage: factor(f)
482
(x + 2) * (x^2 - 2)
483
"""
484
f = self.hecke_operator(n).matrix().characteristic_polynomial(var)
485
return abvar.sqrt_poly(f)
486
487
#n = Integer(n)
488
#M = self.abelian_variety().modular_symbols(sign=1)
489
#f = M.hecke_polynomial(n, var)**2
490
#return f
491
492
493
class Homology_over_base(Homology_abvar):
494
r"""
495
The homology over a modular abelian variety over an arbitrary base
496
commutative ring (not `\ZZ` or
497
`\QQ`).
498
"""
499
def __init__(self, abvar, base_ring):
500
r"""
501
Called when creating homology with coefficients not
502
`\ZZ` or `\QQ`.
503
504
INPUT:
505
506
507
- ``abvar`` - a modular abelian variety
508
509
- ``base_ring`` - a commutative ring
510
511
512
EXAMPLES::
513
514
sage: H = J0(23).homology(GF(5)); H
515
Homology with coefficients in Finite Field of size 5 of Abelian variety J0(23) of dimension 2
516
sage: type(H)
517
<class 'sage.modular.abvar.homology.Homology_over_base_with_category'>
518
519
TESTS::
520
521
sage: loads(dumps(H)) == H
522
True
523
"""
524
Homology_abvar.__init__(self, abvar, base_ring)
525
526
def _repr_(self):
527
"""
528
Return string representation of self.
529
530
EXAMPLES::
531
532
sage: H = J0(23).homology(GF(5))
533
sage: H._repr_()
534
'Homology with coefficients in Finite Field of size 5 of Abelian variety J0(23) of dimension 2'
535
"""
536
return "Homology with coefficients in %s of %s"%(self.base_ring(), self.abelian_variety())
537
538
def hecke_matrix(self, n):
539
"""
540
Return the matrix of the n-th Hecke operator acting on this
541
homology group.
542
543
EXAMPLES::
544
545
sage: t = J1(13).homology(GF(3)).hecke_matrix(3); t
546
[0 0 2 1]
547
[1 1 0 2]
548
[1 1 0 0]
549
[0 1 2 1]
550
sage: t.base_ring()
551
Finite Field of size 3
552
"""
553
n = Integer(n)
554
return self.abelian_variety()._integral_hecke_matrix(n).change_ring(self.base_ring())
555
556
class Homology_submodule(Homology):
557
"""
558
A submodule of the homology of a modular abelian variety.
559
"""
560
def __init__(self, ambient, submodule):
561
"""
562
Create a submodule of the homology of a modular abelian variety.
563
564
INPUT:
565
566
567
- ``ambient`` - the homology of some modular abelian
568
variety with ring coefficients
569
570
- ``submodule`` - a submodule of the free module
571
underlying ambient
572
573
574
EXAMPLES::
575
576
sage: H = J0(37).homology()
577
sage: H.submodule([[1,0,0,0]])
578
Submodule of rank 1 of Integral Homology of Abelian variety J0(37) of dimension 2
579
580
TESTS::
581
582
sage: loads(dumps(H)) == H
583
True
584
"""
585
if not isinstance(ambient, Homology_abvar):
586
raise TypeError, "ambient must be the homology of a modular abelian variety"
587
self.__ambient = ambient
588
#try:
589
# if not submodule.is_submodule(ambient):
590
# raise ValueError, "submodule must be a submodule of the ambient homology group"
591
#except AttributeError:
592
submodule = ambient.free_module().submodule(submodule)
593
self.__submodule = submodule
594
HeckeModule_free_module.__init__(
595
self, ambient.base_ring(), ambient.level(), weight=2)
596
597
def _repr_(self):
598
"""
599
String representation of this submodule of homology.
600
601
EXAMPLES::
602
603
sage: H = J0(37).homology()
604
sage: G = H.submodule([[1, 2, 3, 4]])
605
sage: G._repr_()
606
'Submodule of rank 1 of Integral Homology of Abelian variety J0(37) of dimension 2'
607
"""
608
return "Submodule of rank %s of %s"%(self.rank(), self.__ambient)
609
610
def __cmp__(self, other):
611
r"""
612
Compare self to other.
613
614
EXAMPLE::
615
616
sage: J0(37).homology().decomposition() # indirect doctest
617
[
618
Submodule of rank 2 of Integral Homology of Abelian variety J0(37) of dimension 2,
619
Submodule of rank 2 of Integral Homology of Abelian variety J0(37) of dimension 2
620
]
621
"""
622
623
if not isinstance(other, Homology_submodule):
624
return cmp(type(self), type(other))
625
c = cmp(self.__ambient, other.__ambient)
626
if c: return c
627
return cmp(self.__submodule, other.__submodule)
628
629
630
def ambient_hecke_module(self):
631
"""
632
Return the ambient Hecke module that this homology is contained
633
in.
634
635
EXAMPLES::
636
637
sage: H = J0(48).homology(); H
638
Integral Homology of Abelian variety J0(48) of dimension 3
639
sage: d = H.decomposition(); d
640
[
641
Submodule of rank 2 of Integral Homology of Abelian variety J0(48) of dimension 3,
642
Submodule of rank 4 of Integral Homology of Abelian variety J0(48) of dimension 3
643
]
644
sage: d[0].ambient_hecke_module()
645
Integral Homology of Abelian variety J0(48) of dimension 3
646
"""
647
return self.__ambient
648
649
def free_module(self):
650
"""
651
Return the underlying free module of the homology group.
652
653
EXAMPLES::
654
655
sage: H = J0(48).homology()
656
sage: K = H.decomposition()[1]; K
657
Submodule of rank 4 of Integral Homology of Abelian variety J0(48) of dimension 3
658
sage: K.free_module()
659
Free module of degree 6 and rank 4 over Integer Ring
660
Echelon basis matrix:
661
[ 1 0 0 0 0 0]
662
[ 0 1 0 0 1 -1]
663
[ 0 0 1 0 -1 1]
664
[ 0 0 0 1 0 -1]
665
"""
666
return self.__submodule
667
668
def hecke_bound(self):
669
"""
670
Return a bound on the number of Hecke operators needed to generate
671
the Hecke algebra acting on this homology group.
672
673
EXAMPLES::
674
675
sage: d = J0(43).homology().decomposition(2); d
676
[
677
Submodule of rank 2 of Integral Homology of Abelian variety J0(43) of dimension 3,
678
Submodule of rank 4 of Integral Homology of Abelian variety J0(43) of dimension 3
679
]
680
681
Because the first factor has dimension 2 it corresponds to an
682
elliptic curve, so we have a Hecke bound of 1.
683
684
::
685
686
sage: d[0].hecke_bound()
687
1
688
sage: d[1].hecke_bound()
689
8
690
"""
691
if self.rank() <= 2:
692
return ZZ(1)
693
else:
694
return self.__ambient.hecke_bound()
695
696
def hecke_matrix(self, n):
697
"""
698
Return the matrix of the n-th Hecke operator acting on this
699
homology group.
700
701
EXAMPLES::
702
703
sage: d = J0(125).homology(GF(17)).decomposition(2); d
704
[
705
Submodule of rank 4 of Homology with coefficients in Finite Field of size 17 of Abelian variety J0(125) of dimension 8,
706
Submodule of rank 4 of Homology with coefficients in Finite Field of size 17 of Abelian variety J0(125) of dimension 8,
707
Submodule of rank 8 of Homology with coefficients in Finite Field of size 17 of Abelian variety J0(125) of dimension 8
708
]
709
sage: t = d[0].hecke_matrix(17); t
710
[16 15 15 0]
711
[ 0 5 0 2]
712
[ 2 0 5 15]
713
[ 0 15 0 16]
714
sage: t.base_ring()
715
Finite Field of size 17
716
sage: t.fcp()
717
(x^2 + 13*x + 16)^2
718
"""
719
n = Integer(n)
720
try:
721
return self.__hecke_matrix[n]
722
except AttributeError:
723
self.__hecke_matrix = {}
724
except KeyError:
725
pass
726
t = self.__ambient.hecke_matrix(n)
727
s = t.restrict(self.__submodule)
728
self.__hecke_matrix[n] = s
729
return s
730
731
def rank(self):
732
"""
733
Return the rank of this homology group.
734
735
EXAMPLES::
736
737
sage: d = J0(43).homology().decomposition(2)
738
sage: [H.rank() for H in d]
739
[2, 4]
740
"""
741
return self.__submodule.rank()
742
743
744
745