Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

1415

1416

1417

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1481

1482

1483

1484

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

r""" 

Littelmann paths 

 

AUTHORS: 

 

- Mark Shimozono, Anne Schilling (2012): Initial version 

- Anne Schilling (2013): Implemented 

:class:`~sage.combinat.crystals.littelmann_path.CrystalOfProjectedLevelZeroLSPaths` 

- Travis Scrimshaw (2016): Implemented 

:class:`~sage.combinat.crystals.littelmann_path.InfinityCrystalOfLSPaths` 

""" 

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

# Copyright (C) 2012 Mark Shimozono 

# Anne Schilling 

# 

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

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

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

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

from __future__ import print_function 

 

from sage.misc.cachefunc import cached_in_parent_method, cached_method 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.structure.element_wrapper import ElementWrapper 

from sage.structure.parent import Parent 

from sage.categories.highest_weight_crystals import HighestWeightCrystals 

from sage.categories.regular_crystals import RegularCrystals 

from sage.categories.classical_crystals import ClassicalCrystals 

from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets 

from sage.categories.loop_crystals import (RegularLoopCrystals, 

KirillovReshetikhinCrystals) 

from sage.combinat.root_system.cartan_type import CartanType 

from sage.combinat.root_system.weyl_group import WeylGroup 

from sage.rings.integer import Integer 

from sage.rings.rational_field import QQ 

from sage.combinat.root_system.root_system import RootSystem 

from sage.functions.other import floor 

from sage.misc.latex import latex 

 

 

class CrystalOfLSPaths(UniqueRepresentation, Parent): 

r""" 

Crystal graph of LS paths generated from the straight-line path to a given weight. 

 

INPUT: 

 

- ``cartan_type`` -- (optional) the Cartan type of a finite or affine root system 

- ``starting_weight`` -- a weight; if ``cartan_type`` is given, then the weight should 

be given as a list of coefficients of the fundamental weights, otherwise it should 

be given in the ``weight_space`` basis; for affine highest weight crystals, one needs 

to use the extended weight space. 

 

The crystal class of piecewise linear paths in the weight space, 

generated from a straight-line path from the origin to a given 

element of the weight lattice. 

 

OUTPUT: 

 

- a tuple of weights defining the directions of the piecewise linear segments 

 

EXAMPLES:: 

 

sage: R = RootSystem(['A',2,1]) 

sage: La = R.weight_space(extended = True).basis() 

sage: B = crystals.LSPaths(La[2]-La[0]); B 

The crystal of LS paths of type ['A', 2, 1] and weight -Lambda[0] + Lambda[2] 

 

sage: C = crystals.LSPaths(['A',2,1],[-1,0,1]); C 

The crystal of LS paths of type ['A', 2, 1] and weight -Lambda[0] + Lambda[2] 

sage: B == C 

True 

sage: c = C.module_generators[0]; c 

(-Lambda[0] + Lambda[2],) 

sage: [c.f(i) for i in C.index_set()] 

[None, None, (Lambda[1] - Lambda[2],)] 

 

sage: R = C.R; R 

Root system of type ['A', 2, 1] 

sage: Lambda = R.weight_space().basis(); Lambda 

Finite family {0: Lambda[0], 1: Lambda[1], 2: Lambda[2]} 

sage: b=C(tuple([-Lambda[0]+Lambda[2]])) 

sage: b==c 

True 

sage: b.f(2) 

(Lambda[1] - Lambda[2],) 

 

For classical highest weight crystals we can also compare the results with the tableaux implementation:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: sorted(C, key=str) 

[(-2*Lambda[1] + Lambda[2],), (-Lambda[1] + 1/2*Lambda[2], Lambda[1] - 1/2*Lambda[2]), 

(-Lambda[1] + 2*Lambda[2],), (-Lambda[1] - Lambda[2],), 

(1/2*Lambda[1] - Lambda[2], -1/2*Lambda[1] + Lambda[2]), (2*Lambda[1] - Lambda[2],), 

(Lambda[1] + Lambda[2],), (Lambda[1] - 2*Lambda[2],)] 

sage: C.cardinality() 

8 

sage: B = crystals.Tableaux(['A',2],shape=[2,1]) 

sage: B.cardinality() 

8 

sage: B.digraph().is_isomorphic(C.digraph()) 

True 

 

Make sure you use the weight space and not the weight lattice for your weights:: 

 

sage: R = RootSystem(['A',2,1]) 

sage: La = R.weight_lattice(extended = True).basis() 

sage: B = crystals.LSPaths(La[2]); B 

Traceback (most recent call last): 

... 

ValueError: Please use the weight space, rather than weight lattice for your weights 

 

REFERENCES: 

 

.. [Littelmann95] \P. Littelmann, Paths and root operators in representation 

theory. Ann. of Math. (2) 142 (1995), no. 3, 499-525. 

""" 

 

@staticmethod 

def __classcall_private__(cls, starting_weight, cartan_type = None, starting_weight_parent = None): 

""" 

Classcall to mend the input. 

 

Internally, the 

:class:`~sage.combinat.crystals.littelmann_path.CrystalOfLSPaths` code 

works with a ``starting_weight`` that is in the weight space associated 

to the crystal. The user can, however, also input a ``cartan_type`` 

and the coefficients of the fundamental weights as 

``starting_weight``. This code transforms the input into the right 

format (also necessary for UniqueRepresentation). 

 

TESTS:: 

 

sage: crystals.LSPaths(['A',2,1],[-1,0,1]) 

The crystal of LS paths of type ['A', 2, 1] and weight -Lambda[0] + Lambda[2] 

 

sage: R = RootSystem(['B',2,1]) 

sage: La = R.weight_space(extended=True).basis() 

sage: C = crystals.LSPaths(['B',2,1],[0,0,1]) 

sage: B = crystals.LSPaths(La[2]) 

sage: B is C 

True 

""" 

if cartan_type is not None: 

cartan_type, starting_weight = CartanType(starting_weight), cartan_type 

if cartan_type.is_affine(): 

extended = True 

else: 

extended = False 

 

R = RootSystem(cartan_type) 

P = R.weight_space(extended = extended) 

Lambda = P.basis() 

offset = R.index_set()[Integer(0)] 

starting_weight = P.sum(starting_weight[j-offset]*Lambda[j] for j in R.index_set()) 

if starting_weight_parent is None: 

starting_weight_parent = starting_weight.parent() 

else: 

# Both the weight and the parent of the weight are passed as arguments of init to be able 

# to distinguish between crystals with the extended and non-extended weight lattice! 

if starting_weight.parent() != starting_weight_parent: 

raise ValueError("The passed parent is not equal to parent of the inputted weight!") 

 

return super(CrystalOfLSPaths, cls).__classcall__(cls, starting_weight, starting_weight_parent = starting_weight_parent) 

 

def __init__(self, starting_weight, starting_weight_parent): 

""" 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2,1],[-1,0,1]); C 

The crystal of LS paths of type ['A', 2, 1] and weight -Lambda[0] + Lambda[2] 

sage: C.R 

Root system of type ['A', 2, 1] 

sage: C.weight 

-Lambda[0] + Lambda[2] 

sage: C.weight.parent() 

Extended weight space over the Rational Field of the Root system of type ['A', 2, 1] 

sage: C.module_generators 

((-Lambda[0] + Lambda[2],),) 

 

TESTS:: 

 

sage: C = crystals.LSPaths(['A',2,1], [-1,0,1]) 

sage: TestSuite(C).run() # long time 

sage: C = crystals.LSPaths(['E',6], [1,0,0,0,0,0]) 

sage: TestSuite(C).run() 

 

sage: R = RootSystem(['C',3,1]) 

sage: La = R.weight_space().basis() 

sage: LaE = R.weight_space(extended=True).basis() 

sage: B = crystals.LSPaths(La[0]) 

sage: BE = crystals.LSPaths(LaE[0]) 

sage: B is BE 

False 

sage: B.weight_lattice_realization() 

Weight space over the Rational Field of the Root system of type ['C', 3, 1] 

sage: BE.weight_lattice_realization() 

Extended weight space over the Rational Field of the Root system of type ['C', 3, 1] 

""" 

cartan_type = starting_weight.parent().cartan_type() 

self.R = RootSystem(cartan_type) 

self.weight = starting_weight 

if not self.weight.parent().base_ring().has_coerce_map_from(QQ): 

raise ValueError("Please use the weight space, rather than weight lattice for your weights") 

self._cartan_type = cartan_type 

self._name = "The crystal of LS paths of type %s and weight %s"%(cartan_type,starting_weight) 

if cartan_type.is_affine(): 

if all(i>=0 for i in starting_weight.coefficients()): 

Parent.__init__( self, category=(RegularCrystals(), 

HighestWeightCrystals(), 

InfiniteEnumeratedSets()) ) 

elif starting_weight.parent().is_extended(): 

Parent.__init__(self, category=(RegularCrystals(), InfiniteEnumeratedSets())) 

else: 

cl = self._cartan_type.classical().index_set() 

if sum(self.weight[i] for i in cl) == 1: 

cat = KirillovReshetikhinCrystals() 

else: 

cat = RegularLoopCrystals().Finite() 

Parent.__init__(self, category=cat) 

else: 

Parent.__init__(self, category=ClassicalCrystals()) 

 

if starting_weight == starting_weight.parent().zero(): 

initial_element = self(()) 

else: 

initial_element = self((starting_weight,)) 

self.module_generators = (initial_element,) 

 

def _repr_(self): 

""" 

EXAMPLES:: 

 

sage: crystals.LSPaths(['B',3],[1,1,0]) # indirect doctest 

The crystal of LS paths of type ['B', 3] and weight Lambda[1] + Lambda[2] 

""" 

return self._name 

 

def weight_lattice_realization(self): 

r""" 

Return weight lattice realization of ``self``. 

 

EXAMPLES:: 

 

sage: B = crystals.LSPaths(['B',3],[1,1,0]) 

sage: B.weight_lattice_realization() 

Weight space over the Rational Field of the Root system of type ['B', 3] 

sage: B = crystals.LSPaths(['B',3,1],[1,1,1,0]) 

sage: B.weight_lattice_realization() 

Extended weight space over the Rational Field of the Root system of type ['B', 3, 1] 

""" 

return self.weight.parent() 

 

class Element(ElementWrapper): 

""" 

TESTS:: 

 

sage: C = crystals.LSPaths(['E',6],[1,0,0,0,0,0]) 

sage: c = C.an_element() 

sage: TestSuite(c).run() 

""" 

 

def endpoint(self): 

r""" 

Computes the endpoint of the path. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: b = C.module_generators[0] 

sage: b.endpoint() 

Lambda[1] + Lambda[2] 

sage: b.f_string([1,2,2,1]) 

(-Lambda[1] - Lambda[2],) 

sage: b.f_string([1,2,2,1]).endpoint() 

-Lambda[1] - Lambda[2] 

sage: b.f_string([1,2]) 

(1/2*Lambda[1] - Lambda[2], -1/2*Lambda[1] + Lambda[2]) 

sage: b.f_string([1,2]).endpoint() 

0 

sage: b = C([]) 

sage: b.endpoint() 

0 

""" 

if len(self.value) > 0: 

return sum(self.value) 

return self.parent().weight.parent().zero() 

#return self.parent().R.weight_space(extended = self.parent().extended).zero() 

 

def compress(self): 

r""" 

Merges consecutive positively parallel steps present in the path. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: Lambda = C.R.weight_space().fundamental_weights(); Lambda 

Finite family {1: Lambda[1], 2: Lambda[2]} 

sage: c = C(tuple([1/2*Lambda[1]+1/2*Lambda[2], 1/2*Lambda[1]+1/2*Lambda[2]])) 

sage: c.compress() 

(Lambda[1] + Lambda[2],) 

""" 

if not self.value: 

return self 

q = [] 

curr = self.value[0] 

for i in range(1,len(self.value)): 

if positively_parallel_weights(curr,self.value[i]): 

curr = curr + self.value[i] 

else: 

q.append(curr) 

curr = self.value[i] 

q.append(curr) 

return self.parent()(tuple(q)) 

 

def split_step(self, which_step, r): 

r""" 

Splits indicated step into two parallel steps of relative lengths `r` and `1-r`. 

 

INPUT: 

 

- ``which_step`` -- a position in the tuple ``self`` 

- ``r`` -- a rational number between 0 and 1 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: b = C.module_generators[0] 

sage: b.split_step(0,1/3) 

(1/3*Lambda[1] + 1/3*Lambda[2], 2/3*Lambda[1] + 2/3*Lambda[2]) 

""" 

assert which_step in range(len(self.value)) 

v = self.value[which_step] 

return self.parent()(self.value[:which_step]+tuple([r*v,(1-r)*v])+self.value[which_step+1:]) 

 

def reflect_step(self, which_step, i): 

r""" 

Apply the `i`-th simple reflection to the indicated step in ``self``. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: b = C.module_generators[0] 

sage: b.reflect_step(0,1) 

(-Lambda[1] + 2*Lambda[2],) 

sage: b.reflect_step(0,2) 

(2*Lambda[1] - Lambda[2],) 

""" 

assert i in self.index_set() 

assert which_step in range(len(self.value)) 

return self.parent()(self.value[:which_step]+tuple([self.value[which_step].simple_reflection(i)])+self.value[which_step+1:]) 

 

def _string_data(self, i): 

r""" 

Computes the `i`-string data of ``self``. 

 

TESTS:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: b = C.module_generators[0] 

sage: b._string_data(1) 

() 

sage: b._string_data(2) 

() 

sage: b.f(1)._string_data(1) 

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

sage: b.f(1).f(2)._string_data(2) 

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

""" 

if len(self.value) == 0: 

return () 

# get the i-th simple coroot 

alv = self.value[0].parent().alphacheck()[i] 

# Compute the i-heights of the steps of vs 

steps = [v.scalar(alv) for v in self.value] 

# Get the wet step data 

minima_pos = [] 

ps = 0 

psmin = 0 

for ix in range(len(steps)): 

ps = ps + steps[ix] 

if ps < psmin: 

minima_pos.append((ix,ps,steps[ix])) 

psmin = ps 

return tuple(minima_pos) 

 

def epsilon(self, i): 

r""" 

Returns the distance to the beginning of the `i`-string. 

 

This method overrides the generic implementation in the category of crystals 

since this computation is more efficient. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: [c.epsilon(1) for c in C] 

[0, 1, 0, 0, 1, 0, 1, 2] 

sage: [c.epsilon(2) for c in C] 

[0, 0, 1, 2, 1, 1, 0, 0] 

""" 

return self.e(i,length_only=True) 

 

def phi(self, i): 

r""" 

Returns the distance to the end of the `i`-string. 

 

This method overrides the generic implementation in the category of crystals 

since this computation is more efficient. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: [c.phi(1) for c in C] 

[1, 0, 0, 1, 0, 2, 1, 0] 

sage: [c.phi(2) for c in C] 

[1, 2, 1, 0, 0, 0, 0, 1] 

""" 

return self.f(i,length_only=True) 

 

def e(self, i, power=1, to_string_end=False, length_only=False): 

r""" 

Returns the `i`-th crystal raising operator on ``self``. 

 

INPUT: 

 

- ``i`` -- element of the index set of the underlying root system 

- ``power`` -- positive integer; specifies the power of the raising operator 

to be applied (default: 1) 

- ``to_string_end`` -- boolean; if set to True, returns the dominant end of the 

`i`-string of ``self``. (default: False) 

- ``length_only`` -- boolean; if set to True, returns the distance to the dominant 

end of the `i`-string of ``self``. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: c = C[2]; c 

(1/2*Lambda[1] - Lambda[2], -1/2*Lambda[1] + Lambda[2]) 

sage: c.e(1) 

sage: c.e(2) 

(-Lambda[1] + 2*Lambda[2],) 

sage: c.e(2,to_string_end=True) 

(-Lambda[1] + 2*Lambda[2],) 

sage: c.e(1,to_string_end=True) 

(1/2*Lambda[1] - Lambda[2], -1/2*Lambda[1] + Lambda[2]) 

sage: c.e(1,length_only=True) 

0 

""" 

assert i in self.index_set() 

data = self._string_data(i) 

# compute the minimum i-height M on the path 

if len(data) == 0: 

M = 0 

else: 

M = data[-1][1] 

max_raisings = floor(-M) 

if length_only: 

return max_raisings 

# set the power of e_i to apply 

if to_string_end: 

p = max_raisings 

else: 

p = power 

if p > max_raisings: 

return None 

 

# copy the vector sequence into a working vector sequence ws 

#!!! ws only needs to be the actual vector sequence, not some 

#!!! fancy crystal graph element 

ws = self.parent()(self.value) 

 

ix = len(data)-1 

while ix >= 0 and data[ix][1] < M + p: 

# get the index of the current step to be processed 

j = data[ix][0] 

# find the i-height where the current step might need to be split 

if ix == 0: 

prev_ht = M + p 

else: 

prev_ht = min(data[ix-1][1],M+p) 

# if necessary split the step. Then reflect the wet part. 

if data[ix][1] - data[ix][2] > prev_ht: 

ws = ws.split_step(j,1-(prev_ht-data[ix][1])/(-data[ix][2])) 

ws = ws.reflect_step(j+1,i) 

else: 

ws = ws.reflect_step(j,i) 

ix = ix - 1 

#!!! at this point we should return the fancy crystal graph element 

#!!! corresponding to the humble vector sequence ws 

return self.parent()(ws.compress()) 

 

def dualize(self): 

r""" 

Returns dualized path. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: for c in C: 

....: print("{} {}".format(c, c.dualize())) 

(Lambda[1] + Lambda[2],) (-Lambda[1] - Lambda[2],) 

(-Lambda[1] + 2*Lambda[2],) (Lambda[1] - 2*Lambda[2],) 

(1/2*Lambda[1] - Lambda[2], -1/2*Lambda[1] + Lambda[2]) (1/2*Lambda[1] - Lambda[2], -1/2*Lambda[1] + Lambda[2]) 

(Lambda[1] - 2*Lambda[2],) (-Lambda[1] + 2*Lambda[2],) 

(-Lambda[1] - Lambda[2],) (Lambda[1] + Lambda[2],) 

(2*Lambda[1] - Lambda[2],) (-2*Lambda[1] + Lambda[2],) 

(-Lambda[1] + 1/2*Lambda[2], Lambda[1] - 1/2*Lambda[2]) (-Lambda[1] + 1/2*Lambda[2], Lambda[1] - 1/2*Lambda[2]) 

(-2*Lambda[1] + Lambda[2],) (2*Lambda[1] - Lambda[2],) 

""" 

if len(self.value) == 0: 

return self 

dual_path = [-v for v in self.value] 

dual_path.reverse() 

return self.parent()(tuple(dual_path)) 

 

def f(self, i, power=1, to_string_end=False, length_only=False): 

r""" 

Returns the `i`-th crystal lowering operator on ``self``. 

 

INPUT: 

 

- ``i`` -- element of the index set of the underlying root system 

- ``power`` -- positive integer; specifies the power of the lowering operator 

to be applied (default: 1) 

- ``to_string_end`` -- boolean; if set to True, returns the anti-dominant end of the 

`i`-string of ``self``. (default: False) 

- ``length_only`` -- boolean; if set to True, returns the distance to the anti-dominant 

end of the `i`-string of ``self``. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: c = C.module_generators[0] 

sage: c.f(1) 

(-Lambda[1] + 2*Lambda[2],) 

sage: c.f(1,power=2) 

sage: c.f(2) 

(2*Lambda[1] - Lambda[2],) 

sage: c.f(2,to_string_end=True) 

(2*Lambda[1] - Lambda[2],) 

sage: c.f(2,length_only=True) 

1 

 

sage: C = crystals.LSPaths(['A',2,1],[-1,-1,2]) 

sage: c = C.module_generators[0] 

sage: c.f(2,power=2) 

(Lambda[0] + Lambda[1] - 2*Lambda[2],) 

""" 

dual_path = self.dualize() 

dual_path = dual_path.e(i, power, to_string_end, length_only) 

if length_only: 

return dual_path 

if dual_path is None: 

return None 

return dual_path.dualize() 

 

def s(self, i): 

r""" 

Computes the reflection of ``self`` along the `i`-string. 

 

This method is more efficient than the generic implementation since it uses 

powers of `e` and `f` in the Littelmann model directly. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: c = C.module_generators[0] 

sage: c.s(1) 

(-Lambda[1] + 2*Lambda[2],) 

sage: c.s(2) 

(2*Lambda[1] - Lambda[2],) 

 

sage: C = crystals.LSPaths(['A',2,1],[-1,0,1]) 

sage: c = C.module_generators[0]; c 

(-Lambda[0] + Lambda[2],) 

sage: c.s(2) 

(Lambda[1] - Lambda[2],) 

sage: c.s(1) 

(-Lambda[0] + Lambda[2],) 

sage: c.f(2).s(1) 

(Lambda[0] - Lambda[1],) 

""" 

ph = self.phi(i) 

ep = self.epsilon(i) 

diff = ph - ep 

if diff >= 0: 

return self.f(i, power=diff) 

else: 

return self.e(i, power=-diff) 

 

def weight(self): 

""" 

Return the weight of ``self``. 

 

EXAMPLES:: 

 

sage: B = crystals.LSPaths(['A',1,1],[1,0]) 

sage: b = B.highest_weight_vector() 

sage: b.f(0).weight() 

-Lambda[0] + 2*Lambda[1] - delta 

""" 

P = self.parent().weight_lattice_realization() 

return sum([p for p in self.value], P.zero()) 

 

def _latex_(self): 

r""" 

Latex method for ``self``. 

 

EXAMPLES:: 

 

sage: C = crystals.LSPaths(['A',2],[1,1]) 

sage: c = C.module_generators[0] 

sage: c._latex_() 

[\Lambda_{1} + \Lambda_{2}] 

""" 

return [latex(p) for p in self.value] 

 

 

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

## Projected level-zero 

 

 

class CrystalOfProjectedLevelZeroLSPaths(CrystalOfLSPaths): 

r""" 

Crystal of projected level zero LS paths. 

 

INPUT: 

 

- ``weight`` -- a dominant weight of the weight space of an affine 

Kac-Moody root system 

 

When ``weight`` is just a single fundamental weight `\Lambda_r`, this 

crystal is isomorphic to a Kirillov-Reshetikhin (KR) crystal, see also 

:meth:`sage.combinat.crystals.kirillov_reshetikhin.KirillovReshetikhinFromLSPaths`. 

For general weights, it is isomorphic to a tensor product of 

single-column KR crystals. 

 

EXAMPLES:: 

 

sage: R = RootSystem(['C',3,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]+La[3]) 

sage: LS.cardinality() 

84 

sage: GLS = LS.digraph() 

 

sage: K1 = crystals.KirillovReshetikhin(['C',3,1],1,1) 

sage: K3 = crystals.KirillovReshetikhin(['C',3,1],3,1) 

sage: T = crystals.TensorProduct(K3,K1) 

sage: T.cardinality() 

84 

sage: GT = T.digraph() # long time 

sage: GLS.is_isomorphic(GT, edge_labels = True) # long time 

True 

 

TESTS:: 

 

sage: ct = CartanType(['A',4,2]).dual() 

sage: P = RootSystem(ct).weight_space() 

sage: La = P.fundamental_weights() 

sage: C = crystals.ProjectedLevelZeroLSPaths(La[1]) 

sage: sorted(C, key=str) 

[(-Lambda[0] + Lambda[1],), 

(-Lambda[1] + 2*Lambda[2],), 

(1/2*Lambda[1] - Lambda[2], -1/2*Lambda[1] + Lambda[2]), 

(Lambda[0] - Lambda[1],), 

(Lambda[1] - 2*Lambda[2],)] 

""" 

 

@staticmethod 

def __classcall_private__(cls, weight): 

""" 

Classcall to mend the input. 

 

Internally, the 

:class:`~sage.combinat.crystals.littelmann_path.CrystalOfProjectedLevelZeroLSPaths` 

uses a level zero weight, which is passed on to 

:class:`~sage.combinat.crystals.littelmann_path.CrystalOfLSPaths`. 

``weight`` is first coerced to a level zero weight. 

 

TESTS:: 

 

sage: R = RootSystem(['C',3,1]) 

sage: La = R.weight_space().basis() 

sage: C = crystals.ProjectedLevelZeroLSPaths(La[1] + La[2]) 

sage: C2 = crystals.ProjectedLevelZeroLSPaths(La[1] + La[2]) 

sage: C is C2 

True 

 

sage: R = RootSystem(['C',3,1]) 

sage: La = R.weight_space(extended = True).basis() 

sage: crystals.ProjectedLevelZeroLSPaths(La[1] + La[2]) 

Traceback (most recent call last): 

... 

ValueError: The weight should be in the non-extended weight lattice! 

""" 

if weight.parent().is_extended(): 

raise ValueError("The weight should be in the non-extended weight lattice!") 

La = weight.parent().basis() 

weight = weight - weight.level() * La[0] / La[0].level() 

return super(CrystalOfLSPaths, cls).__classcall__(cls, weight, starting_weight_parent = weight.parent()) 

 

@cached_method 

def maximal_vector(self): 

""" 

Return the maximal vector of ``self``. 

 

EXAMPLES:: 

 

sage: R = RootSystem(['A',2,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1]+La[2]) 

sage: LS.maximal_vector() 

(-3*Lambda[0] + 2*Lambda[1] + Lambda[2],) 

""" 

return self.module_generators[0] 

 

@cached_method 

def classically_highest_weight_vectors(self): 

r""" 

Return the classically highest weight vectors of ``self``. 

 

EXAMPLES:: 

 

sage: R = RootSystem(['A',2,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1]) 

sage: LS.classically_highest_weight_vectors() 

((-2*Lambda[0] + 2*Lambda[1],), 

(-Lambda[0] + Lambda[1], -Lambda[1] + Lambda[2])) 

""" 

I0 = self.cartan_type().classical().index_set() 

return tuple([x for x in self.list() if x.is_highest_weight(I0)]) 

 

def one_dimensional_configuration_sum(self, q=None, group_components=True): 

r""" 

Compute the one-dimensional configuration sum. 

 

INPUT: 

 

- ``q`` -- (default: ``None``) a variable or ``None``; if ``None``, 

a variable ``q`` is set in the code 

- ``group_components`` -- (default: ``True``) boolean; if ``True``, 

then the terms are grouped by classical component 

 

The one-dimensional configuration sum is the sum of the weights 

of all elements in the crystal weighted by the energy function. 

For untwisted types it uses the parabolic quantum Bruhat graph, 

see [LNSSS2013]_. In the dual-of-untwisted case, the parabolic 

quantum Bruhat graph is defined by exchanging the roles of roots 

and coroots (which is still conjectural at this point). 

 

EXAMPLES:: 

 

sage: R = RootSystem(['A',2,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1]) 

sage: LS.one_dimensional_configuration_sum() # long time 

B[-2*Lambda[1] + 2*Lambda[2]] + (q+1)*B[-Lambda[1]] 

+ (q+1)*B[Lambda[1] - Lambda[2]] + B[2*Lambda[1]] 

+ B[-2*Lambda[2]] + (q+1)*B[Lambda[2]] 

sage: R.<t> = ZZ[] 

sage: LS.one_dimensional_configuration_sum(t, False) # long time 

B[-2*Lambda[1] + 2*Lambda[2]] + (t+1)*B[-Lambda[1]] 

+ (t+1)*B[Lambda[1] - Lambda[2]] + B[2*Lambda[1]] 

+ B[-2*Lambda[2]] + (t+1)*B[Lambda[2]] 

 

TESTS:: 

 

sage: R = RootSystem(['B',3,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]+La[2]) 

sage: LS.one_dimensional_configuration_sum() == LS.one_dimensional_configuration_sum(group_components=False) # long time 

True 

sage: K1 = crystals.KirillovReshetikhin(['B',3,1],1,1) 

sage: K2 = crystals.KirillovReshetikhin(['B',3,1],2,1) 

sage: T = crystals.TensorProduct(K2,K1) 

sage: T.one_dimensional_configuration_sum() == LS.one_dimensional_configuration_sum() # long time 

True 

 

sage: R = RootSystem(['D',4,2]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]+La[2]) 

sage: K1 = crystals.KirillovReshetikhin(['D',4,2],1,1) 

sage: K2 = crystals.KirillovReshetikhin(['D',4,2],2,1) 

sage: T = crystals.TensorProduct(K2,K1) 

sage: T.one_dimensional_configuration_sum() == LS.one_dimensional_configuration_sum() # long time 

True 

 

sage: R = RootSystem(['A',5,2]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(3*La[1]) 

sage: K1 = crystals.KirillovReshetikhin(['A',5,2],1,1) 

sage: T = crystals.TensorProduct(K1,K1,K1) 

sage: T.one_dimensional_configuration_sum() == LS.one_dimensional_configuration_sum() # long time 

True 

""" 

if q is None: 

from sage.rings.all import QQ 

q = QQ['q'].gens()[0] 

#P0 = self.weight_lattice_realization().classical() 

P0 = RootSystem(self.cartan_type().classical()).weight_lattice() 

B = P0.algebra(q.parent()) 

def weight(x): 

w = x.weight() 

return P0.sum(int(c)*P0.basis()[i] for i,c in w if i in P0.index_set()) 

if group_components: 

G = self.digraph(index_set = self.cartan_type().classical().index_set()) 

C = G.connected_components() 

return sum(q**(c[0].energy_function())*B.sum(B(weight(b)) for b in c) for c in C) 

return B.sum(q**(b.energy_function())*B(weight(b)) for b in self) 

 

def is_perfect(self, level=1): 

r""" 

Check whether the crystal ``self`` is perfect (of level ``level``). 

 

INPUT: 

 

- ``level`` -- (default: 1) positive integer 

 

A crystal `\mathcal{B}` is perfect of level `\ell` if: 

 

#. `\mathcal{B}` is isomorphic to the crystal graph of a 

finite-dimensional `U_q^{'}(\mathfrak{g})`-module. 

#. `\mathcal{B}\otimes \mathcal{B}` is connected. 

#. There exists a `\lambda\in X`, such that 

`\mathrm{wt}(\mathcal{B}) \subset \lambda + \sum_{i\in I} \ZZ_{\le 0} \alpha_i` 

and there is a unique element in 

`\mathcal{B}` of classical weight `\lambda`. 

#. For all `b \in \mathcal{B}`, 

`\mathrm{level}(\varepsilon (b)) \geq \ell`. 

#. For all `\Lambda` dominant weights of level `\ell`, there exist 

unique elements `b_{\Lambda}, b^{\Lambda} \in \mathcal{B}`, such 

that `\varepsilon (b_{\Lambda}) = \Lambda = \varphi(b^{\Lambda})`. 

 

Points (1)-(3) are known to hold. This method checks points (4) and (5). 

 

EXAMPLES:: 

 

sage: C = CartanType(['C',2,1]) 

sage: R = RootSystem(C) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]) 

sage: LS.is_perfect() 

False 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[2]) 

sage: LS.is_perfect() 

True 

 

sage: C = CartanType(['E',6,1]) 

sage: R = RootSystem(C) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]) 

sage: LS.is_perfect() 

True 

sage: LS.is_perfect(2) 

False 

 

sage: C = CartanType(['D',4,1]) 

sage: R = RootSystem(C) 

sage: La = R.weight_space().basis() 

sage: all(crystals.ProjectedLevelZeroLSPaths(La[i]).is_perfect() for i in [1,2,3,4]) 

True 

 

sage: C = CartanType(['A',6,2]) 

sage: R = RootSystem(C) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]+La[2]) 

sage: LS.is_perfect() 

True 

sage: LS.is_perfect(2) 

False 

""" 

MPhi = [] 

for b in self: 

p = b.Phi().level() 

assert p == b.Epsilon().level() 

if p < level: 

return False 

if p == level: 

MPhi += [b] 

weights = [] 

I = self.index_set() 

rank = len(I) 

La = self.weight_lattice_realization().basis() 

from sage.combinat.integer_vector import IntegerVectors 

for n in range(1,level+1): 

for c in IntegerVectors(n, rank): 

w = sum(c[i]*La[i] for i in I) 

if w.level() == level: 

weights.append(w) 

return sorted([b.Phi() for b in MPhi]) == sorted(weights) 

 

class Element(CrystalOfLSPaths.Element): 

""" 

Element of a crystal of projected level zero LS paths. 

""" 

 

@cached_in_parent_method 

def scalar_factors(self): 

r""" 

Obtain the scalar factors for ``self``. 

 

Each LS path (or ``self``) can be written as a piecewise linear map 

 

.. MATH:: 

 

\pi(t) = \sum_{u'=1}^{u-1} (\sigma_{u'} - \sigma_{u'-1}) \nu_{u'} + (t-\sigma_{u-1}) \nu_{u} 

 

for `0<\sigma_1<\sigma_2<\cdots<\sigma_s=1` and `\sigma_{u-1} \le t \le \sigma_{u}` and `1 \le u \le s`. 

This method returns the tuple of `(\sigma_1,\ldots,\sigma_s)`. 

 

EXAMPLES:: 

 

sage: R = RootSystem(['C',3,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]+La[3]) 

sage: b = LS.module_generators[0] 

sage: b.scalar_factors() 

[1] 

sage: c = b.f(1).f(3).f(2) 

sage: c.scalar_factors() 

[1/3, 1] 

""" 

weight = self.parent().weight 

l = [] 

s = 0 

for c in self.value: 

supp = c.support() 

if supp: 

i = supp[0] 

for w in weight._orbit_iter(): 

# Check whether the vectors c and w are positive scalar multiples of each other 

# If i is not in the support of w, then the first 

# product is 0 

if c[i] * w[i] > 0 and c[i] * w == w[i] * c: 

s += c[i] / w[i] 

l += [s] 

break 

return l 

 

@cached_in_parent_method 

def weyl_group_representation(self): 

r""" 

Transforms the weights in the LS path ``self`` to elements in the Weyl group. 

 

Each LS path can be written as the piecewise linear map: 

 

.. MATH:: 

 

\pi(t) = \sum_{u'=1}^{u-1} (\sigma_{u'} - \sigma_{u'-1}) \nu_{u'} + (t-\sigma_{u-1}) \nu_{u} 

 

for `0<\sigma_1<\sigma_2<\cdots<\sigma_s=1` and `\sigma_{u-1} \le t \le \sigma_{u}` and `1 \le u \le s`. 

Each weight `\nu_u` is also associated to a Weyl group element. This method returns the list 

of Weyl group elements associated to the `\nu_u` for `1\le u\le s`. 

 

EXAMPLES:: 

 

sage: R = RootSystem(['C',3,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]+La[3]) 

sage: b = LS.module_generators[0] 

sage: c = b.f(1).f(3).f(2) 

sage: c.weyl_group_representation() 

[s2*s1*s3, s1*s3] 

""" 

cartan = self.parent().weight.parent().cartan_type().classical() 

I = cartan.index_set() 

W = WeylGroup(cartan, prefix='s', implementation="permutation") 

return [W.from_reduced_word(x.to_dominant_chamber(index_set=I, reduced_word=True)[1]) for x in self.value] 

 

@cached_in_parent_method 

def energy_function(self): 

r""" 

Return the energy function of ``self``. 

 

The energy function `D(\pi)` of the level zero LS path 

`\pi \in \mathbb{B}_\mathrm{cl}(\lambda)` requires a series 

of definitions; for simplicity the root system is assumed to 

be untwisted affine. 

 

The LS path `\pi` is a piecewise linear map from the unit 

interval `[0,1]` to the weight lattice. It is specified by 

"times" `0 = \sigma_0 < \sigma_1 < \dotsm < \sigma_s = 1` and 

"direction vectors" `x_u \lambda` where `x_u \in W / W_J` for 

`1 \le u \le s`, and `W_J` is the stabilizer of `\lambda` in 

the finite Weyl group `W`. Precisely, 

 

.. MATH:: 

 

\pi(t) = \sum_{u'=1}^{u-1} (\sigma_{u'}-\sigma_{u'-1}) 

x_{u'} \lambda + (t-\sigma_{u-1}) x_{u} \lambda 

 

for `1 \le u \le s` and `\sigma_{u-1} \le t \le \sigma_{u}`. 

 

For any `x,y \in W / W_J`, let 

 

.. MATH:: 

 

d: x = w_{0} \stackrel{\beta_{1}}{\leftarrow} 

w_{1} \stackrel{\beta_{2}}{\leftarrow} \cdots 

\stackrel{\beta_{n}}{\leftarrow} w_{n}=y 

 

be a shortest directed path in the parabolic quantum 

Bruhat graph. Define 

 

.. MATH:: 

 

\mathrm{wt}(d) := \sum_{\substack{1 \le k \le n 

\\ \ell(w_{k-1}) < \ell(w_k)}} 

\beta_{k}^{\vee}. 

 

It can be shown that `\mathrm{wt}(d)` depends only on `x,y`; 

call its value `\mathrm{wt}(x,y)`. The energy function `D(\pi)` 

is defined by 

 

.. MATH:: 

 

D(\pi) = -\sum_{u=1}^{s-1} (1-\sigma_{u}) \langle \lambda, 

\mathrm{wt}(x_u,x_{u+1}) \rangle. 

 

For more information, see [LNSSS2013]_. 

 

REFERENCES: 

 

.. [LNSSS2013] \C. Lenart, S. Naito, D. Sagaki, A. Schilling, M. Shimozono, 

*A uniform model for Kirillov-Reshetikhin crystals. Extended abstract.* 

DMTCS proc, to appear ( :arXiv:`1211.6019` ) 

 

.. NOTE:: 

 

In the dual-of-untwisted case the parabolic quantum 

Bruhat graph that is used is obtained by exchanging the 

roles of roots and coroots. Moreover, in the computation 

of the pairing the short roots must be doubled (or tripled 

for type `G`). This factor is determined by the translation 

factor of the corresponding root. Type `BC` is viewed as 

untwisted type, whereas the dual of `BC` is viewed as twisted. 

Except for the untwisted cases, these formulas are 

currently still conjectural. 

 

EXAMPLES:: 

 

sage: R = RootSystem(['C',3,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]+La[3]) 

sage: b = LS.module_generators[0] 

sage: c = b.f(1).f(3).f(2) 

sage: c.energy_function() 

0 

sage: c=b.e(0) 

sage: c.energy_function() 

1 

 

sage: R = RootSystem(['A',2,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1]) 

sage: b = LS.module_generators[0] 

sage: c = b.e(0) 

sage: c.energy_function() 

1 

sage: for c in sorted(LS, key=str): 

....: print("{} {}".format(c,c.energy_function())) 

(-2*Lambda[0] + 2*Lambda[1],) 0 

(-2*Lambda[1] + 2*Lambda[2],) 0 

(-Lambda[0] + Lambda[1], -Lambda[1] + Lambda[2]) 1 

(-Lambda[0] + Lambda[1], Lambda[0] - Lambda[2]) 1 

(-Lambda[1] + Lambda[2], -Lambda[0] + Lambda[1]) 0 

(-Lambda[1] + Lambda[2], Lambda[0] - Lambda[2]) 1 

(2*Lambda[0] - 2*Lambda[2],) 0 

(Lambda[0] - Lambda[2], -Lambda[0] + Lambda[1]) 0 

(Lambda[0] - Lambda[2], -Lambda[1] + Lambda[2]) 0 

 

The next test checks that the energy function is constant 

on classically connected components:: 

 

sage: R = RootSystem(['A',2,1]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1]+La[2]) 

sage: G = LS.digraph(index_set=[1,2]) 

sage: C = G.connected_components() 

sage: [all(c[0].energy_function()==a.energy_function() for a in c) for c in C] 

[True, True, True, True] 

 

sage: R = RootSystem(['D',4,2]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[2]) 

sage: J = R.cartan_type().classical().index_set() 

sage: hw = [x for x in LS if x.is_highest_weight(J)] 

sage: [(x.weight(), x.energy_function()) for x in hw] 

[(-2*Lambda[0] + Lambda[2], 0), (-2*Lambda[0] + Lambda[1], 1), (0, 2)] 

sage: G = LS.digraph(index_set=J) 

sage: C = G.connected_components() 

sage: [all(c[0].energy_function()==a.energy_function() for a in c) for c in C] 

[True, True, True] 

 

sage: R = RootSystem(CartanType(['G',2,1]).dual()) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(La[1]+La[2]) 

sage: G = LS.digraph(index_set=[1,2]) 

sage: C = G.connected_components() 

sage: [all(c[0].energy_function()==a.energy_function() for a in c) for c in C] # long time 

[True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True] 

 

sage: ct = CartanType(['BC',2,2]).dual() 

sage: R = RootSystem(ct) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1]+La[2]) 

sage: G = LS.digraph(index_set=R.cartan_type().classical().index_set()) 

sage: C = G.connected_components() 

sage: [all(c[0].energy_function()==a.energy_function() for a in c) for c in C] # long time 

[True, True, True, True, True, True, True, True, True, True, True] 

 

sage: R = RootSystem(['BC',2,2]) 

sage: La = R.weight_space().basis() 

sage: LS = crystals.ProjectedLevelZeroLSPaths(2*La[1]+La[2]) 

sage: G = LS.digraph(index_set=R.cartan_type().classical().index_set()) 

sage: C = G.connected_components() 

sage: [all(c[0].energy_function()==a.energy_function() for a in c) for c in C] # long time 

[True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, 

True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True] 

""" 

weight = self.parent().weight 

P = weight.parent() 

c_weight = P.classical()(weight) 

ct = P.cartan_type() 

cartan = ct.classical() 

Qv = RootSystem(cartan).coroot_lattice() 

W = WeylGroup(cartan, prefix='s', implementation="permutation") 

J = tuple(weight.weyl_stabilizer()) 

L = self.weyl_group_representation() 

if ct.is_untwisted_affine() or ct.type() == 'BC': 

untwisted = True 

G = W.quantum_bruhat_graph(J) 

else: 

untwisted = False 

cartan_dual = cartan.dual() 

Wd = WeylGroup(cartan_dual, prefix='s', implementation="permutation") 

G = Wd.quantum_bruhat_graph(J) 

Qd = RootSystem(cartan_dual).root_lattice() 

dualize = lambda x: Qv.from_vector(x.to_vector()) 

L = [Wd.from_reduced_word(x.reduced_word()) for x in L] 

def stretch_short_root(a): 

# stretches roots by translation factor 

if ct.dual().type() == 'BC': 

return ct.c()[a.to_simple_root()]*a 

return ct.dual().c()[a.to_simple_root()]*a 

#if a.is_short_root(): 

# if cartan_dual.type() == 'G': 

# return 3*a 

# else: 

# return 2*a 

#return a 

paths = [G.shortest_path(L[i+1],L[i]) for i in range(len(L)-1)] 

paths_labels = [[G.edge_label(p[i],p[i+1]) for i in range(len(p)-1) if p[i].length()+1 != p[i+1].length()] for p in paths] 

scalars = self.scalar_factors() 

if untwisted: 

s = sum((1-scalars[i])*c_weight.scalar( Qv.sum(root.associated_coroot() 

for root in paths_labels[i]) ) for i in range(len(paths_labels))) 

if ct.type() == 'BC': 

return 2*s 

else: 

return s 

else: 

s = sum((1-scalars[i])*c_weight.scalar( dualize (Qd.sum(stretch_short_root(root) for root in paths_labels[i])) ) for i in range(len(paths_labels))) 

if ct.dual().type() == 'BC': 

return s/2 

else: 

return s 

 

 

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

## B(\infty) 

 

 

class InfinityCrystalOfLSPaths(UniqueRepresentation, Parent): 

r""" 

LS path model for `\mathcal{B}(\infty)`. 

 

Elements of `\mathcal{B}(\infty)` are equivalence classes of paths `[\pi]` 

in `\mathcal{B}(k\rho)` for `k\gg 0`, where `\rho` is the Weyl vector. A 

canonical representative for an element of `\mathcal{B}(\infty)` is chosen 

by taking `k` to be minimal such that the endpoint of `\pi` is strictly 

dominant but its representative in `\mathcal{B}((k-1)\rho)` is on the wall 

of the dominant chamber. 

 

REFERENCES: 

 

.. [LZ11] Bin Li and Hechun Zhang. 

*Path realization of crystal* `B(\infty)`. 

Front. Math. China, **6** (4), (2011) pp. 689--706. 

:doi:`10.1007/s11464-010-0073-x` 

""" 

@staticmethod 

def __classcall_private__(cls, cartan_type): 

""" 

Normalize input to ensure a unique representation. 

 

EXAMPLES:: 

 

sage: B1 = crystals.infinity.LSPaths(['A',4]) 

sage: B2 = crystals.infinity.LSPaths('A4') 

sage: B3 = crystals.infinity.LSPaths(CartanType(['A',4])) 

sage: B1 is B2 and B2 is B3 

True 

""" 

cartan_type = CartanType(cartan_type) 

return super(InfinityCrystalOfLSPaths, cls).__classcall__(cls, cartan_type) 

 

def __init__(self, cartan_type): 

""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: B = crystals.infinity.LSPaths(['D',4,3]) 

sage: TestSuite(B).run(max_runs=500) 

sage: B = crystals.infinity.LSPaths(['B',3]) 

sage: TestSuite(B).run() # long time 

""" 

Parent.__init__(self, category=(HighestWeightCrystals(), 

InfiniteEnumeratedSets())) 

self._cartan_type = cartan_type 

self.module_generators = (self.module_generator(),) 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: crystals.infinity.LSPaths(['A',4]) 

The infinity crystal of LS paths of type ['A', 4] 

""" 

return "The infinity crystal of LS paths of type %s" % self._cartan_type 

 

@cached_method 

def module_generator(self): 

r""" 

Return the module generator (or highest weight element) of ``self``. 

 

The module generator is the unique path 

`\pi_\infty\colon t \mapsto t\rho`, for `t \in [0,\infty)`. 

 

EXAMPLES:: 

 

sage: B = crystals.infinity.LSPaths(['A',6,2]) 

sage: mg = B.module_generator(); mg 

(Lambda[0] + Lambda[1] + Lambda[2] + Lambda[3],) 

sage: mg.weight() 

0 

""" 

rho = self.weight_lattice_realization().rho() 

return self((rho,)) 

 

def weight_lattice_realization(self): 

""" 

Return the weight lattice realization of ``self``. 

 

EXAMPLES:: 

 

sage: B = crystals.infinity.LSPaths(['C',4]) 

sage: B.weight_lattice_realization() 

Weight space over the Rational Field of the Root system of type ['C', 4] 

""" 

if self._cartan_type.is_affine(): 

return self._cartan_type.root_system().weight_space(extended=True) 

return self._cartan_type.root_system().weight_space() 

 

class Element(CrystalOfLSPaths.Element): 

 

def e(self, i, power=1, length_only=False): 

r""" 

Return the `i`-th crystal raising operator on ``self``. 

 

INPUT: 

 

- ``i`` -- element of the index set 

- ``power`` -- (default: 1) positive integer; specifies the 

power of the lowering operator to be applied 

- ``length_only`` -- (default: ``False``) boolean; if ``True``, 

then return the distance to the anti-dominant end of the 

`i`-string of ``self`` 

 

EXAMPLES:: 

 

sage: B = crystals.infinity.LSPaths(['B',3,1]) 

sage: mg = B.module_generator() 

sage: mg.e(0) 

sage: mg.e(1) 

sage: mg.e(2) 

sage: x = mg.f_string([1,0,2,1,0,2,1,1,0]) 

sage: all(x.f(i).e(i) == x for i in B.index_set()) 

True 

sage: all(x.e(i).f(i) == x for i in B.index_set() if x.epsilon(i) > 0) 

True 

 

TESTS: 

 

Check that this works in affine types:: 

 

sage: B = crystals.infinity.LSPaths(['A',3,1]) 

sage: mg = B.highest_weight_vector() 

sage: x = mg.f_string([0,1,2,3]) 

sage: x.e_string([3,2,1,0]) == mg 

True 

 

We check that :meth:`epsilon` works:: 

 

sage: B = crystals.infinity.LSPaths(['D',4]) 

sage: mg = B.highest_weight_vector() 

sage: x = mg.f_string([1,3,4,2,4,3,2,1,4]) 

sage: [x.epsilon(i) for i in B.index_set()] 

[1, 1, 0, 1] 

 

Check that :trac:`21671` is fixed:: 

 

sage: B = crystals.infinity.LSPaths(['G',2]) 

sage: len(B.subcrystal(max_depth=7)) 

116 

""" 

ret = super(InfinityCrystalOfLSPaths.Element, self).e(i, power=power, 

length_only=length_only) 

if ret is None: 

return None 

if length_only: 

return ret 

WLR = self.parent().weight_lattice_realization() 

value = list(ret.value) 

endpoint = sum(p for p in value) 

rho = WLR.rho() 

h = WLR.simple_coroots() 

I = self.parent().index_set() 

 

if not positively_parallel_weights(value[-1], rho): 

value.append(rho) 

endpoint += rho 

 

while any(endpoint.scalar(alc) < 1 for alc in h): 

value[-1] += rho 

endpoint += rho 

while all(endpoint.scalar(alc) > 1 for alc in h) and value[-1] != WLR.zero(): 

value[-1] -= rho 

endpoint -= rho 

while value[-1] == WLR.zero(): 

value.pop() 

ret.value = tuple(value) 

return ret 

 

def f(self, i, power=1, length_only=False): 

r""" 

Return the `i`-th crystal lowering operator on ``self``. 

 

INPUT: 

 

- ``i`` -- element of the index set 

- ``power`` -- (default: 1) positive integer; specifies the 

power of the lowering operator to be applied 

- ``length_only`` -- (default: ``False``) boolean; if ``True``, 

then return the distance to the anti-dominant end of the 

`i`-string of ``self`` 

 

EXAMPLES:: 

 

sage: B = crystals.infinity.LSPaths(['D',3,2]) 

sage: mg = B.highest_weight_vector() 

sage: mg.f(1) 

(3*Lambda[0] - Lambda[1] + 3*Lambda[2], 

2*Lambda[0] + 2*Lambda[1] + 2*Lambda[2]) 

sage: mg.f(2) 

(Lambda[0] + 2*Lambda[1] - Lambda[2], 

2*Lambda[0] + 2*Lambda[1] + 2*Lambda[2]) 

sage: mg.f(0) 

(-Lambda[0] + 2*Lambda[1] + Lambda[2] - delta, 

2*Lambda[0] + 2*Lambda[1] + 2*Lambda[2]) 

""" 

dual_path = self.dualize() 

dual_path = super(InfinityCrystalOfLSPaths.Element, dual_path).e(i, power, length_only=length_only) 

if length_only: 

return dual_path 

if dual_path is None: 

return None 

ret = dual_path.dualize() 

WLR = self.parent().weight_lattice_realization() 

value = list(ret.value) 

endpoint = sum(p for p in value) 

rho = WLR.rho() 

h = WLR.simple_coroots() 

 

if not positively_parallel_weights(value[-1], rho): 

value.append(rho) 

endpoint += rho 

 

while any(endpoint.scalar(alc) < 1 for alc in h): 

value[-1] += rho 

endpoint += rho 

while all(endpoint.scalar(alc) > 1 for alc in h) and value[-1] != WLR.zero(): 

value[-1] -= rho 

endpoint -= rho 

while value[-1] == WLR.zero(): 

value.pop() 

ret.value = tuple(value) 

return ret 

 

@cached_method 

def weight(self): 

""" 

Return the weight of ``self``. 

 

.. TODO:: 

 

This is a generic algorithm. We should find a better 

description and implement it. 

 

EXAMPLES:: 

 

sage: B = crystals.infinity.LSPaths(['E',6]) 

sage: mg = B.highest_weight_vector() 

sage: f_seq = [1,4,2,6,4,2,3,1,5,5] 

sage: x = mg.f_string(f_seq) 

sage: x.weight() 

-3*Lambda[1] - 2*Lambda[2] + 2*Lambda[3] + Lambda[4] - Lambda[5] 

 

sage: al = B.cartan_type().root_system().weight_space().simple_roots() 

sage: x.weight() == -sum(al[i] for i in f_seq) 

True 

""" 

WLR = self.parent().weight_lattice_realization() 

alpha = WLR.simple_roots() 

return -WLR.sum(alpha[i] for i in self.to_highest_weight()[1]) 

 

def phi(self,i): 

r""" 

Return `\varphi_i` of ``self``. 

 

Let `\pi \in \mathcal{B}(\infty)`. Define 

 

.. MATH:: 

 

\varphi_i(\pi) := \varepsilon_i(\pi) + \langle h_i, 

\mathrm{wt}(\pi) \rangle, 

 

where `h_i` is the `i`-th simple coroot and `\mathrm{wt}(\pi)` 

is the :meth:`weight` of `\pi`. 

 

INPUT: 

 

- ``i`` -- element of the index set 

 

EXAMPLES:: 

 

sage: B = crystals.infinity.LSPaths(['D',4]) 

sage: mg = B.highest_weight_vector() 

sage: x = mg.f_string([1,3,4,2,4,3,2,1,4]) 

sage: [x.phi(i) for i in B.index_set()] 

[-1, 4, -2, -3] 

""" 

WLR = self.parent().weight_lattice_realization() 

h = WLR.simple_coroots() 

return self.epsilon(i) + WLR(self.weight()).scalar(h[i]) 

 

 

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

## Helper functions 

 

 

def positively_parallel_weights(v, w): 

""" 

Check whether the vectors ``v`` and ``w`` are positive scalar 

multiples of each other. 

 

EXAMPLES:: 

 

sage: from sage.combinat.crystals.littelmann_path import positively_parallel_weights 

sage: La = RootSystem(['A',5,2]).weight_space(extended=True).fundamental_weights() 

sage: rho = sum(La) 

sage: positively_parallel_weights(rho, 4*rho) 

True 

sage: positively_parallel_weights(4*rho, rho) 

True 

sage: positively_parallel_weights(rho, -rho) 

False 

sage: positively_parallel_weights(rho, La[1] + La[2]) 

False 

""" 

supp = v.support() 

if len(supp) > 0: 

i = supp[0] 

if v[i]*w[i] > 0 and v[i]*w == w[i]*v: 

return True 

return False