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

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595

1596

1597

1598

1599

1600

1601

1602

1603

1604

1605

1606

1607

1608

1609

1610

1611

1612

1613

1614

1615

1616

1617

1618

1619

1620

1621

1622

1623

1624

1625

1626

1627

1628

1629

1630

1631

1632

1633

1634

1635

1636

1637

1638

1639

1640

1641

1642

1643

1644

1645

1646

1647

1648

1649

1650

1651

1652

1653

1654

1655

1656

1657

1658

1659

1660

1661

1662

1663

1664

1665

1666

1667

1668

1669

1670

1671

1672

1673

1674

1675

1676

1677

1678

1679

1680

1681

1682

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696

1697

1698

1699

1700

1701

1702

1703

1704

1705

1706

1707

1708

1709

1710

1711

1712

1713

1714

1715

1716

1717

1718

1719

1720

1721

1722

1723

1724

1725

1726

1727

1728

1729

1730

1731

1732

1733

1734

1735

1736

1737

1738

1739

1740

1741

1742

1743

1744

1745

1746

1747

1748

1749

1750

1751

1752

1753

1754

1755

1756

1757

1758

1759

1760

1761

1762

1763

1764

1765

1766

1767

1768

1769

1770

1771

1772

1773

1774

1775

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787

1788

1789

1790

1791

1792

1793

1794

1795

1796

1797

1798

1799

1800

1801

1802

1803

1804

1805

1806

1807

1808

1809

1810

1811

1812

1813

1814

1815

1816

1817

1818

1819

1820

1821

1822

1823

1824

1825

1826

1827

1828

1829

1830

1831

1832

1833

1834

1835

1836

1837

1838

1839

1840

1841

1842

1843

1844

1845

1846

1847

1848

1849

1850

1851

1852

1853

1854

1855

1856

1857

1858

1859

1860

1861

1862

1863

1864

1865

1866

1867

1868

1869

1870

1871

1872

1873

1874

1875

1876

1877

1878

1879

1880

1881

1882

1883

1884

1885

1886

1887

1888

1889

1890

1891

1892

1893

1894

1895

1896

1897

1898

1899

1900

1901

1902

1903

1904

1905

1906

1907

1908

1909

1910

1911

1912

1913

1914

1915

1916

1917

1918

1919

1920

1921

1922

1923

1924

1925

1926

1927

1928

1929

1930

1931

1932

1933

1934

1935

1936

1937

1938

1939

1940

1941

1942

1943

1944

1945

1946

1947

1948

1949

1950

1951

1952

1953

1954

1955

1956

1957

1958

1959

1960

1961

1962

1963

1964

1965

1966

1967

1968

1969

1970

1971

1972

1973

1974

1975

1976

1977

1978

1979

1980

1981

1982

1983

1984

1985

1986

1987

1988

1989

1990

1991

1992

1993

1994

1995

1996

1997

1998

1999

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

2020

2021

2022

2023

2024

2025

2026

2027

2028

2029

2030

2031

2032

2033

2034

2035

2036

2037

2038

2039

2040

2041

2042

2043

2044

2045

2046

2047

2048

2049

2050

2051

2052

2053

2054

2055

2056

2057

2058

2059

2060

2061

2062

2063

2064

2065

2066

2067

2068

2069

2070

2071

2072

2073

2074

2075

2076

2077

2078

2079

2080

2081

2082

2083

2084

2085

2086

2087

2088

2089

2090

2091

2092

2093

2094

2095

2096

2097

2098

2099

2100

2101

2102

2103

2104

2105

2106

2107

2108

2109

2110

2111

2112

2113

2114

2115

2116

2117

2118

2119

2120

2121

2122

2123

2124

2125

2126

2127

2128

2129

2130

2131

2132

2133

2134

2135

2136

2137

2138

2139

2140

2141

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159

2160

2161

2162

2163

2164

2165

2166

2167

2168

2169

2170

2171

2172

2173

2174

2175

2176

2177

2178

2179

2180

2181

2182

2183

2184

2185

2186

2187

2188

2189

2190

2191

2192

2193

2194

2195

2196

2197

2198

2199

2200

2201

2202

2203

2204

2205

2206

2207

2208

2209

2210

2211

2212

2213

2214

2215

2216

2217

2218

2219

2220

2221

2222

2223

2224

2225

2226

2227

2228

2229

2230

2231

2232

2233

2234

2235

2236

2237

2238

2239

2240

2241

2242

2243

2244

2245

2246

2247

2248

2249

2250

2251

2252

2253

2254

2255

2256

2257

2258

2259

2260

2261

2262

2263

2264

2265

2266

2267

2268

2269

2270

2271

2272

2273

2274

2275

2276

2277

2278

2279

2280

2281

2282

2283

2284

2285

2286

2287

2288

2289

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300

2301

2302

2303

2304

2305

2306

2307

2308

2309

2310

2311

2312

2313

2314

2315

2316

2317

2318

2319

2320

2321

2322

2323

2324

2325

2326

2327

2328

2329

2330

2331

2332

2333

2334

2335

2336

2337

2338

2339

2340

2341

2342

2343

2344

2345

2346

2347

2348

2349

2350

2351

2352

2353

2354

2355

2356

2357

2358

2359

2360

2361

2362

2363

2364

2365

2366

2367

2368

2369

2370

2371

2372

2373

2374

2375

2376

2377

2378

2379

2380

2381

2382

2383

2384

2385

2386

2387

2388

2389

2390

2391

2392

2393

2394

2395

2396

2397

2398

2399

2400

2401

2402

2403

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428

2429

2430

2431

2432

2433

2434

2435

2436

2437

2438

2439

2440

2441

2442

2443

2444

2445

2446

2447

2448

2449

2450

2451

2452

2453

2454

2455

2456

2457

2458

2459

2460

2461

2462

2463

2464

2465

2466

2467

2468

2469

2470

2471

2472

2473

2474

2475

2476

2477

2478

2479

2480

2481

2482

2483

2484

2485

2486

2487

2488

2489

2490

2491

2492

2493

2494

2495

2496

2497

2498

2499

2500

2501

2502

2503

2504

2505

2506

2507

2508

2509

2510

2511

2512

2513

2514

2515

2516

2517

2518

2519

2520

2521

2522

2523

2524

2525

2526

2527

2528

2529

2530

2531

2532

2533

2534

2535

2536

2537

2538

2539

2540

2541

2542

2543

2544

2545

2546

2547

2548

2549

2550

2551

2552

2553

2554

2555

2556

2557

2558

2559

2560

2561

2562

2563

2564

2565

2566

2567

2568

2569

2570

2571

2572

2573

2574

2575

2576

2577

2578

2579

2580

2581

2582

2583

2584

2585

2586

2587

2588

2589

2590

2591

2592

2593

2594

2595

2596

2597

2598

2599

2600

2601

2602

2603

2604

2605

2606

2607

2608

2609

2610

2611

2612

2613

2614

2615

2616

2617

2618

2619

2620

2621

2622

2623

2624

2625

2626

2627

2628

2629

2630

2631

2632

2633

2634

2635

2636

2637

2638

2639

2640

2641

2642

2643

2644

2645

2646

2647

2648

2649

2650

2651

2652

2653

2654

2655

2656

2657

2658

2659

2660

2661

2662

2663

2664

2665

2666

2667

2668

2669

2670

2671

2672

2673

2674

2675

2676

2677

2678

2679

2680

2681

2682

2683

2684

2685

2686

2687

2688

2689

2690

2691

2692

2693

2694

2695

2696

2697

2698

2699

2700

2701

2702

2703

2704

2705

2706

2707

2708

2709

2710

2711

2712

2713

2714

2715

2716

2717

2718

2719

2720

2721

2722

2723

2724

2725

2726

2727

2728

2729

2730

2731

2732

2733

2734

2735

2736

2737

2738

2739

2740

2741

2742

2743

2744

2745

2746

2747

2748

2749

2750

2751

2752

2753

2754

2755

2756

2757

2758

2759

2760

2761

2762

2763

2764

2765

2766

2767

2768

2769

2770

2771

2772

2773

2774

2775

2776

2777

2778

2779

2780

2781

2782

2783

2784

2785

2786

2787

2788

2789

2790

2791

2792

2793

2794

2795

2796

2797

2798

2799

2800

2801

2802

2803

2804

2805

2806

2807

2808

2809

2810

2811

2812

2813

2814

2815

2816

2817

2818

2819

2820

2821

2822

2823

2824

2825

2826

2827

2828

2829

2830

2831

2832

2833

2834

2835

2836

2837

2838

2839

2840

2841

2842

2843

2844

2845

2846

2847

2848

2849

2850

2851

2852

2853

2854

2855

2856

2857

2858

2859

2860

2861

2862

2863

2864

2865

2866

2867

2868

2869

2870

2871

2872

2873

2874

2875

2876

2877

2878

2879

2880

2881

2882

2883

2884

2885

2886

2887

2888

2889

2890

2891

2892

2893

2894

2895

2896

2897

2898

2899

2900

2901

2902

2903

2904

2905

2906

2907

2908

2909

2910

2911

2912

2913

2914

2915

2916

2917

2918

2919

2920

2921

2922

2923

2924

2925

2926

2927

2928

2929

2930

2931

2932

2933

2934

2935

2936

2937

2938

2939

2940

2941

2942

2943

2944

2945

2946

2947

2948

2949

2950

2951

2952

2953

2954

2955

2956

2957

2958

2959

2960

2961

2962

2963

2964

2965

2966

2967

2968

2969

2970

2971

2972

2973

2974

2975

2976

2977

2978

2979

2980

2981

2982

2983

2984

2985

2986

2987

2988

2989

2990

2991

2992

2993

2994

2995

2996

2997

2998

2999

3000

3001

3002

3003

3004

3005

3006

3007

3008

3009

3010

3011

3012

3013

3014

3015

3016

3017

3018

3019

3020

3021

3022

3023

3024

3025

3026

3027

3028

3029

3030

3031

3032

3033

3034

3035

3036

3037

3038

3039

3040

3041

3042

3043

3044

3045

3046

3047

3048

3049

3050

3051

3052

3053

3054

3055

3056

3057

3058

3059

3060

3061

3062

3063

3064

3065

3066

3067

3068

3069

3070

3071

3072

3073

3074

3075

3076

3077

3078

3079

3080

3081

3082

3083

3084

3085

3086

3087

3088

3089

3090

3091

3092

3093

3094

3095

3096

3097

3098

3099

3100

3101

3102

3103

3104

3105

3106

3107

3108

3109

3110

3111

3112

3113

3114

3115

3116

3117

3118

3119

3120

3121

3122

3123

3124

3125

3126

3127

3128

3129

3130

3131

3132

3133

3134

3135

3136

3137

3138

3139

3140

3141

3142

3143

3144

3145

3146

3147

3148

3149

3150

3151

3152

3153

3154

3155

3156

3157

3158

3159

3160

3161

3162

3163

3164

3165

3166

3167

3168

3169

3170

3171

3172

3173

3174

3175

3176

3177

3178

3179

3180

3181

3182

3183

3184

3185

3186

3187

3188

3189

3190

3191

3192

3193

3194

3195

3196

3197

3198

3199

3200

3201

3202

3203

3204

3205

3206

3207

3208

3209

3210

3211

3212

3213

3214

3215

3216

3217

3218

3219

3220

3221

3222

3223

3224

3225

3226

3227

3228

3229

3230

3231

3232

3233

3234

3235

3236

3237

3238

3239

3240

3241

3242

3243

3244

3245

3246

3247

3248

3249

3250

3251

3252

3253

3254

3255

3256

3257

3258

3259

3260

3261

3262

3263

3264

3265

3266

3267

3268

3269

3270

3271

3272

3273

3274

3275

3276

3277

3278

3279

3280

3281

3282

3283

3284

3285

3286

3287

3288

3289

3290

3291

3292

3293

3294

3295

3296

3297

3298

3299

3300

3301

3302

3303

3304

3305

3306

3307

3308

3309

3310

3311

3312

3313

3314

3315

3316

3317

3318

3319

3320

3321

3322

3323

3324

3325

3326

3327

3328

3329

3330

3331

3332

3333

3334

3335

3336

3337

3338

3339

3340

3341

3342

3343

3344

3345

3346

3347

3348

3349

3350

3351

3352

3353

3354

3355

3356

3357

3358

3359

3360

3361

3362

3363

3364

3365

3366

3367

3368

3369

3370

3371

3372

3373

3374

3375

3376

3377

3378

3379

3380

3381

3382

3383

3384

3385

3386

3387

3388

3389

3390

3391

3392

3393

3394

3395

3396

3397

3398

3399

3400

3401

3402

3403

3404

3405

3406

3407

3408

3409

3410

3411

3412

3413

3414

3415

3416

3417

3418

3419

3420

3421

3422

3423

3424

3425

3426

3427

3428

3429

3430

3431

3432

3433

3434

3435

3436

3437

3438

3439

3440

3441

3442

3443

3444

3445

3446

3447

3448

3449

3450

3451

3452

3453

3454

3455

3456

3457

3458

3459

3460

3461

3462

3463

3464

3465

3466

3467

3468

3469

3470

3471

3472

3473

3474

3475

3476

3477

3478

3479

3480

3481

3482

3483

3484

3485

3486

3487

3488

3489

3490

3491

3492

3493

3494

3495

3496

3497

3498

3499

3500

3501

3502

3503

3504

3505

3506

3507

3508

3509

3510

3511

3512

3513

3514

3515

3516

3517

3518

3519

3520

3521

3522

3523

3524

3525

3526

3527

3528

3529

3530

3531

3532

3533

3534

3535

3536

3537

3538

3539

3540

3541

3542

3543

3544

3545

3546

3547

3548

3549

3550

3551

3552

3553

3554

3555

3556

3557

3558

3559

3560

3561

3562

3563

3564

3565

3566

3567

3568

3569

3570

3571

3572

3573

3574

3575

3576

3577

3578

3579

3580

3581

3582

3583

3584

3585

3586

3587

3588

3589

3590

3591

3592

3593

3594

3595

3596

3597

3598

3599

3600

3601

3602

3603

3604

3605

3606

3607

3608

3609

3610

3611

3612

3613

3614

3615

3616

3617

3618

3619

3620

3621

3622

3623

3624

3625

3626

3627

3628

3629

3630

3631

3632

3633

3634

3635

3636

3637

3638

3639

3640

3641

3642

3643

3644

3645

3646

3647

3648

3649

3650

3651

3652

3653

3654

3655

3656

3657

3658

3659

3660

3661

3662

3663

3664

3665

3666

3667

3668

3669

3670

3671

3672

3673

3674

3675

3676

3677

3678

3679

3680

3681

3682

3683

3684

3685

3686

3687

3688

3689

3690

3691

3692

3693

3694

3695

3696

3697

3698

3699

3700

3701

3702

3703

3704

3705

3706

3707

3708

3709

3710

3711

3712

3713

3714

3715

3716

3717

3718

3719

3720

3721

3722

3723

3724

3725

3726

3727

3728

3729

3730

3731

3732

3733

3734

3735

3736

3737

3738

3739

3740

3741

3742

3743

3744

3745

3746

3747

3748

3749

3750

3751

3752

3753

3754

3755

3756

3757

3758

3759

3760

3761

3762

3763

3764

3765

3766

3767

3768

3769

3770

3771

3772

3773

3774

3775

3776

3777

3778

3779

3780

3781

3782

3783

3784

3785

3786

3787

3788

3789

3790

3791

3792

3793

3794

3795

3796

3797

3798

3799

3800

3801

3802

3803

3804

3805

3806

3807

3808

3809

3810

3811

3812

3813

3814

3815

3816

3817

3818

3819

3820

3821

3822

3823

3824

3825

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

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

# Copyright (C) 2011 Cameron Franc and Marc Masdeu 

# 

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

# 

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

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

r""" 

Quotients of the Bruhat-Tits tree 

 

This package contains all the functionality described and developed in [FM]_. 

It allows for computations with fundamental domains of the Bruhat-Tits tree, 

under the action of arithmetic groups arising from units in definite 

quaternion algebras. 

 

EXAMPLES: 

 

Create the quotient attached to a maximal order of the quaternion algebra of 

discriminant `13`, at the prime `p = 5`. 

:: 

 

sage: Y = BruhatTitsQuotient(5, 13) 

 

We can query for its genus, as well as get it back as a graph:: 

 

sage: Y.genus() 

5 

sage: Y.get_graph() 

Multi-graph on 2 vertices 

 

The rest of functionality can be found in the docstrings below. 

 

REFERENCES: 

 

.. [FM] Computing fundamental domains for the Bruhat-Tits tree for `\textrm{GL}_2(\QQ_p)`, 

`p`-adic automorphic forms, and the canonical embedding of Shimura curves 

Cameron Franc, Marc Masdeu 

LMS Journal of Computation and Mathematics (2014), volume 17, issue 01, pp. 1-23. 

""" 

 

from __future__ import print_function 

from __future__ import absolute_import 

from sage.rings.integer import Integer 

from sage.matrix.constructor import Matrix 

from sage.matrix.matrix_space import MatrixSpace 

from sage.structure.sage_object import SageObject 

from sage.rings.all import ZZ, Zmod, QQ 

from sage.misc.latex import latex 

from sage.rings.padics.precision_error import PrecisionError 

import collections 

from sage.misc.misc_c import prod 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.misc.cachefunc import cached_method 

from sage.arith.all import gcd, xgcd, kronecker_symbol, fundamental_discriminant 

from sage.rings.padics.all import Qp, Zp 

from sage.rings.finite_rings.finite_field_constructor import GF 

from sage.algebras.quatalg.all import QuaternionAlgebra 

from sage.quadratic_forms.all import QuadraticForm 

from sage.graphs.all import Graph 

from sage.libs.all import pari 

from sage.interfaces.all import magma 

from copy import copy 

from sage.plot.colors import rainbow 

from sage.rings.number_field.all import NumberField 

from sage.modular.arithgroup.all import Gamma0 

from sage.misc.lazy_attribute import lazy_attribute 

from sage.modular.dirichlet import DirichletGroup 

from sage.modular.arithgroup.congroup_gammaH import GammaH_constructor 

from sage.misc.misc import verbose 

 

 

class DoubleCosetReduction(SageObject): 

r""" 

Edges in the Bruhat-Tits tree are represented by cosets of 

matrices in `GL_2`. Given a matrix `x` in `GL_2`, this 

class computes and stores the data corresponding to the 

double coset representation of `x` in terms of a fundamental 

domain of edges for the action of the arithmetic group `\Gamma`. 

 

More precisely: 

 

Initialized with an element `x` of `GL_2(\ZZ)`, finds elements 

`\gamma` in `\Gamma`, `t` and an edge `e` such that `get=x`. It 

stores these values as members ``gamma``, ``label`` and functions 

``self.sign()``, ``self.t()`` and ``self.igamma()``, satisfying: 

 

- if ``self.sign() == +1``: 

``igamma() * edge_list[label].rep * t() == x`` 

 

- if ``self.sign() == -1``: 

``igamma() * edge_list[label].opposite.rep * t() == x`` 

 

It also stores a member called power so that: 

 

``p**(2*power) = gamma.reduced_norm()`` 

 

The usual decomposition `get=x` would be: 

 

- g = gamma / (p ** power) 

 

- e = edge_list[label] 

 

- t' = t * p ** power 

 

Here usual denotes that we have rescaled gamma to have unit 

determinant, and so that the result is honestly an element 

of the arithmetic quaternion group under consideration. In 

practice we store integral multiples and keep track of the 

powers of `p`. 

 

INPUT: 

 

- ``Y`` - BruhatTitsQuotient object in which to work 

- ``x`` - Something coercible into a matrix in `GL_2(\ZZ)`. In 

principle we should allow elements in `GL_2(\QQ_p)`, but it is 

enough to work with integral entries 

- ``extrapow`` - gets added to the power attribute, and it is 

used for the Hecke action. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import DoubleCosetReduction 

sage: Y = BruhatTitsQuotient(5, 13) 

sage: x = Matrix(ZZ,2,2,[123,153,1231,1231]) 

sage: d = DoubleCosetReduction(Y,x) 

sage: d.sign() 

-1 

sage: d.igamma()*Y._edge_list[d.label - len(Y.get_edge_list())].opposite.rep*d.t() == x 

True 

sage: x = Matrix(ZZ,2,2,[1423,113553,11231,12313]) 

sage: d = DoubleCosetReduction(Y,x) 

sage: d.sign() 

1 

sage: d.igamma()*Y._edge_list[d.label].rep*d.t() == x 

True 

 

AUTHORS: 

 

- Cameron Franc (2012-02-20) 

- Marc Masdeu 

""" 

 

def __init__(self, Y, x, extrapow=0): 

r""" 

Initialize and compute the reduction as a double coset. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import DoubleCosetReduction 

sage: Y = BruhatTitsQuotient(5, 13) 

sage: x = Matrix(ZZ,2,2,[123,153,1231,1231]) 

sage: d = DoubleCosetReduction(Y,x) 

sage: TestSuite(d).run() 

""" 

e1 = Y._BT.edge(x) 

try: 

g, label, parity = Y._cached_decomps[e1] 

except KeyError: 

valuation = e1.determinant().valuation(Y._p) 

parity = valuation % 2 

v1 = Y._BT.target(e1) 

v = Y.fundom_rep(v1) 

g, e = Y._find_equivalent_edge(e1, v.entering_edges, 

valuation=valuation) 

label = e.label 

Y._cached_decomps[e1] = (g, label, parity) 

 

self._parent = Y 

self.parity = parity 

self._num_edges = len(Y.get_edge_list()) 

self.label = label + parity * self._num_edges 

# The label will encode whether it is an edge or its opposite ! 

self.gamma = g[0] 

self.x = x 

self.power = g[1] + extrapow 

self._t_prec = -1 

self._igamma_prec = -1 

 

def _repr_(self): 

r""" 

Return the representation of self as a string. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import DoubleCosetReduction 

sage: Y = BruhatTitsQuotient(5, 13) 

sage: x = Matrix(ZZ,2,2,[123,153,1231,1231]) 

sage: DoubleCosetReduction(Y,x) 

Double coset data (-1, [(4), (5), (-4), (-4)], 8) 

""" 

return "Double coset data (%s, %s, %s)"%(self.sign(), list(self.gamma), self.label) 

 

def __eq__(self, other): 

""" 

Return self == other 

 

TESTS:: 

 

sage: from sage.modular.btquotients.btquotient import DoubleCosetReduction 

sage: Y = BruhatTitsQuotient(5, 13) 

sage: x = Matrix(ZZ,2,2,[123,153,1231,1231]) 

sage: d1 = DoubleCosetReduction(Y,x) 

sage: d1 == d1 

True 

""" 

if self._parent != other._parent: 

return False 

if self.parity != other.parity: 

return False 

if self._num_edges != other._num_edges: 

return False 

if self.label != other.label: 

return False 

if self.gamma != other.gamma: 

return False 

if self.x != other.x: 

return False 

if self.power != other.power: 

return False 

if self._t_prec != other._t_prec: 

return False 

if self._igamma_prec != other._igamma_prec: 

return False 

return True 

 

def __ne__(self, other): 

""" 

Return self != other 

 

TESTS:: 

 

sage: from sage.modular.btquotients.btquotient import DoubleCosetReduction 

sage: Y = BruhatTitsQuotient(5, 13) 

sage: x = Matrix(ZZ,2,2,[123,153,1231,1231]) 

sage: d1 = DoubleCosetReduction(Y,x) 

sage: d1 != d1 

False 

""" 

return not self.__eq__(other) 

 

def sign(self): 

r""" 

The direction of the edge. 

 

The Bruhat Tits quotients are directed graphs but we only store 

half the edges (we treat them more like unordered graphs). 

The sign tells whether the matrix self.x is equivalent to the 

representative in the quotient (sign = +1), or to the 

opposite of one of the representatives (sign = -1). 

 

OUTPUT : 

 

an int that is +1 or -1 according to the sign of self 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import DoubleCosetReduction 

sage: Y = BruhatTitsQuotient(3, 11) 

sage: x = Matrix(ZZ,2,2,[123,153,1231,1231]) 

sage: d = DoubleCosetReduction(Y,x) 

sage: d.sign() 

-1 

sage: d.igamma()*Y._edge_list[d.label - len(Y.get_edge_list())].opposite.rep*d.t() == x 

True 

sage: x = Matrix(ZZ,2,2,[1423,113553,11231,12313]) 

sage: d = DoubleCosetReduction(Y,x) 

sage: d.sign() 

1 

sage: d.igamma()*Y._edge_list[d.label].rep*d.t() == x 

True 

""" 

if self.parity == 0: 

return 1 

else: 

return -1 

 

def igamma(self, embedding=None, scale=1): 

r""" 

Image under gamma. 

 

Elements of the arithmetic group can be regarded as elements 

of the global quaternion order, and hence may be represented 

exactly. This function computes the image of such an element 

under the local splitting and returns the corresponding `p`-adic 

approximation. 

 

INPUT: 

 

- ``embedding`` - an integer, or a function (default: 

none). If ``embedding`` is None, then the image of 

``self.gamma`` under the local splitting associated to 

``self.Y`` is used. If ``embedding`` is an integer, then 

the precision of the local splitting of self.Y is raised 

(if necessary) to be larger than this integer, and this 

new local splitting is used. If a function is passed, then 

map ``self.gamma`` under ``embedding``. 

- ``scale`` -- (default: 1) scaling factor applied to the output 

 

OUTPUT: 

 

a 2x2 matrix with `p`-adic entries encoding the image of ``self`` 

under the local splitting 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import DoubleCosetReduction 

sage: Y = BruhatTitsQuotient(7, 11) 

sage: d = DoubleCosetReduction(Y,Matrix(ZZ,2,2,[123,45,88,1])) 

sage: d.igamma() 

[6 + 6*7 + 6*7^2 + 6*7^3 + 6*7^4 + O(7^5) O(7^5)] 

[ O(7^5) 6 + 6*7 + 6*7^2 + 6*7^3 + 6*7^4 + O(7^5)] 

sage: d.igamma(embedding = 7) 

[6 + 6*7 + 6*7^2 + 6*7^3 + 6*7^4 + 6*7^5 + 6*7^6 + O(7^7) O(7^7)] 

[ O(7^7) 6 + 6*7 + 6*7^2 + 6*7^3 + 6*7^4 + 6*7^5 + 6*7^6 + O(7^7)] 

""" 

Y = self._parent 

if embedding is None: 

prec = Y._prec 

else: 

try: 

# The user wants higher precision 

prec = ZZ(embedding) 

except TypeError: 

# The user knows what she is doing, so let it go 

return embedding(self.gamma) 

if prec > self._igamma_prec: 

self._igamma_prec = prec 

self._cached_igamma = Y.embed_quaternion(self.gamma, exact=False, 

prec=prec) 

return scale * self._cached_igamma 

 

def t(self, prec=None): 

r""" 

Return the 't part' of the decomposition using the rest of the data. 

 

INPUT: 

 

- ``prec`` - a `p`-adic precision that t will be computed 

to. Defaults to the default working precision of self. 

 

OUTPUT: 

 

a 2x2 `p`-adic matrix with entries of 

precision ``prec`` that is the 't-part' of the decomposition of 

self 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import DoubleCosetReduction 

sage: Y = BruhatTitsQuotient(5, 13) 

sage: x = Matrix(ZZ,2,2,[123,153,1231,1232]) 

sage: d = DoubleCosetReduction(Y,x) 

sage: t = d.t(20) 

sage: t[1,0].valuation() > 0 

True 

""" 

Y = self._parent 

if prec is None: 

prec = max([5, Y._prec]) 

if self._t_prec >= prec: 

return self._cached_t 

e = Y._edge_list[self.label % self._num_edges] 

tmp_prec = prec 

while self._t_prec < prec: 

if self.parity == 0: 

self._cached_t = (self.igamma(tmp_prec) * e.rep).inverse() * self.x 

# assert self._cached_t[1, 0].valuation()>self._cached_t[1,1].valuation() 

else: 

self._cached_t = (self.igamma(tmp_prec) * e.opposite.rep).inverse() * self.x 

# assert self._cached_t[1, 0].valuation()>self._cached_t[1,1].valuation() 

tmp_prec += 1 

self._t_prec = min([xx.precision_absolute() 

for xx in self._cached_t.list()]) 

return self._cached_t 

 

 

class BruhatTitsTree(SageObject, UniqueRepresentation): 

r""" 

An implementation of the Bruhat-Tits tree for `GL_2(\QQ_p)`. 

 

INPUT: 

 

- ``p`` - a prime number. The corresponding tree is then `p+1` regular 

 

EXAMPLES: 

 

We create the tree for `GL_2(\QQ_5)`:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 5 

sage: T = BruhatTitsTree(p) 

sage: m = Matrix(ZZ,2,2,[p**5,p**2,p**3,1+p+p*3]) 

sage: e = T.edge(m); e 

[ 0 25] 

[625 21] 

sage: v0 = T.origin(e); v0 

[ 25 0] 

[ 21 125] 

sage: v1 = T.target(e); v1 

[ 25 0] 

[ 21 625] 

sage: T.origin(T.opposite(e)) == v1 

True 

sage: T.target(T.opposite(e)) == v0 

True 

 

A value error is raised if a prime is not passed:: 

 

sage: T = BruhatTitsTree(4) 

Traceback (most recent call last): 

... 

ValueError: Input (4) must be prime 

 

AUTHORS: 

 

- Marc Masdeu (2012-02-20) 

""" 

def __init__(self, p): 

""" 

Initialize a BruhatTitsTree object for a given prime `p` 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: T = BruhatTitsTree(17) 

sage: TestSuite(T).run() 

""" 

if not(ZZ(p).is_prime()): 

raise ValueError('Input (%s) must be prime' % p) 

self._p = ZZ(p) 

self._Mat_22 = MatrixSpace(ZZ, 2, 2) 

self._mat_p001 = self._Mat_22([self._p, 0, 0, 1]) 

 

def target(self, e, normalized=False): 

r""" 

Return the target vertex of the edge represented by the 

input matrix e. 

 

INPUT: 

 

- ``e`` - a 2x2 matrix with integer entries 

 

- ``normalized`` - boolean (default: false). If True 

then the input matrix is assumed to be normalized. 

 

OUTPUT: 

 

- ``e`` - 2x2 integer matrix representing the target of 

the input edge 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: T = BruhatTitsTree(7) 

sage: T.target(Matrix(ZZ,2,2,[1,5,8,9])) 

[1 0] 

[0 1] 

""" 

if normalized: 

#then the normalized target vertex is also M and we save some 

#row reductions with a simple return 

return e 

else: 

#must normalize the target vertex representative 

return self.vertex(e) 

 

def origin(self, e, normalized=False): 

r""" 

Return the origin vertex of the edge represented by the 

input matrix e. 

 

INPUT: 

 

- ``e`` - a 2x2 matrix with integer entries 

 

- ``normalized`` - boolean (default: false). If True 

then the input matrix M is assumed to be normalized 

 

OUTPUT: 

 

- ``e`` - A 2x2 integer matrix 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: T = BruhatTitsTree(7) 

sage: T.origin(Matrix(ZZ,2,2,[1,5,8,9])) 

[1 0] 

[1 7] 

""" 

if not normalized: 

#then normalize 

x = copy(self.edge(e)) 

else: 

x = copy(e) 

x.swap_columns(0, 1) 

x.rescale_col(0, self._p) 

return self.vertex(x) 

 

def edge(self, M): 

r""" 

Normalize a matrix to the correct normalized edge 

representative. 

 

INPUT: 

 

- ``M`` - a 2x2 integer matrix 

 

OUTPUT: 

 

- ``newM`` - a 2x2 integer matrix 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: T = BruhatTitsTree(3) 

sage: T.edge( Matrix(ZZ,2,2,[0,-1,3,0]) ) 

[0 1] 

[3 0] 

""" 

p = self._p 

# M_orig = M 

 

def lift(a): 

""" 

Naively approximate a p-adic integer by a positive integer. 

 

INPUT: 

 

- ``a`` - a p-adic integer. 

 

OUTPUT: 

 

An integer. 

 

EXAMPLES:: 

 

sage: x = Zp(3)(-17) 

sage: lift(x) 

3486784384 

""" 

try: 

return ZZ(a.lift()) 

except AttributeError: 

return ZZ(a) 

 

if M.base_ring() is not ZZ: 

M = M.apply_map(lift, R=ZZ) 

 

v = min([M[i, j].valuation(p) for i in range(2) for j in range(2)]) 

 

if v != 0: 

M = p ** (-v) * M 

 

det = M.determinant() 

if not det: 

raise NotImplementedError("matrix must be invertible") 

 

m00 = M[0, 0].valuation(p) 

m01 = M[0, 1].valuation(p) 

 

if m00 <= m01: 

tmp = det.valuation(p) - m00 

bigpower = p ** (1 + tmp) 

r = M[0, 0] 

if r != 0: 

r /= p ** m00 

g, s, _ = xgcd(r, bigpower) 

r = (M[1, 0] * s) % bigpower 

newM = self._Mat_22([p ** m00, 0, r, bigpower / p]) 

else: 

tmp = det.valuation(p) - m01 

bigpower = p ** tmp 

r = M[0, 1] 

if r != 0: 

r /= p ** m01 

g, s, _ = xgcd(r, bigpower) 

r = (ZZ(M[1, 1]) * s) % bigpower 

newM = self._Mat_22([0, p ** m01, bigpower, r]) 

newM.set_immutable() 

# assert self.is_in_group(M_orig.inverse()*newM, as_edge = True) 

return newM 

 

def vertex(self, M): 

r""" 

Normalize a matrix to the corresponding normalized 

vertex representative 

 

INPUT: 

 

- ``M`` - 2x2 integer matrix 

 

OUTPUT: 

 

- a 2x2 integer matrix 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 5 

sage: T = BruhatTitsTree(p) 

sage: m = Matrix(ZZ,2,2,[p**5,p**2,p**3,1+p+p*3]) 

sage: e = T.edge(m) 

sage: t = m.inverse()*e 

sage: scaling = Qp(p,20)(t.determinant()).sqrt() 

sage: t = 1/scaling * t 

sage: min([t[ii,jj].valuation(p) for ii in range(2) for jj in range(2)]) >= 0 

True 

sage: t[1,0].valuation(p) > 0 

True 

""" 

p = self._p 

# M_orig = M 

 

def lift(a): 

try: 

return ZZ(a.lift()) 

except AttributeError: 

return ZZ(a) 

 

if M.base_ring() is not ZZ: 

M = M.apply_map(lift, R=ZZ) 

 

v = min([M[i, j].valuation(p) for i in range(2) for j in range(2)]) 

 

if v != 0: 

M = p ** (-v) * M 

m00 = M[0, 0].valuation(p) 

m01 = M[0, 1].valuation(p) 

if m01 < m00: 

M = copy(M) 

M.swap_columns(0, 1) 

m00 = m01 

m10 = M[1, 0].valuation(p) 

tmp = M.determinant().valuation(p) - m00 

bigpower = p ** tmp 

r = M[0, 0] 

if r != 0: 

r /= p ** m00 

# r = ZZ(r) % bigpower 

g, s, _ = xgcd(r, bigpower) 

m10 = M[1, 0] % bigpower 

r = (m10 * s) % bigpower 

newM = self._Mat_22([p ** m00, 0, r, bigpower]) 

newM.set_immutable() 

# assert self.is_in_group(M_orig.inverse()*newM, as_edge=False) 

return newM 

 

def edges_leaving_origin(self): 

r""" 

Find normalized representatives for the `p+1` edges 

leaving the origin vertex corresponding to the homothety class 

of `\ZZ_p^2`. These are cached. 

 

OUTPUT: 

 

- A list of size `p+1` of 2x2 integer matrices 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: T = BruhatTitsTree(3) 

sage: T.edges_leaving_origin() 

[ 

[0 1] [3 0] [0 1] [0 1] 

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

] 

""" 

try: 

return self._edges_leaving_origin 

except AttributeError: 

p = self._p 

self._edges_leaving_origin = [self.edge(self._Mat_22([0, -1, p, 0]))] 

self._edges_leaving_origin.extend([self.edge(self._Mat_22([p, i, 0, 1])) for i in range(p)]) 

return self._edges_leaving_origin 

 

def edge_between_vertices(self, v1, v2, normalized=False): 

r""" 

Compute the normalized matrix rep. for the edge 

passing between two vertices. 

 

INPUT: 

 

- ``v1`` - 2x2 integer matrix 

 

- ``v2`` - 2x2 integer matrix 

 

- ``normalized`` - boolean (default: False), whether the 

vertices are normalized. 

 

OUTPUT: 

 

- 2x2 integer matrix, representing the edge from ``v1`` to 

``v2``. If ``v1`` and ``v2`` are not at distance `1`, raise 

a ``ValueError``. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 7 

sage: T = BruhatTitsTree(p) 

sage: v1 = T.vertex(Matrix(ZZ,2,2,[p,0,0,1])); v1 

[7 0] 

[0 1] 

sage: v2 = T.vertex(Matrix(ZZ,2,2,[p,1,0,1])); v2 

[1 0] 

[1 7] 

sage: T.edge_between_vertices(v1,v2) 

Traceback (most recent call last): 

... 

ValueError: Vertices are not adjacent. 

 

sage: v3 = T.vertex(Matrix(ZZ,2,2,[1,0,0,1])); v3 

[1 0] 

[0 1] 

sage: T.edge_between_vertices(v1,v3) 

[0 1] 

[1 0] 

""" 

if normalized: 

v22 = v2 

else: 

v22 = self.vertex(v2) 

for e in self.leaving_edges(v1): 

if self.target(e) == v22: 

return e 

raise ValueError('Vertices are not adjacent.') 

 

def leaving_edges(self, M): 

r""" 

Return edges leaving a vertex 

 

INPUT: 

 

- ``M`` - 2x2 integer matrix 

 

OUTPUT: 

 

List of size `p+1` of 2x2 integer matrices 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 7 

sage: T = BruhatTitsTree(p) 

sage: T.leaving_edges(Matrix(ZZ,2,2,[1,0,0,1])) 

[ 

[0 1] [7 0] [0 1] [0 1] [0 1] [0 1] [0 1] [0 1] 

[7 0], [0 1], [7 1], [7 4], [7 5], [7 2], [7 3], [7 6] 

] 

""" 

return [self.edge(M * A) for A in self.edges_leaving_origin()] 

 

def opposite(self, e): 

r""" 

This function returns the edge oriented oppositely to a 

given edge. 

 

INPUT: 

 

- ``e`` - 2x2 integer matrix 

 

OUTPUT: 

 

2x2 integer matrix 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 7 

sage: T = BruhatTitsTree(p) 

sage: e = Matrix(ZZ,2,2,[1,0,0,1]) 

sage: T.opposite(e) 

[0 1] 

[7 0] 

sage: T.opposite(T.opposite(e)) == e 

True 

""" 

x = copy(e) 

x.swap_columns(0, 1) 

x.rescale_col(0, self._p) 

return self.edge(x) 

 

def entering_edges(self, v): 

r""" 

This function returns the edges entering a given vertex. 

 

INPUT: 

 

- ``v`` - 2x2 integer matrix 

 

OUTPUT: 

 

A list of size `p+1` of 2x2 integer matrices 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 7 

sage: T = BruhatTitsTree(p) 

sage: T.entering_edges(Matrix(ZZ,2,2,[1,0,0,1])) 

[ 

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

[0 1], [1 0], [1 1], [4 1], [5 1], [2 1], [3 1], [6 1] 

] 

""" 

return [self.opposite(e) for e in self.leaving_edges(v)] 

 

def subdivide(self, edgelist, level): 

r""" 

(Ordered) edges of self may be regarded as open balls in 

`P^1(\QQ_p)`. Given a list of edges, this function return a list 

of edges corresponding to the level-th subdivision of the 

corresponding opens. That is, each open ball of the input is 

broken up into `p^{\mbox{level}}` subballs of equal radius. 

 

INPUT: 

 

- ``edgelist`` - a list of edges 

 

- ``level`` - an integer 

 

OUTPUT: 

 

A list of 2x2 integer matrices 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 3 

sage: T = BruhatTitsTree(p) 

sage: T.subdivide([Matrix(ZZ,2,2,[p,0,0,1])],2) 

[ 

[27 0] [0 9] [0 9] [0 3] [0 3] [0 3] [0 3] [0 3] [0 3] 

[ 0 1], [3 1], [3 2], [9 1], [9 4], [9 7], [9 2], [9 5], [9 8] 

] 

""" 

if level < 0: 

return [] 

if level == 0: 

return [self._Mat_22(edge) for edge in edgelist] 

else: 

newEgood = [] 

for edge in edgelist: 

edge = self._Mat_22(edge) 

origin = self.origin(edge) 

newE = self.leaving_edges(self.target(edge)) 

newEgood.extend([e for e in newE if self.target(e) != origin]) 

return self.subdivide(newEgood, level - 1) 

 

def get_balls(self, center=1, level=1): 

r""" 

Return a decomposition of `P^1(\QQ_p)` into compact 

open balls. 

 

Each vertex in the Bruhat-Tits tree gives a decomposition of 

`P^1(\QQ_p)` into `p+1` open balls. Each of these balls may 

be further subdivided, to get a finer decomposition. 

 

This function returns the decomposition of `P^1(\QQ_p)` 

corresponding to ``center`` into `(p+1)p^{\mbox{level}}` balls. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 2 

sage: T = BruhatTitsTree(p) 

sage: T.get_balls(Matrix(ZZ,2,2,[p,0,0,1]),1) 

[ 

[0 1] [0 1] [8 0] [0 4] [0 2] [0 2] 

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

] 

""" 

return self.subdivide(self.leaving_edges(center), level) 

 

def find_path(self, v, boundary=None): 

r""" 

Compute a path from a vertex to a given set of so-called 

boundary vertices, whose interior must contain the origin 

vertex. In the case that the boundary is not specified, it 

computes the geodesic between the given vertex and the origin. 

In the case that the boundary contains more than one vertex, 

it computes the geodesic to some point of the boundary. 

 

INPUT: 

 

- ``v`` - a 2x2 matrix representing a vertex ``boundary`` 

 

- a list of matrices (default: None). If ommitted, finds the 

geodesic from ``v`` to the central vertex. 

 

OUTPUT: 

 

An ordered list of vertices describing the geodesic from 

``v`` to ``boundary``, followed by the vertex in the boundary 

that is closest to ``v``. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 3 

sage: T = BruhatTitsTree(p) 

sage: T.find_path( Matrix(ZZ,2,2,[p^4,0,0,1]) ) 

( 

[[81 0] 

[ 0 1], [27 0] 

[ 0 1], [9 0] 

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

[0 1]] , [0 1] 

) 

sage: T.find_path( Matrix(ZZ,2,2,[p^3,0,134,p^2]) ) 

( 

[[27 0] 

[ 8 9], [27 0] 

[ 2 3], [27 0] 

[ 0 1], [9 0] 

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

[0 1]] , [0 1] 

) 

""" 

if boundary is None: 

m = self._Mat_22(1) 

m.set_immutable() 

boundary = {m: m} 

m = self._mat_p001 

new_v = self.vertex(v) 

chain = [] 

while new_v[1, 0] != 0 or new_v[0, 0].valuation(self._p) < new_v[1, 1].valuation(self._p): 

if new_v in boundary: 

return chain, boundary[new_v] 

chain.append(new_v) 

new_v = self.vertex(new_v * m) 

 

if new_v in boundary: 

return chain, boundary[new_v] 

 

while True: 

if new_v in boundary: 

return chain, boundary[new_v] 

chain.append(new_v) 

new_v = self._Mat_22([new_v[0, 0] / self._p, 0, 0, 1]) 

new_v.set_immutable() 

raise RuntimeError 

 

def find_containing_affinoid(self, z): 

r""" 

Return the vertex corresponding to the affinoid in the 

`p`-adic upper half plane that a given (unramified!) point 

reduces to. 

 

INPUT: 

 

- ``z`` - an element of an unramified extension of `\QQ_p` 

that is not contained in `\QQ_p`. 

 

OUTPUT: 

 

A 2x2 integer matrix representing a vertex of ``self``. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: T = BruhatTitsTree(5) 

sage: K.<a> = Qq(5^2,20) 

sage: T.find_containing_affinoid(a) 

[1 0] 

[0 1] 

sage: z = 5*a+3 

sage: v = T.find_containing_affinoid(z).inverse(); v 

[ 1 0] 

[-2/5 1/5] 

 

Note that the translate of ``z`` belongs to the standard 

affinoid. That is, it is a `p`-adic unit and its reduction 

modulo `p` is not in `\mathbb{F}_p`:: 

 

sage: gz = (v[0,0]*z+v[0,1])/(v[1,0]*z+v[1,1]); gz 

(a + 1) + O(5^19) 

sage: gz.valuation() == 0 

True 

""" 

#Assume z belongs to some extension of QQp. 

p = self._p 

if z.valuation() < 0: 

return self.vertex(self._Mat_22([0, 1, p, 0]) * self.find_containing_affinoid(1 / (p * z))) 

a = 0 

pn = 1 

val = z.valuation() 

L = [] 

for ii in range(val): 

L.append(0) 

L.extend(z.expansion()) 

for n in range(len(L)): 

if L[n] != 0: 

if len(L[n]) > 1: 

break 

if len(L[n]) > 0: 

a += pn * L[n][0] 

pn *= p 

return self.vertex(self._Mat_22([pn, a, 0, 1])) 

 

def find_geodesic(self, v1, v2, normalized=True): 

r""" 

This function computes the geodesic between two vertices 

 

INPUT: 

 

- ``v1`` - 2x2 integer matrix representing a vertex 

 

- ``v2`` - 2x2 integer matrix representing a vertex 

 

- ``normalized`` - boolean (default: True) 

 

OUTPUT: 

 

An ordered list of 2x2 integer matrices representing the vertices 

of the paths joining ``v1`` and ``v2``. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 3 

sage: T = BruhatTitsTree(p) 

sage: v1 = T.vertex( Matrix(ZZ,2,2,[p^3, 0, 1, p^1]) ); v1 

[27 0] 

[ 1 3] 

sage: v2 = T.vertex( Matrix(ZZ,2,2,[p,2,0,p]) ); v2 

[1 0] 

[6 9] 

sage: T.find_geodesic(v1,v2) 

[ 

[27 0] [27 0] [9 0] [3 0] [1 0] [1 0] [1 0] 

[ 1 3], [ 0 1], [0 1], [0 1], [0 1], [0 3], [6 9] 

] 

""" 

if not normalized: 

v1, v2 = self.vertex(v1), self.vertex(v2) 

gamma = v2 

vv = self.vertex(gamma.adjoint() * v1) 

chain, v0 = self.find_path(vv) 

return [self.vertex(gamma * x) for x in chain + [v0]] 

 

def find_covering(self, z1, z2, level=0): 

r""" 

Compute a covering of `P^1(\QQ_p)` adapted to a certain 

geodesic in self. 

 

More precisely, the `p`-adic upper half plane points ``z1`` 

and ``z2`` reduce to vertices `v_1`, `v_2`. 

The returned covering consists of all the edges leaving the 

geodesic from `v_1` to `v_2`. 

 

INPUT: 

 

- ``z1``, ``z2`` - unramified algebraic points of h_p 

 

OUTPUT: 

 

a list of 2x2 integer matrices representing edges of self 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import BruhatTitsTree 

sage: p = 3 

sage: K.<a> = Qq(p^2) 

sage: T = BruhatTitsTree(p) 

sage: z1 = a + a*p 

sage: z2 = 1 + a*p + a*p^2 - p^6 

sage: T.find_covering(z1,z2) 

[ 

[0 1] [3 0] [0 1] [0 1] [0 1] [0 1] 

[3 0], [0 1], [3 2], [9 1], [9 4], [9 7] 

] 

 

.. NOTE:: 

 

This function is used to compute certain Coleman integrals 

on `P^1`. That's why the input consists of two points of 

the `p`-adic upper half plane, but decomposes 

`P^1(\QQ_p)`. This decomposition is what allows us to 

represent the relevant integrand as a locally analytic 

function. The ``z1`` and ``z2`` appear in the integrand. 

""" 

v1 = self.find_containing_affinoid(z1) 

v2 = self.find_containing_affinoid(z2) 

vertex_set = [self._Mat_22(0)] 

vertex_set += self.find_geodesic(v1, v2) 

vertex_set += [self._Mat_22(0)] 

E = [] 

for ii in range(1, len(vertex_set) - 1): 

vv = vertex_set[ii] 

# m = vv.determinant().valuation(self._p) 

newE = self.leaving_edges(vv) 

for e in newE: 

targ = self.target(e) 

if targ != vertex_set[ii - 1] and targ != vertex_set[ii + 1]: 

E.extend(self.subdivide([e], level)) 

return E 

 

 

class Vertex(SageObject): 

r""" 

This is a structure to represent vertices of quotients of the 

Bruhat-Tits tree. It is useful to enrich the representation of 

the vertex as a matrix with extra data. 

 

INPUT: 

 

- ``p`` - a prime integer. 

 

- ``label`` - An integer which uniquely identifies this vertex. 

 

- ``rep`` - A 2x2 matrix in reduced form representing this 

vertex. 

 

- ``leaving_edges`` - (default: empty list) A list of edges 

leaving this vertex. 

 

- ``entering_edges`` - (default: empty list) A list of edges 

entering this vertex. 

 

- ``determinant`` - (default: None) The determinant of ``rep``, 

if known. 

 

- ``valuation`` - (default: None) The valuation of the 

determinant of ``rep``, if known. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import Vertex 

sage: v1 = Vertex(5,0,Matrix(ZZ,2,2,[1,2,3,18])) 

sage: v1.rep 

[ 1 2] 

[ 3 18] 

sage: v1.entering_edges 

[] 

 

AUTHORS: 

 

- Marc Masdeu (2012-02-20) 

""" 

def __init__(self, p, label, rep, leaving_edges=None, 

entering_edges=None, determinant=None, valuation=None): 

""" 

This initializes a structure to represent vertices of 

quotients of the Bruhat-Tits tree. It is useful to enrich the 

representation of the vertex as a matrix with extra data. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import Vertex 

sage: Y = BruhatTitsQuotient(5,13) 

sage: v1 = Vertex(5,0,Matrix(ZZ,2,2,[1,2,3,18])) 

sage: TestSuite(v1).run() 

""" 

if leaving_edges is None: 

leaving_edges = [] 

if entering_edges is None: 

entering_edges = [] 

if determinant is None: 

determinant = rep.determinant() 

if valuation is None: 

valuation = determinant.valuation(p) 

self.p = p 

self.label = label 

self.rep = rep 

self.rep.set_immutable() 

self.determinant = determinant 

self.valuation = valuation 

self.parity = valuation % 2 

self.leaving_edges = leaving_edges 

self.entering_edges = entering_edges 

 

def _repr_(self): 

r""" 

Return the representation of self as a string. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,5) 

sage: X.get_vertex_list()[0] 

Vertex of Bruhat-Tits tree for p = 3 

""" 

return "Vertex of Bruhat-Tits tree for p = %s" % (self.p) 

 

def __eq__(self, other): 

""" 

Return self == other 

 

TESTS:: 

 

sage: from sage.modular.btquotients.btquotient import Vertex 

sage: v1 = Vertex(7,0,Matrix(ZZ,2,2,[1,2,3,18])) 

sage: v1 == v1 

True 

""" 

if self.p != other.p: 

return False 

if self.label != other.label: 

return False 

if self.rep != other.rep: 

return False 

if self.determinant != other.determinant: 

return False 

if self.valuation != other.valuation: 

return False 

if self.parity != other.parity: 

return False 

return True 

 

def __ne__(self, other): 

""" 

Return self != other 

 

TESTS:: 

 

sage: from sage.modular.btquotients.btquotient import Vertex 

sage: v1 = Vertex(7,0,Matrix(ZZ,2,2,[1,2,3,18])) 

sage: v1 != v1 

False 

""" 

return not self.__eq__(other) 

 

 

class Edge(SageObject): 

r""" 

This is a structure to represent edges of quotients of the 

Bruhat-Tits tree. It is useful to enrich the representation of an 

edge as a matrix with extra data. 

 

INPUT: 

 

- ``p`` - a prime integer. 

 

- ``label`` - An integer which uniquely identifies this edge. 

 

- ``rep`` - A 2x2 matrix in reduced form representing this edge. 

 

- ``origin`` - The origin vertex of ``self``. 

 

- ``target`` - The target vertex of ``self``. 

 

- ``links`` - (Default: empty list) A list of elements of 

`\Gamma` which identify different edges in the Bruhat-Tits tree 

which are equivalent to ``self``. 

 

- ``opposite`` - (Default: None) The edge opposite to ``self`` 

 

- ``determinant`` - (Default: None) The determinant of ``rep``, 

if known. 

 

- ``valuation`` - (Default: None) The valuation of the 

determinant of ``rep``, if known. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import Edge, Vertex 

sage: v1 = Vertex(7,0,Matrix(ZZ,2,2,[1,2,3,18])) 

sage: v2 = Vertex(7,0,Matrix(ZZ,2,2,[3,2,1,18])) 

sage: e1 = Edge(7,0,Matrix(ZZ,2,2,[1,2,3,18]),v1,v2) 

sage: e1.rep 

[ 1 2] 

[ 3 18] 

 

AUTHORS: 

 

- Marc Masdeu (2012-02-20) 

""" 

def __init__(self, p, label, rep, origin, target, links=None, 

opposite=None, determinant=None, valuation=None): 

""" 

Representation for edges of quotients of the Bruhat-Tits 

tree. It is useful to enrich the representation of an edge as 

a matrix with extra data. 

 

EXAMPLES:: 

 

sage: from sage.modular.btquotients.btquotient import Edge 

sage: Y = BruhatTitsQuotient(5,11) 

sage: el = Y.get_edge_list() 

sage: e1 = el.pop() 

sage: e2 = Edge(5,e1.label,e1.rep,e1.origin,e1.target) 

sage: TestSuite(e2).run() 

""" 

if links is None: 

links = [] 

if determinant is None: 

determinant = rep.determinant() 

if valuation is None: 

valuation = determinant.valuation(p) 

self.p = p 

self.label = label 

self.rep = rep 

self.rep.set_immutable() 

self.origin = origin 

self.target = target 

self.links = links 

self.opposite = opposite 

self.determinant = determinant 

self.valuation = valuation 

self.parity = valuation % 2 

 

def _repr_(self): 

r""" 

Return the representation of self as a string. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,5) 

sage: X.get_edge_list()[0] 

Edge of Bruhat-Tits tree for p = 3 

""" 

return "Edge of Bruhat-Tits tree for p = %s" % (self.p) 

 

def __eq__(self, other): 

""" 

Return self == other 

 

TESTS:: 

 

sage: from sage.modular.btquotients.btquotient import Edge,Vertex 

sage: v1 = Vertex(7,0,Matrix(ZZ,2,2,[1,2,3,18])) 

sage: v2 = Vertex(7,0,Matrix(ZZ,2,2,[3,2,1,18])) 

sage: e1 = Edge(7,0,Matrix(ZZ,2,2,[1,2,3,18]),v1,v2) 

sage: e1 == e1 

True 

""" 

if self.p != other.p: 

return False 

if self.label != other.label: 

return False 

if self.rep != other.rep: 

return False 

if self.origin != other.origin: 

return False 

if self.target != other.target: 

return False 

if self.links != other.links: 

return False 

if self.opposite != other.opposite: 

return False 

if self.determinant != other.determinant: 

return False 

if self.valuation != other.valuation: 

return False 

if self.parity != other.parity: 

return False 

return True 

 

def __ne__(self, other): 

""" 

Return self != other 

 

TESTS:: 

 

sage: from sage.modular.btquotients.btquotient import Edge,Vertex 

sage: v1 = Vertex(7,0,Matrix(ZZ,2,2,[1,2,3,18])) 

sage: v2 = Vertex(7,0,Matrix(ZZ,2,2,[3,2,1,18])) 

sage: e1 = Edge(7,0,Matrix(ZZ,2,2,[1,2,3,18]),v1,v2) 

sage: e1 != e1 

False 

""" 

return not self.__eq__(other) 

 

 

class BruhatTitsQuotient(SageObject, UniqueRepresentation): 

r""" 

This function computes the quotient of the Bruhat-Tits tree 

by an arithmetic quaternionic group. The group in question is the 

group of norm 1 elements in an Eichler `\ZZ[1/p]`-order of some (tame) 

level inside of a definite quaternion algebra that is unramified 

at the prime `p`. Note that this routine relies in Magma in the case 

`p = 2` or when `N^{+} > 1`. 

 

INPUT: 

 

- ``p`` - a prime number 

 

- ``Nminus`` - squarefree integer divisible by an odd number of 

distinct primes and relatively prime to p. This is the 

discriminant of the definite quaternion algebra that one is 

quotienting by. 

 

- ``Nplus`` - an integer coprime to pNminus (Default: 1). This is 

the tame level. It need not be squarefree! If Nplus is not 1 

then the user currently needs magma installed due to sage's 

inability to compute well with nonmaximal Eichler orders in 

rational (definite) quaternion algebras. 

 

- ``character`` - a Dirichlet character (Default: None) of modulus 

`pN^-N^+`. 

 

- ``use_magma`` - boolean (default: False). If True, uses Magma 

for quaternion arithmetic. 

 

- ``magma_session`` -- (default: None). If specified, the Magma session 

to use. 

 

EXAMPLES: 

 

Here is an example without a Dirichlet character:: 

 

sage: X = BruhatTitsQuotient(13, 19) 

sage: X.genus() 

19 

sage: G = X.get_graph(); G 

Multi-graph on 4 vertices 

 

And an example with a Dirichlet character:: 

 

sage: f = DirichletGroup(6)[1] 

sage: X = BruhatTitsQuotient(3,2*5*7,character = f) 

sage: X.genus() 

5 

 

.. NOTE:: 

 

A sage implementation of Eichler orders in rational quaternions 

algebras would remove the dependency on magma. 

 

AUTHORS: 

 

- Marc Masdeu (2012-02-20) 

""" 

@staticmethod 

def __classcall__(cls, p, Nminus, Nplus=1, character=None, 

use_magma=False, seed=None, magma_session=None): 

""" 

Ensure that a canonical BruhatTitsQuotient is created. 

 

EXAMPLES: 

 

sage: BruhatTitsQuotient(3,17) is BruhatTitsQuotient(3,17,1) 

True 

""" 

return super(BruhatTitsQuotient, cls).__classcall__(cls, p, Nminus, Nplus, 

character, use_magma, seed, magma_session) 

 

def __init__(self, p, Nminus, Nplus=1, character=None, 

use_magma=False, seed=None, magma_session=None): 

""" 

Compute the quotient of the Bruhat-Tits tree by an arithmetic 

quaternionic group. 

 

EXAMPLES:: 

 

sage: Y = BruhatTitsQuotient(19,11) 

sage: TestSuite(Y).run() 

""" 

Nminus = Integer(Nminus) 

Nplus = Integer(Nplus) 

p = Integer(p) 

lev = p * Nminus 

self._order_is_initialized = False 

if character is not None: 

extra_level = character.conductor() 

if not extra_level.is_squarefree(): 

raise ValueError("character must be of squarefree conductor") 

self._trivial_character = False 

else: 

G = DirichletGroup(lev * Nplus) 

character = G([1] * G.ngens()) 

extra_level = 1 

self._trivial_character = True 

 

if not p.is_prime(): 

raise ValueError("p must be a prime") 

if not lev.is_squarefree(): 

raise ValueError("level must be squarefree") 

if (gcd(lev, Nplus) > 1): 

raise ValueError("level and conductor must be coprime") 

 

# if len(Nminus.factor()) % 2 != 1: 

# raise ValueError("Nminus should be divisible by an odd number of primes") 

 

self._pN = p 

self._p = p 

self._Nminus = Nminus 

self._Nplus = Nplus 

if use_magma or self._Nplus != 1 or self._p == 2: 

try: 

if magma_session is None: 

self._magma = magma 

else: 

self._magma = magma_session 

magmap = self._magma(p) 

# print("Warning: this input needs magma to work...") 

except RuntimeError: 

raise NotImplementedError('Sage does not know yet how to work with the kind of orders that you are trying to use. Try installing Magma first and set it up so that Sage can use it.') 

 

## This is added for debugging, in order to have reproducible results 

if seed is not None: 

self._magma.function_call('SetSeed', seed, nvals=0) 

self._use_magma = True 

else: 

self._use_magma = False 

 

self._BT = BruhatTitsTree(p) 

 

self._prec = -1 

 

self._cached_vertices = {} 

self._cached_edges = {} 

self._cached_paths = {} 

self._cached_decomps = {} 

self._cached_equivalent = {} 

self._CM_points = {} 

 

self._V = (QQ ** 4).ambient_module().change_ring(ZZ) 

self._Mat_44 = MatrixSpace(ZZ, 4, 4) 

self._Mat_22 = MatrixSpace(ZZ, 2, 2) 

self._Mat_41 = MatrixSpace(ZZ, 4, 1) 

if extra_level == 1: 

self._extra_level = [] 

else: 

self._extra_level = [ff[0] for ff in extra_level.factor()] 

self.get_extra_embedding_matrices() 

self._character = character 

self._Xv = [self._Mat_22([1, 0, 0, 0]), 

self._Mat_22([0, 1, 0, 0]), 

self._Mat_22([0, 0, 1, 0]), 

self._Mat_22([0, 0, 0, 1])] 

self._Xe = [self._Mat_22([1, 0, 0, 0]), 

self._Mat_22([0, 1, 0, 0]), 

self._Mat_22([0, 0, self._p, 0]), 

self._Mat_22([0, 0, 0, 1])] 

 

def _cache_key(self): 

r""" 

Return a hash of self, for using in caching. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,13) 

sage: X._cache_key() 

-406423199 # 32-bit 

1375458358400022881 # 64-bit 

 

sage: Y = BruhatTitsQuotient(5,13,use_magma = True) # optional - magma 

sage: Y._cache_key() == X._cache_key() # optional - magma 

False 

""" 

 

return hash((self._p, self._Nminus, self._Nplus, self._character, self._use_magma)) 

def _repr_(self): 

r""" 

Return the representation of self as a string. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,13); X 

Quotient of the Bruhat Tits tree of GL_2(QQ_5) with discriminant 13 and level 1 

""" 

return "Quotient of the Bruhat Tits tree of GL_2(QQ_%s) with discriminant %s and level %s" % (self.prime(), self.Nminus().factor(), self.Nplus().factor()) 

 

def __eq__(self, other): 

r""" 

Compare self with other. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,13) 

sage: Y = BruhatTitsQuotient(p = 5, Nminus = 13, Nplus=1,seed = 1231) 

sage: X == Y 

True 

""" 

if self._p != other._p: 

return False 

if self._Nminus != other._Nminus: 

return False 

if self._Nplus != other._Nplus: 

return False 

if self._character != other._character: 

return False 

return True 

 

def __ne__(self, other): 

r""" 

Compare self with other. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,13) 

sage: Y = BruhatTitsQuotient(p = 5, Nminus = 13, Nplus=1,seed = 1231) 

sage: X != Y 

False 

""" 

return not self.__eq__(other) 

 

def _latex_(self): 

r""" 

Return the LaTeX representation of ``self``. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,13); latex(X) 

X(5 \cdot 13,1)\otimes_{\mathbb{Z}} \mathbb{F}_{5} 

""" 

return "X(%s,%s)\\otimes_{\\mathbb{Z}} \\mathbb{F}_{%s}" % (latex(self.level().factor()), latex(self.Nplus().factor()), latex(self.prime())) 

 

def get_vertex_dict(self): 

r""" 

This function returns the vertices of the quotient viewed as 

a dict. 

 

OUTPUT: 

 

A python dict with the vertices of the quotient. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(37,3) 

sage: X.get_vertex_dict() 

{[1 0] 

[0 1]: Vertex of Bruhat-Tits tree for p = 37, [ 1 0] 

[ 0 37]: Vertex of Bruhat-Tits tree for p = 37} 

""" 

try: 

return self._boundary 

except AttributeError: 

self._compute_quotient() 

return self._boundary 

 

def get_vertex_list(self): 

r""" 

Return a list of the vertices of the quotient. 

 

OUTPUT: 

 

- A list with the vertices of the quotient. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(37,3) 

sage: X.get_vertex_list() 

[Vertex of Bruhat-Tits tree for p = 37, Vertex of Bruhat-Tits tree for p = 37] 

""" 

try: 

return self._vertex_list 

except AttributeError: 

self._compute_quotient() 

return self._vertex_list 

 

def get_edge_list(self): 

r""" 

Return a list of ``Edge`` which represent a fundamental 

domain inside the Bruhat-Tits tree for the quotient. 

 

OUTPUT: 

 

A list of ``Edge``. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(37,3) 

sage: len(X.get_edge_list()) 

8 

 

""" 

try: 

return self._edge_list 

except AttributeError: 

self._compute_quotient() 

return self._edge_list 

 

def get_list(self): 

r""" 

Return a list of ``Edge`` which represent a fundamental 

domain inside the Bruhat-Tits tree for the quotient, 

together with a list of the opposite edges. This is used 

to work with automorphic forms. 

 

OUTPUT: 

 

A list of ``Edge``. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(37,3) 

sage: len(X.get_list()) 

16 

""" 

E = self.get_edge_list() 

return E + [e.opposite for e in E] 

 

def get_nontorsion_generators(self): 

r""" 

Use a fundamental domain in the Bruhat-Tits tree, and 

certain gluing data for boundary vertices, in order to compute 

a collection of generators for the nontorsion part 

of the arithmetic quaternionic group that one is quotienting by. 

This is analogous to using a polygonal rep. of a compact real 

surface to present its fundamental domain. 

 

OUTPUT: 

 

- A generating list of elements of an arithmetic 

quaternionic group. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,13) 

sage: len(X.get_nontorsion_generators()) 

3 

""" 

try: 

return list(self._nontorsion_generators) 

except AttributeError: 

self._compute_quotient() 

return list(self._nontorsion_generators) 

 

@cached_method 

def get_generators(self): 

r""" 

Use a fundamental domain in the Bruhat-Tits tree, and 

certain gluing data for boundary vertices, in order to compute 

a collection of generators for the arithmetic quaternionic 

group that one is quotienting by. This is analogous to using a 

polygonal rep. of a compact real surface to present its 

fundamental domain. 

 

OUTPUT: 

 

- A generating list of elements of an arithmetic 

quaternionic group. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,2) 

sage: len(X.get_generators()) 

2 

""" 

ans = self.get_nontorsion_generators() 

for s in self.get_vertex_stabs(): 

for o in s: 

if o[2]: 

ans.append(o[0]) 

break 

return ans 

 

def _compute_invariants(self): 

""" 

Compute certain invariants from the level data of the quotient 

which allow one to compute the genus of the curve. 

 

Details to be found in Theorem 9 of [FM]_. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(23,11) 

sage: X._compute_invariants() 

""" 

Nplus = self._Nplus 

lev = self._Nminus 

e4 = 1 

e3 = 1 

mu = Nplus 

for f in lev.factor(): 

e4 *= (1 - kronecker_symbol(-4, Integer(f[0]))) 

e3 *= (1 - kronecker_symbol(-3, Integer(f[0]))) 

mu *= Integer(f[0]) - 1 

for f in Nplus.factor(): 

if (f[1] == 1): 

e4 *= (1 + kronecker_symbol(-4, Integer(f[0]))) 

e3 *= (1 + kronecker_symbol(-3, Integer(f[0]))) 

else: 

if kronecker_symbol(-4, Integer(f[0])) == 1: 

e4 *= 2 

else: 

e4 = 0 

if kronecker_symbol(-3, Integer(f[0])) == 1: 

e3 *= 2 

else: 

e3 = 0 

mu *= 1 + 1 / Integer(f[0]) 

self.e3 = e3 

self.e4 = e4 

self.mu = mu 

 

@lazy_attribute 

def e3(self): 

r""" 

Compute the `e_3` invariant defined by the formula 

 

.. MATH:: 

 

e_k =\prod_{\ell\mid pN^-}\left(1-\left(\frac{-3}{\ell}\right)\right)\prod_{\ell \| N^+}\left(1+\left(\frac{-3}{\ell}\right)\right)\prod_{\ell^2\mid N^+} \nu_\ell(3) 

 

OUTPUT: 

 

an integer 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(31,3) 

sage: X.e3 

1 

""" 

self._compute_invariants() 

return self.e3 

 

@lazy_attribute 

def e4(self): 

r""" 

Compute the `e_4` invariant defined by the formula 

 

.. MATH:: 

 

e_k =\prod_{\ell\mid pN^-}\left(1-\left(\frac{-k}{\ell}\right)\right)\prod_{\ell \| N^+}\left(1+\left(\frac{-k}{\ell}\right)\right)\prod_{\ell^2\mid N^+} \nu_\ell(k) 

 

OUTPUT: 

 

an integer 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(31,3) 

sage: X.e4 

2 

""" 

self._compute_invariants() 

return self.e4 

 

@lazy_attribute 

def mu(self): 

""" 

Compute the mu invariant of self. 

 

OUTPUT: 

 

An integer. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(29,3) 

sage: X.mu 

2 

""" 

self._compute_invariants() 

return self.mu 

 

@cached_method 

def get_num_verts(self): 

""" 

Return the number of vertices in the quotient using the formula 

`V = 2(\mu/12 + e_3/3 + e_4/4)`. 

 

OUTPUT: 

 

- An integer (the number of vertices) 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(29,11) 

sage: X.get_num_verts() 

4 

""" 

return 2 * Integer(self.mu / 12 + self.e3 / 3 + self.e4 / 4) 

 

@cached_method 

def get_num_ordered_edges(self): 

""" 

Return the number of ordered edges `E` in the quotient using 

the formula relating the genus `g` with the number of vertices `V` 

and that of unordered edges `E/2`: `E = 2(g + V - 1)`. 

 

OUTPUT: 

 

- An integer 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,2) 

sage: X.get_num_ordered_edges() 

2 

""" 

return 2 * (self.genus() + self.get_num_verts() - 1) 

 

def genus_no_formula(self): 

""" 

Compute the genus of the quotient from the data of the 

quotient graph. This should agree with self.genus(). 

 

OUTPUT: 

 

An integer 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,2*3*29) 

sage: X.genus_no_formula() 

17 

sage: X.genus_no_formula() == X.genus() 

True 

""" 

return ZZ(1 - len(self.get_vertex_list()) + len(self.get_edge_list())) 

 

@cached_method 

def genus(self): 

r""" 

Compute the genus of the quotient graph using a formula 

This should agree with self.genus_no_formula(). 

 

Compute the genus of the Shimura curve 

corresponding to this quotient via Cerednik-Drinfeld. It is 

computed via a formula and not in terms of the quotient graph. 

 

INPUT: 

 

- level: Integer (default: None) a level. By default, use that 

of ``self``. 

 

- Nplus: Integer (default: None) a conductor. By default, use 

that of ``self``. 

 

OUTPUT: 

 

An integer equal to the genus 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,2*5*31) 

sage: X.genus() 

21 

sage: X.genus() == X.genus_no_formula() 

True 

""" 

return self.dimension_harmonic_cocycles(2) 

 

@cached_method 

def dimension_harmonic_cocycles(self, k, lev=None, Nplus=None, 

character=None): 

r""" 

Compute the dimension of the space of harmonic cocycles 

of weight `k` on ``self``. 

 

OUTPUT: 

 

An integer equal to the dimension 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,7) 

sage: [X.dimension_harmonic_cocycles(k) for k in range(2,20,2)] 

[1, 4, 4, 8, 8, 12, 12, 16, 16] 

 

sage: X = BruhatTitsQuotient(2,5) # optional - magma 

sage: [X.dimension_harmonic_cocycles(k) for k in range(2,40,2)] # optional - magma 

[0, 1, 3, 1, 3, 5, 3, 5, 7, 5, 7, 9, 7, 9, 11, 9, 11, 13, 11] 

 

sage: X = BruhatTitsQuotient(7, 2 * 3 * 5) 

sage: X.dimension_harmonic_cocycles(4) 

12 

sage: X = BruhatTitsQuotient(7, 2 * 3 * 5 * 11 * 13) 

sage: X.dimension_harmonic_cocycles(2) 

481 

sage: X.dimension_harmonic_cocycles(4) 

1440 

""" 

k = ZZ(k) 

if lev is None: 

lev = self._p * self._Nminus 

else: 

lev = ZZ(lev) 

if Nplus is None: 

Nplus = self._Nplus 

else: 

Nplus = ZZ(Nplus) 

 

if character is None: 

if not self._trivial_character: 

character = self._character 

kernel = filter(lambda r: gcd(r, lev * Nplus) == 1 and character(r) == 1, 

range(lev * Nplus)) 

else: 

character = None 

kernel = None 

 

if k == 0: 

return 0 

 

verbose('Computing dimension for (k,level,nplus,char) = (%s, %s, %s, %s)'%(k, lev, Nplus, character), level = 2) 

 

if lev == 1: 

return Gamma0(Nplus).dimension_cusp_forms(k=k) 

 

f = lev.factor() 

if any([l[1] != 1 for l in f]): 

raise NotImplementedError('The level should be squarefree for ' 

'this function to work... Sorry!') 

GH = lambda N,ker: Gamma0(N) if character is None else GammaH_constructor(N,ker) 

 

divs = lev.divisors() 

 

def mumu(N): 

p = 1 

for _,r in ZZ(N).factor(): 

if r > 2: 

return ZZ(0) 

elif r == 1: 

p *= -2 

return ZZ(p) 

return sum([mumu(lev // d) * GH(d * Nplus, kernel).dimension_cusp_forms(k) for d in lev.divisors()]) 

 

def Nplus(self): 

r""" 

Return the tame level `N^+`. 

 

OUTPUT: 

 

An integer equal to `N^+`. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7,1) 

sage: X.Nplus() 

1 

""" 

return self._Nplus 

 

def Nminus(self): 

r""" 

Return the discriminant of the relevant definite 

quaternion algebra. 

 

OUTPUT: 

 

An integer equal to `N^-`. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: X.Nminus() 

7 

""" 

return self._Nminus 

 

@cached_method 

def level(self): 

r""" 

Return `p N^-`, which is the discriminant of the 

indefinite quaternion algebra that is uniformed by 

Cerednik-Drinfeld. 

 

OUTPUT: 

 

An integer equal to `p N^-`. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: X.level() 

35 

""" 

return self._Nminus * self._p 

 

def prime(self): 

r""" 

Return the prime one is working with. 

 

OUTPUT: 

 

An integer equal to the fixed prime `p` 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: X.prime() 

5 

""" 

return self._p 

 

def get_graph(self): 

r""" 

Return the quotient graph (and compute it if needed). 

 

OUTPUT: 

 

A graph representing the quotient of the Bruhat-Tits tree. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(11,5) 

sage: X.get_graph() 

Multi-graph on 2 vertices 

""" 

try: 

return self._S 

except AttributeError: 

self._compute_quotient() 

return self._S 

 

def get_fundom_graph(self): 

r""" 

Return the fundamental domain (and computes it if needed). 

 

OUTPUT: 

 

A fundamental domain for the action of `\Gamma`. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(11,5) 

sage: X.get_fundom_graph() 

Graph on 24 vertices 

""" 

try: 

return self._Sfun 

except AttributeError: 

self._compute_quotient() 

return self._Sfun 

 

def plot(self, *args, **kwargs): 

r""" 

Plot the quotient graph. 

 

OUTPUT: 

 

A plot of the quotient graph 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,23) 

sage: X.plot() 

Graphics object consisting of 17 graphics primitives 

""" 

S = self.get_graph() 

vertex_colors = {} 

v0 = Matrix(ZZ, 2, 2, [1, 0, 0, 1]) 

v0.set_immutable() 

rainbow_color = rainbow(len(self.get_vertex_list())) 

for v in S.vertex_iterator(): 

key = rainbow_color[S.get_vertex(v).label] 

if key in vertex_colors: 

vertex_colors[key].append(v) 

else: 

vertex_colors[key] = [v] 

 

my_args = {} 

my_args['vertex_colors'] = vertex_colors 

my_args['color_by_label'] = True 

my_args['vertex_labels'] = False 

my_args.update(kwargs) 

return S.plot(*args, **my_args) 

 

def plot_fundom(self, *args, **kwargs): 

r""" 

Plot a fundamental domain. 

 

OUTPUT: 

 

A plot of the fundamental domain. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,23) 

sage: X.plot_fundom() 

Graphics object consisting of 88 graphics primitives 

""" 

S = self.get_fundom_graph() 

vertex_colors = {} 

rainbow_color = rainbow(len(self.get_vertex_list())) 

for v in S.vertex_iterator(): 

key = rainbow_color[S.get_vertex(v).label] 

if key in vertex_colors: 

vertex_colors[key].append(v) 

else: 

vertex_colors[key] = [v] 

 

my_args = {} 

my_args['vertex_colors'] = vertex_colors 

my_args['color_by_label'] = True 

my_args['vertex_labels'] = True 

my_args.update(kwargs) 

return S.plot(*args, **my_args) 

 

def is_admissible(self, D): 

r""" 

Test whether the imaginary quadratic field of 

discriminant `D` embeds in the quaternion algebra. It 

furthermore tests the Heegner hypothesis in this setting 

(e.g., is `p` inert in the field, etc). 

 

INPUT: 

 

- ``D`` - an integer whose squarefree part will define the 

quadratic field 

 

OUTPUT: 

 

A boolean describing whether the quadratic field is admissible 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: [X.is_admissible(D) for D in range(-1,-20,-1)] 

[False, True, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, True, False] 

""" 

disc = fundamental_discriminant(D) 

for f in self.level().factor(): 

if kronecker_symbol(disc, f[0]) != -1: 

return False 

for f in self._Nplus.factor(): 

if kronecker_symbol(disc, f[0]) != 1: 

return False 

return True 

 

def _local_splitting_map(self, prec): 

r""" 

Return an embedding of the definite quaternion algebra 

into the algebra of 2x2 matrices with coefficients in `\QQ_p`. 

 

INPUT: 

 

- ``prec`` -- Integer. The precision of the splitting. 

 

OUTPUT: 

 

A function giving the splitting. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(11,3) 

sage: phi = X._local_splitting_map(10) 

sage: B.<i,j,k> = QuaternionAlgebra(3) 

sage: phi(i)**2 == QQ(i**2)*phi(B(1)) 

True 

""" 

I, J, K = self._local_splitting(prec) 

 

def phi(q): 

R = I.parent() 

v = q.coefficient_tuple() 

return R(v[0] + I * v[1] + J * v[2] + K * v[3]) 

return phi 

 

def _local_splitting(self, prec): 

r""" 

Find an embedding of the definite quaternion algebra 

into the algebra of 2x2 matrices with coefficients in `\QQ_p`. 

 

INPUT: 

 

- ``prec`` - Integer. The precision of the splitting. 

 

OUTPUT: 

 

- Matrices `I`, `J`, `K` giving the splitting. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(11,3) 

sage: phi = X._local_splitting_map(10) 

sage: B.<i,j,k> = QuaternionAlgebra(3) 

sage: phi(i)**2 == QQ(i**2)*phi(B(1)) 

True 

""" 

assert not self._use_magma 

if prec <= self._prec: 

return self._II, self._JJ, self._KK 

 

A = self.get_quaternion_algebra() 

 

ZZp = Zp(self._p, prec) 

v = A.invariants() 

a = ZZp(v[0]) 

b = ZZp(v[1]) 

if (A.base_ring() != QQ): 

raise ValueError("must be rational quaternion algebra") 

if (A.discriminant() % self._p == 0): 

raise ValueError("p (=%s) must be an unramified prime" % self._p) 

M = MatrixSpace(ZZp, 2) 

 

if a.is_square(): 

alpha = a.sqrt() 

self._II = M([alpha, 0, 2 * alpha, -alpha]) 

self._JJ = M([b, -b, b - 1, -b]) 

else: 

self._II = M([0, a, 1, 0]) 

z = 0 

self._JJ = 0 

while(self._JJ == 0): 

c = a * z * z + b 

if c.is_square(): 

x = c.sqrt() 

self._JJ = M([x, -a * z, z, -x]) 

else: 

z += 1 

self._KK = self._II * self._JJ 

return self._II, self._JJ, self._KK 

 

def _compute_embedding_matrix(self, prec, force_computation=False): 

r""" 

Return a matrix representing the embedding with the 

given precision. 

 

INPUT: 

 

- ``prec`` - Integer. The precision of the embedding matrix. 

 

EXAMPLES: 

 

Note that the entries of the matrix are elements of Zmod:: 

 

sage: X = BruhatTitsQuotient(3,7) 

sage: A = X.get_embedding_matrix(10) # indirect doctest 

sage: R = A.base_ring() 

sage: B = X.get_eichler_order_basis() 

sage: R(B[0].reduced_trace()) == A[0,0]+A[3,0] 

True 

""" 

if self._use_magma: 

if not force_computation: 

try: 

return Matrix(Zmod(self._pN), 4, 4, 

self._cached_Iota0_matrix) 

except AttributeError: 

pass 

 

Ord = self.get_eichler_order(magma=True) # force_computation = force_computation) 

OrdMax = self.get_maximal_order(magma=True) 

 

OBasis = Ord.Basis() 

verbose('Calling magma: pMatrixRing, args = %s' % [OrdMax, self._p]) 

M, f, rho = self._magma.function_call('pMatrixRing', args=[OrdMax, self._p], params={'Precision': 2000}, nvals=3) 

v = [f.Image(OBasis[i]) for i in [1, 2, 3, 4]] 

 

self._cached_Iota0_matrix = [v[kk][ii, jj].sage() 

for ii in range(1, 3) 

for jj in range(1, 3) 

for kk in range(4)] 

return Matrix(Zmod(self._pN), 4, 4, self._cached_Iota0_matrix) 

else: 

phi = self._local_splitting_map(prec) 

B = self.get_eichler_order_basis() 

return Matrix(Zmod(self._p ** prec), 4, 4, 

[phi(B[kk])[ii, jj] for ii in range(2) 

for jj in range(2) for kk in range(4)]) 

 

@cached_method 

def get_extra_embedding_matrices(self): 

r""" 

Return a list of matrices representing the different embeddings. 

 

.. NOTE:: 

 

The precision is very low (currently set to 5 digits), 

since these embeddings are only used to apply a character. 

 

EXAMPLES: 

 

This portion of the code is only relevant when working with a 

nontrivial Dirichlet character. If there is no such character 

then the code returns an empty list. Even if the character is 

not trivial it might return an empty list:: 

 

sage: f = DirichletGroup(6)[1] 

sage: X = BruhatTitsQuotient(3,2*5*7,character = f) 

sage: X.get_extra_embedding_matrices() 

[] 

 

:: 

 

sage: f = DirichletGroup(6)[1] 

sage: X = BruhatTitsQuotient(5,2,3, character = f, use_magma=True) # optional - magma 

sage: X.get_extra_embedding_matrices() # optional - magma 

[ 

[1 0 2 0] 

[0 0 2 0] 

[0 0 0 0] 

[1 0 2 2] 

] 

""" 

if not self._use_magma or len(self._extra_level) == 0: 

return [] 

n_iters = 0 

Ord = self.get_eichler_order(magma=True) 

OrdMax = self.get_maximal_order(magma=True) 

OBasis = Ord.Basis() 

extra_embeddings = [] 

success = False 

while not success: 

success = True 

for l in self._extra_level: 

success = False 

found = False 

while not found: 

verbose('Calling magma: pMatrixRing, args = %s' % [OrdMax, l]) 

M, f, rho = self._magma.function_call('pMatrixRing', args=[OrdMax, l], params={'Precision': 20}, nvals=3) 

v = [f.Image(OBasis[i]) for i in [1, 2, 3, 4]] 

if all([Qp(l, 5)(v[kk][2, 1].sage()).valuation() >= 1 for kk in range(4)]) and not all([Qp(l, 5)(v[kk][2, 1].sage()).valuation() >= 2 for kk in range(4)]): 

found = True 

success = True 

else: 

n_iters += 1 

verbose('Restarting magma...') 

self._magma.quit() 

self._magma = magma 

self._magma.function_call('SetSeed', n_iters, nvals=0) 

self._order_is_initialized = False 

self._init_order() 

self._compute_embedding_matrix(self._prec, 

force_computation=True) 

Ord = self.get_eichler_order(magma=True) 

OrdMax = self.get_maximal_order(magma=True) 

OBasis = Ord.Basis() 

extra_embeddings = [] 

success = False 

break 

if not success: 

break 

mat = Matrix(GF(l), 4, 4, [v[kk][ii, jj].sage() 

for ii in range(1, 3) 

for jj in range(1, 3) 

for kk in range(4)]) 

extra_embeddings.append(mat) 

return extra_embeddings 

 

def _increase_precision(self, amount=1): 

r""" 

Increase the working precision. 

 

INPUT: 

 

- ``amount`` Integer (default: 1). The amount by which to 

increase the precision. 

 

EXAMPLES: 

 

sage: X = BruhatTitsQuotient(3,101) 

sage: X.get_embedding_matrix() 

[ O(3) 1 + O(3) 1 + O(3) 1 + O(3)] 

[2 + O(3) O(3) 2 + O(3) 2 + O(3)] 

[1 + O(3) 1 + O(3) O(3) 2 + O(3)] 

[1 + O(3) 2 + O(3) 2 + O(3) 2 + O(3)] 

sage: X._increase_precision(5) 

sage: X.get_embedding_matrix()[0,0] 

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

""" 

if amount >= 1: 

self.get_embedding_matrix(prec=self._prec + amount) 

 

def get_embedding_matrix(self, prec=None, exact=False): 

r""" 

Return the matrix of the embedding. 

 

INPUT: 

 

- ``exact`` boolean (Default: ``False``). If ``True``, return an 

embedding into a matrix algebra with coefficients in a 

number field. Otherwise, embed into matrices over `p`-adic 

numbers. 

 

- ``prec`` Integer (Default: ``None``). If specified, return the 

matrix with precision ``prec``. Otherwise, return the 

cached matrix (with the current working precision). 

 

OUTPUT: 

 

- A 4x4 matrix representing the embedding. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,2*3*5) 

sage: X.get_embedding_matrix(4) 

[ 1 + O(7^4) 5 + 2*7 + 3*7^3 + O(7^4) 4 + 5*7 + 6*7^2 + 6*7^3 + O(7^4) 6 + 3*7^2 + 4*7^3 + O(7^4)] 

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

[ O(7^4) 2 + 5*7 + 6*7^3 + O(7^4) 3 + 5*7 + 6*7^2 + 6*7^3 + O(7^4) 3 + 3*7 + 3*7^2 + O(7^4)] 

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

sage: X.get_embedding_matrix(3) 

[ 1 + O(7^4) 5 + 2*7 + 3*7^3 + O(7^4) 4 + 5*7 + 6*7^2 + 6*7^3 + O(7^4) 6 + 3*7^2 + 4*7^3 + O(7^4)] 

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

[ O(7^4) 2 + 5*7 + 6*7^3 + O(7^4) 3 + 5*7 + 6*7^2 + 6*7^3 + O(7^4) 3 + 3*7 + 3*7^2 + O(7^4)] 

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

sage: X.get_embedding_matrix(5) 

[ 1 + O(7^5) 5 + 2*7 + 3*7^3 + 6*7^4 + O(7^5) 4 + 5*7 + 6*7^2 + 6*7^3 + 6*7^4 + O(7^5) 6 + 3*7^2 + 4*7^3 + 5*7^4 + O(7^5)] 

[ O(7^5) O(7^5) 3 + 7 + O(7^5) 1 + 6*7 + 3*7^2 + 2*7^3 + 7^4 + O(7^5)] 

[ O(7^5) 2 + 5*7 + 6*7^3 + 5*7^4 + O(7^5) 3 + 5*7 + 6*7^2 + 6*7^3 + 6*7^4 + O(7^5) 3 + 3*7 + 3*7^2 + 5*7^4 + O(7^5)] 

[ 1 + O(7^5) 3 + 4*7 + 6*7^2 + 3*7^3 + O(7^5) 3 + 7 + O(7^5) 1 + 6*7 + 3*7^2 + 2*7^3 + 7^4 + O(7^5)] 

""" 

if exact is True: 

try: 

return self._Iota_exact 

except AttributeError: 

raise RuntimeError('Exact splitting not available.') 

else: 

if prec is None: 

prec = self._prec 

 

if prec < 0: 

prec = 1 

 

if prec == self._prec: 

try: 

return self._Iota 

except AttributeError: 

pass 

 

self._pN = self._p ** prec 

self._R = Qp(self._p, prec=prec) 

 

if prec > self._prec: 

verbose('self._prec = %s, prec = %s' % (self._prec, prec)) 

Iotamod = self._compute_embedding_matrix(prec) 

self._Iotainv_lift = Iotamod.inverse().lift() 

self._Iota = Matrix(self._R, 4, 4, [Iotamod[ii, jj] 

for ii in range(4) 

for jj in range(4)]) 

 

self._prec = prec 

self._Iotainv = self._Mat_44([self._Iotainv_lift[ii, jj] % self._pN for ii in range(4) for jj in range(4)]) 

return self._Iota 

 

 

def embed_quaternion(self, g, exact=False, prec=None): 

r""" 

Embed the quaternion element ``g`` into a matrix algebra. 

 

INPUT: 

 

- ``g`` a row vector of size `4` whose entries represent a 

quaternion in our basis. 

 

- ``exact`` boolean (default: False) - If True, tries to embed 

``g`` into a matrix algebra over a number field. If False, 

the target is the matrix algebra over `\QQ_p`. 

 

OUTPUT: 

 

A 2x2 matrix with coefficients in `\QQ_p` if ``exact`` is 

False, or a number field if ``exact`` is True. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,2) 

sage: l = X.get_units_of_order() 

sage: len(l) 

12 

sage: l[3] # random 

[-1] 

[ 0] 

[ 1] 

[ 1] 

sage: u = X.embed_quaternion(l[3]); u # random 

[ O(7) 3 + O(7)] 

[2 + O(7) 6 + O(7)] 

sage: X._increase_precision(5) 

sage: v = X.embed_quaternion(l[3]); v # random 

[ 7 + 3*7^2 + 7^3 + 4*7^4 + O(7^6) 3 + 7 + 3*7^2 + 7^3 + 4*7^4 + O(7^6)] 

[ 2 + 7 + 3*7^2 + 7^3 + 4*7^4 + O(7^6) 6 + 5*7 + 3*7^2 + 5*7^3 + 2*7^4 + 6*7^5 + O(7^6)] 

sage: u == v 

True 

""" 

if exact: 

return Matrix(self.get_splitting_field(), 2, 2, 

(self.get_embedding_matrix(exact=True) * g).list()) 

else: 

A = self.get_embedding_matrix(prec=prec) * g 

return Matrix(self._R, 2, 2, A.list()) 

 

embed = embed_quaternion 

 

def get_embedding(self, prec=None): 

r""" 

Return a function which embeds quaternions into a matrix 

algebra. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,3) 

sage: f = X.get_embedding(prec = 4) 

sage: b = Matrix(ZZ,4,1,[1,2,3,4]) 

sage: f(b) 

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

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

""" 

A = self.get_embedding_matrix(prec=prec) 

return lambda g: Matrix(self._R, 2, 2, (A * g).list()) 

 

def get_edge_stabilizers(self): 

r""" 

Compute the stabilizers in the arithmetic group of all 

edges in the Bruhat-Tits tree within a fundamental domain for 

the quotient graph. The stabilizers of an edge and its 

opposite are equal, and so we only store half the data. 

 

OUTPUT: 

 

A list of lists encoding edge stabilizers. It contains one 

entry for each edge. Each entry is a list of data 

corresponding to the group elements in the stabilizer of the 

edge. The data consists of: (0) a column matrix representing 

a quaternion, (1) the power of `p` that one needs to divide 

by in order to obtain a quaternion of norm 1, and hence an 

element of the arithmetic group `\Gamma`, (2) a boolean that 

is only used to compute spaces of modular forms. 

 

EXAMPLES:: 

 

sage: X=BruhatTitsQuotient(3,2) 

sage: s = X.get_edge_stabilizers() 

sage: len(s) == X.get_num_ordered_edges()/2 

True 

sage: len(s[0]) 

3 

""" 

try: 

return self._edge_stabs 

except AttributeError: 

self._edge_stabs = [self._stabilizer(e.rep, as_edge=True) 

for e in self.get_edge_list()] 

return self._edge_stabs 

 

def get_stabilizers(self): 

r""" 

Compute the stabilizers in the arithmetic group of all 

edges in the Bruhat-Tits tree within a fundamental domain for 

the quotient graph. This is similar to get_edge_stabilizers, except 

that here we also store the stabilizers of the opposites. 

 

OUTPUT: 

 

A list of lists encoding edge stabilizers. It contains one 

entry for each edge. Each entry is a list of data 

corresponding to the group elements in the stabilizer of the 

edge. The data consists of: (0) a column matrix representing 

a quaternion, (1) the power of `p` that one needs to divide 

by in order to obtain a quaternion of norm 1, and hence an 

element of the arithmetic group `\Gamma`, (2) a boolean that 

is only used to compute spaces of modular forms. 

 

EXAMPLES:: 

 

sage: X=BruhatTitsQuotient(3,5) 

sage: s = X.get_stabilizers() 

sage: len(s) == X.get_num_ordered_edges() 

True 

sage: gamma = X.embed_quaternion(s[1][0][0][0],prec = 20) 

sage: v = X.get_edge_list()[0].rep 

sage: X._BT.edge(gamma*v) == v 

True 

""" 

S = self.get_edge_stabilizers() 

return S + S 

 

def get_vertex_stabs(self): 

r""" 

This function computes the stabilizers in the arithmetic 

group of all vertices in the Bruhat-Tits tree within a 

fundamental domain for the quotient graph. 

 

OUTPUT: 

 

A list of vertex stabilizers. Each vertex stabilizer is a 

finite cyclic subgroup, so we return generators for these 

subgroups. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(13,2) 

sage: S = X.get_vertex_stabs() 

sage: gamma = X.embed_quaternion(S[0][0][0],prec = 20) 

sage: v = X.get_vertex_list()[0].rep 

sage: X._BT.vertex(gamma*v) == v 

True 

""" 

try: 

return self._vertex_stabs 

except AttributeError: 

self._vertex_stabs = [self._stabilizer(v.rep, as_edge=False) 

for v in self.get_vertex_list()] 

return self._vertex_stabs 

 

def get_quaternion_algebra(self): 

r""" 

Return the underlying quaternion algebra. 

 

OUTPUT: 

 

The underlying definite quaternion algebra 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: X.get_quaternion_algebra() 

Quaternion Algebra (-1, -7) with base ring Rational Field 

""" 

try: 

return self._A 

except AttributeError: 

pass 

self._init_order() 

return self._A 

 

def get_eichler_order(self, magma=False, force_computation=False): 

r""" 

Return the underlying Eichler order of level `N^+`. 

 

OUTPUT: 

 

An Eichler order. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: X.get_eichler_order() 

Order of Quaternion Algebra (-1, -7) with base ring Rational Field with basis (1/2 + 1/2*j, 1/2*i + 1/2*k, j, k) 

""" 

if magma: 

if not force_computation: 

try: 

return self._Omagma 

except AttributeError: 

pass 

self._init_order() 

return self._Omagma 

else: 

try: 

return self._O 

except AttributeError: 

pass 

self._init_order() 

return self._O 

 

def get_maximal_order(self, magma=False, force_computation=False): 

r""" 

Return the underlying maximal order containing the 

Eichler order. 

 

OUTPUT: 

 

A maximal order. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: X.get_maximal_order() 

Order of Quaternion Algebra (-1, -7) with base ring Rational Field with basis (1/2 + 1/2*j, 1/2*i + 1/2*k, j, k) 

""" 

if magma: 

if not force_computation: 

try: 

return self._OMaxmagma 

except AttributeError: 

pass 

self._init_order() 

return self._OMaxmagma 

else: 

try: 

return self._OMax 

except AttributeError: 

pass 

self._init_order() 

return self._OMax 

 

def get_splitting_field(self): 

r""" 

Return a quadratic field that splits the quaternion 

algebra attached to ``self``. Currently requires Magma. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,11) 

sage: X.get_splitting_field() 

Traceback (most recent call last): 

... 

NotImplementedError: Sage does not know yet how to work with the kind of orders that you are trying to use. Try installing Magma first and set it up so that Sage can use it. 

 

If we do have Magma installed, then it works:: 

 

sage: X = BruhatTitsQuotient(5,11,use_magma=True) # optional - magma 

sage: X.get_splitting_field() # optional - magma 

Number Field in a with defining polynomial X1^2 + 11 

""" 

if not self._use_magma: 

raise NotImplementedError('Sage does not know yet how to work with the kind of orders that you are trying to use. Try installing Magma first and set it up so that Sage can use it.') 

try: 

return self._FF 

except AttributeError: 

pass 

self._compute_exact_splitting() 

return self._FF 

 

def get_eichler_order_basis(self): 

r""" 

Return a basis for the global Eichler order. 

 

OUTPUT: 

 

Basis for the underlying Eichler order of level Nplus. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,11) 

sage: X.get_eichler_order_basis() 

[1/2 + 1/2*j, 1/2*i + 1/2*k, j, k] 

""" 

try: 

return self._B 

except AttributeError: 

pass 

self._init_order() 

return self._B 

 

def get_eichler_order_quadform(self): 

r""" 

This function return the norm form for the underlying 

Eichler order of level ``Nplus``. Required for finding elements in 

the arithmetic subgroup Gamma. 

 

OUTPUT: 

 

The norm form of the underlying Eichler order 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,11) 

sage: X.get_eichler_order_quadform() 

Quadratic form in 4 variables over Integer Ring with coefficients: 

[ 3 0 11 0 ] 

[ * 3 0 11 ] 

[ * * 11 0 ] 

[ * * * 11 ] 

""" 

try: 

return self._OQuadForm 

except AttributeError: 

pass 

self._init_order() 

return self._OQuadForm 

 

def get_eichler_order_quadmatrix(self): 

r""" 

This function returns the matrix of the quadratic form of 

the underlying Eichler order in the fixed basis. 

 

OUTPUT: 

 

A 4x4 integral matrix describing the norm form. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,11) 

sage: X.get_eichler_order_quadmatrix() 

[ 6 0 11 0] 

[ 0 6 0 11] 

[11 0 22 0] 

[ 0 11 0 22] 

""" 

try: 

return self._OM 

except AttributeError: 

pass 

self._init_order() 

return self._OM 

 

@cached_method 

def get_units_of_order(self): 

r""" 

Return the units of the underlying Eichler 

`\ZZ`-order. This is a finite group since the order lives in a 

definite quaternion algebra over `\QQ`. 

 

OUTPUT: 

 

A list of elements of the global Eichler `\ZZ`-order of 

level `N^+`. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,11) 

sage: X.get_units_of_order() 

[ 

[ 0] [-2] 

[-2] [ 0] 

[ 0] [ 1] 

[ 1], [ 0] 

] 

""" 

OM = self.get_eichler_order_quadmatrix() 

v = pari('qfminim(%s,2,0, flag = 2)' % (OM.__pari__())) 

n_units = Integer(v[0].sage() / 2) 

v = pari('qfminim(%s,2,%s, flag = 2)' % ((OM.__pari__()), n_units)) 

O_units = [] 

for jj in range(n_units): 

vec = Matrix(ZZ, 4, 1, [v[2][ii, jj].sage() for ii in range(4)]) 

O_units.append(vec) 

return O_units 

 

@cached_method 

def _get_Up_data(self): 

r""" 

Return (compute if necessary) Up data. 

 

The Up data is a vector of length `p`, and each entry consists 

of the corresponding data for the matrix `[p,a,0,1]` where a 

varies from 0 to `p-1`. The data is a tuple (acter,edge_images), 

with edge images being of type ``DoubleCosetReduction``. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,7) 

sage: [o[0] for o in X._get_Up_data()] 

[ 

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

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

] 

""" 

E = self.get_edge_list() 

vec_a = self._BT.subdivide([1], 1) 

return [[alpha.inverse(), 

[DoubleCosetReduction(self, e.rep * alpha) for e in E] 

+ [DoubleCosetReduction(self, e.opposite.rep * alpha) 

for e in E]] 

for alpha in vec_a] 

 

@cached_method 

def _get_atkin_lehner_data(self, q): 

r""" 

Return (and compute if necessary) data to compute the 

Atkin-Lehner involution. 

 

INPUT: 

 

- ``q`` - integer dividing p*Nminus*Nplus 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,5) 

sage: X._get_atkin_lehner_data(3)[0] 

[ 2] 

[ 4] 

[-3] 

[-2] 

""" 

E = self.get_edge_list() 

# self._increase_precision(20) 

 

nninc = -2 

V = [] 

p = self._p 

while len(V) == 0: 

nninc += 2 

#print 'Searching for norm', q*self._p**nninc 

F = lambda g: prod([self._character(ZZ((v * Matrix(ZZ, 4, 1, g))[0, 0])) / self._character((p ** ZZ(nninc / 2))) for v in self.get_extra_embedding_matrices()]) == 1 

V = filter(F, self._find_elements_in_order(q * self._p ** nninc)) 

 

beta1 = Matrix(QQ, 4, 1, V[0]) 

 

success = False 

while not success: 

try: 

x = self.embed_quaternion(beta1) 

nn = x.determinant().valuation() 

T = [beta1, 

[DoubleCosetReduction(self, x.adjoint() * e.rep, 

extrapow=nn) for e in E]] 

success = True 

except (PrecisionError, NotImplementedError): 

self._increase_precision(10) 

return T 

 

@cached_method 

def _get_hecke_data(self, l): 

r""" 

Return (and compute if necessary) data to compute the 

Hecke operator at a prime. 

 

INPUT: 

 

- ``l`` - a prime l. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,17) 

sage: len(X._get_hecke_data(5)) 

2 

""" 

E = self.get_edge_list() 

if (self.level() * self.Nplus()) % l == 0: 

Sset = [] 

else: 

Sset = [self._p] 

BB = self._BB 

p = self._p 

T = [] 

T0 = [] 

V = [] 

nninc = 0 

while len(V) == 0: 

V = filter(lambda g: prod([self._character(ZZ((v * Matrix(ZZ, 4, 1, g))[0, 0])) / self._character((p ** ZZ(nninc / 2))) for v in self.get_extra_embedding_matrices()]) == 1, self._find_elements_in_order(l * p ** nninc)) 

if len(V) == 0: 

nninc += 2 

 

alpha1 = V[0] 

alpha0 = self._conv(alpha1) 

 

alpha = Matrix(QQ, 4, 1, alpha1) 

alphamat = self.embed_quaternion(alpha) 

letters = self.get_nontorsion_generators() + filter(lambda g: prod([self._character(ZZ((v * Matrix(ZZ, 4, 1, g))[0, 0])) / self._character((p ** ZZ(nninc / 2))) for v in self.get_extra_embedding_matrices()]) == 1, self._find_elements_in_order(1)) 

n_iters = 0 

 

def enumerate_words(v, n=None): 

if n is None: 

n = [] 

while True: 

add_new = True 

for jj in range(len(n)): 

n[jj] += 1 

if n[jj] != len(v): 

add_new = False 

break 

else: 

n[jj] = 0 

if add_new: 

n.append(0) 

yield [v[x] for x in n] 

 

for wd in enumerate_words([self._conv(x) for x in letters]): 

if len(T) == l + 1: 

break 

v = prod(wd) 

n_iters += 1 

v0 = v * alpha0 

vinv = self.get_quaternion_algebra()(v0 ** (-1)) 

new = True 

for tt in T0: 

r = vinv * tt 

r_in_order = BB * Matrix(QQ, 4, 1, r.coefficient_tuple()) 

if all([a.is_S_integral(Sset) for a in r_in_order.list()]): 

new = False 

break 

if new: 

v1 = BB * Matrix(QQ, 4, 1, v.coefficient_tuple()) 

success = False 

while not success: 

try: 

x = self.embed_quaternion(v1, prec=max(self._prec, 40), 

exact=False) * alphamat 

nn = x.determinant().valuation() 

dcr = [DoubleCosetReduction(self, x.adjoint() * e.rep, 

extrapow=nn) for e in E] 

T.append([v1, dcr]) 

success = True 

except (PrecisionError, NotImplementedError): 

self._increase_precision(10) 

alphamat = self.embed_quaternion(alpha, prec=max(self._prec, 40), exact=False) 

T0.append(v0) 

return T, alpha 

 

def _find_equivalent_vertex(self, v0, V=None, valuation=None): 

r""" 

Find a vertex in ``V`` equivalent to ``v0``. 

 

INPUT: 

 

- ``v0`` -- a 2x2 matrix in `\ZZ_p` representing a 

vertex in the Bruhat-Tits tree. 

 

- ``V`` -- list (Default: None) If a list of Vertex is given, 

restrict the search to the vertices in ``V``. Otherwise 

use all the vertices in a fundamental domain. 

 

- ``valuation`` -- an integer (Default: None): The valuation 

of the determinant of ``v0``, if known (otherwise it is 

calculated). 

 

OUTPUT: 

 

A pair ``g``, ``v``, where ``v`` is a Vertex in ``V`` 

equivalent to ``v0``, and ``g`` is such that `g\cdot v_0= v`. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,7) 

sage: M = Matrix(ZZ,2,2,[1,3,2,7]) 

sage: M.set_immutable() 

sage: X._find_equivalent_vertex(M)[-1] in X.get_vertex_list() 

True 

""" 

try: 

return self._cached_vertices[v0] 

except KeyError: 

pass 

if V is None: 

V = self.get_vertex_list() 

if valuation is None: 

valuation = v0.determinant().valuation(self._p) 

parity = valuation % 2 

for v in filter(lambda v: v.parity == parity, V): 

g = self._are_equivalent(v0, v.rep, False, valuation + v.valuation) 

if g is not None: 

self._cached_vertices[v0] = (g, v) 

return g, v 

return 0, None 

 

def _find_equivalent_edge(self, e0, E=None, valuation=None): 

r""" 

Find an edge in ``E`` equivalent to ``e0``. 

 

INPUT: 

 

- ``e0`` -- a 2x2 matrix in `\ZZ_p` representing an 

edge in the Bruhat-Tits tree. 

 

- ``E`` -- list (Default: None) If a list of Edge is given, 

restrict the search to the vertices in ``E``. Otherwise 

use all the edges in a fundamental domain. 

 

- ``valuation`` -- an integer (Default: None): The valuation 

of the determinant of ``e0``, if known (otherwise it is 

calculated). 

 

OUTPUT: 

 

A pair ``g``, ``e``, where ``e`` is an Edge in ``E`` 

equivalent to ``e0``, and ``g`` is such that `g\cdot e_0= e`. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,7) 

sage: M = Matrix(ZZ,2,2,[1,3,2,7]) 

sage: M.set_immutable() 

sage: X._find_equivalent_edge(M)[-1] in X.get_edge_list() 

True 

""" 

try: 

return self._cached_edges[e0] 

except KeyError: 

pass 

if valuation is None: 

valuation = e0.determinant().valuation(self._p) 

parity = valuation % 2 

if E is None: 

if parity == 0: 

E = self._edge_list 

else: 

E = [e.opposite for e in self._edge_list] 

for e in filter(lambda x: x.parity == parity, E): 

g = self._are_equivalent(e.rep, e0, True, valuation + e.valuation) 

if g is not None: 

self._cached_edges[e0] = (g, e) 

return g, e 

return 0, None 

 

def fundom_rep(self, v1): 

r""" 

Find an equivalent vertex in the fundamental domain. 

 

INPUT: 

 

- ``v1`` - a 2x2 matrix representing a normalized vertex. 

 

OUTPUT: 

 

A ``Vertex`` equivalent to ``v1``, in the fundamental domain. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,7) 

sage: M = Matrix(ZZ,2,2,[1,3,2,7]) 

sage: M.set_immutable() 

sage: X.fundom_rep(M) 

Vertex of Bruhat-Tits tree for p = 3 

""" 

try: 

tmp = self._cached_paths[v1] 

return tmp 

except KeyError: 

pass 

# print('v1=',v1) 

chain, v = self._BT.find_path(v1, self.get_vertex_dict()) 

# print('chain =', chain) 

while len(chain): 

v0 = chain.pop() 

V = [e.target for e in v.leaving_edges] 

g, v = self._find_equivalent_vertex(v0, V) 

if v is None: 

print('Given vertex:', v0) 

print('Not equivalent to any existing vertex in the list:') 

if V is not None: 

print([ve.label for ve in V]) 

assert 0 # what the hell is that ? 

self._cached_paths[v0] = v 

return v 

 

def _find_lattice(self, v1, v2, as_edges, m): 

r""" 

Find the lattice attached to the pair ``v1``,``v2``. 

 

INPUT: 

 

- ``v1``, ``v2`` - 2x2 matrices. They represent either a pair 

of normalized vertices or a pair of normalized edges. 

 

- ``as_edges`` - boolean. If True, the inputs will be 

considered as edges instead of vertices. 

 

- ``m`` - integer - The valuation of the determinant of 

``v1``*``v2``. 

 

OUTPUT: 

 

A 4x4 integer matrix whose columns encode a lattice and a 4x4 integer matrix encoding a quadratic form. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,17) 

sage: X._find_lattice(Matrix(ZZ,2,2,[1,2,3,4]),Matrix(ZZ,2,2,[3,2,1,5]), True,0) 

( 

[1 0 0 0] [138 204 -35 102] 

[2 3 0 0] [204 306 -51 153] 

[0 0 1 0] [-35 -51 12 -34] 

[0 0 0 1], [102 153 -34 102] 

) 

""" 

if(as_edges): 

X = self._Xe 

else: 

X = self._Xv 

if m + 1 > self._prec: 

self.get_embedding_matrix(prec=m + 1) 

v1adj = v1.adjoint() 

R = self._Mat_44 

vecM = [v2 * X[ii] * v1adj for ii in range(4)] 

M = self._Iotainv * R([[vecM[ii][jj, kk] for ii in range(4)] 

for jj in range(2) for kk in range(2)]) 

M = M.augment(R(self._pN)).transpose() 

E = M.echelon_form().submatrix(0, 0, 4, 4) 

Et = E.transpose() 

return Et, E * self.get_eichler_order_quadmatrix() * Et 

 

def _stabilizer(self, e, as_edge=True): 

r""" 

Find the stabilizer of an edge or vertex. 

 

INPUT: 

 

- ``e`` - A 2x2 matrix representing an edge or vertex 

 

- ``as_edge`` - Boolean (Default = True). Determines whether 

``e`` is treated as an edge or vertex 

 

OUTPUT: 

 

A list of data describing the (finite) stabilizing subgroup 

of ``e``. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,7) 

sage: X._stabilizer(Matrix(ZZ,2,2,[3,8,2,9]))[0][2] 

False 

""" 

p = self._p 

m = e.determinant().valuation(p) 

twom = 2 * m 

E, A = self._find_lattice(e, e, as_edge, twom) 

n_units = len(self.get_units_of_order()) 

## Using PARI to get the shortest vector in the lattice (via LLL) 

## We used to pass qfminim flag = 2 

mat = pari('qfminim(%s,,%s,flag = 2)' % (A.__pari__(), 2 * n_units))[2].sage().transpose() 

n_vecs = mat.nrows() 

stabs = [] 

for jj in range(n_vecs): 

vect = mat.row(jj).row() 

vec = vect.transpose() 

nrd = Integer((vect * A * vec)[0, 0] / 2) 

if nrd == p ** twom: 

g, ans = self._nebentype_check(vec, twom, E, A, flag=0) 

if ans: 

x = self._conv(g.transpose()) 

g.set_immutable() 

stabs.append([g, m, x != p ** m]) 

if len(stabs) <= 1: 

return [[self.B_one(), 0, False]] 

else: 

return stabs 

 

def _nebentype_check(self, vec, twom, E, A, flag = 2): 

""" 

Check if a quaternion maps into a subgroup of matrices 

determined by a nontrivial Dirichlet character (associated to 

self). If `N^+ = 1` then the condition is trivially satisfied. 

 

INPUT: 

 

- ``vec`` - 4x1 integer matrix. It encodes the quaternion to 

test in the basis defined by the columns of E. 

 

- ``twom`` - An integer. 

 

- ``E`` - 4x4 integer matrix. Its columns should form a 

basis for an order in the quaternion algebra. 

 

- ``A`` - 4x4 integer matrix. It encodes the quadratic form on the order defined by the columns of E. 

 

- ``flag`` - integer (Default = 0). Passed to Pari for finding 

minimal elements in a positive definite lattice. 

 

OUTPUT: 

 

A pair consisting of a quaternion (represented by a 4x1 column 

matrix) and a boolean saying whether the quaternion is in the 

subgroup of `M_2(\Qp)` determined by the Dirichlet 

character. Note that if `N^+` is trivial then this function 

aways outputs true. 

 

EXAMPLES:: 

 

sage: f = DirichletGroup(6)[1] 

sage: X = BruhatTitsQuotient(3,2,1,f) 

sage: e = Matrix(ZZ,2,2,[1,2,5,7]) 

sage: m = e.determinant().valuation(3) 

sage: twom = 2*m 

sage: E,A = X._find_lattice(e,e,True,twom) 

sage: X._nebentype_check(E**(-1)*Matrix(ZZ,4,1,[1,0,0,0]),twom,E,A) 

( 

[1] 

[0] 

[0] 

[0], True 

) 

""" 

if not self._use_magma or len(self._extra_level) == 0: 

return E * vec, True 

m = ZZ(twom / 2) 

mat = pari('qfminim(%s,,%s,flag = %s)' % (A.__pari__(), 1000, flag))[2].sage().transpose() 

n_vecs = mat.nrows() 

p = self._p 

pinv = Zmod(self._character.modulus())(p) ** -1 

for jj in range(n_vecs): 

vect = mat.row(jj).row() 

vec = vect.transpose() 

nrd = Integer((vect * A * vec)[0, 0] / 2) 

if nrd == p ** twom: 

g = E * vec 

if prod([self._character(ZZ(pinv ** m * (v * g)[0, 0])) 

for v in self.get_extra_embedding_matrices()]) == 1: 

return g, True 

return None, False 

 

def _are_equivalent(self, v1, v2, as_edges=False, twom=None, 

check_parity=False): 

r""" 

Determine whether two vertices (or edges) of the 

Bruhat-Tits tree are equivalent under the arithmetic group in 

question. The computation boils down to an application of the 

LLL short-vector algorithm to a particular lattice; for 

details see [FM2014]_. 

 

INPUT: 

 

- ``v1``, ``v2`` - two 2x2 integral matrices representing 

either vertices or edges 

 

- ``as_edges`` - boolean (Default: False). Tells whether the 

matrices should be interpreted as edges (if true), or as 

vertices (if false) 

 

- ``twom`` - integer (Default: None) If specified, 

indicates the valuation of the determinant of ``v1`` 

`\times` ``v2``. 

 

OUTPUT: 

 

If the objects are equivalent, returns an element of 

the arithmetic group Gamma that takes ``v1`` to ``v2``. 

Otherwise returns False. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,5) 

sage: M1 = Matrix(ZZ,2,2,[88,3,1,1]) 

sage: M1.set_immutable() 

sage: X._are_equivalent(M1,M1) == False 

False 

sage: M2 = Matrix(ZZ,2,2,[1,2,8,1]); M2.set_immutable() 

sage: X._are_equivalent(M1,M2, as_edges=True) 

sage: X._are_equivalent(M1,M2) == False 

False 

""" 

try: 

return self._cached_equivalent[(v1, v2, as_edges)] 

except KeyError: 

pass 

p = self._p 

if twom is None: 

twom = v1.determinant().valuation(p) + v2.determinant().valuation(p) 

if check_parity: 

if twom % 2 != 0: 

self._cached_equivalent[(v1, v2, as_edges)] = None 

return None 

E, A = self._find_lattice(v1, v2, as_edges, twom) 

## Using PARI to get the shortest vector in the lattice (via LLL) 

vec = pari('qfminim(%s,,1,flag = 2)' % (A.__pari__()))[2].sage() 

 

vect = vec.transpose() 

nrd = Integer((vect * A * vec)[0, 0] / 2) 

if nrd == p ** twom: 

g, ans = self._nebentype_check(vec, twom, E, A) 

if ans: 

m = Integer(twom / 2) 

g.set_immutable() 

self._cached_equivalent[(v1, v2, as_edges)] = (g, m) 

return (g, m) 

self._cached_equivalent[(v1, v2, as_edges)] = None 

return None 

 

def _compute_exact_splitting(self): 

r""" 

Use Magma to calculate a splitting of the order into 

the Matrix algebra with coefficients in an appropriate 

number field. 

 

TESTS:: 

 

sage: X = BruhatTitsQuotient(3,23,use_magma=True) # optional - magma 

sage: X._compute_exact_splitting() # optional - magma 

""" 

# A = self.get_quaternion_algebra() 

R = self.get_maximal_order(magma=True) 

f = R.MatrixRepresentation() 

self._FF = NumberField(f.Codomain().BaseRing().DefiningPolynomial().sage(), 'a') 

allmats = [] 

verbose('Calling magma, compute exact splitting') 

for kk in range(4): 

xseq = self._magma('%s(%s)' % (f.name(), R.gen(kk + 1).name())).ElementToSequence() 

allmats.append(Matrix(self._FF, 2, 2, [self._FF([QQ(xseq[ii + 1][jj + 1]) for jj in range(2)]) for ii in range(4)])) 

self._Iota_exact = Matrix(self._FF, 4, 4, [self._FF(allmats[kk][ii, jj]) for ii in range(2) for jj in range(2) for kk in range(4)]) 

 

def _init_order(self): 

r""" 

Initialize the order of the quaternion algebra. Here we 

possibly use Magma to split it. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(3,23) 

sage: X._init_order() 

""" 

if self._order_is_initialized: 

return 

if self._use_magma: 

verbose('Calling magma, init_order') 

A = self._magma.QuaternionAlgebra(self._Nminus) 

g = A.gens() 

# We store the order because we need to split it 

OMaxmagma = A.QuaternionOrder(1) 

Omagma = OMaxmagma.Order(self._Nplus) 

OBasis = Omagma.Basis() 

self._A = QuaternionAlgebra((g[0] ** 2).sage(), (g[1] ** 2).sage()) 

i, j, k = self._A.gens() 

v = [1] + self._A.gens() 

self._B = [self._A(sum([OBasis[tt + 1][rr + 1].sage() * v[rr] 

for rr in range(4)])) for tt in range(4)] 

self._O = self._A.quaternion_order(self._B) 

self._Omagma = Omagma 

self._OMaxmagma = OMaxmagma 

else: 

# Note that we can't work with non-maximal orders in sage 

assert self._Nplus == 1 

self._A = QuaternionAlgebra(self._Nminus) 

v = [1] + self._A.gens() 

self._O = self._A.maximal_order() 

self._OMax = self._O 

OBasis = self._O.basis() 

self._B = [self._A(OBasis[tt]) for tt in range(4)] 

 

self._OQuadForm = QuadraticForm(self._Mat_44([(self._B[ii] * self._B[jj].conjugate()).reduced_trace() for ii in range(4) for jj in range(4)])) 

self._OM = self._OQuadForm.matrix() 

self._BB = Matrix(QQ, 4, 4, [[self._B[ii][jj] for ii in range(4)] 

for jj in range(4)]).inverse() 

self._order_is_initialized = True 

return 

 

def B_one(self): 

r""" 

Return the coordinates of `1` in the basis for the 

quaternion order. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(7,11) 

sage: v,pow = X.B_one() 

sage: X._conv(v) == 1 

True 

""" 

try: 

return self._B_one 

except AttributeError: 

O = self.get_eichler_order_basis() 

self._B_one = (Matrix(ZZ, 4, 1, Matrix(QQ, 4, 4, [list(x) for x in O]).transpose().inverse().column(0).list()), 0) 

return self._B_one 

 

def _conv(self, v): 

r""" 

Return a quaternion having coordinates in the fixed 

basis for the order given by ``v``. 

 

OUTPUT: 

 

A quaternion. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: A = X.get_quaternion_algebra() 

sage: i,j,k = A.gens() 

sage: B = X.get_eichler_order_basis() 

sage: X._conv([1,2,3,4]) == B[0]+2*B[1]+3*B[2]+4*B[3] 

True 

""" 

if hasattr(v, "list"): 

v = v.list() 

B = self.get_eichler_order_basis() 

return sum([v[i] * B[i] for i in range(4)]) 

 

@cached_method 

def _find_elements_in_order(self, norm, trace=None, primitive=False): 

r""" 

Return elements in the order of the quaternion algebra 

of specified reduced norm. One may optionally choose to 

specify the reduced trace. 

 

INPUT: 

 

- ``norm`` - integer. The required reduced norm. 

 

- ``trace`` - integer (Default: None). If specified, returns 

elements only reduced trace ``trace``. 

 

- ``primitive`` boolean (Default: False). If True, return only 

elements that cannot be divided by `p`. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(5,7) 

sage: X._find_elements_in_order(23) 

[[2, 9, -1, -5], [0, 8, 0, -5], [-2, 9, 1, -5], [6, 7, -3, -4], [2, 5, -1, -4], [0, 6, -1, -4], [0, 8, -1, -4], [2, 9, -1, -4], [-2, 5, 1, -4], [0, 6, 1, -4], [0, 8, 1, -4], [-2, 9, 1, -4], [-6, 7, 3, -4], [7, 6, -4, -3], [7, 6, -3, -3], [6, 7, -3, -3], [0, 8, 0, -3], [-7, 6, 3, -3], [-6, 7, 3, -3], [-7, 6, 4, -3], [0, 1, -1, -2], [0, 6, -1, -2], [0, 1, 1, -2], [0, 6, 1, -2], [9, 2, -5, -1], [6, 0, -4, -1], [8, 0, -4, -1], [5, 2, -4, -1], [9, 2, -4, -1], [1, 0, -2, -1], [6, 0, -2, -1], [0, -1, -1, -1], [-1, 0, -1, -1], [5, 2, -1, -1], [2, 5, -1, -1], [0, -1, 1, -1], [1, 0, 1, -1], [-5, 2, 1, -1], [-2, 5, 1, -1], [-6, 0, 2, -1], [-1, 0, 2, -1], [-8, 0, 4, -1], [-6, 0, 4, -1], [-9, 2, 4, -1], [-5, 2, 4, -1], [-9, 2, 5, -1], [8, 0, -5, 0], [8, 0, -3, 0]] 

sage: X._find_elements_in_order(23,1) 

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

""" 

OQuadForm = self.get_eichler_order_quadform() 

if norm > 10 ** 3: 

verbose('Warning: norm (= %s) is quite large, this may take some time!' % norm) 

V = OQuadForm.vectors_by_length(norm)[norm] 

W = V if not primitive else filter(lambda v: any((vi % self._p != 0 for vi in v)), V) 

return W if trace is None else filter(lambda v: self._conv(v).reduced_trace() == trace, W) 

 

def _compute_quotient(self, check=True): 

r""" 

Compute the quotient graph. 

 

INPUT: 

 

- ``check`` - Boolean (Default = True). 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(11,2) 

sage: X.get_graph() # indirect doctest 

Multi-graph on 2 vertices 

 

sage: X = BruhatTitsQuotient(17,19) 

sage: X.get_graph() # indirect doctest 

Multi-graph on 4 vertices 

 

The following examples require magma:: 

 

sage: X = BruhatTitsQuotient(5,7,12) # optional - magma 

sage: X.get_graph() # optional - magma 

Multi-graph on 24 vertices 

sage: len(X._edge_list) # optional - magma 

72 

 

sage: X = BruhatTitsQuotient(2,3,5) # optional - magma 

sage: X.get_graph() # optional - magma 

Multi-graph on 4 vertices 

 

sage: X = BruhatTitsQuotient(2,3,35) # optional - magma 

sage: X.get_graph() # optional - magma 

Multi-graph on 16 vertices 

 

sage: X = BruhatTitsQuotient(53,11,2) # optional - magma 

sage: X.get_graph() # optional - magma 

Multi-graph on 6 vertices 

 

sage: X = BruhatTitsQuotient(2,13,9) # optional - magma 

sage: X.get_graph() # optional - magma 

Multi-graph on 24 vertices 

 

AUTHORS: 

 

- Cameron Franc (2012-02-20) 

- Marc Masdeu 

""" 

nontorsion_generators = set([]) 

genus = self.genus() 

num_verts = 0 

num_edges = 0 

self.get_embedding_matrix(prec=3) 

p = self._p 

v0 = Vertex(p, num_verts, self._Mat_22([1, 0, 0, 1]), 

determinant=1, valuation=0) 

V = collections.deque([v0]) 

S = Graph(0, multiedges=True, weighted=True) 

Sfun = Graph(0) 

edge_list = [] 

vertex_list = [v0] 

num_edges = 0 

num_verts += 1 

# total_verts = self.get_num_verts() 

# total_edges = genus + total_verts -1 

while len(V): 

v = V.popleft() 

E = self._BT.leaving_edges(v.rep) 

 

verbose('V = %s, E = %s, G = %s (target = %s), lenV = %s'%(num_verts,num_edges,1+num_edges-num_verts,genus,len(V))) 

for e in E: 

edge_det = e.determinant() 

edge_valuation = edge_det.valuation(p) 

 

g, e1 = self._find_equivalent_edge(e, v.leaving_edges, 

valuation=edge_valuation) 

 

if e1 is not None: # The edge is old. We just update the links 

e1.links.append(g) 

target = self._BT.target(e) 

if e1.parity == 0: 

Sfun.add_edge(v.rep, target, label=e1.label) 

else: 

Sfun.add_edge(v.rep, target, label=e1.opposite.label) 

 

Sfun.set_vertex(target, e1.target) 

else: # The edge is new. 

target = self._BT.target(e) 

target.set_immutable() 

new_det = target.determinant() 

new_valuation = new_det.valuation(p) 

# new_parity = new_valuation % 2 

g1, v1 = self._find_equivalent_vertex(target, V, valuation=new_valuation) 

if v1 is None: 

#The vertex is also new 

v1 = Vertex(p, num_verts, target, determinant=new_det, 

valuation=new_valuation) 

vertex_list.append(v1) 

num_verts += 1 

#Add the vertex to the list of pending vertices 

V.append(v1) 

else: 

nontorsion_generators.add(g1[0]) 

 

# Add the edge to the list 

new_e = Edge(p, num_edges, e, v, v1, determinant=edge_det, 

valuation=edge_valuation) 

new_e.links.append(self.B_one()) 

Sfun.add_edge(v.rep, target, label=num_edges) 

Sfun.set_vertex(target, v1) 

 

# Add the edge to the graph 

S.add_edge(v.rep, v1.rep, num_edges) 

S.set_vertex(v.rep, v) 

S.set_vertex(v1.rep, v1) 

 

# Find the opposite edge 

opp = self._BT.opposite(e) 

# opp_det = opp.determinant() 

new_e_opp = Edge(p, num_edges, opp, v1, v, opposite=new_e) 

new_e.opposite = new_e_opp 

 

if new_e.parity == 0: 

edge_list.append(new_e) 

else: 

edge_list.append(new_e_opp) 

 

v.leaving_edges.append(new_e) 

v.entering_edges.append(new_e_opp) 

v1.entering_edges.append(new_e) 

v1.leaving_edges.append(new_e_opp) 

num_edges += 1 

computed_genus = Integer(1 - len(vertex_list) + num_edges) 

if check: 

if computed_genus != genus: 

print('You found a bug! Please report!') 

print('Computed genus =', computed_genus) 

print('Theoretical genus =', genus) 

raise RuntimeError 

if self.get_num_verts() != len(vertex_list): 

raise RuntimeError('Number of vertices different ' 

'from expected.') 

 

self._nontorsion_generators = nontorsion_generators 

self._boundary = dict([(vv.rep, vv) for vv in vertex_list]) 

self._edge_list = edge_list 

self._vertex_list = vertex_list 

self._num_edges = num_edges 

self._S = S 

self._Sfun = Sfun 

 

def harmonic_cocycle_from_elliptic_curve(self, E, prec=None): 

r""" 

Return a harmonic cocycle with the same Hecke eigenvalues as ``E``. 

 

Given an elliptic curve `E` having a conductor `N` of the form `pN^-N^+`, 

return the harmonic cocycle over ``self`` which is attached to ``E`` via 

modularity. The result is only well-defined up to scaling. 

 

INPUT: 

 

- ``E`` -- an elliptic curve over the rational numbers 

 

- ``prec`` -- (default: None) If specified, the harmonic cocycle will take values 

in `\QQ_p` with precision ``prec``. Otherwise it will take values in `\ZZ`. 

 

OUTPUT: 

 

A harmonic cocycle attached via modularity to the given elliptic curve. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('21a1') 

sage: X = BruhatTitsQuotient(7,3) 

sage: f = X.harmonic_cocycle_from_elliptic_curve(E,10) 

sage: T29 = f.parent().hecke_operator(29) 

sage: T29(f) == E.ap(29) * f 

True 

sage: E = EllipticCurve('51a1') 

sage: X = BruhatTitsQuotient(3,17) 

sage: f = X.harmonic_cocycle_from_elliptic_curve(E,20) 

sage: T31 = f.parent().hecke_operator(31) 

sage: T31(f) == E.ap(31) * f 

True 

""" 

from .pautomorphicform import BruhatTitsHarmonicCocycles 

M = BruhatTitsHarmonicCocycles(self, 2, prec=prec) 

q = ZZ.one() 

F = E.base_ring() 

try: 

N = ZZ(E.conductor()) 

except TypeError: 

try: 

N = E.conductor().norm() 

except ValueError: 

N = E.conductor().norm(QQ) 

N1 = self.level() * self.Nplus() 

K = M.base_ring() ** M.dimension() 

while K.dimension() != 1: 

q = q.next_prime() 

if N % q == 0 or N1 % q == 0: 

continue 

if F == QQ: 

Eap = E.ap(q) 

else: 

Q = F(q).factor()[0][0] 

Eap = ZZ(Q.norm() + 1 - E.reduction(Q).count_points()) 

K1 = (M.hecke_matrix(q).transpose() - Eap).right_kernel() 

K = K.intersection(K1) 

col = [ZZ(o) for o in K.matrix().list()] 

return sum([a * M.gen(i) for i, a in enumerate(col) if a != 0], M(0)) 

 

def harmonic_cocycles(self, k, prec=None, basis_matrix=None, base_field=None): 

r""" 

Compute the space of harmonic cocycles of a given even weight ``k``. 

 

INPUT: 

 

- ``k`` - integer - The weight. It must be even. 

 

- ``prec`` - integer (default: None). If specified, the 

precision for the coefficient module 

 

- ``basis_matrix`` - a matrix (default: None). 

 

- ``base_field`` - a ring (default: None) 

 

OUTPUT: A space of harmonic cocycles 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(31,7) 

sage: H = X.harmonic_cocycles(2,prec=10) 

sage: H 

Space of harmonic cocycles of weight 2 on Quotient of the Bruhat Tits tree of GL_2(QQ_31) with discriminant 7 and level 1 

sage: H.basis()[0] 

Harmonic cocycle with values in Sym^0 Q_31^2 

""" 

from .pautomorphicform import BruhatTitsHarmonicCocycles 

return BruhatTitsHarmonicCocycles(self, k, prec=prec, basis_matrix=basis_matrix, base_field=base_field) 

 

def padic_automorphic_forms(self, U, prec=None, t=None, R=None, overconvergent=False): 

r""" 

The module of (quaternionic) `p`-adic automorphic forms over ``self``. 

 

INPUT: 

 

- ``U`` -- A distributions module or an integer. If ``U`` is a 

distributions module then this creates the relevant space of 

automorphic forms. If ``U`` is an integer then the coefficients 

are the (`U-2`)nd power of the symmetric representation of 

`GL_2(\QQ_p)`. 

 

- ``prec`` -- A precision (default : None). If not None should 

be a positive integer. 

 

- ``t`` -- (default : None). The number of additional moments to store. If None, determine 

it automatically from ``prec``, ``U`` and the ``overconvergent`` flag. 

 

- ``R`` -- (default : None). If specified, coefficient field of the automorphic forms. 

If not specified it defaults to the base ring of the distributions ``U``, or to `\QQ_p` 

with the working precision ``prec``. 

 

- ``overconvergent`` -- Boolean (default = False). If True, will construct overconvergent 

`p`-adic automorphic forms. Otherwise it constructs the finite dimensional space of 

`p`-adic automorphic forms which is isomorphic to the space of harmonic cocycles. 

 

EXAMPLES:: 

 

sage: X = BruhatTitsQuotient(11,5) 

sage: X.padic_automorphic_forms(2,prec=10) 

Space of automorphic forms on Quotient of the Bruhat Tits tree of GL_2(QQ_11) with discriminant 5 and level 1 with values in Sym^0 Q_11^2 

""" 

from .pautomorphicform import pAdicAutomorphicForms 

return pAdicAutomorphicForms(self, U, prec=prec, t=t, R=R, overconvergent=overconvergent)