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

1500

1501

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513

1514

1515

1516

1517

1518

1519

1520

1521

1522

1523

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

1539

1540

1541

1542

1543

1544

1545

1546

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1568

1569

1570

1571

1572

1573

1574

1575

1576

1577

1578

1579

1580

1581

1582

1583

1584

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595

1596

1597

1598

1599

1600

1601

1602

1603

1604

1605

1606

1607

1608

1609

1610

1611

1612

1613

1614

1615

1616

1617

1618

1619

1620

1621

1622

1623

1624

1625

1626

1627

1628

1629

1630

1631

1632

1633

1634

1635

1636

1637

1638

1639

1640

1641

1642

1643

1644

1645

1646

1647

1648

1649

1650

1651

1652

1653

1654

1655

1656

1657

1658

1659

1660

1661

1662

1663

1664

1665

1666

1667

1668

1669

1670

1671

1672

1673

1674

1675

1676

1677

1678

1679

1680

1681

1682

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696

1697

1698

1699

1700

1701

1702

1703

1704

1705

1706

1707

1708

1709

1710

1711

1712

1713

1714

1715

1716

1717

1718

1719

1720

1721

1722

1723

1724

1725

1726

1727

1728

1729

1730

1731

1732

1733

1734

1735

1736

1737

1738

1739

1740

1741

1742

1743

1744

1745

1746

1747

1748

1749

1750

1751

1752

1753

1754

1755

1756

1757

1758

1759

1760

1761

1762

1763

1764

1765

1766

1767

1768

1769

1770

1771

1772

1773

1774

1775

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787

1788

1789

1790

1791

1792

1793

1794

1795

1796

1797

1798

1799

1800

1801

1802

1803

1804

1805

1806

1807

1808

1809

1810

1811

1812

1813

1814

1815

1816

1817

1818

1819

1820

1821

1822

1823

1824

1825

1826

1827

1828

1829

1830

1831

1832

1833

1834

1835

1836

1837

1838

1839

1840

1841

1842

1843

1844

1845

1846

1847

1848

1849

1850

1851

1852

1853

1854

1855

1856

1857

1858

1859

1860

1861

1862

1863

1864

1865

1866

1867

1868

1869

1870

1871

1872

1873

1874

1875

1876

1877

1878

1879

# -*- coding: utf-8 -*- 

r""" 

Kirillov-Reshetikhin Tableaux 

 

Kirillov-Reshetikhin tableaux are rectangular tableaux with `r` rows and 

`s` columns that naturally arise under the bijection between rigged 

configurations and tableaux [RigConBijection]_. They are in bijection with 

the elements of the Kirillov-Reshetikhin crystal `B^{r,s}` under the (inverse) 

filling map [OSS13]_ [SS2015]_. They do not have to satisfy the semistandard row or column 

restrictions. These tensor products are the result from the bijection from 

rigged configurations [RigConBijection]_. 

 

For more information, see :class:`~sage.combinat.rigged_configurations.kr_tableaux.KirillovReshetikhinTableaux` 

and :class:`~sage.combinat.rigged_configurations.tensor_product_kr_tableaux.TensorProductOfKirillovReshetikhinTableaux`. 

 

AUTHORS: 

 

- Travis Scrimshaw (2012-01-03): Initial version 

- Travis Scrimshaw (2012-11-14): Added bijection to KR crystals 

 

REFERENCES: 

 

.. [OSS13] Masato Okado, Reiho Sakamoto, and Anne Schilling. 

*Affine crystal structure on rigged configurations of type* `D_n^{(1)}`. 

J. Algebraic Combinatorics, **37** (2013). 571-599. :arxiv:`1109.3523`. 

""" 

 

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

# Copyright (C) 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 __future__ import print_function 

 

# This contains both the parent and element classes. These should be split if 

# the classes grow larger. 

 

from sage.misc.cachefunc import cached_method 

from sage.misc.abstract_method import abstract_method 

from sage.misc.lazy_attribute import lazy_attribute 

from sage.misc.flatten import flatten 

 

from sage.structure.parent import Parent 

 

from sage.categories.loop_crystals import KirillovReshetikhinCrystals 

 

from sage.combinat.crystals.letters import CrystalOfLetters, EmptyLetter 

from sage.combinat.root_system.cartan_type import CartanType 

from sage.combinat.crystals.tensor_product import CrystalOfWords 

from sage.combinat.crystals.tensor_product import TensorProductOfRegularCrystalsElement 

from sage.combinat.crystals.kirillov_reshetikhin import horizontal_dominoes_removed, \ 

KashiwaraNakashimaTableaux, KirillovReshetikhinGenericCrystalElement, \ 

partitions_in_box, vertical_dominoes_removed 

from sage.combinat.partition import Partition 

from sage.combinat.tableau import Tableau 

 

class KirillovReshetikhinTableaux(CrystalOfWords): 

r""" 

Kirillov-Reshetikhin tableaux. 

 

Kirillov-Reshetikhin tableaux are rectangular tableaux with `r` rows and 

`s` columns that naturally arise under the bijection between rigged 

configurations and tableaux [RigConBijection]_. They are in bijection with 

the elements of the Kirillov-Reshetikhin crystal `B^{r,s}` under the 

(inverse) filling map. 

 

Whenever `B^{r,s} \cong B(s\Lambda_r)` as a classical crystal (which is 

the case for `B^{r,s}` in type `A_n^{(1)}`, `B^{n,s}` in type `C_n^{(1)}` and `D_{n+1}^{(2)}`, 

`B^{n,s}` and `B^{n-1,s}` in type `D_n^{(1)}`) then the filling map is trivial. 

 

For `B^{r,s}` in: 

 

- type `D_n^{(1)}` when `r \leq n-2`, 

- type `B_n^{(1)}` when `r < n`, 

- type `A_{2n-1}^{(2)}` for all `r`, 

 

the filling map is defined in [OSS2011]_. 

 

For the spinor cases in type `D_n^{(1)}`, the crystal `B^{k,s}` where 

`k = n-1, n`, is isomorphic as a classical crystal to `B(s\Lambda_k)`, 

and here we consider the Kirillov-Reshetikhin tableaux as living in 

`B(2s \Lambda_k)` under the natural doubling map. In this case, the 

crystal operators `e_i` and `f_i` act as `e_i^2` and `f_i^2` respectively. 

See [BijectionDn]_. 

 

For the spinor case in type `B_n^{(1)}`, the crystal `B^{n,s}`, we 

consider the images under the natural doubling map into `B^{n,2s}`. 

The classical components of this crystal are now given by 

removing `2 \times 2` boxes. The filling map is the same as below 

(see the non-spin type `C_n^{(1)}`). 

 

For `B^{r,s}` in: 

 

- type `C_n^{(1)}` when `r < n`, 

- type `A_{2n}^{(2)\dagger}` for all `r`, 

 

the filling map is given as follows. Suppose we are considering the 

(classically) highest weight element in the classical component 

`B(\lambda)`. Then we fill it in with the horizontal dominoes 

`[\bar{\imath}, i]` in the `i`-th row from the top (in English notation) 

and reordering the columns so that they are increasing. Recall from above 

that `B^{n,s} \cong B(s\Lambda_n)` in type `C^{(1)}_n`. 

 

For `B^{r,s}` in: 

 

- type `A_{2n}^{(2)}` for all `r`, 

- type `D_{n+1}^{(2)}` when `r < n`, 

- type `D_4^{(3)}` when `r = 1`, 

 

the filling map is the same as given in [OSS2011]_ except for 

the rightmost column which is given by the column `[1, 2, \ldots, k, 

\emptyset, \ldots \emptyset]` where `k = (r+x-1)/2` in Step 3 of 

[OSS2011]_. 

 

For the spinor case in type `D_{n+1}^{(2)}`, the crystal `B^{n,s}`, we 

define the filling map in the same way as in type `D_n^{(1)}`. 

 

.. NOTE:: 

 

The filling map and classical decompositions in non-spinor cases can 

be classified by how the special node `0` connects with the 

corresponding classical diagram. 

 

The classical crystal stucture is given by the usual Kashiwara-Nakashima 

tableaux rules. That is to embed this into `B(\Lambda_1)^{\otimes n s}` 

by using the reading word and then applying the classical crystal 

operator. The affine crystal stucture is given by converting to 

the corresponding KR crystal element, performing the affine crystal 

operator, and pulling back to a KR tableau. 

 

For more information about the bijection between rigged configurations 

and tensor products of Kirillov-Reshetikhin tableaux, see 

:class:`~sage.combinat.rigged_configurations.tensor_product_kr_tableaux.TensorProductOfKirillovReshetikhinTableaux`. 

 

.. NOTE:: 

 

The tableaux for all non-simply-laced types are provably correct if the 

bijection with :class:`rigged configurations 

<sage.combinat.rigged_configurations.rigged_configurations.RiggedConfigurations>` 

holds. Therefore this is currently only proven for `B^{r,1}` or 

`B^{1,s}` and in general for types `A_n^{(1)}` and `D_n^{(1)}`. 

 

INPUT: 

 

- ``cartan_type`` -- the Cartan type 

 

- ``r`` -- the Dynkin diagram index (typically the number of rows) 

 

- ``s`` -- the number of columns 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR') 

sage: elt = KRT(4, 3); elt 

[[3], [4]] 

 

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

sage: elt = KRT(-1, 1); elt 

[[1], [-1]] 

 

We can create highest weight crystals from a given shape or weight:: 

 

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

sage: KRT.module_generator(shape=[1,1]) 

[[1, 1], [2, -1]] 

sage: KRT.module_generator(column_shape=[2]) 

[[1, 1], [2, -1]] 

sage: WS = RootSystem(['D',4,1]).weight_space() 

sage: KRT.module_generator(weight=WS.sum_of_terms([[0,-2],[2,1]])) 

[[1, 1], [2, -1]] 

sage: WSC = RootSystem(['D',4]).weight_space() 

sage: KRT.module_generator(classical_weight=WSC.fundamental_weight(2)) 

[[1, 1], [2, -1]] 

 

We can go between 

:func:`~sage.combinat.crystals.kirillov_reshetikhin.KashiwaraNakashimaTableaux` 

and 

:class:`~sage.combinat.rigged_configurations.kr_tableaux.KirillovReshetikhinTableaux` 

elements:: 

 

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

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

sage: elt = KRCrys(3, 2); elt 

[[2], [3]] 

sage: k = KRTab(elt); k 

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

sage: KRCrys(k) 

[[2], [3]] 

 

We check that the classical weights in the classical decompositions 

agree in a few different type:: 

 

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

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

sage: all(t.classical_weight() == KRCrys(t).classical_weight() for t in KRTab) 

True 

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

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

sage: all(t.classical_weight() == KRCrys(t).classical_weight() for t in KRTab) 

True 

sage: KRCrys = crystals.KirillovReshetikhin(['C', 3, 1], 2, 2, model='KN') 

sage: KRTab = crystals.KirillovReshetikhin(['C', 3, 1], 2, 2, model='KR') 

sage: all(t.classical_weight() == KRCrys(t).classical_weight() for t in KRTab) 

True 

sage: KRCrys = crystals.KirillovReshetikhin(['D', 4, 2], 2, 2, model='KN') 

sage: KRTab = crystals.KirillovReshetikhin(['D', 4, 2], 2, 2, model='KR') 

sage: all(t.classical_weight() == KRCrys(t).classical_weight() for t in KRTab) 

True 

sage: KRCrys = crystals.KirillovReshetikhin(['A', 4, 2], 2, 2, model='KN') 

sage: KRTab = crystals.KirillovReshetikhin(['A', 4, 2], 2, 2, model='KR') 

sage: all(t.classical_weight() == KRCrys(t).classical_weight() for t in KRTab) 

True 

""" 

@staticmethod 

def __classcall_private__(cls, cartan_type, r, s): 

""" 

Normalize the input arguments to ensure unique representation. 

 

EXAMPLES:: 

 

sage: KRT1 = crystals.KirillovReshetikhin(CartanType(['A',3,1]), 2, 3, model='KR') 

sage: KRT2 = crystals.KirillovReshetikhin(['A',3,1], 2, 3, model='KR') 

sage: KRT1 is KRT2 

True 

""" 

ct = CartanType(cartan_type) 

if not ct.is_affine(): 

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

 

typ = ct.type() 

if ct.is_untwisted_affine(): 

if typ == 'A': 

return KRTableauxRectangle(ct, r, s) 

if typ == 'B': 

if r == ct.classical().rank(): 

return KRTableauxBn(ct, r, s) 

return KRTableauxTypeVertical(ct, r, s) 

if typ == 'C': 

if r == ct.classical().rank(): 

return KRTableauxRectangle(ct, r, s) 

return KRTableauxTypeHorizonal(ct, r, s) 

if typ == 'D': 

if r == ct.classical().rank() or r == ct.classical().rank() - 1: 

return KRTableauxSpin(ct, r, s) 

return KRTableauxTypeVertical(ct, r, s) 

if typ == 'E': 

return KRTableauxTypeFromRC(ct, r, s) 

else: 

if typ == 'BC': # A_{2n}^{(2)} 

return KRTableauxTypeBox(ct, r, s) 

typ = ct.dual().type() 

if typ == 'BC': # A_{2n}^{(2)\dagger} 

return KRTableauxTypeHorizonal(ct, r, s) 

if typ == 'B': # A_{2n-1}^{(2)} 

return KRTableauxTypeVertical(ct, r, s) 

if typ == 'C': # D_{n+1}^{(2)} 

if r == ct.dual().classical().rank(): 

return KRTableauxDTwistedSpin(ct, r, s) 

return KRTableauxTypeBox(ct, r, s) 

#if typ == 'F': # E_6^{(2)} 

if typ == 'G': # D_4^{(3)} 

if r == 1: 

return KRTableauxTypeBox(ct, r, s) 

return KRTableauxTypeFromRC(ct, r, s) 

 

raise NotImplementedError 

#return super(KirillovReshetikhinTableaux, cls).__classcall__(cls, ct, r, s) 

 

def __init__(self, cartan_type, r, s): 

r""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 2, model='KR') 

sage: TestSuite(KRT).run() 

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

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

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 1], 4, 1, model='KR'); KRT 

Kirillov-Reshetikhin tableaux of type ['D', 4, 1] and shape (4, 1) 

sage: TestSuite(KRT).run() 

""" 

self._r = r 

self._s = s 

self._cartan_type = cartan_type 

 

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

 

self.letters = CrystalOfLetters(cartan_type.classical()) 

self.module_generators = self._build_module_generators() 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: crystals.KirillovReshetikhin(['A', 4, 1], 2, 3, model='KR') 

Kirillov-Reshetikhin tableaux of type ['A', 4, 1] and shape (2, 3) 

""" 

return "Kirillov-Reshetikhin tableaux of type {} and shape ({}, {})".format( 

self._cartan_type, self._r, self._s) 

 

def __iter__(self): 

""" 

Return the iterator of ``self``. 

 

EXAMPLES:: 

 

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

sage: L = [x for x in KR] 

sage: len(L) 

15 

""" 

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

from sage.sets.recursively_enumerated_set import RecursivelyEnumeratedSet 

return RecursivelyEnumeratedSet(self.module_generators, 

lambda x: [x.f(i) for i in index_set], 

structure='graded').breadth_first_search_iterator() 

 

def module_generator(self, i=None, **options): 

r""" 

Return the specified module generator. 

 

INPUT: 

 

- ``i`` -- the index of the module generator 

 

We can also get a module generator by using one of the following 

optional arguments: 

 

- ``shape`` -- the associated shape 

- ``column_shape`` -- the shape given as columns (a column of length 

`k` correspond to a classical weight `\omega_k`) 

- ``weight`` -- the weight 

- ``classical_weight`` -- the classical weight 

 

If no arguments are specified, then return the unique module generator 

of classical weight `s \Lambda_r`. 

 

EXAMPLES:: 

 

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

sage: KRT.module_generator(1) 

[[1, 1], [2, -1]] 

sage: KRT.module_generator(shape=[1,1]) 

[[1, 1], [2, -1]] 

sage: KRT.module_generator(column_shape=[2]) 

[[1, 1], [2, -1]] 

sage: WS = RootSystem(['D',4,1]).weight_space() 

sage: KRT.module_generator(weight=WS.sum_of_terms([[0,-2],[2,1]])) 

[[1, 1], [2, -1]] 

sage: WSC = RootSystem(['D',4]).weight_space() 

sage: KRT.module_generator(classical_weight=WSC.fundamental_weight(2)) 

[[1, 1], [2, -1]] 

sage: KRT.module_generator() 

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

 

sage: KRT = crystals.KirillovReshetikhin(['A', 3, 1], 2, 2, model='KR') 

sage: KRT.module_generator() 

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

""" 

if i is not None: 

return self.module_generators[i] 

n = self._cartan_type.classical().rank() 

 

if "shape" in options: 

shape = list(options["shape"]) 

# Make sure the shape is the correct length 

if len(shape) < n: 

shape.extend( [0]*(n - len(shape)) ) 

for mg in self.module_generators: 

if list(mg.classical_weight().to_vector()) == shape: 

return mg 

return None 

 

if "column_shape" in options: 

shape = list(Partition(options["column_shape"]).conjugate()) 

if len(shape) < n: 

shape.extend( [0]*(n - len(shape)) ) 

for mg in self.module_generators: 

if list(mg.classical_weight().to_vector()) == shape: 

return mg 

return None 

 

if "weight" in options: 

wt = options["weight"] 

for mg in self.module_generators: 

if mg.weight() == wt: 

return mg 

return None 

 

if "classical_weight" in options: 

wt = options["classical_weight"] 

for mg in self.module_generators: 

if mg.classical_weight() == wt: 

return mg 

return None 

 

# Otherwise return the unique module generator of classical weight `s \Lambda_r` 

R = self.weight_lattice_realization() 

Lambda = R.fundamental_weights() 

r = self.r() 

s = self.s() 

weight = s*Lambda[r] - s*Lambda[0] * Lambda[r].level() / Lambda[0].level() 

for b in self.module_generators: 

if b.weight() == weight: 

return b 

assert False 

 

@abstract_method 

def _build_module_generators(self): 

""" 

Build the module generators. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 3, model='KR') 

sage: KRT._build_module_generators() 

([[1, 1, 1], [2, 2, 2]],) 

""" 

 

@abstract_method(optional=True) 

def from_kirillov_reshetikhin_crystal(self, krc): 

""" 

Construct an element of ``self`` from the Kirillov-Reshetikhin 

crystal element ``krc``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR') 

sage: C = crystals.KirillovReshetikhin(['A',4,1], 2, 1, model='KN') 

sage: krc = C(4,3); krc 

[[3], [4]] 

sage: KRT.from_kirillov_reshetikhin_crystal(krc) 

[[3], [4]] 

""" 

 

def _element_constructor_(self, *lst, **options): 

""" 

Construct a 

:class:`~sage.combinat.rigged_configurations.kr_tableaux.KirillovReshetikhinTableauxElement`. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR') 

sage: KRT(3, 4) # indirect doctest 

[[4], [3]] 

sage: KRT(4, 3) 

[[3], [4]] 

""" 

if isinstance(lst[0], KirillovReshetikhinGenericCrystalElement): 

# Check to make sure it can be converted 

if lst[0].cartan_type() != self.cartan_type() \ 

or lst[0].parent().r() != self._r or lst[0].parent().s() != self._s: 

raise ValueError("the Kirillov-Reshetikhin crystal must have the same Cartan type and (r,s)") 

return self.from_kirillov_reshetikhin_crystal(lst[0]) 

 

return self.element_class(self, list(lst), **options) 

 

def r(self): 

""" 

Return the value `r` for this tableaux class which corresponds to the 

number of rows. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR') 

sage: KRT.r() 

2 

""" 

return self._r 

 

def s(self): 

""" 

Return the value `s` for this tableaux class which corresponds to the 

number of columns. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR') 

sage: KRT.s() 

1 

""" 

return self._s 

 

@cached_method 

def kirillov_reshetikhin_crystal(self): 

""" 

Return the corresponding KR crystal in the 

:func:`Kashiwara-Nakashima model 

<sage.combinat.crystals.kirillov_reshetikhin.KashiwaraNakashimaTableaux>`. 

 

EXAMPLES:: 

 

sage: crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR').kirillov_reshetikhin_crystal() 

Kirillov-Reshetikhin crystal of type ['A', 4, 1] with (r,s)=(2,1) 

""" 

return KashiwaraNakashimaTableaux(self._cartan_type, self._r, self._s) 

 

def classical_decomposition(self): 

""" 

Return the classical crystal decomposition of ``self``. 

 

EXAMPLES:: 

 

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

The crystal of tableaux of type ['D', 4] and shape(s) [[], [1, 1], [2, 2]] 

""" 

return self.kirillov_reshetikhin_crystal().classical_decomposition() 

 

def tensor(self, *crystals, **options): 

""" 

Return the tensor product of ``self`` with ``crystals``. 

 

If ``crystals`` is a list of (a tensor product of) KR tableaux, this 

returns a 

:class:`~sage.combinat.rigged_configurations.tensor_product_kr_tableaux.TensorProductOfKirillovReshetikhinTableaux`. 

 

EXAMPLES:: 

 

sage: K = crystals.KirillovReshetikhin(['A', 3, 1], 2, 2, model='KR') 

sage: TP = crystals.TensorProductOfKirillovReshetikhinTableaux(['A', 3, 1], [[1,3],[3,1]]) 

sage: K.tensor(TP, K) 

Tensor product of Kirillov-Reshetikhin tableaux of type ['A', 3, 1] 

and factor(s) ((2, 2), (1, 3), (3, 1), (2, 2)) 

 

sage: C = crystals.KirillovReshetikhin(['A',3,1], 3, 1, model='KN') 

sage: K.tensor(K, C) 

Full tensor product of the crystals 

[Kirillov-Reshetikhin tableaux of type ['A', 3, 1] and shape (2, 2), 

Kirillov-Reshetikhin tableaux of type ['A', 3, 1] and shape (2, 2), 

Kirillov-Reshetikhin crystal of type ['A', 3, 1] with (r,s)=(3,1)] 

""" 

ct = self._cartan_type 

from sage.combinat.rigged_configurations.tensor_product_kr_tableaux \ 

import TensorProductOfKirillovReshetikhinTableaux 

if all(isinstance(B, (KirillovReshetikhinTableaux, TensorProductOfKirillovReshetikhinTableaux)) 

and B.cartan_type() == ct for B in crystals): 

dims = [[self._r, self._s]] 

for B in crystals: 

if isinstance(B, TensorProductOfKirillovReshetikhinTableaux): 

dims += B.dims 

elif isinstance(B, KirillovReshetikhinTableaux): 

dims.append([B._r, B._s]) 

return TensorProductOfKirillovReshetikhinTableaux(ct, dims) 

return super(KirillovReshetikhinTableaux, self).tensor(*crystals, **options) 

 

@lazy_attribute 

def _tableau_height(self): 

""" 

The height of the tableaux in ``self``. 

 

EXAMPLES:: 

 

sage: K = crystals.KirillovReshetikhin(['A', 3, 1], 3, 2, model='KR') 

sage: K._tableau_height 

3 

""" 

return self._r 

 

class KRTableauxRectangle(KirillovReshetikhinTableaux): 

r""" 

Kirillov-Reshetkhin tableaux `B^{r,s}` whose module generator is a single 

`r \times s` rectangle. 

 

These are Kirillov-Reshetkhin tableaux `B^{r,s}` of type: 

 

- `A_n^{(1)}` for all `1 \leq r \leq n`, 

- `C_n^{(1)}` when `r = n`. 

 

TESTS:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 3, 1], 2, 2, model='KR') 

sage: TestSuite(KRT).run() 

sage: KRT = crystals.KirillovReshetikhin(['C', 3, 1], 3, 2, model='KR') 

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

""" 

def _build_module_generators(self): 

r""" 

Build the module generators. 

 

There is only one module generator which corresponds to a single 

`r \times s` rectangle. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 3, model='KR') 

sage: KRT._build_module_generators() 

([[1, 1, 1], [2, 2, 2]],) 

""" 

tableau = [] 

for i in range(self._s): 

tableau.append( [self._r - j for j in range(self._r)] ) 

 

return (self.element_class(self, [self.letters(x) for x in flatten(tableau)]),) 

 

def from_kirillov_reshetikhin_crystal(self, krc): 

""" 

Construct a 

:class:`~sage.combinat.rigged_configurations.kr_tableaux.KirillovReshetikhinTableauxElement`. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR') 

sage: C = crystals.KirillovReshetikhin(['A',4,1], 2, 1, model='KN') 

sage: krc = C(4,3); krc 

[[3], [4]] 

sage: KRT.from_kirillov_reshetikhin_crystal(krc) 

[[3], [4]] 

""" 

# To build a KR tableau from a KR crystal: 

# 1 - start with the highest weight KR tableau 

# 2 - determine a path from the KR crystal to its highest weight 

# 3 - apply the inverse path to the highest weight KR tableau 

f_str = reversed(krc.lift().to_highest_weight()[1]) 

return self.module_generators[0].f_string(f_str) 

 

class KRTableauxTypeVertical(KirillovReshetikhinTableaux): 

r""" 

Kirillov-Reshetkihn tableaux `B^{r,s}` of type: 

 

- `D_n^{(1)}` for all `1 \leq r < n-1`, 

- `B_n^{(1)}` for all `1 \leq r < n`, 

- `A_{2n-1}^{(2)}` for all `1 \leq r \leq n`. 

 

TESTS:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 1], 1, 1, model='KR') 

sage: TestSuite(KRT).run() 

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

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

sage: KRT = crystals.KirillovReshetikhin(['A', 5, 2], 2, 2, model='KR') 

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

""" 

def _fill(self, weight): 

r""" 

Return the highest weight KR tableau of weight ``weight``. 

 

INPUT: 

 

- ``weight`` -- The weight of the highest weight KR tableau (the 

conjugate of the shape of the KR crystal's tableau) 

 

OUTPUT: 

 

- A `r \times s` tableau 

 

EXAMPLES:: 

 

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

sage: KRT._fill([]) 

[[1], [-1]] 

sage: KRT = crystals.KirillovReshetikhin(['D', 14, 1], 12, 7, model='KR') 

sage: KRT._fill([10,10,8,2,2,2]) 

[[1, 1, 1, 1, 1, 7, 1], [2, 2, 2, 2, 2, 8, 2], [3, 3, 7, 9, 7, 9, 3], [4, 4, 8, 10, 8, 10, 4], [5, 5, 9, 11, 9, 11, 5], [6, 6, 10, 12, 10, 12, 6], [7, 7, 11, -12, 11, -12, 7], [8, 8, 12, -11, 12, -11, 8], [9, 9, -12, -10, -12, -10, 9], [10, 10, -11, -9, -11, -9, -9], [-12, 11, -10, -8, -10, -8, -8], [-11, 12, -9, -7, -9, -7, -7]] 

sage: KRT._fill([10,10,6,2,2,2]) 

[[1, 1, 1, 1, 1, 5, 1], [2, 2, 2, 2, 2, 6, 2], [3, 3, 9, 7, 9, 7, 3], [4, 4, 10, 8, 10, 8, 4], [5, 5, 11, 9, 11, 9, 5], [6, 6, 12, 10, 12, 10, 6], [7, 7, -12, 11, -12, 11, 7], [8, 8, -11, 12, -11, 12, 8], [9, 9, -10, -12, -10, -12, -8], [10, 10, -9, -11, -9, -11, -7], [-12, 11, -8, -10, -8, -10, -6], [-11, 12, -7, -9, -7, -9, -5]] 

""" 

# Add zeros until the shape has length s 

weight_list = list(weight) # Make sure we have a list 

while len(weight_list) != self._s: 

weight_list.append(0) 

 

tableau = [] 

i = 0 

# Step 0 - Fill first columns of height r 

while i < self._s and weight_list[i] == self._r: 

tableau.append( [self._r - j for j in range(self._r)] ) 

i += 1 

 

# Step 1 - Add the alternating columns until we hit an odd number of columns 

c = -1 

while i < self._s: 

# If it is an odd number of columns 

if i == self._s - 1 or weight_list[i] != weight_list[i+1]: 

c = weight_list[i] 

i += 1 

break 

temp_list = [-(weight_list[i] + j + 1) for j in range(self._r - weight_list[i])] 

for j in range(weight_list[i]): 

temp_list.append(weight_list[i] - j) 

tableau.append(temp_list) 

tableau.append( [self._r - j for j in range(self._r)] ) 

i += 2 

 

# Step 2 - Add the x dependent columns 

x = c + 1 

while i < self._s: 

temp_list = [-x - j for j in range(self._r - x + 1)] # +1 for indexing 

for j in range(x - weight_list[i] - 1): # +1 for indexing 

temp_list.append(self._r - j) 

x = temp_list[-1] # This is the h+1 entry of the column 

for j in range(weight_list[i]): 

temp_list.append(weight_list[i] - j) 

 

tableau.append(temp_list) 

i += 1 

 

# Step 3 - Add the final column 

if c > -1: 

val = (self._r + x - 1) // 2 

temp_list = [-x - j for j in range(self._r - val)] 

for j in range(val): 

temp_list.append(val - j) 

tableau.append(temp_list) 

 

return self.element_class(self, [self.letters(x) for x in flatten(tableau)]) 

 

def _build_module_generators(self): 

""" 

Build the module generators. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 2, 3, model='KR') 

sage: KRT._build_module_generators() 

([[-2, 1, 1], [-1, 2, -1]], [[1, -2, 1], [2, -1, 2]], 

[[1, 1, 1], [2, 2, -1]], [[1, 1, 1], [2, 2, 2]]) 

""" 

return tuple(self._fill(weight) for weight in 

horizontal_dominoes_removed(self._s, self._r)) 

 

def from_kirillov_reshetikhin_crystal(self, krc): 

""" 

Construct an element of ``self`` from the Kirillov-Reshetikhin 

crystal element ``krc``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 2, 3, model='KR') 

sage: C = crystals.KirillovReshetikhin(['D',4,1], 2, 3, model='KN') 

sage: krc = C(4,3); krc 

[[3], [4]] 

sage: KRT.from_kirillov_reshetikhin_crystal(krc) 

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

""" 

# To build a KR tableau from a KR crystal: 

# 1 - start with a highest weight KR tableau generated from the 

# shape of the KR crystal 

# 2 - determine a path from the KR crystal to its highest weight 

# 3 - apply the inverse path to the highest weight KR tableau 

lifted = krc.lift() 

weight = lifted.to_tableau().shape().conjugate() 

f_str = reversed(lifted.to_highest_weight()[1]) 

return self._fill(weight).f_string(f_str) 

 

class KRTableauxTypeHorizonal(KirillovReshetikhinTableaux): 

r""" 

Kirillov-Reshetikhin tableaux `B^{r,s}` of type: 

 

- `C_n^{(1)}` for `1 \leq r < n`, 

- `A_{2n}^{(2)\dagger}` for `1 \leq r \leq n`. 

 

TESTS:: 

 

sage: KRT = crystals.KirillovReshetikhin(['C', 3, 1], 2, 2, model='KR') 

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

sage: KRT = crystals.KirillovReshetikhin(CartanType(['A', 4, 2]).dual(), 2, 2, model='KR') 

sage: TestSuite(KRT).run() 

""" 

def _fill(self, shape): 

r""" 

Return the highest weight KR tableau of weight ``shape``. 

 

INPUT: 

 

- ``shape`` -- The shape of the KR crystal's tableau 

 

OUTPUT: 

 

- A `r \times s` tableau 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['C', 5, 1], 3, 5, model='KR') 

sage: KRT._fill([3,3,1]) 

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

sage: KRT = crystals.KirillovReshetikhin(['C', 10, 1], 5, 6, model='KR') 

sage: KRT._fill([6,4,2,2]) 

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

sage: KRT._fill([6,4]) 

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

""" 

# Add zeros until the shape has length s 

shape_list = list(shape) # Make sure we have a list 

while len(shape_list) != self._r: 

shape_list.append(0) 

 

lst = [] 

for col in range(1, self._s+1): 

if (self._s - col) % 2 == 0: 

lst.extend( [self.letters(self._r - x) for x in range(self._r)] ) 

else: 

m = self._r 

for j, val in enumerate(shape_list): 

if col >= val: 

m = j 

break 

lst.extend([self.letters(-x) for x in range(m+1, self._r+1)]) 

lst.extend([self.letters(m - x) for x in range(m)]) 

 

return self.element_class(self, lst) 

 

def _build_module_generators(self): 

""" 

Build the module generators. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['C',4,1], 2, 3, model='KR') 

sage: KRT._build_module_generators() 

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

""" 

return tuple(self._fill(shape) for shape in horizontal_dominoes_removed(self._r, self._s)) 

 

def from_kirillov_reshetikhin_crystal(self, krc): 

""" 

Construct an element of ``self`` from the Kirillov-Reshetikhin 

crystal element ``krc``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['C',4,1], 2, 3, model='KR') 

sage: C = crystals.KirillovReshetikhin(['C',4,1], 2, 3, model='KN') 

sage: krc = C(4,3); krc 

[[3], [4]] 

sage: KRT.from_kirillov_reshetikhin_crystal(krc) 

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

""" 

# To build a KR tableau from a KR crystal: 

# 1 - start with a highest weight KR tableau generated from the 

# shape of the KR crystal 

# 2 - determine a path from the KR crystal to its highest weight 

# 3 - apply the inverse path to the highest weight KR tableau 

lifted = krc.lift() 

shape = lifted.to_tableau().shape() 

f_str = reversed(lifted.to_highest_weight()[1]) 

return self._fill(shape).f_string(f_str) 

 

class KRTableauxTypeBox(KRTableauxTypeVertical): 

r""" 

Kirillov-Reshetikhin tableaux `B^{r,s}` of type: 

 

- `A_{2n}^{(2)}` for all `r \leq n`, 

- `D_{n+1}^{(2)}` for all `r < n`, 

- `D_4^{(3)}` for `r = 1`. 

 

TESTS:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 2], 2, 2, model='KR') 

sage: TestSuite(KRT).run() 

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 2], 2, 2, model='KR') 

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

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 3], 1, 2, model='KR') 

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

""" 

def _fill(self, weight): 

r""" 

Return the highest weight KR tableau of weight ``weight``. 

 

INPUT: 

 

- ``weight`` -- The weight of the highest weight KR tableau (the 

conjugate of the shape of the KR crystal's tableau) 

 

OUTPUT: 

 

- A `r \times s` tableau 

 

EXAMPLES:: 

 

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

sage: KRT._fill([]) 

[[1], [-1]] 

sage: KRT = crystals.KirillovReshetikhin(['D', 14, 1], 12, 7, model='KR') 

sage: KRT._fill([10,10,8,2,2,2]) 

[[1, 1, 1, 1, 1, 7, 1], [2, 2, 2, 2, 2, 8, 2], [3, 3, 7, 9, 7, 9, 3], [4, 4, 8, 10, 8, 10, 4], [5, 5, 9, 11, 9, 11, 5], [6, 6, 10, 12, 10, 12, 6], [7, 7, 11, -12, 11, -12, 7], [8, 8, 12, -11, 12, -11, 8], [9, 9, -12, -10, -12, -10, 9], [10, 10, -11, -9, -11, -9, -9], [-12, 11, -10, -8, -10, -8, -8], [-11, 12, -9, -7, -9, -7, -7]] 

sage: KRT._fill([10,10,6,2,2,2]) 

[[1, 1, 1, 1, 1, 5, 1], [2, 2, 2, 2, 2, 6, 2], [3, 3, 9, 7, 9, 7, 3], [4, 4, 10, 8, 10, 8, 4], [5, 5, 11, 9, 11, 9, 5], [6, 6, 12, 10, 12, 10, 6], [7, 7, -12, 11, -12, 11, 7], [8, 8, -11, 12, -11, 12, 8], [9, 9, -10, -12, -10, -12, -8], [10, 10, -9, -11, -9, -11, -7], [-12, 11, -8, -10, -8, -10, -6], [-11, 12, -7, -9, -7, -9, -5]] 

""" 

# Add zeros until the shape has length s 

weight_list = list(weight) # Make sure we have a list 

while len(weight_list) != self._s: 

weight_list.append(0) 

 

tableau = [] 

i = 0 

# Step 0 - Fill first columns of height r 

while i < self._s and weight_list[i] == self._r: 

tableau.append( [self._r - j for j in range(self._r)] ) 

i += 1 

 

# Step 1 - Add the alternating columns until we hit an odd number of columns 

c = -1 

while i < self._s: 

# If it is an odd number of columns 

if i == self._s - 1 or weight_list[i] != weight_list[i+1]: 

c = weight_list[i] 

i += 1 

break 

temp_list = [-(weight_list[i] + j + 1) for j in range(self._r - weight_list[i])] 

for j in range(weight_list[i]): 

temp_list.append(weight_list[i] - j) 

tableau.append(temp_list) 

tableau.append( [self._r - j for j in range(self._r)] ) 

i += 2 

 

# Step 2 - Add the x dependent columns 

x = c + 1 

while i < self._s: 

temp_list = [-x - j for j in range(self._r - x + 1)] # +1 for indexing 

for j in range(x - weight_list[i] - 1): # +1 for indexing 

temp_list.append(self._r - j) 

x = temp_list[-1] # This is the h+1 entry of the column 

for j in range(weight_list[i]): 

temp_list.append(weight_list[i] - j) 

 

tableau.append(temp_list) 

i += 1 

 

# Step 3 - Add the final column 

if c > -1: 

val = x - 1 

temp_list = ['E' for j in range(self._r - val)] 

for j in range(val): 

temp_list.append(val - j) 

tableau.append(temp_list) 

 

return self.element_class(self, [self.letters(x) for x in flatten(tableau)]) 

 

def _build_module_generators(self): 

""" 

Build the module generators. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A',4,2], 2, 2, model='KR') 

sage: KRT._build_module_generators() 

([[-2, 1], [-1, 2]], [[2, 1], [-2, E]], [[1, E], [2, E]], 

[[1, 1], [-2, 2]], [[1, 1], [2, E]], [[1, 1], [2, 2]]) 

""" 

return tuple(self._fill(weight) for weight in partitions_in_box(self._s, self._r)) 

 

class KRTableauxSpin(KRTableauxRectangle): 

r""" 

Kirillov-Reshetikhin tableaux `B^{r,s}` of type `D_n^{(1)}` with 

`r = n, n-1`. 

 

TESTS:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 1], 3, 2, model='KR') 

sage: TestSuite(KRT).run() 

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

sage: TestSuite(KRT).run() 

""" 

def _build_module_generators(self): 

r""" 

Build the module generators. 

 

There is only one module generator which corresponds to a single 

`n \times s` rectangle. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 1], 3, 3, model='KR') 

sage: KRT._build_module_generators() 

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

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 1], 4, 3, model='KR') 

sage: KRT._build_module_generators() 

([[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]],) 

""" 

n = self.cartan_type().classical().rank() 

if self._r == n: 

return KRTableauxRectangle._build_module_generators(self) 

 

tableau = [] 

for i in range(self._s): 

tableau.append( [-n] + [self._r - j for j in range(self._r)] ) 

 

return (self.element_class(self, [self.letters(x) for x in flatten(tableau)]),) 

 

class KRTableauxBn(KRTableauxTypeHorizonal): 

""" 

Kirillov-Reshetkhin tableaux `B^{n,s}` of type `B_n^{(1)}`. 

 

TESTS:: 

 

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

sage: TestSuite(KRT).run() 

""" 

def _build_module_generators(self): 

""" 

Build the module generators. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['B', 2, 1], 2, 2, model='KR') 

sage: KRT._build_module_generators() 

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

""" 

odd = int(self._s % 2) 

shapes = [[int(x * 2 + odd) for x in sh] for sh 

in vertical_dominoes_removed(self._r, self._s // 2)] 

return tuple(self._fill(sh) for sh in shapes) 

 

def from_kirillov_reshetikhin_crystal(self, krc): 

""" 

Construct an element of ``self`` from the Kirillov-Reshetikhin 

crystal element ``krc``. 

 

EXAMPLES:: 

 

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

sage: C = crystals.KirillovReshetikhin(['B',3,1], 3, 3, model='KN') 

sage: krc = C.module_generators[1].f_string([3,2,3,1,3,3]); krc 

[++-, [[2], [0], [-3]]] 

sage: KR.from_kirillov_reshetikhin_crystal(krc) 

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

""" 

# To build a KR tableau from a type B_n spinor KR crystal: 

# 1 - determine a path from the KR crystal to its highest weight 

# 2 - find the corresponding highest weight KR tableau 

# 3 - apply the inverse path to the highest weight KR tableau 

lifted = krc.lift() 

to_hw = lifted.to_highest_weight() 

f_str = reversed(to_hw[1]) 

wt = to_hw[0].weight() 

for x in self.module_generators: 

if x.classical_weight() == wt: 

return x.f_string(f_str) 

raise ValueError("no matching highest weight element found") 

 

class KirillovReshetikhinTableauxElement(TensorProductOfRegularCrystalsElement): 

r""" 

A Kirillov-Reshetikhin tableau. 

 

For more information, see 

:class:`~sage.combinat.rigged_configurations.kr_tableaux.KirillovReshetikhinTableaux` 

and 

:class:`~sage.combinat.rigged_configurations.tensor_product_kr_tableaux.TensorProductOfKirillovReshetikhinTableaux`. 

""" 

def __init__(self, parent, list, **options): 

r""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR') 

sage: elt = KRT(4, 3); elt 

[[3], [4]] 

sage: TestSuite(elt).run() 

""" 

# Make sure we are a list of letters 

if list != [] and not isinstance(list[0], (parent.letters.element_class, EmptyLetter)): 

list = [parent.letters(x) for x in list] 

TensorProductOfRegularCrystalsElement.__init__(self, parent, list) 

 

def _repr_(self): 

""" 

Return the string representation of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 1, model='KR') 

sage: KRT(3,2) 

[[2], [3]] 

""" 

return repr(self.to_array()) 

 

def _repr_diagram(self): 

""" 

Return a string representation of ``self`` as a diagram. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A',4,1], 2, 2, model='KR') 

sage: elt = KRT(2,1,4,3) 

sage: print(elt._repr_diagram()) 

1 3 

2 4 

""" 

return self.to_tableau()._repr_diagram() 

 

def _latex_(self): 

r""" 

Return a latex representation of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 3, model='KR') 

sage: latex(KRT(3,2,4,2,4,3)) 

{\def\lr#1{\multicolumn{1}{|@{\hspace{.6ex}}c@{\hspace{.6ex}}|}{\raisebox{-.3ex}{$#1$}}} 

\raisebox{-.6ex}{$\begin{array}[b]{*{3}c}\cline{1-3} 

\lr{2}&\lr{2}&\lr{3}\\\cline{1-3} 

\lr{3}&\lr{4}&\lr{4}\\\cline{1-3} 

\end{array}$} 

} 

""" 

from sage.combinat.output import tex_from_array 

return tex_from_array([[val._latex_() for val in row] for row in self.to_array()]) 

 

def _ascii_art_(self): 

r""" 

Return an ASCII art representation of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A',4,1], 2, 2, model='KR') 

sage: ascii_art(KRT(2,1,4,3)) 

1 3 

2 4 

""" 

from sage.typeset.ascii_art import AsciiArt 

return AsciiArt(self._repr_diagram().splitlines()) 

 

def _unicode_art_(self): 

r""" 

Return a unicode art representation of ``self``. 

 

EXAMPLES:: 

 

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

sage: unicode_art(KRT(2,1,-4,3)) 

┌───┬───┐ 

│ 1 │ 3 │ 

├───┼───┤ 

│ 2 │ 4̄ │ 

└───┴───┘ 

""" 

return self.to_tableau()._unicode_art_() 

 

def to_kirillov_reshetikhin_crystal(self): 

r""" 

Construct a 

:func:`~sage.combinat.crystals.kirillov_reshetihkin.KashiwaraNakashimaTableaux` 

element from ``self``. 

 

We construct the Kirillov-Reshetikhin crystal element as follows: 

 

1. Determine the shape `\lambda` of the KR crystal from the weight. 

2. Determine a path `e_{i_1} e_{i_2} \cdots e_{i_k}` to the highest 

weight. 

3. Apply `f_{i_k} \cdots f_{i_2} f_{i_1}` to a highest weight KR 

crystal of shape `\lambda`. 

 

EXAMPLES:: 

 

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

sage: elt = KRT(3,2,-1,1); elt 

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

sage: elt.to_kirillov_reshetikhin_crystal() 

[[2], [3]] 

 

TESTS: 

 

Spinor tests:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 4, 3, model='KR') 

sage: KRC = crystals.KirillovReshetikhin(['D',4,1], 4, 3, model='KN') 

sage: elt = KRT(-3,-4,2,1,-3,-4,2,1,-2,-4,3,1); elt 

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

sage: ret = elt.to_kirillov_reshetikhin_crystal(); ret 

[++--, [[1], [3], [-4], [-3]]] 

sage: test = KRT(ret); test 

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

sage: test == elt 

True 

""" 

return self.parent().kirillov_reshetikhin_crystal()(self) 

 

@cached_method 

def to_array(self, rows=True): 

r""" 

Return a 2-dimensional array representation of this 

Kirillov-Reshetikhin element. 

 

If the output is in rows, then it outputs the top row first (in the 

English convention) from left to right. 

 

For example: if the reading word is `[2, 1, 4, 3]`, so as a 

`2 \times 2` tableau:: 

 

1 3 

2 4 

 

we output ``[[1, 3], [2, 4]]``. 

 

If the output is in columns, then it outputs the leftmost column first 

with the bottom element first. In other words this parses the reading 

word into its columns. 

 

Continuing with the previous example, the output would be 

``[[2, 1], [4, 3]]``. 

 

INPUT: 

 

- ``rows`` -- (Default: ``True``) Set to ``True`` if the resulting 

array is by row, otherwise it is by column. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 2, model='KR') 

sage: elt = KRT(2, 1, 4, 3) 

sage: elt.to_array() 

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

sage: elt.to_array(False) 

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

""" 

ret_list = [] 

h = self.parent()._tableau_height 

s = self.parent()._s 

if rows: 

for i in reversed(range(h)): 

row = [] 

for j in range(s): 

row.append(self[j * h + i]) 

ret_list.append(row) 

else: 

for j in range(s): 

col = [] 

for i in range(h): 

col.append(self[j * h + i]) 

ret_list.append(col) 

 

return ret_list 

 

@cached_method 

def to_tableau(self): 

""" 

Return a :class:`Tableau` object of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 2, model='KR') 

sage: elt = KRT(2, 1, 4, 3); elt 

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

sage: t = elt.to_tableau(); t 

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

sage: type(t) 

<class 'sage.combinat.tableau.Tableaux_all_with_category.element_class'> 

""" 

return Tableau(self.to_array()) 

 

def pp(self): 

""" 

Pretty print ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['A', 4, 1], 2, 2, model='KR') 

sage: elt = KRT(2, 1, 4, 3); elt 

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

sage: elt.pp() 

1 3 

2 4 

""" 

self.to_tableau().pp() 

 

def to_classical_highest_weight(self, index_set=None): 

r""" 

Return the classical highest weight element corresponding to ``self``. 

 

INPUT: 

 

- ``index_set`` -- (Default: ``None``) Return the highest weight 

with respect to the index set. If ``None`` is passed in, then this 

uses the classical index set. 

 

OUTPUT: 

 

A pair ``[H, f_str]`` where ``H`` is the highest weight element and 

``f_str`` is a list of `a_i` of `f_{a_i}` needed to reach ``H``. 

 

EXAMPLES:: 

 

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

sage: elt = KRTab(3,2,-1,1); elt 

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

sage: elt.to_classical_highest_weight() 

[[[1, 1], [2, -1]], [1, 2]] 

""" 

if index_set is None: 

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

for i in index_set: 

next = self.e(i) 

if next is not None: 

hw = next.to_classical_highest_weight(index_set=index_set) 

return [hw[0], [i] + hw[1]] 

return [self, []] 

 

def weight(self): 

""" 

Return the weight of ``self``. 

 

EXAMPLES:: 

 

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

sage: KR.module_generators[1].weight() 

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

""" 

return self.Phi() - self.Epsilon() 

 

@cached_method 

def classical_weight(self): 

r""" 

Return the classical weight of ``self``. 

 

EXAMPLES:: 

 

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

sage: elt = KRT(3,2,-1,1); elt 

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

sage: elt.classical_weight() 

(0, 1, 1, 0) 

""" 

F = self.cartan_type().classical().root_system() 

if F.ambient_space() is None: 

WLR = F.weight_lattice() 

else: 

WLR = F.ambient_space() 

return sum((self[j].weight() for j in range(len(self))), WLR.zero()) 

 

def e(self, i): 

""" 

Perform the action of `e_i` on ``self``. 

 

.. TODO:: 

 

Implement a direct action of `e_0` without moving to KR crystals. 

 

EXAMPLES:: 

 

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

sage: KRT.module_generators[0].e(0) 

[[-2, 1], [-1, -1]] 

""" 

if i == self.parent()._cartan_type.special_node(): 

ret = self.to_kirillov_reshetikhin_crystal().e0() 

if ret is None: 

return None 

return ret.to_kirillov_reshetikhin_tableau() 

return TensorProductOfRegularCrystalsElement.e(self, i) 

 

def f(self, i): 

""" 

Perform the action of `f_i` on ``self``. 

 

.. TODO:: 

 

Implement a direct action of `f_0` without moving to KR crystals. 

 

EXAMPLES:: 

 

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

sage: KRT.module_generators[0].f(0) 

[[1, 1], [2, -1]] 

""" 

if i == self.parent()._cartan_type.special_node(): 

ret = self.to_kirillov_reshetikhin_crystal().f0() 

if ret is None: 

return None 

return ret.to_kirillov_reshetikhin_tableau() 

return TensorProductOfRegularCrystalsElement.f(self, i) 

 

def epsilon(self, i): 

r""" 

Compute `\varepsilon_i` of ``self``. 

 

.. TODO:: 

 

Implement a direct action of `\varepsilon_0` without moving to 

KR crystals. 

 

EXAMPLES:: 

 

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

sage: KRT.module_generators[0].epsilon(0) 

2 

""" 

if i == self.parent()._cartan_type.special_node(): 

return self.to_kirillov_reshetikhin_crystal().epsilon0() 

return TensorProductOfRegularCrystalsElement.epsilon(self, i) 

 

def phi(self, i): 

r""" 

Compute `\varphi_i` of ``self``. 

 

.. TODO:: 

 

Compute `\varphi_0` without moving to KR crystals. 

 

EXAMPLES:: 

 

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

sage: KRT.module_generators[0].phi(0) 

2 

""" 

if i == self.parent()._cartan_type.special_node(): 

return self.to_kirillov_reshetikhin_crystal().phi0() 

return TensorProductOfRegularCrystalsElement.phi(self, i) 

 

def left_split(self): 

r""" 

Return the image of ``self`` under the left column splitting map. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 2, 3, model='KR') 

sage: mg = KRT.module_generators[1]; mg.pp() 

1 -2 1 

2 -1 2 

sage: ls = mg.left_split(); ls.pp() 

1 (X) -2 1 

2 -1 2 

sage: ls.parent() 

Tensor product of Kirillov-Reshetikhin tableaux of type ['D', 4, 1] and factor(s) ((2, 1), (2, 2)) 

""" 

P = self.parent() 

if P._s == 1: 

raise ValueError("cannot split a single column") 

from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import \ 

TensorProductOfKirillovReshetikhinTableaux 

r = P._r 

TP = TensorProductOfKirillovReshetikhinTableaux(P._cartan_type, [[r, 1], [r, P._s-1]]) 

lf = TP.crystals[0](*(self[:r])) 

rf = TP.crystals[1](*(self[r:])) 

return TP(lf, rf) 

 

def right_split(self): 

r""" 

Return the image of ``self`` under the right column splitting map. 

 

Let `\ast` denote the :meth:`Lusztig involution<lusztig_involution>`, 

and `\mathrm{ls}` as the :meth:`left splitting map<left_split>`. 

The right splitting map is defined as 

`\mathrm{rs} := \ast \circ \mathrm{ls} \circ \ast`. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 2, 3, model='KR') 

sage: mg = KRT.module_generators[1]; mg.pp() 

1 -2 1 

2 -1 2 

sage: ls = mg.right_split(); ls.pp() 

-2 1 (X) 1 

-1 2 2 

sage: ls.parent() 

Tensor product of Kirillov-Reshetikhin tableaux of type ['D', 4, 1] and factor(s) ((2, 2), (2, 1)) 

""" 

return self.lusztig_involution().left_split().lusztig_involution() 

 

KirillovReshetikhinTableaux.Element = KirillovReshetikhinTableauxElement 

 

class KRTableauxSpinElement(KirillovReshetikhinTableauxElement): 

r""" 

Kirillov-Reshetikhin tableau for spinors. 

 

Here we are in the embedding `B(\Lambda_n) \hookrightarrow 

B(2 \Lambda_n)`, so `e_i` and `f_i` act by `e_i^2` and `f_i^2` 

respectively for all `i \neq 0`. We do this so our columns are full 

width (as opposed to half width and/or uses a `\pm` representation). 

""" 

def e(self, i): 

r""" 

Calculate the action of `e_i` on ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 4, 1, model='KR') 

sage: KRT(-1, -4, 3, 2).e(1) 

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

sage: KRT(-1, -4, 3, 2).e(3) 

""" 

if i == self.parent()._cartan_type.special_node(): 

# Only need to do it once since we pull to the KR crystal 

return KirillovReshetikhinTableauxElement.e(self, i) 

 

half = KirillovReshetikhinTableauxElement.e(self, i) 

if half is None: 

return None 

return KirillovReshetikhinTableauxElement.e(half, i) 

 

def f(self, i): 

r""" 

Calculate the action of `f_i` on ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 4, 1, model='KR') 

sage: KRT(-1, -4, 3, 2).f(1) 

sage: KRT(-1, -4, 3, 2).f(3) 

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

""" 

if i == self.parent()._cartan_type.special_node(): 

# Only need to do it once since we pull to the KR crystal 

return KirillovReshetikhinTableauxElement.f(self, i) 

 

half = KirillovReshetikhinTableauxElement.f(self, i) 

if half is None: 

return None 

 

return KirillovReshetikhinTableauxElement.f(half, i) 

 

def epsilon(self, i): 

r""" 

Compute `\varepsilon_i` of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 4, 1, model='KR') 

sage: KRT(-1, -4, 3, 2).epsilon(1) 

1 

sage: KRT(-1, -4, 3, 2).epsilon(3) 

0 

""" 

if i == self.parent()._cartan_type.special_node(): 

# Don't need to half it since we pull to the KR crystal 

return KirillovReshetikhinTableauxElement.epsilon(self, i) 

return KirillovReshetikhinTableauxElement.epsilon(self, i) // 2 

 

def phi(self, i): 

r""" 

Compute `\varphi_i` of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,1], 4, 1, model='KR') 

sage: KRT(-1, -4, 3, 2).phi(1) 

0 

sage: KRT(-1, -4, 3, 2).phi(3) 

1 

""" 

if i == self.parent()._cartan_type.special_node(): 

# Don't need to half it since we pull to the KR crystal 

return KirillovReshetikhinTableauxElement.phi(self, i) 

return KirillovReshetikhinTableauxElement.phi(self, i) // 2 

 

@cached_method 

def to_array(self, rows=True): 

r""" 

Return a 2-dimensional array representation of this 

Kirillov-Reshetikhin element. 

 

If the output is in rows, then it outputs the top row first (in the 

English convention) from left to right. 

 

For example: if the reading word is `[2, 1, 4, 3]`, so as a 

`2 \times 2` tableau:: 

 

1 3 

2 4 

 

we output ``[[1, 3], [2, 4]]``. 

 

If the output is in columns, then it outputs the leftmost column first 

with the bottom element first. In other words this parses the reading 

word into its columns. 

 

Continuing with the previous example, the output would be 

``[[2, 1], [4, 3]]``. 

 

INPUT: 

 

- ``rows`` -- (Default: ``True``) Set to ``True`` if the resulting 

array is by row, otherwise it is by column. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 1], 4, 3, model='KR') 

sage: elt = KRT(-3,-4,2,1,-3,-4,2,1,-2,-4,3,1) 

sage: elt.to_array() 

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

sage: elt.to_array(False) 

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

""" 

ret_list = [] 

h = self.parent()._cartan_type.classical().rank() 

s = self.parent()._s 

if rows: 

for i in reversed(range(h)): 

row = [] 

for j in range(s): 

row.append(self[j * h + i]) 

ret_list.append(row) 

else: 

for j in range(s): 

col = [] 

for i in range(h): 

col.append(self[j * h + i]) 

ret_list.append(col) 

 

return ret_list 

 

def left_split(self): 

""" 

Return the image of ``self`` under the left column splitting map. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 1], 4, 3, model='KR') 

sage: elt = KRT(-3,-4,2,1,-3,-4,2,1,-2,-4,3,1); elt.pp() 

1 1 1 

2 2 3 

-4 -4 -4 

-3 -3 -2 

sage: elt.left_split().pp() 

1 (X) 1 1 

2 2 3 

-4 -4 -4 

-3 -3 -2 

""" 

P = self.parent() 

if P._s == 1: 

raise ValueError("cannot split a single column") 

from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import \ 

TensorProductOfKirillovReshetikhinTableaux 

h = P._cartan_type.classical().rank() 

TP = TensorProductOfKirillovReshetikhinTableaux(P._cartan_type, [[P._r, 1], [P._r, P._s-1]]) 

lf = TP.crystals[0](*(self[:h])) 

rf = TP.crystals[1](*(self[h:])) 

return TP(lf, rf) 

 

# FIXME: This is a copy of the above classical weight, and cached_method 

# overwrites this method if it is called via super. 

@cached_method 

def classical_weight(self): 

r""" 

Return the classical weight of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 1], 4, 1, model='KR') 

sage: KRT.module_generators[0].classical_weight() 

(1/2, 1/2, 1/2, 1/2) 

""" 

F = self.cartan_type().classical().root_system() 

if F.ambient_space() is None: 

WLR = F.weight_lattice() 

else: 

WLR = F.ambient_space() 

return sum((self[j].weight() for j in range(len(self))), WLR.zero()) / 2 

 

KRTableauxBn.Element = KRTableauxSpinElement 

KRTableauxSpin.Element = KRTableauxSpinElement 

 

class KRTableauxDTwistedSpin(KRTableauxRectangle): 

r""" 

Kirillov-Reshetikhin tableaux `B^{r,s}` of type `D_n^{(2)}` with `r = n`. 

 

EXAMPLES:: 

 

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

sage: KRT.cardinality() 

8 

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

sage: KRT.cardinality() == KRC.cardinality() 

True 

""" 

Element = KRTableauxSpinElement 

 

class KRTableauxTypeFromRCElement(KirillovReshetikhinTableauxElement): 

r""" 

A Kirillov-Reshetikhin tableau constructed from rigged configurations 

under the bijection `\Phi`. 

""" 

def e(self, i): 

""" 

Perform the action of `e_i` on ``self``. 

 

.. TODO:: 

 

Implement a direct action of `e_0` without moving to 

rigged configurations. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,3], 2, 1, model='KR') 

sage: KRT.module_generators[0].e(0) 

[[2], [E]] 

""" 

if i == self.parent().cartan_type().special_node(): 

P = self.parent() 

from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import TensorProductOfKirillovReshetikhinTableaux 

K = TensorProductOfKirillovReshetikhinTableaux(P.cartan_type(), [[2, P.s()]]) 

ret = K(self).to_rigged_configuration() 

RC = ret.parent() 

ret = ret.to_virtual_configuration().e(0) 

if ret is None: 

return None 

ret = RC.from_virtual(ret) 

return ret.to_tensor_product_of_kirillov_reshetikhin_tableaux()[0] 

return TensorProductOfRegularCrystalsElement.e(self, i) 

 

def f(self, i): 

""" 

Perform the action of `f_i` on ``self``. 

 

.. TODO:: 

 

Implement a direct action of `f_0` without moving to 

rigged configurations. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,3], 2, 1, model='KR') 

sage: KRT.module_generators[0].f(0) 

sage: KRT.module_generators[3].f(0) 

[[1], [0]] 

""" 

if i == self.parent().cartan_type().special_node(): 

P = self.parent() 

from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import TensorProductOfKirillovReshetikhinTableaux 

K = TensorProductOfKirillovReshetikhinTableaux(P.cartan_type(), [[2, P.s()]]) 

ret = K(self).to_rigged_configuration() 

RC = ret.parent() 

ret = ret.to_virtual_configuration().f(0) 

if ret is None: 

return None 

ret = RC.from_virtual(ret) 

return ret.to_tensor_product_of_kirillov_reshetikhin_tableaux()[0] 

return TensorProductOfRegularCrystalsElement.f(self, i) 

 

def epsilon(self, i): 

r""" 

Compute `\varepsilon_i` of ``self``. 

 

.. TODO:: 

 

Implement a direct action of `\epsilon_0` without moving to 

KR crystals. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,3], 2, 2, model='KR') 

sage: KRT.module_generators[0].epsilon(0) 

6 

""" 

if i == self.parent().cartan_type().special_node(): 

P = self.parent() 

from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import TensorProductOfKirillovReshetikhinTableaux 

K = TensorProductOfKirillovReshetikhinTableaux(P.cartan_type(), [[2, P.s()]]) 

rc = K(self).to_rigged_configuration().to_virtual_configuration() 

return rc.epsilon(0) 

return TensorProductOfRegularCrystalsElement.epsilon(self, i) 

 

def phi(self, i): 

r""" 

Compute `\varphi_i` of ``self``. 

 

.. TODO:: 

 

Compute `\phi_0` without moving to KR crystals. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,3], 2, 2, model='KR') 

sage: KRT.module_generators[0].phi(0) 

0 

""" 

if i == self.parent().cartan_type().special_node(): 

P = self.parent() 

from sage.combinat.rigged_configurations.tensor_product_kr_tableaux import TensorProductOfKirillovReshetikhinTableaux 

K = TensorProductOfKirillovReshetikhinTableaux(P.cartan_type(), [[2, P.s()]]) 

rc = K(self).to_rigged_configuration().to_virtual_configuration() 

return rc.phi(0) 

return TensorProductOfRegularCrystalsElement.phi(self, i) 

 

 

class KRTableauxTypeFromRC(KirillovReshetikhinTableaux): 

r""" 

Kirillov-Reshetikhin tableaux `B^{r,s}` constructed from rigged 

configurations under the bijection `\Phi`. 

 

.. WARNING:: 

 

The Kashiwara-Nakashima version is not implemented due to the 

non-trivial multiplicities of classical components, so 

:meth:`classical_decomposition` does not work. 

""" 

def __init__(self, cartan_type, r, s): 

r""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D', 4, 3], 2, 1, model='KR') 

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

""" 

# We must modify the constructor of KirillovReshetikhinTableaux 

self._r = r 

self._s = s 

self._cartan_type = cartan_type 

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

self.letters = CrystalOfLetters(cartan_type.classical()) 

 

@lazy_attribute 

def module_generators(self): 

""" 

The module generators of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,3], 2, 1, model='KR') 

sage: KRT.module_generators 

([[1], [2]], [[1], [0]], [[1], [E]], [[E], [E]]) 

""" 

return self._build_module_generators() 

 

def _build_module_generators(self): 

r""" 

Return the module generators of ``self``. 

 

EXAMPLES:: 

 

sage: KRT = crystals.KirillovReshetikhin(['D',4,3], 2, 1, model='KR') 

sage: KRT._build_module_generators() 

([[1], [2]], [[1], [0]], [[1], [E]], [[E], [E]]) 

""" 

from sage.combinat.rigged_configurations.rigged_configurations import RiggedConfigurations 

RC = RiggedConfigurations(self._cartan_type, [[self._r, self._s]]) 

return tuple(mg.to_tensor_product_of_kirillov_reshetikhin_tableaux()[0] 

for mg in RC.module_generators) 

 

@lazy_attribute 

def _tableau_height(self): 

""" 

The height of the tableaux in ``self``. 

 

EXAMPLES:: 

 

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

sage: [crystals.KirillovReshetikhin(ct, r, 1, model='KR')._tableau_height 

....: for r in ct.classical().index_set()] 

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

""" 

if self._cartan_type.type() == 'E': 

if self._cartan_type.classical().rank() == 6: 

# 6 2 - 5 

# / / 

# 0 - 1 - 3 - 4 

if self._r == 1: 

return 1 

if self._r == [3, 6]: 

return 2 

if self._r in [2, 4]: 

return 3 

if self._r == 5: 

return 4 

if self._cartan_type.classical().rank() == 7: 

# 1-2-3 

# / 

# 0-7-6-5-4 

if self._r <= 3: 

return self._r + 1 

return 8 - self._r 

if self._cartan_type.classical().rank() == 8: 

# 1-2-3 

# / 

# 0-8-7-6-5-4 

if self._r <= 3: 

return self._r + 1 

return 9 - self._r 

if not self._cartan_type.is_untwisted_affine(): 

if self._cartan_type.dual().type() == 'G': 

return self._r 

return len(self.module_generators[0]) // self._s 

 

Element = KRTableauxTypeFromRCElement