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

r""" 

Exterior powers of free modules 

 

Given a free module `M` of finite rank over a commutative ring `R` 

and a positive integer `p`, the `p`-*th exterior power of* `M` 

is the set `\Lambda^p(M)` of all alternating contravariant tensors of 

degree `p` on `M`, i.e. of all multilinear maps 

 

.. MATH:: 

 

\underbrace{M^*\times\cdots\times M^*}_{p\ \; \mbox{times}} 

\longrightarrow R 

 

that vanish whenever any of two of their arguments are equal 

(`M^*` stands for the dual of `M`). 

Note that `\Lambda^1(M) = M`. The exterior power 

`\Lambda^p(M)` is a free module of rank `\binom{n}{p}` over `R`, 

where `n` is the rank of `M`. 

 

Similarly, the `p`-*th exterior power of the dual of* `M` 

is the set `\Lambda^p(M^*)` of all alternating forms of degree `p` on 

`M`, i.e. of all multilinear maps 

 

.. MATH:: 

 

\underbrace{M\times\cdots\times M}_{p\ \; \mbox{times}} 

\longrightarrow R 

 

that vanish whenever any of two of their arguments are equal. 

Note that `\Lambda^1(M^*) = M^*` (the dual of `M`). The exterior power 

`\Lambda^p(M^*)` is a free module of rank `\binom{n}{p}` over `R`, 

where `n` is the rank of `M`. 

 

The class :class:`ExtPowerFreeModule` implements `\Lambda^p(M)`, while 

the class :class:`ExtPowerDualFreeModule` implements `\Lambda^p(M^*)`. 

 

AUTHORS: 

 

- Eric Gourgoulhon: initial version, regarding `\Lambda^p(M^*)` only 

(2015); add class for `\Lambda^p(M)` (2017) 

 

 

REFERENCES: 

 

- \K. Conrad: *Exterior powers* [Con2013]_ 

- Chap. 19 of S. Lang: *Algebra* [Lan2002]_ 

 

""" 

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

# Copyright (C) 2017 Eric Gourgoulhon <eric.gourgoulhon@obspm.fr> 

# 

# 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.rings.integer import Integer 

from sage.tensor.modules.finite_rank_free_module import FiniteRankFreeModule 

from sage.tensor.modules.free_module_tensor import FreeModuleTensor 

from sage.tensor.modules.alternating_contr_tensor import AlternatingContrTensor 

from sage.tensor.modules.free_module_alt_form import FreeModuleAltForm 

 

class ExtPowerFreeModule(FiniteRankFreeModule): 

r""" 

Exterior power of a free module of finite rank over a commutative 

ring. 

 

Given a free module `M` of finite rank over a commutative ring `R` 

and a positive integer `p`, the `p`-*th exterior power of* `M` is 

the set `\Lambda^p(M)` of all alternating contravariant tensors of 

degree `p` on `M`, i.e. of all multilinear maps 

 

.. MATH:: 

 

\underbrace{M^*\times\cdots\times M^*}_{p\ \; \mbox{times}} 

\longrightarrow R 

 

that vanish whenever any of two of their arguments are equal. 

Note that `\Lambda^1(M) = M`. 

 

`\Lambda^p(M)` is a free module of rank `\binom{n}{p}` over 

`R`, where `n` is the rank of `M`. 

Accordingly, the class :class:`ExtPowerFreeModule` inherits from the 

class 

:class:`~sage.tensor.modules.finite_rank_free_module.FiniteRankFreeModule`. 

 

This is a Sage *parent* class, whose *element* class is 

:class:`~sage.tensor.modules.alternating_contr_tensor.AlternatingContrTensor` 

 

INPUT: 

 

- ``fmodule`` -- free module `M` of finite rank, as an instance of 

:class:`~sage.tensor.modules.finite_rank_free_module.FiniteRankFreeModule` 

- ``degree`` -- positive integer; the degree `p` of the alternating 

elements 

- ``name`` -- (default: ``None``) string; name given to `\Lambda^p(M)` 

- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to 

denote `\Lambda^p(M)` 

 

EXAMPLES: 

 

2nd exterior power of the dual of a free `\ZZ`-module of rank 3:: 

 

sage: M = FiniteRankFreeModule(ZZ, 3, name='M') 

sage: e = M.basis('e') 

sage: from sage.tensor.modules.ext_pow_free_module import ExtPowerFreeModule 

sage: A = ExtPowerFreeModule(M, 2) ; A 

2nd exterior power of the Rank-3 free module M over the 

Integer Ring 

 

Instead of importing ExtPowerFreeModule in the global name space, it is 

recommended to use the module's method 

:meth:`~sage.tensor.modules.finite_rank_free_module.FiniteRankFreeModule.exterior_power`:: 

 

sage: A = M.exterior_power(2) ; A 

2nd exterior power of the Rank-3 free module M over the 

Integer Ring 

sage: latex(A) 

\Lambda^{2}\left(M\right) 

 

``A`` is a module (actually a free module) over `\ZZ`:: 

 

sage: A.category() 

Category of finite dimensional modules over Integer Ring 

sage: A in Modules(ZZ) 

True 

sage: A.rank() 

3 

sage: A.base_ring() 

Integer Ring 

sage: A.base_module() 

Rank-3 free module M over the Integer Ring 

 

``A`` is a *parent* object, whose elements are alternating 

contravariant tensors, represented by instances of the class 

:class:`~sage.tensor.modules.alternating_contr_tensor.AlternatingContrTensor`:: 

 

sage: a = A.an_element() ; a 

Alternating contravariant tensor of degree 2 on the Rank-3 free 

module M over the Integer Ring 

sage: a.display() # expansion with respect to M's default basis (e) 

e_0/\e_1 

sage: from sage.tensor.modules.alternating_contr_tensor import AlternatingContrTensor 

sage: isinstance(a, AlternatingContrTensor) 

True 

sage: a in A 

True 

sage: A.is_parent_of(a) 

True 

 

Elements can be constructed from ``A``. In particular, 0 yields 

the zero element of ``A``:: 

 

sage: A(0) 

Alternating contravariant tensor zero of degree 2 on the Rank-3 

free module M over the Integer Ring 

sage: A(0) is A.zero() 

True 

 

while non-zero elements are constructed by providing their components in a 

given basis:: 

 

sage: e 

Basis (e_0,e_1,e_2) on the Rank-3 free module M over the Integer Ring 

sage: comp = [[0,3,-1],[-3,0,4],[1,-4,0]] 

sage: a = A(comp, basis=e, name='a') ; a 

Alternating contravariant tensor a of degree 2 on the Rank-3 

free module M over the Integer Ring 

sage: a.display(e) 

a = 3 e_0/\e_1 - e_0/\e_2 + 4 e_1/\e_2 

 

An alternative is to construct the alternating contravariant tensor from an 

empty list of components and to set the nonzero components afterwards:: 

 

sage: a = A([], name='a') 

sage: a.set_comp(e)[0,1] = 3 

sage: a.set_comp(e)[0,2] = -1 

sage: a.set_comp(e)[1,2] = 4 

sage: a.display(e) 

a = 3 e_0/\e_1 - e_0/\e_2 + 4 e_1/\e_2 

 

The exterior powers are unique:: 

 

sage: A is M.exterior_power(2) 

True 

 

The exterior power `\Lambda^1(M)` is nothing but `M`:: 

 

sage: M.exterior_power(1) is M 

True 

 

For a degree `p\geq 2`, there is a coercion 

`\Lambda^p(M)\rightarrow T^{(p,0)}(M)`:: 

 

sage: T20 = M.tensor_module(2,0) ; T20 

Free module of type-(2,0) tensors on the Rank-3 free module M 

over the Integer Ring 

sage: T20.has_coerce_map_from(A) 

True 

 

Of course, there is no coercion in the reverse direction:: 

 

sage: A.has_coerce_map_from(T20) 

False 

 

The coercion map `\Lambda^2(M)\rightarrow T^{(2,0)}(M)` in action:: 

 

sage: ta = T20(a) ; ta 

Type-(2,0) tensor a on the Rank-3 free module M over the Integer Ring 

sage: ta.display(e) 

a = 3 e_0*e_1 - e_0*e_2 - 3 e_1*e_0 + 4 e_1*e_2 + e_2*e_0 - 4 e_2*e_1 

sage: a.display(e) 

a = 3 e_0/\e_1 - e_0/\e_2 + 4 e_1/\e_2 

sage: ta.symmetries() # the antisymmetry is of course preserved 

no symmetry; antisymmetry: (0, 1) 

sage: ta == a # equality as type-(2,0) tensors 

True 

 

""" 

 

Element = AlternatingContrTensor 

 

def __init__(self, fmodule, degree, name=None, latex_name=None): 

r""" 

TESTS:: 

 

sage: from sage.tensor.modules.ext_pow_free_module import ExtPowerFreeModule 

sage: M = FiniteRankFreeModule(ZZ, 3, name='M') 

sage: e = M.basis('e') 

sage: A = ExtPowerFreeModule(M, 2) ; A 

2nd exterior power of the Rank-3 free module M over the 

Integer Ring 

sage: TestSuite(A).run() 

 

""" 

from sage.functions.other import binomial 

self._fmodule = fmodule 

self._degree = degree 

rank = binomial(fmodule._rank, degree) 

self._zero_element = 0 # provisory (to avoid infinite recursion 

# in what follows) 

if name is None and fmodule._name is not None: 

name = '/\^{}('.format(degree) + fmodule._name + ')' 

if latex_name is None and fmodule._latex_name is not None: 

latex_name = r'\Lambda^{' + str(degree) + r'}\left(' + \ 

fmodule._latex_name + r'\right)' 

FiniteRankFreeModule.__init__(self, fmodule._ring, rank, 

name=name, latex_name=latex_name, 

start_index=fmodule._sindex, 

output_formatter=fmodule._output_formatter) 

# Unique representation: 

if self._degree == 1 or \ 

self._degree in self._fmodule._exterior_powers: 

raise ValueError("the {}th exterior power of ".format(degree) + 

"{}".format(self._fmodule) + 

" has already been created") 

else: 

self._fmodule._exterior_powers[self._degree] = self 

# Zero element 

self._zero_element = self._element_constructor_(name='zero', 

latex_name='0') 

for basis in self._fmodule._known_bases: 

self._zero_element._components[basis] = \ 

self._zero_element._new_comp(basis) 

# (since new components are initialized to zero) 

 

#### Parent methods 

 

def _element_constructor_(self, comp=[], basis=None, name=None, 

latex_name=None): 

r""" 

Construct an alternating contravariant tensor. 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(ZZ, 3, name='M') 

sage: e = M.basis('e') 

sage: A = M.exterior_power(2) 

sage: a = A._element_constructor_(0) ; a 

Alternating contravariant tensor zero of degree 2 on the 

Rank-3 free module M over the Integer Ring 

sage: a = A._element_constructor_([], name='a') ; a 

Alternating contravariant tensor a of degree 2 on the Rank-3 

free module M over the Integer Ring 

sage: a[e,0,2], a[e,1,2] = 3, -1 

sage: a.display() 

a = 3 e_0/\e_2 - e_1/\e_2 

 

""" 

if isinstance(comp, (int, Integer)) and comp == 0: 

return self._zero_element 

resu = self.element_class(self._fmodule, self._degree, name=name, 

latex_name=latex_name) 

if comp: 

resu.set_comp(basis)[:] = comp 

return resu 

 

def _an_element_(self): 

r""" 

Construct some (unamed) alternating contravariant tensor. 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(QQ, 4, name='M') 

sage: e = M.basis('e') 

sage: a = M.exterior_power(2)._an_element_() ; a 

Alternating contravariant tensor of degree 2 on the 4-dimensional vector space M 

over the Rational Field 

sage: a.display() 

1/2 e_0/\e_1 

sage: a = M.exterior_power(3)._an_element_() ; a 

Alternating contravariant tensor of degree 3 on the 4-dimensional vector space M 

over the Rational Field 

sage: a.display() 

1/2 e_0/\e_1/\e_2 

sage: a = M.exterior_power(4)._an_element_() ; a 

Alternating contravariant tensor of degree 4 on the 4-dimensional vector space M 

over the Rational Field 

sage: a.display() 

1/2 e_0/\e_1/\e_2/\e_3 

 

""" 

resu = self.element_class(self._fmodule, self._degree) 

if self._fmodule._def_basis is not None: 

sindex = self._fmodule._sindex 

ind = [sindex + i for i in range(resu._tensor_rank)] 

resu.set_comp()[ind] = self._fmodule._ring.an_element() 

return resu 

 

#### End of parent methods 

 

def _repr_(self): 

r""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(ZZ, 5, name='M') 

sage: M.exterior_power(2)._repr_() 

'2nd exterior power of the Rank-5 free module M over the Integer Ring' 

sage: M.exterior_power(3)._repr_() 

'3rd exterior power of the Rank-5 free module M over the Integer Ring' 

sage: M.exterior_power(4)._repr_() 

'4th exterior power of the Rank-5 free module M over the Integer Ring' 

sage: M.exterior_power(5)._repr_() 

'5th exterior power of the Rank-5 free module M over the Integer Ring' 

 

""" 

description = "{}".format(self._degree) 

if self._degree == 2: 

description += "nd" 

elif self._degree == 3: 

description += "rd" 

else: 

description += "th" 

description += " exterior power of the {}".format(self._fmodule) 

return description 

 

def base_module(self): 

r""" 

Return the free module on which ``self`` is constructed. 

 

OUTPUT: 

 

- instance of :class:`FiniteRankFreeModule` representing the 

free module on which the exterior power is defined. 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(ZZ, 5, name='M') 

sage: A = M.exterior_power(2) 

sage: A.base_module() 

Rank-5 free module M over the Integer Ring 

sage: A.base_module() is M 

True 

 

""" 

return self._fmodule 

 

def degree(self): 

r""" 

Return the degree of ``self``. 

 

OUTPUT: 

 

- integer `p` such that ``self`` is the exterior power 

`\Lambda^p(M)` 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(ZZ, 5, name='M') 

sage: A = M.exterior_power(2) 

sage: A.degree() 

2 

sage: M.exterior_power(4).degree() 

4 

 

""" 

return self._degree 

 

 

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

 

 

class ExtPowerDualFreeModule(FiniteRankFreeModule): 

r""" 

Exterior power of the dual of a free module of finite rank 

over a commutative ring. 

 

Given a free module `M` of finite rank over a commutative ring `R` 

and a positive integer `p`, the `p`-*th exterior power of the dual of* 

`M` is the set `\Lambda^p(M^*)` of all alternating forms of degree 

`p` on `M`, i.e. of all multilinear maps 

 

.. MATH:: 

 

\underbrace{M\times\cdots\times M}_{p\ \; \mbox{times}} 

\longrightarrow R 

 

that vanish whenever any of two of their arguments are equal. 

Note that `\Lambda^1(M^*) = M^*` (the dual of `M`). 

 

`\Lambda^p(M^*)` is a free module of rank `\binom{n}{p}` over 

`R`, where `n` is the rank of `M`. 

Accordingly, the class :class:`ExtPowerDualFreeModule` inherits from 

the class 

:class:`~sage.tensor.modules.finite_rank_free_module.FiniteRankFreeModule`. 

 

This is a Sage *parent* class, whose *element* class is 

:class:`~sage.tensor.modules.free_module_alt_form.FreeModuleAltForm`. 

 

INPUT: 

 

- ``fmodule`` -- free module `M` of finite rank, as an instance of 

:class:`~sage.tensor.modules.finite_rank_free_module.FiniteRankFreeModule` 

- ``degree`` -- positive integer; the degree `p` of the alternating 

forms 

- ``name`` -- (default: ``None``) string; name given to `\Lambda^p(M^*)` 

- ``latex_name`` -- (default: ``None``) string; LaTeX symbol to 

denote `\Lambda^p(M^*)` 

 

EXAMPLES: 

 

2nd exterior power of the dual of a free `\ZZ`-module of rank 3:: 

 

sage: M = FiniteRankFreeModule(ZZ, 3, name='M') 

sage: e = M.basis('e') 

sage: from sage.tensor.modules.ext_pow_free_module import ExtPowerDualFreeModule 

sage: A = ExtPowerDualFreeModule(M, 2) ; A 

2nd exterior power of the dual of the Rank-3 free module M over the 

Integer Ring 

 

Instead of importing ExtPowerDualFreeModule in the global name space, 

it is recommended to use the module's method 

:meth:`~sage.tensor.modules.finite_rank_free_module.FiniteRankFreeModule.dual_exterior_power`:: 

 

sage: A = M.dual_exterior_power(2) ; A 

2nd exterior power of the dual of the Rank-3 free module M over the 

Integer Ring 

sage: latex(A) 

\Lambda^{2}\left(M^*\right) 

 

``A`` is a module (actually a free module) over `\ZZ`:: 

 

sage: A.category() 

Category of finite dimensional modules over Integer Ring 

sage: A in Modules(ZZ) 

True 

sage: A.rank() 

3 

sage: A.base_ring() 

Integer Ring 

sage: A.base_module() 

Rank-3 free module M over the Integer Ring 

 

``A`` is a *parent* object, whose elements are alternating forms, 

represented by instances of the class 

:class:`~sage.tensor.modules.free_module_alt_form.FreeModuleAltForm`:: 

 

sage: a = A.an_element() ; a 

Alternating form of degree 2 on the Rank-3 free module M over the 

Integer Ring 

sage: a.display() # expansion with respect to M's default basis (e) 

e^0/\e^1 

sage: from sage.tensor.modules.free_module_alt_form import FreeModuleAltForm 

sage: isinstance(a, FreeModuleAltForm) 

True 

sage: a in A 

True 

sage: A.is_parent_of(a) 

True 

 

Elements can be constructed from ``A``. In particular, 0 yields 

the zero element of ``A``:: 

 

sage: A(0) 

Alternating form zero of degree 2 on the Rank-3 free module M over the 

Integer Ring 

sage: A(0) is A.zero() 

True 

 

while non-zero elements are constructed by providing their components in a 

given basis:: 

 

sage: e 

Basis (e_0,e_1,e_2) on the Rank-3 free module M over the Integer Ring 

sage: comp = [[0,3,-1],[-3,0,4],[1,-4,0]] 

sage: a = A(comp, basis=e, name='a') ; a 

Alternating form a of degree 2 on the Rank-3 free module M over the 

Integer Ring 

sage: a.display(e) 

a = 3 e^0/\e^1 - e^0/\e^2 + 4 e^1/\e^2 

 

An alternative is to construct the alternating form from an empty list of 

components and to set the nonzero components afterwards:: 

 

sage: a = A([], name='a') 

sage: a.set_comp(e)[0,1] = 3 

sage: a.set_comp(e)[0,2] = -1 

sage: a.set_comp(e)[1,2] = 4 

sage: a.display(e) 

a = 3 e^0/\e^1 - e^0/\e^2 + 4 e^1/\e^2 

 

The exterior powers are unique:: 

 

sage: A is M.dual_exterior_power(2) 

True 

 

The exterior power `\Lambda^1(M^*)` is nothing but `M^*`:: 

 

sage: M.dual_exterior_power(1) is M.dual() 

True 

sage: M.dual() 

Dual of the Rank-3 free module M over the Integer Ring 

sage: latex(M.dual()) 

M^* 

 

Since any tensor of type (0,1) is a linear form, there is a coercion map 

from the set `T^{(0,1)}(M)` of such tensors to `M^*`:: 

 

sage: T01 = M.tensor_module(0,1) ; T01 

Free module of type-(0,1) tensors on the Rank-3 free module M over the 

Integer Ring 

sage: M.dual().has_coerce_map_from(T01) 

True 

 

There is also a coercion map in the reverse direction:: 

 

sage: T01.has_coerce_map_from(M.dual()) 

True 

 

For a degree `p\geq 2`, the coercion holds only in the direction 

`\Lambda^p(M^*)\rightarrow T^{(0,p)}(M)`:: 

 

sage: T02 = M.tensor_module(0,2) ; T02 

Free module of type-(0,2) tensors on the Rank-3 free module M over the 

Integer Ring 

sage: T02.has_coerce_map_from(A) 

True 

sage: A.has_coerce_map_from(T02) 

False 

 

The coercion map `T^{(0,1)}(M) \rightarrow M^*` in action:: 

 

sage: b = T01([-2,1,4], basis=e, name='b') ; b 

Type-(0,1) tensor b on the Rank-3 free module M over the Integer Ring 

sage: b.display(e) 

b = -2 e^0 + e^1 + 4 e^2 

sage: lb = M.dual()(b) ; lb 

Linear form b on the Rank-3 free module M over the Integer Ring 

sage: lb.display(e) 

b = -2 e^0 + e^1 + 4 e^2 

 

The coercion map `M^* \rightarrow T^{(0,1)}(M)` in action:: 

 

sage: tlb = T01(lb) ; tlb 

Type-(0,1) tensor b on the Rank-3 free module M over the Integer Ring 

sage: tlb == b 

True 

 

The coercion map `\Lambda^2(M^*)\rightarrow T^{(0,2)}(M)` in action:: 

 

sage: ta = T02(a) ; ta 

Type-(0,2) tensor a on the Rank-3 free module M over the Integer Ring 

sage: ta.display(e) 

a = 3 e^0*e^1 - e^0*e^2 - 3 e^1*e^0 + 4 e^1*e^2 + e^2*e^0 - 4 e^2*e^1 

sage: a.display(e) 

a = 3 e^0/\e^1 - e^0/\e^2 + 4 e^1/\e^2 

sage: ta.symmetries() # the antisymmetry is of course preserved 

no symmetry; antisymmetry: (0, 1) 

 

""" 

 

Element = FreeModuleAltForm 

 

def __init__(self, fmodule, degree, name=None, latex_name=None): 

r""" 

TESTS:: 

 

sage: from sage.tensor.modules.ext_pow_free_module import ExtPowerDualFreeModule 

sage: M = FiniteRankFreeModule(ZZ, 3, name='M') 

sage: e = M.basis('e') 

sage: A = ExtPowerDualFreeModule(M, 2) ; A 

2nd exterior power of the dual of the Rank-3 free module M over 

the Integer Ring 

sage: TestSuite(A).run() 

 

""" 

from sage.functions.other import binomial 

self._fmodule = fmodule 

self._degree = degree 

rank = binomial(fmodule._rank, degree) 

self._zero_element = 0 # provisory (to avoid infinite recursion in what 

# follows) 

if degree == 1: # case of the dual 

if name is None and fmodule._name is not None: 

name = fmodule._name + '*' 

if latex_name is None and fmodule._latex_name is not None: 

latex_name = fmodule._latex_name + r'^*' 

else: 

if name is None and fmodule._name is not None: 

name = '/\^{}('.format(degree) + fmodule._name + '*)' 

if latex_name is None and fmodule._latex_name is not None: 

latex_name = r'\Lambda^{' + str(degree) + r'}\left(' + \ 

fmodule._latex_name + r'^*\right)' 

FiniteRankFreeModule.__init__(self, fmodule._ring, rank, name=name, 

latex_name=latex_name, 

start_index=fmodule._sindex, 

output_formatter=fmodule._output_formatter) 

# Unique representation: 

if self._degree in self._fmodule._dual_exterior_powers: 

raise ValueError("the {}th exterior power of ".format(degree) + 

"the dual of {}".format(self._fmodule) + 

" has already been created") 

else: 

self._fmodule._dual_exterior_powers[self._degree] = self 

# Zero element 

self._zero_element = self._element_constructor_(name='zero', 

latex_name='0') 

for basis in self._fmodule._known_bases: 

self._zero_element._components[basis] = \ 

self._zero_element._new_comp(basis) 

# (since new components are initialized to zero) 

 

#### Parent methods 

 

def _element_constructor_(self, comp=[], basis=None, name=None, 

latex_name=None): 

r""" 

Construct an alternating form. 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(ZZ, 3, name='M') 

sage: e = M.basis('e') 

sage: A = M.dual_exterior_power(1) 

sage: a = A._element_constructor_(0) ; a 

Linear form zero on the Rank-3 free module M over the Integer Ring 

sage: a = A._element_constructor_([2,0,-1], name='a') ; a 

Linear form a on the Rank-3 free module M over the Integer Ring 

sage: a.display() 

a = 2 e^0 - e^2 

sage: A = M.dual_exterior_power(2) 

sage: a = A._element_constructor_(0) ; a 

Alternating form zero of degree 2 on the Rank-3 free module M over 

the Integer Ring 

sage: a = A._element_constructor_([], name='a') ; a 

Alternating form a of degree 2 on the Rank-3 free module M over 

the Integer Ring 

sage: a[e,0,2], a[e,1,2] = 3, -1 

sage: a.display() 

a = 3 e^0/\e^2 - e^1/\e^2 

 

""" 

if isinstance(comp, (int, Integer)) and comp == 0: 

return self._zero_element 

if isinstance(comp, FreeModuleTensor): 

# coercion of a tensor of type (0,1) to a linear form 

tensor = comp # for readability 

if tensor.tensor_type() == (0,1) and self._degree == 1 and \ 

tensor.base_module() is self._fmodule: 

resu = self.element_class(self._fmodule, 1, name=tensor._name, 

latex_name=tensor._latex_name) 

for basis, comp in tensor._components.items(): 

resu._components[basis] = comp.copy() 

return resu 

else: 

raise TypeError("cannot coerce the {} ".format(tensor) + 

"to an element of {}".format(self)) 

# standard construction 

resu = self.element_class(self._fmodule, self._degree, name=name, 

latex_name=latex_name) 

if comp: 

resu.set_comp(basis)[:] = comp 

return resu 

 

def _an_element_(self): 

r""" 

Construct some (unamed) alternating form. 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(QQ, 4, name='M') 

sage: e = M.basis('e') 

sage: a = M.dual_exterior_power(1)._an_element_() ; a 

Linear form on the 4-dimensional vector space M over the Rational 

Field 

sage: a.display() 

1/2 e^0 

sage: a = M.dual_exterior_power(2)._an_element_() ; a 

Alternating form of degree 2 on the 4-dimensional vector space M 

over the Rational Field 

sage: a.display() 

1/2 e^0/\e^1 

sage: a = M.dual_exterior_power(3)._an_element_() ; a 

Alternating form of degree 3 on the 4-dimensional vector space M 

over the Rational Field 

sage: a.display() 

1/2 e^0/\e^1/\e^2 

sage: a = M.dual_exterior_power(4)._an_element_() ; a 

Alternating form of degree 4 on the 4-dimensional vector space M 

over the Rational Field 

sage: a.display() 

1/2 e^0/\e^1/\e^2/\e^3 

 

""" 

resu = self.element_class(self._fmodule, self._degree) 

if self._fmodule._def_basis is not None: 

sindex = self._fmodule._sindex 

ind = [sindex + i for i in range(resu._tensor_rank)] 

resu.set_comp()[ind] = self._fmodule._ring.an_element() 

return resu 

 

def _coerce_map_from_(self, other): 

r""" 

Determine whether coercion to ``self`` exists from other parent. 

 

EXAMPLES: 

 

Sets of type-`(0,1)` tensors coerce to ``self`` if the degree is 1:: 

 

sage: M = FiniteRankFreeModule(ZZ, 3, name='M') 

sage: L1 = M.dual_exterior_power(1) ; L1 

Dual of the Rank-3 free module M over the Integer Ring 

sage: T01 = M.tensor_module(0,1) ; T01 

Free module of type-(0,1) tensors on the Rank-3 free module M over 

the Integer Ring 

sage: L1._coerce_map_from_(T01) 

True 

 

Of course, coercions from other tensor types are meaningless:: 

 

sage: L1._coerce_map_from_(M.tensor_module(1,0)) 

False 

sage: L1._coerce_map_from_(M.tensor_module(0,2)) 

False 

 

If the degree is larger than 1, there is no coercion:: 

 

sage: L2 = M.dual_exterior_power(2) ; L2 

2nd exterior power of the dual of the Rank-3 free module M over 

the Integer Ring 

sage: L2._coerce_map_from_(M.tensor_module(0,2)) 

False 

 

""" 

from sage.tensor.modules.tensor_free_module import TensorFreeModule 

if isinstance(other, TensorFreeModule): 

# coercion of a type-(0,1) tensor to a linear form 

if self._fmodule is other._fmodule and self._degree == 1 and \ 

other.tensor_type() == (0,1): 

return True 

return False 

 

#### End of parent methods 

 

def _repr_(self): 

r""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(ZZ, 5, name='M') 

sage: M.dual_exterior_power(1)._repr_() 

'Dual of the Rank-5 free module M over the Integer Ring' 

sage: M.dual_exterior_power(2)._repr_() 

'2nd exterior power of the dual of the Rank-5 free module M over the Integer Ring' 

sage: M.dual_exterior_power(3)._repr_() 

'3rd exterior power of the dual of the Rank-5 free module M over the Integer Ring' 

sage: M.dual_exterior_power(4)._repr_() 

'4th exterior power of the dual of the Rank-5 free module M over the Integer Ring' 

sage: M.dual_exterior_power(5)._repr_() 

'5th exterior power of the dual of the Rank-5 free module M over the Integer Ring' 

 

""" 

if self._degree == 1: 

return "Dual of the {}".format(self._fmodule) 

description = "{}".format(self._degree) 

if self._degree == 2: 

description += "nd" 

elif self._degree == 3: 

description += "rd" 

else: 

description += "th" 

description += " exterior power of the dual of the {}".format( 

self._fmodule) 

return description 

 

def base_module(self): 

r""" 

Return the free module on which ``self`` is constructed. 

 

OUTPUT: 

 

- instance of :class:`FiniteRankFreeModule` representing the free 

module on which the exterior power is defined. 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(ZZ, 5, name='M') 

sage: A = M.dual_exterior_power(2) 

sage: A.base_module() 

Rank-5 free module M over the Integer Ring 

sage: A.base_module() is M 

True 

 

""" 

return self._fmodule 

 

def degree(self): 

r""" 

Return the degree of ``self``. 

 

OUTPUT: 

 

- integer `p` such that ``self`` is the exterior power `\Lambda^p(M^*)` 

 

EXAMPLES:: 

 

sage: M = FiniteRankFreeModule(ZZ, 5, name='M') 

sage: A = M.dual_exterior_power(2) 

sage: A.degree() 

2 

sage: M.dual_exterior_power(4).degree() 

4 

 

""" 

return self._degree