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

r""" 

Scheme morphism 

 

.. NOTE:: 

 

You should never create the morphisms directly. Instead, use the 

:meth:`~sage.schemes.generic.scheme.hom` and 

:meth:`~sage.structure.parent.Hom` methods that are inherited by 

all schemes. 

 

If you want to extend the Sage library with some new kind of scheme, 

your new class (say, ``myscheme``) should provide a method 

 

* ``myscheme._morphism(*args, **kwds)`` returning a morphism 

between two schemes in your category, usually defined via 

polynomials. Your morphism class should derive from 

:class:`SchemeMorphism_polynomial`. These morphisms will usually be 

elements of the Hom-set 

:class:`~sage.schemes.generic.homset.SchemeHomset_generic`. 

 

Optionally, you can also provide a special Hom-set class for your 

subcategory of schemes. If you want to do this, you should also 

provide a method 

 

* ``myscheme._homset(*args, **kwds)`` returning a 

Hom-set, which must be an element of a derived class of 

:class:`~sage.schemes.generic.homset.SchemeHomset_generic`. If your 

new Hom-set class does not use ``myscheme._morphism`` then you 

do not have to provide it. 

 

Note that points on schemes are morphisms `Spec(K)\to X`, too. But we 

typically use a different notation, so they are implemented in a 

different derived class. For this, you should implement a method 

 

* ``myscheme._point(*args, **kwds)`` returning a point, that is, 

a morphism `Spec(K)\to X`. Your point class should derive from 

:class:`SchemeMorphism_point`. 

 

Optionally, you can also provide a special Hom-set for the points, for 

example the point Hom-set can provide a method to enumerate all 

points. If you want to do this, you should also provide a method 

 

* ``myscheme._point_homset(*args, **kwds)`` returning 

the :mod:`~sage.schemes.generic.homset` of points. The Hom-sets of 

points are implemented in classes named ``SchemeHomset_points_...``. 

If your new Hom-set class does not use ``myscheme._point`` then 

you do not have to provide it. 

 

AUTHORS: 

 

- David Kohel, William Stein 

 

- William Stein (2006-02-11): fixed bug where P(0,0,0) was allowed as 

a projective point. 

 

- Volker Braun (2011-08-08): Renamed classes, more documentation, misc 

cleanups. 

 

- Ben Hutz (June 2012): added support for projective ring 

 

- Simon King (2013-10): copy the changes of :class:`~sage.categories.morphism.Morphism` 

that have been introduced in :trac:`14711`. 

""" 

 

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

# Copyright (C) 2013 Simon King <simon.king@uni-jena.de> 

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

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

# Copyright (C) 2006 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/ 

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

 

from __future__ import absolute_import, print_function 

 

import operator 

from sage.structure.element import (AdditiveGroupElement, RingElement, 

Element, parent, coercion_model) 

from sage.arith.power import generic_power 

from sage.structure.richcmp import richcmp 

from sage.structure.sequence import Sequence 

from sage.categories.homset import Homset, Hom, End 

from sage.categories.number_fields import NumberFields 

from sage.categories.fields import Fields 

from sage.rings.all import Integer, CIF 

from sage.rings.fraction_field import FractionField 

from sage.rings.fraction_field_element import FractionFieldElement 

from .point import is_SchemeTopologicalPoint 

from sage.rings.infinity import infinity 

from . import scheme 

 

from sage.categories.gcd_domains import GcdDomains 

from sage.rings.qqbar import QQbar 

from sage.rings.quotient_ring import QuotientRing_generic 

from sage.rings.rational_field import QQ 

from sage.categories.map import FormalCompositeMap, Map 

from sage.misc.constant_function import ConstantFunction 

from sage.categories.morphism import SetMorphism 

from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme 

 

 

def is_SchemeMorphism(f): 

""" 

Test whether ``f`` is a scheme morphism. 

 

INPUT: 

 

- ``f`` -- anything. 

 

OUTPUT: 

 

Boolean. Return ``True`` if ``f`` is a scheme morphism or a point 

on an elliptic curve. 

 

EXAMPLES:: 

 

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

sage: f = H([y,x^2+y]); f 

Scheme endomorphism of Affine Space of dimension 2 over Rational Field 

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

(y, x^2 + y) 

sage: from sage.schemes.generic.morphism import is_SchemeMorphism 

sage: is_SchemeMorphism(f) 

True 

""" 

from sage.schemes.elliptic_curves.ell_point import EllipticCurvePoint_field 

return isinstance(f, (SchemeMorphism, EllipticCurvePoint_field)); 

 

class SchemeMorphism(Element): 

""" 

Base class for scheme morphisms 

 

INPUT: 

 

- ``parent`` -- the parent of the morphism. 

 

.. TODO:: 

 

For historical reasons, :class:`SchemeMorphism` copies code from 

:class:`~sage.categories.map.Map` rather than inheriting from it. 

Proper inheritance should be used instead. See :trac:`14711`. 

 

EXAMPLES:: 

 

sage: X = Spec(ZZ) 

sage: Hom = X.Hom(X) 

sage: from sage.schemes.generic.morphism import SchemeMorphism 

sage: f = SchemeMorphism(Hom) 

sage: type(f) 

<class 'sage.schemes.generic.morphism.SchemeMorphism'> 

 

TESTS:: 

 

sage: A2 = AffineSpace(QQ,2) 

sage: A2.structure_morphism().domain() 

Affine Space of dimension 2 over Rational Field 

sage: A2.structure_morphism().category() 

Category of homsets of schemes 

""" 

 

def __init__(self, parent, codomain=None): 

""" 

The Python constructor. 

 

EXAMPLES:: 

 

sage: X = Spec(ZZ) 

sage: Hom = X.Hom(X) 

sage: from sage.schemes.generic.morphism import SchemeMorphism 

sage: f = SchemeMorphism(Hom) 

sage: type(f) 

<class 'sage.schemes.generic.morphism.SchemeMorphism'> 

""" 

if codomain is not None: 

parent = Hom(parent, codomain) 

if not isinstance(parent, Homset): 

raise TypeError("parent (=%s) must be a Homspace"%parent) 

Element.__init__(self, parent) 

self.domain = ConstantFunction(parent.domain()) 

self._codomain = parent.codomain() 

self.codomain = ConstantFunction(self._codomain) 

 

# We copy methods of sage.categories.map.Map, to make 

# a future transition of SchemeMorphism to a sub-class of Morphism 

# easier. 

def __call__(self, x, *args, **kwds): 

""" 

Do not override this method! 

 

For implementing application of maps, implement a method 

``_call_(self, x)`` and/or a method ``_call_with_args(x, args, kwds)`. 

In these methods, you can assume that ``x`` belongs to the domain of 

this morphism, ``args`` is a tuple and ``kwds`` is a dict. 

 

EXAMPLES:: 

 

sage: R.<x,y> = QQ[] 

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

sage: H = A.Hom(A) 

sage: f = H([y,x^2+y]) 

sage: f([2,3]) # indirect doctest 

(3, 7) 

 

An example with optional arguments:: 

 

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

sage: H=Hom(PS,PS) 

sage: f=H([x^3,x*y^2]) 

sage: P=PS(0,1) 

sage: f(P,check=False) # indirect doctest 

(0 : 0) 

""" 

P = parent(x) 

D = self.domain() 

if P is D: # we certainly want to call _call_/with_args 

if not args and not kwds: 

return self._call_(x) 

return self._call_with_args(x, args, kwds) 

# Is there coercion? 

converter = D._internal_coerce_map_from(P) 

if converter is None: 

try: 

return self.pushforward(x,*args,**kwds) 

except (AttributeError, TypeError, NotImplementedError): 

pass # raise TypeError, "%s must be coercible into %s"%(x, self.domain()) 

# Here, we would like to do 

##try: 

## x = D(x). 

##except (TypeError, NotImplementedError): 

## raise TypeError, "%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain()) 

# However, this would involve a test whether x.codomain() == 

# self. This would trigger a Groebner basis computation, that 

# (1) could be slow and (2) could involve an even slower toy 

# implementation, resulting in a warning. 

# 

# Contract: If x is a scheme morphism point, then _call_ knows 

# what to do with it (e.g., use the _coords attribute). Otherwise, 

# we can try a conversion into the domain (e.g., if x is a list), 

# WITHOUT to trigger a Groebner basis computation. 

if kwds.get('check', True): 

if not isinstance(x, SchemeMorphism_point): 

try: 

x = D(x) 

except (TypeError, NotImplementedError): 

raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain())) 

elif self.domain()!=x.codomain(): 

raise TypeError("%s fails to convert into the map's domain %s, but a `pushforward` method is not properly implemented"%(x, self.domain())) 

else: 

x = converter(x) 

if not args and not kwds: 

return self._call_(x) 

return self._call_with_args(x, args, kwds) 

 

def _repr_defn(self): 

r""" 

Return a string representation of the definition of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

sage: X = Spec(ZZ) 

sage: Hom = X.Hom(X) 

sage: from sage.schemes.generic.morphism import SchemeMorphism 

sage: f = SchemeMorphism(Hom) 

sage: f._repr_defn() 

Traceback (most recent call last): 

... 

NotImplementedError 

""" 

raise NotImplementedError 

 

def _repr_type(self): 

r""" 

Return a string representation of the type of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

sage: A2 = AffineSpace(QQ,2) 

sage: A2.structure_morphism() # indirect doctest 

Scheme morphism: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Rational Field 

Defn: Structure map 

""" 

return "Scheme" 

 

def _repr_(self): 

r""" 

Return a string representation of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

sage: X = Spec(ZZ) 

sage: Hom = X.Hom(X) 

sage: from sage.schemes.generic.morphism import SchemeMorphism 

sage: f = SchemeMorphism(Hom) 

sage: f._repr_() 

Traceback (most recent call last): 

... 

NotImplementedError 

""" 

if self.is_endomorphism(): 

s = "%s endomorphism of %s"%(self._repr_type(), self.domain()) 

else: 

s = "%s morphism:"%self._repr_type() 

s += "\n From: %s"%self.domain() 

s += "\n To: %s"%self._codomain 

d = self._repr_defn() 

if d != '': 

s += "\n Defn: %s"%('\n '.join(self._repr_defn().split('\n'))) 

return s 

 

def __mul__(self, right): 

""" 

We can currently only multiply scheme morphisms. 

 

If one factor is an identity morphism, the other is returned. 

Otherwise, a formal composition of maps obtained from the scheme 

morphisms is returned. 

 

EXAMPLES: 

 

Identity maps do not contribute to the product:: 

 

sage: X = AffineSpace(QQ,2) 

sage: id = X.identity_morphism() 

sage: id^0 # indirect doctest 

Scheme endomorphism of Affine Space of dimension 2 over Rational Field 

Defn: Identity map 

sage: id^2 

Scheme endomorphism of Affine Space of dimension 2 over Rational Field 

Defn: Identity map 

 

Here, we see a formal composition:: 

 

sage: X = AffineSpace(QQ,2) 

sage: f = X.structure_morphism() 

sage: Y = Spec(QQ) 

sage: g = Y.structure_morphism() 

sage: g * f # indirect doctest 

Composite map: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Integer Ring 

Defn: Generic morphism: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Rational Field 

then 

Generic morphism: 

From: Spectrum of Rational Field 

To: Spectrum of Integer Ring 

 

Of course, the codomain of the first factor must coincide with the 

domain of the second factor:: 

 

sage: f * g 

Traceback (most recent call last): 

... 

TypeError: self (=Scheme morphism: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Rational Field 

Defn: Structure map) domain must equal right (=Scheme morphism: 

From: Spectrum of Rational Field 

To: Spectrum of Integer Ring 

Defn: Structure map) codomain 

""" 

if not isinstance(right, SchemeMorphism): 

return coercion_model.bin_op(self, right, operator.mul) 

if right.codomain() != self.domain(): 

raise TypeError("self (=%s) domain must equal right (=%s) codomain"%(self, right)) 

if isinstance(self, SchemeMorphism_id): 

return right 

if isinstance(right, SchemeMorphism_id): 

return self 

return self._composition(right) 

 

def __pow__(self, n, dummy=None): 

""" 

Exponentiate an endomorphism. 

 

INPUT: 

 

- ``n`` -- integer. The exponent. 

 

OUTPUT: 

 

A composite map that belongs to the same endomorphism set as ``self``. 

 

EXAMPLES:: 

 

sage: X = AffineSpace(QQ,2) 

sage: id = X.identity_morphism() 

sage: id^0 

Scheme endomorphism of Affine Space of dimension 2 over Rational Field 

Defn: Identity map 

sage: id^2 

Scheme endomorphism of Affine Space of dimension 2 over Rational Field 

Defn: Identity map 

""" 

if not self.is_endomorphism(): 

raise TypeError("self must be an endomorphism.") 

if n==0: 

return self.domain().identity_morphism() 

return generic_power(self, n) 

 

def category(self): 

""" 

Return the category of the Hom-set. 

 

OUTPUT: 

 

A category. 

 

EXAMPLES:: 

 

sage: A2 = AffineSpace(QQ,2) 

sage: A2.structure_morphism().category() 

Category of homsets of schemes 

""" 

return self.parent().category() 

 

def category_for(self): 

""" 

Return the category which this morphism belongs to. 

 

EXAMPLES:: 

 

sage: A2 = AffineSpace(QQ,2) 

sage: A2.structure_morphism().category_for() 

Category of schemes 

""" 

return self.parent().homset_category() 

 

def is_endomorphism(self): 

""" 

Return wether the morphism is an endomorphism. 

 

OUTPUT: 

 

Boolean. Whether the domain and codomain are identical. 

 

EXAMPLES:: 

 

sage: X = AffineSpace(QQ,2) 

sage: X.structure_morphism().is_endomorphism() 

False 

sage: X.identity_morphism().is_endomorphism() 

True 

""" 

return self.parent().is_endomorphism_set() 

 

def _composition(self, right): 

""" 

A helper for multiplying maps by composition. 

 

.. WARNING:: 

 

Do not override this method! Override :meth:`_composition_` 

instead. 

 

EXAMPLES:: 

 

sage: X = AffineSpace(QQ,2) 

sage: f = X.structure_morphism() 

sage: Y = Spec(QQ) 

sage: g = Y.structure_morphism() 

sage: g * f # indirect doctest 

Composite map: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Integer Ring 

Defn: Generic morphism: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Rational Field 

then 

Generic morphism: 

From: Spectrum of Rational Field 

To: Spectrum of Integer Ring 

 

sage: f * g 

Traceback (most recent call last): 

... 

TypeError: self (=Scheme morphism: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Rational Field 

Defn: Structure map) domain must equal right (=Scheme morphism: 

From: Spectrum of Rational Field 

To: Spectrum of Integer Ring 

Defn: Structure map) codomain 

""" 

category = self.category_for()._meet_(right.category_for()) 

H = Hom(right.domain(), self._codomain, category) 

return self._composition_(right, H) 

 

def _composition_(self, right, homset): 

""" 

Helper to construct the composition of two morphisms. 

 

Override this if you want to have a different behaviour of composition 

 

INPUT: 

 

- ``right`` -- a map or callable 

- ``homset`` -- a homset containing the composed map 

 

OUTPUT: 

 

An element of ``homset``. The output is obtained by converting the 

arguments to :class:`~sage.categories.morphism.SetMorphism` if 

necessary, and then forming a :class:`~sage.categories.map.FormalCompositeMap` 

 

EXAMPLES:: 

 

sage: X = AffineSpace(QQ,2) 

sage: f = X.structure_morphism() 

sage: Y = Spec(QQ) 

sage: g = Y.structure_morphism() 

sage: g * f # indirect doctest 

Composite map: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Integer Ring 

Defn: Generic morphism: 

From: Affine Space of dimension 2 over Rational Field 

To: Spectrum of Rational Field 

then 

Generic morphism: 

From: Spectrum of Rational Field 

To: Spectrum of Integer Ring 

""" 

if not isinstance(right, Map): 

right = SetMorphism(right.parent(), right) 

return FormalCompositeMap(homset, right, SetMorphism(self.parent(),self)) 

 

def glue_along_domains(self, other): 

r""" 

Glue two morphism 

 

INPUT: 

 

- ``other`` -- a scheme morphism with the same domain. 

 

OUTPUT: 

 

Assuming that self and other are open immersions with the same 

domain, return scheme obtained by gluing along the images. 

 

EXAMPLES: 

 

We construct a scheme isomorphic to the projective line over 

`\mathrm{Spec}(\QQ)` by gluing two copies of `\mathbb{A}^1` 

minus a point:: 

 

sage: R.<x,y> = PolynomialRing(QQ, 2) 

sage: S.<xbar, ybar> = R.quotient(x*y - 1) 

sage: Rx = PolynomialRing(QQ, 'x') 

sage: i1 = Rx.hom([xbar]) 

sage: Ry = PolynomialRing(QQ, 'y') 

sage: i2 = Ry.hom([ybar]) 

sage: Sch = Schemes() 

sage: f1 = Sch(i1) 

sage: f2 = Sch(i2) 

 

Now f1 and f2 have the same domain, which is a 

`\mathbb{A}^1` minus a point. We glue along the domain:: 

 

sage: P1 = f1.glue_along_domains(f2) 

sage: P1 

Scheme obtained by gluing X and Y along U, where 

X: Spectrum of Univariate Polynomial Ring in x over Rational Field 

Y: Spectrum of Univariate Polynomial Ring in y over Rational Field 

U: Spectrum of Quotient of Multivariate Polynomial Ring in x, y 

over Rational Field by the ideal (x*y - 1) 

 

sage: a, b = P1.gluing_maps() 

sage: a 

Affine Scheme morphism: 

From: Spectrum of Quotient of Multivariate Polynomial Ring in x, y 

over Rational Field by the ideal (x*y - 1) 

To: Spectrum of Univariate Polynomial Ring in x over Rational Field 

Defn: Ring morphism: 

From: Univariate Polynomial Ring in x over Rational Field 

To: Quotient of Multivariate Polynomial Ring in x, y over 

Rational Field by the ideal (x*y - 1) 

Defn: x |--> xbar 

sage: b 

Affine Scheme morphism: 

From: Spectrum of Quotient of Multivariate Polynomial Ring in x, y 

over Rational Field by the ideal (x*y - 1) 

To: Spectrum of Univariate Polynomial Ring in y over Rational Field 

Defn: Ring morphism: 

From: Univariate Polynomial Ring in y over Rational Field 

To: Quotient of Multivariate Polynomial Ring in x, y over 

Rational Field by the ideal (x*y - 1) 

Defn: y |--> ybar 

""" 

from . import glue 

return glue.GluedScheme(self, other) 

 

class SchemeMorphism_id(SchemeMorphism): 

""" 

Return the identity morphism from `X` to itself. 

 

INPUT: 

 

- ``X`` -- the scheme. 

 

EXAMPLES:: 

 

sage: X = Spec(ZZ) 

sage: X.identity_morphism() # indirect doctest 

Scheme endomorphism of Spectrum of Integer Ring 

Defn: Identity map 

""" 

def __init__(self, X): 

""" 

The Python constructor. 

 

See :class:`SchemeMorphism_id` for details. 

 

TESTS:: 

 

sage: Spec(ZZ).identity_morphism() 

Scheme endomorphism of Spectrum of Integer Ring 

Defn: Identity map 

""" 

SchemeMorphism.__init__(self, X.Hom(X)) 

 

def _repr_defn(self): 

r""" 

Return a string representation of the definition of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

sage: Spec(ZZ).identity_morphism()._repr_defn() 

'Identity map' 

""" 

return 'Identity map' 

 

 

class SchemeMorphism_structure_map(SchemeMorphism): 

r""" 

The structure morphism 

 

INPUT: 

 

- ``parent`` -- Hom-set with codomain equal to the base scheme of 

the domain. 

 

EXAMPLES:: 

 

sage: Spec(ZZ).structure_morphism() # indirect doctest 

Scheme endomorphism of Spectrum of Integer Ring 

Defn: Structure map 

""" 

def __init__(self, parent, codomain=None): 

""" 

The Python constructor. 

 

See :class:`SchemeMorphism_structure_map` for details. 

 

TESTS:: 

 

sage: from sage.schemes.generic.morphism import SchemeMorphism_structure_map 

sage: SchemeMorphism_structure_map( Spec(QQ).Hom(Spec(ZZ)) ) 

Scheme morphism: 

From: Spectrum of Rational Field 

To: Spectrum of Integer Ring 

Defn: Structure map 

""" 

SchemeMorphism.__init__(self, parent, codomain=None) 

if self.domain().base_scheme() != self._codomain: 

raise ValueError("parent must have codomain equal the base scheme of domain.") 

 

def _repr_defn(self): 

r""" 

Return a string representation of the definition of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

sage: Spec(ZZ).structure_morphism()._repr_defn() 

'Structure map' 

""" 

return 'Structure map' 

 

 

class SchemeMorphism_spec(SchemeMorphism): 

""" 

Morphism of spectra of rings 

 

INPUT: 

 

- ``parent`` -- Hom-set whose domain and codomain are affine schemes. 

 

- ``phi`` -- a ring morphism with matching domain and codomain. 

 

- ``check`` -- boolean (optional, default:``True``). Whether to 

check the input for consistency. 

 

EXAMPLES:: 

 

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

sage: phi = R.hom([QQ(7)]); phi 

Ring morphism: 

From: Univariate Polynomial Ring in x over Rational Field 

To: Rational Field 

Defn: x |--> 7 

 

sage: X = Spec(QQ); Y = Spec(R) 

sage: f = X.hom(phi); f 

Affine Scheme morphism: 

From: Spectrum of Rational Field 

To: Spectrum of Univariate Polynomial Ring in x over Rational Field 

Defn: Ring morphism: 

From: Univariate Polynomial Ring in x over Rational Field 

To: Rational Field 

Defn: x |--> 7 

 

sage: f.ring_homomorphism() 

Ring morphism: 

From: Univariate Polynomial Ring in x over Rational Field 

To: Rational Field 

Defn: x |--> 7 

""" 

def __init__(self, parent, phi, check=True): 

""" 

The Python constructor. 

 

See :class:`SchemeMorphism_structure_map` for details. 

 

TESTS:: 

 

sage: from sage.schemes.generic.morphism import SchemeMorphism_spec 

sage: SchemeMorphism_spec(Spec(QQ).Hom(Spec(ZZ)), ZZ.hom(QQ)) 

Affine Scheme morphism: 

From: Spectrum of Rational Field 

To: Spectrum of Integer Ring 

Defn: Natural morphism: 

From: Integer Ring 

To: Rational Field 

""" 

SchemeMorphism.__init__(self, parent) 

if check: 

from sage.categories.all import Rings 

if not (isinstance(phi, Map) and phi.category_for().is_subcategory(Rings())): 

raise TypeError("phi (=%s) must be a ring homomorphism" % phi) 

if phi.domain() != parent.codomain().coordinate_ring(): 

raise TypeError("phi (=%s) must have domain %s" 

% (phi, parent.codomain().coordinate_ring())) 

if phi.codomain() != parent.domain().coordinate_ring(): 

raise TypeError("phi (=%s) must have codomain %s" 

% (phi, parent.domain().coordinate_ring())) 

self.__ring_homomorphism = phi 

 

def _call_(self, x): 

r""" 

Make morphisms callable. 

 

INPUT: 

 

- ``x`` -- a scheme point. 

 

OUTPUT: 

 

The image scheme point. 

 

EXAMPLES: 

 

The following fails because inverse images of prime ideals 

under ring homomorphisms are not yet implemented:: 

 

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

sage: phi = R.hom([QQ(7)]) 

sage: X = Spec(QQ); Y = Spec(R) 

sage: f = X.hom(phi) 

sage: f(X.an_element()) # indirect doctest 

Traceback (most recent call last): 

... 

NotImplementedError 

""" 

# By virtue of argument preprocessing in __call__, we can assume that 

# x is a topological scheme point of self 

S = self.ring_homomorphism().inverse_image(x.prime_ideal()) 

return self._codomain(S) 

 

def _repr_type(self): 

r""" 

Return a string representation of the type of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

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

sage: phi = R.hom([QQ(7)]) 

sage: X = Spec(QQ); Y = Spec(R) 

sage: f = X.hom(phi) 

sage: f._repr_type() 

'Affine Scheme' 

""" 

return "Affine Scheme" 

 

def _repr_defn(self): 

r""" 

Return a string representation of the definition of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

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

sage: phi = R.hom([QQ(7)]) 

sage: X = Spec(QQ); Y = Spec(R) 

sage: f = X.hom(phi) 

sage: print(f._repr_defn()) 

Ring morphism: 

From: Univariate Polynomial Ring in x over Rational Field 

To: Rational Field 

Defn: x |--> 7 

""" 

return repr(self.ring_homomorphism()) 

 

def ring_homomorphism(self): 

""" 

Return the underlying ring homomorphism. 

 

OUTPUT: 

 

A ring homomorphism. 

 

EXAMPLES:: 

 

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

sage: phi = R.hom([QQ(7)]) 

sage: X = Spec(QQ); Y = Spec(R) 

sage: f = X.hom(phi) 

sage: f.ring_homomorphism() 

Ring morphism: 

From: Univariate Polynomial Ring in x over Rational Field 

To: Rational Field 

Defn: x |--> 7 

""" 

return self.__ring_homomorphism 

 

 

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

# Morphisms between schemes given on points 

# The _affine and _projective below refer to the CODOMAIN. 

# The domain can be either affine or projective regardless 

# of the class 

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

class SchemeMorphism_polynomial(SchemeMorphism): 

r""" 

A morphism of schemes determined by polynomials that define what 

the morphism does on points in the ambient space. 

 

INPUT: 

 

- ``parent`` -- Hom-set whose domain and codomain are affine or 

projective schemes. 

 

- ``polys`` -- a list/tuple/iterable of polynomials defining the 

scheme morphism. 

 

- ``check`` -- boolean (optional, default:``True``). Whether to 

check the input for consistency. 

 

EXAMPLES: 

 

An example involving the affine plane:: 

 

sage: R.<x,y> = QQ[] 

sage: A2 = AffineSpace(R) 

sage: H = A2.Hom(A2) 

sage: f = H([x-y, x*y]) 

sage: f([0,1]) 

(-1, 0) 

 

An example involving the projective line:: 

 

sage: R.<x,y> = QQ[] 

sage: P1 = ProjectiveSpace(R) 

sage: H = P1.Hom(P1) 

sage: f = H([x^2+y^2,x*y]) 

sage: f([0,1]) 

(1 : 0) 

 

Some checks are performed to make sure the given polynomials 

define a morphism:: 

 

sage: f = H([exp(x),exp(y)]) 

Traceback (most recent call last): 

... 

TypeError: polys (=[e^x, e^y]) must be elements of 

Multivariate Polynomial Ring in x, y over Rational Field 

 

""" 

def __init__(self, parent, polys, check=True): 

""" 

The Python constructor. 

 

See :class:`SchemeMorphism_polynomial` for details. 

 

EXAMPLES:: 

 

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

sage: H = A2.Hom(A2) 

sage: H([x-y, x*y]) 

Scheme endomorphism of Affine Space of dimension 2 over Rational Field 

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

(x - y, x*y) 

""" 

if check: 

if not isinstance(polys, (list, tuple)): 

raise TypeError("polys (=%s) must be a list or tuple"%polys) 

source_ring = parent.domain().ambient_space().coordinate_ring() 

target = parent._codomain.ambient_space() 

if len(polys) != target.ngens(): 

raise ValueError("there must be %s polynomials"%target.ngens()) 

try: 

polys = [source_ring(poly) for poly in polys] 

except TypeError: #we may have been given elements in the quotient 

try: 

polys = [source_ring(poly.lift()) for poly in polys] 

except (TypeError, AttributeError): 

raise TypeError("polys (=%s) must be elements of %s"%(polys, source_ring)) 

polys = Sequence(polys) 

self._polys = tuple(polys) 

SchemeMorphism.__init__(self, parent) 

 

def defining_polynomials(self): 

""" 

Return the defining polynomials. 

 

OUTPUT: 

 

An immutable sequence of polynomials that defines this scheme 

morphism. 

 

EXAMPLES:: 

 

sage: R.<x,y> = QQ[] 

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

sage: H = A.Hom(A) 

sage: H([x^3+y, 1-x-y]).defining_polynomials() 

(x^3 + y, -x - y + 1) 

""" 

return self._polys 

 

def _call_(self, x): 

""" 

Apply this morphism to a point in the domain. 

 

INPUT: 

 

- ``x`` -- a point in the domain or a list or tuple that 

defines a point in the domain. 

 

OUTPUT: 

 

A point in the codomain. 

 

EXAMPLES:: 

 

sage: R.<x,y> = QQ[] 

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

sage: H = A.Hom(A) 

sage: f = H([y,x^2+y]) 

sage: f([2,3]) # indirect doctest 

(3, 7) 

 

An example with algebraic schemes:: 

 

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

sage: X = A.subscheme(x) 

sage: Y = A.subscheme(y) 

sage: Hom_XY = X.Hom(Y) 

sage: f = Hom_XY([y,0]) # (0,y) |-> (y,0) 

sage: f 

Scheme morphism: 

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

x 

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

y 

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

(y, 0) 

sage: f([0,3]) 

(3, 0) 

 

The input must be convertible into the map's domain:: 

 

sage: f(0) 

Traceback (most recent call last): 

... 

TypeError: 0 fails to convert into the map's domain Closed 

subscheme of Affine Space of dimension 2 over Rational Field 

defined by: 

x, but a `pushforward` method is not properly implemented 

 

It is possible to avoid the checks on the resulting point which can be 

useful for indeterminacies, but be careful!! :: 

 

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

sage: H=Hom(PS,PS) 

sage: f=H([x^3,x*y^2]) 

sage: P=PS(0,1) 

sage: f(P,check=False) 

(0 : 0) 

 

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

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

sage: H=Hom(X,X) 

sage: f=H([x^2,y^2,z^2]); 

sage: f([4,4,1]) 

(16 : 16 : 1) 

 

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

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

sage: H=Hom(X,X) 

sage: f=H([x^2,y^2,z^2]); 

sage: f(P([4,4,1])) 

(16 : 16 : 1) 

""" 

# Checks were done in __call__ 

P = [f(x._coords) for f in self.defining_polynomials()] 

return self._codomain.point(P,check=True) 

 

def _call_with_args(self, x, args, kwds): 

""" 

Apply this morphism to a point in the domain, with additional arguments 

 

INPUT: 

 

- ``x`` -- a point in the domain or a list or tuple that defines a point in the domain. 

- ``check``, a boolean, either provided by position or name. 

 

OUTPUT: 

 

A point in the codomain. 

 

EXAMPLES:: 

 

sage: R.<x,y> = QQ[] 

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

sage: H = A.Hom(A) 

sage: f = H([y,x^2+y]) 

sage: f([2,3]) 

(3, 7) 

 

An example with algebraic schemes:: 

 

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

sage: X = A.subscheme(x) 

sage: Y = A.subscheme(y) 

sage: Hom_XY = X.Hom(Y) 

sage: f = Hom_XY([y,0]) # (0,y) |-> (y,0) 

sage: f 

Scheme morphism: 

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

x 

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

y 

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

(y, 0) 

sage: f([0,3]) 

(3, 0) 

 

As usual, if the input does not belong to a map's domain, it is first 

attempted to convert it:: 

 

sage: f(0) 

Traceback (most recent call last): 

... 

TypeError: 0 fails to convert into the map's domain Closed subscheme of 

Affine Space of dimension 2 over Rational Field defined by: 

x, but a `pushforward` method is not properly implemented 

 

It is possible to avoid the checks on the resulting point which can be 

useful for indeterminacies, but be careful!! :: 

 

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

sage: H=Hom(PS,PS) 

sage: f=H([x^3,x*y^2]) 

sage: P=PS(0,1) 

sage: f(P,check=False) # indirect doctest 

(0 : 0) 

 

:: 

 

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

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

sage: H=Hom(X,X) 

sage: f=H([x^2,y^2,z^2]); 

sage: f([4,4,1]) 

(16 : 16 : 1) 

 

:: 

 

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

sage: P2.<u,v,w,t> = ProjectiveSpace(ZZ, 3) 

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

sage: H = Hom(X, X) 

sage: f = H([x^2, y^2, z^2]); 

sage: f(P2([4,4,1,1])) 

Traceback (most recent call last): 

... 

TypeError: (4 : 4 : 1 : 1) fails to convert into the map's domain Closed subscheme of 

Projective Space of dimension 2 over Integer Ring defined by: 

x^2 - y^2, but a `pushforward` method is not properly implemented 

""" 

if args: 

check = args[0] 

else: 

check = kwds.get("check", False) 

# containment of x in the domain has already been checked, in __call__ 

P = [f(x._coords) for f in self.defining_polynomials()] 

return self._codomain.point(P,check) 

 

 

def _repr_defn(self): 

""" 

Return a string representation of the definition of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

sage: R.<x,y> = QQ[] 

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

sage: H = A.Hom(A) 

sage: f = H([y,x^2+y]) 

sage: print(f._repr_defn()) 

Defined on coordinates by sending (x, y) to 

(y, x^2 + y) 

""" 

i = self.domain().ambient_space()._repr_generic_point() 

o = self._codomain.ambient_space()._repr_generic_point(self.defining_polynomials()) 

return "Defined on coordinates by sending %s to\n%s"%(i,o) 

 

def __getitem__(self,i): 

""" 

returns the ith poly with self[i] 

 

INPUT: 

 

- ``i``-- integer 

 

OUTPUT: 

 

- element of the coordinate ring of the domain 

 

Examples:: 

 

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

sage: H=Hom(P,P) 

sage: f=H([3/5*x^2,6*y^2]) 

sage: f[1] 

6*y^2 

""" 

return(self._polys[i]) 

 

def __copy__(self): 

r""" 

Return a copy of ``self``. 

 

OUTPUT: 

 

- :class:`SchemeMorphism_polynomial` 

 

EXAMPLES:: 

 

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

sage: H = Hom(P, P) 

sage: f = H([3/5*x^2, 6*y^2]) 

sage: g = copy(f) 

sage: f == g 

True 

sage: f is g 

False 

 

:: 

 

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

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

sage: Q = X(23, 23, 46) 

sage: P = X(1, 1, 1) 

sage: P != Q 

True 

""" 

return self.parent()(self._polys) 

 

def base_ring(self): 

r""" 

Return the base ring of ``self``, that is, the ring over which the coefficients 

of ``self`` is given as polynomials. 

 

OUTPUT: 

 

- ring 

 

EXAMPLES:: 

 

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

sage: H=Hom(P,P) 

sage: f=H([3/5*x^2,6*y^2]) 

sage: f.base_ring() 

Rational Field 

 

:: 

 

sage: R.<t>=PolynomialRing(ZZ,1) 

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

sage: H=Hom(P,P) 

sage: f=H([3*x^2,y^2]) 

sage: f.base_ring() 

Multivariate Polynomial Ring in t over Integer Ring 

""" 

return(self.domain().base_ring()) 

 

def coordinate_ring(self): 

r""" 

Returns the coordinate ring of the ambient projective space 

the multivariable polynomial ring over the base ring 

 

OUTPUT: 

 

- ring 

 

EXAMPLES:: 

 

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

sage: H=Hom(P,P) 

sage: f=H([3/5*x^2,6*y^2]) 

sage: f.coordinate_ring() 

Multivariate Polynomial Ring in x, y over Rational Field 

 

:: 

 

sage: R.<t>=PolynomialRing(ZZ,1) 

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

sage: H=Hom(P,P) 

sage: f=H([3*x^2,y^2]) 

sage: f.coordinate_ring() 

Multivariate Polynomial Ring in x, y over Multivariate Polynomial Ring 

in t over Integer Ring 

""" 

return(self._polys[0].parent()) 

 

def change_ring(self, R, check=True): 

r""" 

Returns a new :class:`SchemeMorphism_polynomial` which is this map coerced to ``R``. 

 

If ``check`` is ``True``, then the initialization checks are performed. 

 

INPUT: 

 

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

 

- ``check`` -- Boolean 

 

OUTPUT: 

 

- A new :class:`SchemeMorphism_polynomial` which is this map coerced to ``R``. 

 

EXAMPLES:: 

 

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

sage: H = Hom(P,P) 

sage: f = H([3*x^2, y^2]) 

sage: f.change_ring(GF(3)) 

Traceback (most recent call last): 

... 

ValueError: polys (=[0, y^2]) must be of the same degree 

 

:: 

 

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

sage: H = Hom(P,P) 

sage: f = H([5/2*x^3 + 3*x*y^2-y^3, 3*z^3 + y*x^2, x^3-z^3]) 

sage: f.change_ring(GF(3)) 

Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 

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

(x^3 - y^3 : x^2*y : x^3 - z^3) 

 

:: 

 

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

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

sage: H = Hom(X,X) 

sage: f = H([x, y]) 

sage: f.change_ring(GF(3)) 

Scheme endomorphism of Closed subscheme of Projective Space of dimension 

1 over Finite Field of size 3 defined by: 

-x^2 - y^2 

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

(x : y) 

 

 

Check that :trac:`16834` is fixed:: 

 

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

sage: h = Hom(A,A) 

sage: f = h([x^2+1.5, y^3, z^5-2.0]) 

sage: f.change_ring(CC) 

Scheme endomorphism of Affine Space of dimension 3 over Complex Field with 53 bits of precision 

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

(x^2 + 1.50000000000000, y^3, z^5 - 2.00000000000000) 

 

:: 

 

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

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

sage: h = Hom(A,B) 

sage: f = h([x^2, y^2]) 

sage: f.change_ring(QQ) 

Scheme morphism: 

From: Projective Space of dimension 1 over Rational Field 

To: Affine Space of dimension 2 over Rational Field 

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

(x^2, y^2) 

 

:: 

 

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

sage: H = Hom(A,A) 

sage: f = H([3*x^2/y, y^2/x]) 

sage: f.change_ring(RR) 

Scheme endomorphism of Affine Space of dimension 2 over Real Field with 

53 bits of precision 

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

(3.00000000000000*x^2/y, y^2/x) 

 

:: 

 

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

sage: K.<a> = NumberField(x^3-x+1) 

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

sage: H = End(P) 

sage: f = H([x^2 + a*x*y + a^2*y^2, y^2]) 

sage: emb = K.embeddings(QQbar) 

sage: f.change_ring(emb[0]) 

Scheme endomorphism of Projective Space of dimension 1 over Algebraic 

Field 

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

(x^2 + (-1.324717957244746?)*x*y + 1.754877666246693?*y^2 : y^2) 

sage: f.change_ring(emb[1]) 

Scheme endomorphism of Projective Space of dimension 1 over Algebraic 

Field 

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

(x^2 + (0.6623589786223730? - 0.5622795120623013?*I)*x*y + 

(0.1225611668766537? - 0.744861766619745?*I)*y^2 : y^2) 

 

:: 

 

sage: K.<v> = QuadraticField(2, embedding=QQbar(sqrt(2))) 

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

sage: H = End(P) 

sage: f = H([x^2+v*y^2, y^2]) 

sage: f.change_ring(QQbar) 

Scheme endomorphism of Projective Space of dimension 1 over Algebraic 

Field 

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

(x^2 + 1.414213562373095?*y^2 : y^2) 

 

:: 

 

sage: set_verbose(None) 

sage: K.<w> = QuadraticField(2, embedding=QQbar(-sqrt(2))) 

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

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

sage: H = End(X) 

sage: f = H([6*x^2+2*x*y+16*y^2, -w*x^2-4*x*y-4*y^2]) 

sage: f.change_ring(QQbar) 

Scheme endomorphism of Closed subscheme of Projective Space of dimension 

1 over Algebraic Field defined by: 

x - y 

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

(6*x^2 + 2*x*y + 16*y^2 : 1.414213562373095?*x^2 + (-4)*x*y + (-4)*y^2) 

 

:: 

 

sage: R.<x> = QQ[] 

sage: f = x^6-2 

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

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

sage: H = Hom(A,A) 

sage: F = H([b*x/y, 1+y]) 

sage: F.change_ring(QQbar) 

Scheme endomorphism of Affine Space of dimension 2 over Algebraic Field 

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

(1.122462048309373?*x/y, y + 1) 

 

:: 

 

sage: K.<a> = QuadraticField(-1) 

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

sage: H = End(A) 

sage: phi = H([x/y, y]) 

sage: emb = K.embeddings(QQbar)[0] 

sage: phi.change_ring(emb) 

Scheme endomorphism of Affine Space of dimension 2 over Algebraic Field 

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

(x/y, y) 

""" 

K = self.codomain().base_ring() 

T = self.domain().change_ring(R) 

if self.is_endomorphism(): 

H = End(T) 

else: 

S = self.codomain().change_ring(R) 

H = Hom(T,S) 

 

if isinstance(R, Map): 

if R.domain() == self.base_ring(): 

from sage.structure.coerce_maps import CallableConvertMap 

S = self.domain().ambient_space().coordinate_ring() 

T = T.ambient_space().coordinate_ring() 

phi = CallableConvertMap(S, T, lambda self, g:T(g.map_coefficients(R))) 

G = [] 

for f in self: 

if isinstance(f, FractionFieldElement): 

G.append(phi(f.numerator())/phi(f.denominator())) 

else: 

G.append(phi(f)) 

else: 

G = [] 

for f in self: 

if isinstance(f, FractionFieldElement): 

G.append(f.numerator().change_ring(R) / f.denominator().change_ring(R)) 

else: 

G.append(f.change_ring(R)) 

return H(G, check) 

 

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

r""" 

Specialization of this map. 

 

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) 

 

- ``homset`` -- homset of specialized map (optional) 

 

OUTPUT: :class:`SchemeMorphism_polynomial` 

 

EXAMPLES:: 

 

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

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

sage: H = End(P) 

sage: f = H([x^2 + c*y^2,y^2]) 

sage: f.specialization({c:1}) 

Scheme endomorphism of Projective Space of dimension 1 over Rational Field 

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

(x^2 + y^2 : y^2) 

 

:: 

 

sage: R.<a,b> = PolynomialRing(QQ) 

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

sage: H = End(P) 

sage: f = H([x^3 + a*x*y^2 + b*y^3, y^3]) 

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

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

sage: F = f.specialization(phi=phi); F 

Scheme endomorphism of Projective Space of dimension 1 over Rational Field 

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

(x^3 + 2*x*y^2 - y^3 : y^3) 

sage: g = H([x^2 + a*y^2,y^2]) 

sage: G = g.specialization(phi=phi) 

sage: G.parent() is F.parent() 

False 

sage: G = g.specialization(phi=phi, homset=F.parent()) 

sage: G.parent() is F.parent() 

True 

 

:: 

 

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

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

sage: X = P.subscheme([x - c*y]) 

sage: H = End(X) 

sage: f = H([x^2, c*y^2]) 

sage: f.specialization({c:2}) 

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

x - 2*y 

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

(x^2 : 2*y^2) 

 

:: 

 

sage: R.<c> = QQ[] 

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

sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2], domain=P) 

sage: F = f.dynatomic_polynomial(3) 

sage: g = F.specialization({c:1}); g 

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

sage: g == f.specialization({c:1}).dynatomic_polynomial(3) 

True 

""" 

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[0].parent(), D) 

if homset is None: 

domain = self.domain() 

if isinstance(domain, AlgebraicScheme_subscheme): 

domain = domain.specialization(phi=phi) 

else: 

domain = domain.change_ring(phi.codomain().base_ring()) 

if self.is_endomorphism(): 

homset = End(domain) 

else: 

codomain = self.codomain() 

if isinstance(codomain, AlgebraicScheme_subscheme): 

codomain = codomain.specialization(phi=phi) 

else: 

codomain = codomain.change_ring(phi.codomain().base_ring()) 

homset = Hom(domain, codomain) 

return homset([phi(g) for g in self]) 

 

def _composition_(self, other, homset): 

r""" 

Straightforward implementation of composition for scheme morphisms 

defined by polynomials. 

 

TESTS:: 

 

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

sage: H = Hom(P,P) 

sage: f = H([x^2 -29/16*y^2, y^2]) 

sage: g = H([y,x+y]) 

sage: h = f*g 

sage: h 

Scheme endomorphism of Projective Space of dimension 1 over Rational 

Field 

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

(-29/16*x^2 - 29/8*x*y - 13/16*y^2 : x^2 + 2*x*y + y^2) 

sage: p = P((1,3)) 

sage: h(p) == f(g(p)) 

True 

 

sage: Q = ProjectiveSpace(QQ,2) 

sage: H2 = Hom(P,Q) 

sage: h2 = H2([x^2+y^2,x^2,y^2+2*x^2]) 

sage: h2 * f 

Scheme morphism: 

From: Projective Space of dimension 1 over Rational Field 

To: Projective Space of dimension 2 over Rational Field 

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

(x^4 - 29/8*x^2*y^2 + 1097/256*y^4 : x^4 - 29/8*x^2*y^2 + 841/256*y^4 : 2*x^4 - 29/4*x^2*y^2 + 969/128*y^4) 

 

:: 

 

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

sage: A1.<z> = AffineSpace(QQ, 1) 

sage: H = End(A) 

sage: f = H([x^2+y^2, y^2/x]) 

sage: H1 = Hom(A, A1) 

sage: g = H1([x + y^2]) 

sage: g*f 

Scheme morphism: 

From: Affine Space of dimension 2 over Rational Field 

To: Affine Space of dimension 1 over Rational Field 

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

((x^4 + x^2*y^2 + y^4)/x^2) 

sage: f*g 

Traceback (most recent call last): 

... 

TypeError: self (=Scheme endomorphism of Affine Space of dimension 2 over Rational Field 

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

(x^2 + y^2, y^2/x)) domain must equal right (=Scheme morphism: 

From: Affine Space of dimension 2 over Rational Field 

To: Affine Space of dimension 1 over Rational Field 

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

(y^2 + x)) codomain 

 

Not both defined by polynomials:: 

 

sage: x = polygen(QQ) 

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

sage: p1, p2 = K.Hom(K) 

sage: R.<x,y> = K[] 

sage: q1 = R.Hom(R)(p1) 

sage: A = AffineSpace(R) 

sage: f1 = A.Hom(A)(q1) 

sage: g = A.Hom(A)([x^2-y, y+1]) 

sage: g*f1 

Composite map: 

From: Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2 

To: Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2 

Defn: Generic endomorphism of Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2 

then 

Generic endomorphism of Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2 

""" 

try: 

opolys = tuple(other._polys) 

except AttributeError: 

return super(SchemeMorphism_polynomial, self)._composition_(other, homset) 

return homset([p(*opolys) for p in self._polys]) 

 

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

# Rational points on schemes, which we view as morphisms determined 

# by coordinates. 

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

 

class SchemeMorphism_point(SchemeMorphism): 

""" 

Base class for rational points on schemes. 

 

Recall that the `K`-rational points of a scheme `X` over `k` can 

be identified with the set of morphisms `Spec(K) \to X`. In Sage, 

the rational points are implemented by such scheme morphisms. 

 

EXAMPLES:: 

 

sage: from sage.schemes.generic.morphism import SchemeMorphism 

sage: f = SchemeMorphism(Spec(ZZ).Hom(Spec(ZZ))) 

sage: type(f) 

<class 'sage.schemes.generic.morphism.SchemeMorphism'> 

""" 

def _repr_(self): 

r""" 

Return a string representation of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

sage: A = AffineSpace(2, QQ) 

sage: a = A(1,2) 

sage: a._repr_() 

'(1, 2)' 

""" 

return self._codomain.ambient_space()._repr_generic_point(self._coords) 

 

def _latex_(self): 

r""" 

Return a latex representation of ``self``. 

 

OUTPUT: 

 

String. 

 

EXAMPLES:: 

 

sage: A = AffineSpace(2, QQ) 

sage: a = A(1,2) 

sage: latex(a) == a._latex_() 

True 

sage: a._latex_() 

'\\left(1, 2\\right)' 

""" 

return self._codomain.ambient_space()._latex_generic_point(self._coords) 

 

def __getitem__(self, n): 

""" 

Return the ``n``-th coordinate. 

 

OUTPUT: 

 

The coordinate values as an element of the base ring. 

 

EXAMPLES:: 

 

sage: A = AffineSpace(2, QQ) 

sage: a = A(1,2) 

sage: a[0] 

1 

sage: a[1] 

2 

""" 

return self._coords[n] 

 

def __iter__(self): 

""" 

Iterate over the coordinates of the point. 

 

OUTPUT: 

 

An iterator. 

 

EXAMPLES:: 

 

sage: A = AffineSpace(2, QQ) 

sage: a = A(1,2) 

sage: iter = a.__iter__() 

sage: next(iter) 

1 

sage: next(iter) 

2 

sage: list(a) 

[1, 2] 

""" 

return iter(self._coords) 

 

def __tuple__(self): 

""" 

Return the coordinates as a tuple. 

 

OUTPUT: 

 

A tuple. 

 

EXAMPLES:: 

 

sage: A = AffineSpace(2, QQ) 

sage: a = A(1,2) 

sage: tuple(a) 

(1, 2) 

""" 

return self._coords 

 

def __len__(self): 

""" 

Return the number of coordinates. 

 

OUTPUT: 

 

Integer. The number of coordinates used to describe the point. 

 

EXAMPLES:: 

 

sage: A = AffineSpace(2, QQ) 

sage: a = A(1,2) 

sage: len(a) 

2 

""" 

return len(self._coords) 

 

def _richcmp_(self, other, op): 

""" 

Compare two scheme morphisms. 

 

INPUT: 

 

- ``other`` -- anything. To compare against the scheme 

morphism ``self``. 

 

OUTPUT: 

 

boolean 

 

EXAMPLES:: 

 

sage: A = AffineSpace(2, QQ) 

sage: a = A(1,2) 

sage: b = A(3,4) 

sage: a < b 

True 

sage: a != b 

True 

""" 

if not isinstance(other, SchemeMorphism_point): 

try: 

other = self._codomain.ambient_space()(other) 

except TypeError: 

return NotImplemented 

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

 

def scheme(self): 

""" 

Return the scheme whose point is represented. 

 

OUTPUT: 

 

A scheme. 

 

EXAMPLES:: 

 

sage: A = AffineSpace(2, QQ) 

sage: a = A(1,2) 

sage: a.scheme() 

Affine Space of dimension 2 over Rational Field 

""" 

return self._codomain 

 

def change_ring(self, R, check=True): 

r""" 

Returns a new :class:`SchemeMorphism_point` which is this point coerced to``R``. 

 

If ``check`` is true, then the initialization checks are performed. 

 

INPUT: 

 

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

 

kwds: 

 

- ``check`` -- Boolean 

 

OUTPUT: :class:`SchemeMorphism_point` 

 

EXAMPLES:: 

 

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

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

sage: X(23,23,1).change_ring(GF(13)) 

(10 : 10 : 1) 

 

:: 

 

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

sage: P(-2/3,1).change_ring(CC) 

(-0.666666666666667 : 1.00000000000000) 

 

:: 

 

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

sage: P(152,113).change_ring(Zp(5)) 

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

 

:: 

 

sage: K.<v> = QuadraticField(-7) 

sage: O = K.maximal_order() 

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

sage: H = End(P) 

sage: F = H([x^2+O(v)*y^2, y^2]) 

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

Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field 

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

(x^2 + (-2.645751311064591?*I)*y^2 : y^2) 

 

:: 

 

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

sage: K.<a> = NumberField(x^2-x+1) 

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

sage: Q = P([a+1,1]) 

sage: emb = K.embeddings(QQbar) 

sage: Q.change_ring(emb[0]) 

(1.5000000000000000? - 0.866025403784439?*I : 1) 

sage: Q.change_ring(emb[1]) 

(1.5000000000000000? + 0.866025403784439?*I : 1) 

 

:: 

 

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

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

sage: Q = P([v,1]) 

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

(-1.414213562373095? : 1) 

 

:: 

 

sage: R.<x> = QQ[] 

sage: f = x^6-2 

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

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

sage: P = A([b,1]) 

sage: P.change_ring(QQbar) 

(1.122462048309373?, 1) 

""" 

S = self.codomain().change_ring(R) 

Q = [R(t) for t in self] 

return(S.point(Q, check=check)) 

 

def __copy__(self): 

r""" 

Returns a copy of the :class:`SchemeMorphism_point` self coerced to `R`. 

 

OUTPUT: 

 

- :class:`SchemeMorphism_point` 

 

EXAMPLES:: 

 

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

sage: Q = P(152, 113) 

sage: Q2 = copy(Q) 

sage: Q2 is Q 

False 

sage: Q2 == Q 

True 

""" 

return(self._codomain.point(self._coords, check=False)) 

 

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

r""" 

Specialization of this point. 

 

Given a family of points 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) 

 

- ``ambient`` -- ambient space of specialized point (optional) 

 

OUTPUT: :class:`SchemeMorphism_polynomial` 

 

EXAMPLES:: 

 

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

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

sage: Q = P([c,1]) 

sage: Q.specialization({c:1}) 

(1 : 1) 

 

:: 

 

sage: R.<a,b> = PolynomialRing(QQ) 

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

sage: Q = P([a^2 + 2*a*b + 34, 1]) 

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

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

sage: T = Q.specialization(phi=phi); T 

(34 : 1) 

sage: Q2 = P([a,1]) 

sage: T2 = Q2.specialization(phi=phi) 

sage: T2.codomain() is T.codomain() 

False 

sage: T3 = Q2.specialization(phi=phi, ambient=T.codomain()) 

sage: T3.codomain() is T.codomain() 

True 

 

:: 

 

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

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

sage: X = P.subscheme([x - c*y]) 

sage: Q = X([c, 1]) 

sage: Q2 = Q.specialization({c:2}); Q2 

(2 : 1) 

sage: Q2.codomain() 

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

x - 2*y 

 

:: 

 

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

sage: S.<k,j> = PolynomialRing(R) 

sage: K.<a,b,c,d> = S[] 

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

sage: H = End(P) 

sage: Q = P([a^2,b^2]) 

sage: Q.specialization({a:2}) 

(4 : b^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.codomain().ambient_space().coordinate_ring(), D) 

if ambient is None: 

ambient = self.codomain() 

if isinstance(ambient, AlgebraicScheme_subscheme): 

ambient = ambient.specialization(phi=phi) 

else: 

ambient = ambient.change_ring(phi.codomain().base_ring()) 

psi = ambient.ambient_space().coordinate_ring().hom([0 for i in range(ambient.ambient_space().ngens())], ambient.base_ring()) 

return ambient([psi(phi(t)) for t in self])