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

r""" 

Products of projective spaces 

 

This class builds on the projective space class and its point and morphism classes. 

 

Products of projective spaces of varying dimension are convenient 

ambient spaces for complete intersections. 

 

Group actions on them, and 

the interplay with representation theory, provide many interesting 

examples of algebraic varieties. 

 

EXAMPLES: 

 

We construct products projective spaces of various dimensions over the same ring:: 

 

sage: P1 = ProjectiveSpace(ZZ, 1, 'x') 

sage: P2 = ProjectiveSpace(ZZ, 2, 'y') 

sage: ProductProjectiveSpaces([P1, P2]) 

Product of projective spaces P^1 x P^2 over Integer Ring 

 

We can also construct the product by specifying the dimensions and the base ring:: 

 

sage: ProductProjectiveSpaces([1, 2, 3], QQ, 'z') 

Product of projective spaces P^1 x P^2 x P^3 over Rational Field 

 

sage: P2xP2 = ProductProjectiveSpaces([2, 2], QQ, names=['x', 'y']) 

sage: P2xP2.coordinate_ring().inject_variables() 

Defining x0, x1, x2, y0, y1, y2 

""" 

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

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

# Copyright (C) 2014 Ben Hutz <bn4941@gmail.com> 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License 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/ 

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

 

 

import six 

from sage.misc.cachefunc import cached_method 

from sage.misc.mrange import xmrange 

from sage.misc.all import prod 

from sage.rings.all import (PolynomialRing, ZZ, QQ, Integer, CommutativeRing) 

from sage.rings.finite_rings.finite_field_constructor import is_FiniteField 

from sage.categories.fields import Fields 

from sage.rings.polynomial.polydict import ETuple 

from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme 

from sage.schemes.generic.ambient_space import AmbientSpace 

from sage.schemes.projective.projective_space import ProjectiveSpace, ProjectiveSpace_ring 

from sage.schemes.product_projective.homset import (SchemeHomset_points_product_projective_spaces_ring, 

SchemeHomset_points_product_projective_spaces_field) 

from sage.schemes.product_projective.point import (ProductProjectiveSpaces_point_ring, 

ProductProjectiveSpaces_point_field, 

ProductProjectiveSpaces_point_finite_field) 

from sage.schemes.product_projective.morphism import ProductProjectiveSpaces_morphism_ring 

from sage.schemes.product_projective.subscheme import AlgebraicScheme_subscheme_product_projective 

 

 

def is_ProductProjectiveSpaces(x): 

r""" 

Return True if ``x`` is a product of projective spaces. 

 

This is an ambient space defined by `\mathbb{P}^n_R \times \cdots \times \mathbb{P}^m_R`, 

where `R` is a ring and `n,\ldots, m\geq 0` are integers. 

 

OUTPUT: Boolean. 

 

EXAMPLES:: 

 

sage: is_ProductProjectiveSpaces(ProjectiveSpace(5, names='x')) 

False 

sage: is_ProductProjectiveSpaces(ProductProjectiveSpaces([1, 2, 3], ZZ, 'x')) 

True 

""" 

return isinstance(x, ProductProjectiveSpaces_ring) 

 

def ProductProjectiveSpaces(n, R=None, names='x'): 

r""" 

Returns the Cartesian product of projective spaces. 

 

Can input either a list of projective space over the same base \ 

ring or the list of dimensions, the base ring, and the variable names. 

 

INPUT: 

 

- ``n`` -- a list of integers or a list of projective spaces. 

 

- ``R`` -- a ring. 

 

- ``names`` -- a string or list of strings. 

 

EXAMPLES:: 

 

sage: P1 = ProjectiveSpace(QQ, 2, 'x') 

sage: P2 = ProjectiveSpace(QQ, 3, 'y') 

sage: ProductProjectiveSpaces([P1, P2]) 

Product of projective spaces P^2 x P^3 over Rational Field 

 

:: 

 

sage: ProductProjectiveSpaces([2, 2],GF(7), 'y') 

Product of projective spaces P^2 x P^2 over Finite Field of size 7 

 

:: 

 

sage: P1 = ProjectiveSpace(ZZ, 2, 'x') 

sage: P2 = ProjectiveSpace(QQ, 3, 'y') 

sage: ProductProjectiveSpaces([P1, P2]) 

Traceback (most recent call last): 

... 

AttributeError: components must be over the same base ring 

""" 

if isinstance(R, (list, tuple)): 

n, R = R, n 

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

raise TypeError("must be a list of dimensions") 

if R is None: 

R = QQ # default is the rationals 

if isinstance(n[0], ProjectiveSpace_ring): 

#this should be a list of projective spaces 

names = [] 

N = [] 

R = None 

for PS in n: 

if not isinstance(PS,ProjectiveSpace_ring): 

raise TypeError("must be a list of projective spaces or (dimensions, base ring, names)") 

if R is None: 

R = PS.base_ring() 

elif R != PS.base_ring(): 

raise AttributeError("components must be over the same base ring") 

N.append(PS.dimension_relative()) 

names += PS.variable_names() 

if is_FiniteField(R): 

X = ProductProjectiveSpaces_finite_field(N, R, names) 

elif R in Fields(): 

X = ProductProjectiveSpaces_field(N, R, names) 

else: 

X = ProductProjectiveSpaces_ring(N, R, names) 

X._components = n 

else: 

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

raise ValueError("need list or tuple of dimensions") 

if not isinstance(R, CommutativeRing): 

raise ValueError("must be a commutative ring") 

from sage.structure.category_object import normalize_names 

n_vars = sum(d+1 for d in n) 

if isinstance(names, six.string_types): 

names = normalize_names(n_vars, names) 

else: 

name_list = list(names) 

if len(name_list) == len(n): 

names = [] 

for name, dim in zip(name_list, n): 

names += normalize_names(dim+1, name) 

else: 

n_vars = sum(1+d for d in n) 

names = normalize_names(n_vars, name_list) 

if is_FiniteField(R): 

X = ProductProjectiveSpaces_finite_field(n, R, names) 

elif R in Fields(): 

X = ProductProjectiveSpaces_field(n, R, names) 

else: 

X = ProductProjectiveSpaces_ring(n, R, names) 

return(X) 

 

class ProductProjectiveSpaces_ring(AmbientSpace): 

r""" 

Cartesian product of projective spaces `\mathbb{P}^{n_1} \times \cdots \times \mathbb{P}^{n_r}`. 

 

EXAMPLES:: 

 

sage: P.<x0,x1,x2,x3,x4> = ProductProjectiveSpaces([1, 2], QQ); P 

Product of projective spaces P^1 x P^2 over Rational Field 

sage: P.coordinate_ring() 

Multivariate Polynomial Ring in x0, x1, x2, x3, x4 over Rational Field 

sage: P[0] 

Projective Space of dimension 1 over Rational Field 

sage: P[1] 

Projective Space of dimension 2 over Rational Field 

sage: Q = P(6, 3, 2, 2, 2); Q 

(2 : 1 , 1 : 1 : 1) 

sage: Q[0] 

(2 : 1) 

sage: H = Hom(P,P) 

sage: f = H([x0^2*x3, x2*x1^2, x2^2, 2*x3^2, x4^2]) 

sage: f(Q) 

(4 : 1 , 1 : 2 : 1) 

""" 

def __init__(self, N, R = QQ, names = None): 

r""" 

The Python constructor. 

 

INPUT: 

 

- ``N`` - a list or tuple of positive integers. 

 

- ``R`` - a ring. 

 

- ``names`` - a tuple or list of strings. This must either be a single variable name 

or the complete list of variables. 

 

EXAMPLES:: 

 

sage: T.<x,y,z,u,v,w> = ProductProjectiveSpaces([2, 2], QQ) 

sage: T 

Product of projective spaces P^2 x P^2 over Rational Field 

sage: T.coordinate_ring() 

Multivariate Polynomial Ring in x, y, z, u, v, w over Rational Field 

sage: T[1].coordinate_ring() 

Multivariate Polynomial Ring in u, v, w over Rational Field 

 

:: 

 

sage: ProductProjectiveSpaces([1,1,1],ZZ, ['x', 'y', 'z', 'u', 'v', 'w']) 

Product of projective spaces P^1 x P^1 x P^1 over Integer Ring 

 

:: 

 

sage: T = ProductProjectiveSpaces([1, 1], QQ, 'z') 

sage: T.coordinate_ring() 

Multivariate Polynomial Ring in z0, z1, z2, z3 over Rational Field 

""" 

assert isinstance(N, (tuple, list)) 

N = [Integer(n) for n in N] 

assert isinstance(R, CommutativeRing) 

if len(N) < 2: 

raise ValueError("must be at least two components for a product") 

AmbientSpace.__init__(self, sum(N), R) 

self._dims = N 

start = 0 

self._components = [] 

for i in range(len(N)): 

self._components.append(ProjectiveSpace(N[i],R,names[start:start+N[i]+1])) 

start += N[i]+1 

#Note that the coordinate ring should really be the tensor product of the component 

#coordinate rings. But we just deal with them as multihomogeneous polynomial rings 

self._coordinate_ring = PolynomialRing(R,sum(N)+ len(N),names) 

self._assign_names(names) 

 

def _repr_(self): 

r""" 

Return a string representation of this space. 

 

OUTPUT: String. 

 

EXAMPLES:: 

 

sage: ProductProjectiveSpaces([1, 1, 1], ZZ, ['x', 'y', 'z', 'u', 'v', 'w']) 

Product of projective spaces P^1 x P^1 x P^1 over Integer Ring 

""" 

return ''.join([ 

'Product of projective spaces ', 

' x '.join(['P^{0}'.format(d) for d in self._dims]), 

' over ', 

str(self.base_ring())]) 

 

def _repr_generic_point(self, v=None): 

""" 

Return a string representation of the generic point 

on this product space. 

 

If ``v`` is None, the representation of the generic point of 

the product space is returned. 

 

OUTPUT: String. 

 

EXAMPLES:: 

 

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

sage: T._repr_generic_point() 

'(x0 : x1 , x2 : x3 : x4 , x5 : x6)' 

""" 

if v is None: 

v = list(self.gens()) 

else: 

v = list(v) 

splitv = self._factors(v) 

return '(%s)'%(" , ".join((" : ".join([str(t) for t in P])) for P in splitv)) 

 

def _latex_(self): 

r""" 

Return a LaTeX representation of this product space. 

 

EXAMPLES:: 

 

sage: latex(ProductProjectiveSpaces([1, 2, 3], ZZ, 'x')) 

{\mathbf P}_{\Bold{Z}}^1 \times {\mathbf P}_{\Bold{Z}}^2 \times {\mathbf 

P}_{\Bold{Z}}^3 

""" 

return '%s'%" \\times ".join([PS._latex_() for PS in self]) 

 

def _latex_generic_point(self, v = None): 

""" 

Return a LaTeX representation of the generic point 

on this product space. 

 

EXAMPLES:: 

 

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

sage: T._latex_generic_point() 

'\\left(x_{0} : x_{1} , x_{2} : x_{3} : x_{4} , x_{5} : x_{6} : x_{7} : x_{8}\\right)' 

""" 

if v is None: 

v = list(self.gens()) 

else: 

v = list(v) 

splitv = self._factors(v) 

return '\\left(%s\\right)'%(" , ".join((" : ".join([t._latex_() for t in P])) for P in splitv)) 

 

def __getitem__(self, i): 

r""" 

Return the `i`-th component of the product. 

 

INPUT: 

 

- ``i`` - a positive integer. 

 

OUTPUT: A projective space. 

 

EXAMPLES:: 

 

sage: T.<a,x,y,z,u,v,w> = ProductProjectiveSpaces([3, 2], QQ) 

sage: T[0] 

Projective Space of dimension 3 over Rational Field 

""" 

return(self._components[i]) 

 

def __eq__(self, right): 

r""" 

Check equality of two products of projective spaces. 

 

INPUT: 

 

- ``right`` -- a product of projective spaces 

 

OUTPUT: Boolean 

 

EXAMPLES:: 

 

sage: S.<a,x,y,z,u,v,w> = ProductProjectiveSpaces([3, 2], QQ) 

sage: T.<x,y,z,u,v,w> = ProductProjectiveSpaces([2, 2], QQ) 

sage: S == T 

False 

""" 

if not isinstance(right, ProductProjectiveSpaces_ring): 

return False 

else: 

return self._components == right._components 

 

def __ne__(self, other): 

""" 

Check non-equality of two products of projective spaces. 

 

INPUT: 

 

- ``other`` -- a product of projective spaces 

 

OUTPUT: Boolean 

 

EXAMPLES:: 

 

sage: S.<a,x,y,z,u,v,w> = ProductProjectiveSpaces([3, 2], QQ) 

sage: T.<x,y,z,u,v,w> = ProductProjectiveSpaces([2, 2], QQ) 

sage: S != T 

True 

""" 

return not (self == other) 

 

def __pow__(self, m): 

""" 

Return the Cartesian power of this space. 

 

INPUT: ``m`` -- integer. 

 

OUTPUT: product of projective spaces. 

 

EXAMPLES:: 

 

sage: P1 = ProductProjectiveSpaces([2,1], QQ, 'x') 

sage: P1^3 

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

Rational Field 

 

As you see, custom variable names are not preserved by power operator, 

since there is no natural way to make new ones in general. 

""" 

mm = int(m) 

if mm != m: 

raise ValueError("m must be an integer") 

return ProductProjectiveSpaces(self.dimension_relative_components()*mm, self.base_ring()) 

 

def __mul__(self, right): 

r""" 

Create the product of projective spaces. 

 

INPUT: 

 

- ``right`` - a projective space, product of projective spaces, or subscheme. 

 

OUTPUT: a product of projective spaces or subscheme 

 

EXAMPLES:: 

 

sage: S.<t,x,y,z,u,v,w> = ProductProjectiveSpaces([3, 2], QQ) 

sage: T.<a,b> = ProjectiveSpace(QQ, 1) 

sage: S*T 

Product of projective spaces P^3 x P^2 x P^1 over Rational Field 

 

:: 

 

sage: S = ProductProjectiveSpaces([3, 2], QQ, 'x') 

sage: T = ProductProjectiveSpaces([2, 2], QQ, 'y') 

sage: S*T 

Product of projective spaces P^3 x P^2 x P^2 x P^2 over Rational Field 

 

:: 

 

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: S*X 

Closed subscheme of Product of projective spaces P^1 x P^2 x P^1 x P^2 x P^2 over Integer Ring defined by: 

-x1*x3 + x0*x4 

 

:: 

 

sage: S = ProductProjectiveSpaces([3, 2], QQ,'x') 

sage: T = AffineSpace(2, QQ, 'y') 

sage: S*T 

Traceback (most recent call last): 

... 

TypeError: Affine Space of dimension 2 over Rational Field must be a projective space, 

product of projective spaces, or subscheme 

""" 

if self is right: 

return self.__pow__(2) 

if isinstance(right, ProductProjectiveSpaces_ring): 

return ProductProjectiveSpaces(self.components() + right.components()) 

elif isinstance(right, ProjectiveSpace_ring): 

return ProductProjectiveSpaces(self.components() + [right]) 

elif isinstance(right, AlgebraicScheme_subscheme): 

AS = self*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()]) 

else: 

raise TypeError('%s must be a projective space, product of projective spaces, or subscheme'%right) 

 

def components(self): 

r""" 

Return the components of this product of projective spaces. 

 

OUTPUT: A list of projective spaces. 

 

EXAMPLES:: 

 

sage: P.<x,y,z,u,v> = ProductProjectiveSpaces(QQ,[2,1]) 

sage: P.components() 

[Projective Space of dimension 2 over Rational Field, 

Projective Space of dimension 1 over Rational Field] 

""" 

return self._components 

 

def dimension_relative(self): 

r""" 

Return the relative dimension of the product of projective spaces. 

 

OUTPUT: A positive integer. 

 

EXAMPLES:: 

 

sage: T.<a,x,y,z,u,v,w> = ProductProjectiveSpaces([3,2],QQ) 

sage: T.dimension_relative() 

5 

""" 

return(sum(self._dims)) 

 

def dimension_absolute(self): 

r""" 

Return the absolute dimension of the product of projective spaces. 

 

OUTPUT: A positive integer. 

 

EXAMPLES:: 

 

sage: T.<x,y,z,u,v,w> = ProductProjectiveSpaces([2, 2], GF(17)) 

sage: T.dimension_absolute() 

4 

sage: T.dimension() 

4 

""" 

base = self.base_scheme() 

if base.is_noetherian(): 

return sum([self[i].dimension_relative() + base.dimension() for i in range(self.num_components())]) 

raise NotImplementedError("cannot compute the dimension of this scheme.") 

 

dimension = dimension_absolute 

 

def dimension_relative_components(self): 

r""" 

Return the relative dimension of the product of projective spaces. 

 

OUTPUT: A list of positive integers. 

 

EXAMPLES:: 

 

sage: T.<a,x,y,z,u,v,w> = ProductProjectiveSpaces([3, 2], QQ) 

sage: T.dimension_relative_components() 

[3, 2] 

""" 

return(self._dims) 

 

def dimension_absolute_components(self): 

r""" 

Return the absolute dimension of the product of projective spaces. 

 

OUTPUT: A list of positive integers. 

 

EXAMPLES:: 

 

sage: T.<x,y,z,u,v,w> = ProductProjectiveSpaces([2, 2], GF(17)) 

sage: T.dimension_absolute_components() 

[2, 2] 

sage: T.dimension_components() 

[2, 2] 

""" 

base = self.base_scheme() 

if base.is_noetherian(): 

return [self[i].dimension_relative() + base.dimension() for i in range(self.num_components())] 

raise NotImplementedError("cannot compute the dimension of this scheme.") 

 

dimension_components = dimension_absolute_components 

 

def num_components(self): 

r""" 

Returns the number of components of this space. 

 

OUTPUT: An integer. 

 

EXAMPLES:: 

 

sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') 

sage: T.num_components() 

3 

""" 

return(len(self._components)) 

 

def ngens(self): 

r""" 

Return the number of generators of this space. 

 

This is the number of variables in the coordinate ring of the 

projective space. 

 

OUTPUT: An integer. 

 

EXAMPLES:: 

 

sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') 

sage: T.ngens() 

6 

""" 

return(sum([P.ngens() for P in self._components])) 

 

def _factors(self, v): 

r""" 

Return the tuple/list ``v`` split into the components of this space. 

 

INPUT: 

 

- ``v`` -- a list or tuple. 

 

OUTPUT: A list of lists. 

 

EXAMPLES:: 

 

sage: T = ProductProjectiveSpaces([1, 1, 1], QQ, 'x') 

sage: T._factors([1, 2, 3, 4, 5, 6]) 

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

""" 

if not isinstance(v, (list, tuple, ETuple)): 

raise TypeError("%s, must be a list or tuple"%v) 

if len(v) != self.ngens(): 

raise ValueError("%s must have %s elements"%(v, self.ngens())) 

index = 0 

splitv = [] 

dims=self._dims 

for i in range(len(dims)): 

splitv.append(v[index:index+dims[i]+1]) 

index += dims[i]+1 

return(splitv) 

 

def _degree(self, polynomial): 

r""" 

Return the homogeneous degrees. 

 

INPUT: 

 

A polynomial in :meth:`coordinate_ring`. 

 

OUTPUT: 

 

A tuple of integers, one for each projective space component. A 

``ValueError`` is raised if the polynomial is not multihomogenous. 

 

EXAMPLES:: 

 

sage: P1xP1.<x,y,s,t> = ProductProjectiveSpaces([1, 1], QQ) 

sage: P1xP1._degree(x^2*t + y^2*s) 

[2, 1] 

sage: P1xP1._degree(x + s) 

Traceback (most recent call last): 

... 

ValueError: polynomial is not multi-homogeneous 

""" 

E = polynomial.exponents() 

if len(E) == 0: 

return [] 

d = [sum(t) for t in self._factors(E[0])] 

for k in range(len(E)): 

if not all([d == [sum(t) for t in self._factors(E[k])]]): 

raise ValueError("polynomial is not multi-homogeneous") 

return d 

 

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

""" 

Construct a point. 

 

For internal use only. See :mod:`morphism` for details. 

 

EXAMPLES:: 

 

sage: P = ProductProjectiveSpaces([1, 1], QQ, 'z') 

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

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

(1 : 1 , 1 : 1) 

""" 

return ProductProjectiveSpaces_point_ring(*args, **kwds) 

 

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

""" 

Construct a morphism. 

 

For internal use only. See :mod:`morphism` for details. 

 

EXAMPLES:: 

 

sage: P.<x,y,z,w> = ProductProjectiveSpaces([1, 1], QQ) 

sage: P._morphism(P.Hom(P), [x, y, z, w]) 

Scheme endomorphism of Product of projective spaces P^1 x P^1 over Rational Field 

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

(x : y , z : w). 

""" 

return ProductProjectiveSpaces_morphism_ring(*args, **kwds) 

 

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

""" 

Construct a point Hom-set. 

 

For internal use only. See :mod:`morphism` for details. 

 

EXAMPLES:: 

 

sage: P.<x,y,z,w> = ProductProjectiveSpaces([1,1], ZZ) 

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

Set of rational points of Product of projective spaces P^1 x P^1 over 

Integer Ring 

""" 

return SchemeHomset_points_product_projective_spaces_ring(*args, **kwds) 

 

def _validate(self, polynomials): 

r""" 

If ``polynomials`` is a tuple of valid polynomial functions on this space, 

return ``polynomials``, otherwise raise a ``TypeError``. 

 

Since this is a product of projective spaces, the polynomials must be multi-homogeneous. 

 

INPUT: 

 

- ``polynomials`` -- tuple of polynomials in the coordinate ring of this projective space. 

 

OUTPUT: 

 

- tuple of polynomials in the coordinate ring of this space. 

 

EXAMPLES:: 

 

sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2, 1], QQ) 

sage: T._validate([x^2*u, y^2*w, z^2*u, w^2, u^2]) 

[x^2*u, y^2*w, z^2*u, w^2, u^2] 

 

:: 

 

sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2, 1], QQ) 

sage: T._validate([x^2+w^2, y^2*w, z^2*u, w^2, u^2]) 

Traceback (most recent call last): 

... 

ValueError: polynomial is not multi-homogeneous 

 

:: 

 

sage: R.<t> = PolynomialRing(GF(5)) 

sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2, 1], QQ) 

sage: T._validate([t, t, t, w^2, u^2]) 

Traceback (most recent call last): 

... 

TypeError: polynomials (=[t, t, t, w^2, u^2]) must be elements of Multivariate 

Polynomial Ring in x, y, z, w, u over Rational Field 

""" 

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

raise TypeError('the argument polynomials=%s must be a list or tuple'%polynomials) 

#check in the coordinate ring 

source_ring = self.coordinate_ring() 

try: 

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

except TypeError: 

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

for f in polynomials: 

self._degree(f) #raises a ValueError if not multi-homogeneous 

return polynomials 

 

def _check_satisfies_equations(self, v): 

""" 

Return True if ``v`` defines a point on the scheme this space; raise a 

TypeError otherwise. 

 

EXAMPLES:: 

 

sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2, 1], QQ) 

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

True 

 

:: 

 

sage: R.<t> = PolynomialRing(GF(7)) 

sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2, 1], R) 

sage: T._check_satisfies_equations([1 + t, 1, 0, 0, 1]) 

True 

 

:: 

 

sage: T.<x,y,z,w,u> = ProductProjectiveSpaces([2, 1], ZZ) 

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

Traceback (most recent call last): 

... 

TypeError: the zero vector is not a point in projective space 

 

:: 

 

sage: T.<x,y,z,w> = ProductProjectiveSpaces([1, 1], ZZ) 

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

Traceback (most recent call last): 

... 

TypeError: the list v=[1, 1, 1, 0, 0] must have 4 components 

 

:: 

 

sage: T.<x,y,z,w> = ProductProjectiveSpaces([1, 1], ZZ) 

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

Traceback (most recent call last): 

... 

TypeError: the components of v=[1, 1/2, 1, 0] must be elements of Integer Ring 

""" 

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

raise TypeError('the argument v=%s must be a list or tuple'%v) 

n = self.ngens() 

if not len(v) == n: 

raise TypeError('the list v=%s must have %s components'%(v, n)) 

R = self.base_ring() 

try: 

n = [R(w) for w in v] 

except TypeError: 

raise TypeError('the components of v=%s must be elements of %s'%(v, R)) 

#check if any of the component points are 0 

N = self._dims 

start = 0 

for i in range(len(N)): 

if v[start:start + N[i]+1] == [R(0)]*(N[i]+1): 

raise TypeError('the zero vector is not a point in projective space') 

start += N[i]+1 

return True 

 

def _an_element_(self): 

r""" 

Returns a (preferably typical) element of this space. 

 

This is used both for illustration and testing purposes. 

 

OUTPUT: 

 

A point in the this projective space. 

 

EXAMPLES:: 

 

sage: ProductProjectiveSpaces([1, 2, 3], ZZ).an_element() 

(7 : 1 , 7 : 6 : 1 , 7 : 6 : 5 : 1) 

sage: ProductProjectiveSpaces([3, 2, 1], PolynomialRing(ZZ, 'y')).an_element() 

(7*y : 6*y : 5*y : 1 , 7*y : 6*y : 1 , 7*y : 1) 

""" 

v = [R.an_element() for R in self._components] 

return self(v) 

 

def subscheme(self, X): 

r""" 

Return the closed subscheme defined by ``X``. 

 

INPUT: 

 

- ``X`` - a list or tuple of equations. 

 

OUTPUT: 

 

:class:`AlgebraicScheme_subscheme_projective_cartesian_product`. 

 

EXAMPLES:: 

 

sage: P.<x,y,z,w> = ProductProjectiveSpaces([1, 1],GF(5)) 

sage: X = P.subscheme([x-y, z-w]);X 

Closed subscheme of Product of projective spaces P^1 x P^1 over Finite Field of size 5 defined by: 

x - y, 

z - w 

sage: X.defining_polynomials () 

[x - y, z - w] 

sage: I = X.defining_ideal(); I 

Ideal (x - y, z - w) of Multivariate Polynomial Ring in x, y, z, w over 

Finite Field of size 5 

sage: X.dimension() 

0 

sage: X.base_ring() 

Finite Field of size 5 

sage: X.base_scheme() 

Spectrum of Finite Field of size 5 

sage: X.structure_morphism() 

Scheme morphism: 

From: Closed subscheme of Product of projective spaces P^1 x P^1 over Finite Field of size 5 defined by: 

x - y, 

z - w 

To: Spectrum of Finite Field of size 5 

Defn: Structure map 

""" 

return AlgebraicScheme_subscheme_product_projective(self, X) 

 

def change_ring(self, R): 

r""" 

Return a product of projective spaces over a ring ``R`` and otherwise the same as this projective space. 

 

INPUT: 

 

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

 

OUTPUT: 

 

- Product of projective spaces over ``R``. 

 

.. NOTE:: 

 

There is no need to have any relation between ``R`` and the base ring 

of this space, if you want to have such a relation, use 

``self.base_extend(R)`` instead. 

 

EXAMPLES:: 

 

sage: T.<x,y,z,u,v,w> = ProductProjectiveSpaces([2, 2], QQ) 

sage: T.change_ring(GF(17)) 

Product of projective spaces P^2 x P^2 over Finite Field of size 17 

""" 

new_components = [P.change_ring(R) for P in self._components] 

return ProductProjectiveSpaces(new_components) 

 

def affine_patch(self, I, return_embedding = False): 

r""" 

Return the `I^{th}` affine patch of this projective space product 

where ``I`` is a multi-index. 

 

INPUT: 

 

- ``I`` -- a list or tuple of positive integers. 

 

- ``return_embedding`` -- Boolean, if true the projective embedding is also returned. 

 

OUTPUT: 

 

- An affine space. 

 

- An embedding into a product of projective spaces (optional). 

 

EXAMPLES:: 

 

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

sage: phi = PP.affine_patch([0, 1, 2], True) 

sage: phi.domain() 

Affine Space of dimension 6 over Integer Ring 

sage: phi 

Scheme morphism: 

From: Affine Space of dimension 6 over Integer Ring 

To: Product of projective spaces P^2 x P^2 x P^2 over Integer Ring 

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

(1 : x0 : x1 , x2 : 1 : x3 , x4 : x5 : 1) 

""" 

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

raise TypeError('the argument I=%s must be a list or tuple of positive integers'%I) 

PP = self.ambient_space() 

N = PP._dims 

if len(I) != len(N): 

raise ValueError('the argument I=%s must have %s entries'%(I,len(N))) 

I = tuple([int(i) for i in I]) # implicit type checking 

for i in range(len(I)): 

if I[i] < 0 or I[i] > N[i]: 

raise ValueError("argument i (= %s) must be between 0 and %s."%(I[i], N[i])) 

try: 

if return_embedding: 

return self.__affine_patches[I][1] 

else: 

return self.__affine_patches[I][0] 

except AttributeError: 

self.__affine_patches = {} 

except KeyError: 

pass 

from sage.schemes.affine.affine_space import AffineSpace 

AA = AffineSpace(PP.base_ring(), sum(N), 'x') 

v = list(AA.gens()) 

index = 0 

for i in range(len(I)): 

v.insert(index+I[i], 1) 

index += N[i]+1 

phi = AA.hom(v, self) 

self.__affine_patches.update({I:(AA, phi)}) 

if return_embedding: 

return phi 

else: 

return AA 

 

@cached_method 

def segre_embedding(self, PP=None, var='u'): 

r""" 

Return the Segre embedding of this space into the appropriate 

projective space. 

 

INPUT: 

 

- ``PP`` -- (default: ``None``) ambient image projective space; 

this is constructed if it is not given. 

 

- ``var`` -- string, variable name of the image projective space, default `u` (optional). 

 

OUTPUT: 

 

Hom -- from this space to the appropriate subscheme of projective space. 

 

.. TODO:: 

 

Cartesian products with more than two components. 

 

EXAMPLES:: 

 

sage: X.<y0,y1,y2,y3,y4,y5> = ProductProjectiveSpaces(ZZ, [2, 2]) 

sage: phi = X.segre_embedding(); phi 

Scheme morphism: 

From: Product of projective spaces P^2 x P^2 over Integer Ring 

To: Closed subscheme of Projective Space of dimension 8 over Integer Ring defined by: 

-u5*u7 + u4*u8, 

-u5*u6 + u3*u8, 

-u4*u6 + u3*u7, 

-u2*u7 + u1*u8, 

-u2*u4 + u1*u5, 

-u2*u6 + u0*u8, 

-u1*u6 + u0*u7, 

-u2*u3 + u0*u5, 

-u1*u3 + u0*u4 

Defn: Defined by sending (y0 : y1 : y2 , y3 : y4 : y5) to 

(y0*y3 : y0*y4 : y0*y5 : y1*y3 : y1*y4 : y1*y5 : y2*y3 : y2*y4 : y2*y5). 

 

:: 

 

sage: T = ProductProjectiveSpaces([1, 2], CC, 'z') 

sage: T.segre_embedding() 

Scheme morphism: 

From: Product of projective spaces P^1 x P^2 over Complex Field with 53 bits of precision 

To: Closed subscheme of Projective Space of dimension 5 over Complex Field with 53 bits of precision defined by: 

-u2*u4 + u1*u5, 

-u2*u3 + u0*u5, 

-u1*u3 + u0*u4 

Defn: Defined by sending (z0 : z1 , z2 : z3 : z4) to 

(z0*z2 : z0*z3 : z0*z4 : z1*z2 : z1*z3 : z1*z4). 

 

:: 

 

sage: T = ProductProjectiveSpaces([1, 2, 1], QQ, 'z') 

sage: T.segre_embedding() 

Scheme morphism: 

From: Product of projective spaces P^1 x P^2 x P^1 over Rational Field 

To: Closed subscheme of Projective Space of dimension 11 over 

Rational Field defined by: 

-u9*u10 + u8*u11, 

-u7*u10 + u6*u11, 

-u7*u8 + u6*u9, 

-u5*u10 + u4*u11, 

-u5*u8 + u4*u9, 

-u5*u6 + u4*u7, 

-u5*u9 + u3*u11, 

-u5*u8 + u3*u10, 

-u5*u8 + u2*u11, 

-u4*u8 + u2*u10, 

-u3*u8 + u2*u9, 

-u3*u6 + u2*u7, 

-u3*u4 + u2*u5, 

-u5*u7 + u1*u11, 

-u5*u6 + u1*u10, 

-u3*u7 + u1*u9, 

-u3*u6 + u1*u8, 

-u5*u6 + u0*u11, 

-u4*u6 + u0*u10, 

-u3*u6 + u0*u9, 

-u2*u6 + u0*u8, 

-u1*u6 + u0*u7, 

-u1*u4 + u0*u5, 

-u1*u2 + u0*u3 

Defn: Defined by sending (z0 : z1 , z2 : z3 : z4 , z5 : z6) to 

(z0*z2*z5 : z0*z2*z6 : z0*z3*z5 : z0*z3*z6 : z0*z4*z5 : z0*z4*z6 

: z1*z2*z5 : z1*z2*z6 : z1*z3*z5 : z1*z3*z6 : z1*z4*z5 : z1*z4*z6). 

""" 

N = self._dims 

M = prod([n+1 for n in N]) - 1 

CR = self.coordinate_ring() 

 

vars = list(self.coordinate_ring().variable_names()) + [var + str(i) for i in range(M+1)] 

R = PolynomialRing(self.base_ring(), self.ngens()+M+1, vars, order='lex') 

 

#set-up the elimination for the segre embedding 

mapping = [] 

k = self.ngens() 

index = self.num_components()*[0] 

for count in range(M + 1): 

mapping.append(R.gen(k+count)-prod([CR(self[i].gen(index[i])) for i in range(len(index))])) 

for i in range(len(index)-1, -1, -1): 

if index[i] == N[i]: 

index[i] = 0 

else: 

index[i] += 1 

break #only increment once 

 

#change the defining ideal of the subscheme into the variables 

I = R.ideal(list(self.defining_polynomials()) + mapping) 

J = I.groebner_basis() 

s = set(R.gens()[:self.ngens()]) 

n = len(J)-1 

L = [] 

while s.isdisjoint(J[n].variables()): 

L.append(J[n]) 

n = n-1 

 

#create new subscheme 

if PP is None: 

PS = ProjectiveSpace(self.base_ring(), M, R.variable_names()[self.ngens():]) 

Y = PS.subscheme(L) 

else: 

if PP.dimension_relative() != M: 

raise ValueError("projective Space %s must be dimension %s")%(PP, M) 

S = PP.coordinate_ring() 

psi = R.hom([0]*k + list(S.gens()), S) 

L = [psi(l) for l in L] 

Y = PP.subscheme(L) 

 

#create embedding for points 

mapping = [] 

index = self.num_components()*[0] 

for count in range(M + 1): 

mapping.append(prod([CR(self[i].gen(index[i])) for i in range(len(index))])) 

for i in range(len(index)-1, -1, -1): 

if index[i] == N[i]: 

index[i] = 0 

else: 

index[i] += 1 

break #only increment once 

phi = self.hom(mapping, Y) 

 

return phi 

 

class ProductProjectiveSpaces_field(ProductProjectiveSpaces_ring): 

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

""" 

Construct a point. 

 

For internal use only. See :mod:`morphism` for details. 

 

EXAMPLES:: 

 

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

sage: P = ProductProjectiveSpaces([1, 2], NumberField(u^2 - 2, 'v'), 'x') 

sage: P([1, 3, u, 1, 1]) 

(1/3 : 1 , v : 1 : 1) 

""" 

return ProductProjectiveSpaces_point_field(*args, **kwds) 

 

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

""" 

Construct a point Hom-set. 

 

For internal use only. See :mod:`morphism` for details. 

 

EXAMPLES:: 

 

sage: P.<x,y,z,w> = ProductProjectiveSpaces([1, 1], GF(5)) 

sage: P._point_homset(Spec(GF(5)), P) 

Set of rational points of Product of projective spaces P^1 x P^1 

over Finite Field of size 5 

""" 

return SchemeHomset_points_product_projective_spaces_field(*args, **kwds) 

 

def points_of_bounded_height(self,bound, prec=53): 

r""" 

Returns an iterator of the points in this product of projective spaces with the absolute heights of the 

components of at most the given bound. 

 

Bound check is strict for the rational field. Requires the base field of this space to be a number field. 

Uses the Doyle-Krumm algorithm for computing algebraic numbers up to a given height [Doyle-Krumm]_. 

 

INPUT: 

 

- ``bound`` - a real number 

 

- ``prec`` - the precision to use to compute the elements of bounded height for number fields 

 

OUTPUT: 

 

- an iterator of points in this space 

 

.. WARNING:: 

 

In the current implementation, the output of the [Doyle-Krumm]_ algorithm 

cannot be guaranteed to be correct due to the necessity of floating point 

computations. In some cases, the default 53-bit precision is 

considerably lower than would be required for the algorithm to 

generate correct output. 

 

EXAMPLES:: 

 

sage: PP = ProductProjectiveSpaces(QQ, [1, 2]) 

sage: list(PP.points_of_bounded_height(2)) 

[(0 : 1 , 0 : 0 : 1), (0 : 1 , 1 : 0 : 1), (0 : 1 , -1 : 0 : 1), (0 : 1 , 0 : 1 : 1), 

(0 : 1 , 1 : 1 : 1), (0 : 1 , -1 : 1 : 1), (0 : 1 , 0 : -1 : 1), (0 : 1 , 1 : -1 : 1), 

(0 : 1 , -1 : -1 : 1), (0 : 1 , 0 : 1 : 0), (0 : 1 , 1 : 1 : 0), (0 : 1 , -1 : 1 : 0), 

(0 : 1 , 1 : 0 : 0), (1 : 1 , 0 : 0 : 1), (1 : 1 , 1 : 0 : 1), (1 : 1 , -1 : 0 : 1), 

(1 : 1 , 0 : 1 : 1), (1 : 1 , 1 : 1 : 1), (1 : 1 , -1 : 1 : 1), (1 : 1 , 0 : -1 : 1), 

(1 : 1 , 1 : -1 : 1), (1 : 1 , -1 : -1 : 1), (1 : 1 , 0 : 1 : 0), (1 : 1 , 1 : 1 : 0), 

(1 : 1 , -1 : 1 : 0), (1 : 1 , 1 : 0 : 0), (-1 : 1 , 0 : 0 : 1), (-1 : 1 , 1 : 0 : 1), 

(-1 : 1 , -1 : 0 : 1), (-1 : 1 , 0 : 1 : 1), (-1 : 1 , 1 : 1 : 1), (-1 : 1 , -1 : 1 : 1), 

(-1 : 1 , 0 : -1 : 1), (-1 : 1 , 1 : -1 : 1), (-1 : 1 , -1 : -1 : 1), (-1 : 1 , 0 : 1 : 0), 

(-1 : 1 , 1 : 1 : 0), (-1 : 1 , -1 : 1 : 0), (-1 : 1 , 1 : 0 : 0), (1 : 0 , 0 : 0 : 1), 

(1 : 0 , 1 : 0 : 1), (1 : 0 , -1 : 0 : 1), (1 : 0 , 0 : 1 : 1), (1 : 0 , 1 : 1 : 1), 

(1 : 0 , -1 : 1 : 1), (1 : 0 , 0 : -1 : 1), (1 : 0 , 1 : -1 : 1), (1 : 0 , -1 : -1 : 1), 

(1 : 0 , 0 : 1 : 0), (1 : 0 , 1 : 1 : 0), (1 : 0 , -1 : 1 : 0), (1 : 0 , 1 : 0 : 0)] 

 

:: 

 

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

sage: P = ProductProjectiveSpaces([1, 1], NumberField(u^2 - 2, 'v')) 

sage: list(P.points_of_bounded_height(1.5)) 

[(0 : 1 , 0 : 1), (0 : 1 , -1 : 1), (0 : 1 , 1 : 1), (0 : 1 , -1/2*v : 1), (0 : 1 , -v : 1), 

(0 : 1 , 1/2*v : 1), (0 : 1 , v : 1), (0 : 1 , 1 : 0), (-1 : 1 , 0 : 1), (-1 : 1 , -1 : 1), 

(-1 : 1 , 1 : 1), (-1 : 1 , -1/2*v : 1), (-1 : 1 , -v : 1), (-1 : 1 , 1/2*v : 1), (-1 : 1 , v : 1), 

(-1 : 1 , 1 : 0), (1 : 1 , 0 : 1), (1 : 1 , -1 : 1), (1 : 1 , 1 : 1), (1 : 1 , -1/2*v : 1), 

(1 : 1 , -v : 1), (1 : 1 , 1/2*v : 1), (1 : 1 , v : 1), (1 : 1 , 1 : 0), (-1/2*v : 1 , 0 : 1), 

(-1/2*v : 1 , -1 : 1), (-1/2*v : 1 , 1 : 1), (-1/2*v : 1 , -1/2*v : 1), (-1/2*v : 1 , -v : 1), 

(-1/2*v : 1 , 1/2*v : 1), (-1/2*v : 1 , v : 1), (-1/2*v : 1 , 1 : 0), (-v : 1 , 0 : 1), 

(-v : 1 , -1 : 1), (-v : 1 , 1 : 1), (-v : 1 , -1/2*v : 1), (-v : 1 , -v : 1), (-v : 1 , 1/2*v : 1), 

(-v : 1 , v : 1), (-v : 1 , 1 : 0), (1/2*v : 1 , 0 : 1), (1/2*v : 1 , -1 : 1), (1/2*v : 1 , 1 : 1), 

(1/2*v : 1 , -1/2*v : 1), (1/2*v : 1 , -v : 1), (1/2*v : 1 , 1/2*v : 1), (1/2*v : 1 , v : 1), 

(1/2*v : 1 , 1 : 0), (v : 1 , 0 : 1), (v : 1 , -1 : 1), (v : 1 , 1 : 1), (v : 1 , -1/2*v : 1), 

(v : 1 , -v : 1), (v : 1 , 1/2*v : 1), (v : 1 , v : 1), (v : 1 , 1 : 0), (1 : 0 , 0 : 1), 

(1 : 0 , -1 : 1), (1 : 0 , 1 : 1), (1 : 0 , -1/2*v : 1), (1 : 0 , -v : 1), (1 : 0 , 1/2*v : 1), 

(1 : 0 , v : 1), (1 : 0 , 1 : 0)] 

""" 

m = self.num_components() 

comp_points = [list(self._components[i].points_of_bounded_height(bound, prec)) for i in range(m)] 

indices = xmrange([len(comp_points[i]) for i in range(m)]) 

return iter([self([comp_points[t][I[t]] for t in range(m)]) for I in indices]) 

 

class ProductProjectiveSpaces_finite_field(ProductProjectiveSpaces_field): 

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

r""" 

Construct a point. 

 

For internal use only. See :mod:`morphism` for details. 

 

EXAMPLES:: 

 

sage: P = ProductProjectiveSpaces([1, 2], GF(11)) 

sage: P([3, 7, 4, 5, 9]) 

(2 : 1 , 9 : 3 : 1) 

""" 

return ProductProjectiveSpaces_point_finite_field(*args, **kwds) 

 

def __iter__(self): 

r""" 

Returns iterator over the elements of this product of projective spaces. 

 

EXAMPLES:: 

 

sage: P = ProductProjectiveSpaces([2, 1], GF(3)) 

sage: [x for x in P] 

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

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

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

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

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

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

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

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

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

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

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

""" 

iters = [iter(T) for T in self._components] 

L=[] 

for x in iters: 

L.append(next(x)) # put at zero 

yield(self(L)) 

j = 0 

while j < self.num_components(): 

try: 

L[j] = next(iters[j]) 

yield(self(L)) 

j = 0 

except StopIteration: 

iters[j] = iter(self[j]) # reset 

L[j] = next(iters[j]) # put at zero 

j += 1 

 

def rational_points(self, F=None): 

r""" 

Return the list of `F`-rational points on this product of projective spaces, 

where `F` is a given finite field, or the base ring of this space. 

 

EXAMPLES:: 

 

sage: P = ProductProjectiveSpaces([1, 1], GF(5)) 

sage: P.rational_points() 

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

(0 : 1 , 1 : 1), (1 : 1 , 1 : 1), (2 : 1 , 1 : 1), (3 : 1 , 1 : 1), (4 : 1 , 1 : 1), (1 : 0 , 1 : 1), 

(0 : 1 , 2 : 1), (1 : 1 , 2 : 1), (2 : 1 , 2 : 1), (3 : 1 , 2 : 1), (4 : 1 , 2 : 1), (1 : 0 , 2 : 1), 

(0 : 1 , 3 : 1), (1 : 1 , 3 : 1), (2 : 1 , 3 : 1), (3 : 1 , 3 : 1), (4 : 1 , 3 : 1), (1 : 0 , 3 : 1), 

(0 : 1 , 4 : 1), (1 : 1 , 4 : 1), (2 : 1 , 4 : 1), (3 : 1 , 4 : 1), (4 : 1 , 4 : 1), (1 : 0 , 4 : 1), 

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

 

:: 

 

sage: P = ProductProjectiveSpaces([1, 1], GF(2)) 

sage: P.rational_points(GF(2^2,'a')) 

[(0 : 1 , 0 : 1), (a : 1 , 0 : 1), (a + 1 : 1 , 0 : 1), (1 : 1 , 0 : 1), (1 : 0 , 0 : 1), (0 : 1 , a : 1), 

(a : 1 , a : 1), (a + 1 : 1 , a : 1), (1 : 1 , a : 1), (1 : 0 , a : 1), (0 : 1 , a + 1 : 1), (a : 1 , a + 1 : 1), 

(a + 1 : 1 , a + 1 : 1), (1 : 1 , a + 1 : 1), (1 : 0 , a + 1 : 1), (0 : 1 , 1 : 1), (a : 1 , 1 : 1), 

(a + 1 : 1 , 1 : 1), (1 : 1 , 1 : 1), (1 : 0 , 1 : 1), (0 : 1 , 1 : 0), (a : 1 , 1 : 0), (a + 1 : 1 , 1 : 0), 

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

""" 

if F is None: 

return list(self) 

elif not is_FiniteField(F): 

raise TypeError("second argument (= %s) must be a finite field"%F) 

return list(self.base_extend(F))