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

r""" 

Algebraic schemes 

 

An algebraic scheme is defined by a set of polynomials in some 

suitable affine or projective coordinates. Possible ambient spaces are 

 

* Affine spaces (:class:`AffineSpace 

<sage.schemes.affine.affine_space.AffineSpace_generic>`), 

 

* Projective spaces (:class:`ProjectiveSpace 

<sage.schemes.projective.projective_space.ProjectiveSpace_ring>`), or 

 

* Toric varieties (:class:`ToricVariety 

<sage.schemes.toric.variety.ToricVariety_field>`). 

 

Note that while projective spaces are of course toric varieties themselves, 

they are implemented differently in Sage due to efficiency considerations. 

You still can create a projective space as a toric variety if you wish. 

 

In the following, we call the corresponding subschemes affine 

algebraic schemes, projective algebraic schemes, or toric algebraic 

schemes. In the future other ambient spaces, perhaps by means of 

gluing relations, may be introduced. 

 

Generally, polynomials `p_0, p_1, \dots, p_n` define an ideal 

`I=\left<p_0, p_1, \dots, p_n\right>`. In the projective and toric case, the 

polynomials (and, therefore, the ideal) must be homogeneous. The 

associated subscheme `V(I)` of the ambient space is, roughly speaking, 

the subset of the ambient space on which all polynomials vanish simultaneously. 

 

.. WARNING:: 

 

You should not construct algebraic scheme objects directly. Instead, use 

``.subscheme()`` methods of ambient spaces. See below for examples. 

 

EXAMPLES: 

 

We first construct the ambient space, here the affine space `\QQ^2`:: 

 

sage: A2 = AffineSpace(2, QQ, 'x, y') 

sage: A2.coordinate_ring().inject_variables() 

Defining x, y 

 

Now we can write polynomial equations in the variables `x` and `y`. For 

example, one equation cuts out a curve (a one-dimensional subscheme):: 

 

sage: V = A2.subscheme([x^2+y^2-1]); V 

Closed subscheme of Affine Space of dimension 2 

over Rational Field defined by: 

x^2 + y^2 - 1 

sage: V.dimension() 

1 

 

Here is a more complicated example in a projective space:: 

 

sage: P3 = ProjectiveSpace(3, QQ, 'x') 

sage: P3.inject_variables() 

Defining x0, x1, x2, x3 

sage: Q = matrix([[x0, x1, x2], [x1, x2, x3]]).minors(2); Q 

[-x1^2 + x0*x2, -x1*x2 + x0*x3, -x2^2 + x1*x3] 

sage: twisted_cubic = P3.subscheme(Q) 

sage: twisted_cubic 

Closed subscheme of Projective Space of dimension 3 

over Rational Field defined by: 

-x1^2 + x0*x2, 

-x1*x2 + x0*x3, 

-x2^2 + x1*x3 

sage: twisted_cubic.dimension() 

1 

 

Note that there are 3 equations in the 3-dimensional ambient space, 

yet the subscheme is 1-dimensional. One can show that it is not 

possible to eliminate any of the equations, that is, the twisted cubic 

is **not** a complete intersection of two polynomial equations. 

 

Let us look at one affine patch, for example the one where `x_0=1` :: 

 

sage: patch = twisted_cubic.affine_patch(0) 

sage: patch 

Closed subscheme of Affine Space of dimension 3 

over Rational Field defined by: 

-x0^2 + x1, 

-x0*x1 + x2, 

-x1^2 + x0*x2 

sage: patch.embedding_morphism() 

Scheme morphism: 

From: Closed subscheme of Affine Space of dimension 3 

over Rational Field defined by: 

-x0^2 + x1, 

-x0*x1 + x2, 

-x1^2 + x0*x2 

To: Closed subscheme of Projective Space of dimension 3 

over Rational Field defined by: 

x1^2 - x0*x2, 

x1*x2 - x0*x3, 

x2^2 - x1*x3 

Defn: Defined on coordinates by sending (x0, x1, x2) to 

(1 : x0 : x1 : x2) 

 

 

AUTHORS: 

 

- David Kohel (2005): initial version. 

- William Stein (2005): initial version. 

- Andrey Novoseltsev (2010-05-17): subschemes of toric varieties. 

- Volker Braun (2010-12-24): documentation of schemes and 

refactoring. Added coordinate neighborhoods and is_smooth() 

- Ben Hutz (2014): subschemes of Cartesian products of projective space 

- Ben Hutz (2017): split subschemes types into respective folders 

""" 

from __future__ import absolute_import 

 

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

# Copyright (C) 2010 Volker Braun <vbraun.name@gmail.com> 

# Copyright (C) 2005 David Kohel <kohel@maths.usyd.edu.au> 

# Copyright (C) 2010 Andrey Novoseltsev <novoselt@gmail.com> 

# Copyright (C) 2005 William Stein <wstein@gmail.com> 

# 

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

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

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

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

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

 

 

#*** A quick overview over the class hierarchy: 

# class AlgebraicScheme(scheme.Scheme) 

# class AlgebraicScheme_subscheme 

# class AlgebraicScheme_subscheme_affine 

# class AlgebraicScheme_subscheme_projective 

# class AlgebraicScheme_subscheme_toric 

# class AlgebraicScheme_subscheme_affine_toric 

# class AlgebraicScheme_quasi 

 

 

from sage.combinat.tuple import UnorderedTuples 

 

from sage.categories.number_fields import NumberFields 

from sage.categories.morphism import Morphism 

 

from sage.rings.all import ZZ 

from sage.rings.ideal import is_Ideal 

from sage.rings.rational_field import is_RationalField 

from sage.rings.finite_rings.finite_field_constructor import is_FiniteField 

 

from sage.misc.latex import latex 

from sage.misc.misc import is_iterator 

from sage.structure.all import Sequence 

from sage.structure.richcmp import richcmp, richcmp_method 

from sage.calculus.functions import jacobian 

 

import sage.schemes.affine 

from . import ambient_space 

from . import scheme 

 

 

 

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

def is_AlgebraicScheme(x): 

""" 

Test whether ``x`` is an algebraic scheme. 

 

INPUT: 

 

- ``x`` -- anything. 

 

OUTPUT: 

 

Boolean. Whether ``x`` is an algebraic scheme, that is, a 

subscheme of an ambient space over a ring defined by polynomial 

equations. 

 

EXAMPLES:: 

 

sage: A2 = AffineSpace(2, QQ, 'x, y') 

sage: A2.coordinate_ring().inject_variables() 

Defining x, y 

sage: V = A2.subscheme([x^2+y^2]); V 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

x^2 + y^2 

sage: from sage.schemes.generic.algebraic_scheme import is_AlgebraicScheme 

sage: is_AlgebraicScheme(V) 

True 

 

Affine space is itself not an algebraic scheme, though the closed 

subscheme defined by no equations is:: 

 

sage: from sage.schemes.generic.algebraic_scheme import is_AlgebraicScheme 

sage: is_AlgebraicScheme(AffineSpace(10, QQ)) 

False 

sage: V = AffineSpace(10, QQ).subscheme([]); V 

Closed subscheme of Affine Space of dimension 10 over Rational Field defined by: 

(no polynomials) 

sage: is_AlgebraicScheme(V) 

True 

 

We create a more complicated closed subscheme:: 

 

sage: A,x = AffineSpace(10, QQ).objgens() 

sage: X = A.subscheme([sum(x)]); X 

Closed subscheme of Affine Space of dimension 10 over Rational Field defined by: 

x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 

sage: is_AlgebraicScheme(X) 

True 

 

:: 

 

sage: is_AlgebraicScheme(QQ) 

False 

sage: S = Spec(QQ) 

sage: is_AlgebraicScheme(S) 

False 

""" 

return isinstance(x, AlgebraicScheme) 

 

 

 

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

class AlgebraicScheme(scheme.Scheme): 

""" 

An algebraic scheme presented as a subscheme in an ambient space. 

 

This is the base class for all algebraic schemes, that is, schemes 

defined by equations in affine, projective, or toric ambient 

spaces. 

""" 

 

def __init__(self, A): 

""" 

TESTS:: 

 

sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme 

sage: P = ProjectiveSpace(3, ZZ) 

sage: P.category() 

Category of schemes over Integer Ring 

sage: S = AlgebraicScheme(P); S 

Subscheme of Projective Space of dimension 3 over Integer Ring 

sage: S.category() 

Category of schemes over Integer Ring 

""" 

if not ambient_space.is_AmbientSpace(A): 

raise TypeError("A (=%s) must be an ambient space") 

self.__A = A 

self.__divisor_group = {} 

scheme.Scheme.__init__(self, A.base_scheme()) 

 

def _latex_(self): 

""" 

Return a LaTeX representation of this algebraic scheme. 

 

TESTS:: 

 

sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme 

sage: P = ProjectiveSpace(3, ZZ) 

sage: S = AlgebraicScheme(P); S 

Subscheme of Projective Space of dimension 3 over Integer Ring 

sage: S._latex_() 

'\text{Subscheme of } {\\mathbf P}_{\\Bold{Z}}^3' 

""" 

return "\text{Subscheme of } %s" % latex(self.__A) 

 

def is_projective(self): 

""" 

Return True if self is presented as a subscheme of an ambient 

projective space. 

 

OUTPUT: 

 

Boolean. 

 

EXAMPLES:: 

 

sage: PP.<x,y,z,w> = ProjectiveSpace(3,QQ) 

sage: f = x^3 + y^3 + z^3 + w^3 

sage: R = f.parent() 

sage: I = [f] + [f.derivative(zz) for zz in PP.gens()] 

sage: V = PP.subscheme(I) 

sage: V.is_projective() 

True 

sage: AA.<x,y,z,w> = AffineSpace(4,QQ) 

sage: V = AA.subscheme(I) 

sage: V.is_projective() 

False 

 

Note that toric varieties are implemented differently than 

projective spaces. This is why this method returns ``False`` 

for toric varieties:: 

 

sage: PP.<x,y,z,w> = toric_varieties.P(3) 

sage: V = PP.subscheme(x^3 + y^3 + z^3 + w^3) 

sage: V.is_projective() 

False 

""" 

return self.ambient_space().is_projective() 

 

def coordinate_ring(self): 

""" 

Return the coordinate ring of this algebraic scheme. The 

result is cached. 

 

OUTPUT: 

 

The coordinate ring. Usually a polynomial ring, or a quotient 

thereof. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([x-y, x-z]) 

sage: S.coordinate_ring() 

Quotient of Multivariate Polynomial Ring in x, y, z over Integer Ring by the ideal (x - y, x - z) 

""" 

try: 

return self._coordinate_ring 

except AttributeError: 

R = self.__A.coordinate_ring() 

I = self.defining_ideal() 

Q = R.quotient(I) 

self._coordinate_ring = Q 

return Q 

 

def ambient_space(self): 

""" 

Return the ambient space of this algebraic scheme. 

 

EXAMPLES:: 

 

sage: A.<x, y> = AffineSpace(2, GF(5)) 

sage: S = A.subscheme([]) 

sage: S.ambient_space() 

Affine Space of dimension 2 over Finite Field of size 5 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([x-y, x-z]) 

sage: S.ambient_space() is P 

True 

""" 

return self.__A 

 

def embedding_morphism(self): 

r""" 

Return the default embedding morphism of ``self``. 

 

If the scheme `Y` was constructed as a neighbourhood of a 

point `p \in X`, then :meth:`embedding_morphism` returns a 

local isomorphism `f:Y\to X` around the preimage point 

`f^{-1}(p)`. The latter is returned by 

:meth:`embedding_center`. 

 

If the algebraic scheme `Y` was not constructed as a 

neighbourhood of a point, then the embedding in its 

:meth:`ambient_space` is returned. 

 

OUTPUT: 

 

A scheme morphism whose 

:meth:`~morphism.SchemeMorphism.domain` is ``self``. 

 

* By default, it is the tautological embedding into its own 

ambient space :meth:`ambient_space`. 

 

* If the algebraic scheme (which itself is a subscheme of an 

auxiliary :meth:`ambient_space`) was constructed as a patch 

or neighborhood of a point then the embedding is the 

embedding into the original scheme. 

 

* A ``NotImplementedError`` is raised if the construction of 

the embedding morphism is not implemented yet. 

 

EXAMPLES:: 

 

sage: A2.<x,y> = AffineSpace(QQ,2) 

sage: C = A2.subscheme(x^2+y^2-1) 

sage: C.embedding_morphism() 

Scheme morphism: 

From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

x^2 + y^2 - 1 

To: Affine Space of dimension 2 over Rational Field 

Defn: Defined on coordinates by sending (x, y) to 

(x, y) 

sage: P1xP1.<x,y,u,v> = toric_varieties.P1xP1() 

sage: P1 = P1xP1.subscheme(x-y) 

sage: P1.embedding_morphism() 

Scheme morphism: 

From: Closed subscheme of 2-d CPR-Fano toric variety covered 

by 4 affine patches defined by: 

x - y 

To: 2-d CPR-Fano toric variety covered by 4 affine patches 

Defn: Defined on coordinates by sending [x : y : u : v] to 

[y : y : u : v] 

 

So far, the embedding was just in the own ambient space. Now a 

bit more interesting examples:: 

 

sage: P2.<x,y,z> = ProjectiveSpace(QQ,2) 

sage: X = P2.subscheme((x^2-y^2)*z) 

sage: p = (1,1,0) 

sage: nbhd = X.neighborhood(p) 

sage: nbhd 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

-x0^2*x1 - 2*x0*x1 

 

Note that `p=(1,1,0)` is a singular point of `X`. So the 

neighborhood of `p` is not just affine space. The 

:meth:`neighborhood` method returns a presentation of 

the neighborhood as a subscheme of an auxiliary 2-dimensional 

affine space:: 

 

sage: nbhd.ambient_space() 

Affine Space of dimension 2 over Rational Field 

 

But its :meth:`embedding_morphism` is not into this auxiliary 

affine space, but the original subscheme `X`:: 

 

sage: nbhd.embedding_morphism() 

Scheme morphism: 

From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

-x0^2*x1 - 2*x0*x1 

To: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 

x^2*z - y^2*z 

Defn: Defined on coordinates by sending (x0, x1) to 

(1 : x0 + 1 : x1) 

 

A couple more examples:: 

 

sage: patch1 = P1xP1.affine_patch(1) 

sage: patch1 

2-d affine toric variety 

sage: patch1.embedding_morphism() 

Scheme morphism: 

From: 2-d affine toric variety 

To: 2-d CPR-Fano toric variety covered by 4 affine patches 

Defn: Defined on coordinates by sending [y : u] to 

[1 : y : u : 1] 

sage: subpatch = P1.affine_patch(1) 

sage: subpatch 

Closed subscheme of 2-d affine toric variety defined by: 

-y + 1 

sage: subpatch.embedding_morphism() 

Scheme morphism: 

From: Closed subscheme of 2-d affine toric variety defined by: 

-y + 1 

To: Closed subscheme of 2-d CPR-Fano toric variety covered 

by 4 affine patches defined by: 

x - y 

Defn: Defined on coordinates by sending [y : u] to 

[1 : y : u : 1] 

""" 

if '_embedding_morphism' in self.__dict__: 

hom = self._embedding_morphism 

if isinstance(hom, tuple): 

raise hom[0] 

return hom 

ambient = self.ambient_space() 

return self.hom(self.coordinate_ring().gens(), ambient) 

 

def embedding_center(self): 

r""" 

Return the distinguished point, if there is any. 

 

If the scheme `Y` was constructed as a neighbourhood of a 

point `p \in X`, then :meth:`embedding_morphism` returns a 

local isomorphism `f:Y\to X` around the preimage point 

`f^{-1}(p)`. The latter is returned by 

:meth:`embedding_center`. 

 

OUTPUT: 

 

A point of ``self``. Raises ``AttributeError`` if there is no 

distinguished point, depending on how ``self`` was 

constructed. 

 

EXAMPLES:: 

 

sage: P3.<w,x,y,z> = ProjectiveSpace(QQ,3) 

sage: X = P3.subscheme( (w^2-x^2)*(y^2-z^2) ) 

sage: p = [1,-1,3,4] 

sage: nbhd = X.neighborhood(p); nbhd 

Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: 

x0^2*x2^2 - x1^2*x2^2 + 6*x0^2*x2 - 6*x1^2*x2 + 2*x0*x2^2 + 

2*x1*x2^2 - 7*x0^2 + 7*x1^2 + 12*x0*x2 + 12*x1*x2 - 14*x0 - 14*x1 

sage: nbhd.embedding_center() 

(0, 0, 0) 

sage: nbhd.embedding_morphism()(nbhd.embedding_center()) 

(1/4 : -1/4 : 3/4 : 1) 

sage: nbhd.embedding_morphism() 

Scheme morphism: 

From: Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: 

x0^2*x2^2 - x1^2*x2^2 + 6*x0^2*x2 - 6*x1^2*x2 + 2*x0*x2^2 + 

2*x1*x2^2 - 7*x0^2 + 7*x1^2 + 12*x0*x2 + 12*x1*x2 - 14*x0 - 14*x1 

To: Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: 

w^2*y^2 - x^2*y^2 - w^2*z^2 + x^2*z^2 

Defn: Defined on coordinates by sending (x0, x1, x2) to 

(x0 + 1 : x1 - 1 : x2 + 3 : 4) 

""" 

if '_embedding_center' in self.__dict__: 

return self._embedding_center 

raise AttributeError('This algebraic scheme does not have a designated point.') 

 

def ngens(self): 

""" 

Return the number of generators of the ambient space of this 

algebraic scheme. 

 

EXAMPLES:: 

 

sage: A.<x, y> = AffineSpace(2, GF(5)) 

sage: S = A.subscheme([]) 

sage: S.ngens() 

2 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([x-y, x-z]) 

sage: P.ngens() 

3 

""" 

return self.__A.ngens() 

 

def _repr_(self): 

""" 

Return a string representation of this algebraic scheme. 

 

TESTS:: 

 

sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme 

sage: P = ProjectiveSpace(3, ZZ) 

sage: S = AlgebraicScheme(P); S 

Subscheme of Projective Space of dimension 3 over Integer Ring 

sage: S._repr_() 

'Subscheme of Projective Space of dimension 3 over Integer Ring' 

""" 

return "Subscheme of %s"%self.__A 

 

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

""" 

Construct the Hom-set 

 

INPUT: 

 

Same as :class:`sage.schemes.generic.homset.SchemeHomset_generic`. 

 

OUTPUT: 

 

The Hom-set of the ambient space. 

 

EXAMPLES:: 

 

sage: P1.<x,y> = toric_varieties.P1() 

sage: type(P1.Hom(P1)) 

<class 'sage.schemes.toric.homset.SchemeHomset_toric_variety_with_category'> 

sage: X = P1.subscheme(x-y) 

sage: type(X.Hom(X)) 

<class 'sage.schemes.toric.homset.SchemeHomset_toric_variety_with_category'> 

 

:: 

 

sage: P1xP1 = toric_varieties.P1xP1() 

sage: P1 = toric_varieties.P1() 

sage: P1xP1._homset(P1xP1,P1) 

Set of morphisms 

From: 2-d CPR-Fano toric variety covered by 4 affine patches 

To: 1-d CPR-Fano toric variety covered by 2 affine patches 

""" 

return self.__A._homset(*args, **kwds) 

 

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

""" 

Construct a point Hom-set. For internal use only. 

 

TESTS:: 

 

sage: P2.<x,y,z> = ProjectiveSpace(2, ZZ) 

sage: P2._point_homset(Spec(ZZ), P2) 

Set of rational points of Projective Space of dimension 2 over Integer Ring 

""" 

return self.__A._point_homset(*args, **kwds) 

 

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

r""" 

Construct a point of ``self``. For internal use only. 

 

TESTS:: 

 

sage: P2.<x,y,z> = ProjectiveSpace(2, QQ) 

sage: point_homset = P2._point_homset(Spec(QQ), P2) 

sage: P2._point(point_homset, [1,2,1]) 

(1 : 2 : 1) 

""" 

return self.__A._point(*args, **kwds) 

 

 

 

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

class AlgebraicScheme_quasi(AlgebraicScheme): 

""" 

The quasi-affine or quasi-projective scheme `X - Y`, where `X` and `Y` 

are both closed subschemes of a common ambient affine or projective 

space. 

 

.. WARNING:: 

 

You should not create objects of this class directly. The 

preferred method to construct such subschemes is to use 

:meth:`complement` method of algebraic schemes. 

 

OUTPUT: 

 

An instance of :class:`AlgebraicScheme_quasi`. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([]) 

sage: T = P.subscheme([x-y]) 

sage: T.complement(S) 

Quasi-projective subscheme X - Y of Projective Space of dimension 2 over 

Integer Ring, where X is defined by: 

(no polynomials) 

and Y is defined by: 

x - y 

""" 

 

def __init__(self, X, Y): 

""" 

The constructor. 

 

INPUT: 

 

- ``X``, ``Y`` -- two subschemes of the same ambient space. 

 

TESTS:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([]) 

sage: T = P.subscheme([x-y]) 

sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_quasi 

sage: AlgebraicScheme_quasi(S, T) 

Quasi-projective subscheme X - Y of Projective Space of dimension 2 over Integer Ring, where X is defined by: 

(no polynomials) 

and Y is defined by: 

x - y 

""" 

self.__X = X 

self.__Y = Y 

if not isinstance(X, AlgebraicScheme_subscheme): 

raise TypeError("X must be a closed subscheme of an ambient space.") 

if not isinstance(Y, AlgebraicScheme_subscheme): 

raise TypeError("Y must be a closed subscheme of an ambient space.") 

if X.ambient_space() != Y.ambient_space(): 

raise ValueError("X and Y must be embedded in the same ambient space.") 

# _latex_ and _repr_ assume all of the above conditions and should be 

# probably changed if they are relaxed! 

A = X.ambient_space() 

self._base_ring = A.base_ring() 

AlgebraicScheme.__init__(self, A) 

 

def _latex_(self): 

""" 

Return a LaTeX representation of this algebraic scheme. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_quasi 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([]) 

sage: T = P.subscheme([x-y]) 

sage: U = AlgebraicScheme_quasi(S, T); U 

Quasi-projective subscheme X - Y of Projective Space of dimension 2 

over Integer Ring, where X is defined by: 

(no polynomials) 

and Y is defined by: 

x - y 

sage: U._latex_() 

'\\text{Quasi-projective subscheme } 

(X\\setminus Y)\\subset {\\mathbf P}_{\\Bold{Z}}^2,\\text{ where } 

X \\text{ is defined by }\\text{no polynomials},\\text{ and } 

Y \\text{ is defined by } x - y.' 

""" 

if sage.schemes.affine.affine_space.is_AffineSpace(self.ambient_space()): 

t = "affine" 

else: 

t = "projective" 

X = ', '.join(latex(f) for f in self.__X.defining_polynomials()) 

if not X: 

X = r"\text{no polynomials}" 

Y = ', '.join(latex(f) for f in self.__Y.defining_polynomials()) 

if not Y: 

Y = r"\text{no polynomials}" 

return (r"\text{Quasi-%s subscheme } (X\setminus Y)\subset %s," 

r"\text{ where } X \text{ is defined by }%s," 

r"\text{ and } Y \text{ is defined by } %s." 

% (t, latex(self.ambient_space()), X, Y)) 

 

def _repr_(self): 

r""" 

Return a string representation of this algebraic scheme. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_quasi 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([]) 

sage: T = P.subscheme([x-y]) 

sage: U = AlgebraicScheme_quasi(S, T); U 

Quasi-projective subscheme X - Y of Projective Space of dimension 2 over Integer Ring, where X is defined by: 

(no polynomials) 

and Y is defined by: 

x - y 

sage: U._repr_() 

'Quasi-projective subscheme X - Y of Projective Space of dimension 2 over Integer Ring, where X is defined by:\n (no polynomials)\nand Y is defined by:\n x - y' 

""" 

if sage.schemes.affine.affine_space.is_AffineSpace(self.ambient_space()): 

t = "affine" 

else: 

t = "projective" 

return ("Quasi-%s subscheme X - Y of %s, where X is defined by:\n%s\n" 

"and Y is defined by:\n%s" 

% (t, self.ambient_space(), str(self.__X).split("\n", 1)[1], 

str(self.__Y).split("\n", 1)[1])) 

 

def X(self): 

""" 

Return the scheme `X` such that self is represented as `X - Y`. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([]) 

sage: T = P.subscheme([x-y]) 

sage: U = T.complement(S) 

sage: U.X() is S 

True 

""" 

return self.__X 

 

def Y(self): 

""" 

Return the scheme `Y` such that self is represented as `X - Y`. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([]) 

sage: T = P.subscheme([x-y]) 

sage: U = T.complement(S) 

sage: U.Y() is T 

True 

""" 

return self.__Y 

 

def _check_satisfies_equations(self, v): 

""" 

Verify that the coordinates of v define a point on this scheme, or 

raise a TypeError. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([]) 

sage: T = P.subscheme([x-y]) 

sage: U = T.complement(S) 

sage: U._check_satisfies_equations([1, 2, 0]) 

True 

sage: U._check_satisfies_equations([1, 1, 0]) 

Traceback (most recent call last): 

... 

TypeError: Coordinates [1, 1, 0] do not define a point on 

Quasi-projective subscheme X - Y of Projective Space of dimension 2 

over Integer Ring, where X is defined by: 

(no polynomials) 

and Y is defined by: 

x - y 

 

sage: U._check_satisfies_equations([1, 4]) 

Traceback (most recent call last): 

... 

TypeError: number of arguments does not match number of variables in parent 

 

sage: A.<x, y> = AffineSpace(2, GF(7)) 

sage: S = A.subscheme([x^2-y]) 

sage: T = A.subscheme([x-y]) 

sage: U = T.complement(S) 

sage: U._check_satisfies_equations([2, 4]) 

True 

sage: U.point([2,4]) 

(2, 4) 

sage: U._check_satisfies_equations(_) 

True 

sage: U._check_satisfies_equations([1, 1]) 

Traceback (most recent call last): 

... 

TypeError: Coordinates [1, 1] do not define a point on Quasi-affine 

subscheme X - Y of Affine Space of dimension 2 over Finite 

Field of size 7, where X is defined by: 

x^2 - y 

and Y is defined by: 

x - y 

sage: U._check_satisfies_equations([1, 0]) 

Traceback (most recent call last): 

... 

TypeError: Coordinates [1, 0] do not define a point on Quasi-affine 

subscheme X - Y of Affine Space of dimension 2 over Finite 

Field of size 7, where X is defined by: 

x^2 - y 

and Y is defined by: 

x - y 

 

TESTS: 

 

The bug reported at :trac:`12211` has been fixed:: 

 

sage: P.<x, y, z, w> = ProjectiveSpace(3, QQ) 

sage: S = P.subscheme([x]) 

sage: T = P.subscheme([y, z]) 

sage: U = T.complement(S) 

sage: U._check_satisfies_equations([0, 0, 1, 1]) 

True 

""" 

coords = list(v) 

for f in self.__X.defining_polynomials(): 

if f(coords) != 0: 

raise TypeError("Coordinates %s do not define a point on %s"%(v,self)) 

for f in self.__Y.defining_polynomials(): 

if f(coords) != 0: 

return True 

raise TypeError("Coordinates %s do not define a point on %s"%(v,self)) 

 

def rational_points(self, F=None, bound=0): 

""" 

Return the set of rational points on this algebraic scheme 

over the field `F`. 

 

EXAMPLES:: 

 

sage: A.<x, y> = AffineSpace(2, GF(7)) 

sage: S = A.subscheme([x^2-y]) 

sage: T = A.subscheme([x-y]) 

sage: U = T.complement(S) 

sage: U.rational_points() 

[(2, 4), (3, 2), (4, 2), (5, 4), (6, 1)] 

sage: U.rational_points(GF(7^2, 'b')) 

[(2, 4), (3, 2), (4, 2), (5, 4), (6, 1), (b, b + 4), (b + 1, 3*b + 5), (b + 2, 5*b + 1), 

(b + 3, 6), (b + 4, 2*b + 6), (b + 5, 4*b + 1), (b + 6, 6*b + 5), (2*b, 4*b + 2), 

(2*b + 1, b + 3), (2*b + 2, 5*b + 6), (2*b + 3, 2*b + 4), (2*b + 4, 6*b + 4), 

(2*b + 5, 3*b + 6), (2*b + 6, 3), (3*b, 2*b + 1), (3*b + 1, b + 2), (3*b + 2, 5), 

(3*b + 3, 6*b + 3), (3*b + 4, 5*b + 3), (3*b + 5, 4*b + 5), (3*b + 6, 3*b + 2), 

(4*b, 2*b + 1), (4*b + 1, 3*b + 2), (4*b + 2, 4*b + 5), (4*b + 3, 5*b + 3), 

(4*b + 4, 6*b + 3), (4*b + 5, 5), (4*b + 6, b + 2), (5*b, 4*b + 2), (5*b + 1, 3), 

(5*b + 2, 3*b + 6), (5*b + 3, 6*b + 4), (5*b + 4, 2*b + 4), (5*b + 5, 5*b + 6), 

(5*b + 6, b + 3), (6*b, b + 4), (6*b + 1, 6*b + 5), (6*b + 2, 4*b + 1), (6*b + 3, 2*b + 6), 

(6*b + 4, 6), (6*b + 5, 5*b + 1), (6*b + 6, 3*b + 5)] 

""" 

if F is None: 

F = self.base_ring() 

 

if bound == 0: 

if is_RationalField(F): 

raise TypeError("A positive bound (= %s) must be specified."%bound) 

if not is_FiniteField(F): 

raise TypeError("Argument F (= %s) must be a finite field."%F) 

pts = [] 

for P in self.ambient_space().rational_points(F): 

try: 

if self._check_satisfies_equations(list(P)): 

pts.append(P) 

except TypeError: 

pass 

pts.sort() 

return pts 

 

 

 

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

@richcmp_method 

class AlgebraicScheme_subscheme(AlgebraicScheme): 

""" 

An algebraic scheme presented as a closed subscheme is defined by 

explicit polynomial equations. This is as opposed to a general 

scheme, which could, e.g., be the Neron model of some object, and 

for which we do not want to give explicit equations. 

 

INPUT: 

 

- ``A`` - ambient space (e.g. affine or projective `n`-space) 

 

- ``polynomials`` - single polynomial, ideal or iterable of defining 

polynomials; in any case polynomials must belong to the coordinate 

ring of the ambient space and define valid polynomial functions (e.g. 

they should be homogeneous in the case of a projective space) 

 

OUTPUT: 

 

- algebraic scheme 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme 

sage: P.<x, y, z> = ProjectiveSpace(2, QQ) 

sage: P.subscheme([x^2-y*z]) 

Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 

x^2 - y*z 

sage: AlgebraicScheme_subscheme(P, [x^2-y*z]) 

Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 

x^2 - y*z 

""" 

 

def __init__(self, A, polynomials): 

""" 

See ``AlgebraicScheme_subscheme`` for documentation. 

 

TESTS:: 

 

sage: from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme 

sage: P.<x, y, z> = ProjectiveSpace(2, QQ) 

sage: P.subscheme([x^2-y*z]) 

Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 

x^2 - y*z 

sage: AlgebraicScheme_subscheme(P, [x^2-y*z]) 

Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 

x^2 - y*z 

""" 

from sage.rings.polynomial.multi_polynomial_sequence import is_PolynomialSequence 

 

AlgebraicScheme.__init__(self, A) 

self._base_ring = A.base_ring() 

R = A.coordinate_ring() 

if is_Ideal(polynomials): 

I = polynomials 

polynomials = I.gens() 

if I.ring() is R: # Otherwise we will recompute I later after 

self.__I = I # converting generators to the correct ring 

if isinstance(polynomials, tuple) or is_PolynomialSequence(polynomials) or is_iterator(polynomials): 

polynomials = list(polynomials) 

elif not isinstance(polynomials, list): 

# Looks like we got a single polynomial 

polynomials = [polynomials] 

for n, f in enumerate(polynomials): 

try: 

polynomials[n] = R(f) 

except TypeError: 

raise TypeError("%s cannot be converted to a polynomial in " 

"the coordinate ring of this %s!" % (f, A)) 

polynomials = tuple(polynomials) 

self.__polys = A._validate(polynomials) 

 

def _check_satisfies_equations(self, v): 

""" 

Verify that the coordinates of v define a point on this scheme, or 

raise a TypeError. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, QQ) 

sage: S = P.subscheme([x^2-y*z]) 

sage: S._check_satisfies_equations([1, 1, 1]) 

True 

sage: S._check_satisfies_equations([1, 0, 1]) 

Traceback (most recent call last): 

... 

TypeError: Coordinates [1, 0, 1] do not define a point on Closed subscheme 

of Projective Space of dimension 2 over Rational Field defined by: 

x^2 - y*z 

sage: S._check_satisfies_equations([0, 0, 0]) 

Traceback (most recent call last): 

... 

TypeError: Coordinates [0, 0, 0] do not define a point on Closed subscheme 

of Projective Space of dimension 2 over Rational Field defined by: 

x^2 - y*z 

""" 

coords = list(v) 

for f in self.defining_polynomials(): 

if f(coords) != 0: # it must be "!=0" instead of "if f(v)", e.g., 

# because of p-adic base rings. 

raise TypeError("Coordinates %s do not define a point on %s"%(coords,self)) 

try: 

return self.ambient_space()._check_satisfies_equations(coords) 

except TypeError: 

raise TypeError("Coordinates %s do not define a point on %s"%(coords,self)) 

 

def base_extend(self, R): 

""" 

Return the base change to the ring `R` of this scheme. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, GF(11)) 

sage: S = P.subscheme([x^2-y*z]) 

sage: S.base_extend(GF(11^2, 'b')) 

Closed subscheme of Projective Space of dimension 2 over Finite Field in b of size 11^2 defined by: 

x^2 - y*z 

sage: S.base_extend(ZZ) 

Traceback (most recent call last): 

... 

ValueError: no natural map from the base ring (=Finite Field of size 11) to R (=Integer Ring)! 

""" 

A = self.ambient_space().base_extend(R) 

return A.subscheme(self.__polys) 

 

def __richcmp__(self, other, op): 

""" 

EXAMPLES:: 

 

sage: A.<x, y, z> = AffineSpace(3, QQ) 

sage: X = A.subscheme([x*y, z]) 

sage: X == A.subscheme([z, x*y]) 

True 

sage: X == A.subscheme([x*y, z^2]) 

False 

sage: B.<u, v, t> = AffineSpace(3, QQ) 

sage: X == B.subscheme([u*v, t]) 

False 

""" 

if not isinstance(other, AlgebraicScheme_subscheme): 

return NotImplemented 

A = self.ambient_space() 

if other.ambient_space() != A: 

return NotImplemented 

return richcmp(self.defining_ideal(), other.defining_ideal(), op) 

 

def _latex_(self): 

""" 

Return a LaTeX representation of this scheme. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, GF(11)) 

sage: S = P.subscheme([x^2-y*z]) 

sage: S 

Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: 

x^2 - y*z 

sage: S._latex_() 

'\\text{Closed subscheme of } {\\mathbf P}_{\\Bold{F}_{11}}^2 \\text{ defined by } x^{2} - y z' 

sage: S = P.subscheme([x^2-y*z, x^5]) 

sage: S 

Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: 

x^2 - y*z, 

x^5 

sage: S._latex_() 

'\\text{Closed subscheme of } {\\mathbf P}_{\\Bold{F}_{11}}^2 \\text{ defined by } x^{2} - y z, x^{5}' 

""" 

polynomials = ', '.join(latex(f) for f in self.defining_polynomials()) 

if not polynomials: 

polynomials = r"\text{no polynomials}" 

return (r"\text{Closed subscheme of } %s \text{ defined by } %s" 

% (latex(self.ambient_space()), polynomials)) 

 

def _repr_(self): 

r""" 

Return a string representation of this scheme. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, GF(11)) 

sage: S = P.subscheme([x^2-y*z]) 

sage: S 

Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: 

x^2 - y*z 

sage: S._repr_() 

'Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by:\n x^2 - y*z' 

sage: S = P.subscheme([x^2-y*z, x^5]) 

sage: S 

Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: 

x^2 - y*z, 

x^5 

sage: S._repr_() 

'Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by:\n x^2 - y*z,\n x^5' 

""" 

polynomials = ',\n '.join(str(f) for f in self.defining_polynomials()) 

if not polynomials: 

polynomials = '(no polynomials)' 

return ("Closed subscheme of %s defined by:\n %s" 

% (self.ambient_space(), polynomials)) 

 

def defining_polynomials(self): 

""" 

Return the polynomials that define this scheme as a subscheme 

of its ambient space. 

 

OUTPUT: 

 

A tuple of polynomials in the coordinate ring of the ambient 

space. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([x^2-y*z, x^3+z^3]) 

sage: S.defining_polynomials() 

(x^2 - y*z, x^3 + z^3) 

""" 

return self.__polys 

 

def defining_ideal(self): 

""" 

Return the ideal that defines this scheme as a subscheme 

of its ambient space. 

 

OUTPUT: 

 

An ideal in the coordinate ring of the ambient space. 

 

EXAMPLES:: 

 

sage: P.<x, y, z> = ProjectiveSpace(2, ZZ) 

sage: S = P.subscheme([x^2-y*z, x^3+z^3]) 

sage: S.defining_ideal() 

Ideal (x^2 - y*z, x^3 + z^3) of Multivariate Polynomial Ring in x, y, z over Integer Ring 

""" 

try: 

return self.__I 

except AttributeError: 

R = self.ambient_space().coordinate_ring() 

self.__I = R.ideal(self.defining_polynomials()) 

return self.__I 

 

# Note: dimension must be implemented by the derived classes 

def codimension(self): 

r""" 

Return the codimension of the algebraic subscheme. 

 

OUTPUT: 

 

Integer. 

 

EXAMPLES:: 

 

sage: PP.<x,y,z,w,v> = ProjectiveSpace(4,QQ) 

sage: V = PP.subscheme(x*y) 

sage: V.codimension() 

1 

sage: V.dimension() 

3 

""" 

return self.ambient_space().dimension() - self.dimension() 

 

def irreducible_components(self): 

r""" 

Return the irreducible components of this algebraic scheme, as 

subschemes of the same ambient space. 

 

OUTPUT: 

 

an immutable sequence of irreducible subschemes of the ambient 

space of this scheme 

 

The components are cached. 

 

EXAMPLES: 

 

We define what is clearly a union of four hypersurfaces in 

`\P^4_{\QQ}` then find the irreducible components:: 

 

sage: PP.<x,y,z,w,v> = ProjectiveSpace(4,QQ) 

sage: V = PP.subscheme( (x^2 - y^2 - z^2)*(w^5 - 2*v^2*z^3)* w * (v^3 - x^2*z) ) 

sage: V.irreducible_components() 

[ 

Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: 

w, 

Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: 

x^2 - y^2 - z^2, 

Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: 

x^2*z - v^3, 

Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: 

w^5 - 2*z^3*v^2 

] 

 

We verify that the irrelevant ideal isn't accidently returned 

(see :trac:`6920`):: 

 

sage: PP.<x,y,z,w> = ProjectiveSpace(3,QQ) 

sage: f = x^3 + y^3 + z^3 + w^3 

sage: R = f.parent() 

sage: I = [f] + [f.derivative(zz) for zz in PP.gens()] 

sage: V = PP.subscheme(I) 

sage: V.irreducible_components() 

[ 

<BLANKLINE> 

] 

 

The same polynomial as above defines a scheme with a 

nontrivial irreducible component in affine space (instead of 

the empty scheme as above):: 

 

sage: AA.<x,y,z,w> = AffineSpace(4,QQ) 

sage: V = AA.subscheme(I) 

sage: V.irreducible_components() 

[ 

Closed subscheme of Affine Space of dimension 4 over Rational Field defined by: 

w, 

z, 

y, 

x 

] 

""" 

try: 

return self.__irreducible_components 

except AttributeError: 

pass 

I = self.defining_ideal() 

P = I.associated_primes() 

if self.is_projective(): 

# In the projective case, we must exclude the prime ideals 

# that contain the irrelevant ideal, which is the ideal 

# generated by the variables, which are the gens of the 

# base ring. 

G = I.ring().gens() 

# We make a list of ideals with the property that "any" 

# of the elements of G are not in the ideal. 

P = [J for J in P if any(g not in J for g in G)] 

 

A = self.ambient_space() 

C = Sequence([A.subscheme(X) for X in P], check=False, cr=True) 

C.sort(key=lambda scheme: scheme.defining_ideal().gens()) 

C.set_immutable() 

self.__irreducible_components = C 

return C 

 

def is_irreducible(self): 

r""" 

Return whether this subscheme is or is not irreducible. 

 

OUTPUT: Boolean. 

 

EXAMPLES:: 

 

sage: K = QuadraticField(-3) 

sage: P.<x,y,z,w,t,u> = ProjectiveSpace(K, 5) 

sage: X = P.subscheme([x*y - z^2 - K.0*t^2, t*w*x + y*z^2 - u^3]) 

sage: X.is_irreducible() 

True 

 

:: 

 

sage: P.<x,y,z> = ProjectiveSpace(QQ, 2) 

sage: X = P.subscheme([(y + x - z)^2]) 

sage: X.is_irreducible() 

False 

 

:: 

 

sage: A.<x,y,z,w> = AffineSpace(GF(17), 4) 

sage: X = A.subscheme([x*y*z^2 - x*y*z*w - z*w^2 + w^3, x^3*y*z*w - x*y^3*z - x^2*y*z*w \ 

- x^2*w^3 + y^2*w^2 + x*w^3]) 

sage: X.is_irreducible() 

False 

""" 

return self.defining_ideal().is_prime() 

 

def Jacobian_matrix(self): 

r""" 

Return the matrix `\frac{\partial f_i}{\partial x_j}` of 

(formal) partial derivatives. 

 

OUTPUT: 

 

A matrix of polynomials. 

 

EXAMPLES:: 

 

sage: P3.<w,x,y,z> = ProjectiveSpace(3, QQ) 

sage: twisted_cubic = P3.subscheme(matrix([[w, x, y],[x, y, z]]).minors(2)) 

sage: twisted_cubic.Jacobian_matrix() 

[ y -2*x w 0] 

[ z -y -x w] 

[ 0 z -2*y x] 

 

This example addresses ticket :trac:`20512`:: 

 

sage: X = P3.subscheme([]) 

sage: X.Jacobian_matrix().base_ring() == P3.coordinate_ring() 

True 

""" 

R = self.ambient_space().coordinate_ring() 

l = self.defining_polynomials() 

if len(l) == 0: 

return sage.matrix.constructor.Matrix(R, 0) 

return jacobian(l, R.gens()) 

 

def Jacobian(self): 

r""" 

Return the Jacobian ideal. 

 

This is the ideal generated by 

 

* the `d\times d` minors of the Jacobian matrix, where `d` is 

the :meth:`codimension` of the algebraic scheme, and 

 

* the defining polynomials of the algebraic scheme. Note that 

some authors do not include these in the definition of the 

Jacobian ideal. An example of a reference that does include 

the defining equations is [LazarsfeldJacobian]_. 

 

OUTPUT: 

 

An ideal in the coordinate ring of the ambient space. 

 

REFERENCES: 

 

.. [LazarsfeldJacobian] 

Robert Lazarsfeld: 

Positivity in algebraic geometry II; 

Positivity for Vector Bundles, and Multiplier Ideals, 

page 181. 

 

EXAMPLES:: 

 

sage: P3.<w,x,y,z> = ProjectiveSpace(3, QQ) 

sage: twisted_cubic = P3.subscheme(matrix([[w, x, y],[x, y, z]]).minors(2)) 

sage: twisted_cubic.Jacobian() 

Ideal (-x^2 + w*y, -x*y + w*z, -y^2 + x*z, x*z, -2*w*z, w*y, 3*w*y, -2*w*x, 

w^2, y*z, -2*x*z, w*z, 3*w*z, -2*w*y, w*x, z^2, -2*y*z, x*z, 3*x*z, -2*w*z, 

w*y) of Multivariate Polynomial Ring in w, x, y, z over Rational Field 

sage: twisted_cubic.defining_ideal() 

Ideal (-x^2 + w*y, -x*y + w*z, -y^2 + x*z) of Multivariate Polynomial Ring 

in w, x, y, z over Rational Field 

 

This example addresses ticket :trac:`20512`:: 

 

sage: X = P3.subscheme([]) 

sage: X.Jacobian() == P3.coordinate_ring().unit_ideal() 

True 

""" 

d = self.codimension() 

minors = self.Jacobian_matrix().minors(d) 

I = self.defining_ideal() 

minors = tuple([ I.reduce(m) for m in minors ]) 

return I.ring().ideal(I.gens() + minors) 

 

def reduce(self): 

r""" 

Return the corresponding reduced algebraic space associated to this 

scheme. 

 

EXAMPLES: First we construct the union of a doubled and tripled 

line in the affine plane over `\QQ` :: 

 

sage: A.<x,y> = AffineSpace(2, QQ) 

sage: X = A.subscheme([(x-1)^2*(x-y)^3]); X 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

x^5 - 3*x^4*y + 3*x^3*y^2 - x^2*y^3 - 2*x^4 + 6*x^3*y 

- 6*x^2*y^2 + 2*x*y^3 + x^3 - 3*x^2*y + 3*x*y^2 - y^3 

sage: X.dimension() 

1 

 

Then we compute the corresponding reduced scheme:: 

 

sage: Y = X.reduce(); Y 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

x^2 - x*y - x + y 

 

Finally, we verify that the reduced scheme `Y` is the union 

of those two lines:: 

 

sage: L1 = A.subscheme([x-1]); L1 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

x - 1 

sage: L2 = A.subscheme([x-y]); L2 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

x - y 

sage: W = L1.union(L2); W # taken in ambient space 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

x^2 - x*y - x + y 

sage: Y == W 

True 

""" 

try: 

return self._reduce 

except AttributeError: 

r = self.defining_ideal().radical() 

A = self.ambient_space() 

V = A.subscheme(r) 

V._reduce = V # so knows it is already reduced! 

self._reduce = V 

return V 

 

def union(self, other): 

""" 

Return the scheme-theoretic union of self and other in their common 

ambient space. 

 

EXAMPLES: We construct the union of a line and a tripled-point on 

the line. 

 

:: 

 

sage: A.<x,y> = AffineSpace(2, QQ) 

sage: I = ideal([x,y])^3 

sage: P = A.subscheme(I) 

sage: L = A.subscheme([y-1]) 

sage: S = L.union(P); S 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

y^4 - y^3, 

x*y^3 - x*y^2, 

x^2*y^2 - x^2*y, 

x^3*y - x^3 

sage: S.dimension() 

1 

sage: S.reduce() 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

y^2 - y, 

x*y - x 

 

We can also use the notation "+" for the union:: 

 

sage: A.subscheme([x]) + A.subscheme([y^2 - (x^3+1)]) 

Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 

x^4 - x*y^2 + x 

 

Saving and loading:: 

 

sage: loads(S.dumps()) == S 

True 

""" 

if not isinstance(other, AlgebraicScheme_subscheme): 

raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space"%other) 

A = self.ambient_space() 

if other.ambient_space() != A: 

raise ValueError("other (=%s) must be in the same ambient space as self"%other) 

return A.subscheme(self.defining_ideal().intersection(other.defining_ideal())) 

 

def __pow__(self, m): 

""" 

Return the Cartesian power of this space. 

 

INPUT: ``m`` -- integer. 

 

OUTPUT: subscheme of product of ambient spaces. 

 

EXAMPLES:: 

 

sage: P2.<y0,y1,y2> = ProjectiveSpace(ZZ, 2) 

sage: Z = P2.subscheme([y0^2 - y1*y2, y2]) 

sage: Z**3 

Closed subscheme of Product of projective spaces P^2 x P^2 x P^2 over 

Integer Ring defined by: 

x0^2 - x1*x2, 

x2, 

x3^2 - x4*x5, 

x5, 

x6^2 - x7*x8, 

x8 

 

:: 

 

sage: A2.<x,y> = AffineSpace(QQ, 2) 

sage: V = A2.subscheme([x^2-y, x-1]) 

sage: V**4 

Closed subscheme of Affine Space of dimension 8 over Rational Field 

defined by: 

x0^2 - x1, 

x0 - 1, 

x2^2 - x3, 

x2 - 1, 

x4^2 - x5, 

x4 - 1, 

x6^2 - x7, 

x6 - 1 

 

:: 

 

sage: T.<x0,x1,x2,x3,x4,x5> = ProductProjectiveSpaces([2,2], ZZ) 

sage: X = T.subscheme([x0*x4 - x1*x3]) 

sage: X^2 

Closed subscheme of Product of projective spaces P^2 x P^2 x P^2 x P^2 

over Integer Ring defined by: 

-x1*x3 + x0*x4, 

-x7*x9 + x6*x10 

 

:: 

 

sage: E = EllipticCurve([0,0,0,0,1]) 

sage: E^2 

Closed subscheme of Product of projective spaces P^2 x P^2 over Rational 

Field defined by: 

-x0^3 + x1^2*x2 - x2^3, 

-x3^3 + x4^2*x5 - x5^3 

""" 

AS = self.ambient_space().__pow__(m) 

CR = AS.coordinate_ring() 

n = self.ambient_space().coordinate_ring().ngens() 

 

polys = [] 

for i in range(m): 

phi = self.ambient_space().coordinate_ring().hom(list(CR.gens()[n*i : n*(i+1)]), CR) 

polys.extend([phi(t) for t in self.defining_polynomials()]) 

return AS.subscheme(polys) 

 

def __mul__(self, right): 

r""" 

Create the product of subschemes. 

 

INPUT: ``right`` - a subscheme of similar type. 

 

OUTPUT: a subscheme of a the product of the ambient spaces. 

 

EXAMPLES:: 

 

sage: S = ProductProjectiveSpaces([1,2,1], ZZ, 't') 

sage: T = ProductProjectiveSpaces([2,2], ZZ, 'x') 

sage: T.inject_variables() 

Defining x0, x1, x2, x3, x4, x5 

sage: X = T.subscheme([x0*x4 - x1*x3]) 

sage: X*S 

Closed subscheme of Product of projective spaces P^2 x P^2 x P^1 x P^2 x 

P^1 over Integer Ring defined by: 

-x1*x3 + x0*x4 

 

:: 

 

sage: S = ProjectiveSpace(ZZ, 2, 't') 

sage: T.<x0,x1,x2,x3> = ProjectiveSpace(ZZ, 3) 

sage: X = T.subscheme([x0*x2 - x1*x3]) 

sage: X*S 

Closed subscheme of Product of projective spaces P^3 x P^2 

over Integer Ring defined by: 

x0*x2 - x1*x3 

 

:: 

 

sage: A2 = AffineSpace(ZZ, 2, 't') 

sage: A3.<x0,x1,x2> = AffineSpace(ZZ, 3) 

sage: X = A3.subscheme([x0*x2 - x1]) 

sage: X*A2 

Closed subscheme of Affine Space of dimension 5 over Integer Ring 

defined by: 

x0*x2 - x1 

 

:: 

 

sage: T.<x0,x1,x2,x3,x4,x5> = ProductProjectiveSpaces([2,2], ZZ) 

sage: X = T.subscheme([x0*x4 - x1*x3]) 

sage: X*X 

Closed subscheme of Product of projective spaces P^2 x P^2 x P^2 x P^2 

over Integer Ring defined by: 

-x1*x3 + x0*x4, 

-x7*x9 + x6*x10 

 

:: 

 

sage: P1.<z0,z1> = ProjectiveSpace(ZZ, 1) 

sage: Y = P1.subscheme([z0 - z1]) 

sage: T.<x0,x1,x2,x3,x4,x5> = ProductProjectiveSpaces([2,2], ZZ) 

sage: X = T.subscheme([x0*x4 - x1*x3]) 

sage: X*Y 

Closed subscheme of Product of projective spaces P^2 x P^2 x P^1 over 

Integer Ring defined by: 

-x1*x3 + x0*x4, 

z0 - z1 

 

:: 

 

sage: A3.<x0,x1,x2> = AffineSpace(ZZ, 3) 

sage: X = A3.subscheme([x0*x2 - x1]) 

sage: P1.<u,v>=ProjectiveSpace(ZZ,1) 

sage: Y = P1.subscheme([u-v]) 

sage: X*Y 

Traceback (most recent call last): 

... 

TypeError: Projective Space of dimension 1 over Integer Ring must be an affine space or affine subscheme 

sage: Y*X 

Traceback (most recent call last): 

... 

TypeError: Affine Space of dimension 3 over Integer Ring must be a projective space, product of projective spaces, or subscheme 

sage: PP.<a,b,c,d>=ProductProjectiveSpaces(ZZ, [1,1]) 

sage: Z = PP.subscheme([a*d-b*c]) 

sage: X*Z 

Traceback (most recent call last): 

... 

TypeError: Product of projective spaces P^1 x P^1 over Integer Ring must be an affine space or affine subscheme 

sage: Z*X 

Traceback (most recent call last): 

... 

TypeError: Affine Space of dimension 3 over Integer Ring must be a projective space, product of projective spaces, or subscheme 

""" 

#This will catch any ambient space mistmatches 

AS = self.ambient_space()*right.ambient_space() 

CR = AS.coordinate_ring() 

n = self.ambient_space().coordinate_ring().ngens() 

 

phi = self.ambient_space().coordinate_ring().hom(list(CR.gens()[:n]), CR) 

psi = right.ambient_space().coordinate_ring().hom(list(CR.gens()[n:]), CR) 

return AS.subscheme([phi(t) for t in self.defining_polynomials()] + [psi(t) for t in right.defining_polynomials()]) 

 

 

__add__ = union 

 

def intersection(self, other): 

""" 

Return the scheme-theoretic intersection of self and other in their 

common ambient space. 

 

EXAMPLES:: 

 

sage: A.<x, y> = AffineSpace(2, ZZ) 

sage: X = A.subscheme([x^2-y]) 

sage: Y = A.subscheme([y]) 

sage: X.intersection(Y) 

Closed subscheme of Affine Space of dimension 2 over Integer Ring defined by: 

x^2 - y, 

y 

""" 

if not isinstance(other, AlgebraicScheme_subscheme): 

raise TypeError("other (=%s) must be a closed algebraic subscheme of an ambient space"%other) 

A = self.ambient_space() 

if other.ambient_space() != A: 

raise ValueError("other (=%s) must be in the same ambient space as self"%other) 

return A.subscheme(self.defining_ideal() + other.defining_ideal()) 

 

def complement(self, other=None): 

""" 

Return the scheme-theoretic complement other - self, where 

self and other are both closed algebraic subschemes of the 

same ambient space. 

 

If other is unspecified, it is taken to be the ambient space 

of self. 

 

EXAMPLES:: 

 

sage: A.<x, y, z> = AffineSpace(3, ZZ) 

sage: X = A.subscheme([x+y-z]) 

sage: Y = A.subscheme([x-y+z]) 

sage: Y.complement(X) 

Quasi-affine subscheme X - Y of Affine Space of 

dimension 3 over Integer Ring, where X is defined by: 

x + y - z 

and Y is defined by: 

x - y + z 

sage: Y.complement() 

Quasi-affine subscheme X - Y of Affine Space of 

dimension 3 over Integer Ring, where X is defined by: 

(no polynomials) 

and Y is defined by: 

x - y + z 

sage: P.<x, y, z> = ProjectiveSpace(2, QQ) 

sage: X = P.subscheme([x^2+y^2+z^2]) 

sage: Y = P.subscheme([x*y+y*z+z*x]) 

sage: Y.complement(X) 

Quasi-projective subscheme X - Y of Projective Space of 

dimension 2 over Rational Field, where X is defined by: 

x^2 + y^2 + z^2 

and Y is defined by: 

x*y + x*z + y*z 

sage: Y.complement(P) 

Quasi-projective subscheme X - Y of Projective Space of 

dimension 2 over Rational Field, where X is defined by: 

(no polynomials) 

and Y is defined by: 

x*y + x*z + y*z 

""" 

A = self.ambient_space() 

if other is None: 

other = A.subscheme([]) 

elif not isinstance(other, AlgebraicScheme_subscheme): 

if other == A: 

other = A.subscheme([]) 

else: 

raise TypeError("Argument other (=%s) must be a closed algebraic subscheme of an ambient space"%other) 

if other.ambient_space() != A: 

raise ValueError("other (=%s) must be in the same ambient space as self"%other) 

return AlgebraicScheme_quasi(other, self) 

 

def rational_points(self, bound=0, F=None): 

""" 

Return the rational points on the algebraic subscheme. 

 

EXAMPLES: 

 

Enumerate over a projective scheme over a number field:: 

 

sage: u = QQ['u'].0 

sage: K.<v> = NumberField(u^2 + 3) 

sage: A.<x,y> = ProjectiveSpace(K,1) 

sage: X=A.subscheme(x^2 - y^2) 

sage: X.rational_points(3) 

[(-1 : 1), (1 : 1)] 

 

One can enumerate points up to a given bound on a projective scheme 

over the rationals:: 

 

sage: E = EllipticCurve('37a') 

sage: E.rational_points(bound=8) 

[(-1 : -1 : 1), (-1 : 0 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 0), (1/4 : -5/8 : 1), 

(1/4 : -3/8 : 1), (1 : -1 : 1), (1 : 0 : 1), (2 : -3 : 1), (2 : 2 : 1)] 

 

For a small finite field, the complete set of points can be 

enumerated. :: 

 

sage: Etilde = E.base_extend(GF(3)) 

sage: Etilde.rational_points() 

[(0 : 0 : 1), (0 : 1 : 0), (0 : 2 : 1), (1 : 0 : 1), 

(1 : 2 : 1), (2 : 0 : 1), (2 : 2 : 1)] 

 

The class of hyperelliptic curves does not (yet) support 

desingularization of the places at infinity into two points:: 

 

sage: FF = FiniteField(7) 

sage: P.<x> = PolynomialRing(FiniteField(7)) 

sage: C = HyperellipticCurve(x^8+x+1) 

sage: C.rational_points() 

[(0 : 1 : 0), (0 : 1 : 1), (0 : 6 : 1), (2 : 0 : 1), 

(4 : 0 : 1), (6 : 1 : 1), (6 : 6 : 1)] 

 

.. TODO:: 

 

1. The above algorithms enumerate all projective points and 

test whether they lie on the scheme; Implement a more naive 

sieve at least for covers of the projective line. 

 

2. Implement Stoll's model in weighted projective space to 

resolve singularities and find two points (1 : 1 : 0) and 

(-1 : 1 : 0) at infinity. 

""" 

if F is None: 

F = self.base_ring() 

X = self.base_extend(F)(F) 

if F in NumberFields() or F == ZZ: 

try: 

return X.points(bound) # checks for proper bound done in points functions 

except TypeError: 

raise TypeError("Unable to enumerate points over %s."%F) 

try: 

return X.points() 

except TypeError: 

raise TypeError("Unable to enumerate points over %s."%F) 

 

def change_ring(self, R): 

r""" 

Returns a new algebraic subscheme which is this subscheme coerced to ``R``. 

 

INPUT: 

 

- ``R`` -- ring or morphism. 

 

OUTPUT: 

 

- A new algebraic subscheme which is this subscheme coerced to ``R``. 

 

EXAMPLES:: 

 

sage: P.<x,y> = ProjectiveSpace(QQ, 1) 

sage: X = P.subscheme([3*x^2-y^2]) 

sage: H = Hom(X,X) 

sage: X.change_ring(GF(3)) 

Closed subscheme of Projective Space of dimension 1 over Finite Field of size 3 defined by: 

-y^2 

 

:: 

 

sage: K.<w> = QuadraticField(2) 

sage: R.<z> = K[] 

sage: L.<v> = K.extension(z^3-5) 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: X = P.subscheme(x - w*y) 

sage: X.change_ring(L) 

Closed subscheme of Projective Space of dimension 1 over Number Field in v with 

defining polynomial z^3 - 5 over its base field defined by: 

x + (-w)*y 

 

:: 

 

sage: K.<w> = QuadraticField(2) 

sage: R.<z> = K[] 

sage: L.<v> = K.extension(z^3-5) 

sage: P.<x,y,z> = AffineSpace(L,3) 

sage: X = P.subscheme([x-w*y, z^2-v*x]) 

sage: emb = L.embeddings(QQbar) 

sage: X.change_ring(emb[0]) 

Closed subscheme of Affine Space of dimension 3 over Algebraic Field 

defined by: 

x + (-1.414213562373095? + 0.?e-16*I)*y, 

z^2 + (0.8549879733383485? + 1.480882609682365?*I)*x 

 

:: 

 

sage: K.<w> = QuadraticField(2) 

sage: R.<z> = K[] 

sage: L.<v> = K.extension(z^3-5) 

sage: P.<x,y,z> = AffineSpace(L,3) 

sage: X = P.subscheme([x-w*y, z^2-v*x]) 

sage: emb = L.embeddings(QQbar) 

sage: X.change_ring(emb[1]) 

Closed subscheme of Affine Space of dimension 3 over Algebraic Field 

defined by: 

x + (-1.414213562373095? + 0.?e-16*I)*y, 

z^2 + (0.8549879733383485? - 1.480882609682365?*I)*x 

 

:: 

 

sage: K.<w> = QuadraticField(-3) 

sage: P.<x,y> = ProjectiveSpace(K, 1) 

sage: X = P.subscheme(x-w*y) 

sage: X.change_ring(CC) 

Closed subscheme of Projective Space of dimension 1 over Complex Field 

with 53 bits of precision defined by: 

x + (-1.73205080756888*I)*y 

 

:: 

 

sage: K.<w> = QuadraticField(3) 

sage: P.<x,y> = ProjectiveSpace(K,1) 

sage: X = P.subscheme(x-w*y) 

sage: X.change_ring(RR) 

Closed subscheme of Projective Space of dimension 1 over Real Field 

with 53 bits of precision defined by: 

x - 1.73205080756888*y 

 

:: 

 

sage: K.<v> = CyclotomicField(7) 

sage: O = K.maximal_order() 

sage: P.<x,y> = ProjectiveSpace(O, 1) 

sage: X = P.subscheme([x^2+O(v)*y^2]) 

sage: X.change_ring(CC) 

Closed subscheme of Projective Space of dimension 1 over Complex Field 

with 53 bits of precision defined by: 

x^2 + (0.623489801858734 + 0.781831482468030*I)*y^2 

sage: X.change_ring(K).change_ring(K.embeddings(QQbar)[0]) 

Closed subscheme of Projective Space of dimension 1 over Algebraic Field defined by: 

x^2 + (-0.9009688679024191? - 0.4338837391175581?*I)*y^2 

 

:: 

 

sage: R.<x> = QQ[] 

sage: f = x^6-2 

sage: L.<b> = NumberField(f, embedding=f.roots(CC)[2][0]) 

sage: A.<x,y> = AffineSpace(L, 2) 

sage: H = Hom(A,A) 

sage: X = A.subscheme([b*x^2, y^2]) 

sage: X.change_ring(CC) 

Closed subscheme of Affine Space of dimension 2 over Complex Field with 

53 bits of precision defined by: 

(-0.561231024154687 - 0.972080648619833*I)*x^2, 

y^2 

""" 

K = self.base_ring() 

AS = self.ambient_space() 

new_AS = AS.change_ring(R) 

I = [f.change_ring(R) for f in self.defining_polynomials()] 

return(new_AS.subscheme(I)) 

 

def weil_restriction(self): 

r""" 

Compute the Weil restriction of this variety over some extension 

field. If the field is a finite field, then this computes 

the Weil restriction to the prime subfield. 

 

A Weil restriction of scalars - denoted `Res_{L/k}` - is a 

functor which, for any finite extension of fields `L/k` and 

any algebraic variety `X` over `L`, produces another 

corresponding variety `Res_{L/k}(X)`, defined over `k`. It is 

useful for reducing questions about varieties over large 

fields to questions about more complicated varieties over 

smaller fields. 

 

This function does not compute this Weil restriction directly 

but computes on generating sets of polynomial ideals: 

 

Let `d` be the degree of the field extension `L/k`, let `a` a 

generator of `L/k` and `p` the minimal polynomial of 

`L/k`. Denote this ideal by `I`. 

 

Specifically, this function first maps each variable `x` to 

its representation over `k`: `\sum_{i=0}^{d-1} a^i x_i`. Then 

each generator of `I` is evaluated over these representations 

and reduced modulo the minimal polynomial `p`. The result is 

interpreted as a univariate polynomial in `a` and its 

coefficients are the new generators of the returned ideal. 

 

If the input and the output ideals are radical, this is 

equivalent to the statement about algebraic varieties above. 

 

OUTPUT: Affine subscheme - the Weil restriction of ``self``. 

 

EXAMPLES:: 

 

sage: R.<x> = QQ[] 

sage: K.<w> = NumberField(x^5-2) 

sage: R.<x> = K[] 

sage: L.<v> = K.extension(x^2+1) 

sage: A.<x,y> = AffineSpace(L,2) 

sage: X = A.subscheme([y^2-L(w)*x^3-v]) 

sage: X.weil_restriction() 

Closed subscheme of Affine Space of dimension 4 over Number Field in w 

with defining polynomial x^5 - 2 defined by: 

(-w)*z0^3 + (3*w)*z0*z1^2 + z2^2 - z3^2, 

(-3*w)*z0^2*z1 + (w)*z1^3 + 2*z2*z3 - 1 

sage: X.weil_restriction().ambient_space() is A.weil_restriction() 

True 

 

:: 

 

sage: A.<x,y,z> = AffineSpace(GF(5^2,'t'),3) 

sage: X = A.subscheme([y^2-x*z, z^2+2*y]) 

sage: X.weil_restriction() 

Closed subscheme of Affine Space of dimension 6 over Finite Field of 

size 5 defined by: 

z2^2 - 2*z3^2 - z0*z4 + 2*z1*z5, 

2*z2*z3 + z3^2 - z1*z4 - z0*z5 - z1*z5, 

z4^2 - 2*z5^2 + 2*z2, 

2*z4*z5 + z5^2 + 2*z3 

""" 

try: 

X = self.__weil_restriction 

except AttributeError: 

L = self.base_ring() 

if L.is_finite(): 

d = L.degree() 

else: 

d = L.relative_degree() 

 

if d == 1: 

X = self 

else: 

A = self.ambient_space().weil_restriction() 

I = self.defining_ideal().weil_restriction() 

X = A.subscheme(I) 

self.__weil_restriction = X 

return X 

 

def specialization(self, D=None, phi=None): 

r""" 

Specialization of this subscheme. 

 

Given a family of maps defined over a polynomial ring. A specialization 

is a particular member of that family. The specialization can be specified either 

by a dictionary or a :class:`SpecializationMorphism`. 

 

INPUT: 

 

- ``D`` -- dictionary (optional) 

 

- ``phi`` -- SpecializationMorphism (optional) 

 

OUTPUT: :class:`SchemeMorphism_polynomial` 

 

EXAMPLES:: 

 

sage: R.<c> = PolynomialRing(QQ) 

sage: P.<x,y> = ProjectiveSpace(R, 1) 

sage: X = P.subscheme([x^2 + c*y^2]) 

sage: X.specialization(dict({c:2})) 

Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: 

x^2 + 2*y^2 

 

:: 

 

sage: R.<c> = PolynomialRing(QQ) 

sage: S.<a,b> = R[] 

sage: P.<x,y,z> = AffineSpace(S,3) 

sage: X = P.subscheme([x^2+a*c*y^2 - b*z^2]) 

sage: from sage.rings.polynomial.flatten import SpecializationMorphism 

sage: phi = SpecializationMorphism(P.coordinate_ring(),dict({c:2,a:1})) 

sage: X.specialization(phi=phi) 

Closed subscheme of Affine Space of dimension 3 over Univariate Polynomial Ring in b over Rational Field defined by: 

x^2 + 2*y^2 + (-b)*z^2 

""" 

if D is None: 

if phi is None: 

raise ValueError("either the dictionary or the specialization must be provided") 

else: 

from sage.rings.polynomial.flatten import SpecializationMorphism 

phi = SpecializationMorphism(self.ambient_space().coordinate_ring(),D) 

amb = self.ambient_space().change_ring(phi.codomain().base_ring()) 

return amb.subscheme([phi(g) for g in self.defining_polynomials()])