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

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

1415

1416

1417

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1481

1482

1483

1484

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

1500

1501

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513

1514

1515

1516

1517

1518

1519

1520

1521

1522

1523

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

1539

1540

1541

1542

1543

1544

1545

1546

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1568

1569

1570

1571

1572

1573

1574

1575

1576

1577

1578

1579

1580

1581

1582

1583

1584

# -*- coding: utf-8 -*- 

r""" 

Manin Relations for overconvergent modular symbols 

 

Code to create the Manin Relations class, which solves the "Manin relations". 

That is, a description of `Div^0(P^1(\QQ))` as a `\ZZ[\Gamma_0(N)]`-module in 

terms of generators and relations is found. The method used is geometric, 

constructing a nice fundamental domain for `\Gamma_0(N)` and reading the 

relevant Manin relations off of that picture. The algorithm follows [PS2011]_. 

 

AUTHORS: 

 

- Robert Pollack, Jonathan Hanke (2012): initial version 

 

""" 

#***************************************************************************** 

# Copyright (C) 2012 Robert Pollack <rpollack@math.bu.edu> 

# Jonathan Hanke <jonhanke@gmail.com> 

# 

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

# as published by the Free Software Foundation; either version 2 of 

# the License, or (at your option) any later version. 

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

#***************************************************************************** 

from __future__ import print_function, absolute_import 

from six import iteritems 

 

from sage.matrix.matrix_space import MatrixSpace 

from sage.modular.modsym.all import P1List 

from sage.rings.integer import Integer 

from sage.rings.integer_ring import ZZ 

from sage.rings.rational_field import QQ 

from sage.structure.sage_object import SageObject 

from sage.misc.cachefunc import cached_method 

 

from .sigma0 import Sigma0 

 

M2ZSpace = MatrixSpace(ZZ,2) 

 

 

def M2Z(x): 

r""" 

Create an immutable `2 \times 2` integer matrix from ``x``. 

 

INPUT: anything that can be converted into a `2 \times 2` matrix. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import M2Z 

sage: M2Z([1,2,3,4]) 

[1 2] 

[3 4] 

sage: M2Z(1) 

[1 0] 

[0 1] 

""" 

x = M2ZSpace(x) 

x.set_immutable() 

return x 

 

Id = M2Z([1, 0, 0, 1]) 

sig = M2Z([0, 1, -1, 0]) 

tau = M2Z([0, -1, 1, -1]) 

minone_inf_path = M2Z([1, 1, -1, 0]) 

 

# We store these so that we do not have to constantly create them. 

t00 = (0, 0) 

t10 = (1, 0) 

t01 = (0, 1) 

t11 = (1, 1) 

 

 

class PollackStevensModularDomain(SageObject): 

r""" 

The domain of a modular symbol. 

 

INPUT: 

 

- ``N`` -- a positive integer, the level of the congruence subgroup 

`\Gamma_0(N)` 

 

- ``reps`` -- a list of `2 \times 2` matrices, the coset 

representatives of `Div^0(P^1(\QQ))` 

 

- ``indices`` -- a list of integers; indices of elements in 

``reps`` which are generators 

 

- ``rels`` -- a list of list of triples ``(d, A, i)``, one for each 

coset representative of ``reps`` which describes how to express the 

elements of ``reps`` in terms of generators specified by ``indices``. 

See :meth:`relations` for a detailed explanations of these triples. 

 

- ``equiv_ind`` -- a dictionary which maps normalized coordinates on 

`P^1(\ZZ/N\ZZ)` to an integer such that a matrix whose bottom row is 

equivalent to `[a:b]` in `P^1(\ZZ/N\ZZ)` is in the coset of 

``reps[equiv_ind[(a,b)]]`` 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import PollackStevensModularDomain, M2Z 

sage: PollackStevensModularDomain(2 , [M2Z([1,0,0,1]), M2Z([1,1,-1,0]), M2Z([0,-1,1,1])], [0,2], [[(1, M2Z([1,0,0,1]), 0)], [(-1,M2Z([-1,-1,0,-1]),0)], [(1, M2Z([1,0,0,1]), 2)]], {(0,1): 0, (1,0): 1, (1,1): 2}) 

Modular Symbol domain of level 2 

 

TESTS: 

 

The level ``N`` must be an integer:: 

 

sage: PollackStevensModularDomain(1/2, None, None, None, None) 

Traceback (most recent call last): 

... 

TypeError: no conversion of this rational to integer 

sage: PollackStevensModularDomain(Gamma0(11), None, None, None, None) 

Traceback (most recent call last): 

... 

TypeError: unable to coerce <class 'sage.modular.arithgroup.congroup_gamma0.Gamma0_class_with_category'> to an integer 

 

""" 

def __init__(self, N, reps, indices, rels, equiv_ind): 

r""" 

INPUT: 

 

See :class:`PollackStevensModularDomain`. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import PollackStevensModularDomain, ManinRelations 

sage: isinstance(ManinRelations(11), PollackStevensModularDomain) # indirect doctest 

True 

""" 

self._N = ZZ(N) 

self._reps = reps 

 

self._indices = sorted(indices) 

self._gens = [M2Z(reps[i]) for i in self._indices] 

self._ngens = len(indices) 

 

if len(rels) != len(reps): 

raise ValueError("length of reps and length of rels must be equal") 

self._rels = rels 

self._rel_dict = {} 

for j, L in enumerate(rels): 

self._rel_dict[reps[j]] = L 

 

self._equiv_ind = equiv_ind 

self._equiv_rep = {} 

for ky in equiv_ind: 

self._equiv_rep[ky] = reps[equiv_ind[ky]] 

 

def _repr_(self): 

r""" 

A string representation of this domain. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import PollackStevensModularDomain, M2Z 

sage: PollackStevensModularDomain(2 , [M2Z([1,0,0,1]), M2Z([1,1,-1,0]), M2Z([0,-1,1,1])], [0,2], [[(1, M2Z([1,0,0,1]), 0)], [(-1,M2Z([-1,-1,0,-1]),0)], [(1, M2Z([1,0,0,1]), 2)]], {(0,1): 0, (1,0): 1, (1,1): 2})._repr_() 

'Modular Symbol domain of level 2' 

""" 

return "Modular Symbol domain of level %s" % self._N 

 

def __len__(self): 

r""" 

Return the number of coset representatives. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: len(A) 

12 

""" 

return len(self._reps) 

 

def __getitem__(self, i): 

r""" 

Return the ``i``-th coset representative. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A[4] 

[-1 -2] 

[ 2 3] 

""" 

return self._reps[i] 

 

def __iter__(self): 

r""" 

Return an iterator over all coset representatives. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: for rep in A: 

....: if rep[1,0] == 1: 

....: print(rep) 

[ 0 -1] 

[ 1 3] 

[ 0 -1] 

[ 1 2] 

[ 0 -1] 

[ 1 1] 

""" 

return iter(self._reps) 

 

def gens(self): 

r""" 

Return the list of coset representatives chosen as generators. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A.gens() 

[ 

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

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

] 

""" 

return self._gens 

 

def gen(self, n=0): 

r""" 

Return the ``n``-th generator. 

 

INPUT: 

 

- ``n`` -- integer (default: 0), which generator is desired 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(137) 

sage: A.gen(17) 

[-4 -1] 

[ 9 2] 

""" 

return self._gens[n] 

 

def ngens(self): 

r""" 

Return the number of generators. 

 

OUTPUT: 

 

The number of coset representatives from which a modular symbol's value 

on any coset can be derived. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(1137) 

sage: A.ngens() 

255 

""" 

return len(self._gens) 

 

def level(self): 

r""" 

Return the level `N` of `\Gamma_0(N)` that we work with. 

 

OUTPUT: 

 

The integer `N` of the group `\Gamma_0(N)` for which the Manin 

Relations are being computed. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A.level() 

11 

""" 

return self._N 

 

def indices(self, n=None): 

r""" 

Return the `n`-th index of the coset representatives which were 

chosen as our generators. 

 

In particular, the divisors associated to these coset representatives 

generate all divisors over `\ZZ[\Gamma_0(N)]`, and thus a modular 

symbol is uniquely determined by its values on these divisors. 

 

INPUT: 

 

- ``n`` -- integer (default: None) 

 

OUTPUT: 

 

The ``n``-th index of the generating set in ``self.reps()`` or all 

indices if ``n`` is ``None``. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A.indices() 

[0, 2, 3] 

 

sage: A.indices(2) 

3 

 

sage: A = ManinRelations(13) 

sage: A.indices() 

[0, 2, 3, 4, 5] 

 

sage: A = ManinRelations(101) 

sage: A.indices() 

[0, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 16, 17, 19, 20, 23, 24, 26, 28] 

""" 

if n is None: 

return self._indices 

else: 

return self._indices[n] 

 

def reps(self, n=None): 

r""" 

Return the ``n``-th coset representative associated with our 

fundamental domain. 

 

INPUT: 

 

- ``n`` -- integer (default: None) 

 

OUTPUT: 

 

The ``n``-th coset representative or all coset representatives if ``n`` 

is ``None``. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A.reps(0) 

[1 0] 

[0 1] 

sage: A.reps(1) 

[ 1 1] 

[-1 0] 

sage: A.reps(2) 

[ 0 -1] 

[ 1 3] 

sage: A.reps() 

[ 

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

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

<BLANKLINE> 

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

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

] 

""" 

if n is None: 

return self._reps 

else: 

return self._reps[n] 

 

def relations(self, A=None): 

r""" 

Express the divisor attached to the coset representative of ``A`` in 

terms of our chosen generators. 

 

INPUT: 

 

- ``A`` -- ``None``, an integer, or a coset representative (default: 

``None``) 

 

OUTPUT: 

 

A `\ZZ[\Gamma_0(N)]`-relation expressing the divisor attached to ``A`` 

in terms of the generating set. The relation is given as a list of 

triples ``(d, B, i)`` such that the divisor attached to `A`` is the sum 

of ``d`` times the divisor attached to ``B^{-1} * self.reps(i)``. 

 

If ``A`` is an integer, then return this data for the ``A``-th 

coset representative. 

 

If ``A`` is ``None``, then return this data in a list for all coset 

representatives. 

 

.. NOTE:: 

 

These relations allow us to recover the value of a modular symbol 

on any coset representative in terms of its values on our 

generating set. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: MR = ManinRelations(11) 

sage: MR.indices() 

[0, 2, 3] 

sage: MR.relations(0) 

[(1, [1 0] 

[0 1], 0)] 

sage: MR.relations(2) 

[(1, [1 0] 

[0 1], 2)] 

sage: MR.relations(3) 

[(1, [1 0] 

[0 1], 3)] 

 

The fourth coset representative can be expressed through the 

second coset representative:: 

 

sage: MR.reps(4) 

[-1 -2] 

[ 2 3] 

sage: d, B, i = MR.relations(4)[0] 

sage: P = B.inverse()*MR.reps(i); P 

[ 2 -1] 

[-3 2] 

sage: d # the above corresponds to minus the divisor of A.reps(4) since d is -1 

-1 

 

The sixth coset representative can be expressed as the sum of 

the second and the third:: 

 

sage: MR.reps(6) 

[ 0 -1] 

[ 1 2] 

sage: MR.relations(6) 

[(1, [1 0] 

[0 1], 2), (1, [1 0] 

[0 1], 3)] 

sage: MR.reps(2), MR.reps(3) # MR.reps(6) is the sum of these divisors 

( 

[ 0 -1] [-1 -1] 

[ 1 3], [ 3 2] 

) 

 

TESTS: 

 

Test that the other ways of calling this method work:: 

 

sage: MR.relations(MR.reps(6)) 

[(1, [1 0] 

[0 1], 2), (1, [1 0] 

[0 1], 3)] 

sage: MR.relations(None) 

[[(1, [1 0] 

[0 1], 0)], [(-1, [-1 -1] 

[ 0 -1], 0)], [(1, [1 0] 

[0 1], 2)], [(1, [1 0] 

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

[11 7], 2)], [(-1, [-4 -3] 

[11 8], 3)], [(1, [1 0] 

[0 1], 2), (1, [1 0] 

[0 1], 3)], [(-1, [1 0] 

[0 1], 2), (-1, [1 0] 

[0 1], 3)], [(1, [1 0] 

[0 1], 2), (1, [1 0] 

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

[11 7], 2), (-1, [-4 -3] 

[11 8], 3)], [(-1, [1 0] 

[0 1], 2), (-1, [1 0] 

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

[11 7], 2), (1, [-4 -3] 

[11 8], 3)], [(-1, [-3 -2] 

[11 7], 2), (-1, [-4 -3] 

[11 8], 3)], [(1, [-3 -2] 

[11 7], 2), (1, [-4 -3] 

[11 8], 3)]] 

""" 

if A is None: 

return self._rels 

elif isinstance(A, (int, Integer, slice)): 

return self._rels[A] 

else: 

return self._rel_dict[A] 

 

def equivalent_index(self, A): 

r""" 

Return the index of the coset representative equivalent to ``A``. 

 

Here by equivalent we mean the unique coset representative whose bottom 

row is equivalent to the bottom row of ``A`` in `P^1(\ZZ/N\ZZ)`. 

 

INPUT: 

 

- ``A`` -- an element of `SL_2(\ZZ)` 

 

OUTPUT: 

 

The unique integer ``j`` satisfying that the bottom row of 

``self.reps(j)`` is equivalent to the bottom row of ``A``. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: MR = ManinRelations(11) 

sage: A = matrix(ZZ,2,2,[1,5,3,16]) 

sage: j = MR.equivalent_index(A); j 

11 

sage: MR.reps(11) 

[ 1 -1] 

[-1 2] 

sage: MR.equivalent_rep(A) 

[ 1 -1] 

[-1 2] 

sage: MR.P1().normalize(3,16) 

(1, 9) 

""" 

return self._equiv_ind[self._P.normalize(A[t10], A[t11])] 

 

def equivalent_rep(self, A): 

r""" 

Return a coset representative that is equivalent to ``A`` modulo 

`\Gamma_0(N)`. 

 

INPUT: 

 

- ``A`` -- a matrix in `SL_2(\ZZ)` 

 

OUTPUT: 

 

The unique generator congruent to ``A`` modulo `\Gamma_0(N)`. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = matrix([[5,3],[38,23]]) 

sage: ManinRelations(60).equivalent_rep(A) 

[-7 -3] 

[26 11] 

""" 

return self._reps[self.equivalent_index(A)] 

 

def P1(self): 

r""" 

Return the Sage representation of `P^1(\ZZ/N\ZZ)`. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A.P1() 

The projective line over the integers modulo 11 

 

""" 

return self._P 

 

 

class ManinRelations(PollackStevensModularDomain): 

r""" 

This class gives a description of `Div^0(P^1(\QQ))` as a 

`\ZZ[\Gamma_0(N)]`-module. 

 

INPUT: 

 

- ``N`` -- a positive integer, the level of `\Gamma_0(N)` to work with 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: ManinRelations(1) 

Manin Relations of level 1 

sage: ManinRelations(11) 

Manin Relations of level 11 

 

Large values of ``N`` are not supported:: 

 

sage: ManinRelations(2^20) 

Traceback (most recent call last): 

... 

OverflowError: Modulus is too large (must be <= 46340) 

 

TESTS: 

 

``N`` has to be a positive integer:: 

 

sage: ManinRelations(0) 

Traceback (most recent call last): 

... 

ValueError: N must be a positive integer 

sage: ManinRelations(-5) 

Traceback (most recent call last): 

... 

ValueError: N must be a positive integer 

 

""" 

def __init__(self, N): 

r""" 

Create an instance of this class. 

 

INPUT: 

 

- ``N`` -- a positive integer, the level of `\Gamma_0(N)` to work with 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: type(ManinRelations(30)) 

<class 'sage.modular.pollack_stevens.fund_domain.ManinRelations'> 

""" 

N = ZZ(N) 

if N <= 0: 

raise ValueError("N must be a positive integer") 

self._N = N 

SN = Sigma0(N) 

 

## Creates and stores the Sage representation of P^1(Z/NZ) 

P = P1List(N) 

self._P = P 

IdN = SN([1, 0, 0, 1]) 

 

## Creates a fundamental domain for Gamma_0(N) whose boundary 

## is a union of unimodular paths (except in the case of 

## 3-torsion). We will call the intersection of this domain 

## with the real axis the collection of cusps (even if some 

## are Gamma_0(N) equivalent to one another). 

cusps = self.form_list_of_cusps() 

 

## Takes the boundary of this fundamental domain and finds 

## SL_2(Z) matrices whose associated unimodular path gives 

## this boundary. These matrices form the beginning of our 

## collection of coset reps for Gamma_0(N) / SL_2(Z). 

coset_reps = self.fd_boundary(cusps) 

 

## Takes the bottom row of each of our current coset reps, 

## thinking of them as distinct elements of P^1(Z/NZ) 

p1s = [(coset_reps[j])[1] for j in range(len(coset_reps))] 

 

## Initializes relevant Manin data 

gens_index = [] 

twotor_index = [] 

twotorrels = [] 

threetor_index = [] 

threetorrels = [] 

rels = [0] * len(coset_reps) 

gammas = {} 

 

## the list rels (above) will give Z[Gamma_0(N)] relations between 

## the associated divisor of each coset representatives in terms 

## of our chosen set of generators. 

## entries of rels will be lists of elements of the form (c,A,r) 

## with c a constant, A a Gamma_0(N) matrix, and r the index of a 

## generator. The meaning is that the divisor associated to the 

## j-th coset rep will equal the sum of: 

## 

## c * A^(-1) * (divisor associated to r-th coset rep) 

## 

## as one varies over all (c,A,r) in rels[j]. 

## (Here r must be in self.generator_indices().) 

## 

## This will be used for modular symbols as then the value of a 

## modular symbol phi on the (associated divisor) of the j-th 

## element of coset_reps will be the sum of c * phi (r-th generator) | A 

## as one varies over the tuples in rels[j] 

 

boundary_checked = [False] * len(coset_reps) 

 

## The list boundary_checked keeps track of which boundary pieces of the 

## fundamental domain have been already used as we are picking 

## our generators 

 

## The following loop will choose our generators by picking one edge 

## out of each pair of edges that are glued to each other and picking 

## each edge glued to itself (arising from two-torsion) 

## ------------------------------------------------------------------ 

for r in range(len(coset_reps)): 

if not boundary_checked[r]: 

 

## We now check if this boundary edge is glued to itself by 

## Gamma_0(N) 

 

if P.normalize(p1s[r][0], p1s[r][1]) == P.normalize(-p1s[r][1], p1s[r][0]): 

## This edge is glued to itself and so coset_reps[r] 

## needs to be added to our generator list. 

 

## this relation expresses the fact that 

## coset_reps[r] is one of our basic generators 

rels[r] = [(1, IdN, r)] 

 

## the index r is adding to our list 

## of indexes of generators 

gens_index.append(r) 

 

## the index r is adding to our list of indexes of 

## generators which satisfy a 2-torsion relation 

twotor_index.append(r) 

 

# we use the adjoint instead of the inverse for speed 

gam = SN(coset_reps[r] * sig * coset_reps[r].adjoint()) 

## gam is 2-torsion matrix and in Gamma_0(N). 

## if D is the divisor associated to coset_reps[r] 

## then gam * D = - D and so (1+gam)D=0. 

 

## This gives a restriction to the possible values of 

## modular symbols on D 

 

## The 2-torsion matrix gam is recorded in our list of 

## 2-torsion relations. 

twotorrels.append(gam) 

 

## We have now finished with this edge. 

boundary_checked[r] = True 

 

else: 

c = coset_reps[r][t10] 

d = coset_reps[r][t11] 

 

## In the following case the ideal triangle below 

## the unimodular path described by coset_reps[r] 

## contains a point fixed by a 3-torsion element. 

if (c ** 2 + d ** 2 + c * d) % N == 0: 

 

## the index r is adding to our list of indexes 

## of generators 

gens_index.append(r) 

 

## this relation expresses the fact that coset_reps[r] 

## is one of our basic generators 

rels[r] = [(1, IdN, r)] 

 

## the index r is adding to our list of indexes of 

## generators which satisfy a 3-torsion relation 

threetor_index.append(r) 

 

# Use the adjoint instead of the inverse for speed. 

gam = SN(coset_reps[r] * tau * coset_reps[r].adjoint()) 

## gam is 3-torsion matrix and in Gamma_0(N). 

## if D is the divisor associated to coset_reps[r] 

## then (1+gam+gam^2)D=0. 

## This gives a restriction to the possible values of 

## modular symbols on D 

 

## The 3-torsion matrix gam is recorded in our list of 

## 3-torsion relations. 

threetorrels.append(gam) 

 

## The reverse of the unimodular path associated to 

## coset_reps[r] is not Gamma_0(N) equivalent to it, so 

## we need to include it in our list of coset 

## representatives and record the relevant relations. 

 

a = coset_reps[r][t00] 

b = coset_reps[r][t01] 

 

A = M2Z([-b, a, -d, c]) 

coset_reps.append(A) 

## A (representing the reversed edge) is included in 

## our list of coset reps 

 

rels.append([(-1, IdN, r)]) 

## This relation means that phi on the reversed edge 

## equals -phi on original edge 

 

boundary_checked[r] = True 

## We have now finished with this edge. 

 

else: 

## This is the generic case where neither 2 or 

## 3-torsion intervenes. 

## The below loop searches through the remaining edges 

## and finds which one is equivalent to the reverse of 

## coset_reps[r] 

## --------------------------------------------------- 

for s in range(r + 1, len(coset_reps)): 

if boundary_checked[s]: 

continue 

if P.normalize(p1s[s][0], p1s[s][1]) == P.normalize(-p1s[r][1], p1s[r][0]): 

## the reverse of coset_reps[r] is 

## Gamma_0(N)-equivalent to coset_reps[s] 

## coset_reps[r] will now be made a generator 

## and we need to express phi(coset_reps[s]) 

## in terms of phi(coset_reps[r]) 

 

gens_index.append(r) 

## the index r is adding to our list of 

## indexes of generators 

 

rels[r] = [(1, IdN, r)] 

## this relation expresses the fact that 

## coset_reps[r] is one of our basic generators 

 

A = coset_reps[s] * sig 

## A corresponds to reversing the orientation 

## of the edge corr. to coset_reps[r] 

# Use adjoint instead of inverse for speed 

gam = SN(coset_reps[r] * A.adjoint()) 

## gam is in Gamma_0(N) (by assumption of 

## ending up here in this if statement) 

 

rels[s] = [(-1, gam, r)] 

## this relation means that phi evaluated on 

## coset_reps[s] equals -phi(coset_reps[r])|gam 

## To see this, let D_r be the divisor 

## associated to coset_reps[r] and D_s to 

## coset_reps[s]. Then gam D_s = -D_r and so 

## phi(gam D_s) = - phi(D_r) and thus 

## phi(D_s) = -phi(D_r)|gam 

## since gam is in Gamma_0(N) 

 

gammas[coset_reps[r]] = gam 

## this is a dictionary whose keys are the 

## non-torsion generators and whose values 

## are the corresponding gamma_i. It is 

## eventually stored as self.gammas. 

 

boundary_checked[r] = True 

boundary_checked[s] = True 

break 

 

## We now need to complete our list of coset representatives by 

## finding all unimodular paths in the interior of the fundamental 

## domain, as well as express these paths in terms of our chosen set 

## of generators. 

## ------------------------------------------------------------------- 

 

for r in range(len(cusps) - 2): 

## r is the index of the cusp on the left of the path. We only run 

## thru to the number of cusps - 2 since you cannot start an 

## interior path on either of the last two cusps 

 

for s in range(r + 2, len(cusps)): 

## s is in the index of the cusp on the right of the path 

cusp1 = cusps[r] 

cusp2 = cusps[s] 

if self.is_unimodular_path(cusp1, cusp2): 

A, B = self.unimod_to_matrices(cusp1, cusp2) 

## A and B are the matrices whose associated paths 

## connect cusp1 to cusp2 and cusp2 to cusp1 (respectively) 

coset_reps.extend([A, B]) 

## A and B are added to our coset reps 

vA = [] 

vB = [] 

 

## This loop now encodes the relation between the 

## unimodular path A and our generators. This is done 

## simply by accounting for all of the edges that lie 

## below the path attached to A (as they form a triangle) 

## Similarly, this is also done for B. 

 

## Running between the cusps between cusp1 and cusp2 

for rel in rels[r + 2: s + 2]: 

## Add edge relation 

vA.append(rel[0]) 

## Add negative of edge relation 

vB.append((-rel[0][0], rel[0][1], rel[0][2])) 

## Add relations for A and B to relations list 

rels.extend([vA, vB]) 

 

## Make the translation table between the Sage and Geometric 

## descriptions of P^1 

equiv_ind = {} 

for i, rep in enumerate(coset_reps): 

ky = P.normalize(rep[t10], rep[t11]) 

equiv_ind[ky] = i 

 

self.gammas = gammas 

PollackStevensModularDomain.__init__(self, N, coset_reps, gens_index, 

rels, equiv_ind) 

 

## A list of indices of the (geometric) coset representatives whose 

## paths are identified by some 2-torsion element (which switches the 

## path orientation) 

self._indices_with_two_torsion = twotor_index 

self._reps_with_two_torsion = [coset_reps[i] for i in twotor_index] 

 

## A dictionary of (2-torsion in PSL_2(Z)) matrices in 

## Gamma_0(N) that give the orientation identification in the 

## paths listed in twotor_index above! 

self._two_torsion = {} 

for j, tor_elt in zip(twotor_index, twotorrels): 

self._two_torsion[coset_reps[j]] = tor_elt 

 

## A list of indices of the (geometric) coset representatives that 

## form one side of an ideal triangle with an interior fixed point of 

## a 3-torsion element of Gamma_0(N) 

self._indices_with_three_torsion = threetor_index 

self._reps_with_three_torsion = [coset_reps[i] for i in threetor_index] 

 

## A dictionary of (3-torsion in PSL_2(Z)) matrices in 

## Gamma_0(N) that give the interior fixed point described in 

## threetor_index above! 

self._three_torsion = {} 

for j, tor_elt in zip(threetor_index, threetorrels): 

self._three_torsion[coset_reps[j]] = tor_elt 

 

def _repr_(self): 

r""" 

A printable representation of this domain. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: ManinRelations(11)._repr_() 

'Manin Relations of level 11' 

""" 

return "Manin Relations of level %s" % self._N 

 

def indices_with_two_torsion(self): 

r""" 

Return the indices of coset representatives whose associated unimodular path 

contains a point fixed by a `\Gamma_0(N)` element of order 2 (where the 

order is computed in `PSL_2(\ZZ)`). 

 

OUTPUT: 

 

A list of integers. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: MR = ManinRelations(11) 

sage: MR.indices_with_two_torsion() 

[] 

sage: MR = ManinRelations(13) 

sage: MR.indices_with_two_torsion() 

[3, 4] 

sage: MR.reps(3), MR.reps(4) 

( 

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

[ 3 2], [ 2 3] 

) 

 

The corresponding matrix of order 2:: 

 

sage: A = MR.two_torsion_matrix(MR.reps(3)); A 

[ 5 2] 

[-13 -5] 

sage: A^2 

[-1 0] 

[ 0 -1] 

 

You can see that multiplication by ``A`` just interchanges the rational 

cusps determined by the columns of the matrix ``MR.reps(3)``:: 

 

sage: MR.reps(3), A*MR.reps(3) 

( 

[-1 -1] [ 1 -1] 

[ 3 2], [-2 3] 

) 

""" 

return self._indices_with_two_torsion 

 

def reps_with_two_torsion(self): 

r""" 

The coset representatives whose associated unimodular path contains a 

point fixed by a `\Gamma_0(N)` element of order 2 (where the order is 

computed in `PSL_2(\ZZ)`). 

 

OUTPUT: 

 

A list of matrices. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: MR = ManinRelations(11) 

sage: MR.reps_with_two_torsion() 

[] 

sage: MR = ManinRelations(13) 

sage: MR.reps_with_two_torsion() 

[ 

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

[ 3 2], [ 2 3] 

] 

sage: B = MR.reps_with_two_torsion()[0] 

 

The corresponding matrix of order 2:: 

 

sage: A = MR.two_torsion_matrix(B); A 

[ 5 2] 

[-13 -5] 

sage: A^2 

[-1 0] 

[ 0 -1] 

 

You can see that multiplication by ``A`` just interchanges the rational 

cusps determined by the columns of the matrix ``MR.reps(3)``:: 

 

sage: B, A*B 

( 

[-1 -1] [ 1 -1] 

[ 3 2], [-2 3] 

) 

""" 

return self._reps_with_two_torsion 

 

def two_torsion_matrix(self, A): 

r""" 

Return the matrix of order two in `\Gamma_0(N)` which 

corresponds to an ``A`` in ``self.reps_with_two_torsion()``. 

 

INPUT: 

 

- ``A`` -- a matrix in ``self.reps_with_two_torsion()`` 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: MR = ManinRelations(25) 

sage: B = MR.reps_with_two_torsion()[0] 

 

The corresponding matrix of order 2:: 

 

sage: A = MR.two_torsion_matrix(B); A 

[ 7 2] 

[-25 -7] 

sage: A^2 

[-1 0] 

[ 0 -1] 

""" 

return self._two_torsion[A] 

 

def indices_with_three_torsion(self): 

r""" 

A list of indices of coset representatives whose associated unimodular 

path contains a point fixed by a `\Gamma_0(N)` element of order 3 in 

the ideal triangle directly below that path (the order is computed in 

`PSL_2(\ZZ)`). 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: MR = ManinRelations(11) 

sage: MR.indices_with_three_torsion() 

[] 

sage: MR = ManinRelations(13) 

sage: MR.indices_with_three_torsion() 

[2, 5] 

sage: B = MR.reps(2); B 

[ 0 -1] 

[ 1 3] 

 

The corresponding matrix of order three:: 

 

sage: A = MR.three_torsion_matrix(B); A 

[-4 -1] 

[13 3] 

sage: A^3 

[1 0] 

[0 1] 

 

The columns of ``B`` and the columns of ``A*B`` and ``A^2*B`` give the 

same rational cusps:: 

 

sage: B 

[ 0 -1] 

[ 1 3] 

sage: A*B, A^2*B 

( 

[-1 1] [ 1 0] 

[ 3 -4], [-4 1] 

) 

""" 

return self._indices_with_three_torsion 

 

def reps_with_three_torsion(self): 

r""" 

A list of coset representatives whose associated unimodular 

path contains a point fixed by a `\Gamma_0(N)` element of 

order 3 in the ideal triangle directly below that path (the 

order is computed in `PSL_2(\ZZ)`). 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: MR = ManinRelations(13) 

sage: B = MR.reps_with_three_torsion()[0]; B 

[ 0 -1] 

[ 1 3] 

 

The corresponding matrix of order three:: 

 

sage: A = MR.three_torsion_matrix(B); A 

[-4 -1] 

[13 3] 

sage: A^3 

[1 0] 

[0 1] 

 

The columns of ``B`` and the columns of ``A*B`` and ``A^2*B`` 

give the same rational cusps:: 

 

sage: B 

[ 0 -1] 

[ 1 3] 

sage: A*B, A^2*B 

( 

[-1 1] [ 1 0] 

[ 3 -4], [-4 1] 

) 

""" 

return self._reps_with_three_torsion 

 

def three_torsion_matrix(self, A): 

r""" 

Return the matrix of order two in `\Gamma_0(N)` which 

corresponds to an ``A`` in ``self.reps_with_two_torsion()``. 

 

INPUT: 

 

- ``A`` -- a matrix in ``self.reps_with_two_torsion()`` 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: MR = ManinRelations(37) 

sage: B = MR.reps_with_three_torsion()[0] 

 

The corresponding matrix of order 3:: 

 

sage: A = MR.three_torsion_matrix(B); A 

[-11 -3] 

[ 37 10] 

sage: A^3 

[1 0] 

[0 1] 

""" 

return self._three_torsion[A] 

 

def form_list_of_cusps(self): 

r""" 

Return the intersection of a fundamental domain for `\Gamma_0(N)` with 

the real axis. 

 

The construction of this fundamental domain follows the arguments of 

[PS2011]_ Section 2. The boundary of this fundamental domain consists 

entirely of unimodular paths when `\Gamma_0(N)` has no elements of 

order 3. (See [PS2011]_ Section 2.5 for the case when there are 

elements of order 3.) 

 

OUTPUT: 

 

A sorted list of rational numbers marking the intersection of a 

fundamental domain for `\Gamma_0(N)` with the real axis. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A.form_list_of_cusps() 

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

sage: A = ManinRelations(13) 

sage: A.form_list_of_cusps() 

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

sage: A = ManinRelations(101) 

sage: A.form_list_of_cusps() 

[-1, -6/7, -5/6, -4/5, -7/9, -3/4, -11/15, -8/11, -5/7, -7/10, 

-9/13, -2/3, -5/8, -13/21, -8/13, -3/5, -7/12, -11/19, -4/7, -1/2, 

-4/9, -3/7, -5/12, -7/17, -2/5, -3/8, -4/11, -1/3, -2/7, -3/11, 

-1/4, -2/9, -1/5, -1/6, 0] 

""" 

## Get the level 

N = self.level() 

 

## Some convenient shortcuts 

P = self.P1() 

sP = len(P.list()) # Size of P^1(Z/NZ) 

 

## Initialize some lists 

 

C = [QQ(-1), "?", QQ(0)] 

 

## Initialize the list of cusps at the bottom of the fund. domain. 

## The ? denotes that it has not yet been checked if more cusps need 

## to be added between the surrounding cusps. 

 

full_domain = False # Says that we are not done yet! 

 

v = [False for r in range(sP)] 

## This initializes a list indexed by P^1(Z/NZ) which keeps track of 

## which right coset representatives we've found for Gamma_0(N)/SL_2(Z) 

## thru the construction of a fundamental domain 

 

## Includeds the coset repns formed by the original ideal triangle 

## (with corners at -1, 0, infty) 

 

v[P.index(0, 1)] = True 

v[P.index(1, -1)] = True 

v[P.index(-1, 0)] = True 

 

## Main Loop -- Ideal Triangle Flipping 

## ==================================== 

while (not full_domain): 

full_domain = True 

 

## This loop runs through the current set of cusps 

## and checks to see if more cusps should be added 

## ----------------------------------------------- 

for s in range(1, len(C), 2): # range over odd indices in the 

# final list C 

if C[s] == "?": 

 

## Single out our two cusps (path from cusp2 to cusp1) 

cusp1 = C[s - 1] 

cusp2 = C[s + 1] 

 

## Makes the unimodular transform for the path from cusp2 

## to cusp1 

 

b1 = cusp1.denominator() 

b2 = cusp2.denominator() 

 

## This is the point where it is determined whether 

## or not the adjacent triangle should be added 

## ------------------------------------------------ 

pos = P.index(b2, b1) # The Sage index of the bottom 

## row of our unimodular 

## transformation gam 

 

## Check if we need to flip (since this P1 element has not 

## yet been accounted for!) 

if not v[pos]: 

v[pos] = True # Say this P1 element now occurs 

v[P.index(b1, -(b1 + b2))] = True 

## Say that the other two ideal triangle edges 

## also occur! 

 

v[P.index(-(b1 + b2), b2)] = True 

 

## Check to see if this triangle contains a fixed 

## point by an element of Gamma_0(N). If such an 

## element is present, the fundamental domain can be 

## extended no further. 

 

if (b1 ** 2 + b2 ** 2 + b1 * b2) % N != 0: 

 

## this congruence is exactly equivalent to 

## gam * [0 -1; 1 -1] * gam^(-1) is in Gamma_0(N) 

## where gam is the matrix corresponding to the 

## unimodular path connecting cusp1 to cusp2 

 

C[s] = "i" # The '?' is changed to an 'i' 

## indicating that a new cusp needs to 

## be inserted here 

full_domain = False 

else: 

C[s] = "x" # The '?' is changed to an 'x' and no 

# more checking below is needed! =) 

else: 

C[s] = "x" # The '?' is changed to an 'x' and no more 

## checking below is needed! =) 

 

## Now insert the missing cusps (where there is an 'i' in 

## the final list) 

## This will keep the fundamental domain as flat as possible! 

## --------------------------------------------------------------- 

s = 1 

while s < len(C): # range over odd indices in the final list C 

if C[s] == "i": 

C[s] = "?" 

 

## Single out our two cusps (path from cusp2 to cusp1) 

cusp1 = C[s - 1] 

cusp2 = C[s + 1] 

 

## Makes the unimodular transform for the path 

## from cusp2 to cusp1 

a1 = cusp1.numerator() 

b1 = cusp1.denominator() 

a2 = cusp2.numerator() 

b2 = cusp2.denominator() 

 

## Inserts the Farey center of these two cusps! 

a = a1 + a2 

b = b1 + b2 

C.insert(s + 1, a / b) 

C.insert(s + 2, "?") 

s += 2 

s += 2 

 

## Remove the (now superfluous) extra string characters that appear 

## in the odd list entries 

C = [QQ(C[ss]) for ss in range(0, len(C), 2)] 

return C 

 

def is_unimodular_path(self, r1, r2): 

r""" 

Determine whether two (non-infinite) cusps are connected by a 

unimodular path. 

 

INPUT: 

 

- ``r1, r2`` -- rational numbers 

 

OUTPUT: 

 

A boolean expressing whether or not a unimodular path connects ``r1`` 

to ``r2``. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A.is_unimodular_path(0,1/3) 

True 

sage: A.is_unimodular_path(1/3,0) 

True 

sage: A.is_unimodular_path(0,2/3) 

False 

sage: A.is_unimodular_path(2/3,0) 

False 

""" 

a = r1.numerator() 

b = r2.numerator() 

c = r1.denominator() 

d = r2.denominator() 

return (a * d - b * c) ** 2 == 1 

 

def unimod_to_matrices(self, r1, r2): 

r""" 

Return the two matrices whose associated unimodular paths connect 

``r1`` and ``r2`` and ``r2`` and ``r1``, respectively. 

 

INPUT: 

 

- ``r1, r2`` -- rational numbers (that are assumed to be connected by a 

unimodular path) 

 

OUTPUT: 

 

A pair of `2 \times 2` matrices of determinant 1 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: A.unimod_to_matrices(0,1/3) 

( 

[ 0 1] [1 0] 

[-1 3], [3 1] 

) 

""" 

a = r1.numerator() 

b = r2.numerator() 

c = r1.denominator() 

d = r2.denominator() 

if (a * d - b * c) == 1: 

ans = M2Z([a, b, c, d]), M2Z([-b, a, -d, c]) 

else: 

ans = M2Z([-a, b, -c, d]), M2Z([b, a, d, c]) 

return ans 

 

def fd_boundary(self, C): 

r""" 

Find matrices whose associated unimodular paths give the 

boundary of a fundamental domain. 

 

Here the fundamental domain is for `\Gamma_0(N)`. (In the 

case when `\Gamma_0(N)` has elements of order three the shape 

cut out by these unimodular matrices is a little smaller than 

a fundamental domain. See Section 2.5 of [PS2011]_.) 

 

INPUT: 

 

- ``C`` -- a list of rational numbers coming from 

``self.form_list_of_cusps()`` 

 

OUTPUT: 

 

A list of `2 \times 2` integer matrices of determinant 1 whose associated 

unimodular paths give the boundary of a fundamental domain for 

`\Gamma_0(N)` (or nearly so in the case of 3-torsion). 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import ManinRelations 

sage: A = ManinRelations(11) 

sage: C = A.form_list_of_cusps(); C 

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

sage: A.fd_boundary(C) 

[ 

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

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

] 

sage: A = ManinRelations(13) 

sage: C = A.form_list_of_cusps(); C 

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

sage: A.fd_boundary(C) 

[ 

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

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

] 

sage: A = ManinRelations(101) 

sage: C = A.form_list_of_cusps(); C 

[-1, -6/7, -5/6, -4/5, -7/9, -3/4, -11/15, -8/11, -5/7, -7/10, 

-9/13, -2/3, -5/8, -13/21, -8/13, -3/5, -7/12, -11/19, -4/7, -1/2, 

-4/9, -3/7, -5/12, -7/17, -2/5, -3/8, -4/11, -1/3, -2/7, -3/11, 

-1/4, -2/9, -1/5, -1/6, 0] 

sage: A.fd_boundary(C) 

[ 

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

[0 1], [-1 0], [ 1 6], [ 6 5], [ 5 9], [ 9 4], [ 4 11], [11 7], 

<BLANKLINE> 

[-2 -1] [-1 -4] [-4 -3] [-3 -2] [-2 -7] [-7 -5] [-5 -3] [-3 -4] 

[ 7 3], [ 3 11], [11 8], [ 8 5], [ 5 17], [17 12], [12 7], [ 7 9], 

<BLANKLINE> 

[-4 -1] [-1 -4] [ -4 -11] [-11 -7] [-7 -3] [-3 -8] [ -8 -13] 

[ 9 2], [ 2 7], [ 7 19], [ 19 12], [12 5], [ 5 13], [ 13 21], 

<BLANKLINE> 

[-13 -5] [-5 -2] [-2 -9] [-9 -7] [-7 -5] [-5 -8] [ -8 -11] 

[ 21 8], [ 8 3], [ 3 13], [13 10], [10 7], [ 7 11], [ 11 15], 

<BLANKLINE> 

[-11 -3] [-3 -7] [-7 -4] [-4 -5] [-5 -6] [-6 -1] 

[ 15 4], [ 4 9], [ 9 5], [ 5 6], [ 6 7], [ 7 1] 

] 

""" 

C.reverse() # Reverse here to get clockwise orientation of boundary 

 

## These matrices correspond to the paths from infty to 0 and 

## -1 to infty 

mats = [Id, minone_inf_path] 

 

## Now find SL_2(Z) matrices whose associated unimodular paths 

## connect the cusps listed in C. 

for j in range(len(C) - 1): 

a = C[j].numerator() 

b = C[j + 1].numerator() 

c = C[j].denominator() 

d = C[j + 1].denominator() 

new_mat = M2Z([a, b, c, d]) 

mats.append(new_mat) 

 

return mats 

 

@cached_method 

def prep_hecke_on_gen(self, l, gen, modulus=None): 

r""" 

This function does some precomputations needed to compute `T_l`. 

 

In particular, if `\phi` is a modular symbol and `D_m` is the divisor 

associated to the generator ``gen``, to compute `(\phi|T_{l})(D_m)` one 

needs to compute `\phi(\gamma_a D_m)|\gamma_a` where `\gamma_a` runs 

through the `l+1` matrices defining `T_l`. One 

then takes `\gamma_a D_m` and writes it as a sum of unimodular 

divisors. For each such unimodular divisor, say `[M]` where `M` is a 

`SL_2` matrix, we then write `M=\gamma h` where `\gamma` is in 

`\Gamma_0(N)` and `h` is one of our chosen coset representatives. Then 

`\phi([M]) = \phi([h]) | \gamma^{-1}`. Thus, one has 

 

.. MATH:: 

 

(\phi | \gamma_a)(D_m) = \sum_h \sum_j \phi([h]) | \gamma_{hj}^{-1} \cdot \gamma_a 

 

as `h` runs over all coset representatives and `j` simply runs over 

however many times `M_h` appears in the above computation. 

 

Finally, the output of this function is a dictionary ``D`` 

whose keys are the coset representatives in ``self.reps()`` 

where each value is a list of matrices, and the entries of 

``D`` satisfy: 

 

.. MATH:: 

 

D[h][j] = \gamma_{hj} * \gamma_a 

 

INPUT: 

 

- ``l`` -- a prime 

- ``gen`` -- a generator 

 

OUTPUT: 

 

A list of lists (see above). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: M = phi.parent().source() 

sage: w = M.prep_hecke_on_gen(2, M.gens()[0]) 

sage: one = Matrix(ZZ,2,2,1) 

sage: one.set_immutable() 

sage: w[one] 

[[1 0] 

[0 2], [1 1] 

[0 2], [2 0] 

[0 1]] 

""" 

N = self.level() 

SN = Sigma0(N) 

 

ans = {} 

# this will be the dictionary D above enumerated by coset reps 

 

# This loop will run thru the l+1 (or l) matrices 

# defining T_l of the form [1, a, 0, l] and carry out the 

# computation described above. 

# ------------------------------------- 

for a in range(l + 1): 

if ((a < l) or (N % l != 0)) and (modulus is None or a % l == modulus % l): 

# if the level is not prime to l the matrix [l, 0, 0, 1] is avoided. 

gamma = basic_hecke_matrix(a, l) 

t = gamma * gen 

# In the notation above this is gam_a * D_m 

from .manin_map import unimod_matrices_to_infty, unimod_matrices_from_infty 

v = unimod_matrices_from_infty(t[0, 0], t[1, 0]) + unimod_matrices_to_infty(t[0, 1], t[1, 1]) 

# This expresses t as a sum of unimodular divisors 

 

# This loop runs over each such unimodular divisor 

# ------------------------------------------------ 

for A in v: 

# B is the coset rep equivalent to A 

B = self.equivalent_rep(A) 

# gaminv = B*A^(-1), but A is in SL2. 

gaminv = B * A.adjoint() 

# The matrix gaminv * gamma is added to our list in the j-th slot 

# (as described above) 

tmp = SN(gaminv * gamma) 

try: 

ans[B].append(tmp) 

except KeyError: 

ans[B] = [tmp] 

 

return ans 

 

@cached_method 

def prep_hecke_on_gen_list(self, l, gen, modulus=None): 

r""" 

Return the precomputation to compute `T_l` in a way that 

speeds up the Hecke calculation. 

 

Namely, returns a list of the form [h,A]. 

 

INPUT: 

 

- ``l`` -- a prime 

- ``gen`` -- a generator 

 

OUTPUT: 

 

A list of lists (see above). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: M = phi.parent().source() 

sage: len(M.prep_hecke_on_gen_list(2, M.gens()[0])) 

4 

""" 

ans = [] 

for h, vh in iteritems(self.prep_hecke_on_gen(l, gen, modulus=modulus)): 

ans.extend([(h, v) for v in vh]) 

return ans 

 

 

def basic_hecke_matrix(a, l): 

r""" 

Return the `2 \times 2` matrix with entries ``[1, a, 0, l]`` if ``a<l`` 

and ``[l, 0, 0, 1]`` if ``a>=l``. 

 

INPUT: 

 

- `a` -- an integer or Infinity 

- ``l`` -- a prime 

 

OUTPUT: 

 

A `2 \times 2` matrix of determinant l 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.fund_domain import basic_hecke_matrix 

sage: basic_hecke_matrix(0, 7) 

[1 0] 

[0 7] 

sage: basic_hecke_matrix(5, 7) 

[1 5] 

[0 7] 

sage: basic_hecke_matrix(7, 7) 

[7 0] 

[0 1] 

sage: basic_hecke_matrix(19, 7) 

[7 0] 

[0 1] 

sage: basic_hecke_matrix(infinity, 7) 

[7 0] 

[0 1] 

""" 

if a < l: 

return M2Z([1, a, 0, l]) 

else: 

return M2Z([l, 0, 0, 1])