Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

r""" 

Arithmetic subgroups (finite index subgroups of `{\rm SL}_2(\ZZ)`) 

""" 

################################################################################ 

# 

# Copyright (C) 2009, The Sage Group -- http://www.sagemath.org/ 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# 

# The full text of the GPL is available at: 

# 

# http://www.gnu.org/licenses/ 

# 

################################################################################ 

from __future__ import absolute_import 

from six.moves import range 

 

from sage.groups.old import Group 

from sage.rings.all import ZZ 

from sage.arith.all import lcm 

from sage.misc.cachefunc import cached_method 

from copy import copy # for making copies of lists of cusps 

from sage.modular.modsym.p1list import lift_to_sl2z 

from sage.modular.cusps import Cusp 

 

from sage.misc.lazy_import import lazy_import 

lazy_import('sage.modular.arithgroup.congroup_sl2z', 'SL2Z') 

from sage.structure.element import parent 

 

from .arithgroup_element import ArithmeticSubgroupElement 

 

def is_ArithmeticSubgroup(x): 

r""" 

Return True if x is of type ArithmeticSubgroup. 

 

EXAMPLES:: 

 

sage: from sage.modular.arithgroup.all import is_ArithmeticSubgroup 

sage: is_ArithmeticSubgroup(GL(2, GF(7))) 

False 

sage: is_ArithmeticSubgroup(Gamma0(4)) 

True 

""" 

 

return isinstance(x, ArithmeticSubgroup) 

 

 

class ArithmeticSubgroup(Group): 

r""" 

Base class for arithmetic subgroups of `{\rm SL}_2(\ZZ)`. Not 

intended to be used directly, but still includes quite a few 

general-purpose routines which compute data about an arithmetic subgroup 

assuming that it has a working element testing routine. 

""" 

 

Element = ArithmeticSubgroupElement 

 

def __init__(self): 

r""" 

Standard init routine. 

 

EXAMPLES:: 

 

sage: G = Gamma1(7) 

sage: G.category() # indirect doctest 

Category of groups 

""" 

Group.__init__(self) 

 

def _repr_(self): 

r""" 

Return the string representation of self. 

 

NOTE: This function should be overridden by all subclasses. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup()._repr_() 

'Generic arithmetic subgroup of SL2Z' 

""" 

return "Generic arithmetic subgroup of SL2Z" 

 

def _repr_option(self, key): 

""" 

Metadata about the :meth:`_repr_` output. 

 

See :meth:`sage.structure.parent._repr_option` for details. 

 

EXAMPLES:: 

 

sage: Gamma1(7)._repr_option('element_ascii_art') 

True 

""" 

if key == 'element_ascii_art': 

return True 

return super(ArithmeticSubgroup, self)._repr_option(key) 

 

def __reduce__(self): 

r""" 

Used for pickling self. 

 

NOTE: This function should be overridden by all subclasses. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().__reduce__() 

Traceback (most recent call last): 

... 

NotImplementedError: all subclasses must define a __reduce__ method 

""" 

raise NotImplementedError("all subclasses must define a __reduce__ method") 

 

def _element_constructor_(self, x, check=True): 

r""" 

Create an element of this congruence subgroup from x. 

 

If the optional flag check is True (default), check whether 

x actually gives an element of self. 

 

EXAMPLES:: 

 

sage: G = Gamma(5) 

sage: G([1, 0, -10, 1]) # indirect doctest 

[ 1 0] 

[-10 1] 

sage: G(matrix(ZZ, 2, [26, 5, 5, 1])) 

[26 5] 

[ 5 1] 

sage: G([1, 1, 6, 7]) 

Traceback (most recent call last): 

... 

TypeError: matrix [1 1] 

[6 7] is not an element of Congruence Subgroup Gamma(5) 

""" 

# Do not override this function! Derived classes should override 

# _contains_sl2. 

x = SL2Z(x, check) 

if not check or x in self: 

return x 

raise TypeError("matrix %s is not an element of %s" % (x, self)) 

 

def __contains__(self, x): 

r""" 

Test if x is an element of this group. This checks that x defines (is?) a 2x2 integer matrix of determinant 1, and 

then hands over to the routine _contains_sl2, which derived classes should implement. 

 

EXAMPLES:: 

 

sage: [1,2] in SL2Z # indirect doctest 

False 

sage: [1,2,0,1] in SL2Z # indirect doctest 

True 

sage: SL2Z([1,2,0,1]) in Gamma(3) # indirect doctest 

False 

sage: -1 in SL2Z 

True 

sage: 2 in SL2Z 

False 

""" 

# Do not override this function! Derived classes should override 

# _contains_sl2. 

if isinstance(x, list) and len(x) == 4: 

if not (x[0] in ZZ and x[1] in ZZ and x[2] in ZZ and x[3] in ZZ): 

return False 

a,b,c,d = map(ZZ, x) 

if a*d - b*c != 1: return False 

return self._contains_sl2(a,b,c,d) 

else: 

if parent(x) is not SL2Z: 

try: 

y = SL2Z(x) 

except TypeError: 

return False 

x = y 

return self._contains_sl2(x.a(),x.b(),x.c(),x.d()) 

 

def _contains_sl2(self, a,b,c,d): 

r""" 

Test whether the matrix [a,b;c,d], which may be assumed to have 

determinant 1, is an element of self. This must be overridden by all 

subclasses. 

 

EXAMPLES:: 

 

sage: G = sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup() 

sage: 1 in G 

Traceback (most recent call last): 

... 

NotImplementedError: Please implement _contains_sl2 for <class 'sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup_with_category'> 

""" 

raise NotImplementedError("Please implement _contains_sl2 for %s" % self.__class__) 

 

def __hash__(self): 

r""" 

Return a hash of self. 

 

EXAMPLES:: 

 

sage: Gamma0(11).__hash__() 

118770652 # 32-bit 

3713075136762760156 # 64-bit 

sage: Gamma1(11).__hash__() 

201042552 # 32-bit 

3713075136845032056 # 64-bit 

 

TESTS: 

 

We test that :trac:`18743` is fixed:: 

 

sage: G1 = GammaH(37,[4]); G1 

Congruence Subgroup Gamma_H(37) with H generated by [4] 

sage: G2 = GammaH(37,[4,16]); G2 

Congruence Subgroup Gamma_H(37) with H generated by [4, 7] 

sage: G1 == G2 

True 

sage: G1.__hash__() == G2.__hash__() 

True 

sage: set([G1,G2]) 

{Congruence Subgroup Gamma_H(37) with H generated by [4]} 

 

""" 

return hash((self.level(), self.index())) 

 

def is_parent_of(self, x): 

r""" 

Check whether this group is a valid parent for the element x. Required 

by Sage's testing framework. 

 

EXAMPLES:: 

 

sage: Gamma(3).is_parent_of(ZZ(1)) 

False 

sage: Gamma(3).is_parent_of([1,0,0,1]) 

False 

sage: Gamma(3).is_parent_of(SL2Z([1,1,0,1])) 

False 

sage: Gamma(3).is_parent_of(SL2Z(1)) 

True 

""" 

return (parent(x) == SL2Z and x in self) 

 

def coset_reps(self, G=None): 

r""" 

Return right coset representatives for self \\ G, where G is another 

arithmetic subgroup that contains self. If G = None, default to G = 

SL2Z. 

 

For generic arithmetic subgroups G this is carried out by Todd-Coxeter 

enumeration; here G is treated as a black box, implementing nothing but 

membership testing. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().coset_reps() 

Traceback (most recent call last): 

... 

NotImplementedError: Please implement _contains_sl2 for <class 'sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup_with_category'> 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup.coset_reps(Gamma0(3)) 

[ 

[1 0] [ 0 -1] [ 0 -1] [ 0 -1] 

[0 1], [ 1 0], [ 1 1], [ 1 2] 

] 

""" 

return self.todd_coxeter(G)[0] 

 

@cached_method 

def todd_coxeter(self, G=None, on_right=True): 

r""" 

Compute coset representatives for self \\ G and action of standard 

generators on them via Todd-Coxeter enumeration. 

 

If ``G`` is ``None``, default to ``SL2Z``. The method also computes 

generators of the subgroup at same time. 

 

INPUT: 

 

- ``G`` - intermediate subgroup (currently not implemented if different 

from SL(2,Z)) 

 

- ``on_right`` - boolean (default: True) - if True return right coset 

enumeration, if False return left one. 

 

This is *extremely* slow in general. 

 

OUTPUT: 

 

- a list of coset representatives 

 

- a list of generators for the group 

 

- ``l`` - list of integers that correspond to the action of the 

standard parabolic element [[1,1],[0,1]] of `SL(2,\ZZ)` on the cosets 

of self. 

 

- ``s`` - list of integers that correspond to the action of the standard 

element of order `2` [[0,-1],[1,0]] on the cosets of self. 

 

EXAMPLES:: 

 

sage: L = SL2Z([1,1,0,1]) 

sage: S = SL2Z([0,-1,1,0]) 

 

sage: G = Gamma(2) 

sage: reps, gens, l, s = G.todd_coxeter() 

sage: len(reps) == G.index() 

True 

sage: all(reps[i] * L * ~reps[l[i]] in G for i in range(6)) 

True 

sage: all(reps[i] * S * ~reps[s[i]] in G for i in range(6)) 

True 

 

sage: G = Gamma0(7) 

sage: reps, gens, l, s = G.todd_coxeter() 

sage: len(reps) == G.index() 

True 

sage: all(reps[i] * L * ~reps[l[i]] in G for i in range(8)) 

True 

sage: all(reps[i] * S * ~reps[s[i]] in G for i in range(8)) 

True 

 

sage: G = Gamma1(3) 

sage: reps, gens, l, s = G.todd_coxeter(on_right=False) 

sage: len(reps) == G.index() 

True 

sage: all(~reps[l[i]] * L * reps[i] in G for i in range(8)) 

True 

sage: all(~reps[s[i]] * S * reps[i] in G for i in range(8)) 

True 

 

sage: G = Gamma0(5) 

sage: reps, gens, l, s = G.todd_coxeter(on_right=False) 

sage: len(reps) == G.index() 

True 

sage: all(~reps[l[i]] * L * reps[i] in G for i in range(6)) 

True 

sage: all(~reps[s[i]] * S * reps[i] in G for i in range(6)) 

True 

""" 

if G is None: 

G = SL2Z 

if G != SL2Z: 

raise NotImplementedError("Don't know how to compute coset reps for subgroups yet") 

 

id = SL2Z([1,0,0,1]) 

l = SL2Z([1,1,0,1]) 

s = SL2Z([0,-1,1,0]) 

 

reps = [id] # coset representatives 

reps_inv = {id:0} # coset representatives index 

 

l_wait_back = [id] # rep with no incoming s_edge 

s_wait_back = [id] # rep with no incoming l_edge 

l_wait = [id] # rep with no outgoing l_edge 

s_wait = [id] # rep with no outgoing s_edge 

 

l_edges = [None] # edges for l 

s_edges = [None] # edges for s 

 

gens = [] 

 

while l_wait or s_wait: 

if l_wait: 

x = l_wait.pop(0) 

y = x 

not_end = True 

while not_end: 

if on_right: 

y = y*l 

else: 

y = l*y 

for i in range(len(l_wait_back)): 

v = l_wait_back[i] 

if on_right: 

yy = y*~v 

else: 

yy = ~v*y 

if yy in self: 

l_edges[reps_inv[x]] = reps_inv[v] 

del l_wait_back[i] 

if yy != id: 

gens.append(self(yy)) 

not_end = False 

break 

else: 

reps_inv[y] = len(reps) 

l_edges[reps_inv[x]] = len(reps) 

reps.append(y) 

l_edges.append(None) 

s_edges.append(None) 

s_wait_back.append(y) 

s_wait.append(y) 

x = y 

 

if s_wait: 

x = s_wait.pop(0) 

y = x 

not_end = True 

while not_end: 

if on_right: 

y = y*s 

else: 

y = s*y 

for i in range(len(s_wait_back)): 

v = s_wait_back[i] 

if on_right: 

yy = y*~v 

else: 

yy = ~v*y 

if yy in self: 

s_edges[reps_inv[x]] = reps_inv[v] 

del s_wait_back[i] 

if yy != id: 

gens.append(self(yy)) 

not_end = False 

break 

else: 

reps_inv[y] = len(reps) 

s_edges[reps_inv[x]] = len(reps) 

reps.append(y) 

l_edges.append(None) 

s_edges.append(None) 

l_wait_back.append(y) 

l_wait.append(y) 

x = y 

 

return reps, gens, l_edges, s_edges 

 

def nu2(self): 

r""" 

Return the number of orbits of elliptic points of order 2 for this 

arithmetic subgroup. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().nu2() 

Traceback (most recent call last): 

... 

NotImplementedError: Please implement _contains_sl2 for <class 'sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup_with_category'> 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup.nu2(Gamma0(1105)) == 8 

True 

""" 

 

# Subgroups not containing -1 have no elliptic points of order 2. 

 

if not self.is_even(): 

return 0 

 

# Cheap trick: if self is a subgroup of something with no elliptic points, 

# then self has no elliptic points either. 

 

from .all import Gamma0, is_CongruenceSubgroup 

if is_CongruenceSubgroup(self): 

if self.is_subgroup(Gamma0(self.level())) and Gamma0(self.level()).nu2() == 0: 

return 0 

 

# Otherwise, the number of elliptic points is the number of g in self \ 

# SL2Z such that the stabiliser of g * i in self is not trivial. (Note 

# that the points g*i for g in the coset reps are not distinct, but it 

# still works, since the failure of these points to be distinct happens 

# precisely when the preimages are not elliptic.) 

 

count = 0 

for g in self.coset_reps(): 

if g * SL2Z([0,1,-1,0]) * (~g) in self: 

count += 1 

return count 

 

def nu3(self): 

r""" 

Return the number of orbits of elliptic points of order 3 for this 

arithmetic subgroup. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().nu3() 

Traceback (most recent call last): 

... 

NotImplementedError: Please implement _contains_sl2 for <class 'sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup_with_category'> 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup.nu3(Gamma0(1729)) == 8 

True 

 

We test that a bug in handling of subgroups not containing -1 is fixed:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup.nu3(GammaH(7, [2])) 

2 

""" 

 

# Cheap trick: if self is a subgroup of something with no elliptic points, 

# then self has no elliptic points either. 

 

from .all import Gamma0, is_CongruenceSubgroup 

if is_CongruenceSubgroup(self): 

if self.is_subgroup(Gamma0(self.level())) and Gamma0(self.level()).nu3() == 0: 

return 0 

 

count = 0 

for g in self.coset_reps(): 

if g * SL2Z([0,1,-1,-1]) * (~g) in self: 

count += 1 

 

if self.is_even(): 

return count 

else: 

return count // 2 

 

def is_abelian(self): 

r""" 

Return True if this arithmetic subgroup is abelian. 

 

Since arithmetic subgroups are always nonabelian, this always 

returns False. 

 

EXAMPLES:: 

 

sage: SL2Z.is_abelian() 

False 

sage: Gamma0(3).is_abelian() 

False 

sage: Gamma1(12).is_abelian() 

False 

sage: GammaH(4, [3]).is_abelian() 

False 

""" 

return False 

 

def is_finite(self): 

r""" 

Return True if this arithmetic subgroup is finite. 

 

Since arithmetic subgroups are always infinite, this always 

returns False. 

 

EXAMPLES:: 

 

sage: SL2Z.is_finite() 

False 

sage: Gamma0(3).is_finite() 

False 

sage: Gamma1(12).is_finite() 

False 

sage: GammaH(4, [3]).is_finite() 

False 

""" 

return False 

 

def is_subgroup(self, right): 

r""" 

Return True if self is a subgroup of right, and False otherwise. For 

generic arithmetic subgroups this is done by the absurdly slow 

algorithm of checking all of the generators of self to see if they are 

in right. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().is_subgroup(SL2Z) 

Traceback (most recent call last): 

... 

NotImplementedError: Please implement _contains_sl2 for <class 'sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup_with_category'> 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup.is_subgroup(Gamma1(18), Gamma0(6)) 

True 

""" 

# ridiculously slow generic algorithm 

 

w = self.gens() 

for g in w: 

if not (g in right): 

return False 

return True 

 

def is_normal(self): 

r""" 

Return True precisely if this subgroup is a normal subgroup of SL2Z. 

 

EXAMPLES:: 

 

sage: Gamma(3).is_normal() 

True 

sage: Gamma1(3).is_normal() 

False 

""" 

for x in self.gens(): 

for y in SL2Z.gens(): 

if y*SL2Z(x)*(~y) not in self: 

return False 

return True 

 

def is_odd(self): 

r""" 

Return True precisely if this subgroup does not contain the 

matrix -1. 

 

EXAMPLES:: 

 

sage: SL2Z.is_odd() 

False 

sage: Gamma0(20).is_odd() 

False 

sage: Gamma1(5).is_odd() 

True 

sage: GammaH(11, [3]).is_odd() 

True 

""" 

return not self.is_even() 

 

def is_even(self): 

r""" 

Return True precisely if this subgroup contains the matrix -1. 

 

EXAMPLES:: 

 

sage: SL2Z.is_even() 

True 

sage: Gamma0(20).is_even() 

True 

sage: Gamma1(5).is_even() 

False 

sage: GammaH(11, [3]).is_even() 

False 

""" 

return [-1, 0, 0, -1] in self 

 

def to_even_subgroup(self): 

r""" 

Return the smallest even subgroup of `SL(2, \ZZ)` containing self. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().to_even_subgroup() 

Traceback (most recent call last): 

... 

NotImplementedError: Please implement _contains_sl2 for <class 'sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup_with_category'> 

""" 

if self.is_even(): 

return self 

else: 

raise NotImplementedError 

 

def order(self): 

r""" 

Return the number of elements in this arithmetic subgroup. 

 

Since arithmetic subgroups are always infinite, this always returns 

infinity. 

 

EXAMPLES:: 

 

sage: SL2Z.order() 

+Infinity 

sage: Gamma0(5).order() 

+Infinity 

sage: Gamma1(2).order() 

+Infinity 

sage: GammaH(12, [5]).order() 

+Infinity 

""" 

from sage.rings.infinity import infinity 

return infinity 

 

def reduce_cusp(self, c): 

r""" 

Given a cusp `c \in \mathbb{P}^1(\QQ)`, return the unique reduced cusp 

equivalent to c under the action of self, where a reduced cusp is an 

element `\tfrac{r}{s}` with r,s coprime non-negative integers, s as 

small as possible, and r as small as possible for that s. 

 

NOTE: This function should be overridden by all subclasses. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().reduce_cusp(1/4) 

Traceback (most recent call last): 

... 

NotImplementedError 

""" 

raise NotImplementedError 

 

def cusps(self, algorithm='default'): 

r""" 

Return a sorted list of inequivalent cusps for self, i.e. a set of 

representatives for the orbits of self on `\mathbb{P}^1(\QQ)`. 

These should be returned in a reduced form where this makes sense. 

 

INPUT: 

 

- ``algorithm`` -- which algorithm to use to compute the cusps of self. 

``'default'`` finds representatives for a known complete set of 

cusps. ``'modsym'`` computes the boundary map on the space of weight 

two modular symbols associated to self, which finds the cusps for 

self in the process. 

 

EXAMPLES:: 

 

sage: Gamma0(36).cusps() 

[0, 1/18, 1/12, 1/9, 1/6, 1/4, 1/3, 5/12, 1/2, 2/3, 5/6, Infinity] 

sage: Gamma0(36).cusps(algorithm='modsym') == Gamma0(36).cusps() 

True 

sage: GammaH(36, [19,29]).cusps() == Gamma0(36).cusps() 

True 

sage: Gamma0(1).cusps() 

[Infinity] 

""" 

try: 

return copy(self._cusp_list[algorithm]) 

except (AttributeError,KeyError): 

self._cusp_list = {} 

 

from .congroup_sl2z import is_SL2Z 

if is_SL2Z(self): 

s = [Cusp(1,0)] 

 

if algorithm == 'default': 

s = self._find_cusps() 

elif algorithm == 'modsym': 

s = sorted([self.reduce_cusp(c) for c in self.modular_symbols().cusps()]) 

else: 

raise ValueError("unknown algorithm: %s"%algorithm) 

 

self._cusp_list[algorithm] = s 

return copy(s) 

 

def _find_cusps(self): 

r""" 

Calculate a list of inequivalent cusps. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroup(5)._find_cusps() 

Traceback (most recent call last): 

... 

NotImplementedError 

 

NOTE: There is a generic algorithm implemented at the top level that 

uses the coset representatives of self. This is *very slow* and for all 

the standard congruence subgroups there is a quicker way of doing it, 

so this should usually be overridden in subclasses; but it doesn't have 

to be. 

""" 

i = Cusp([1,0]) 

L = [i] 

for a in self.coset_reps(): 

ai = i.apply([a.a(), a.b(), a.c(), a.d()]) 

new = 1 

for v in L: 

if self.are_equivalent(ai, v): 

new = 0 

break 

if new == 1: 

L.append(ai) 

return L 

 

def are_equivalent(self, x, y, trans = False): 

r""" 

Test whether or not cusps x and y are equivalent modulo self. If self 

has a reduce_cusp() method, use that; otherwise do a slow explicit 

test. 

 

If trans = False, returns True or False. If trans = True, then return 

either False or an element of self mapping x onto y. 

 

EXAMPLES:: 

 

sage: Gamma0(7).are_equivalent(Cusp(1/3), Cusp(0), trans=True) 

[ 3 -1] 

[-14 5] 

sage: Gamma0(7).are_equivalent(Cusp(1/3), Cusp(1/7)) 

False 

""" 

x = Cusp(x) 

y = Cusp(y) 

if not trans: 

try: 

xr = self.reduce_cusp(x) 

yr = self.reduce_cusp(y) 

if xr != yr: 

return False 

if xr == yr: 

return True 

except NotImplementedError: 

pass 

 

vx = lift_to_sl2z(x.numerator(),x.denominator(), 0) 

dx = SL2Z([vx[2], -vx[0], vx[3], -vx[1]]) 

vy = lift_to_sl2z(y.numerator(),y.denominator(), 0) 

dy = SL2Z([vy[2], -vy[0], vy[3], -vy[1]]) 

 

for i in range(self.index()): 

# Note that the width of any cusp is bounded above by the index of self. 

# If self is congruence, then the level of self is a much better bound, but 

# this method is written to work with non-congruence subgroups as well, 

if dy * SL2Z([1,i,0,1])*(~dx) in self: 

if trans: 

return dy * SL2Z([1,i,0,1]) * ~dx 

else: 

return True 

elif (self.is_odd() and dy * SL2Z([-1,-i,0,-1]) * ~dx in self): 

if trans: 

return dy * SL2Z([-1,-i,0,-1]) * ~dx 

else: 

return True 

return False 

 

def cusp_data(self, c): 

r""" 

Return a triple (g, w, t) where g is an element of self generating the 

stabiliser of the given cusp, w is the width of the cusp, and t is 1 if 

the cusp is regular and -1 if not. 

 

EXAMPLES:: 

 

sage: Gamma1(4).cusp_data(Cusps(1/2)) 

( 

[ 1 -1] 

[ 4 -3], 1, -1 

) 

""" 

c = Cusp(c) 

 

# first find an element of SL2Z sending infinity to the given cusp 

w = lift_to_sl2z(c.denominator(), c.numerator(), 0) 

g = SL2Z([w[3], w[1], w[2],w[0]]) 

 

for d in range(1,1+self.index()): 

if g * SL2Z([1,d,0,1]) * (~g) in self: 

return (g * SL2Z([1,d,0,1]) * (~g), d, 1) 

elif g * SL2Z([-1,-d,0,-1]) * (~g) in self: 

return (g * SL2Z([-1,-d,0,-1]) * (~g), d, -1) 

raise ArithmeticError("Can't get here!") 

 

def is_regular_cusp(self, c): 

r""" 

Return True if the orbit of the given cusp is a regular cusp for self, 

otherwise False. This is automatically true if -1 is in self. 

 

EXAMPLES:: 

 

sage: Gamma1(4).is_regular_cusp(Cusps(1/2)) 

False 

sage: Gamma1(4).is_regular_cusp(Cusps(oo)) 

True 

""" 

if self.is_even(): return True 

return (self.cusp_data(c)[2] == 1) 

 

def cusp_width(self, c): 

r""" 

Return the width of the orbit of cusps represented by c. 

 

EXAMPLES:: 

 

sage: Gamma0(11).cusp_width(Cusps(oo)) 

1 

sage: Gamma0(11).cusp_width(0) 

11 

sage: [Gamma0(100).cusp_width(c) for c in Gamma0(100).cusps()] 

[100, 1, 4, 1, 1, 1, 4, 25, 1, 1, 4, 1, 25, 4, 1, 4, 1, 1] 

""" 

return self.cusp_data(c)[1] 

 

def index(self): 

r""" 

Return the index of self in the full modular group. 

 

EXAMPLES:: 

 

sage: Gamma0(17).index() 

18 

sage: sage.modular.arithgroup.congroup_generic.CongruenceSubgroup(5).index() 

Traceback (most recent call last): 

... 

NotImplementedError 

""" 

 

return len(list(self.coset_reps())) 

 

def generalised_level(self): 

r""" 

Return the generalised level of self, i.e. the least common multiple of 

the widths of all cusps. 

 

If self is *even*, Wohlfart's theorem tells us that this is equal to 

the (conventional) level of self when self is a congruence subgroup. 

This can fail if self is odd, but the actual level is at most twice the 

generalised level. See the paper by Kiming, Schuett and Verrill for 

more examples. 

 

EXAMPLES:: 

 

sage: Gamma0(18).generalised_level() 

18 

sage: sage.modular.arithgroup.arithgroup_perm.HsuExample18().generalised_level() 

24 

 

In the following example, the actual level is twice the generalised 

level. This is the group `G_2` from Example 17 of K-S-V. 

 

:: 

 

sage: G = CongruenceSubgroup(8, [ [1,1,0,1], [3,-1,4,-1] ]) 

sage: G.level() 

8 

sage: G.generalised_level() 

4 

""" 

return lcm([self.cusp_width(c) for c in self.cusps()]) 

 

def projective_index(self): 

r""" 

Return the index of the image of self in `{\rm PSL}_2(\ZZ)`. This is equal 

to the index of self if self contains -1, and half of this otherwise. 

 

This is equal to the degree of the natural map from the modular curve 

of self to the `j`-line. 

 

EXAMPLES:: 

 

sage: Gamma0(5).projective_index() 

6 

sage: Gamma1(5).projective_index() 

12 

""" 

 

if self.is_even(): 

return self.index() 

else: 

return self.index() // 2 

 

def is_congruence(self): 

r""" 

Return True if self is a congruence subgroup. 

 

EXAMPLES:: 

 

sage: Gamma0(5).is_congruence() 

True 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup().is_congruence() 

Traceback (most recent call last): 

... 

NotImplementedError 

""" 

 

raise NotImplementedError 

 

def genus(self): 

r""" 

Return the genus of the modular curve of self. 

 

EXAMPLES:: 

 

sage: Gamma1(5).genus() 

0 

sage: Gamma1(31).genus() 

26 

sage: Gamma1(157).genus() == dimension_cusp_forms(Gamma1(157), 2) 

True 

sage: GammaH(7, [2]).genus() 

0 

sage: [Gamma0(n).genus() for n in [1..23]] 

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 2, 2] 

sage: [n for n in [1..200] if Gamma0(n).genus() == 1] 

[11, 14, 15, 17, 19, 20, 21, 24, 27, 32, 36, 49] 

 

 

""" 

 

return ZZ(1 + (self.projective_index()) / ZZ(12) - (self.nu2())/ZZ(4) - (self.nu3())/ZZ(3) - self.ncusps()/ZZ(2)) 

 

def farey_symbol(self): 

r""" 

Return the Farey symbol associated to this subgroup. See the 

:mod:`~sage.modular.arithgroup.farey_symbol` module for more 

information. 

 

EXAMPLES:: 

 

sage: Gamma1(4).farey_symbol() 

FareySymbol(Congruence Subgroup Gamma1(4)) 

""" 

from .farey_symbol import Farey 

return Farey(self) 

 

@cached_method 

def generators(self, algorithm="farey"): 

r""" 

Return a list of generators for this congruence subgroup. The result is cached. 

 

INPUT: 

 

- ``algorithm`` (string): either ``farey`` or ``todd-coxeter``. 

 

If ``algorithm`` is set to ``"farey"``, then the generators will be 

calculated using Farey symbols, which will always return a *minimal* 

generating set. See :mod:`~sage.modular.arithgroup.farey_symbol` for 

more information. 

 

If ``algorithm`` is set to ``"todd-coxeter"``, a simpler algorithm 

based on Todd-Coxeter enumeration will be used. This is *exceedingly* 

slow for general subgroups, and the list of generators will be far from 

minimal (indeed it may contain repetitions). 

 

EXAMPLES:: 

 

sage: Gamma(2).generators() 

[ 

[1 2] [ 3 -2] [-1 0] 

[0 1], [ 2 -1], [ 0 -1] 

] 

sage: Gamma(2).generators(algorithm="todd-coxeter") 

[ 

[1 2] [-1 0] [ 1 0] [-1 0] [-1 2] [-1 0] [1 0] 

[0 1], [ 0 -1], [-2 1], [ 0 -1], [-2 3], [ 2 -1], [2 1] 

] 

""" 

if algorithm=="farey": 

return self.farey_symbol().generators() 

elif algorithm == "todd-coxeter": 

return self.todd_coxeter()[1] 

else: 

raise ValueError("Unknown algorithm '%s' (should be either 'farey' or 'todd-coxeter')" % algorithm) 

 

def gens(self, *args, **kwds): 

r""" 

Return a tuple of generators for this congruence subgroup. 

 

The generators need not be minimal. For arguments, see :meth:`~generators`. 

 

EXAMPLES:: 

 

sage: SL2Z.gens() 

( 

[ 0 -1] [1 1] 

[ 1 0], [0 1] 

) 

""" 

return tuple(self.generators(*args, **kwds)) 

 

def gen(self, i): 

r""" 

Return the i-th generator of self, i.e. the i-th element of the 

tuple self.gens(). 

 

EXAMPLES:: 

 

sage: SL2Z.gen(1) 

[1 1] 

[0 1] 

""" 

return self.generators()[i] 

 

def ngens(self): 

r""" 

Return the size of the minimal generating set of self returned by 

:meth:`generators`. 

 

EXAMPLES:: 

 

sage: Gamma0(22).ngens() 

8 

sage: Gamma1(14).ngens() 

13 

sage: GammaH(11, [3]).ngens() 

3 

sage: SL2Z.ngens() 

2 

""" 

return len(self.generators()) 

 

def ncusps(self): 

r""" 

Return the number of cusps of this arithmetic subgroup. This is 

provided as a separate function since for dimension formulae in even 

weight all we need to know is the number of cusps, and this can be 

calculated very quickly, while enumerating all cusps is much slower. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup.ncusps(Gamma0(7)) 

2 

""" 

 

return ZZ(len(self.cusps())) 

 

def nregcusps(self): 

r""" 

Return the number of cusps of self that are "regular", i.e. their 

stabiliser has a generator with both eigenvalues +1 rather than -1. If 

the group contains -1, every cusp is clearly regular. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup.nregcusps(Gamma1(4)) 

2 

""" 

return self.ncusps() - self.nirregcusps() 

 

def nirregcusps(self): 

r""" 

Return the number of cusps of self that are "irregular", i.e. their 

stabiliser can only be generated by elements with both eigenvalues -1 

rather than +1. If the group contains -1, every cusp is clearly 

regular. 

 

EXAMPLES:: 

 

sage: sage.modular.arithgroup.arithgroup_generic.ArithmeticSubgroup.nirregcusps(Gamma1(4)) 

1 

""" 

if self.is_even(): 

return 0 

else: 

return ZZ(len([c for c in self.cusps() if not self.is_regular_cusp(c)])) 

 

def dimension_modular_forms(self, k=2): 

r""" 

Return the dimension of the space of weight k modular forms for this 

group. This is given by a standard formula in terms of k and various 

invariants of the group; see Diamond + Shurman, "A First Course in 

Modular Forms", section 3.5 and 3.6. If k is not given, defaults to k = 

2. 

 

For dimensions of spaces of modular forms with character for Gamma1, use 

the standalone function dimension_modular_forms(). 

 

For weight 1 modular forms this function only works in cases where one 

can prove solely in terms of Riemann-Roch theory that there aren't any 

cusp forms (i.e. when the number of regular cusps is strictly greater 

than the degree of the canonical divisor). Otherwise a 

NotImplementedError is raised. 

 

EXAMPLES:: 

 

sage: Gamma1(31).dimension_modular_forms(2) 

55 

sage: Gamma1(3).dimension_modular_forms(1) 

1 

sage: Gamma1(4).dimension_modular_forms(1) # irregular cusp 

1 

sage: Gamma1(31).dimension_modular_forms(1) 

Traceback (most recent call last): 

... 

NotImplementedError: Computation of dimensions of weight 1 cusp forms spaces not implemented in general 

""" 

 

k = ZZ(k) 

if k < 0: return ZZ(0) 

if k == 0: return ZZ(1) 

 

if not (k % 2): 

# k even 

 

return (k-1) * (self.genus() - 1) + (k // ZZ(4))*self.nu2() + (k // ZZ(3))*self.nu3() + (k // ZZ(2))*self.ncusps() 

 

else: 

# k odd 

if self.is_even(): 

return ZZ(0) 

else: 

e_reg = self.nregcusps() 

e_irr = self.nirregcusps() 

 

if k > 1: 

return (k-1)*(self.genus()-1) + (k // ZZ(3)) * self.nu3() + (k * e_reg)/ZZ(2) + (k-1)/ZZ(2) * e_irr 

else: 

if e_reg > 2*self.genus() - 2: 

return e_reg / ZZ(2) 

else: 

raise NotImplementedError("Computation of dimensions of weight 1 modular forms spaces not implemented in general") 

 

def dimension_cusp_forms(self, k=2): 

r""" 

Return the dimension of the space of weight k cusp forms for this 

group. This is given by a standard formula in terms of k and various 

invariants of the group; see Diamond + Shurman, "A First Course in 

Modular Forms", section 3.5 and 3.6. If k is not given, default to k = 

2. 

 

For dimensions of spaces of cusp forms with character for Gamma1, use 

the standalone function dimension_cusp_forms(). 

 

For weight 1 cusp forms this function only works in cases where one can 

prove solely in terms of Riemann-Roch theory that there aren't any cusp 

forms (i.e. when the number of regular cusps is strictly greater than 

the degree of the canonical divisor). Otherwise a NotImplementedError is 

raised. 

 

EXAMPLES:: 

 

sage: Gamma1(31).dimension_cusp_forms(2) 

26 

sage: Gamma1(3).dimension_cusp_forms(1) 

0 

sage: Gamma1(4).dimension_cusp_forms(1) # irregular cusp 

0 

sage: Gamma1(31).dimension_cusp_forms(1) 

Traceback (most recent call last): 

... 

NotImplementedError: Computation of dimensions of weight 1 cusp forms spaces not implemented in general 

""" 

k = ZZ(k) 

if k <= 0: return ZZ(0) 

 

if not (k % 2): 

# k even 

 

if k == 2: 

return self.genus() 

 

else: 

return (k-1) * (self.genus() - 1) + (k // ZZ(4))*self.nu2() + (k // ZZ(3))*self.nu3() + (k // ZZ(2) - 1)*self.ncusps() 

 

else: 

# k odd 

 

if self.is_even(): 

return ZZ(0) 

 

else: 

e_reg = self.nregcusps() 

e_irr = self.nirregcusps() 

 

if k > 1: 

return (k-1)*(self.genus()-1) + (k // ZZ(3)) * self.nu3() + (k-2)/ZZ(2) * e_reg + (k-1)/ZZ(2) * e_irr 

else: 

if e_reg > 2*self.genus() - 2: 

return ZZ(0) 

else: 

raise NotImplementedError("Computation of dimensions of weight 1 cusp forms spaces not implemented in general") 

 

def dimension_eis(self, k=2): 

r""" 

Return the dimension of the space of weight k Eisenstein series for 

this group, which is a subspace of the space of modular forms 

complementary to the space of cusp forms. 

 

INPUT: 

 

- ``k`` - an integer (default 2). 

 

EXAMPLES:: 

 

sage: GammaH(33,[2]).dimension_eis() 

7 

sage: GammaH(33,[2]).dimension_eis(3) 

0 

sage: GammaH(33, [2,5]).dimension_eis(2) 

3 

sage: GammaH(33, [4]).dimension_eis(1) 

4 

""" 

 

if k < 0: return ZZ(0) 

if k == 0: return ZZ(1) 

 

if not (k % 2): # k even 

if k > 2: 

return self.ncusps() 

else: # k = 2 

return self.ncusps() - 1 

 

else: # k odd 

if self.is_even(): 

return 0 

if k > 1: 

return self.nregcusps() 

else: # k = 1 

return ZZ(self.nregcusps()/ ZZ(2)) 

 

def as_permutation_group(self): 

r""" 

Return self as an arithmetic subgroup defined in terms of the 

permutation action of `SL(2,\ZZ)` on its right cosets. 

 

This method uses Todd-Coxeter enumeration (via the method 

:meth:`~todd_coxeter`) which can be extremely slow for arithmetic 

subgroups with relatively large index in `SL(2,\ZZ)`. 

 

EXAMPLES:: 

 

sage: G = Gamma(3) 

sage: P = G.as_permutation_group(); P 

Arithmetic subgroup of index 24 

sage: G.ncusps() == P.ncusps() 

True 

sage: G.nu2() == P.nu2() 

True 

sage: G.nu3() == P.nu3() 

True 

sage: G.an_element() in P 

True 

sage: P.an_element() in G 

True 

""" 

_,_,l_edges,s2_edges=self.todd_coxeter() 

n = len(l_edges) 

s3_edges = [None] * n 

r_edges = [None] * n 

for i in range(n): 

ii = s2_edges[l_edges[i]] 

s3_edges[ii] = i 

r_edges[ii] = s2_edges[i] 

if self.is_even(): 

from sage.modular.arithgroup.arithgroup_perm import EvenArithmeticSubgroup_Permutation 

g=EvenArithmeticSubgroup_Permutation(S2=s2_edges,S3=s3_edges,L=l_edges,R=r_edges) 

else: 

from sage.modular.arithgroup.arithgroup_perm import OddArithmeticSubgroup_Permutation 

g=OddArithmeticSubgroup_Permutation(S2=s2_edges,S3=s3_edges,L=l_edges,R=r_edges) 

g.relabel() 

return g 

 

def sturm_bound(self, weight=2): 

r""" 

Returns the Sturm bound for modular forms of the given weight and level 

this subgroup. 

 

INPUT: 

 

- ``weight`` - an integer `\geq 2` (default: 2) 

 

EXAMPLES:: 

 

sage: Gamma0(11).sturm_bound(2) 

2 

sage: Gamma0(389).sturm_bound(2) 

65 

sage: Gamma0(1).sturm_bound(12) 

1 

sage: Gamma0(100).sturm_bound(2) 

30 

sage: Gamma0(1).sturm_bound(36) 

3 

sage: Gamma0(11).sturm_bound() 

2 

sage: Gamma0(13).sturm_bound() 

3 

sage: Gamma0(16).sturm_bound() 

4 

sage: GammaH(16,[13]).sturm_bound() 

8 

sage: GammaH(16,[15]).sturm_bound() 

16 

sage: Gamma1(16).sturm_bound() 

32 

sage: Gamma1(13).sturm_bound() 

28 

sage: Gamma1(13).sturm_bound(5) 

70 

 

FURTHER DETAILS: This function returns a positive integer 

`n` such that the Hecke operators 

`T_1,\ldots, T_n` acting on *cusp forms* generate the 

Hecke algebra as a `\ZZ`-module when the character 

is trivial or quadratic. Otherwise, `T_1,\ldots,T_n` 

generate the Hecke algebra at least as a 

`\ZZ[\varepsilon]`-module, where 

`\ZZ[\varepsilon]` is the ring generated by the 

values of the Dirichlet character `\varepsilon`. 

Alternatively, this is a bound such that if two cusp forms 

associated to this space of modular symbols are congruent modulo 

`(\lambda, q^n)`, then they are congruent modulo 

`\lambda`. 

 

REFERENCES: 

 

- See the Agashe-Stein appendix to Lario and Schoof, 

*Some computations with Hecke rings and deformation rings*, 

Experimental Math., 11 (2002), no. 2, 303-311. 

 

- This result originated in the paper Sturm, 

*On the congruence of modular forms*, 

Springer LNM 1240, 275-280, 1987. 

 

REMARK: Kevin Buzzard pointed out to me (William Stein) in Fall 

2002 that the above bound is fine for `\Gamma_1(N)` with 

character, as one sees by taking a power of `f`. More 

precisely, if `f \cong 0 \pmod{p}` for first 

`s` coefficients, then `f^r \cong 0 \pmod{p}` for 

first `sr` coefficients. Since the weight of `f^r` 

is `r\cdot k(f)`, it follows that if 

`s \geq b`, where `b` is the Sturm bound for 

`\Gamma_0(N)` at weight `k(f)`, then `f^r` 

has valuation large enough to be forced to be `0` at 

`r*k(f)` by Sturm bound (which is valid if we choose 

`r` correctly). Thus `f \cong 0 \pmod{p}`. 

Conclusion: For `\Gamma_1(N)` with fixed character, the 

Sturm bound is *exactly* the same as for `\Gamma_0(N)`. 

 

A key point is that we are finding 

`\ZZ[\varepsilon]` generators for the Hecke algebra 

here, not `\ZZ`-generators. So if one wants 

generators for the Hecke algebra over `\ZZ`, this 

bound must be suitably modified (and I'm not sure what the 

modification is). 

 

AUTHORS: 

 

- William Stein 

""" 

return ZZ((self.index() * weight / ZZ(12)).ceil())