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

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

r""" 

Element class for Pollack-Stevens' Modular Symbols 

 

This is the class of elements in the spaces of Pollack-Steven's modular symbols as described in [PS]_. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol(); phi 

Modular symbol of level 11 with values in Sym^0 Q^2 

sage: phi.weight() # Note that weight k=2 of a modular form corresponds here to weight 0 

0 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi.is_ordinary(11) 

True 

sage: phi_lift = phi.lift(11, 5, eigensymbol = True) # long time 

sage: phi_lift.padic_lseries().series(5) # long time 

O(11^5) + (10 + 3*11 + 6*11^2 + 9*11^3 + O(11^4))*T + (6 + 3*11 + 2*11^2 + O(11^3))*T^2 + (2 + 2*11 + O(11^2))*T^3 + (5 + O(11))*T^4 + O(T^5) 

 

:: 

 

sage: A = ModularSymbols(Gamma1(8),4).decomposition()[0].plus_submodule().new_subspace() 

sage: from sage.modular.pollack_stevens.space import ps_modsym_from_simple_modsym_space 

sage: phi = ps_modsym_from_simple_modsym_space(A) 

sage: phi.values() 

[(-1, 0, 0), (1, 0, 0), (-9, -6, -4)] 

 

""" 

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

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

# 

# 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 

from __future__ import absolute_import 

import operator 

from sage.structure.element import ModuleElement 

from sage.structure.richcmp import op_EQ, op_NE 

from sage.rings.integer_ring import ZZ 

from sage.rings.rational_field import QQ 

from sage.misc.cachefunc import cached_method 

from sage.rings.padics.factory import Qp 

from sage.rings.polynomial.all import PolynomialRing 

from sage.rings.padics.padic_generic import pAdicGeneric 

from sage.arith.all import next_prime, binomial, gcd, kronecker 

from sage.misc.misc import verbose 

from sage.rings.padics.precision_error import PrecisionError 

 

from sage.categories.action import Action 

from .manin_map import ManinMap 

from .sigma0 import Sigma0 

from sage.misc.misc import walltime 

from .fund_domain import M2Z 

 

minusproj = [1, 0, 0, -1] 

 

def _iterate_Up(Phi, p, M, ap, q, aq, check): 

r""" 

Return an overconvergent Hecke-eigensymbol lifting self -- self must be a 

`p`-ordinary eigensymbol 

 

INPUT: 

 

- ``p`` -- prime 

 

- ``M`` -- integer equal to the number of moments 

 

- ``ap`` -- Hecke eigenvalue at `p` 

 

- ``q`` -- prime 

 

- ``aq`` -- Hecke eigenvalue at `q` 

 

OUTPUT: 

 

- Hecke-eigenvalue overconvergent modular symbol lifting self. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('57a') 

sage: p = 5 

sage: prec = 4 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi_stabilized = phi.p_stabilize(p,M = prec) 

sage: Phi = phi_stabilized.lift(p,prec) # indirect doctest 

""" 

if ap.valuation(p) > 0: 

raise ValueError("Lifting non-ordinary eigensymbols not implemented (issue #20)") 

 

## Act by Hecke to ensure values are in D and not D^dag after solving difference equation 

verbose("Applying Hecke", level = 2) 

 

apinv = ~ap 

Phi = apinv * Phi.hecke(p) 

 

## Killing eisenstein part 

verbose("Killing eisenstein part with q = %s" % q, level = 2) 

k = Phi.parent().weight() 

Phi = ((q ** (k + 1) + 1) * Phi - Phi.hecke(q)) 

 

## Iterating U_p 

verbose("Iterating U_p", level = 2) 

Psi = apinv * Phi.hecke(p) 

 

for attempts in range(M-1): 

verbose("%s attempt (val = %s/%s)" % (attempts + 1,(Phi-Psi).valuation(),M), level = 2) 

Phi = Psi 

Psi = apinv * Phi.hecke(p) 

Psi._normalize() 

Phi = ~(q ** (k + 1) + 1 - aq) * Phi 

return Phi 

 

class PSModSymAction(Action): 

def __init__(self, actor, MSspace): 

r""" 

Create the action 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: g = phi._map._codomain._act._Sigma0(matrix(ZZ,2,2,[1,2,3,4])) 

sage: phi * g # indirect doctest 

Modular symbol of level 11 with values in Sym^0 Q^2 

""" 

 

Action.__init__(self, actor, MSspace, False, operator.mul) 

 

def _call_(self, sym, g): 

r""" 

Return the result of sym * g 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: g = phi._map._codomain._act._Sigma0(matrix(ZZ,2,2,[2,1,5,-1])) 

sage: phi * g # indirect doctest 

Modular symbol of level 11 with values in Sym^0 Q^2 

""" 

 

return sym.__class__(sym._map * g, sym.parent(), construct=True) 

 

 

class PSModularSymbolElement(ModuleElement): 

def __init__(self, map_data, parent, construct=False): 

r""" 

Initialize a modular symbol 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: phi = E.pollack_stevens_modular_symbol() 

""" 

ModuleElement.__init__(self, parent) 

if construct: 

self._map = map_data 

else: 

self._map = ManinMap(parent._coefficients, parent._source, map_data) 

 

def _repr_(self): 

r""" 

Return the string representation of the symbol. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi._repr_() 

'Modular symbol of level 11 with values in Sym^0 Q^2' 

""" 

return "Modular symbol of level %s with values in %s" % (self.parent().level(), self.parent().coefficient_module()) 

 

def dict(self): 

r""" 

Return dictionary on the modular symbol self, where keys are generators and values are the corresponding values of self on generators 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: Set([x.moment(0) for x in phi.dict().values()]) == Set([-1/5, 1, 0]) 

True 

""" 

D = {} 

for g in self.parent().source().gens(): 

D[g] = self._map[g] 

return D 

 

def weight(self): 

r""" 

Return the weight of this Pollack-Stevens modular symbol. 

 

This is `k-2`, where `k` is the usual notion of weight for modular 

forms! 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.weight() 

0 

""" 

return self.parent().weight() 

 

def values(self): 

r""" 

Return the values of the symbol self on our chosen generators 

(generators are listed in ``self.dict().keys()``) 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi.dict().keys() 

[ 

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

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

] 

sage: sorted(phi.values()) == sorted(phi.dict().values()) 

True 

""" 

return [self._map[g] for g in self.parent().source().gens()] 

 

def _normalize(self, **kwds): 

""" 

Normalize all of the values of the symbol self 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi._normalize() 

Modular symbol of level 11 with values in Sym^0 Q^2 

sage: phi._normalize().values() 

[-1/5, 1, 0] 

""" 

for val in self._map: 

val.normalize(**kwds) 

return self 

 

def _richcmp_(self, other, op): 

""" 

Check if self == other. 

 

Here self and other have the same parent. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi == phi 

True 

sage: phi == 2*phi 

False 

sage: psi = EllipticCurve('37a').pollack_stevens_modular_symbol() 

sage: psi == phi 

False 

""" 

if op not in [op_EQ, op_NE]: 

return NotImplemented 

 

b = all(self._map[g] == other._map[g] 

for g in self.parent().source().gens()) 

 

return b == (op == op_EQ) 

 

def _add_(self, right): 

""" 

Return self + right 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi + phi 

Modular symbol of level 11 with values in Sym^0 Q^2 

sage: (phi + phi).values() 

[-2/5, 2, 0] 

""" 

return self.__class__(self._map + right._map, self.parent(), construct=True) 

 

def _lmul_(self, right): 

""" 

Return self * right 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol(); 

sage: phi.values() 

[-1/5, 1, 0] 

sage: 2*phi 

Modular symbol of level 11 with values in Sym^0 Q^2 

sage: (2*phi).values() 

[-2/5, 2, 0] 

""" 

return self.__class__(self._map * right, self.parent(), construct=True) 

 

def _rmul_(self, right): 

""" 

Return self * right 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi*2 

Modular symbol of level 11 with values in Sym^0 Q^2 

sage: (phi*2).values() 

[-2/5, 2, 0] 

""" 

return self.__class__(self._map * right, self.parent(), construct=True) 

 

def _sub_(self, right): 

""" 

Return self - right 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi - phi 

Modular symbol of level 11 with values in Sym^0 Q^2 

sage: (phi - phi).values() 

[0, 0, 0] 

""" 

return self.__class__(self._map - right._map, self.parent(), construct=True) 

 

def _get_prime(self, p=None, alpha=None, allow_none=False): 

""" 

Combine a prime specified by the user with the prime from the parent. 

 

INPUT: 

 

- ``p`` -- an integer or None (default None); if specified 

needs to match the prime of the parent. 

 

- ``alpha`` -- an element or None (default None); if p-adic 

can contribute a prime. 

 

- ``allow_none`` -- boolean (default False); whether to allow 

no prime to be specified. 

 

OUTPUT: 

 

- a prime or None. If ``allow_none`` is False then a 

``ValueError`` will be raised rather than returning None if no 

prime can be determined. 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.distributions import Symk 

sage: D = OverconvergentDistributions(0, 5, 10) 

sage: M = PollackStevensModularSymbols(Gamma0(5), coefficients=D) 

sage: f = M(1); f._get_prime() 

5 

sage: f._get_prime(5) 

5 

sage: f._get_prime(7) 

Traceback (most recent call last): 

... 

ValueError: inconsistent prime 

sage: f._get_prime(alpha=Qp(5)(1)) 

5 

sage: D = Symk(0) 

sage: M = PollackStevensModularSymbols(Gamma0(2), coefficients=D) 

sage: f = M(1); f._get_prime(allow_none=True) is None 

True 

sage: f._get_prime(alpha=Qp(7)(1)) 

7 

sage: f._get_prime(7,alpha=Qp(7)(1)) 

7 

sage: f._get_prime() 

Traceback (most recent call last): 

... 

ValueError: you must specify a prime 

""" 

pp = self.parent().prime() 

ppp = ((alpha is not None) and hasattr(alpha.parent(), 'prime') 

and alpha.parent().prime()) or None 

p = ZZ(p) or pp or ppp 

if not p: 

if not allow_none: 

raise ValueError("you must specify a prime") 

elif (pp and p != pp) or (ppp and p != ppp): 

raise ValueError("inconsistent prime") 

return p 

 

def plus_part(self): 

r""" 

Return the plus part of self -- i.e. ``self + self | [1,0,0,-1]``. 

 

Note that we haven't divided by 2. Is this a problem? 

 

OUTPUT: 

 

- self + self | [1,0,0,-1] 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: (phi.plus_part()+phi.minus_part()) == 2 * phi 

True 

""" 

S0N = Sigma0(self.parent().level()) 

return self + self * S0N(minusproj) 

 

def minus_part(self): 

r""" 

Return the minus part of self -- i.e. self - self | [1,0,0,-1] 

 

Note that we haven't divided by 2. Is this a problem? 

 

OUTPUT: 

 

- self -- self | [1,0,0,-1] 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: (phi.plus_part()+phi.minus_part()) == phi * 2 

True 

""" 

S0N = Sigma0(self.parent().level()) 

return self - self * S0N(minusproj) 

 

def hecke(self, ell, algorithm="prep"): 

r""" 

Return self | `T_{\ell}` by making use of the precomputations in 

self.prep_hecke() 

 

INPUT: 

 

- ``ell`` -- a prime 

 

- ``algorithm`` -- a string, either 'prep' (default) or 

'naive' 

 

OUTPUT: 

 

- The image of this element under the Hecke operator 

`T_{\ell}` 

 

ALGORITHMS: 

 

- If ``algorithm == 'prep'``, precomputes a list of matrices 

that only depend on the level, then uses them to speed up 

the action. 

 

- If ``algorithm == 'naive'``, just acts by the matrices 

defining the Hecke operator. That is, it computes 

sum_a self | [1,a,0,ell] + self | [ell,0,0,1], 

the last term occurring only if the level is prime to ell. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi.hecke(2) == phi * E.ap(2) 

True 

sage: phi.hecke(3) == phi * E.ap(3) 

True 

sage: phi.hecke(5) == phi * E.ap(5) 

True 

sage: phi.hecke(101) == phi * E.ap(101) 

True 

 

sage: all([phi.hecke(p, algorithm='naive') == phi * E.ap(p) for p in [2,3,5,101]]) # long time 

True 

""" 

return self.__class__(self._map.hecke(ell, algorithm), 

self.parent(), construct=True) 

 

def valuation(self, p=None): 

r""" 

Return the valuation of ``self`` at `p`. 

 

Here the valuation is the minimum of the valuations of the 

values of ``self``. 

 

INPUT: 

 

- ``p`` - prime 

 

OUTPUT: 

 

- The valuation of ``self`` at `p` 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi.valuation(2) 

0 

sage: phi.valuation(3) 

0 

sage: phi.valuation(5) 

-1 

sage: phi.valuation(7) 

0 

sage: phi.valuation() 

Traceback (most recent call last): 

... 

ValueError: you must specify a prime 

 

sage: phi2 = phi.lift(11, M=2) 

sage: phi2.valuation() 

0 

sage: phi2.valuation(3) 

Traceback (most recent call last): 

... 

ValueError: inconsistent prime 

sage: phi2.valuation(11) 

0 

""" 

q = self._get_prime(p) 

return min([val.valuation(q) for val in self._map]) 

 

def diagonal_valuation(self, p): 

""" 

Return the minimum of the diagonal valuation on the values of self 

 

INPUT: 

 

- ``p`` -- a positive integral prime 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi.diagonal_valuation(2) 

0 

sage: phi.diagonal_valuation(3) 

0 

sage: phi.diagonal_valuation(5) 

-1 

sage: phi.diagonal_valuation(7) 

0 

""" 

return min([val.diagonal_valuation(p) for val in self._map]) 

 

@cached_method 

def is_Tq_eigensymbol(self, q, p=None, M=None): 

r""" 

Determine if self is an eigenvector for `T_q` modulo `p^M` 

 

INPUT: 

 

- ``q`` -- prime of the Hecke operator 

 

- ``p`` -- prime we are working modulo 

 

- ``M`` -- degree of accuracy of approximation 

 

OUTPUT: 

 

- True/False 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi_ord = phi.p_stabilize(p = 3, ap = E.ap(3), M = 10, ordinary = True) 

sage: phi_ord.is_Tq_eigensymbol(2,3,10) 

True 

sage: phi_ord.is_Tq_eigensymbol(2,3,100) 

False 

sage: phi_ord.is_Tq_eigensymbol(2,3,1000) 

False 

sage: phi_ord.is_Tq_eigensymbol(3,3,10) 

True 

sage: phi_ord.is_Tq_eigensymbol(3,3,100) 

False 

""" 

try: 

aq = self.Tq_eigenvalue(q, p, M) 

return True 

except ValueError: 

return False 

 

# what happens if a cached method raises an error? Is it 

# recomputed each time? 

@cached_method 

def Tq_eigenvalue(self, q, p=None, M=None, check=True): 

r""" 

Eigenvalue of `T_q` modulo `p^M` 

 

INPUT: 

 

- ``q`` -- prime of the Hecke operator 

 

- ``p`` -- prime we are working modulo (default: None) 

 

- ``M`` -- degree of accuracy of approximation (default: None) 

 

- ``check`` -- check that ``self`` is an eigensymbol 

 

OUTPUT: 

 

- Constant `c` such that `self|T_q - c * self` has valuation greater than 

or equal to `M` (if it exists), otherwise raises ValueError 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.values() 

[-1/5, 1, 0] 

sage: phi_ord = phi.p_stabilize(p = 3, ap = E.ap(3), M = 10, ordinary = True) 

sage: phi_ord.Tq_eigenvalue(2,3,10) + 2 

O(3^10) 

 

sage: phi_ord.Tq_eigenvalue(3,3,10) 

2 + 3^2 + 2*3^3 + 2*3^4 + 2*3^6 + 3^8 + 2*3^9 + O(3^10) 

sage: phi_ord.Tq_eigenvalue(3,3,100) 

Traceback (most recent call last): 

... 

ValueError: result not determined to high enough precision 

""" 

qhecke = self.hecke(q) 

gens = self.parent().source().gens() 

if p is None: 

p = self.parent().prime() 

i = 0 

 

g = gens[i] 

verbose("Computing eigenvalue", level = 2) 

while self._map[g].moment(0).is_zero(): 

if not qhecke._map[g].moment(0).is_zero(): 

raise ValueError("not a scalar multiple") 

i += 1 

try: 

g = gens[i] 

except IndexError: 

raise ValueError("self is zero") 

aq = self.parent().base_ring()(self._map[g].find_scalar_from_zeroth_moment(qhecke._map[g], p, M, check)) 

 

verbose("Found eigenvalues of %s" % aq, level = 2) 

if check: 

verbose("Checking that this is actually an eigensymbol", level = 2) 

if p is None or M is None or not ZZ(p).is_prime(): 

for g in gens[1:]: 

try: 

if not (qhecke._map[g] - aq * self._map[g]).is_zero(): 

# using != did not work 

raise ValueError("not a scalar multiple") 

except PrecisionError: 

if qhecke._map[g] != aq * self._map[g]: 

raise ValueError("not a scalar multiple") 

else: 

verbose('p = %s, M = %s' % (p, M), level = 2) 

if qhecke != aq * self: 

raise ValueError("not a scalar multiple") 

# if not aq.parent().is_exact() and M is not None: 

# aq.add_bigoh(M) 

return aq 

 

def is_ordinary(self, p=None, P=None): 

r""" 

Return true if the `p`-th eigenvalue is a `p`-adic unit. 

 

INPUT: 

 

- ``p`` - a positive integral prime, or None (default None) 

- ``P`` - a prime of the base ring above `p`, or None. This is ignored 

unless the base ring is a number field. 

 

OUTPUT: 

 

- True/False 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a1') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi.is_ordinary(2) 

False 

sage: E.ap(2) 

-2 

sage: phi.is_ordinary(3) 

True 

sage: E.ap(3) 

-1 

sage: phip = phi.p_stabilize(3,20) 

sage: phip.is_ordinary() 

True 

 

A number field example. Here there are multiple primes above `p`, and 

`\phi` is ordinary at one but not the other.:: 

 

sage: f = Newforms(32, 8, names='a')[1] 

sage: K = f.hecke_eigenvalue_field() 

sage: a = f[3] 

sage: from sage.modular.pollack_stevens.space import ps_modsym_from_simple_modsym_space 

sage: phi = ps_modsym_from_simple_modsym_space(f.modular_symbols(1)) 

sage: phi.is_ordinary(K.ideal(3, 1/16*a + 3/2)) != phi.is_ordinary(K.ideal(3, 1/16*a + 5/2)) 

True 

sage: phi.is_ordinary(3) 

Traceback (most recent call last): 

... 

TypeError: P must be an ideal 

 

""" 

# q is the prime below p, if base is a number field; q = p otherwise 

if p is None: 

if self.parent().prime() == 0: 

raise ValueError("need to specify a prime") 

q = p = self.parent().prime() 

elif p in ZZ: 

q = p 

else: 

q = p.smallest_integer() 

if not q.is_prime(): 

raise ValueError("p is not prime") 

if (self.parent().prime() != q) and (self.parent().prime() != 0): 

raise ValueError("prime does not match coefficient module's prime") 

aq = self.Tq_eigenvalue(q) 

return aq.valuation(p) == 0 

 

def evaluate_twisted(self, a, chi): 

r""" 

Return `\Phi_{\chi}(\{a/p\}-\{\infty\})` where `\Phi` is ``self`` and 

`\chi` is a quadratic character 

 

INPUT: 

 

- ``a`` -- integer in the range range(p) 

- ``chi`` -- the modulus of a quadratic character. 

 

OUTPUT: 

 

The distribution `\Phi_{\chi}(\{a/p\}-\{\infty\})`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('17a1') 

sage: L = E.padic_lseries(5, implementation="pollackstevens", precision=4) #long time 

sage: D = L.quadratic_twist() # long time 

sage: L.symbol().evaluate_twisted(1,D) # long time 

(1 + 5 + 3*5^2 + 5^3 + O(5^4), 5^2 + O(5^3), 1 + O(5^2), 2 + O(5)) 

 

sage: E = EllipticCurve('40a4') 

sage: L = E.padic_lseries(7, implementation="pollackstevens", precision=4) #long time 

sage: D = L.quadratic_twist() # long time 

sage: L.symbol().evaluate_twisted(1,D) # long time 

(4 + 6*7 + 3*7^2 + O(7^4), 6*7 + 6*7^2 + O(7^3), 6 + O(7^2), 1 + O(7)) 

""" 

p = self.parent().prime() 

S0p = Sigma0(p) 

Dists = self.parent().coefficient_module() 

M = Dists.precision_cap() 

p = Dists.prime() 

twisted_dist = Dists.zero() 

m_map = self._map 

for b in range(1, abs(chi) + 1): 

if gcd(b, chi) == 1: 

M1 = S0p([1, (b / abs(chi)) % p ** M, 0, 1]) 

new_dist = m_map(M1 * M2Z([a, 1, p, 0])) * M1 

new_dist = new_dist.scale(kronecker(chi, b)).normalize() 

twisted_dist += new_dist 

return twisted_dist.normalize() 

 

def _consistency_check(self): 

""" 

Check that the map really does satisfy the Manin relations loop (for debugging). 

The two and three torsion relations are checked and it is checked that the symbol 

adds up correctly around the fundamental domain 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a1') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi._consistency_check() 

This modular symbol satisfies the Manin relations 

""" 

f = self._map 

MR = self._map._manin 

## Test two torsion relations 

for g in MR.reps_with_two_torsion(): 

gamg = MR.two_torsion_matrix(g) 

if not (f[g] * gamg + f[g]).is_zero(): 

raise ValueError("Two torsion relation failed with", g) 

 

## Test three torsion relations 

for g in MR.reps_with_three_torsion(): 

gamg = MR.three_torsion_matrix(g) 

if not (f[g] * (gamg ** 2) + f[g] * gamg + f[g]).is_zero(): 

raise ValueError("Three torsion relation failed with", g) 

 

## Test that the symbol adds to 0 around the boundary of the 

## fundamental domain 

t = self.parent().coefficient_module().zero() 

for g in MR.gens()[1:]: 

if not(g in MR.reps_with_two_torsion() 

or g in MR.reps_with_three_torsion()): 

t += f[g] * MR.gammas[g] - f[g] 

else: 

if g in MR.reps_with_two_torsion(): 

t -= f[g] 

else: 

t -= f[g] # what ?? same thing ?? 

 

id = MR.gens()[0] 

if f[id] * MR.gammas[id] - f[id] != -t: 

print(t) 

print(f[id] * MR.gammas[id] - f[id]) 

raise ValueError("Does not add up correctly around loop") 

 

print("This modular symbol satisfies the Manin relations") 

 

 

class PSModularSymbolElement_symk(PSModularSymbolElement): 

def _find_alpha(self, p, k, M=None, ap=None, new_base_ring=None, ordinary=True, check=True, find_extraprec=True): 

r""" 

Find `\alpha`, a `U_p` eigenvalue, which is found as a root of 

the polynomial `x^2 - a_p * x + p^{k+1} \chi(p)`. 

 

INPUT: 

 

- ``p`` -- prime 

 

- ``k`` -- Pollack-Stevens weight 

 

- ``M`` -- precision (default: None) of `\QQ_p` 

 

- ``ap`` -- Hecke eigenvalue at `p` (default: None) 

 

- ``new_base_ring`` -- field of definition of `\alpha` (default: None) 

 

- ``ordinary`` -- True if the prime is ordinary (default: True) 

 

- ``check`` -- check to see if the prime is ordinary (default: True) 

 

- ``find_extraprec`` -- setting this to True finds extra precision (default: True) 

 

OUTPUT: 

 

The output is a tuple (``alpha``, ``new_base_ring``, 

``newM``, ``eisenloss``,``q``,``aq``), with 

 

- ``alpha`` -- `U_p` eigenvalue 

 

- ``new_base_ring`` -- field of definition of `\alpha` with precision at least ``newM`` 

 

- ``newM`` -- new precision 

 

- ``eisenloss`` -- loss of precision 

 

- ``q`` -- a prime not equal to `p` which was used to find extra precision 

 

- ``aq`` -- the Hecke eigenvalue `a_q` corresponding to `q` 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: p = 5 

sage: M = 10 

sage: k = 0 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phi._find_alpha(p,k,M) 

(1 + 4*5 + 3*5^2 + 2*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 3*5^7 + 2*5^8 + 3*5^9 + 3*5^10 + 3*5^12 + 2*5^13 + O(5^14), 5-adic Field with capped relative precision 14, 13, 1, 2, -2) 

""" 

if ap is None: 

ap = self.Tq_eigenvalue(p, check=check) 

if check and ap.valuation(p) > 0: 

raise ValueError("p is not ordinary") 

 

chi = self._map._codomain._character 

if chi is not None: 

eps = chi(p) 

else: 

eps = 1 

poly = PolynomialRing(ap.parent(), 'x')([p ** (k + 1) * eps, -ap, 1]) 

if new_base_ring is None: 

# These should actually be completions of disc.parent() 

if p == 2: 

# is this the right precision adjustment for p=2? 

new_base_ring = Qp(2, M + 1) 

else: 

new_base_ring = Qp(p, M) 

set_padicbase = True 

else: 

set_padicbase = False 

try: 

verbose("finding alpha: rooting %s in %s" % (poly, new_base_ring), level = 2) 

poly = poly.change_ring(new_base_ring) 

(v0, e0), (v1, e1) = poly.roots() 

except (TypeError, ValueError): 

raise ValueError("new base ring must contain a root of x^2 - ap * x + p^(k+1)") 

if v0.valuation(p) > 0: 

v0, v1 = v1, v0 

if ordinary: 

alpha = v0 

else: 

alpha = v1 

if find_extraprec: 

newM, eisenloss, q, aq = self._find_extraprec(p, M, alpha, check) 

else: 

newM, eisenloss, q, aq = M, None, None, None 

if set_padicbase: 

# We want to ensure that the relative precision of alpha 

# and (alpha-1) are both at least *newM*, where newM is 

# obtained from self._find_extraprec 

prec_cap = None 

verbose("testing prec_rel: newM = %s, alpha = %s" % (newM, alpha), 

level=2) 

if alpha.precision_relative() < newM: 

prec_cap = newM + alpha.valuation(p) + (1 if p == 2 else 0) 

if ordinary: 

a1val = (alpha - 1).valuation(p) 

verbose("a1val = %s" % a1val, level=2) 

if a1val > 0 and ap != 1 + p ** (k + 1): 

# if ap = 1 + p**(k+1) then alpha=1 and we need to give up. 

if prec_cap is None: 

prec_cap = newM + a1val + (1 if p == 2 else 0) 

else: 

prec_cap = max(prec_cap, newM + a1val + (1 if p == 2 else 0)) 

verbose("prec_cap = %s" % prec_cap, level=2) 

if prec_cap is not None: 

new_base_ring = Qp(p, prec_cap) 

return self._find_alpha(p=p, k=k, M=M, ap=ap, new_base_ring=new_base_ring, ordinary=ordinary, check=False, find_extraprec=find_extraprec) 

return alpha, new_base_ring, newM, eisenloss, q, aq 

 

def p_stabilize(self, p=None, M=20, alpha=None, ap=None, new_base_ring=None, ordinary=True, check=True): 

r""" 

Return the `p`-stabilization of self to level `N p` on which `U_p` acts by `\alpha`. 

 

Note that since `\alpha` is `p`-adic, the resulting symbol 

is just an approximation to the true `p`-stabilization 

(depending on how well `\alpha` is approximated). 

 

INPUT: 

 

- ``p`` -- prime not dividing the level of self 

 

- ``M`` -- (default: 20) precision of `\QQ_p` 

 

- ``alpha`` -- `U_p` eigenvalue 

 

- ``ap`` -- Hecke eigenvalue 

 

- ``new_base_ring`` -- change of base ring 

 

- ``ordinary`` -- (default: True) whether to return the ordinary 

(at ``p``) eigensymbol. 

 

- ``check`` -- (default: True) whether to perform extra sanity checks 

 

OUTPUT: 

 

A modular symbol with the same Hecke eigenvalues as 

self away from `p` and eigenvalue `\alpha` at `p`. 

The eigenvalue `\alpha` depends on the parameter ``ordinary``. 

 

If ``ordinary`` == True: the unique modular symbol of level 

`N p` with the same Hecke eigenvalues as self away from 

`p` and unit eigenvalue at `p`; else the unique modular 

symbol of level `N p` with the same Hecke eigenvalues as 

self away from `p` and non-unit eigenvalue at `p`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: p = 5 

sage: prec = 4 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: phis = phi.p_stabilize(p,M = prec) 

sage: phis 

Modular symbol of level 55 with values in Sym^0 Q_5^2 

sage: phis.hecke(7) == phis*E.ap(7) 

True 

sage: phis.hecke(5) == phis*E.ap(5) 

False 

sage: phis.hecke(3) == phis*E.ap(3) 

True 

sage: phis.Tq_eigenvalue(5) 

1 + 4*5 + 3*5^2 + 2*5^3 + O(5^4) 

sage: phis.Tq_eigenvalue(5,M = 3) 

1 + 4*5 + 3*5^2 + O(5^3) 

 

sage: phis = phi.p_stabilize(p,M = prec,ordinary=False) 

sage: phis.Tq_eigenvalue(5) 

5 + 5^2 + 2*5^3 + O(5^5) 

 

A complicated example (with nontrivial character):: 

 

sage: chi = DirichletGroup(24)([-1, -1, -1]) 

sage: f = Newforms(chi,names='a')[0] 

sage: from sage.modular.pollack_stevens.space import ps_modsym_from_simple_modsym_space 

sage: phi = ps_modsym_from_simple_modsym_space(f.modular_symbols(1)) 

sage: phi11, h11 = phi.completions(11,20)[0] 

sage: phi11s = phi11.p_stabilize() 

sage: phi11s.is_Tq_eigensymbol(11) # long time 

True 

""" 

if check: 

p = self._get_prime(p, alpha) 

k = self.parent().weight() 

M = ZZ(M) 

verbose("p stabilizing: M = %s" % M, level=2) 

if alpha is None: 

alpha, new_base_ring, newM, eisenloss, q, aq = self._find_alpha(p, k, M + 1, ap, new_base_ring, ordinary, check, find_extraprec=False) 

new_base_ring = Qp(p, M) if p != 2 else Qp(p, M + 1) 

else: 

if new_base_ring is None: 

new_base_ring = alpha.parent() 

if check: 

if ap is None: 

ap = self.base_ring()(alpha + p ** (k + 1) / alpha) 

elif alpha ** 2 - ap * alpha + p ** (k + 1) != 0: 

raise ValueError("alpha must be a root of x^2 - a_p*x + p^(k+1)") 

if self.hecke(p) != ap * self: 

raise ValueError("alpha must be a root of x^2 - a_p*x + p^(k+1)") 

verbose("found alpha = %s" % alpha, level = 2) 

 

V = self.parent()._p_stabilize_parent_space(p, new_base_ring) 

return self.__class__(self._map.p_stabilize(p, alpha, V), V, construct=True) 

 

def completions(self, p, M): 

r""" 

If `K` is the base_ring of self, this function takes all maps 

`K\to \QQ_p` and applies them to self return a list of 

(modular symbol,map: `K\to \QQ_p`) as map varies over all such maps. 

 

.. NOTE:: 

 

This only returns all completions when `p` splits completely in `K` 

 

INPUT: 

 

- ``p`` -- prime 

 

- ``M`` -- precision 

 

OUTPUT: 

 

- A list of tuples (modular symbol,map: `K\to \QQ_p`) as map varies over all such maps 

 

EXAMPLES:: 

 

sage: from sage.modular.pollack_stevens.space import ps_modsym_from_simple_modsym_space 

sage: D = ModularSymbols(67,2,1).cuspidal_submodule().new_subspace().decomposition()[1] 

sage: f = ps_modsym_from_simple_modsym_space(D) 

sage: S = f.completions(41,10); S 

[(Modular symbol of level 67 with values in Sym^0 Q_41^2, Ring morphism: 

From: Number Field in alpha with defining polynomial x^2 + 3*x + 1 

To: 41-adic Field with capped relative precision 10 

Defn: alpha |--> 5 + 22*41 + 19*41^2 + 10*41^3 + 28*41^4 + 22*41^5 + 9*41^6 + 25*41^7 + 40*41^8 + 8*41^9 + O(41^10)), (Modular symbol of level 67 with values in Sym^0 Q_41^2, Ring morphism: 

From: Number Field in alpha with defining polynomial x^2 + 3*x + 1 

To: 41-adic Field with capped relative precision 10 

Defn: alpha |--> 33 + 18*41 + 21*41^2 + 30*41^3 + 12*41^4 + 18*41^5 + 31*41^6 + 15*41^7 + 32*41^9 + O(41^10))] 

sage: TestSuite(S[0][0]).run(skip=['_test_category']) 

""" 

K = self.base_ring() 

R = Qp(p, M + 10)['x'] 

x = R.gen() 

if K == QQ: 

f = x - 1 

else: 

f = K.defining_polynomial() 

v = R(f).roots() 

if len(v) == 0: 

L = Qp(p, M).extension(f, names='a') 

# a = L.gen() 

V = self.parent().change_ring(L) 

Dist = V.coefficient_module() 

psi = K.hom([K.gen()], L) 

embedded_sym = self.parent().element_class(self._map.apply(psi, codomain=Dist, to_moments=True), V, construct=True) 

ans = [embedded_sym, psi] 

return ans 

else: 

roots = [r[0] for r in v] 

ans = [] 

V = self.parent().change_ring(Qp(p, M)) 

Dist = V.coefficient_module() 

for r in roots: 

psi = K.hom([r], Qp(p, M)) 

embedded_sym = self.parent().element_class(self._map.apply(psi, codomain=Dist, to_moments=True), V, construct=True) 

ans.append((embedded_sym, psi)) 

return ans 

 

def lift(self, p=None, M=None, alpha=None, new_base_ring=None, 

algorithm = None, eigensymbol=False, check=True): 

r""" 

Return a (`p`-adic) overconvergent modular symbol with 

`M` moments which lifts self up to an Eisenstein error 

 

Here the Eisenstein error is a symbol whose system of Hecke 

eigenvalues equals `\ell+1` for `T_\ell` when `\ell` 

does not divide `Np` and 1 for `U_q` when `q` divides `Np`. 

 

INPUT: 

 

- ``p`` -- prime 

 

- ``M`` -- integer equal to the number of moments 

 

- ``alpha`` -- `U_p` eigenvalue 

 

- ``new_base_ring`` -- change of base ring 

 

- ``algorithm`` -- 'stevens' or 'greenberg' (default 'stevens') 

 

- ``eigensymbol`` -- if True, lifts to Hecke eigensymbol (self must 

be a `p`-ordinary eigensymbol) 

 

(Note: ``eigensymbol = True`` does *not* just indicate to the code that 

self is an eigensymbol; it solves a wholly different problem, lifting 

an eigensymbol to an eigensymbol.) 

 

OUTPUT: 

 

An overconvergent modular symbol whose specialization equals self, up 

to some Eisenstein error if ``eigensymbol`` is False. If ``eigensymbol 

= True`` then the output will be an overconvergent Hecke eigensymbol 

(and it will lift the input exactly, the Eisenstein error disappears). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: f = E.pollack_stevens_modular_symbol() 

sage: g = f.lift(11,4,algorithm='stevens',eigensymbol=True) 

sage: g.is_Tq_eigensymbol(2) 

True 

sage: g.Tq_eigenvalue(3) 

10 + 10*11 + 10*11^2 + 10*11^3 + O(11^4) 

sage: g.Tq_eigenvalue(11) 

1 + O(11^4) 

 

We check that lifting and then specializing gives back the original symbol:: 

 

sage: g.specialize() == f 

True 

 

Another example, which showed precision loss in an earlier version of the code:: 

 

sage: E = EllipticCurve('37a') 

sage: p = 5 

sage: prec = 4 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: Phi = phi.p_stabilize_and_lift(p,prec, algorithm='stevens', eigensymbol=True) # long time 

sage: Phi.Tq_eigenvalue(5,M = 4) # long time 

3 + 2*5 + 4*5^2 + 2*5^3 + O(5^4) 

 

Another example:: 

 

sage: from sage.modular.pollack_stevens.padic_lseries import pAdicLseries 

sage: E = EllipticCurve('37a') 

sage: p = 5 

sage: prec = 6 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: Phi = phi.p_stabilize_and_lift(p=p,M=prec,alpha=None,algorithm='stevens',eigensymbol=True) #long time 

sage: L = pAdicLseries(Phi) # long time 

sage: L.symbol() is Phi # long time 

True 

 

Examples using Greenberg's algorithm:: 

 

sage: E = EllipticCurve('11a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: Phi = phi.lift(11,8,algorithm='greenberg',eigensymbol=True) 

sage: Phi2 = phi.lift(11,8,algorithm='stevens',eigensymbol=True) 

sage: Phi == Phi2 

True 

 

An example in higher weight:: 

 

sage: from sage.modular.pollack_stevens.space import ps_modsym_from_simple_modsym_space 

sage: f = ps_modsym_from_simple_modsym_space(Newforms(7, 4)[0].modular_symbols(1)) 

sage: fs = f.p_stabilize(5) 

sage: FsG = fs.lift(M=6, eigensymbol=True,algorithm='greenberg') # long time 

sage: FsG.values()[0] # long time 

5^-1 * (2*5 + 5^2 + 3*5^3 + 4*5^4 + O(5^7), O(5^6), 2*5^2 + 3*5^3 + O(5^5), O(5^4), 5^2 + O(5^3), O(5^2)) 

sage: FsS = fs.lift(M=6, eigensymbol=True,algorithm='stevens') # long time 

sage: FsS == FsG # long time 

True 

""" 

if p is None: 

p = self.parent().prime() 

if p == 0: 

raise ValueError("must specify a prime") 

elif (self.parent().prime() != 0) and p != self.parent().prime(): 

raise ValueError("inconsistent prime") 

if M is None: 

M = self.parent().precision_cap() + 1 

elif M <= 1: 

raise ValueError("M must be at least 2") 

else: 

M = ZZ(M) 

if new_base_ring is None: 

if isinstance(self.parent().base_ring(), pAdicGeneric): 

new_base_ring = self.parent().base_ring() 

else: 

# We may need extra precision in solving the difference equation 

if algorithm == 'greenberg': 

extraprec = 0 

else: 

extraprec = (M - 1).exact_log(p) # DEBUG: was M-1 

# should eventually be a completion 

new_base_ring = Qp(p, M + extraprec) 

if algorithm is None: 

# The default algorithm is Greenberg's, if possible. 

algorithm = 'greenberg' if eigensymbol else 'stevens' 

elif algorithm == 'greenberg': 

if not eigensymbol: 

raise ValueError("Greenberg's algorithm only works" 

" for eigensymbols. Try 'stevens'") 

elif algorithm != 'stevens': 

raise ValueError("algorithm %s not recognized" % algorithm) 

if eigensymbol: 

# We need some extra precision due to the fact that solving 

# the difference equation can give denominators. 

if alpha is None: 

verbose('Finding alpha with M = %s' % M, level = 2) 

alpha = self.Tq_eigenvalue(p, M=M + 1, check=check) 

newM, eisenloss, q, aq = self._find_extraprec(p, M + 1, alpha, check) 

Phi = self._lift_to_OMS(p, newM, new_base_ring, algorithm) 

Phi = _iterate_Up(Phi, p, newM, alpha, q, aq, check) 

Phi = Phi.reduce_precision(M) 

return Phi._normalize(include_zeroth_moment = True) 

else: 

return self._lift_to_OMS(p, M, new_base_ring, algorithm) 

 

def _lift_to_OMS(self, p, M, new_base_ring, algorithm = 'greenberg'): 

r""" 

Return a (`p`-adic) overconvergent modular symbol with 

`M` moments which lifts self up to an Eisenstein error 

 

Here the Eisenstein error is a symbol whose system of Hecke 

eigenvalues equals `\ell+1` for `T_\ell` when `\ell` 

does not divide `Np` and 1 for `U_q` when `q` divides `Np`. 

 

INPUT: 

 

- ``p`` -- prime 

 

- ``M`` -- integer equal to the number of moments 

 

- ``new_base_ring`` -- new base ring 

 

- ``algorithm`` -- (default: 'greenberg') a string, either 'greenberg' 

or 'stevens', specifying whether to use 

the lifting algorithm of M.Greenberg or that of Pollack--Stevens. 

The latter one solves the difference equation, which is not needed. The 

option to use Pollack--Stevens' algorithm here is just for historical reasons. 

 

OUTPUT: 

 

- An overconvergent modular symbol whose specialization 

equals self up to some Eisenstein error. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: f = E.pollack_stevens_modular_symbol() 

sage: f._lift_to_OMS(11,4,Qp(11,4)) 

Modular symbol of level 11 with values in Space of 11-adic distributions with k=0 action and precision cap 4 

""" 

D = {} 

manin = self.parent().source() 

MSS = self.parent()._lift_parent_space(p, M, new_base_ring) 

if algorithm == 'greenberg': 

for g in manin.gens(): 

D[g] = self._map[g].lift(p, M, new_base_ring) 

elif algorithm == 'stevens': 

half = ZZ(1) / ZZ(2) 

for g in manin.gens()[1:]: 

twotor = g in manin.reps_with_two_torsion() 

threetor = g in manin.reps_with_three_torsion() 

if twotor: 

# See [PS] section 4.1 

gam = manin.two_torsion_matrix(g) 

mu = self._map[g].lift(p, M, new_base_ring) 

D[g] = (mu - mu * gam) * half 

elif threetor: 

# See [PS] section 4.1 

gam = manin.three_torsion_matrix(g) 

mu = self._map[g].lift(p, M, new_base_ring) 

D[g] = (2 * mu - mu * gam - mu * (gam ** 2)) * half 

else: 

# no two or three torsion 

D[g] = self._map[g].lift(p, M, new_base_ring) 

 

t = self.parent().coefficient_module().lift(p, M, new_base_ring).zero() 

## This loops adds up around the boundary of fundamental 

## domain except the two vertical lines 

for g in manin.gens()[1:]: 

twotor = g in manin.reps_with_two_torsion() 

threetor = g in manin.reps_with_three_torsion() 

if twotor or threetor: 

t = t - D[g] 

else: 

t += D[g] * manin.gammas[g] - D[g] 

## t now should be sum Phi(D_i) | (gamma_i - 1) - sum 

## Phi(D'_i) - sum Phi(D''_i) 

 

## (Here I'm using the opposite sign convention of [PS1] 

## regarding D'_i and D''_i) 

 

D[manin.gen(0)] = -t.solve_difference_equation() # Check this! 

else: 

raise NotImplementedError 

 

return MSS(D) 

 

def _find_aq(self, p, M, check): 

r""" 

Helper function for finding Hecke eigenvalue `aq` for a prime `q` 

not equal to `p`. This is called in the case when `alpha = 1 (mod p^M)` 

(with `alpha` a `U_p`-eigenvalue), which creates the need to use 

other Hecke eigenvalues (and `alpha`s), because of division by `(alpha - 1)`. 

 

INPUT: 

 

- ``p`` -- working prime 

 

- ``M`` -- precision 

 

- ``check`` -- checks that ``self`` is a `T_q` eigensymbol 

 

OUTPUT: 

 

Tuple ``(q, aq, eisenloss)``, with 

 

- ``q`` -- a prime not equal to `p` 

 

- ``aq`` -- Hecke eigenvalue at `q` 

 

- ``eisenloss`` -- the `p`-adic valuation of `a_q - q^{k+1} - 1` 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: f = E.pollack_stevens_modular_symbol() 

sage: f._find_aq(5,10,True) 

(2, -2, 1) 

""" 

N = self.parent().level() 

q = ZZ(2) 

k = self.parent().weight() 

aq = self.Tq_eigenvalue(q, check=check) 

eisenloss = (aq - q ** (k + 1) - 1).valuation(p) 

while ((q == p) or (N % q == 0) or (eisenloss >= M)) and (q < 50): 

q = next_prime(q) 

aq = self.Tq_eigenvalue(q, check=check) 

if q != p: 

eisenloss = (aq - q ** (k + 1) - 1).valuation(p) 

else: 

eisenloss = (aq - 1).valuation(p) 

if q >= 50: 

raise ValueError("The symbol appears to be eisenstein -- " 

"not implemented yet") 

return q, aq, eisenloss 

 

def _find_extraprec(self, p, M, alpha, check): 

r""" 

Find the extra precision needed to account for: 

 

1) The denominators in the Hecke eigenvalue 

2) the denominators appearing when solving the difference equation, 

3) those denominators who might be also present in self. 

 

INPUT : 

 

- ``p`` -- working prime 

- ``M`` -- precision 

- ``alpha`` -- the Up-eigenvalue 

- ``check`` -- whether to check that ``self`` is a `T_q` eigensymbol 

 

OUTPUT : 

 

A tuple (newM, eisenloss, q, aq), where ``newM`` is the new precision, `q` is 

a prime different from `p`, and ``aq`` is the eigenvalue of `T_q` of the eigensymbol. 

The value ``eisenloss`` is the loss of precision accounted for in the denominators of the Hecke 

eigenvalue. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: p = 5 

sage: M = 10 

sage: k = 0 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: alpha = phi.Tq_eigenvalue(p) 

sage: phi._find_extraprec(p,M,alpha,True) 

(13, 1, 2, -2) 

""" 

q, aq, eisenloss = self._find_aq(p, M, check) 

newM = M + eisenloss 

# We also need to add precision to account for denominators appearing while solving the difference equation. 

eplog = (newM - 1).exact_log(p) 

while eplog < (newM + eplog).exact_log(p): 

eplog = (newM + eplog).exact_log(p) 

verbose("M = %s, newM = %s, eplog=%s" % (M, newM, eplog), level=2) 

newM += eplog 

 

# We also need to add precision to account for denominators that might be present in self 

s = self.valuation(p) 

if s < 0: 

newM += -s 

return newM, eisenloss, q, aq 

 

 

def p_stabilize_and_lift(self, p, M, alpha=None, ap=None, 

new_base_ring=None, 

ordinary=True, algorithm='greenberg', eigensymbol=False, 

check=True): 

""" 

`p`-stabilize and lift self 

 

INPUT: 

 

- ``p`` -- prime, not dividing the level of self 

 

- ``M`` -- precision 

 

- ``alpha`` -- (default: None) the `U_p` eigenvalue, if known 

 

- ``ap`` -- (default: None) the Hecke eigenvalue at p (before stabilizing), if known 

 

- ``new_base_ring`` -- (default: None) if specified, force the resulting eigensymbol to take values in the given ring 

 

- ``ordinary`` -- (default: True) whether to return the ordinary 

(at ``p``) eigensymbol. 

 

- ``algorithm`` -- (default: 'greenberg') a string, either 'greenberg' 

or 'stevens', specifying whether to use 

the lifting algorithm of M.Greenberg or that of Pollack--Stevens. 

The latter one solves the difference equation, which is not needed. The 

option to use Pollack--Stevens' algorithm here is just for historical reasons. 

 

- ``eigensymbol`` -- (default: False) if True, return an overconvergent eigensymbol. Otherwise just perform a naive lift 

 

- ``check`` -- (default: True) whether to perform extra sanity checks 

 

OUTPUT: 

 

`p`-stabilized and lifted version of self. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a') 

sage: f = E.pollack_stevens_modular_symbol() 

sage: g = f.p_stabilize_and_lift(3,10) # long time 

sage: g.Tq_eigenvalue(5) # long time 

1 + O(3^10) 

sage: g.Tq_eigenvalue(7) # long time 

1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + 2*3^8 + 2*3^9 + O(3^10) 

sage: g.Tq_eigenvalue(3) # long time 

2 + 3^2 + 2*3^3 + 2*3^4 + 2*3^6 + 3^8 + 2*3^9 + O(3^10) 

""" 

if check: 

p = self._get_prime(p, alpha) 

k = self.parent().weight() 

M = ZZ(M) 

# alpha will be the eigenvalue of Up 

M0 = M + 1 

if alpha is None: 

alpha, new_base_ring, newM, eisenloss, q, aq = self._find_alpha(p, k, M0, ap, new_base_ring, ordinary, check) 

if new_base_ring is None: 

new_base_ring = alpha.parent() 

newM, eisenloss, q, aq = self._find_extraprec(p, M0, alpha, check) 

if hasattr(new_base_ring, 'precision_cap') and newM > new_base_ring.precision_cap(): 

raise ValueError("Not enough precision in new base ring") 

 

# Now we can stabilize 

self = self.p_stabilize(p=p, alpha=alpha, ap=ap, M=newM, 

new_base_ring=new_base_ring, check=check) 

# And use the standard lifting function for eigensymbols 

Phi = self._lift_to_OMS(p, newM, new_base_ring, algorithm) 

Phi = _iterate_Up(Phi, p=p, M=newM, ap=alpha, q=q, aq=aq, check=check) 

Phi = Phi.reduce_precision(M) 

return Phi._normalize(include_zeroth_moment = True) 

 

 

class PSModularSymbolElement_dist(PSModularSymbolElement): 

 

def reduce_precision(self, M): 

r""" 

Only hold on to `M` moments of each value of self 

 

EXAMPLES:: 

 

sage: D = OverconvergentDistributions(0, 5, 10) 

sage: M = PollackStevensModularSymbols(Gamma0(5), coefficients=D) 

sage: f = M(1) 

sage: f.reduce_precision(1) 

Modular symbol of level 5 with values in Space of 5-adic distributions with k=0 action and precision cap 10 

""" 

return self.__class__(self._map.reduce_precision(M), self.parent(), 

construct=True) 

 

def precision_relative(self): 

r""" 

Return the number of moments of each value of self 

 

EXAMPLES:: 

 

sage: D = OverconvergentDistributions(0, 5, 10) 

sage: M = PollackStevensModularSymbols(Gamma0(5), coefficients=D) 

sage: f = M(1) 

sage: f.precision_relative() 

1 

""" 

return min([len(a._moments) for a in self._map]) 

 

 

def specialize(self, new_base_ring=None): 

r""" 

Return the underlying classical symbol of weight `k` - i.e., 

applies the canonical map `D_k \to Sym^k` to all values of 

self. 

 

EXAMPLES:: 

 

sage: D = OverconvergentDistributions(0, 5, 10); M = PollackStevensModularSymbols(Gamma0(5), coefficients=D); M 

Space of overconvergent modular symbols for Congruence Subgroup Gamma0(5) with sign 0 

and values in Space of 5-adic distributions with k=0 action and precision cap 10 

sage: f = M(1) 

sage: f.specialize() 

Modular symbol of level 5 with values in Sym^0 Z_5^2 

sage: f.specialize().values() 

[1 + O(5), 1 + O(5), 1 + O(5)] 

sage: f.values() 

[1 + O(5), 1 + O(5), 1 + O(5)] 

sage: f.specialize().parent() 

Space of modular symbols for Congruence Subgroup Gamma0(5) with sign 0 and values in Sym^0 Z_5^2 

sage: f.specialize().parent().coefficient_module() 

Sym^0 Z_5^2 

sage: f.specialize().parent().coefficient_module().is_symk() 

True 

sage: f.specialize(Qp(5,20)) 

Modular symbol of level 5 with values in Sym^0 Q_5^2 

""" 

if new_base_ring is None: 

new_base_ring = self.base_ring() 

return self.__class__(self._map.specialize(new_base_ring), 

self.parent()._specialize_parent_space(new_base_ring), construct=True) 

 

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

""" 

Return the `p`-adic L-series of this modular symbol. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: phi = E.pollack_stevens_modular_symbol() 

sage: L = phi.lift(37, M=6, eigensymbol=True).padic_lseries(); L # long time 

37-adic L-series of Modular symbol of level 37 with values in Space of 37-adic distributions with k=0 action and precision cap 7 

sage: L.series(2) # long time 

O(37^6) + (4 + 37 + 36*37^2 + 19*37^3 + 21*37^4 + O(37^5))*T + O(T^2) 

""" 

from sage.modular.pollack_stevens.padic_lseries import pAdicLseries 

return pAdicLseries(self, *args, **kwds)