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

r""" 

Integral lattices 

 

An integral lattice is a finitely generated free abelian group 

`L \cong \ZZ^r` equipped with a non-degenerate, symmetric bilinear 

form `L \times L \colon \rightarrow \ZZ`. 

 

Here, lattices have an ambient quadratic space `\QQ^n` and 

a distinguished basis. 

 

EXAMPLES:: 

 

sage: M = Matrix(ZZ, [[0,1], [1,0]]) 

sage: IntegralLattice(M) 

Lattice of degree 2 and rank 2 over Integer Ring 

Basis matrix: 

[1 0] 

[0 1] 

Inner product matrix: 

[0 1] 

[1 0] 

 

A lattice can be defined by an inner product matrix of the 

ambient space and a basis:: 

 

sage: G = matrix.identity(3) 

sage: basis = [[1,-1,0], [0,1,-1]] 

sage: L = IntegralLattice(G, basis) 

sage: L 

Lattice of degree 3 and rank 2 over Integer Ring 

Basis matrix: 

[ 1 -1 0] 

[ 0 1 -1] 

Inner product matrix: 

[1 0 0] 

[0 1 0] 

[0 0 1] 

 

sage: L.gram_matrix() 

[ 2 -1] 

[-1 2] 

 

AUTHORS: 

 

- Simon Brandhorst (2017-09): First created 

""" 

 

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

# Copyright (C) 2017 Simon Brandhorst <sbrandhorst@web.de> 

# 

# 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/ 

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

 

from sage.rings.integer_ring import ZZ 

from sage.rings.integer import Integer 

from sage.rings.rational_field import QQ 

from sage.modules.free_quadratic_module import FreeQuadraticModule_submodule_with_basis_pid, FreeQuadraticModule 

from sage.matrix.constructor import matrix 

from sage.structure.element import is_Matrix 

from sage.arith.misc import gcd 

from sage.combinat.root_system.cartan_matrix import CartanMatrix 

from sage.misc.cachefunc import cached_method 

 

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

# 

# Constructor functions 

# 

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

 

def IntegralLattice(data, basis=None): 

r""" 

Return the integral lattice spanned by ``basis`` in the ambient space. 

 

A lattice is a finitely generated free abelian group `L \cong \ZZ^r` 

equipped with a non-degenerate, symmetric bilinear form 

`L \times L \colon \rightarrow \ZZ`. Here, lattices have an 

ambient quadratic space `\QQ^n` and a distinguished basis. 

 

INPUT: 

 

The input is a descriptor of the lattice and a (optional) basis. 

- ``data`` -- can be one of the following: 

 

* a symmetric matrix over the rationals -- the inner product matrix 

* an integer -- the dimension for a euclidian lattice 

* a symmetric Cartan type or anything recognized by 

:class:`CartanMatrix` (see also 

:mod:`Cartan types <sage.combinat.root_system.cartan_type>`) 

-- for a root lattice 

* the string ``"U"`` or ``"H"`` -- for hyperbolic lattices 

 

- ``basis`` -- (optional) a matrix whose rows form a basis of the 

lattice, or a list of module elements forming a basis 

 

OUTPUT: 

 

A lattice in the ambient space defined by the inner_product_matrix. 

Unless specified, the basis of the lattice is the standard basis. 

 

EXAMPLES:: 

 

sage: H5 = Matrix(ZZ, 2, [2,1,1,-2]) 

sage: IntegralLattice(H5) 

Lattice of degree 2 and rank 2 over Integer Ring 

Basis matrix: 

[1 0] 

[0 1] 

Inner product matrix: 

[ 2 1] 

[ 1 -2] 

 

A basis can be specified too:: 

 

sage: IntegralLattice(H5, Matrix([1,1])) 

Lattice of degree 2 and rank 1 over Integer Ring 

Basis matrix: 

[1 1] 

Inner product matrix: 

[ 2 1] 

[ 1 -2] 

 

We can define a Euclidian lattice just by its dimension:: 

 

sage: IntegralLattice(3) 

Lattice of degree 3 and rank 3 over Integer Ring 

Basis matrix: 

[1 0 0] 

[0 1 0] 

[0 0 1] 

Inner product matrix: 

[1 0 0] 

[0 1 0] 

[0 0 1] 

 

Here is an example of the `A_2` root lattice in Euclidian space:: 

 

sage: basis = Matrix([[1,-1,0], [0,1,-1]]) 

sage: A2 = IntegralLattice(3, basis) 

sage: A2 

Lattice of degree 3 and rank 2 over Integer Ring 

Basis matrix: 

[ 1 -1 0] 

[ 0 1 -1] 

Inner product matrix: 

[1 0 0] 

[0 1 0] 

[0 0 1] 

sage: A2.gram_matrix() 

[ 2 -1] 

[-1 2] 

 

We use ``"U"`` or ``"H"`` for defining a hyperbolic lattice:: 

 

sage: L1 = IntegralLattice("U") 

sage: L1 

Lattice of degree 2 and rank 2 over Integer Ring 

Basis matrix: 

[1 0] 

[0 1] 

Inner product matrix: 

[0 1] 

[1 0] 

sage: L1 == IntegralLattice("H") 

True 

 

We can construct root lattices by specifying their type 

(see :mod:`Cartan types <sage.combinat.root_system.cartan_type>` 

and :class:`CartanMatrix`):: 

 

sage: IntegralLattice(["E", 7]) 

Lattice of degree 7 and rank 7 over Integer Ring 

Basis matrix: 

[1 0 0 0 0 0 0] 

[0 1 0 0 0 0 0] 

[0 0 1 0 0 0 0] 

[0 0 0 1 0 0 0] 

[0 0 0 0 1 0 0] 

[0 0 0 0 0 1 0] 

[0 0 0 0 0 0 1] 

Inner product matrix: 

[ 2 0 -1 0 0 0 0] 

[ 0 2 0 -1 0 0 0] 

[-1 0 2 -1 0 0 0] 

[ 0 -1 -1 2 -1 0 0] 

[ 0 0 0 -1 2 -1 0] 

[ 0 0 0 0 -1 2 -1] 

[ 0 0 0 0 0 -1 2] 

sage: IntegralLattice(["A", 2]) 

Lattice of degree 2 and rank 2 over Integer Ring 

Basis matrix: 

[1 0] 

[0 1] 

Inner product matrix: 

[ 2 -1] 

[-1 2] 

sage: IntegralLattice("D3") 

Lattice of degree 3 and rank 3 over Integer Ring 

Basis matrix: 

[1 0 0] 

[0 1 0] 

[0 0 1] 

Inner product matrix: 

[ 2 -1 -1] 

[-1 2 0] 

[-1 0 2] 

sage: IntegralLattice(["D", 4]) 

Lattice of degree 4 and rank 4 over Integer Ring 

Basis matrix: 

[1 0 0 0] 

[0 1 0 0] 

[0 0 1 0] 

[0 0 0 1] 

Inner product matrix: 

[ 2 -1 0 0] 

[-1 2 -1 -1] 

[ 0 -1 2 0] 

[ 0 -1 0 2] 

 

We can specify a basis as well:: 

 

sage: G = Matrix(ZZ, 2, [0,1,1,0]) 

sage: B = [vector([1,1])] 

sage: IntegralLattice(G, basis=B) 

Lattice of degree 2 and rank 1 over Integer Ring 

Basis matrix: 

[1 1] 

Inner product matrix: 

[0 1] 

[1 0] 

sage: IntegralLattice(["A", 3], [[1,1,1]]) 

Lattice of degree 3 and rank 1 over Integer Ring 

Basis matrix: 

[1 1 1] 

Inner product matrix: 

[ 2 -1 0] 

[-1 2 -1] 

[ 0 -1 2] 

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

Lattice of degree 4 and rank 1 over Integer Ring 

Basis matrix: 

[1 1 1 1] 

Inner product matrix: 

[1 0 0 0] 

[0 1 0 0] 

[0 0 1 0] 

[0 0 0 1] 

sage: IntegralLattice("A2", [[1,1]]) 

Lattice of degree 2 and rank 1 over Integer Ring 

Basis matrix: 

[1 1] 

Inner product matrix: 

[ 2 -1] 

[-1 2] 

 

TESTS:: 

 

sage: IntegralLattice(["A", 1, 1]) 

Traceback (most recent call last): 

... 

ValueError: lattices must be nondegenerate; use FreeQuadraticModule instead 

sage: IntegralLattice(["D", 3, 1]) 

Traceback (most recent call last): 

... 

ValueError: lattices must be nondegenerate; use FreeQuadraticModule instead 

""" 

if is_Matrix(data): 

inner_product_matrix = data 

elif isinstance(data, Integer): 

inner_product_matrix = matrix.identity(ZZ, data) 

elif data == "U" or data == "H": 

inner_product_matrix = matrix([[0,1],[1,0]]) 

else: 

inner_product_matrix = CartanMatrix(data) 

if basis is None: 

basis = matrix.identity(ZZ, inner_product_matrix.ncols()) 

if inner_product_matrix != inner_product_matrix.transpose(): 

raise ValueError("the inner product matrix must be symmetric\n%s" 

% inner_product_matrix) 

 

A = FreeQuadraticModule(ZZ, 

inner_product_matrix.ncols(), 

inner_product_matrix=inner_product_matrix) 

return FreeQuadraticModule_integer_symmetric(ambient=A, 

basis=basis, 

inner_product_matrix=inner_product_matrix, 

already_echelonized=False) 

 

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

# 

# Base class for Lattices 

# 

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

 

class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_basis_pid): 

r""" 

This class represents non-degenerate, integral, 

symmetric free quadratic `\ZZ`-modules. 

 

INPUT: 

 

- ``ambient`` -- an ambient free quadratic module 

- ``basis`` -- a list of elements of ambient or a matrix 

- ``inner_product_matrix`` -- a symmetric matrix over the rationals 

 

EXAMPLES:: 

 

sage: IntegralLattice("U",basis=[vector([1,1])]) 

Lattice of degree 2 and rank 1 over Integer Ring 

Basis matrix: 

[1 1] 

Inner product matrix: 

[0 1] 

[1 0] 

""" 

def __init__(self, ambient, basis, inner_product_matrix, 

check=True, already_echelonized=False): 

r""" 

Create the integral lattice spanned by ``basis`` in the ambient space. 

 

TESTS:: 

 

sage: L = IntegralLattice("U") 

sage: TestSuite(L).run() 

""" 

FreeQuadraticModule_submodule_with_basis_pid.__init__( 

self, 

ambient, 

basis, 

inner_product_matrix, 

check=check, 

already_echelonized=already_echelonized) 

if self.determinant() == 0: 

raise ValueError("lattices must be nondegenerate; " 

"use FreeQuadraticModule instead") 

if self.gram_matrix().base_ring() is not ZZ: 

if self.gram_matrix().denominator() != 1: 

raise ValueError("lattices must be integral; " 

"use FreeQuadraticModule instead") 

 

def _mul_(self, other, switch_sides=False): 

r""" 

Multiplication of the basis by ``other``. 

 

EXAMPLES:: 

 

sage: M = Matrix(ZZ,2,[1,2,2,-1]) 

sage: L = IntegralLattice(M) 

sage: 2 * L 

Lattice of degree 2 and rank 2 over Integer Ring 

Basis matrix: 

[2 0] 

[0 2] 

Inner product matrix: 

[ 1 2] 

[ 2 -1] 

sage: L * matrix(ZZ,2,[1,2,3,4]) 

Lattice of degree 2 and rank 2 over Integer Ring 

Basis matrix: 

[1 2] 

[3 4] 

Inner product matrix: 

[ 1 2] 

[ 2 -1] 

""" 

B = self.basis_matrix() 

B = other * B if switch_sides else B * other 

# check whether it is integral 

if other in ZZ or other.denominator()==1: 

return self.sublattice(B.rows()) 

else: 

return self.span(B.rows()) 

 

def _repr_(self): 

r""" 

The print representation of this lattice. 

 

EXAMPLES:: 

 

sage: A2 = IntegralLattice("A2") 

sage: A2 

Lattice of degree 2 and rank 2 over Integer Ring 

Basis matrix: 

[1 0] 

[0 1] 

Inner product matrix: 

[ 2 -1] 

[-1 2] 

""" 

if self.is_sparse(): 

s = "Sparse lattice of degree %s and rank %s over %s\n"%( 

self.degree(), self.rank(), self.base_ring()) + \ 

"Basis matrix:\n%s\n" % self.basis_matrix() + \ 

"Inner product matrix:\n%s" % self.inner_product_matrix() 

else: 

s = "Lattice of degree %s and rank %s over %s\n"%( 

self.degree(), self.rank(), self.base_ring()) + \ 

"Basis matrix:\n%s\n" % self.basis_matrix() + \ 

"Inner product matrix:\n%s" % self.inner_product_matrix() 

return s 

 

@cached_method 

def is_even(self): 

r""" 

Return whether the diagonal entries of the Gram matrix are even. 

 

EXAMPLES:: 

 

sage: G = Matrix(ZZ,2,2,[-1,1,1,2]) 

sage: L = IntegralLattice(G) 

sage: L.is_even() 

False 

sage: L = IntegralLattice("A2") 

sage: L.is_even() 

True 

""" 

return all(d % 2 == 0 for d in self.gram_matrix().diagonal()) 

 

@cached_method 

def dual_lattice(self): 

r""" 

Return the dual lattice as a :class:`FreeQuadraticModule` 

 

Let `L` be a lattice. Its dual lattice is 

 

.. MATH:: 

 

L^\vee = \{x \in L \otimes \QQ : (x, l) \in \ZZ \; \forall l \in L \}. 

 

EXAMPLES:: 

 

sage: L = IntegralLattice("A2") 

sage: Ldual=L.dual_lattice() 

sage: Ldual 

Free module of degree 2 and rank 2 over Integer Ring 

Echelon basis matrix: 

[1/3 2/3] 

[ 0 1] 

 

Since our lattices are always integral, a lattice is contained in its dual:: 

 

sage: L.is_submodule(Ldual) 

True 

""" 

return self.span(self.gram_matrix().inverse()*self.basis_matrix()) 

 

@cached_method 

def discriminant_group(self, s=0): 

r""" 

Return the discriminant group `L^\vee / L` of this lattice. 

 

INPUT: 

 

- ``s`` -- an integer (default: 0) 

 

OUTPUT: 

 

The `s` primary part of the discriminant group. 

If `s=0`, returns the whole discriminant group. 

 

EXAMPLES:: 

 

sage: L = IntegralLattice(Matrix(ZZ,2,2,[2,1,1,-2])*2) 

sage: L.discriminant_group() 

Finite quadratic module over Integer Ring with invariants (2, 10) 

Gram matrix of the quadratic form with values in Q/2Z: 

[ 1 1/2] 

[1/2 9/5] 

sage: L.discriminant_group(2) 

Finite quadratic module over Integer Ring with invariants (2, 2) 

Gram matrix of the quadratic form with values in Q/2Z: 

[ 1 1/2] 

[1/2 1] 

sage: L.discriminant_group(5) 

Finite quadratic module over Integer Ring with invariants (5,) 

Gram matrix of the quadratic form with values in Q/2Z: 

[6/5] 

 

TESTS:: 

 

sage: L = IntegralLattice("H") 

sage: L.discriminant_group() 

Finite quadratic module over Integer Ring with invariants () 

Gram matrix of the quadratic form with values in Q/2Z: 

[] 

""" 

from sage.modules.torsion_quadratic_module import TorsionQuadraticModule 

D = TorsionQuadraticModule(self.dual_lattice(), self) 

d = D.annihilator().gen() 

a = d.prime_to_m_part(s) 

Dp_gens = [a*g for g in D.gens()] 

return D.submodule(Dp_gens) 

 

def signature(self): 

r""" 

Return the signature of this lattice, which is defined as 

the difference between the number of positive eigenvalues and 

the number of negative eigenvalues in the Gram matrix. 

 

EXAMPLES:: 

 

sage: U = IntegralLattice("U") 

sage: U.signature() 

0 

""" 

sig = self.signature_pair() 

return sig[0] - sig[1] 

 

@cached_method 

def signature_pair(self): 

r""" 

Return the signature tuple `(n_+,n_-)` of this lattice. 

 

Here `n_+` (resp. `n_-`) is the number of positive (resp. negative) 

eigenvalues of the Gram matrix. 

 

EXAMPLES:: 

 

 

sage: A2 = IntegralLattice("A2") 

sage: A2.signature_pair() 

(2, 0) 

""" 

from sage.quadratic_forms.quadratic_form import QuadraticForm 

return QuadraticForm(QQ, self.gram_matrix()).signature_vector()[:2] 

 

def direct_sum(self, M): 

r""" 

Return the direct sum of this lattice with ``M``. 

 

INPUT: 

 

- ``M`` -- a module over `\ZZ` 

 

EXAMPLES:: 

 

sage: A = IntegralLattice(1) 

sage: A.direct_sum(A) 

Lattice of degree 2 and rank 2 over Integer Ring 

Basis matrix: 

[1 0] 

[0 1] 

Inner product matrix: 

[1 0] 

[0 1] 

""" 

IM = matrix.block_diagonal([self.inner_product_matrix(), 

M.inner_product_matrix()]) 

ambient = FreeQuadraticModule(ZZ, 

self.degree() + M.degree(), IM) 

smzero = matrix.zero(self.rank(), M.degree()) 

mszero = matrix.zero(M.rank(), self.degree()) 

basis = self.basis_matrix().augment(smzero).stack( 

mszero.augment(M.basis_matrix())) 

ipm = ambient.inner_product_matrix() 

return FreeQuadraticModule_integer_symmetric(ambient=ambient, 

basis=basis, 

inner_product_matrix=ipm, 

already_echelonized=False) 

 

def is_primitive(self, M): 

r""" 

Return whether ``M`` is a primitive submodule of this lattice. 

 

A `\ZZ`-submodule ``M`` of a `\ZZ`-module ``L`` is called primitive if 

the quotient ``L/M`` is torsion free. 

 

INPUT: 

 

- ``M`` -- a submodule of this lattice 

 

EXAMPLES:: 

 

sage: U = IntegralLattice("U") 

sage: L1 = U.span([vector([1,1])]) 

sage: L2 = U.span([vector([1,-1])]) 

sage: U.is_primitive(L1) 

True 

sage: U.is_primitive(L2) 

True 

sage: U.is_primitive(L1+L2) 

False 

 

We can also compute the index:: 

 

sage: (L1+L2).index_in(U) 

2 

""" 

return (gcd((self/M).invariants()) == 0) 

 

def orthogonal_complement(self, M): 

r""" 

Return the orthogonal complement of ``M`` in this lattice. 

 

INPUT: 

 

- ``M`` -- a module in the same ambient space or 

a list of elements of the ambient space 

 

EXAMPLES:: 

 

sage: H5 = Matrix(ZZ,2,[2,1,1,-2]) 

sage: L = IntegralLattice(H5) 

sage: S = L.span([vector([1,1])]) 

sage: L.orthogonal_complement(S) 

Lattice of degree 2 and rank 1 over Integer Ring 

Basis matrix: 

[1 3] 

Inner product matrix: 

[ 2 1] 

[ 1 -2] 

 

sage: L = IntegralLattice(2) 

sage: L.orthogonal_complement([vector(ZZ,[1,0])]) 

Lattice of degree 2 and rank 1 over Integer Ring 

Basis matrix: 

[0 1] 

Inner product matrix: 

[1 0] 

[0 1] 

""" 

from sage.modules.free_module import FreeModule_generic 

if not isinstance(M,FreeModule_generic): 

M = self.span(M) 

elif M.ambient_vector_space() != self.ambient_vector_space(): 

raise ValueError("M must have the same " 

"ambient vector space as this lattice") 

 

K = (self.inner_product_matrix() * M.basis_matrix().transpose()).kernel() 

K = self.span(K.basis()) 

K = K.base_extend(QQ) 

return self.sublattice(self.intersection(K).basis()) 

 

def sublattice(self, basis): 

r""" 

Return the sublattice spanned by ``basis``. 

 

INPUT: 

 

- ``basis`` -- A list of elements of this lattice. 

 

EXAMPLES:: 

 

sage: U = IntegralLattice("U") 

sage: S = U.sublattice([vector([1,1])]) 

sage: S 

Lattice of degree 2 and rank 1 over Integer Ring 

Basis matrix: 

[1 1] 

Inner product matrix: 

[0 1] 

[1 0] 

sage: U.sublattice([vector([1,-1])/2]) 

Traceback (most recent call last): 

... 

ValueError: lattices must be integral; use FreeQuadraticModule instead 

sage: S.sublattice([vector([1,-1])]) 

Traceback (most recent call last): 

... 

ValueError: the basis (= [(1, -1)]) does not span a submodule 

""" 

M = FreeQuadraticModule_integer_symmetric( 

ambient=self.ambient_module(), basis=basis, 

inner_product_matrix=self.inner_product_matrix(), 

already_echelonized=False) 

if not M.is_submodule(self): 

raise ValueError("the basis (= %s) does not span " 

"a submodule" % basis) 

return M 

 

def overlattice(self, gens): 

r""" 

Return the lattice spanned by this lattice and ``gens``. 

 

INPUT: 

 

- ``gens`` -- a list of elements or a rational matrix 

 

EXAMPLES:: 

 

sage: L = IntegralLattice(Matrix(ZZ,2,2,[2,0,0,2])) 

sage: M = L.overlattice([vector([1,1])/2]) 

sage: M.gram_matrix() 

[1 1] 

[1 2] 

""" 

basis = (self + self.span(gens)).basis() 

return FreeQuadraticModule_integer_symmetric( 

ambient=self.ambient_module(), basis=basis, 

inner_product_matrix=self.inner_product_matrix(), 

already_echelonized=False) 

 

def orthogonal_group(self, gens=None, is_finite=None): 

""" 

Return the orthogonal group of this lattice as a matrix group. 

 

The elements are isometries of the ambient vector space 

which preserve this lattice. They are represented by 

matrices with respect to the standard basis. 

 

INPUT: 

 

- ``gens`` -- a list of matrices (default:``None``) 

- ``is_finite`` -- bool (default: ``None``) If set to ``True``, 

then the group is placed in the category of finite groups. Sage does not check this. 

 

OUTPUT: 

 

The matrix group generated by ``gens``. 

If ``gens`` is not specified, then generators of the full 

orthogonal group of this lattice are computed. They are 

continued as the identity on the orthogonal complement of 

the lattice in its ambient space. Currently, we can only 

compute the orthogonal group for positive definite lattices. 

 

EXAMPLES:: 

 

sage: A4 = IntegralLattice("A4") 

sage: Aut = A4.orthogonal_group() 

sage: Aut 

Group of isometries with 5 generators ( 

[-1 0 0 0] [0 0 0 1] [-1 -1 -1 0] [ 1 0 0 0] [ 1 0 0 0] 

[ 0 -1 0 0] [0 0 1 0] [ 0 0 0 -1] [-1 -1 -1 -1] [ 0 1 0 0] 

[ 0 0 -1 0] [0 1 0 0] [ 0 0 1 1] [ 0 0 0 1] [ 0 0 1 1] 

[ 0 0 0 -1], [1 0 0 0], [ 0 1 0 0], [ 0 0 1 0], [ 0 0 0 -1] 

) 

 

The group acts from the right on the lattice and its discriminant group:: 

 

sage: x = A4.an_element() 

sage: g = Aut.an_element() 

sage: g 

[ 1 1 1 0] 

[ 0 0 -1 0] 

[ 0 0 1 1] 

[ 0 -1 -1 -1] 

sage: x*g 

(1, 1, 1, 0) 

sage: (x*g).parent()==A4 

True 

sage: (g*x).parent() 

Vector space of dimension 4 over Rational Field 

sage: y = A4.discriminant_group().an_element() 

sage: y*g 

(1) 

 

If the group is finite we can compute the usual things:: 

 

sage: Aut.order() 

240 

sage: conj = Aut.conjugacy_classes_representatives() 

sage: len(conj) 

14 

sage: Aut.structure_description() # optional - database_gap 

'C2 x S5' 

 

The lattice can live in a larger ambient space:: 

 

sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1])) 

sage: A2.orthogonal_group() 

Group of isometries with 3 generators ( 

[-1/3 2/3 2/3] [ 2/3 2/3 -1/3] [1 0 0] 

[ 2/3 -1/3 2/3] [ 2/3 -1/3 2/3] [0 0 1] 

[ 2/3 2/3 -1/3], [-1/3 2/3 2/3], [0 1 0] 

) 

 

It can be negative definite as well:: 

 

sage: A2m = IntegralLattice(-Matrix(ZZ,2,[2,1,1,2])) 

sage: G = A2m.orthogonal_group() 

sage: G.order() 

12 

 

If the lattice is indefinite, sage does not know how to compute generators. 

Can you teach it?:: 

 

sage: U = IntegralLattice(Matrix(ZZ,2,[0,1,1,0])) 

sage: U.orthogonal_group() 

Traceback (most recent call last): 

... 

NotImplementedError: currently, we can only compute generators for orthogonal groups over definite lattices. 

 

But we can define subgroups:: 

 

sage: S = IntegralLattice(Matrix(ZZ,2,[2, 3, 3, 2])) 

sage: f = Matrix(ZZ,2,[0,1,-1,3]) 

sage: S.orthogonal_group([f]) 

Group of isometries with 1 generator ( 

[ 0 1] 

[-1 3] 

) 

 

TESTS: 

 

We can handle the trivial group:: 

 

sage: S = IntegralLattice(Matrix(ZZ,2,[2, 3, 3, 2])) 

sage: S.orthogonal_group([]) 

Group of isometries with 1 generator ( 

[1 0] 

[0 1] 

) 

""" 

from sage.categories.groups import Groups 

from sage.groups.matrix_gps.isometries import GroupOfIsometries 

sig = self.signature_pair() 

if gens is None: 

gens = [] 

if sig[1]==0 or sig[0]==0: #definite 

from sage.quadratic_forms.quadratic_form import QuadraticForm 

is_finite = True 

# Compute transformation matrix to the ambient module. 

L = self.overlattice(self.ambient_module().gens()) 

Orthogonal = L.orthogonal_complement(self) 

B = self.basis_matrix().stack(Orthogonal.basis_matrix()) 

if sig[0] == 0: #negative definite 

q = QuadraticForm(ZZ, -2*self.gram_matrix()) 

else: # positve definite 

q = QuadraticForm(ZZ, 2*self.gram_matrix()) 

identity = matrix.identity(Orthogonal.rank()) 

for g in q.automorphism_group().gens(): 

g = g.matrix().T 

# We continue g as identity on the orthogonal complement. 

g = matrix.block_diagonal([g, identity]) 

g = B.inverse()*g*B 

gens.append(g) 

else: #indefinite 

raise NotImplementedError( 

"currently, we can only compute generators " 

"for orthogonal groups over definite lattices.") 

deg = self.degree() 

base = self.ambient_vector_space().base_ring() 

inv_bil = self.inner_product_matrix() 

if is_finite: 

cat = Groups().Finite() 

else: 

cat = Groups() 

D = self.discriminant_group() 

G = GroupOfIsometries(deg, 

base, 

gens, 

inv_bil, 

category=cat, 

invariant_submodule=self, 

invariant_quotient_module=D) 

return G 

 

automorphisms=orthogonal_group 

 

def genus(self): 

r""" 

Return the genus of this lattice. 

 

EXAMPLES:: 

 

sage: L = IntegralLattice("U") 

sage: L.genus() 

Genus of 

[0 1] 

[1 0] 

Genus symbol at 2: 1^2 

""" 

from sage.quadratic_forms.genera.genus import Genus 

return Genus(self.gram_matrix())