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