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

r""" 

Kleber Trees 

 

A Kleber tree is a tree of weights generated by Kleber's algorithm 

[Kleber1]_. The nodes correspond to the weights in the positive Weyl chamber 

obtained by subtracting a (non-zero) positive root. The edges are labeled by 

the coefficients of the roots of the difference. 

 

AUTHORS: 

 

- Travis Scrimshaw (2011-05-03): Initial version 

- Travis Scrimshaw (2013-02-13): Added support for virtual trees and improved 

`\LaTeX` output 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KleberTree(['A', 3, 1], [[3,2], [2,1], [1,1], [1,1]]) 

Kleber tree of Cartan type ['A', 3, 1] and B = ((3, 2), (2, 1), (1, 1), (1, 1)) 

sage: KleberTree(['D', 4, 1], [[2,2]]) 

Kleber tree of Cartan type ['D', 4, 1] and B = ((2, 2),) 

 

TESTS:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A', 3, 1], [[3,2], [2,1], [1,1], [1,1]]) 

sage: sorted((x.weight.to_vector(), x.up_root.to_vector()) for x in KT.list()) 

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

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

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

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

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

((1, 0, 3), (1, 1, 0)), 

((1, 1, 1), (1, 1, 1)), 

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

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

((3, 0, 1), (0, 1, 1))] 

 

sage: KT = KleberTree(['A', 7, 1], [[3,2], [2,1], [1,1]]) 

sage: KT 

Kleber tree of Cartan type ['A', 7, 1] and B = ((3, 2), (2, 1), (1, 1)) 

sage: sorted((x.weight.to_vector(), x.up_root.to_vector()) for x in KT.list()) 

[((0, 0, 0, 1, 1, 0, 0), (1, 1, 1, 0, 0, 0, 0)), 

((0, 0, 1, 0, 0, 1, 0), (2, 3, 3, 2, 1, 0, 0)), 

((0, 0, 3, 0, 0, 0, 0), (1, 1, 0, 0, 0, 0, 0)), 

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

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

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

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

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

""" 

 

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

# Copyright (C) 2011, 2012 Travis Scrimshaw <tscrim@ucdavis.edu> 

# 

# 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 six.moves import range 

import itertools 

 

from sage.misc.lazy_attribute import lazy_attribute 

from sage.misc.cachefunc import cached_method 

from sage.misc.latex import latex 

from sage.misc.misc_c import prod 

from sage.arith.all import binomial 

from sage.rings.integer import Integer 

from sage.rings.all import ZZ 

 

from sage.structure.parent import Parent 

from sage.structure.element import Element 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.structure.richcmp import richcmp_not_equal, richcmp 

from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets 

from sage.modules.free_module import FreeModule 

 

from sage.combinat.root_system.cartan_type import CartanType 

 

from sage.graphs.digraph import DiGraph 

from sage.graphs.dot2tex_utils import have_dot2tex 

 

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

# Latex method for viewing the trees # 

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

 

def _draw_tree(tree_node, node_label=True, style_point=None, style_node='fill=white', style_line=None, 

hspace=2.5, vspace=-2.5, start=[0.,0.], rpos=[0.,0.], node_id=0, node_prefix='T', 

edge_labels=True, use_vector_notation=False): 

r""" 

Return the tikz latex for drawing the Kleber tree. 

 

AUTHORS: 

 

- Viviane Pons (2013-02-13): Initial version 

- Travis Scrimshaw (2013-03-02): Modified to work with Kleber tree output 

 

.. WARNING:: 

 

Internal latex function. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A',3,1], [[3,2],[1,1]]) 

sage: latex(KT) # indirect doctest 

\begin{tikzpicture} 

\node[fill=white] (T0) at (0.000, 0.000){$V_{\omega_{1}+2\omega_{3}}$}; 

\node (T00) at (0.000, -2.500){$V_{\omega_{3}}$}; 

\draw (T0) to node[sloped,above]{\tiny $\alpha_{1} + \alpha_{2} + \alpha_{3}$} (T00); 

\end{tikzpicture} 

""" 

draw_point = lambda point: '(%.3f, %.3f)'%(point[0],point[1]) 

if not tree_node.children: 

r = '' 

node_name = node_prefix + str(node_id) 

r = "\\node (%s) at %s"%(node_name, draw_point(start)) 

if node_label: 

r += "{$%s$};\n"%tree_node._latex_() 

else: 

r += "{};\n" 

rpos[0] = start[0] 

rpos[1] = start[1] 

start[0] += hspace 

return r 

 

node_name = node_prefix + str(node_id) 

if style_line is None: 

style_line_str = '' 

else: 

style_line_str = "[%s]"%style_line 

if node_label: 

node_place_str = '' 

else: 

node_place_str = ".center" 

 

nb_children = len(tree_node.children) 

half = nb_children // 2 

children_str = '' 

pos = [start[0],start[1]] 

start[1] += vspace 

lines_str = '' 

 

# Getting children string 

for i in range(nb_children): 

if i == half and nb_children % 2 == 0: 

pos[0] = start[0] 

start[0] += hspace 

if i == half+1 and nb_children % 2 == 1: 

pos[0] = rpos[0] 

child = tree_node.children[i] 

children_str += _draw_tree(child, node_label=node_label, style_node=style_node, style_point=style_point, style_line=style_line, hspace=hspace, vspace=vspace, start=start, rpos=rpos, node_id=i, node_prefix=node_name, edge_labels=edge_labels, use_vector_notation=use_vector_notation) 

if edge_labels: 

if use_vector_notation: 

edge_str = latex(child.up_root.to_vector()) 

else: 

edge_str = latex(child.up_root) 

lines_str += "\\draw%s (%s%s) to node[sloped,above]{\\tiny $%s$} (%s%s%s);\n"%(style_line_str, node_name, node_place_str, edge_str, node_name, i, node_place_str) 

else: 

lines_str += "\\draw%s (%s%s) -- (%s%s%s);\n"%(style_line_str, node_name, node_place_str, node_name, i, node_place_str) 

 

#drawing root 

if style_node is None: 

style_node = '' 

else: 

style_node = "[%s]"%style_node 

if style_point is None: 

style_point = '' 

else: 

style_point = "[%s]"%style_point 

start[1] -= vspace 

rpos[0] = pos[0] 

rpos[1] = pos[1] 

point_str = '' 

node_str = "\\node%s (%s) at %s"%(style_node, node_name, draw_point(pos)) 

if node_label: 

node_str += "{$%s$};\n"%tree_node._latex_() 

else: 

node_str += "{};\n" 

point_str = "\\draw%s (%s) circle;\n"%(style_point, node_name) 

 

res = node_str 

res += children_str 

res += lines_str 

res += point_str 

return res 

 

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

# Kleber tree nodes # 

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

 

class KleberTreeNode(Element): 

r""" 

A node in the Kleber tree. 

 

This class is meant to be used internally by the Kleber tree class and 

should not be created directly by the user. 

 

For more on the Kleber tree and the nodes, see :class:`KleberTree`. 

 

The dominating root is the ``up_root`` which is the difference 

between the parent node's weight and this node's weight. 

 

INPUT: 

 

- ``parent_obj`` -- The parent object of this element 

- ``node_weight`` -- The weight of this node 

- ``dominant_root`` -- The dominating root 

- ``parent_node`` -- (default:None) The parent node of this node 

""" 

def __init__(self, parent_obj, node_weight, dominant_root, parent_node=None): 

r""" 

Initialize the tree node. 

 

TESTS:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

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

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

sage: KT = KleberTree(['A', 2, 1], [[1,1]]) 

sage: parent = KT(WS.sum_of_terms([(1,5), (2,2)]), R.zero()) 

sage: parent 

Kleber tree node with weight [5, 2] and upwards edge root [0, 0] 

sage: parent.parent_node 

sage: child = KT(WS.sum_of_terms([(1,3), (2,1)]), R.sum_of_terms([(1,1), (2,2)]), parent) 

sage: child 

Kleber tree node with weight [3, 1] and upwards edge root [1, 2] 

sage: child.parent_node 

Kleber tree node with weight [5, 2] and upwards edge root [0, 0] 

sage: TestSuite(parent).run() 

""" 

self.parent_node = parent_node 

self.children = [] 

self.weight = node_weight 

self.up_root = dominant_root 

Element.__init__(self, parent_obj) 

 

@lazy_attribute 

def depth(self): 

""" 

Return the depth of this node in the tree. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

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

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

sage: KT = KleberTree(['A', 2, 1], [[1,1]]) 

sage: n = KT(WS.sum_of_terms([(1,5), (2,2)]), R.zero()) 

sage: n.depth 

0 

sage: n2 = KT(WS.sum_of_terms([(1,5), (2,2)]), R.zero(), n) 

sage: n2.depth 

1 

""" 

depth = -1 # Offset 

cur = self 

while cur is not None: 

depth += 1 

cur = cur.parent_node 

 

return depth 

 

@cached_method 

def multiplicity(self): 

r""" 

Return the multiplicity of ``self``. 

 

The multiplicity of a node `x` of depth `d` weight `\lambda` in a 

simply-laced Kleber tree is equal to: 

 

.. MATH:: 

 

\prod_{i > 0} \prod_{a \in \overline{I}} 

\binom{p_i^{(a)} + m_i^{(a)}}{p_i^{(a)}} 

 

Recall that 

 

.. MATH:: 

 

m_i^{(a)} = \left( \lambda^{(i-1)} - 2 \lambda^{(i)} + 

\lambda^{(i+1)} \mid \overline{\Lambda}_a \right), 

 

p_i^{(a)} = \left( \alpha_a \mid \lambda^{(i)} \right) 

- \sum_{j > i} (j - i) L_j^{(a)}, 

 

where `\lambda^{(i)}` is the weight node at depth `i` in the path 

to `x` from the root and we set `\lambda^{(j)} = \lambda` for all 

`j \geq d`. 

 

Note that `m_i^{(a)} = 0` for all `i > d`. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A',3,1], [[3,2],[2,1],[1,1],[1,1]]) 

sage: for x in KT: x, x.multiplicity() 

(Kleber tree node with weight [2, 1, 2] and upwards edge root [0, 0, 0], 1) 

(Kleber tree node with weight [3, 0, 1] and upwards edge root [0, 1, 1], 1) 

(Kleber tree node with weight [0, 2, 2] and upwards edge root [1, 0, 0], 1) 

(Kleber tree node with weight [1, 0, 3] and upwards edge root [1, 1, 0], 2) 

(Kleber tree node with weight [1, 1, 1] and upwards edge root [1, 1, 1], 4) 

(Kleber tree node with weight [0, 0, 2] and upwards edge root [2, 2, 1], 2) 

(Kleber tree node with weight [2, 0, 0] and upwards edge root [0, 1, 1], 2) 

(Kleber tree node with weight [0, 0, 2] and upwards edge root [1, 1, 0], 1) 

(Kleber tree node with weight [0, 1, 0] and upwards edge root [1, 1, 1], 2) 

(Kleber tree node with weight [0, 1, 0] and upwards edge root [0, 0, 1], 1) 

 

TESTS: 

 

We check that :trac:`16057` is fixed:: 

 

sage: RC = RiggedConfigurations(['D',4,1], [[1,3],[3,3],[4,3]]) 

sage: sum(x.multiplicity() for x in RC.kleber_tree()) == len(RC.module_generators) 

True 

""" 

# The multiplicity corresponding to the root is always 1 

if self.parent_node is None: 

return Integer(1) 

 

mult = Integer(1) 

I = self.parent()._classical_ct.index_set() 

for a,m in self.up_root: 

p = self.weight[a] 

for r,s in self.parent().B: 

if r == a and s > self.depth: 

p -= s - self.depth 

mult *= binomial(m + p, m) 

 

prev_up_root = self.up_root 

cur = self.parent_node 

while cur.parent_node is not None: 

root_diff = cur.up_root - prev_up_root 

for a,m in root_diff: 

p = cur.weight[a] 

for r,s in self.parent().B: 

if r == a and s > cur.depth: 

p -= s - cur.depth 

mult *= binomial(m + p, m) 

prev_up_root = cur.up_root 

cur = cur.parent_node 

 

return mult 

 

def __hash__(self): 

r""" 

TESTS:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

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

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

sage: KT = KleberTree(['A', 2, 1], [[1,1]]) 

sage: n = KT(WS.sum_of_terms([(1,5), (2,2)]), R.zero()) 

sage: hash(n) 

-603608031356818252 # 64-bit 

-1956156236 # 32-bit 

""" 

return hash(self.depth) ^ hash(self.weight) 

 

def _richcmp_(self, rhs, op): 

r""" 

Check whether two nodes are equal. 

 

TESTS:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

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

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

sage: KT = KleberTree(['A', 2, 1], [[1,1]]) 

sage: n = KT(WS.sum_of_terms([(1,5), (2,2)]), R.zero()) 

sage: n2 = KT(WS.sum_of_terms([(1,5), (2,2)]), R.zero(), n) 

sage: n2 > n 

True 

sage: n3 = KT(WS.sum_of_terms([(1,5), (2,2)]), R.zero(), n) 

sage: n2 == n3 

True 

sage: n3 = KT(WS.sum_of_terms([(1,5), (2,3)]), R.zero(), n) 

sage: n2 < n3 

True 

""" 

lx = self.depth 

rx = rhs.depth 

if lx != rx: 

return richcmp_not_equal(lx, rx, op) 

 

lx = self.parent_node 

rx = rhs.parent_node 

if lx != rx: 

return richcmp_not_equal(lx, rx, op) 

 

return richcmp(self.weight, rhs.weight, op) 

 

def _repr_(self): 

r""" 

Return the string representation of ``self``. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: RS = RootSystem(['A', 3]) 

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

sage: KT = KleberTree(['A', 2, 1], [[1,1]]) 

sage: node = KT(WS.sum_of_terms([(1,2), (2,1), (3,1)]), R.sum_of_terms([(1,3), (3,3)])); node 

Kleber tree node with weight [2, 1, 1] and upwards edge root [3, 0, 3] 

 

With virtual nodes:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['A',6,2], [[2,2]]) 

sage: KT.root 

Kleber tree node with weight [0, 2, 0, 2, 0] and upwards edge root [0, 0, 0, 0, 0] 

""" 

return "Kleber tree node with weight %s and upwards edge root %s"%( 

list(self.weight.to_vector()), list(self.up_root.to_vector()) ) 

 

def _latex_(self): 

r""" 

Return latex representation of ``self``. 

 

TESTS:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: RS = RootSystem(['A', 3]) 

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

sage: KT = KleberTree(['A', 3, 1], [[3,2], [1,1]]) 

sage: node = KT(WS.sum_of_terms([(1,4), (3,1)]), R.zero()) 

sage: latex(node) 

V_{4\omega_{1}+\omega_{3}} 

sage: node = KT(WS.zero(), R.zero()) 

sage: latex(node) 

V_{0} 

sage: node = KT(WS.sum_of_terms([(1,2)]), R.zero()) 

sage: latex(node) 

V_{2\omega_{1}} 

 

With virtual nodes:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['C',3,1], [[2,2]]) 

sage: latex(KT.root) 

[V_{2\omega_{2}+2\omega_{4}}] 

sage: KT = VirtualKleberTree(['A',6,2], [[2,2]]) 

sage: latex(KT.root) 

[V_{2\omega_{2}+2\omega_{4}}] 

""" 

ret_str = "V_{" 

if self.multiplicity() != 1: 

ret_str = repr(self.multiplicity()) + ret_str 

for pair in self.weight: 

if pair[1] > 1: 

ret_str += repr(pair[1]) + "\omega_{" + repr(pair[0]) + "}+" 

elif pair[1] == 1: 

ret_str += "\omega_{" + repr(pair[0]) + "}+" 

 

if ret_str[-1] == '{': 

ret_str += "0}" 

else: 

ret_str = ret_str[:-1] + "}" 

 

ct = self.parent()._cartan_type 

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

return "[" + ret_str + "]" 

elif not ct.is_simply_laced(): 

s_factors = self.parent()._folded_ct.scaling_factors() 

gamma = max(s_factors) 

# Subtract 1 for indexing 

if gamma > 1: 

L = [self.parent()._folded_ct.folding_orbit()[a][0] for a in 

range(1, len(s_factors)) if s_factors[a] == gamma] 

else: 

L = [] 

 

if self.depth % gamma == 0 or all(self.up_root[a] == 0 for a in L): 

return "[" + ret_str + "]" 

return ret_str 

 

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

# Kleber tree classes # 

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

 

class KleberTree(UniqueRepresentation, Parent): 

r""" 

The tree that is generated by Kleber's algorithm. 

 

A Kleber tree is a tree of weights generated by Kleber's algorithm 

[Kleber1]_. It is used to generate the set of all admissible rigged 

configurations for the simply-laced affine types `A_n^{(1)}`, 

`D_n^{(1)}`, `E_6^{(1)}`, `E_7^{(1)}`, and `E_8^{(1)}`. 

 

.. SEEALSO:: 

 

There is a modified version for non-simply-laced affine types at 

:class:`VirtualKleberTree`. 

 

The nodes correspond to the weights in the positive Weyl chamber obtained 

by subtracting a (non-zero) positive root. The edges are labeled by the 

coefficients of the roots, and `X` is a child of `Y` if `Y` is the root 

else if the edge label of `Y` to its parent `Z` is greater (in every 

component) than the label from `X` to `Y`. 

 

For a Kleber tree, one needs to specify an affine (simply-laced) 

Cartan type and a sequence of pairs `(r,s)`, where `s` is any positive 

integer and `r` is a node in the Dynkin diagram. Each `(r,s)` can be 

viewed as a rectangle of width `s` and height `r`. 

 

INPUT: 

 

- ``cartan_type`` -- an affine simply-laced Cartan type 

 

- ``B`` -- a list of dimensions of rectangles by `[r, c]` 

where `r` is the number of rows and `c` is the number of columns 

 

REFERENCES: 

 

.. [Kleber1] Michael Kleber. 

*Combinatorial structure of finite dimensional representations of 

Yangians: the simply-laced case*. 

Internat. Math. Res. Notices. (1997) no. 4. 187-201. 

 

.. [Kleber2] Michael Kleber. 

*Finite dimensional representations of quantum affine algebras*. 

Ph.D. dissertation at University of California Berkeley. (1998). 

:arxiv:`math.QA/9809087`. 

 

EXAMPLES: 

 

Simply-laced example:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A', 3, 1], [[3,2], [1,1]]) 

sage: KT.list() 

[Kleber tree node with weight [1, 0, 2] and upwards edge root [0, 0, 0], 

Kleber tree node with weight [0, 0, 1] and upwards edge root [1, 1, 1]] 

sage: KT = KleberTree(['A', 3, 1], [[3,2], [2,1], [1,1], [1,1]]) 

sage: KT.cardinality() 

10 

sage: KT = KleberTree(['D', 4, 1], [[2,2]]) 

sage: KT.cardinality() 

3 

sage: KT = KleberTree(['D', 4, 1], [[4,5]]) 

sage: KT.cardinality() 

1 

 

From [Kleber2]_:: 

 

sage: KT = KleberTree(['E', 6, 1], [[4, 2]]) # long time (9s on sage.math, 2012) 

sage: KT.cardinality() # long time 

12 

 

We check that relabelled types work (:trac:`16876`):: 

 

sage: ct = CartanType(['A',3,1]).relabel(lambda x: x+2) 

sage: kt = KleberTree(ct, [[3,1],[5,1]]) 

sage: list(kt) 

[Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 0, 0], 

Kleber tree node with weight [0, 0, 0] and upwards edge root [1, 1, 1]] 

sage: kt = KleberTree(['A',3,1], [[1,1],[3,1]]) 

sage: list(kt) 

[Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 0, 0], 

Kleber tree node with weight [0, 0, 0] and upwards edge root [1, 1, 1]] 

""" 

@staticmethod 

def __classcall_private__(cls, cartan_type, B, classical=None): 

""" 

Normalize the input arguments to ensure unique representation. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT1 = KleberTree(CartanType(['A',3,1]), [[2,2]]) 

sage: KT2 = KleberTree(['A',3,1], [(2,2)]) 

sage: KT3 = KleberTree(['A',3,1], ((2,2),)) 

sage: KT2 is KT1, KT3 is KT1 

(True, True) 

""" 

cartan_type = CartanType(cartan_type) 

if not cartan_type.is_affine(): 

raise ValueError("The Cartan type must be affine") 

 

if not cartan_type.classical().is_simply_laced(): 

raise ValueError("use VirtualKleberTree for non-simply-laced types") 

 

# Standardize B input into a tuple of tuples 

B = tuple([tuple(rs) for rs in B]) 

 

if classical is None: 

classical = cartan_type.classical() 

else: 

classical = CartanType(classical) 

return super(KleberTree, cls).__classcall__(cls, cartan_type, B, classical) 

 

def __init__(self, cartan_type, B, classical_ct): 

r""" 

Construct a Kleber tree. 

 

The input ``classical_ct`` is the classical Cartan type to run the 

algorithm on and is only meant to be used internally. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['D', 3, 1], [[1,1], [1,1]]); KT 

Kleber tree of Cartan type ['D', 3, 1] and B = ((1, 1), (1, 1)) 

sage: TestSuite(KT).run(skip="_test_elements") 

""" 

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

 

self._cartan_type = cartan_type 

self.B = B 

self._classical_ct = classical_ct 

# Our computations in _children_iter_vector use dense vectors. 

# Moreover, ranks are relatively small, so just use the dense 

# version of the Cartan matrix. 

self._CM = self._classical_ct.cartan_matrix().dense_matrix() 

self._build_tree() 

self._latex_options = dict(edge_labels=True, use_vector_notation=False, 

hspace=2.5, vspace=min(-2.5, -0.75*self._classical_ct.rank())) 

 

def latex_options(self, **options): 

""" 

Return the current latex options if no arguments are passed, otherwise 

set the corresponding latex option. 

 

OPTIONS: 

 

- ``hspace`` -- (default: `2.5`) the horizontal spacing of the 

tree nodes 

- ``vspace`` -- (default: ``x``) the vertical spacing of the tree 

nodes, here ``x`` is the minimum of `-2.5` or `-.75n` where `n` is 

the rank of the classical type 

- ``edge_labels`` -- (default: ``True``) display edge labels 

- ``use_vector_notation`` -- (default: ``False``) display edge labels 

using vector notation instead of a linear combination 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['D', 3, 1], [[2,1], [2,1]]) 

sage: KT.latex_options(vspace=-4, use_vector_notation=True) 

sage: sorted(KT.latex_options().items()) 

[('edge_labels', True), ('hspace', 2.5), ('use_vector_notation', True), ('vspace', -4)] 

""" 

if not options: 

from copy import copy 

return copy(self._latex_options) 

for k in options: 

self._latex_options[k] = options[k] 

 

def _latex_(self): 

r""" 

Return a latex representation of this Kleber tree. 

 

.. SEEALSO:: 

 

:meth:`latex_options()` 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['D', 3, 1], [[2,1], [2,1]]) 

sage: KT._latex_() 

'\\begin{tikzpicture}...\\end{tikzpicture}' 

""" 

from sage.graphs.graph_latex import setup_latex_preamble 

setup_latex_preamble() 

 

return "\\begin{tikzpicture}\n" + \ 

_draw_tree(self.root, **self._latex_options) \ 

+ "\\end{tikzpicture}" 

 

def _build_tree(self): 

""" 

Build the Kleber tree. 

 

TESTS: 

 

This is called from the constructor:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A',3,1], [[2,2]]) # indirect doctest 

""" 

P = self._classical_ct.root_system().weight_lattice() 

# Create an empty node at first step 

self.root = KleberTreeNode(self, P.zero(), 

self._classical_ct.root_system().root_lattice().zero()) 

full_list = [self.root] # The list of tree nodes 

 

n = self._classical_ct.rank() 

 

# Convert the B values into an L matrix 

L = [] 

I = self._classical_ct.index_set() 

for i in range(n): 

L.append([0]) 

 

for r,s in self.B: 

while len(L[0]) < s: # Add more columns if needed 

for row in L: 

row.append(0) 

L[I.index(r)][s - 1] += 1 # The -1 is for indexing 

 

# Perform a special case of the algorithm for the root node 

weight_basis = P.basis() 

for a in range(n): 

self.root.weight += sum(L[a]) * weight_basis[I[a]] 

new_children = [] 

for new_child in self._children_iter(self.root): 

if not self._prune(new_child, 1): 

new_children.append(new_child) 

self.root.children.append(new_child) 

full_list.append(new_child) 

 

depth = 1 

growth = True 

 

# self._has_normaliz is set by _children_iter 

if self._classical_ct.rank() >= 7 or self._has_normaliz: 

child_itr = self._children_iter 

else: 

child_itr = self._children_iter_vector 

 

while growth: 

growth = False 

depth += 1 

leaves = new_children 

 

if depth <= len(L[0]): 

new_children = [] 

for x in full_list: 

growth = True 

for a in range(n): 

for i in range(depth - 1, len(L[a])): # Subtract 1 for indexing 

x.weight += L[a][i] * weight_basis[I[a]] 

 

new_children = [new_child 

for x in leaves 

for new_child in child_itr(x) 

if not self._prune(new_child, depth)] 

 

# Connect the new children into the tree 

if new_children: 

growth = True 

for new_child in new_children: 

new_child.parent_node.children.append(new_child) 

full_list.append(new_child) 

 

self._set = full_list 

 

def _children_iter(self, node): 

r""" 

Iterate over the children of ``node``. 

 

Helper iterator to iterate over all children, by generating and/or 

computing them, of the Kleber tree node. 

 

We compute the children by computing integral points (expressed as 

simple roots) in the polytope given by the intersection of the 

negative root cone and shifted positive weight cone. More precisely, 

we rewrite the condition `\lambda - \mu \in Q^+`, for `\mu \in P^+`, 

as `\lambda - Q^+ = \mu \in P^+`. 

 

INPUT: 

 

- ``node`` -- the current node in the tree whose children we want 

to generate 

 

TESTS:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['D', 3, 1], [[1,1], [1,1]]) 

sage: for x in KT: x # indirect doctest 

Kleber tree node with weight [2, 0, 0] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [0, 1, 1] and upwards edge root [1, 0, 0] 

Kleber tree node with weight [0, 0, 0] and upwards edge root [2, 1, 1] 

 

sage: KT = KleberTree(['D', 4, 1], [[2,2]]) 

sage: KT[1] 

Kleber tree node with weight [0, 1, 0, 0] and upwards edge root [1, 2, 1, 1] 

sage: for x in KT: x 

Kleber tree node with weight [0, 2, 0, 0] and upwards edge root [0, 0, 0, 0] 

Kleber tree node with weight [0, 1, 0, 0] and upwards edge root [1, 2, 1, 1] 

Kleber tree node with weight [0, 0, 0, 0] and upwards edge root [1, 2, 1, 1] 

sage: for x in KT._children_iter(KT[1]): x 

Kleber tree node with weight [0, 0, 0, 0] and upwards edge root [1, 2, 1, 1] 

""" 

# It is faster to just cycle through than build the polytope and its 

# lattice points when we are sufficiently small 

# The number 500 comes from testing on my machine about where the 

# tradeoff occurs between the methods. However, this may grow as 

# the _children_iter_vector is further optimized. 

if node != self.root and prod(val+1 for val in node.up_root.coefficients()) < 1000: 

for x in self._children_iter_vector(node): 

yield x 

return 

 

n = self._classical_ct.rank() 

I = self._classical_ct.index_set() 

Q = self._classical_ct.root_system().root_lattice() 

P = self._classical_ct.root_system().weight_lattice() 

 

# Construct the polytope by inequalities 

from sage.geometry.polyhedron.constructor import Polyhedron 

# Construct the shifted weight cone 

root_weight = node.weight.to_vector() 

ieqs = [[root_weight[i]] + list(col) 

for i,col in enumerate(self._CM.columns())] 

# Construct the negative weight cone 

for i in range(n): 

v = [0] * (n+1) 

v[i+1] = -1 

ieqs.append(v) 

ieqs.append([-1]*(n+1)) # For avoiding the origin 

# Construct the bounds for the non-root nodes 

if node != self.root: 

for i,c in enumerate(node.up_root.to_vector()): 

v = [0] * (n+1) 

v[0] = c 

v[i+1] = 1 

ieqs.append(v) 

 

try: 

poly = Polyhedron(ieqs=ieqs, backend='normaliz') 

self._has_normaliz = True 

except ImportError: 

poly = Polyhedron(ieqs=ieqs) 

self._has_normaliz = False 

 

# Build the nodes from the polytope 

# Sort for a consistent ordering (it is typically a small list) 

for pt in sorted(poly.integral_points(), reverse=True): 

up_root = Q._from_dict({I[i]: -val for i,val in enumerate(pt) if val != 0}, 

remove_zeros=False) 

wt = node.weight + sum(val * P.simple_root(I[i]) for i,val in enumerate(pt)) 

yield KleberTreeNode(self, wt, up_root, node) 

 

def _children_iter_vector(self, node): 

r""" 

Iterate over the children of ``node``. 

 

Helper iterator to iterate over all children, by generating and/or 

computing them, of the Kleber tree node. This implementation 

iterates over all possible uproot vectors. 

 

.. SEEALSO:: 

 

:meth:`_children_iter` 

 

INPUT: 

 

- ``node`` -- the current node in the tree whose children we want 

to generate 

 

TESTS:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['D', 4, 1], [[2,2]]) 

sage: KT[1] 

Kleber tree node with weight [0, 1, 0, 0] and upwards edge root [1, 2, 1, 1] 

sage: for x in KT._children_iter(KT[1]): x 

Kleber tree node with weight [0, 0, 0, 0] and upwards edge root [1, 2, 1, 1] 

""" 

Q = self._classical_ct.root_system().root_lattice() 

P = self._classical_ct.root_system().weight_lattice() 

I = self._classical_ct.index_set() 

wt = node.weight.to_vector() 

cols = self._CM.columns() 

F = FreeModule(ZZ, self._classical_ct.rank()) 

 

L = [range(val + 1) for val in node.up_root.to_vector()] 

 

it = itertools.product(*L) 

next(it) # First element is the zero element 

for root in it: 

# Convert the list to the weight lattice 

converted_root = sum(cols[i] * c for i,c in enumerate(root) if c != 0) 

 

if all(wt[i] >= val for i,val in enumerate(converted_root)): 

wd = {I[i]: wt[i] - val for i,val in enumerate(converted_root)} 

rd = {I[i]: val for i,val in enumerate(root) if val != 0} 

yield KleberTreeNode(self, 

P._from_dict(wd), 

Q._from_dict(rd, remove_zeros=False), 

node) 

 

def _prune(self, new_child, depth): 

r""" 

Return ``True`` if we are to prune the tree at ``new_child``. 

 

This always returns ``False`` since we do not do any pruning. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A', 2, 1], [[1,1]]) 

sage: KT._prune(KT.root, 0) 

False 

""" 

return False 

 

def breadth_first_iter(self): 

r""" 

Iterate over all nodes in the tree following a breadth-first traversal. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A', 3, 1], [[2, 2], [2, 3]]) 

sage: for x in KT.breadth_first_iter(): x 

Kleber tree node with weight [0, 5, 0] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 3, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 3, 0] and upwards edge root [1, 2, 1] 

Kleber tree node with weight [2, 1, 2] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [1, 1, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 1, 0] and upwards edge root [1, 2, 1] 

""" 

cur = [] 

next = [self.root] 

while len(next) > 0: 

cur = next 

next = [] 

for node in cur: 

yield node 

next.extend(node.children) 

 

def depth_first_iter(self): 

r""" 

Iterate (recursively) over the nodes in the tree following a 

depth-first traversal. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A', 3, 1], [[2, 2], [2, 3]]) 

sage: for x in KT.depth_first_iter(): x 

Kleber tree node with weight [0, 5, 0] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 3, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [2, 1, 2] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 3, 0] and upwards edge root [1, 2, 1] 

Kleber tree node with weight [1, 1, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 1, 0] and upwards edge root [1, 2, 1] 

""" 

return self._depth_first_iter(None) 

 

def _depth_first_iter(self, cur): 

r""" 

Helper recursive function used in depth-first iteration. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A', 3, 1], [[2, 2], [2, 3]]) 

sage: for x in KT._depth_first_iter(None): x 

Kleber tree node with weight [0, 5, 0] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 3, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [2, 1, 2] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 3, 0] and upwards edge root [1, 2, 1] 

Kleber tree node with weight [1, 1, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 1, 0] and upwards edge root [1, 2, 1] 

""" 

if cur is None: 

cur = self.root 

 

yield cur 

 

for child in cur.children: 

for x in self._depth_first_iter(child): 

yield x 

 

__iter__ = breadth_first_iter 

 

def _repr_(self): 

""" 

Return a text representation of this Kleber tree. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KleberTree(['D', 4, 1], [[2, 2]]) # indirect doctest 

Kleber tree of Cartan type ['D', 4, 1] and B = ((2, 2),) 

""" 

return "Kleber tree of Cartan type %s and B = %s"%(repr(self._cartan_type), self.B) 

 

def cartan_type(self): 

r""" 

Return the Cartan type of this Kleber tree. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['A', 3, 1], [[1,1]]) 

sage: KT.cartan_type() 

['A', 3, 1] 

""" 

return self._cartan_type 

 

def digraph(self): 

r""" 

Return a DiGraph representation of this Kleber tree. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['D', 4, 1], [[2, 2]]) 

sage: KT.digraph() 

Digraph on 3 vertices 

""" 

d = {} 

for x in self.breadth_first_iter(): 

d[x] = {} 

if x.parent_node is None: 

continue 

d[x][x.parent_node] = tuple(x.up_root.to_vector()) 

G = DiGraph(d) 

 

if have_dot2tex(): 

G.set_latex_options(format="dot2tex", edge_labels=True) 

return G 

 

def plot(self, **options): 

""" 

Return the plot of self as a directed graph. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

sage: KT = KleberTree(['D', 4, 1], [[2, 2]]) 

sage: print(KT.plot()) 

Graphics object consisting of 8 graphics primitives 

""" 

return self.digraph().plot(edge_labels=True, vertex_size=0, **options) 

 

def _element_constructor_(self, node_weight, dominant_root, parent_node=None): 

""" 

Construct a Kleber tree node. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import KleberTree 

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

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

sage: KT = KleberTree(['A', 2, 1], [[1,1]]) 

sage: root = KT(WS.sum_of_terms([(1,5), (2,2)]), R.zero()); root # indirect doctest 

Kleber tree node with weight [5, 2] and upwards edge root [0, 0] 

sage: child = KT(WS.sum_of_terms([(1,5), (2,1)]), R.zero(), root); child # indirect doctest 

Kleber tree node with weight [5, 1] and upwards edge root [0, 0] 

sage: child.parent_node 

Kleber tree node with weight [5, 2] and upwards edge root [0, 0] 

""" 

return self.element_class(self, node_weight, dominant_root, parent_node) 

 

Element = KleberTreeNode 

 

class VirtualKleberTree(KleberTree): 

""" 

A virtual Kleber tree. 

 

We can use a modified version of the Kleber algorithm called the virtual 

Kleber algorithm [OSS03]_ to compute all admissible rigged configurations 

for non-simply-laced types. This uses the following embeddings 

into the simply-laced types: 

 

.. MATH:: 

 

C_n^{(1)}, A_{2n}^{(2)}, A_{2n}^{(2)\dagger}, D_{n+1}^{(2)} 

\hookrightarrow A_{2n-1}^{(1)} 

 

A_{2n-1}^{(2)}, B_n^{(1)} \hookrightarrow D_{n+1}^{(1)} 

 

E_6^{(2)}, F_4^{(1)} \hookrightarrow E_6^{(1)} 

 

D_4^{(3)}, G_2^{(1)} \hookrightarrow D_4^{(1)} 

 

One then selects the subset of admissible nodes which are translates of 

the virtual requirements. In the graph, the selected nodes are indicated 

by brackets `[]`. 

 

.. NOTE:: 

 

Because these are virtual nodes, all information is given 

in the corresponding simply-laced type. 

 

.. SEEALSO:: 

 

For more on the Kleber algorithm, see :class:`KleberTree`. 

 

REFERENCES: 

 

.. [OSS03] Masato Okado, Anne Schilling, and Mark Shimozono. 

*Virtual crystals and Klebers algorithm*. Commun. Math. Phys. **238** 

(2003). 187-209. :arxiv:`math.QA/0209082`. 

 

INPUT: 

 

- ``cartan_type`` -- an affine non-simply-laced Cartan type 

 

- ``B`` -- a list of dimensions of rectangles by `[r, c]` 

where `r` is the number of rows and `c` is the number of columns 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['C', 4, 1], [[2,2]]) 

sage: KT.cardinality() 

3 

sage: KT.base_tree().cardinality() 

6 

sage: KT = VirtualKleberTree(['C', 4, 1], [[4,5]]) 

sage: KT.cardinality() 

1 

sage: KT = VirtualKleberTree(['D', 5, 2], [[2,1], [1,1]]) 

sage: KT.cardinality() 

8 

sage: KT = VirtualKleberTree(CartanType(['A', 4, 2]).dual(), [[1,1], [2,2]]) 

sage: KT.cardinality() 

15 

""" 

@staticmethod 

def __classcall_private__(cls, cartan_type, B): 

""" 

Normalize the input arguments to ensure unique representation. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT1 = VirtualKleberTree(CartanType(['C',3,1]).as_folding(), [[2,2]]) 

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

sage: KT3 = VirtualKleberTree(['C',3,1], ((2,2),)) 

sage: KT2 is KT1, KT3 is KT1 

(True, True) 

""" 

cartan_type = CartanType(cartan_type) 

# Standardize B input into a tuple of tuples 

B = tuple(map(tuple, B)) 

if cartan_type.type() == 'BC' or cartan_type.dual().type() == 'BC': 

# Types A_{2n}^{(2)} and its dual 

return KleberTreeTypeA2Even(cartan_type, B) 

if cartan_type.classical().is_simply_laced(): 

raise ValueError("use KleberTree for simply-laced types") 

return super(VirtualKleberTree, cls).__classcall__(cls, cartan_type, B) 

 

def __init__(self, cartan_type, B): 

""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['C',4,1], [[2,2]]) 

sage: TestSuite(KT).run(skip="_test_elements") 

""" 

self._folded_ct = cartan_type.as_folding() 

virtual_dims = [] 

self.base_dims = B 

sigma = self._folded_ct.folding_orbit() 

gamma = self._folded_ct.scaling_factors() 

classical_ct = self._folded_ct.folding_of().classical() 

for r,s in B: 

for i in sigma[r]: 

virtual_dims.append([i, s * gamma[r]]) 

 

KleberTree.__init__(self, cartan_type, virtual_dims, classical_ct) 

 

def _repr_(self): 

""" 

Return a text representation of this Kleber tree. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: VirtualKleberTree(['C', 4, 1], [[2, 2]]) 

Virtual Kleber tree of Cartan type ['C', 4, 1] and B = ((2, 2),) 

""" 

return "Virtual Kleber tree of Cartan type %s and B = %s"%(repr(self._cartan_type), self.base_dims) 

 

def _prune(self, new_child, depth): 

r""" 

Return ``True`` if we are to prune the tree at ``new_child``. 

 

Suppose `\lambda` is the weight of the child we want to add at depth 

`\ell`. We prune ``new_child`` if either of the following conditions 

are not satisfied: 

 

1. `(\lambda \mid \alpha_a) = (\lambda \mid \alpha_b)` if `a` and `b` 

are in the same `\sigma`-orbit. 

2. If `\ell - 1 \notin \gamma_a \ZZ`, then the `a`-th component of 

``up_root`` of ``new_child`` must equal the `a`-th component of 

``up_root`` of its ``parent_node``. Note that from condition 1, 

we only need to check one such `a` from each `\sigma`-orbit. 

 

These conditions are equivalent to Definition 4.1 in [OSS03]_. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: RS = RootSystem(['A', 3]) 

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

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

sage: x = KT(WS.sum_of_terms([(1,1), (2,1), (3,3)]), R.sum_of_terms([(1,2),(2,2),(3,1)]), KT.root) 

sage: KT._prune(x, 1) 

True 

""" 

sigma = self._folded_ct._orbit 

for orbit in sigma[1:]: 

start = new_child.weight[orbit[0]] 

if any(new_child.weight[i] != start for i in orbit[1:]): 

return True 

gamma = self._folded_ct.scaling_factors() 

for a in range(1, len(gamma)): 

if (depth - 1) % gamma[a] != 0 and new_child.up_root[sigma[a][0]] \ 

!= new_child.parent_node.up_root[sigma[a][0]]: 

return True 

return False 

 

def breadth_first_iter(self, all_nodes=False): 

r""" 

Iterate over all nodes in the tree following a breadth-first traversal. 

 

INPUT: 

 

- ``all_nodes`` -- (default: ``False``) if ``True``, output all 

nodes in the tree 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

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

sage: for x in KT.breadth_first_iter(): x 

Kleber tree node with weight [1, 2, 1] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 1, 0] 

sage: for x in KT.breadth_first_iter(True): x 

Kleber tree node with weight [1, 2, 1] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [0, 2, 0] and upwards edge root [1, 1, 1] 

Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 1, 0] 

""" 

s_factors = self._folded_ct.scaling_factors() 

gamma = max(s_factors) 

# Subtract 1 for indexing 

if gamma > 1: 

sigma = self._folded_ct.folding_orbit() 

L = [sigma[a][0] for a in range(1, len(s_factors)) 

if s_factors[a] == gamma] 

else: 

L = [] 

 

for x in KleberTree.breadth_first_iter(self): 

if all_nodes or (x.depth) % gamma == 0 or all(x.up_root[a] == 0 for a in L): 

yield x 

 

def depth_first_iter(self, all_nodes=False): 

r""" 

Iterate (recursively) over the nodes in the tree following a 

depth-first traversal. 

 

INPUT: 

 

- ``all_nodes`` -- (default: ``False``) if ``True``, output all 

nodes in the tree 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

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

sage: for x in KT.depth_first_iter(): x 

Kleber tree node with weight [1, 2, 1] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 1, 0] 

sage: for x in KT.depth_first_iter(True): x 

Kleber tree node with weight [1, 2, 1] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [0, 2, 0] and upwards edge root [1, 1, 1] 

Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 1, 0] 

""" 

s_factors = self._folded_ct.scaling_factors() 

gamma = max(s_factors) 

# Subtract 1 for indexing 

if gamma > 1: 

sigma = self._folded_ct.folding_orbit() 

L = [sigma[a][0] for a in range(1, len(s_factors)) 

if s_factors[a] == gamma] 

else: 

L = [] 

 

for x in self._depth_first_iter(None): 

if all_nodes or (x.depth) % gamma == 0 or all(x.up_root[a] == 0 for a in L): 

yield x 

 

__iter__ = breadth_first_iter 

 

def base_tree(self): 

""" 

Return the underlying virtual Kleber tree associated to ``self``. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['C', 4, 1], [[2,2]]) 

sage: KT.base_tree() 

Kleber tree of Cartan type ['A', 7, 1] and B = ((2, 2), (6, 2)) 

""" 

return KleberTree(self._folded_ct.folding_of(), self.B) 

 

class KleberTreeTypeA2Even(VirtualKleberTree): 

r""" 

Kleber tree for types `A_{2n}^{(2)}` and `A_{2n}^{(2)\dagger}`. 

 

Note that here for `A_{2n}^{(2)}` we use `\tilde{\gamma}_a` in place of 

`\gamma_a` in constructing the virtual Kleber tree, and so we end up 

selecting all nodes since `\tilde{\gamma}_a = 1` for all `a \in 

\overline{I}`. For type `A_{2n}^{(2)\dagger}`, we have `\gamma_a = 1` 

for all `a \in \overline{I}`. 

 

.. SEEALSO:: 

 

:class:`VirtualKleberTree` 

""" 

@staticmethod 

def __classcall_private__(cls, cartan_type, B): 

""" 

Normalize the input arguments to ensure unique representation. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

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

sage: KT2 = VirtualKleberTree(['A',6,2], [(2,2)]) 

sage: KT3 = VirtualKleberTree(['A',6,2], ((2,2),)) 

sage: KT2 is KT1, KT3 is KT1 

(True, True) 

""" 

cartan_type = CartanType(cartan_type) 

# Standardize B input into a tuple of tuples 

B = tuple(map(tuple, B)) 

return super(KleberTreeTypeA2Even, cls).__classcall__(cls, cartan_type, B) 

 

def __init__(self, cartan_type, B): 

""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['A',6,2], [[2,2]]); KT 

Virtual Kleber tree of Cartan type ['BC', 3, 2] and B = ((2, 2),) 

sage: TestSuite(KT).run(skip="_test_elements") 

""" 

self._folded_ct = cartan_type.as_folding() 

virtual_dims = [] 

n = cartan_type.classical().rank() 

self.base_dims = B 

sigma = self._folded_ct.folding_orbit() 

classical_ct = self._folded_ct.folding_of().classical() 

for r,s in B: 

if r == n: 

virtual_dims.extend([[n, s], [n, s]]) 

else: 

for i in sigma[r]: 

virtual_dims.append([i, s]) 

 

KleberTree.__init__(self, cartan_type, virtual_dims, classical_ct) 

 

def __iter__(self): 

""" 

Iterate over all of the nodes. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['A',6,2], [[2,2]]) 

sage: L = [x for x in KT] 

sage: len(L) == KT.cardinality() 

True 

""" 

return KleberTree.__iter__(self) 

 

def _prune(self, new_child, depth): 

r""" 

Return ``True`` if we are to prune the tree at ``new_child``. 

 

Suppose `\lambda` is the weight of the child we want to add at 

depth `\ell`. We prune ``new_child`` if `(\lambda \mid \alpha_a) 

\neq (\lambda \mid \alpha_b)` if `a` and `b` are in the same 

`\sigma`-orbit. 

 

These conditions are equivalent to Definition 4.1 in [OSS03]_ by using 

`\tilde{\gamma}`, and since `\tilde{\gamma}_a = 1` for all `a`, the 

second condition becomes vacuous. 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

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

sage: WS = RS.weight_lattice() 

sage: R = RS.root_lattice() 

sage: KT = VirtualKleberTree(['A',6,2], [[2,2]]) 

sage: x = KT(WS.sum_of_terms([(2,1), (4,1)]), R.sum_of_terms([(1,1),(2,2),(3,2),(4,2),(5,1)]), KT.root) 

sage: KT._prune(x, 1) 

False 

""" 

sigma = self._folded_ct._orbit 

for orbit in sigma[1:]: 

start = new_child.weight[orbit[0]] 

for i in orbit[1:]: 

if new_child.weight[i] != start: 

return True 

return False 

 

def breadth_first_iter(self, all_nodes=False): 

r""" 

Iterate over all nodes in the tree following a breadth-first traversal. 

 

INPUT: 

 

- ``all_nodes`` -- (default: ``False``) if ``True``, output all 

nodes in the tree 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['A', 4, 2], [[2,1]]) 

sage: for x in KT.breadth_first_iter(): x 

Kleber tree node with weight [0, 2, 0] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 0, 0] and upwards edge root [1, 2, 1] 

sage: for x in KT.breadth_first_iter(True): x 

Kleber tree node with weight [0, 2, 0] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 0, 0] and upwards edge root [1, 2, 1] 

""" 

return KleberTree.breadth_first_iter(self) 

 

def depth_first_iter(self, all_nodes=False): 

r""" 

Iterate (recursively) over the nodes in the tree following a 

depth-first traversal. 

 

INPUT: 

 

- ``all_nodes`` -- (default: ``False``) if ``True``, output all 

nodes in the tree 

 

EXAMPLES:: 

 

sage: from sage.combinat.rigged_configurations.kleber_tree import VirtualKleberTree 

sage: KT = VirtualKleberTree(['A', 4, 2], [[2,1]]) 

sage: for x in KT.depth_first_iter(): x 

Kleber tree node with weight [0, 2, 0] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 0, 0] and upwards edge root [1, 2, 1] 

sage: for x in KT.depth_first_iter(True): x 

Kleber tree node with weight [0, 2, 0] and upwards edge root [0, 0, 0] 

Kleber tree node with weight [1, 0, 1] and upwards edge root [0, 1, 0] 

Kleber tree node with weight [0, 0, 0] and upwards edge root [1, 2, 1] 

""" 

return KleberTree.depth_first_iter(self)