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

r""" 

Subschemes of toric space 

 

AUTHORS: 

 

- David Kohel (2005): initial version. 

- William Stein (2005): initial version. 

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

""" 

 

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

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

# 

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

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

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

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

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

 

from sage.calculus.functions import jacobian 

from sage.rings.all import ZZ 

from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme 

 

class AlgebraicScheme_subscheme_toric(AlgebraicScheme_subscheme): 

r""" 

Construct an algebraic subscheme of a toric variety. 

 

.. WARNING:: 

 

You should not create objects of this class directly. The 

preferred method to construct such subschemes is to use 

:meth:`~ToricVariety_field.subscheme` method of :class:`toric 

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

 

INPUT: 

 

- ``toric_variety`` -- ambient :class:`toric variety 

<ToricVariety_field>`. 

 

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

polynomials in the coordinate ring of ``toric_variety``. 

 

OUTPUT: 

 

- :class:`algebraic subscheme of a toric variety 

<AlgebraicScheme_subscheme_toric>`. 

 

TESTS:: 

 

sage: P1xP1 = toric_varieties.P1xP1() 

sage: P1xP1.inject_variables() 

Defining s, t, x, y 

sage: import sage.schemes.toric.toric_subscheme as SCM 

sage: X = SCM.AlgebraicScheme_subscheme_toric( 

....: P1xP1, [x*s + y*t, x^3+y^3]) 

sage: X 

Closed subscheme of 2-d CPR-Fano toric variety 

covered by 4 affine patches defined by: 

s*x + t*y, 

x^3 + y^3 

 

A better way to construct the same scheme as above:: 

 

sage: P1xP1.subscheme([x*s + y*t, x^3+y^3]) 

Closed subscheme of 2-d CPR-Fano toric variety 

covered by 4 affine patches defined by: 

s*x + t*y, 

x^3 + y^3 

""" 

 

# Implementation note: if the toric variety is affine you should 

# construct instances of the derived class 

# AlgebraicScheme_subscheme_affine_toric instead. 

 

def __init__(self, toric_variety, polynomials): 

r""" 

See :class:`AlgebraicScheme_subscheme_toric` for documentation. 

 

TESTS:: 

 

sage: P1xP1 = toric_varieties.P1xP1() 

sage: P1xP1.inject_variables() 

Defining s, t, x, y 

sage: import sage.schemes.toric.toric_subscheme as SCM 

sage: X = SCM.AlgebraicScheme_subscheme_toric( 

....: P1xP1, [x*s + y*t, x^3+y^3]) 

sage: X 

Closed subscheme of 2-d CPR-Fano toric variety 

covered by 4 affine patches defined by: 

s*x + t*y, 

x^3 + y^3 

""" 

# Just to make sure that keyword arguments will be passed correctly 

super(AlgebraicScheme_subscheme_toric, self).__init__(toric_variety, 

polynomials) 

 

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

r""" 

Construct a morphism determined by action on points of ``self``. 

 

INPUT: 

 

- same as for 

:class:`~sage.schemes.toric.morphism.SchemeMorphism_polynomial_toric_variety`. 

 

OUTPUT: 

 

- :class:`~sage.schemes.toric.morphism.SchemeMorphism_polynomial_toric_variety`. 

 

TESTS:: 

 

sage: P1xP1 = toric_varieties.P1xP1() 

sage: P1xP1.inject_variables() 

Defining s, t, x, y 

sage: P1 = P1xP1.subscheme(s - t) 

sage: H = P1.Hom(P1xP1) 

sage: H([s, s, x, y]) 

Scheme morphism: 

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

covered by 4 affine patches defined by: 

s - t 

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

Defn: Defined on coordinates by sending [s : t : x : y] to 

[s : s : x : y] 

 

sage: sbar, tbar, xbar, ybar = P1.coordinate_ring().gens() 

sage: P1._morphism(H, [sbar, sbar, xbar, ybar]) 

Scheme morphism: 

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

covered by 4 affine patches defined by: 

s - t 

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

Defn: Defined on coordinates by sending [s : t : x : y] to 

[t : t : x : y] 

""" 

from sage.schemes.toric.morphism import SchemeMorphism_polynomial_toric_variety 

return SchemeMorphism_polynomial_toric_variety(*args, **kwds) 

 

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

r""" 

Construct a Hom-set for ``self``. 

 

INPUT: 

 

- same as for 

:class:`~sage.schemes.toric.homset.SchemeHomset_points_toric_field`. 

 

OUTPUT: 

 

:class:`~sage.schemes.toric.homset.SchemeHomset_points_subscheme_toric_field`. 

 

TESTS:: 

 

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

sage: quadric = P2.subscheme([x^2 + y^2 + z^2]) 

sage: quadric._point_homset(Spec(QQ), quadric) 

Set of rational points of Closed subscheme of 2-d CPR-Fano 

toric variety covered by 3 affine patches defined by: 

x^2 + y^2 + z^2 

sage: type(quadric.point_set()) 

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

""" 

from sage.schemes.toric.homset import SchemeHomset_points_subscheme_toric_field 

return SchemeHomset_points_subscheme_toric_field(*args, **kwds) 

 

def fan(self): 

""" 

Return the fan of the ambient space. 

 

OUTPUT: 

 

A fan. 

 

EXAMPLES:: 

 

sage: P2.<x,y,z> = toric_varieties.P(2) 

sage: E = P2.subscheme([x^2+y^2+z^2]) 

sage: E.fan() 

Rational polyhedral fan in 2-d lattice N 

""" 

return self.ambient_space().fan() 

 

def affine_patch(self, i): 

r""" 

Return the ``i``-th affine patch of ``self`` as an affine 

toric algebraic scheme. 

 

INPUT: 

 

- ``i`` -- integer, index of a generating cone of the fan of the 

ambient space of ``self``. 

 

OUTPUT: 

 

- subscheme of an affine :class:`toric variety 

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

corresponding to the pull-back of ``self`` by the embedding 

morphism of the ``i``-th :meth:`affine patch of the ambient 

space 

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

of ``self``. 

 

The result is cached, so the ``i``-th patch is always the same object 

in memory. 

 

EXAMPLES:: 

 

sage: P1xP1 = toric_varieties.P1xP1() 

sage: patch1 = P1xP1.affine_patch(1) 

sage: patch1.embedding_morphism() 

Scheme morphism: 

From: 2-d affine toric variety 

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

Defn: Defined on coordinates by sending [t : x] to 

[1 : t : x : 1] 

sage: P1xP1.inject_variables() 

Defining s, t, x, y 

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

sage: subpatch = P1.affine_patch(1) 

sage: subpatch 

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

x - 1 

""" 

i = int(i) # implicit type checking 

try: 

return self._affine_patches[i] 

except AttributeError: 

self._affine_patches = dict() 

except KeyError: 

pass 

ambient_patch = self.ambient_space().affine_patch(i) 

phi_p = ambient_patch.embedding_morphism().defining_polynomials() 

patch = ambient_patch.subscheme( 

[p(phi_p) for p in self.defining_polynomials()]) 

patch._embedding_morphism = patch.hom(phi_p, self, check=False) 

self._affine_patches[i] = patch 

return patch 

 

def affine_algebraic_patch(self, cone=None, names=None): 

r""" 

Return the affine patch corresponding to ``cone`` as an affine 

algebraic scheme. 

 

INPUT: 

 

- ``cone`` -- a :class:`Cone 

<sage.geometry.cone.ConvexRationalPolyhedralCone>` `\sigma` 

of the fan. It can be omitted for an affine toric variety, 

in which case the single generating cone is used. 

 

OUTPUT: 

 

An :class:`affine algebraic subscheme 

<sage.schemes.affine.affine_subscheme.AlgebraicScheme_subscheme_affine>` 

corresponding to the patch `\mathop{Spec}(\sigma^\vee \cap M)` 

associated to the cone `\sigma`. 

 

See also :meth:`affine_patch`, which expresses the patches as 

subvarieties of affine toric varieties instead. 

 

REFERENCES: 

 

.. 

 

David A. Cox, "The Homogeneous Coordinate Ring of a Toric 

Variety", Lemma 2.2. 

:arxiv:`alg-geom/9210008v2` 

 

EXAMPLES:: 

 

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

sage: cone = P2.fan().generating_cone(0) 

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

sage: V.affine_algebraic_patch(cone) 

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

z0^3 + z1^3 + 1 

 

sage: cone = Cone([(0,1),(2,1)]) 

sage: A2Z2.<x,y> = AffineToricVariety(cone) 

sage: A2Z2.affine_algebraic_patch() 

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

-z0*z1 + z2^2 

sage: V = A2Z2.subscheme(x^2+y^2-1) 

sage: patch = V.affine_algebraic_patch(); patch 

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

-z0*z1 + z2^2, 

z0 + z1 - 1 

sage: nbhd_patch = V.neighborhood([1,0]).affine_algebraic_patch(); nbhd_patch 

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

-z0*z1 + z2^2, 

z0 + z1 - 1 

sage: nbhd_patch.embedding_center() 

(0, 1, 0) 

 

Here we got two defining equations. The first one describes 

the singularity of the ambient space and the second is the 

pull-back of `x^2+y^2-1` :: 

 

sage: lp = LatticePolytope([(1,0,0),(1,1,0),(1,1,1),(1,0,1),(-2,-1,-1)], 

....: lattice=ToricLattice(3)) 

sage: X.<x,y,u,v,t> = CPRFanoToricVariety(Delta_polar=lp) 

sage: Y = X.subscheme(x*v+y*u+t) 

sage: cone = Cone([(1,0,0),(1,1,0),(1,1,1),(1,0,1)]) 

sage: Y.affine_algebraic_patch(cone) 

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

z0*z2 - z1*z3, 

z1 + z3 + 1 

""" 

from sage.modules.all import vector 

from sage.misc.all import prod 

ambient = self.ambient_space() 

fan = ambient.fan() 

if cone is None: 

assert ambient.is_affine() 

cone = fan.generating_cone(0) 

else: 

cone = fan.embed(cone) 

# R/I = C[sigma^dual cap M] 

R, I, dualcone = ambient._semigroup_ring(cone, names) 

 

# inhomogenize the Cox homogeneous polynomial with respect to the given cone 

inhomogenize = dict( (ambient.coordinate_ring().gen(i), 1) 

for i in range(0,fan.nrays()) 

if not i in cone.ambient_ray_indices() ) 

polynomials = [ p.subs(inhomogenize) for p in self.defining_polynomials() ] 

 

# map the monomial x^{D_m} to m, see reference. 

n_rho_matrix = cone.rays().matrix() 

def pullback_polynomial(p): 

result = R.zero() 

for coefficient, monomial in p: 

exponent = monomial.exponents()[0] 

exponent = [ exponent[i] for i in cone.ambient_ray_indices() ] 

exponent = vector(ZZ,exponent) 

m = n_rho_matrix.solve_right(exponent) 

assert all(x in ZZ for x in m), \ 

'The polynomial '+str(p)+' does not define a ZZ-divisor!' 

m_coeffs = dualcone.Hilbert_coefficients(m) 

result += coefficient * prod(R.gen(i)**m_coeffs[i] 

for i in range(0,R.ngens())) 

return result 

 

# construct the affine algebraic scheme to use as patch 

polynomials = [pullback_polynomial(_) for _ in polynomials] 

from sage.schemes.affine.affine_space import AffineSpace 

patch_cover = AffineSpace(R) 

polynomials = list(I.gens()) + polynomials 

polynomials = [x for x in polynomials if not x.is_zero()] 

patch = patch_cover.subscheme(polynomials) 

 

# TODO: If the cone is not smooth, then the coordinate_ring() 

# of the affine toric variety is wrong; it should be the 

# G-invariant part. So we can't construct the embedding 

# morphism in that case. 

if cone.is_smooth(): 

x = ambient.coordinate_ring().gens() 

phi = [] 

for i in range(0,fan.nrays()): 

if i in cone.ambient_ray_indices(): 

phi.append(pullback_polynomial(x[i])) 

else: 

phi.append(1) 

patch._embedding_morphism = patch.hom(phi, self) 

else: 

patch._embedding_morphism = (NotImplementedError, 

'I only know how to construct embedding morphisms for smooth patches') 

 

try: 

point = self.embedding_center() 

except AttributeError: 

return patch 

 

# it remains to find the preimage of point 

# map m to the monomial x^{D_m}, see reference. 

F = ambient.coordinate_ring().fraction_field() 

image = [] 

for m in dualcone.Hilbert_basis(): 

x_Dm = prod([ F.gen(i)**(m*n) for i,n in enumerate(fan.rays()) ]) 

image.append(x_Dm) 

patch._embedding_center = tuple( f(list(point)) for f in image ) 

return patch 

 

def _best_affine_patch(self, point): 

r""" 

Return the best affine patch of the ambient toric variety. 

 

INPUT: 

 

- ``point`` -- a point of the algebraic subscheme. 

 

OUTPUT: 

 

Integer. The index of the patch. See :meth:`affine_patch`. 

 

EXAMPLES:: 

 

sage: P.<x,y,z>= toric_varieties.P2() 

sage: S = P.subscheme(x+2*y+3*z) 

sage: S._best_affine_patch(P.point([2,-3,0])) 

1 

sage: S._best_affine_patch([2,-3,0]) 

1 

""" 

# TODO: this method should pick a "best" patch in the sense 

# that it is numerically stable to dehomogenize, see the 

# corresponding method for projective varieties. 

point = list(point) 

zeros = set(i for i, coord in enumerate(point) if coord == 0) 

for cone_idx, cone in enumerate(self.ambient_space().fan().generating_cones()): 

if zeros.issubset(cone.ambient_ray_indices()): 

return cone_idx 

assert False, 'The point must not have been a point of the toric variety.' 

 

def neighborhood(self, point): 

r""" 

Return an toric algebraic scheme isomorphic to neighborhood of 

the ``point``. 

 

INPUT: 

 

- ``point`` -- a point of the toric algebraic scheme. 

 

OUTPUT: 

 

An affine toric algebraic scheme (polynomial equations in an 

affine toric variety) with fixed 

:meth:`~AlgebraicScheme.embedding_morphism` and 

:meth:`~AlgebraicScheme.embedding_center`. 

 

EXAMPLES:: 

 

sage: P.<x,y,z>= toric_varieties.P2() 

sage: S = P.subscheme(x+2*y+3*z) 

sage: s = S.point([0,-3,2]); s 

[0 : -3 : 2] 

sage: patch = S.neighborhood(s); patch 

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

x + 2*y + 6 

sage: patch.embedding_morphism() 

Scheme morphism: 

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

x + 2*y + 6 

To: Closed subscheme of 2-d CPR-Fano toric variety covered by 3 affine patches defined by: 

x + 2*y + 3*z 

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

[-2*y - 6 : y : 2] 

sage: patch.embedding_center() 

[0 : -3] 

sage: patch.embedding_morphism()(patch.embedding_center()) 

[0 : -3 : 2] 

 

A more complicated example:: 

 

sage: dP6.<x0,x1,x2,x3,x4,x5> = toric_varieties.dP6() 

sage: twoP1 = dP6.subscheme(x0*x3) 

sage: patch = twoP1.neighborhood([0,1,2, 3,4,5]); patch 

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

3*x0 

sage: patch.embedding_morphism() 

Scheme morphism: 

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

3*x0 

To: Closed subscheme of 2-d CPR-Fano toric variety covered by 6 affine patches defined by: 

x0*x3 

Defn: Defined on coordinates by sending [x0 : x1] to 

[0 : x1 : 2 : 3 : 4 : 5] 

sage: patch.embedding_center() 

[0 : 1] 

sage: patch.embedding_morphism()(patch.embedding_center()) 

[0 : 1 : 2 : 3 : 4 : 5] 

""" 

point = list(point) 

self._check_satisfies_equations(point) 

PP = self.ambient_space() 

n = PP.dimension() 

fan = PP.fan() 

cone_idx = self._best_affine_patch(point) 

cone = fan.generating_cone(cone_idx) 

 

patch_cover = PP.affine_patch(cone_idx) 

R = patch_cover.coordinate_ring() 

phi = [] 

point_preimage = [] 

for i in range(0,fan.nrays()): 

try: 

ray_index = cone.ambient_ray_indices().index(i) 

phi.append(R.gen(ray_index)) 

point_preimage.append(point[i]) 

except ValueError: 

phi.append(point[i]) 

pullback_polys = [f(phi) for f in self.defining_polynomials()] 

patch = patch_cover.subscheme(pullback_polys) 

S = patch.coordinate_ring() 

phi_reduced = [S(t) for t in phi] 

 

patch._embedding_center = patch(point_preimage) 

patch._embedding_morphism = patch.hom(phi_reduced,self) 

return patch 

 

def dimension(self): 

""" 

Return the dimension of ``self``. 

 

OUTPUT: 

 

Integer. If ``self`` is empty, `-1` is returned. 

 

EXAMPLES:: 

 

sage: P1xP1 = toric_varieties.P1xP1() 

sage: P1xP1.inject_variables() 

Defining s, t, x, y 

sage: P1 = P1xP1.subscheme(s-t) 

sage: P1.dimension() 

1 

sage: P1xP1.subscheme([s-t, (s-t)^2]).dimension() 

1 

sage: P1xP1.subscheme([s, t]).dimension() 

-1 

""" 

if '_dimension' in self.__dict__: 

return self._dimension 

npatches = self.ambient_space().fan().ngenerating_cones() 

dims = [ self.affine_patch(i).dimension() for i in range(0,npatches) ] 

self._dimension = max(dims) 

return self._dimension 

 

def is_smooth(self, point=None): 

r""" 

Test whether the algebraic subscheme is smooth. 

 

INPUT: 

 

- ``point`` -- A point or ``None`` (default). The point to 

test smoothness at. 

 

OUTPUT: 

 

Boolean. If no point was specified, returns whether the 

algebraic subscheme is smooth everywhere. Otherwise, 

smoothness at the specified point is tested. 

 

EXAMPLES:: 

 

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

sage: cuspidal_curve = P2.subscheme([y^2*z-x^3]) 

sage: cuspidal_curve 

Closed subscheme of 2-d CPR-Fano toric variety covered by 3 affine patches defined by: 

-x^3 + y^2*z 

sage: cuspidal_curve.is_smooth([1,1,1]) 

True 

sage: cuspidal_curve.is_smooth([0,0,1]) 

False 

sage: cuspidal_curve.is_smooth() 

False 

 

Any sufficiently generic cubic hypersurface is smooth:: 

 

sage: P2.subscheme([y^2*z-x^3+z^3+1/10*x*y*z]).is_smooth() 

True 

 

A more complicated example:: 

 

sage: dP6.<x0,x1,x2,x3,x4,x5> = toric_varieties.dP6() 

sage: disjointP1s = dP6.subscheme(x0*x3) 

sage: disjointP1s.is_smooth() 

True 

sage: intersectingP1s = dP6.subscheme(x0*x1) 

sage: intersectingP1s.is_smooth() 

False 

 

A smooth hypersurface in a compact singular toric variety:: 

 

sage: lp = LatticePolytope([(1,0,0),(1,1,0),(1,1,1),(1,0,1),(-2,-1,-1)], 

....: lattice=ToricLattice(3)) 

sage: X.<x,y,u,v,t> = CPRFanoToricVariety(Delta_polar=lp) 

sage: Y = X.subscheme(x*v+y*u+t) 

sage: cone = Cone([(1,0,0),(1,1,0),(1,1,1),(1,0,1)]) 

sage: Y.is_smooth() 

True 

""" 

if not point is None: 

toric_patch = self.neighborhood(point) 

return toric_patch.is_smooth(toric_patch.embedding_center()) 

 

# testing smoothness everywhere tends to be expensive 

if '_smooth' in self.__dict__: 

return self._smooth 

npatches = self.ambient_space().fan().ngenerating_cones() 

self._smooth = all(self.affine_patch(i).is_smooth() for i in range(0,npatches)) 

return self._smooth 

 

def is_nondegenerate(self): 

r""" 

Check if ``self`` is nondegenerate. 

 

OUTPUT: 

 

Whether the variety is nondegenerate, that is, the intersection 

with every open torus orbit is smooth and transversal. 

 

EXAMPLES:: 

 

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

sage: P2.subscheme([x^3 + y^3 + z^3]).is_nondegenerate() 

True 

sage: P2.subscheme([x*y*z]).is_nondegenerate() 

False 

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

sage: X.is_smooth() 

True 

sage: X.is_nondegenerate() 

False 

 

A K3 surface in `\mathbf{P}^1 \times \mathbf{P}^1 \times \mathbf{P}^1`:: 

 

sage: diamond = lattice_polytope.cross_polytope(3) 

sage: fan = FaceFan(diamond) 

sage: P1xP1xP1 = ToricVariety(fan) 

sage: z0, z1, z2, z3, z4, z5 = P1xP1xP1.gens() 

sage: t = 5; 

sage: F = z0^2*z1^2*z2^2 + z1^2*z2^2*z3^2 + z0^2*z2^2*z4^2\ 

....: + z2^2*z3^2*z4^2 + t*z0*z1*z2*z3*z4*z5 + z0^2*z1^2*z5^2\ 

....: + z1^2*z3^2*z5^2 + z0^2*z4^2*z5^2 + z3^2*z4^2*z5^2 

sage: X = P1xP1xP1.subscheme([F]) 

sage: X.is_smooth() 

True 

sage: X.is_nondegenerate() 

False 

 

Taking a random change of variables breaks the symmetry, but 

makes the surface nondegenerate:: 

 

sage: F1 = F.subs(z0 = 1*z0 + 1*z3, z3 = 1*z0 + 2*z3,\ 

....: z1 = -2*z1 + -1*z4, z4 = 1*z1 + 2*z4,\ 

....: z2 = -3*z2 + -1*z5, z5 = -3*z2 + 2*z5 ) 

sage: Y = P1xP1xP1.subscheme([F1]) 

sage: Y.is_smooth() 

True 

sage: Y.is_nondegenerate() 

True 

 

This example is from Hamm, :arxiv:`1106.1826v1`. It addresses 

an issue raised at :trac:`15239`:: 

 

sage: X = toric_varieties.WP([1,4,2,3], names='z0 z1 z2 z3') 

sage: X.inject_variables() 

Defining z0, z1, z2, z3 

sage: g0 = z1^3 + z2^6 +z3^4 

sage: g = g0-2*z3^2*z0^6+z2*z0^10+z0^12 

sage: Y = X.subscheme([g]) 

sage: Y.is_nondegenerate() 

False 

 

It handles nonzero characteristic:: 

 

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

sage: f = x^5 + 2*x*y^4 + y^5 - 2*y^3*z^2 + x*z^4 - 2*z^5 

sage: P2.change_ring(GF(5)).subscheme([f]).is_nondegenerate() 

True 

sage: P2.change_ring(GF(7)).subscheme([f]).is_nondegenerate() 

False 

 

TESTS: 

 

Some corner cases discussed at :trac:`15239`:: 

 

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

sage: P2.subscheme([]).is_nondegenerate() 

False 

sage: P2.subscheme([x]).is_nondegenerate() 

False 

 

""" 

X = self.ambient_space() 

fan = X.fan() 

SR = X.Stanley_Reisner_ideal() 

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing 

R = PolynomialRing(X.base_ring(), fan.nrays() + SR.ngens(), 't') 

slack = R.gens()[fan.nrays():] 

SR = SR.change_ring(R) 

 

def restrict(cone): 

patch = dict() 

divide = dict() 

for i in cone.ambient_ray_indices(): 

patch[R.gen(i)] = R.zero() # restrict to torus orbit 

# divide out highest power of R.gen(i) 

divide[R.gen(i)] = R.one() 

ideal = self.defining_ideal().change_ring(R) 

ideal = ideal.subs(patch) 

mat = jacobian(ideal.gens(), R.gens()[:fan.nrays()]) 

minors = mat.minors(self.codimension()) 

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

Jac_patch = R.ideal(ideal.gens() + minors) 

SR_patch = R.ideal([monomial * slack[i] - R.one() 

for i, monomial in 

enumerate(SR.subs(divide).gens())]) 

return ideal, Jac_patch + SR_patch 

 

for dim in range(0, fan.dim() + 1): 

for cone in fan(dim): 

ideal1, ideal2 = restrict(cone) 

if ideal1.is_zero() or ideal2.dimension() != -1: 

return False 

 

return True 

 

def is_schon(self): 

r""" 

Check if ``self`` is schon (nondegenerate). 

 

See `is_nondegenerate` for further documentation. 

 

EXAMPLES:: 

 

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

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

sage: X.is_smooth() 

True 

sage: X.is_schon() 

False 

 

""" 

return self.is_nondegenerate() 

 

class AlgebraicScheme_subscheme_affine_toric(AlgebraicScheme_subscheme_toric): 

r""" 

Construct an algebraic subscheme of an affine toric variety. 

 

.. WARNING:: 

 

You should not create objects of this class directly. The preferred 

method to construct such subschemes is to use 

:meth:`~ToricVariety_field.subscheme` method of 

:class:`toric varieties <ToricVariety_field>`. 

 

INPUT: 

 

- ``toric_variety`` -- ambient :class:`affine toric variety 

<ToricVariety_field>`; 

 

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

polynomials in the coordinate ring of ``toric_variety``. 

 

OUTPUT: 

 

A :class:`algebraic subscheme of an affine toric variety 

<AlgebraicScheme_subscheme_affine_toric>`. 

 

TESTS:: 

 

sage: P1xP1 = toric_varieties.P1xP1() 

sage: P1xP1.inject_variables() 

Defining s, t, x, y 

sage: import sage.schemes.toric.toric_subscheme as SCM 

sage: X = SCM.AlgebraicScheme_subscheme_toric( 

....: P1xP1, [x*s + y*t, x^3+y^3]) 

sage: X 

Closed subscheme of 2-d CPR-Fano toric variety 

covered by 4 affine patches defined by: 

s*x + t*y, 

x^3 + y^3 

 

A better way to construct the same scheme as above:: 

 

sage: P1xP1.subscheme([x*s + y*t, x^3+y^3]) 

Closed subscheme of 2-d CPR-Fano toric variety 

covered by 4 affine patches defined by: 

s*x + t*y, 

x^3 + y^3 

""" 

 

def __init__(self, toric_variety, polynomials): 

r""" 

See :class:`AlgebraicScheme_subscheme_toric` for documentation. 

 

TESTS:: 

 

sage: P1xP1 = toric_varieties.P1xP1() 

sage: P1xP1.inject_variables() 

Defining s, t, x, y 

sage: import sage.schemes.toric.toric_subscheme as SCM 

sage: X = SCM.AlgebraicScheme_subscheme_toric( 

....: P1xP1, [x*s + y*t, x^3+y^3]) 

sage: X 

Closed subscheme of 2-d CPR-Fano toric variety 

covered by 4 affine patches defined by: 

s*x + t*y, 

x^3 + y^3 

""" 

assert toric_variety.is_affine(), 'The toric variety must be affine!' 

# Just to make sure that keyword arguments will be passed correctly 

super(AlgebraicScheme_subscheme_affine_toric, self).__init__(toric_variety, 

polynomials) 

 

def dimension(self): 

""" 

Return the dimension of ``self``. 

 

OUTPUT: 

 

- integer. 

 

EXAMPLES:: 

 

sage: P1xP1.<s0,s1,t0,t1> = toric_varieties.P1xP1() 

sage: P1 = P1xP1.subscheme(s0-s1) 

sage: P1.dimension() 

1 

 

A more complicated example where the ambient toric variety is 

not smooth:: 

 

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

sage: X.is_smooth() 

False 

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

sage: Y 

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

x*y, 

x^2 

sage: Y.dimension() 

1 

""" 

if '_dimension' in self.__dict__: 

return self._dimension 

 

if self.ambient_space().is_smooth(): 

self._dimension = self.defining_ideal().dimension() 

else: 

self._dimension = self.affine_algebraic_patch().dimension() 

return self._dimension 

 

def is_smooth(self, point=None): 

r""" 

Test whether the algebraic subscheme is smooth. 

 

INPUT: 

 

- ``point`` -- A point or ``None`` (default). The point to 

test smoothness at. 

 

OUTPUT: 

 

Boolean. If no point was specified, returns whether the 

algebraic subscheme is smooth everywhere. Otherwise, 

smoothness at the specified point is tested. 

 

EXAMPLES:: 

 

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

sage: cuspidal_curve = A2.subscheme([y^2-x^3]) 

sage: cuspidal_curve 

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

-x^3 + y^2 

sage: cuspidal_curve.is_smooth([1,1]) 

True 

sage: cuspidal_curve.is_smooth([0,0]) 

False 

sage: cuspidal_curve.is_smooth() 

False 

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

sage: circle.is_smooth([1,0]) 

True 

sage: circle.is_smooth() 

True 

 

A more complicated example where the ambient toric variety is 

not smooth:: 

 

sage: X.<x,y> = toric_varieties.A2_Z2() # 2-d affine space mod Z/2 

sage: X.is_smooth() 

False 

sage: Y = X.subscheme([x*y, x^2]) # (twice the x=0 curve) mod Z/2 

sage: Y 

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

x*y, 

x^2 

sage: Y.dimension() # Y is a Weil divisor but not Cartier 

1 

sage: Y.is_smooth() 

True 

sage: Y.is_smooth([0,0]) 

True 

""" 

if not point is None: 

self._check_satisfies_equations(point) 

if self.ambient_space().is_smooth(): 

R = self.ambient_space().coordinate_ring() 

point_subs = dict(zip(R.gens(), point)) 

Jac = self.Jacobian().subs(point_subs) 

return not Jac.is_zero() 

else: 

self._embedding_center = self.point(point) 

affine = self.affine_algebraic_patch() 

return affine.is_smooth(affine.embedding_center()) 

 

# testing smoothness everywhere tends to be expensive 

if '_smooth' in self.__dict__: 

return self._smooth 

 

if self.ambient_space().is_smooth(): 

sing_dim = self.Jacobian().dimension() 

self._smooth = (sing_dim == -1) 

else: 

self._smooth = self.affine_algebraic_patch().is_smooth() 

 

return self._smooth