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

1880

1881

1882

1883

1884

1885

1886

1887

1888

1889

1890

1891

1892

1893

1894

1895

1896

1897

1898

1899

1900

1901

1902

1903

1904

1905

1906

1907

1908

1909

1910

1911

1912

1913

1914

1915

1916

1917

1918

1919

1920

1921

1922

1923

1924

1925

1926

1927

1928

1929

1930

1931

1932

1933

1934

1935

1936

1937

1938

1939

1940

1941

1942

1943

1944

1945

1946

1947

1948

1949

1950

1951

1952

1953

1954

1955

1956

1957

1958

1959

1960

1961

1962

1963

1964

1965

1966

1967

1968

1969

1970

1971

1972

1973

1974

1975

1976

1977

1978

1979

1980

1981

1982

1983

1984

1985

1986

1987

1988

1989

1990

1991

1992

1993

1994

1995

1996

1997

1998

1999

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

2020

2021

2022

2023

2024

2025

2026

2027

2028

2029

2030

2031

2032

2033

2034

2035

2036

2037

2038

2039

2040

2041

2042

2043

2044

2045

2046

2047

2048

2049

2050

2051

2052

2053

2054

2055

2056

2057

2058

2059

2060

2061

2062

2063

2064

2065

2066

2067

2068

2069

2070

2071

2072

2073

2074

2075

2076

2077

2078

2079

2080

2081

2082

2083

2084

2085

2086

2087

2088

2089

2090

2091

2092

2093

2094

2095

2096

2097

2098

2099

2100

2101

2102

2103

2104

2105

2106

2107

2108

2109

2110

2111

2112

2113

2114

2115

2116

2117

2118

2119

2120

2121

2122

2123

2124

2125

2126

2127

2128

2129

2130

2131

2132

2133

2134

2135

2136

2137

2138

2139

2140

2141

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159

2160

2161

2162

2163

2164

2165

2166

2167

2168

2169

2170

2171

2172

2173

2174

2175

2176

2177

2178

2179

2180

2181

2182

2183

2184

2185

2186

2187

2188

2189

2190

2191

2192

2193

2194

2195

2196

2197

2198

2199

2200

2201

2202

2203

2204

2205

2206

2207

2208

2209

2210

2211

2212

2213

2214

2215

2216

2217

2218

2219

2220

2221

2222

2223

2224

2225

2226

2227

2228

2229

2230

2231

2232

2233

2234

2235

2236

2237

2238

2239

2240

2241

2242

2243

2244

2245

2246

2247

2248

2249

2250

2251

2252

2253

2254

2255

2256

2257

2258

2259

2260

2261

2262

2263

2264

2265

2266

2267

2268

2269

2270

2271

2272

2273

2274

2275

2276

2277

2278

2279

2280

2281

2282

2283

2284

2285

2286

2287

2288

2289

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300

2301

2302

2303

2304

2305

2306

2307

2308

2309

2310

2311

2312

2313

2314

2315

2316

2317

2318

2319

2320

2321

2322

2323

2324

2325

2326

2327

2328

2329

2330

2331

2332

2333

2334

2335

2336

2337

2338

2339

2340

2341

2342

2343

2344

2345

2346

2347

2348

2349

2350

2351

2352

2353

2354

2355

2356

2357

2358

2359

2360

2361

2362

2363

2364

2365

2366

2367

2368

2369

2370

2371

2372

2373

2374

2375

2376

2377

2378

2379

2380

2381

2382

2383

2384

2385

2386

2387

2388

2389

2390

2391

2392

2393

2394

2395

2396

2397

2398

2399

2400

2401

2402

2403

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428

2429

2430

2431

2432

2433

2434

2435

2436

2437

2438

2439

2440

2441

2442

2443

2444

2445

2446

2447

2448

2449

2450

2451

2452

2453

2454

2455

2456

2457

2458

2459

2460

2461

2462

2463

2464

2465

2466

2467

2468

2469

2470

2471

2472

2473

2474

2475

2476

2477

2478

2479

2480

2481

2482

2483

2484

2485

2486

2487

2488

2489

2490

2491

2492

2493

2494

2495

2496

2497

2498

2499

2500

2501

2502

2503

2504

2505

2506

2507

2508

2509

2510

2511

2512

2513

2514

2515

2516

2517

2518

2519

2520

2521

2522

2523

2524

2525

2526

2527

2528

2529

2530

2531

2532

2533

2534

2535

2536

2537

2538

2539

2540

2541

2542

2543

2544

2545

2546

2547

2548

2549

2550

2551

2552

2553

2554

2555

2556

2557

2558

2559

2560

2561

2562

2563

2564

2565

2566

2567

2568

2569

2570

2571

2572

2573

2574

2575

2576

2577

2578

2579

2580

2581

r""" 

Symmetric Group Algebra 

""" 

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

# Copyright (C) 2007 Mike Hansen <mhansen@gmail.com>, 

# 

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

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

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

from __future__ import print_function, absolute_import 

from six.moves import range 

 

from sage.misc.cachefunc import cached_method 

from .combinatorial_algebra import CombinatorialAlgebra 

from .free_module import CombinatorialFreeModule 

from sage.algebras.group_algebra import GroupAlgebra_class 

from sage.categories.weyl_groups import WeylGroups 

from sage.combinat.permutation import Permutation, Permutations, from_permutation_group_element 

from . import partition 

from .tableau import Tableau, StandardTableaux_size, StandardTableaux_shape, StandardTableaux 

from sage.interfaces.all import gap 

from sage.rings.all import QQ, PolynomialRing 

from sage.arith.all import factorial 

from sage.matrix.all import matrix 

from sage.modules.all import vector 

from sage.groups.perm_gps.permgroup_element import PermutationGroupElement 

import itertools 

from sage.combinat.permutation_cython import (left_action_same_n, right_action_same_n) 

import six 

 

# TODO: Remove this function and replace it with the class 

# TODO: Create parents for other bases (such as the seminormal basis) 

def SymmetricGroupAlgebra(R, W, category=None): 

""" 

Return the symmetric group algebra of order ``W`` over the ring ``R``. 

 

INPUT: 

 

- ``W`` -- a symmetric group; alternatively an integer `n` can be 

provided, as shorthand for ``Permutations(n)``. 

- ``R`` -- a base ring 

- ``category`` -- a category (default: the category of ``W``) 

 

This supports several implementations of the symmetric group. At 

this point this has been tested with ``W=Permutations(n)`` and 

``W=SymmetricGroup(n)``. 

 

.. WARNING:: 

 

Some features are failing in the latter case, in particular if 

the domain of the symmetric group is not `1,\ldots,n`. 

 

.. NOTE:: 

 

The brave can also try setting ``W=WeylGroup(['A',n-1])``, but 

little support for this currently exists. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3); QS3 

Symmetric group algebra of order 3 over Rational Field 

sage: QS3(1) 

[1, 2, 3] 

sage: QS3(2) 

2*[1, 2, 3] 

sage: basis = [QS3(p) for p in Permutations(3)] 

sage: a = sum(basis); a 

[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1] 

sage: a^2 

6*[1, 2, 3] + 6*[1, 3, 2] + 6*[2, 1, 3] + 6*[2, 3, 1] + 6*[3, 1, 2] + 6*[3, 2, 1] 

sage: a^2 == 6*a 

True 

sage: b = QS3([3, 1, 2]) 

sage: b 

[3, 1, 2] 

sage: b*a 

[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1] 

sage: b*a == a 

True 

 

We now construct the symmetric group algebra by providing 

explicitly the underlying group:: 

 

sage: SGA = SymmetricGroupAlgebra(QQ, Permutations(4)); SGA 

Symmetric group algebra of order 4 over Rational Field 

sage: SGA.group() 

Standard permutations of 4 

sage: SGA.an_element() 

[1, 2, 3, 4] + 2*[1, 2, 4, 3] + 3*[1, 3, 2, 4] + [4, 1, 2, 3] 

 

sage: SGA = SymmetricGroupAlgebra(QQ, SymmetricGroup(4)); SGA 

Symmetric group algebra of order 4 over Rational Field 

sage: SGA.group() 

Symmetric group of order 4! as a permutation group 

sage: SGA.an_element() 

() + 2*(1,2) + 4*(1,2,3,4) 

 

sage: SGA = SymmetricGroupAlgebra(QQ, WeylGroup(["A",3], prefix='s')); SGA 

Symmetric group algebra of order 4 over Rational Field 

sage: SGA.group() 

Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space) 

sage: SGA.an_element() 

2*s1*s2*s3*s2*s1 + 3*s1*s2*s3*s1 + s1*s2*s3 + 1 

 

The preferred way to construct the symmetric group algebra is to 

go through the usual ``algebra`` method:: 

 

sage: SGA = Permutations(3).algebra(QQ); SGA 

Symmetric group algebra of order 3 over Rational Field 

sage: SGA.group() 

Standard permutations of 3 

 

sage: SGA = SymmetricGroup(3).algebra(QQ); SGA 

Symmetric group algebra of order 3 over Rational Field 

sage: SGA.group() 

Symmetric group of order 3! as a permutation group 

 

The canonical embedding from the symmetric group algebra of order 

`n` to the symmetric group algebra of order `p > n` is available as 

a coercion:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: QS4 = SymmetricGroupAlgebra(QQ, 4) 

sage: QS4.coerce_map_from(QS3) 

Generic morphism: 

From: Symmetric group algebra of order 3 over Rational Field 

To: Symmetric group algebra of order 4 over Rational Field 

 

sage: x3 = QS3([3,1,2]) + 2 * QS3([2,3,1]); x3 

2*[2, 3, 1] + [3, 1, 2] 

sage: QS4(x3) 

2*[2, 3, 1, 4] + [3, 1, 2, 4] 

 

This allows for mixed expressions:: 

 

sage: x4 = 3*QS4([3, 1, 4, 2]) 

sage: x3 + x4 

2*[2, 3, 1, 4] + [3, 1, 2, 4] + 3*[3, 1, 4, 2] 

 

sage: QS0 = SymmetricGroupAlgebra(QQ, 0) 

sage: QS1 = SymmetricGroupAlgebra(QQ, 1) 

sage: x0 = QS0([]) 

sage: x1 = QS1([1]) 

sage: x0 * x1 

[1] 

sage: x3 - (2*x0 + x1) - x4 

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

 

Caveat: to achieve this, constructing ``SymmetricGroupAlgebra(QQ, 

10)`` currently triggers the construction of all symmetric group 

algebras of smaller order. Is this a feature we really want to have? 

 

.. WARNING:: 

 

The semantics of multiplication in symmetric group algebras 

with index set ``Permutations(n)`` is determined by the order 

in which permutations are multiplied, which currently defaults 

to "in such a way that multiplication is associative with 

permutations acting on integers from the right", but can be 

changed to the opposite order at runtime by setting the global 

variable ``Permutations.options['mult']`` (see 

:meth:`sage.combinat.permutation.Permutations.options` ). 

On the other hand, the semantics of multiplication in symmetric 

group algebras with index set ``SymmetricGroup(n)`` does not 

depend on this global variable. (This has the awkward 

consequence that the coercions between these two sorts of 

symmetric group algebras do not respect multiplication when 

this global variable is set to ``'r2l'``.) 

In view of this, it is recommended that code not rely on the 

usual multiplication function, but rather use the methods 

:meth:`left_action_product` and :meth:`right_action_product` 

for multiplying permutations (these methods don't depend on the 

setting). See :trac:`14885` for more information. 

 

We conclude by constructing the algebra of the symmetric group as 

a monoid algebra:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3, category=Monoids()) 

sage: QS3.category() 

Category of finite dimensional monoid algebras over Rational Field 

sage: TestSuite(QS3).run() 

 

 

TESTS:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: TestSuite(QS3).run() 

 

sage: QS3.group() 

Standard permutations of 3 

 

sage: QS3.one_basis() 

[1, 2, 3] 

 

sage: p1 = Permutation([1,2,3]) 

sage: p2 = Permutation([2,1,3]) 

sage: QS3.product_on_basis(p1,p2) 

[2, 1, 3] 

 

sage: W = WeylGroup(["A",3]) 

sage: SGA = SymmetricGroupAlgebra(QQ, W) 

sage: SGA.group() is W 

True 

sage: TestSuite(SGA).run() 

 

sage: SG = SymmetricGroupAlgebra(ZZ, 3) 

sage: SG.group().conjugacy_classes_representatives() 

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

 

sage: SGg = SymmetricGroup(3).algebra(ZZ) 

sage: SGg.group().conjugacy_classes_representatives() 

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

""" 

from sage.rings.semirings.non_negative_integer_semiring import NN 

if W in NN: 

W = Permutations(W) 

if category is None: 

category = W.category() 

return SymmetricGroupAlgebra_n(R, W, category.Algebras(R)) 

 

class SymmetricGroupAlgebra_n(GroupAlgebra_class): 

 

def __init__(self, R, W, category): 

""" 

TESTS:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: TestSuite(QS3).run() 

 

sage: QS3 in GroupAlgebras(QQ) 

True 

sage: QS3 in FiniteDimensionalAlgebrasWithBasis(QQ) 

True 

 

Check that :trac:`16926` works:: 

 

sage: S = SymmetricGroup(4) 

sage: SGA = S.algebra(QQ) 

sage: TestSuite(SGA).run() 

 

Checking that coercion works between equivalent indexing sets:: 

 

sage: G = SymmetricGroup(4).algebra(QQ) 

sage: S = SymmetricGroupAlgebra(QQ,4) 

sage: S(G.an_element()) 

[1, 2, 3, 4] + 2*[2, 1, 3, 4] + 4*[2, 3, 4, 1] 

sage: G(S.an_element()) 

() + 2*(3,4) + 3*(2,3) + (1,4,3,2) 

 

Checking the recovery of `n`: 

 

sage: SymmetricGroup(4).algebra(QQ).n 

4 

sage: SymmetricGroup(1).algebra(QQ).n 

1 

sage: SymmetricGroup(0).algebra(QQ).n 

0 

sage: Permutations(4).algebra(QQ).n 

4 

sage: Permutations(1).algebra(QQ).n 

1 

sage: Permutations(0).algebra(QQ).n 

0 

sage: SymmetricGroupAlgebra(QQ, WeylGroup(["A",3])).n 

4 

sage: SymmetricGroupAlgebra(QQ, WeylGroup(["A",1])).n 

2 

sage: SymmetricGroupAlgebra(QQ, WeylGroup(["A",0])).n # todo: not implemented 

1 

""" 

if not W in WeylGroups or W.cartan_type().type() != 'A': 

raise ValueError("W (=%s) should be a symmetric group or a nonnegative integer") 

rank = W.cartan_type().rank() 

if rank == 0: # Ambiguous: n=0 or n=1? 

# The following trick works for both SymmetricGroup(n) and 

# Permutations(n) and it's currently not possible to 

# construct the WeylGroup for n=0 

self.n = W.degree() 

else: 

self.n = W.cartan_type().rank() + 1 

GroupAlgebra_class.__init__(self, R, W, prefix='', 

latex_prefix='', category=category) 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: SymmetricGroupAlgebra(QQ, 3) 

Symmetric group algebra of order 3 over Rational Field 

""" 

return "Symmetric group algebra of order {} over {}".format(self.n, self.base_ring()) 

 

def _coerce_map_from_(self, S): 

""" 

Return ``True`` or a morphism if there exists a coercion from ``S`` 

into ``self`` or ``False`` otherwise. 

 

EXAMPLES: 

 

Symmetric group algebras:: 

 

sage: SGA4 = SymmetricGroupAlgebra(QQ, 4) 

sage: SGA2 = SymmetricGroupAlgebra(QQ, 2) 

sage: SGA4.has_coerce_map_from(SGA2) 

True 

sage: SGA2Z = SymmetricGroupAlgebra(ZZ, 2) 

sage: SGA4.has_coerce_map_from(SGA2Z) 

True 

sage: p = Permutation([2,1]) 

sage: SGA4(-3*SGA2Z.monomial(p)) 

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

 

Descent algebras:: 

 

sage: DA = DescentAlgebra(QQ, 4) 

sage: SGA4 = SymmetricGroupAlgebra(QQ, 4) 

sage: SGA4.has_coerce_map_from(DA.D()) 

True 

sage: SGA4.has_coerce_map_from(DA.B()) 

True 

sage: SGA4.has_coerce_map_from(DA.I()) 

True 

sage: x = DA.B()[4] 

sage: SGA4(x) 

[1, 2, 3, 4] 

 

sage: DAB = DescentAlgebra(ZZ,2).B() 

sage: SGA4.has_coerce_map_from(DAB) 

True 

sage: SGA4(DAB[2]) 

[1, 2, 3, 4] 

 

sage: QSG4 = SymmetricGroup(4).algebra(ZZ) 

sage: DAB = DescentAlgebra(ZZ,4).B() 

sage: QSG4(DAB[1,2,1]) 

() + (3,4) + (2,3,4) + (1,2) + (1,2)(3,4) + (1,2,3,4) 

+ (1,3,2) + (1,3,4,2) + (1,3,4) + (1,4,3,2) + (1,4,2) + (1,4) 

""" 

# Symmetric group algebras of smaller rank 

if (isinstance(S, SymmetricGroupAlgebra_n) and S.n <= self.n 

and self.base_ring().has_coerce_map_from(S.base_ring())): 

return S.canonical_embedding(self) 

 

# Descent algebras 

from sage.combinat.descent_algebra import DescentAlgebra 

# TODO: A better way to handle all of the bases 

if isinstance(S, (DescentAlgebra.D, DescentAlgebra.B, DescentAlgebra.I)): 

# Same rank and base ring, just the natural morphism 

if (S.realization_of()._n == self.n and self.base_ring() == S.base_ring() 

and self._indices == Permutations(self.n)): 

return S.to_symmetric_group_algebra 

# Otherwise compose with the canonical embedding in order to ensure 

# that the right base ring and the right index set are being used. 

# Slightly hacky! 

if (S.realization_of()._n <= self.n and 

self.base_ring().has_coerce_map_from(S.base_ring())): 

phi = S.to_symmetric_group_algebra 

return phi.codomain().canonical_embedding(self) * phi 

 

return super(SymmetricGroupAlgebra_n, self)._coerce_map_from_(S) 

 

def _element_constructor_(self, x): 

""" 

Construct an element of ``self``. 

 

EXAMPLES:: 

 

sage: S = SymmetricGroupAlgebra(QQ, 4) 

sage: G = SymmetricGroup(3) 

sage: p = Permutation((1,2)) 

sage: S(p) 

[2, 1, 3, 4] 

sage: S(G(p)) 

[2, 1, 3, 4] 

sage: S(p) == S(G(p)) 

True 

""" 

if isinstance(x, Permutation): 

return self.monomial_from_smaller_permutation(x) 

if isinstance(x, PermutationGroupElement): 

return self.monomial_from_smaller_permutation( 

from_permutation_group_element(x)) 

 

return super(SymmetricGroupAlgebra_n, self)._element_constructor_(x) 

 

def _sibling(self, n): 

r""" 

Return the sibling group algebra of order `n`. 

 

EXAMPLES:: 

 

sage: SGA = SymmetricGroupAlgebra(QQ, Permutations(3))._sibling(4); SGA 

Symmetric group algebra of order 4 over Rational Field 

sage: SGA.group() 

Standard permutations of 4 

 

sage: SGA = SymmetricGroupAlgebra(QQ, SymmetricGroup(3))._sibling(4); SGA 

Symmetric group algebra of order 4 over Rational Field 

sage: SGA.group() 

Symmetric group of order 4! as a permutation group 

 

sage: SGA = SymmetricGroupAlgebra(QQ, WeylGroup(["A",2]))._sibling(4); SGA 

Traceback (most recent call last): 

... 

NotImplementedError: Constructing the sibling algebra of a different order 

only implemented for PermutationGroup and SymmetricGroup 

""" 

try: 

W = self.basis().keys().__class__(n) 

except Exception: 

raise NotImplementedError("Constructing the sibling algebra of a different order " 

"only implemented for PermutationGroup and SymmetricGroup") 

return SymmetricGroupAlgebra(self.base_ring(), W) 

 

 

# _repr_ customization: output the basis element indexed by [1,2,3] as [1,2,3] 

_repr_option_bracket = False 

 

def left_action_product(self, left, right): 

""" 

Return the product of two elements ``left`` and ``right`` of 

``self``, where multiplication is defined in such a way that 

for two permutations `p` and `q`, the product `pq` is the 

permutation obtained by first applying `q` and then applying 

`p`. This definition of multiplication is tailored to make 

multiplication of permutations associative with their action on 

numbers if permutations are to act on numbers from the left. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: p1 = Permutation([2, 1, 3]) 

sage: p2 = Permutation([3, 1, 2]) 

sage: QS3.left_action_product(QS3(p1), QS3(p2)) 

[3, 2, 1] 

sage: x = QS3([1, 2, 3]) - 2*QS3([1, 3, 2]) 

sage: y = 1/2 * QS3([3, 1, 2]) + 3*QS3([1, 2, 3]) 

sage: QS3.left_action_product(x, y) 

3*[1, 2, 3] - 6*[1, 3, 2] - [2, 1, 3] + 1/2*[3, 1, 2] 

sage: QS3.left_action_product(0, x) 

0 

 

The method coerces its input into the algebra ``self``:: 

 

sage: QS4 = SymmetricGroupAlgebra(QQ, 4) 

sage: QS4.left_action_product(QS3([1, 2, 3]), QS3([2, 1, 3])) 

[2, 1, 3, 4] 

sage: QS4.left_action_product(1, Permutation([4, 1, 2, 3])) 

[4, 1, 2, 3] 

 

TESTS:: 

 

sage: QS4 = SymmetricGroup(4).algebra(QQ) 

sage: QS4.left_action_product(QS4((1,2)), QS4((2,3))) 

(1,2,3) 

sage: QS4.left_action_product(1, QS4((1,2))) 

(1,2) 

 

.. WARNING:: 

 

Note that coercion presently works from permutations of ``n`` 

into the ``n``-th symmetric group algebra, and also from all 

smaller symmetric group algebras into the ``n``-th symmetric 

group algebra, but not from permutations of integers smaller 

than ``n`` into the ``n``-th symmetric group algebra. 

""" 

a = self(left) 

b = self(right) 

if not isinstance(self._indices, Permutations): 

return b * a 

P = Permutations(self.n) 

return self.sum_of_terms([(P(left_action_same_n(p._list, q._list)), x * y) 

for (p, x) in a for (q, y) in b]) 

# Why did we use left_action_same_n instead of 

# left_action_product? 

# Because having cast a and b into self, we already know that 

# p and q are permutations of the same number of elements, 

# and thus we don't need to waste our time on the input 

# sanitizing of left_action_product. 

 

def right_action_product(self, left, right): 

""" 

Return the product of two elements ``left`` and ``right`` of 

``self``, where multiplication is defined in such a way that 

for two permutations `p` and `q`, the product `pq` is the 

permutation obtained by first applying `p` and then applying 

`q`. This definition of multiplication is tailored to make 

multiplication of permutations associative with their action on 

numbers if permutations are to act on numbers from the right. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: p1 = Permutation([2, 1, 3]) 

sage: p2 = Permutation([3, 1, 2]) 

sage: QS3.right_action_product(QS3(p1), QS3(p2)) 

[1, 3, 2] 

sage: x = QS3([1, 2, 3]) - 2*QS3([1, 3, 2]) 

sage: y = 1/2 * QS3([3, 1, 2]) + 3*QS3([1, 2, 3]) 

sage: QS3.right_action_product(x, y) 

3*[1, 2, 3] - 6*[1, 3, 2] + 1/2*[3, 1, 2] - [3, 2, 1] 

sage: QS3.right_action_product(0, x) 

0 

 

The method coerces its input into the algebra ``self``:: 

 

sage: QS4 = SymmetricGroupAlgebra(QQ, 4) 

sage: QS4.right_action_product(QS3([1, 2, 3]), QS3([2, 1, 3])) 

[2, 1, 3, 4] 

sage: QS4.right_action_product(1, Permutation([4, 1, 2, 3])) 

[4, 1, 2, 3] 

 

TESTS:: 

 

sage: QS4 = SymmetricGroup(4).algebra(QQ) 

sage: QS4.right_action_product(QS4((1,2)), QS4((2,3))) 

(1,3,2) 

sage: QS4.right_action_product(1, QS4((1,2))) 

(1,2) 

 

.. WARNING:: 

 

Note that coercion presently works from permutations of ``n`` 

into the ``n``-th symmetric group algebra, and also from all 

smaller symmetric group algebras into the ``n``-th symmetric 

group algebra, but not from permutations of integers smaller 

than ``n`` into the ``n``-th symmetric group algebra. 

""" 

a = self(left) 

b = self(right) 

if not isinstance(self._indices, Permutations): 

return a * b 

P = Permutations(self.n) 

return self.sum_of_terms([(P(right_action_same_n(p._list, q._list)), x * y) 

for (p, x) in a for (q, y) in b]) 

# Why did we use right_action_same_n instead of 

# right_action_product? 

# Because having cast a and b into self, we already know that 

# p and q are permutations of the same number of elements, 

# and thus we don't need to waste our time on the input 

# sanitizing of right_action_product. 

 

def canonical_embedding(self, other): 

""" 

Return the canonical coercion of ``self`` into a symmetric 

group algebra ``other``. 

 

INPUT: 

 

- ``other`` -- a symmetric group algebra with order `p` 

satisfying `p \geq n`, where `n` is the order of ``self``, 

over a ground ring into which the ground ring of ``self`` 

coerces. 

 

EXAMPLES:: 

 

sage: QS2 = SymmetricGroupAlgebra(QQ, 2) 

sage: QS4 = SymmetricGroupAlgebra(QQ, 4) 

sage: phi = QS2.canonical_embedding(QS4); phi 

Generic morphism: 

From: Symmetric group algebra of order 2 over Rational Field 

To: Symmetric group algebra of order 4 over Rational Field 

 

sage: x = QS2([2,1]) + 2 * QS2([1,2]) 

sage: phi(x) 

2*[1, 2, 3, 4] + [2, 1, 3, 4] 

 

sage: loads(dumps(phi)) 

Generic morphism: 

From: Symmetric group algebra of order 2 over Rational Field 

To: Symmetric group algebra of order 4 over Rational Field 

 

sage: ZS2 = SymmetricGroupAlgebra(ZZ, 2) 

sage: phi = ZS2.canonical_embedding(QS4); phi 

Generic morphism: 

From: Symmetric group algebra of order 2 over Integer Ring 

To: Symmetric group algebra of order 4 over Rational Field 

 

sage: phi = ZS2.canonical_embedding(QS2); phi 

Generic morphism: 

From: Symmetric group algebra of order 2 over Integer Ring 

To: Symmetric group algebra of order 2 over Rational Field 

 

sage: QS4.canonical_embedding(QS2) 

Traceback (most recent call last): 

... 

ValueError: There is no canonical embedding from Symmetric group 

algebra of order 2 over Rational Field to Symmetric group 

algebra of order 4 over Rational Field 

 

sage: QS4g = SymmetricGroup(4).algebra(QQ) 

sage: QS4.canonical_embedding(QS4g)(QS4([1,3,2,4])) 

(2,3) 

sage: QS4g.canonical_embedding(QS4)(QS4g((2,3))) 

[1, 3, 2, 4] 

sage: ZS2.canonical_embedding(QS4g)(ZS2([2,1])) 

(1,2) 

sage: ZS2g = SymmetricGroup(2).algebra(ZZ) 

sage: ZS2g.canonical_embedding(QS4)(ZS2g((1,2))) 

[2, 1, 3, 4] 

""" 

if not isinstance(other, SymmetricGroupAlgebra_n) or self.n > other.n: 

raise ValueError("There is no canonical embedding from {0} to {1}".format(other, self)) 

return self.module_morphism(other.monomial_from_smaller_permutation, codomain = other) # category = self.category() (currently broken) 

 

def monomial_from_smaller_permutation(self, permutation): 

""" 

Convert ``permutation`` into a permutation, possibly extending it 

to the appropriate size, and return the corresponding basis 

element of ``self``. 

 

EXAMPLES:: 

 

sage: QS5 = SymmetricGroupAlgebra(QQ, 5) 

sage: QS5.monomial_from_smaller_permutation([]) 

[1, 2, 3, 4, 5] 

sage: QS5.monomial_from_smaller_permutation(Permutation([3,1,2])) 

[3, 1, 2, 4, 5] 

sage: QS5.monomial_from_smaller_permutation([5,3,4,1,2]) 

[5, 3, 4, 1, 2] 

sage: QS5.monomial_from_smaller_permutation(SymmetricGroup(2)((1,2))) 

[2, 1, 3, 4, 5] 

 

sage: QS5g = SymmetricGroup(5).algebra(QQ) 

sage: QS5g.monomial_from_smaller_permutation([2,1]) 

(1,2) 

 

TESTS:: 

 

sage: QS5.monomial_from_smaller_permutation([5,3,4,1,2]).parent() 

Symmetric group algebra of order 5 over Rational Field 

""" 

P = self.basis().keys() 

return self.monomial( P(permutation) ) 

 

def antipode(self, x): 

r""" 

Return the image of the element ``x`` of ``self`` under the 

antipode of the Hopf algebra ``self`` (where the 

comultiplication is the usual one on a group algebra). 

 

Explicitly, this is obtained by replacing each permutation 

`\sigma` by `\sigma^{-1}` in ``x`` while keeping all 

coefficients as they are. 

 

EXAMPLES:: 

 

sage: QS4 = SymmetricGroupAlgebra(QQ, 4) 

sage: QS4.antipode(2 * QS4([1, 3, 4, 2]) - 1/2 * QS4([1, 4, 2, 3])) 

-1/2*[1, 3, 4, 2] + 2*[1, 4, 2, 3] 

sage: all( QS4.antipode(QS4(p)) == QS4(p.inverse()) 

....: for p in Permutations(4) ) 

True 

 

sage: ZS3 = SymmetricGroupAlgebra(ZZ, 3) 

sage: ZS3.antipode(ZS3.zero()) 

0 

sage: ZS3.antipode(-ZS3(Permutation([2, 3, 1]))) 

-[3, 1, 2] 

""" 

return self.sum_of_terms([(p.inverse(), coeff) for 

(p, coeff) in self(x)], 

distinct=True) 

 

def retract_plain(self, f, m): 

r""" 

Return the plain retract of the element `f \in R S_n` 

to `R S_m`, where `m \leq n` (and where `R S_n` is ``self``). 

 

If `m` is a nonnegative integer less or equal to `n`, then the 

plain retract from `S_n` to `S_m` is defined as an `R`-linear 

map `S_n \to S_m` which sends every permutation `p \in S_n` 

to 

 

.. MATH:: 

 

\begin{cases} \mbox{pret}(p) &\mbox{if } \mbox{pret}(p)\mbox{ is defined;} \\ 

0 & \mbox{otherwise} \end{cases}. 

 

Here `\mbox{pret}(p)` denotes the plain retract of the 

permutation `p` to `S_m`, which is defined in 

:meth:`~sage.combinat.permutation.Permutation.retract_plain`. 

 

EXAMPLES:: 

 

sage: SGA3 = SymmetricGroupAlgebra(QQ, 3) 

sage: SGA3.retract_plain(2*SGA3([1,2,3]) - 4*SGA3([2,1,3]) + 7*SGA3([1,3,2]), 2) 

2*[1, 2] - 4*[2, 1] 

sage: SGA3.retract_plain(2*SGA3([1,3,2]) - 5*SGA3([2,3,1]), 2) 

0 

 

sage: SGA5 = SymmetricGroupAlgebra(QQ, 5) 

sage: SGA5.retract_plain(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 4) 

11*[3, 2, 1, 4] 

sage: SGA5.retract_plain(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 3) 

11*[3, 2, 1] 

sage: SGA5.retract_plain(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 2) 

0 

sage: SGA5.retract_plain(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 1) 

0 

 

sage: SGA5.retract_plain(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 3) 

8*[1, 2, 3] - 6*[1, 3, 2] 

sage: SGA5.retract_plain(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 1) 

8*[1] 

sage: SGA5.retract_plain(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 0) 

8*[] 

 

TESTS: 

 

Check this works with other indexing sets:: 

 

sage: G = SymmetricGroup(4).algebra(QQ) 

sage: G.retract_plain(G.an_element(), 3) 

() + 2*(1,2) 

 

.. SEEALSO:: 

 

:meth:`retract_direct_product`, :meth:`retract_okounkov_vershik` 

""" 

RSm = self._sibling(m) 

I = RSm.group() 

pairs = [] 

P = Permutations(self.n) 

for (p, coeff) in six.iteritems(f.monomial_coefficients()): 

p_ret = P(p).retract_plain(m) 

if p_ret is not None: 

pairs.append((I(p_ret), coeff)) 

return RSm.sum_of_terms(pairs, distinct=True) 

 

def retract_direct_product(self, f, m): 

r""" 

Return the direct-product retract of the element `f \in R S_n` 

to `R S_m`, where `m \leq n` (and where `R S_n` is ``self``). 

 

If `m` is a nonnegative integer less or equal to `n`, then the 

direct-product retract from `S_n` to `S_m` is defined as an 

`R`-linear map `S_n \to S_m` which sends every permutation 

`p \in S_n` to 

 

.. MATH:: 

 

\begin{cases} \mbox{dret}(p) &\mbox{if } \mbox{dret}(p)\mbox{ is defined;} \\ 

0 & \mbox{otherwise} \end{cases}. 

 

Here `\mbox{dret}(p)` denotes the direct-product retract of the 

permutation `p` to `S_m`, which is defined in 

:meth:`~sage.combinat.permutation.Permutation.retract_direct_product`. 

 

EXAMPLES:: 

 

sage: SGA3 = SymmetricGroupAlgebra(QQ, 3) 

sage: SGA3.retract_direct_product(2*SGA3([1,2,3]) - 4*SGA3([2,1,3]) + 7*SGA3([1,3,2]), 2) 

2*[1, 2] - 4*[2, 1] 

sage: SGA3.retract_direct_product(2*SGA3([1,3,2]) - 5*SGA3([2,3,1]), 2) 

0 

 

sage: SGA5 = SymmetricGroupAlgebra(QQ, 5) 

sage: SGA5.retract_direct_product(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 4) 

11*[3, 2, 1, 4] 

sage: SGA5.retract_direct_product(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 3) 

-6*[1, 3, 2] + 11*[3, 2, 1] 

sage: SGA5.retract_direct_product(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 2) 

0 

sage: SGA5.retract_direct_product(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 1) 

2*[1] 

 

sage: SGA5.retract_direct_product(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 3) 

8*[1, 2, 3] - 6*[1, 3, 2] 

sage: SGA5.retract_direct_product(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 1) 

2*[1] 

sage: SGA5.retract_direct_product(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 0) 

2*[] 

 

TESTS: 

 

Check this works with other indexing sets:: 

 

sage: G = SymmetricGroup(4).algebra(QQ) 

sage: G.retract_direct_product(G.an_element(), 3) 

() + 2*(1,2) 

 

.. SEEALSO:: 

 

:meth:`retract_plain`, :meth:`retract_okounkov_vershik` 

""" 

RSm = self._sibling(m) 

I = RSm.group() 

dct = {} 

P = Permutations(self.n) 

for (p, coeff) in six.iteritems(f.monomial_coefficients()): 

p_ret = P(p).retract_direct_product(m) 

if p_ret is not None: 

p_ret = I(p_ret) 

if not p_ret in dct: 

dct[p_ret] = coeff 

else: 

dct[p_ret] += coeff 

return RSm._from_dict(dct) 

 

def retract_okounkov_vershik(self, f, m): 

r""" 

Return the Okounkov-Vershik retract of the element `f \in R S_n` 

to `R S_m`, where `m \leq n` (and where `R S_n` is ``self``). 

 

If `m` is a nonnegative integer less or equal to `n`, then the 

Okounkov-Vershik retract from `S_n` to `S_m` is defined as an 

`R`-linear map `S_n \to S_m` which sends every permutation 

`p \in S_n` to the Okounkov-Vershik retract of the permutation 

`p` to `S_m`, which is defined in 

:meth:`~sage.combinat.permutation.Permutation.retract_okounkov_vershik`. 

 

EXAMPLES:: 

 

sage: SGA3 = SymmetricGroupAlgebra(QQ, 3) 

sage: SGA3.retract_okounkov_vershik(2*SGA3([1,2,3]) - 4*SGA3([2,1,3]) + 7*SGA3([1,3,2]), 2) 

9*[1, 2] - 4*[2, 1] 

sage: SGA3.retract_okounkov_vershik(2*SGA3([1,3,2]) - 5*SGA3([2,3,1]), 2) 

2*[1, 2] - 5*[2, 1] 

 

sage: SGA5 = SymmetricGroupAlgebra(QQ, 5) 

sage: SGA5.retract_okounkov_vershik(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 4) 

-6*[1, 3, 2, 4] + 8*[1, 4, 2, 3] + 11*[3, 2, 1, 4] 

sage: SGA5.retract_okounkov_vershik(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 3) 

2*[1, 3, 2] + 11*[3, 2, 1] 

sage: SGA5.retract_okounkov_vershik(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 2) 

13*[1, 2] 

sage: SGA5.retract_okounkov_vershik(8*SGA5([1,4,2,5,3]) - 6*SGA5([1,3,2,5,4]) + 11*SGA5([3,2,1,4,5]), 1) 

13*[1] 

 

sage: SGA5.retract_okounkov_vershik(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 3) 

8*[1, 2, 3] - 6*[1, 3, 2] 

sage: SGA5.retract_okounkov_vershik(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 1) 

2*[1] 

sage: SGA5.retract_okounkov_vershik(8*SGA5([1,2,3,4,5]) - 6*SGA5([1,3,2,4,5]), 0) 

2*[] 

 

TESTS: 

 

Check this works with other indexing sets:: 

 

sage: G = SymmetricGroup(4).algebra(QQ) 

sage: G.retract_okounkov_vershik(G.an_element(), 3) 

() + 2*(1,2) + 4*(1,2,3) 

 

.. SEEALSO:: 

 

:meth:`retract_plain`, :meth:`retract_direct_product` 

""" 

RSm = self._sibling(m) 

I = RSm.group() 

dct = {} 

P = Permutations(self.n) 

for (p, coeff) in six.iteritems(f.monomial_coefficients()): 

p_ret = I(P(p).retract_okounkov_vershik(m)) 

if not p_ret in dct: 

dct[p_ret] = coeff 

else: 

dct[p_ret] += coeff 

return RSm._from_dict(dct) 

 

def cpis(self): 

""" 

Return a list of the centrally primitive idempotents of 

``self``. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ,3) 

sage: a = QS3.cpis() 

sage: a[0] # [3] 

1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1] 

sage: a[1] # [2, 1] 

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

 

TESTS: 

 

Check this works with other indexing sets:: 

 

sage: G = SymmetricGroup(3).algebra(QQ) 

sage: a = G.cpis() 

sage: a[0] 

1/6*() + 1/6*(2,3) + 1/6*(1,2) + 1/6*(1,2,3) + 1/6*(1,3,2) + 1/6*(1,3) 

sage: a[1] 

2/3*() - 1/3*(1,2,3) - 1/3*(1,3,2) 

""" 

return [self.cpi(p) for p in partition.Partitions_n(self.n)] 

 

def cpi(self, p): 

""" 

Return the centrally primitive idempotent for the symmetric group 

of order `n` corresponding to the irreducible representation 

indexed by the partition ``p``. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ,3) 

sage: QS3.cpi([2,1]) 

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

sage: QS3.cpi([3]) 

1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1] 

sage: QS3.cpi([1,1,1]) 

1/6*[1, 2, 3] - 1/6*[1, 3, 2] - 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] - 1/6*[3, 2, 1] 

 

sage: QS0 = SymmetricGroupAlgebra(QQ, 0) 

sage: QS0.cpi(Partition([])) 

[] 

 

TESTS:: 

 

sage: QS3.cpi([2,2]) 

Traceback (most recent call last): 

... 

TypeError: p (= [2, 2]) must be a partition of n (= 3) 

""" 

if p not in partition.Partitions_n(self.n): 

raise TypeError("p (= {p}) must be a partition of n (= {n})".format(p=p, n=self.n)) 

 

character_table = eval(gap.eval("Display(Irr(SymmetricGroup(%d)));"%self.n)) 

 

np = partition.Partitions_n(self.n).list() 

np.reverse() 

p_index = np.index(p) 

 

big_coeff = character_table[p_index][0] / factorial(self.n) 

 

character_row = character_table[p_index] 

P = Permutations(self.n) 

dct = { self._indices(g): big_coeff * character_row[np.index(g.cycle_type())] 

for g in P } 

 

return self._from_dict(dct) 

 

@cached_method 

def algebra_generators(self): 

r""" 

Return generators of this group algebra (as algebra) as a 

list of permutations. 

 

The generators used for the group algebra of `S_n` are the 

transposition `(2, 1)` and the `n`-cycle `(1, 2, \ldots, n)`, 

unless `n \leq 1` (in which case no generators are needed). 

 

EXAMPLES:: 

 

sage: SymmetricGroupAlgebra(ZZ,5).algebra_generators() 

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

 

sage: SymmetricGroupAlgebra(QQ,0).algebra_generators() 

Family () 

 

sage: SymmetricGroupAlgebra(QQ,1).algebra_generators() 

Family () 

 

TESTS: 

 

Check that :trac:`15309` is fixed:: 

 

sage: S3 = SymmetricGroupAlgebra(QQ, 3) 

sage: S3.algebra_generators() 

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

sage: C = CombinatorialFreeModule(ZZ, ZZ) 

sage: M = C.module_morphism(lambda x: S3.zero(), codomain=S3) 

sage: M.register_as_coercion() 

""" 

from sage.sets.family import Family 

if self.n <= 1: 

return Family([]) 

a = list(range(1, self.n + 1)) 

a[0] = 2 

a[1] = 1 

b = list(range(2, self.n + 2)) 

b[self.n-1] = 1 

return Family([self.monomial(self._indices(a)), self.monomial(self._indices(b))]) 

 

def _conjugacy_classes_representatives_underlying_group(self): 

r""" 

Return a complete list of representatives of conjugacy 

classes of the underlying symmetric group. 

 

.. WARNING:: 

 

This currently is only implemented when ``self`` is built using 

the index set ``Permutations(n)``. 

 

EXAMPLES:: 

 

sage: SG=SymmetricGroupAlgebra(ZZ,3) 

sage: SG._conjugacy_classes_representatives_underlying_group() 

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

 

sage: SGg = SymmetricGroup(3).algebra(ZZ) 

sage: SGg._conjugacy_classes_representatives_underlying_group() # not tested 

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

""" 

P = self.basis().keys() 

return [P.element_in_conjugacy_classes(nu) for nu in partition.Partitions(self.n)] 

 

def rsw_shuffling_element(self, k): 

r""" 

Return the `k`-th Reiner-Saliola-Welker shuffling element in 

the group algebra ``self``. 

 

The `k`-th Reiner-Saliola-Welker shuffling element in the 

symmetric group algebra `R S_n` over a ring `R` is defined as the 

sum `\sum_{\sigma \in S_n} \mathrm{noninv}_k(\sigma) \cdot \sigma`, 

where for every permutation `\sigma`, the number 

`\mathrm{noninv}_k(\sigma)` is the number of all 

`k`-noninversions of `\sigma` (that is, the number of all 

`k`-element subsets of `\{ 1, 2, \ldots, n \}` on which 

`\sigma` restricts to a strictly increasing map). See 

:meth:`sage.combinat.permutation.number_of_noninversions` for 

the `\mathrm{noninv}` map. 

 

This element is more or less the operator `\nu_{k, 1^{n-k}}` 

introduced in [RSW2011]_; more precisely, `\nu_{k, 1^{n-k}}` 

is the left multiplication by this element. 

 

It is a nontrivial theorem (Theorem 1.1 in [RSW2011]_) that 

the operators `\nu_{k, 1^{n-k}}` (for fixed `n` and varying 

`k`) pairwise commute. It is a conjecture (Conjecture 1.2 in 

[RSW2011]_) that all their eigenvalues are integers (which, in 

light of their commutativity and easily established symmetry, 

yields that they can be simultaneously diagonalized over `\QQ` 

with only integer eigenvalues). 

 

EXAMPLES: 

 

The Reiner-Saliola-Welker shuffling elements on `\QQ S_3`:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: QS3.rsw_shuffling_element(0) 

[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1] 

sage: QS3.rsw_shuffling_element(1) 

3*[1, 2, 3] + 3*[1, 3, 2] + 3*[2, 1, 3] + 3*[2, 3, 1] + 3*[3, 1, 2] + 3*[3, 2, 1] 

sage: QS3.rsw_shuffling_element(2) 

3*[1, 2, 3] + 2*[1, 3, 2] + 2*[2, 1, 3] + [2, 3, 1] + [3, 1, 2] 

sage: QS3.rsw_shuffling_element(3) 

[1, 2, 3] 

sage: QS3.rsw_shuffling_element(4) 

0 

 

Checking the commutativity of Reiner-Saliola-Welker shuffling 

elements (we leave out the ones for which it is trivial):: 

 

sage: def test_rsw_comm(n): 

....: QSn = SymmetricGroupAlgebra(QQ, n) 

....: rsws = [QSn.rsw_shuffling_element(k) for k in range(2, n)] 

....: return all( all( rsws[i] * rsws[j] == rsws[j] * rsws[i] 

....: for j in range(i) ) 

....: for i in range(len(rsws)) ) 

sage: test_rsw_comm(3) 

True 

sage: test_rsw_comm(4) 

True 

sage: test_rsw_comm(5) # long time 

True 

 

.. NOTE:: 

 

For large ``k`` (relative to ``n``), it might be faster to call 

``QSn.left_action_product(QSn.semi_rsw_element(k), QSn.antipode(binary_unshuffle_sum(k)))`` 

than ``QSn.rsw_shuffling_element(n)``. 

 

.. SEEALSO:: 

 

:meth:`semi_rsw_element`, :meth:`binary_unshuffle_sum` 

""" 

P = self.basis().keys() 

I = Permutations(self.n) 

return self.sum_of_terms([(p, I(p).number_of_noninversions(k)) for p in P], 

distinct=True) 

 

def semi_rsw_element(self, k): 

r""" 

Return the `k`-th semi-RSW element in the group algebra ``self``. 

 

The `k`-th semi-RSW element in the symmetric group algebra 

`R S_n` over a ring `R` is defined as the sum of all permutations 

`\sigma \in S_n` satisfying 

`\sigma(1) < \sigma(2) < \cdots < \sigma(k)`. 

 

This element has the property that, if it is denoted by `s_k`, 

then `s_k S(s_k)` is `(n-k)!` times the `k`-th 

Reiner-Saliola-Welker shuffling element of `R S_n` (see 

:meth:`rsw_shuffling_element`). Here, `S` denotes the antipode 

of the group algebra `R S_n`. 

 

The `k`-th semi-RSW element is the image of the complete 

non-commutative symmetric function `S^{(k, 1^{n-k})}` in the 

ring of non-commutative symmetric functions under the canonical 

projection on the symmetric group algebra (through the descent 

algebra). 

 

EXAMPLES: 

 

The semi-RSW elements on `\QQ S_3`:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: QS3.semi_rsw_element(0) 

[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1] 

sage: QS3.semi_rsw_element(1) 

[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1] 

sage: QS3.semi_rsw_element(2) 

[1, 2, 3] + [1, 3, 2] + [2, 3, 1] 

sage: QS3.semi_rsw_element(3) 

[1, 2, 3] 

sage: QS3.semi_rsw_element(4) 

0 

 

Let us check the relation with the `k`-th Reiner-Saliola-Welker 

shuffling element stated in the docstring:: 

 

sage: def test_rsw(n): 

....: ZSn = SymmetricGroupAlgebra(ZZ, n) 

....: for k in range(1, n): 

....: a = ZSn.semi_rsw_element(k) 

....: b = ZSn.left_action_product(a, ZSn.antipode(a)) 

....: if factorial(n-k) * ZSn.rsw_shuffling_element(k) != b: 

....: return False 

....: return True 

sage: test_rsw(3) 

True 

sage: test_rsw(4) 

True 

sage: test_rsw(5) # long time 

True 

 

Let us also check the statement about the complete 

non-commutative symmetric function:: 

 

sage: def test_rsw_ncsf(n): 

....: ZSn = SymmetricGroupAlgebra(ZZ, n) 

....: NSym = NonCommutativeSymmetricFunctions(ZZ) 

....: S = NSym.S() 

....: for k in range(1, n): 

....: a = S(Composition([k] + [1]*(n-k))).to_symmetric_group_algebra() 

....: if a != ZSn.semi_rsw_element(k): 

....: return False 

....: return True 

sage: test_rsw_ncsf(3) 

True 

sage: test_rsw_ncsf(4) 

True 

sage: test_rsw_ncsf(5) # long time 

True 

""" 

n = self.n 

if n < k: 

return self.zero() 

def complement(xs): 

res = list(range(1, n + 1)) 

for x in xs: 

res.remove(x) 

return res 

P = Permutations(n) 

I = self._indices 

return self.sum_of_monomials([I(P(complement(q) + list(q))) 

for q in itertools.permutations(range(1, n+1), n-k)]) 

 

def binary_unshuffle_sum(self, k): 

r""" 

Return the `k`-th binary unshuffle sum in the group algebra 

``self``. 

 

The `k`-th binary unshuffle sum in the symmetric group algebra 

`R S_n` over a ring `R` is defined as the sum of all permutations 

`\sigma \in S_n` satisfying 

`\sigma(1) < \sigma(2) < \cdots < \sigma(k)` and 

`\sigma(k+1) < \sigma(k+2) < \cdots < \sigma(n)`. 

 

This element has the property that, if it is denoted by `t_k`, 

and if the `k`-th semi-RSW element (see :meth:`semi_rsw_element`) 

is denoted by `s_k`, then `s_k S(t_k)` and `t_k S(s_k)` both 

equal the `k`-th Reiner-Saliola-Welker shuffling element of 

`R S_n` (see :meth:`rsw_shuffling_element`). 

 

The `k`-th binary unshuffle sum is the image of the complete 

non-commutative symmetric function `S^{(k, n-k)}` in the 

ring of non-commutative symmetric functions under the canonical 

projection on the symmetric group algebra (through the descent 

algebra). 

 

EXAMPLES: 

 

The binary unshuffle sums on `\QQ S_3`:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: QS3.binary_unshuffle_sum(0) 

[1, 2, 3] 

sage: QS3.binary_unshuffle_sum(1) 

[1, 2, 3] + [2, 1, 3] + [3, 1, 2] 

sage: QS3.binary_unshuffle_sum(2) 

[1, 2, 3] + [1, 3, 2] + [2, 3, 1] 

sage: QS3.binary_unshuffle_sum(3) 

[1, 2, 3] 

sage: QS3.binary_unshuffle_sum(4) 

0 

 

Let us check the relation with the `k`-th Reiner-Saliola-Welker 

shuffling element stated in the docstring:: 

 

sage: def test_rsw(n): 

....: ZSn = SymmetricGroupAlgebra(ZZ, n) 

....: for k in range(1, n): 

....: a = ZSn.semi_rsw_element(k) 

....: b = ZSn.binary_unshuffle_sum(k) 

....: c = ZSn.left_action_product(a, ZSn.antipode(b)) 

....: d = ZSn.left_action_product(b, ZSn.antipode(a)) 

....: e = ZSn.rsw_shuffling_element(k) 

....: if c != e or d != e: 

....: return False 

....: return True 

sage: test_rsw(3) 

True 

sage: test_rsw(4) # long time 

True 

sage: test_rsw(5) # long time 

True 

 

Let us also check the statement about the complete 

non-commutative symmetric function:: 

 

sage: def test_rsw_ncsf(n): 

....: ZSn = SymmetricGroupAlgebra(ZZ, n) 

....: NSym = NonCommutativeSymmetricFunctions(ZZ) 

....: S = NSym.S() 

....: for k in range(1, n): 

....: a = S(Composition([k, n-k])).to_symmetric_group_algebra() 

....: if a != ZSn.binary_unshuffle_sum(k): 

....: return False 

....: return True 

sage: test_rsw_ncsf(3) 

True 

sage: test_rsw_ncsf(4) 

True 

sage: test_rsw_ncsf(5) # long time 

True 

""" 

n = self.n 

if n < k: 

return self.zero() 

def complement(xs): 

res = list(range(1, n + 1)) 

for x in xs: 

res.remove(x) 

return res 

P = Permutations(n) 

return self.sum_of_monomials([self._indices(P(list(q) + complement(q))) 

for q in itertools.combinations(range(1, n+1), k)]) 

 

def jucys_murphy(self, k): 

r""" 

Return the Jucys-Murphy element `J_k` (also known as a 

Young-Jucys-Murphy element) for the symmetric group 

algebra ``self``. 

 

The Jucys-Murphy element `J_k` in the symmetric group algebra 

`R S_n` is defined for every `k \in \{ 1, 2, \ldots, n \}` by 

 

.. MATH:: 

 

J_k = (1, k) + (2, k) + \cdots + (k-1, k) \in R S_n, 

 

where the addends are transpositions in `S_n` (regarded as 

elements of `R S_n`). We note that there is not a dependence on `n`, 

so it is often surpressed in the notation. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: QS3.jucys_murphy(1) 

0 

sage: QS3.jucys_murphy(2) 

[2, 1, 3] 

sage: QS3.jucys_murphy(3) 

[1, 3, 2] + [3, 2, 1] 

 

sage: QS4 = SymmetricGroupAlgebra(QQ, 4) 

sage: j3 = QS4.jucys_murphy(3); j3 

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

sage: j4 = QS4.jucys_murphy(4); j4 

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

sage: j3*j4 == j4*j3 

True 

 

sage: QS5 = SymmetricGroupAlgebra(QQ, 5) 

sage: QS5.jucys_murphy(4) 

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

 

TESTS:: 

 

sage: QS3.jucys_murphy(4) 

Traceback (most recent call last): 

... 

ValueError: k (= 4) must be between 1 and n (= 3) (inclusive) 

""" 

if k < 1 or k > self.n: 

raise ValueError("k (= {k}) must be between 1 and n (= {n}) (inclusive)".format(k=k, n=self.n)) 

 

res = self.zero() 

 

for i in range(1, k): 

p = list(range(1, self.n + 1)) 

p[i-1] = k 

p[k-1] = i 

res += self.monomial(self._indices(p)) 

return res 

 

 

 

def seminormal_basis(self, mult='l2r'): 

r""" 

Return a list of the seminormal basis elements of ``self``. 

 

The seminormal basis of a symmetric group algebra is defined as 

follows: 

 

Let `n` be a nonnegative integer. Let `R` be a `\QQ`-algebra. 

In the following, we will use the "left action" convention for 

multiplying permutations. This means that for all permutations 

`p` and `q` in `S_n`, the product `pq` is defined in such a way 

that `(pq)(i) = p(q(i))` for each `i \in \{ 1, 2, \ldots, n \}` 

(this is the same convention as in :meth:`left_action_product`, 

but not the default semantics of the `*` operator on 

permutations in Sage). Thus, for instance, `s_2 s_1` is the 

permutation obtained by first transposing `1` with `2` and 

then transposing `2` with `3` (where `s_i = (i, i+1)`). 

 

For every partition `\lambda` of `n`, let 

 

.. MATH:: 

 

\kappa_{\lambda} = \frac{n!}{f^{\lambda}} 

 

where `f^{\lambda}` is the number of standard Young tableaux 

of shape `\lambda`. Note that `\kappa_{\lambda}` is an integer, 

namely the product of all hook lengths of `\lambda` (by the 

hook length formula). In Sage, this integer can be computed by 

using :func:`sage.combinat.symmetric_group_algebra.kappa()`. 

 

Let `T` be a standard tableau of size `n`. 

 

Let `a(T)` denote the formal sum (in `R S_n`) of all 

permutations in `S_n` which stabilize the rows of `T` (as 

sets), i. e., which map each entry `i` of `T` to an entry in 

the same row as `i`. (See 

:func:`sage.combinat.symmetric_group_algebra.a()` for 

an implementation of this.) 

 

Let `b(T)` denote the signed formal sum (in `R S_n`) of all 

permutations in `S_n` which stabilize the columns of `T` (as 

sets). Here, "signed" means that each permutation is 

multiplied with its sign. (This is implemented in 

:func:`sage.combinat.symmetric_group_algebra.b()`.) 

 

Define an element `e(T)` of `R S_n` to be `a(T) b(T)`. (This 

is implemented in :func:`sage.combinat.symmetric_group_algebra.e()` 

for `R = \QQ`.) 

 

Let `\mathrm{sh}(T)` denote the shape of `T`. 

(See :meth:`~sage.combinat.tableau.Tableau.shape`.) 

 

Let `\overline{T}` denote the standard tableau of size `n-1` 

obtained by removing the letter `n` (along with its cell) from 

`T` (if `n \geq 1`). 

 

Now, we define an element `\epsilon(T)` of `R S_n`. We define 

it by induction on the size `n` of `T`, so we set 

`\epsilon(\emptyset) = 1` and only need to define `\epsilon(T)` 

for `n \geq 1`, assuming that `\epsilon(\overline{T})` is 

already defined. We do this by setting 

 

.. MATH:: 

 

\epsilon(T) = \frac{1}{\kappa_{\mathrm{sh}(T)}} 

\epsilon(\overline{T}) 

e(T) \epsilon(\overline{T}). 

 

This element `\epsilon(T)` is implemented as 

:func:`sage.combinat.symmetric_group_algebra.epsilon` for 

`R = \QQ`, but it is also a particular case of the elements 

`\epsilon(T, S)` defined below. 

 

Now let `S` be a further tableau of the same shape as `T` 

(possibly equal to `T`). Let `\pi_{T, S}` denote the 

permutation in `S_n` such that applying this permutation to 

the entries of `T` yields the tableau `S`. Define an element 

`\epsilon(T, S)` of `R S_n` by 

 

.. MATH:: 

 

\epsilon(T, S) = \frac{1}{\kappa_{\mathrm{sh}(T)}} 

\epsilon(\overline S) \pi_{T, S} 

e(T) \epsilon(\overline T) 

= \frac{1}{\kappa_{\mathrm{sh}(T)}} 

\epsilon(\overline S) a(S) \pi_{T, S} 

b(T) \epsilon(\overline T). 

 

This element `\epsilon(T, S)` is called *Young's seminormal 

unit corresponding to the bitableau `(T, S)`*, and is the 

return value of :meth:`epsilon_ik` applied to ``T`` and 

``S``. Note that `\epsilon(T, T) = \epsilon(T)`. 

 

If we let `\lambda` run through all partitions of `n`, and 

`(T, S)` run through all pairs of tableaux of shape 

`\lambda`, then the elements `\epsilon(T, S)` form a basis 

of `R S_n`. This basis is called *Young's seminormal basis* 

and has the properties that 

 

.. MATH:: 

 

\epsilon(T, S) \epsilon(U, V) = \delta_{T, V} \epsilon(U, S) 

 

(where `\delta` stands for the Kronecker delta). 

 

.. WARNING:: 

 

Because of our convention, we are multiplying our elements in 

reverse of those given in some papers, for example [Ram1997]_. 

Using the other convention of multiplying permutations, we would 

instead have 

`\epsilon(U, V) \epsilon(T, S) = \delta_{T, V} \epsilon(U, S)`. 

 

In other words, Young's seminormal basis consists of the matrix 

units in a (particular) Artin-Wedderburn decomposition of `R S_n` 

into a direct product of matrix algebras over `\QQ`. 

 

The output of :meth:`seminormal_basis` is a list of all 

elements of the seminormal basis of ``self``. 

 

INPUT: 

 

- ``mult`` -- string (default: ``'l2r'``). If set to ``'r2l'``, 

this causes the method to return the list of the 

antipodes (:meth:`antipode`) of all `\epsilon(T, S)` 

instead of the `\epsilon(T, S)` themselves. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ,3) 

sage: QS3.seminormal_basis() 

[1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1], 

1/3*[1, 2, 3] + 1/6*[1, 3, 2] - 1/3*[2, 1, 3] - 1/6*[2, 3, 1] - 1/6*[3, 1, 2] + 1/6*[3, 2, 1], 

1/3*[1, 3, 2] + 1/3*[2, 3, 1] - 1/3*[3, 1, 2] - 1/3*[3, 2, 1], 

1/4*[1, 3, 2] - 1/4*[2, 3, 1] + 1/4*[3, 1, 2] - 1/4*[3, 2, 1], 

1/3*[1, 2, 3] - 1/6*[1, 3, 2] + 1/3*[2, 1, 3] - 1/6*[2, 3, 1] - 1/6*[3, 1, 2] - 1/6*[3, 2, 1], 

1/6*[1, 2, 3] - 1/6*[1, 3, 2] - 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] - 1/6*[3, 2, 1]] 

 

TESTS:: 

 

sage: QS3g = SymmetricGroup(3).algebra(QQ) 

sage: QS3g.seminormal_basis() 

[1/6*() + 1/6*(2,3) + 1/6*(1,2) + 1/6*(1,2,3) + 1/6*(1,3,2) + 1/6*(1,3), 

1/3*() + 1/6*(2,3) - 1/3*(1,2) - 1/6*(1,2,3) - 1/6*(1,3,2) + 1/6*(1,3), 

1/3*(2,3) + 1/3*(1,2,3) - 1/3*(1,3,2) - 1/3*(1,3), 

1/4*(2,3) - 1/4*(1,2,3) + 1/4*(1,3,2) - 1/4*(1,3), 

1/3*() - 1/6*(2,3) + 1/3*(1,2) - 1/6*(1,2,3) - 1/6*(1,3,2) - 1/6*(1,3), 

1/6*() - 1/6*(2,3) - 1/6*(1,2) + 1/6*(1,2,3) + 1/6*(1,3,2) - 1/6*(1,3)] 

 

REFERENCES: 

 

.. [Ram1997] Arun Ram. *Seminormal representations of Weyl groups 

and Iwahori-Hecke algebras*. Proc. London Math. Soc. (3) 

**75** (1997). 99-133. :arxiv:`math/9511223v1`. 

http://www.ms.unimelb.edu.au/~ram/Publications/1997PLMSv75p99.pdf 

""" 

basis = [] 

for part in partition.Partitions_n(self.n): 

stp = StandardTableaux_shape(part) 

for t1 in stp: 

for t2 in stp: 

basis.append(self.epsilon_ik(t1, t2, mult=mult)) 

return basis 

 

 

def dft(self, form="seminormal", mult='l2r'): 

""" 

Return the discrete Fourier transform for ``self``. 

 

INPUT: 

 

- ``mult`` -- string (default: `l2r`). If set to `r2l`, 

this causes the method to use the antipodes 

(:meth:`antipode`) of the seminormal basis instead of 

the seminormal basis. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: QS3.dft() 

[ 1 1 1 1 1 1] 

[ 1 1/2 -1 -1/2 -1/2 1/2] 

[ 0 3/4 0 3/4 -3/4 -3/4] 

[ 0 1 0 -1 1 -1] 

[ 1 -1/2 1 -1/2 -1/2 -1/2] 

[ 1 -1 -1 1 1 -1] 

""" 

if form == "seminormal": 

return self._dft_seminormal(mult=mult) 

else: 

raise ValueError("invalid form (= %s)"%form) 

 

def _dft_seminormal(self, mult='l2r'): 

""" 

Return the seminormal form of the discrete Fourier for ``self``. 

 

INPUT: 

 

- ``mult`` -- string (default: `l2r`). If set to `r2l`, 

this causes the method to use the antipodes 

(:meth:`antipode`) of the seminormal basis instead of 

the seminormal basis. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: QS3._dft_seminormal() 

[ 1 1 1 1 1 1] 

[ 1 1/2 -1 -1/2 -1/2 1/2] 

[ 0 3/4 0 3/4 -3/4 -3/4] 

[ 0 1 0 -1 1 -1] 

[ 1 -1/2 1 -1/2 -1/2 -1/2] 

[ 1 -1 -1 1 1 -1] 

 

.. SEEALSO:: 

 

:meth:`seminormal_basis` 

""" 

snb = self.seminormal_basis(mult=mult) 

return matrix( [vector(b) for b in snb] ).inverse().transpose() 

 

def epsilon_ik(self, itab, ktab, star=0, mult='l2r'): 

r""" 

Return the seminormal basis element of ``self`` corresponding to the 

pair of tableaux ``itab`` and ``ktab`` (or restrictions of these 

tableaux, if the optional variable ``star`` is set). 

 

INPUT: 

 

- ``itab``, ``ktab`` -- two standard tableaux of size `n`. 

 

- ``star`` -- integer (default: `0`). 

 

- ``mult`` -- string (default: `l2r`). If set to `r2l`, 

this causes the method to return the antipode 

(:meth:`antipode`) of `\epsilon(I, K)` instead of 

`\epsilon(I, K)` itself. 

 

OUTPUT: 

 

The element `\epsilon(I, K)`, where `I` and `K` are the tableaux 

obtained by removing all entries higher than `n - \mathrm{star}` 

from ``itab`` and ``ktab``, respectively. Here, we are using the 

notations from :meth:`seminormal_basis`. 

 

EXAMPLES:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: a = QS3.epsilon_ik([[1,2,3]], [[1,2,3]]); a 

1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1] 

sage: QS3.dft()*vector(a) 

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

sage: a = QS3.epsilon_ik([[1,2],[3]], [[1,2],[3]]); a 

1/3*[1, 2, 3] - 1/6*[1, 3, 2] + 1/3*[2, 1, 3] - 1/6*[2, 3, 1] - 1/6*[3, 1, 2] - 1/6*[3, 2, 1] 

sage: QS3.dft()*vector(a) 

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

 

Let us take some properties of the seminormal basis listed in 

the docstring of :meth:`seminormal_basis`, and verify them on 

the situation of `S_3`. 

 

First, check the formula 

 

.. MATH:: 

 

\epsilon(T) = \frac{1}{\kappa_{\mathrm{sh}(T)}} 

\epsilon(\overline{T}) 

e(T) \epsilon(\overline{T}). 

 

In fact:: 

 

sage: from sage.combinat.symmetric_group_algebra import e 

sage: def test_sn1(n): 

....: QSn = SymmetricGroupAlgebra(QQ, n) 

....: QSn1 = SymmetricGroupAlgebra(QQ, n - 1) 

....: for T in StandardTableaux(n): 

....: TT = T.restrict(n-1) 

....: eTT = QSn1.epsilon_ik(TT, TT) 

....: eT = QSn.epsilon_ik(T, T) 

....: kT = prod(T.shape().hooks()) 

....: if kT * eT != eTT * e(T) * eTT: 

....: return False 

....: return True 

sage: test_sn1(3) 

True 

sage: test_sn1(4) # long time 

True 

 

Next, we check the identity 

 

.. MATH:: 

 

\epsilon(T, S) = \frac{1}{\kappa_{\mathrm{sh}(T)}} 

\epsilon(\overline S) \pi_{T, S} 

e(T) \epsilon(\overline T) 

 

which we used to define `\epsilon(T, S)`. In fact:: 

 

sage: from sage.combinat.symmetric_group_algebra import e 

sage: def test_sn2(n): 

....: QSn = SymmetricGroupAlgebra(QQ, n) 

....: mul = QSn.left_action_product 

....: QSn1 = SymmetricGroupAlgebra(QQ, n - 1) 

....: for lam in Partitions(n): 

....: k = prod(lam.hooks()) 

....: for T in StandardTableaux(lam): 

....: for S in StandardTableaux(lam): 

....: TT = T.restrict(n-1) 

....: SS = S.restrict(n-1) 

....: eTT = QSn1.epsilon_ik(TT, TT) 

....: eSS = QSn1.epsilon_ik(SS, SS) 

....: eTS = QSn.epsilon_ik(T, S) 

....: piTS = [0] * n 

....: for (i, j) in T.cells(): 

....: piTS[T[i][j] - 1] = S[i][j] 

....: piTS = QSn(Permutation(piTS)) 

....: if k * eTS != mul(mul(eSS, piTS), mul(e(T), eTT)): 

....: return False 

....: return True 

sage: test_sn2(3) 

True 

sage: test_sn2(4) # long time 

True 

 

Let us finally check the identity 

 

.. MATH:: 

 

\epsilon(T, S) \epsilon(U, V) = \delta_{T, V} \epsilon(U, S) 

 

In fact:: 

 

sage: def test_sn3(lam): 

....: n = lam.size() 

....: QSn = SymmetricGroupAlgebra(QQ, n) 

....: mul = QSn.left_action_product 

....: for T in StandardTableaux(lam): 

....: for S in StandardTableaux(lam): 

....: for U in StandardTableaux(lam): 

....: for V in StandardTableaux(lam): 

....: lhs = mul(QSn.epsilon_ik(T, S), QSn.epsilon_ik(U, V)) 

....: if T == V: 

....: rhs = QSn.epsilon_ik(U, S) 

....: else: 

....: rhs = QSn.zero() 

....: if rhs != lhs: 

....: return False 

....: return True 

sage: all( test_sn3(lam) for lam in Partitions(3) ) 

True 

sage: all( test_sn3(lam) for lam in Partitions(4) ) # long time 

True 

""" 

it = Tableau(itab) 

kt = Tableau(ktab) 

 

stn = StandardTableaux_size(self.n) 

 

if it not in stn: 

raise TypeError("it must be a standard tableau of size %s"%self.n) 

 

if kt not in stn: 

raise TypeError("kt must be a standard tableau of size %s"%self.n) 

 

if it.shape() != kt.shape(): 

raise ValueError("it and kt must be of the same shape") 

 

BR = self.base_ring() 

I = self._indices 

z_elts = {} 

epik = epsilon_ik(it, kt, star=star) 

for m,c in six.iteritems(epik._monomial_coefficients): 

z_elts[I(m)] = BR(c) 

z = self._from_dict(z_elts) 

 

if mult == 'l2r': 

return z 

else: 

return z.map_support(lambda x: x.inverse()) 

 

 

epsilon_ik_cache = {} 

def epsilon_ik(itab, ktab, star=0): 

""" 

Return the seminormal basis element of the symmetric group 

algebra `\QQ S_n` corresponding to the pair of tableaux 

``itab`` and ``ktab`` (or restrictions of these tableaux, 

if the optional variable ``star`` is set). 

 

INPUT: 

 

- ``itab``, ``ktab`` -- two standard tableaux of same size. 

 

- ``star`` -- integer (default: `0`). 

 

OUTPUT: 

 

The element `\epsilon(I, K) \in \QQ S_n`, where `I` and `K` 

are the tableaux obtained by removing all entries higher 

than `n - \mathrm{star}` from ``itab`` and ``ktab``, 

respectively (where `n` is the size of ``itab`` and 

``ktab``). Here, we are using the notations from 

:meth:`~sage.combinat.symmetric_group_algebra.SymmetricGroupAlgebra_n.seminormal_basis`. 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import epsilon_ik 

sage: epsilon_ik([[1,2],[3]], [[1,3],[2]]) 

1/4*[1, 3, 2] - 1/4*[2, 3, 1] + 1/4*[3, 1, 2] - 1/4*[3, 2, 1] 

sage: epsilon_ik([[1,2],[3]], [[1,3],[2]], star=1) 

Traceback (most recent call last): 

... 

ValueError: the two tableaux must be of the same shape 

""" 

it = Tableau(itab) 

kt = Tableau(ktab) 

if star: 

it = it.restrict(it.size() - star) 

kt = kt.restrict(kt.size() - star) 

 

if it.shape() != kt.shape(): 

raise ValueError("the two tableaux must be of the same shape") 

 

if kt == it: 

res = epsilon(itab) 

elif (it, kt) in epsilon_ik_cache: 

res = epsilon_ik_cache[(it, kt)] 

else: 

eik = e_ik(it, kt, star) 

QSn = eik.parent() 

mul = QSn.right_action_product 

epsilon_ik_cache[(it, kt)] = mul(mul(epsilon(it, star+1), eik), 

epsilon(kt, star+1)) * (1/kappa(it.shape())) 

res = epsilon_ik_cache[(it, kt)] 

 

return res 

 

 

epsilon_cache = {} 

def epsilon(tab, star=0): 

r""" 

The `(T, T)`-th element of the seminormal basis of the group 

algebra `\QQ[S_n]`, where `T` is the tableau ``tab`` (with its 

``star`` highest entries removed if the optional variable 

``star`` is set). 

 

See the docstring of 

:meth:`~sage.combinat.symmetric_group_algebra.SymmetricGroupAlgebra_n.seminormal_basis` 

for the notation used herein. 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import epsilon 

sage: epsilon([[1,2]]) 

1/2*[1, 2] + 1/2*[2, 1] 

sage: epsilon([[1],[2]]) 

1/2*[1, 2] - 1/2*[2, 1] 

""" 

t = Tableau(tab) 

 

if star: 

t = t.restrict(t.size() - star) 

 

if t in epsilon_cache: 

res = epsilon_cache[t] 

else: 

if t.size() == 2: 

epsilon_cache[t] = e(t) * (1 / kappa(t.shape())) 

res = epsilon_cache[t] 

elif t == Tableau([[1]]): 

epsilon_cache[t] = e(t) 

res = epsilon_cache[t] 

else: 

et = e(t) 

QSn = et.parent() 

mul = QSn.right_action_product 

epsilon_cache[t] = mul(mul(epsilon(t, 1), e(t)), epsilon(t, 1)) * (1 / kappa(t.shape())) 

res = epsilon_cache[t] 

 

return res 

 

 

def pi_ik(itab, ktab): 

r""" 

Return the permutation `p` which sends every entry of the 

tableau ``itab`` to the respective entry of the tableau 

``ktab``, as an element of the corresponding symmetric group 

algebra. 

 

This assumes that ``itab`` and ``ktab`` are tableaux (possibly 

given just as lists of lists) of the same shape. 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import pi_ik 

sage: pi_ik([[1,3],[2]], [[1,2],[3]]) 

[1, 3, 2] 

""" 

it = Tableau(itab) 

kt = Tableau(ktab) 

 

p = [None]*kt.size() 

for i in range(len(kt)): 

for j in range(len(kt[i])): 

p[ it[i][j] -1 ] = kt[i][j] 

 

QSn = SymmetricGroupAlgebra(QQ, it.size()) 

p = Permutation(p) 

return QSn(p) 

 

 

def kappa(alpha): 

r""" 

Return `\kappa_\alpha`, which is `n!` divided by the number 

of standard tableaux of shape `\alpha` (where `\alpha` is a 

partition of `n`). 

 

INPUT: 

 

- ``alpha`` -- integer partition (can be encoded as a list). 

 

OUTPUT: 

 

The factorial of the size of ``alpha``, divided by the number of 

standard tableaux of shape ``alpha``. Equivalently, the product 

of all hook lengths of ``alpha``. 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import kappa 

sage: kappa(Partition([2,1])) 

3 

sage: kappa([2,1]) 

3 

""" 

try: 

n = alpha.size() 

except AttributeError: 

n = sum(alpha) 

return factorial(n) / StandardTableaux(alpha).cardinality() 

 

def a(tableau, star=0, base_ring=QQ): 

r""" 

The row projection operator corresponding to the Young tableau 

``tableau`` (which is supposed to contain every integer from 

`1` to its size precisely once, but may and may not be standard). 

 

This is the sum (in the group algebra of the relevant symmetric 

group over `\QQ`) of all the permutations which preserve 

the rows of ``tableau``. It is called `a_{\text{tableau}}` in 

[EtRT]_, Section 4.2. 

 

REFERENCES: 

 

.. [EtRT] Pavel Etingof, Oleg Golberg, Sebastian Hensel, Tiankai 

Liu, Alex Schwendner, Dmitry Vaintrob, Elena Yudovina, 

"Introduction to representation theory", 

:arXiv:`0901.0827v5`. 

 

INPUT: 

 

- ``tableau`` -- Young tableau which contains every integer 

from `1` to its size precisely once. 

 

- ``star`` -- nonnegative integer (default: `0`). When this 

optional variable is set, the method computes not the row 

projection operator of ``tableau``, but the row projection 

operator of the restriction of ``tableau`` to the entries 

``1, 2, ..., tableau.size() - star`` instead. 

 

- ``base_ring`` -- commutative ring (default: ``QQ``). When this 

optional variable is set, the row projection operator is 

computed over a user-determined base ring instead of `\QQ`. 

(Note that symmetric group algebras currently don't preserve 

coercion, so e. g. a symmetric group algebra over `\ZZ` 

does not coerce into the corresponding one over `\QQ`; so 

convert manually or choose your base rings wisely!) 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import a 

sage: a([[1,2]]) 

[1, 2] + [2, 1] 

sage: a([[1],[2]]) 

[1, 2] 

sage: a([]) 

[] 

sage: a([[1, 5], [2, 3], [4]]) 

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

sage: a([[1,4], [2,3]], base_ring=ZZ) 

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

""" 

t = Tableau(tableau) 

if star: 

t = t.restrict(t.size()-star) 

 

rs = t.row_stabilizer().list() 

n = t.size() 

 

sgalg = SymmetricGroupAlgebra(base_ring, n) 

one = base_ring.one() 

P = Permutation 

 

# Ugly hack for the case of an empty tableau, due to the 

# annoyance of Permutation(Tableau([]).row_stabilizer()[0]) 

# being [1] rather than [] (which seems to have its origins in 

# permutation group code). 

# TODO: Fix this. 

if len(tableau) == 0: 

return sgalg.one() 

 

rd = dict((P(h), one) for h in rs) 

return sgalg._from_dict(rd) 

 

def b(tableau, star=0, base_ring=QQ): 

r""" 

The column projection operator corresponding to the Young tableau 

``tableau`` (which is supposed to contain every integer from 

`1` to its size precisely once, but may and may not be standard). 

 

This is the signed sum (in the group algebra of the relevant 

symmetric group over `\QQ`) of all the permutations which 

preserve the column of ``tableau`` (where the signs are the usual 

signs of the permutations). It is called `b_{\text{tableau}}` in 

[EtRT]_, Section 4.2. 

 

INPUT: 

 

- ``tableau`` -- Young tableau which contains every integer 

from `1` to its size precisely once. 

 

- ``star`` -- nonnegative integer (default: `0`). When this 

optional variable is set, the method computes not the column 

projection operator of ``tableau``, but the column projection 

operator of the restriction of ``tableau`` to the entries 

``1, 2, ..., tableau.size() - star`` instead. 

 

- ``base_ring`` -- commutative ring (default: ``QQ``). When this 

optional variable is set, the column projection operator is 

computed over a user-determined base ring instead of `\QQ`. 

(Note that symmetric group algebras currently don't preserve 

coercion, so e. g. a symmetric group algebra over `\ZZ` 

does not coerce into the corresponding one over `\QQ`; so 

convert manually or choose your base rings wisely!) 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import b 

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

[1, 2] 

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

[1, 2] - [2, 1] 

sage: b([]) 

[] 

sage: b([[1, 2, 4], [5, 3]]) 

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

sage: b([[1, 4], [2, 3]], base_ring=ZZ) 

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

sage: b([[1, 4], [2, 3]], base_ring=Integers(5)) 

[1, 2, 3, 4] + 4*[1, 2, 4, 3] + 4*[2, 1, 3, 4] + [2, 1, 4, 3] 

 

With the ``l2r`` setting for multiplication, the unnormalized 

Young symmetrizer ``e(tableau)`` should be the product 

``b(tableau) * a(tableau)`` for every ``tableau``. Let us check 

this on the standard tableaux of size 5:: 

 

sage: from sage.combinat.symmetric_group_algebra import a, b, e 

sage: all( e(t) == b(t) * a(t) for t in StandardTableaux(5) ) 

True 

""" 

t = Tableau(tableau) 

if star: 

t = t.restrict(t.size()-star) 

 

cs = t.column_stabilizer().list() 

n = t.size() 

 

sgalg = SymmetricGroupAlgebra(base_ring, n) 

one = base_ring.one() 

P = Permutation 

 

# Ugly hack for the case of an empty tableau, due to the 

# annoyance of Permutation(Tableau([]).row_stabilizer()[0]) 

# being [1] rather than [] (which seems to have its origins in 

# permutation group code). 

# TODO: Fix this. 

if len(tableau) == 0: 

return sgalg.one() 

 

cd = dict((P(v), v.sign()*one) for v in cs) 

return sgalg._from_dict(cd) 

 

e_cache = {} 

def e(tableau, star=0): 

r""" 

The unnormalized Young projection operator corresponding to 

the Young tableau ``tableau`` (which is supposed to contain 

every integer from `1` to its size precisely once, but may 

and may not be standard). 

 

If `n` is a nonnegative integer, and `T` is a Young tableau 

containing every integer from `1` to `n` exactly once, then 

the unnormalized Young projection operator `e(T)` is defined by 

 

.. MATH:: 

 

e(T) = a(T) b(T) \in \QQ S_n, 

 

where `a(T) \in \QQ S_n` is the sum of all permutations in `S_n` 

which fix the rows of `T` (as sets), and `b(T) \in \QQ S_n` is the 

signed sum of all permutations in `S_n` which fix the columns of 

`T` (as sets). Here, "signed" means that each permutation is 

multiplied with its sign; and the product on the group `S_n` is 

defined in such a way that `(pq)(i) = p(q(i))` for any 

permutations `p` and `q` and any `1 \leq i \leq n`. 

 

Note that the definition of `e(T)` is not uniform across 

literature. Others define it as `b(T) a(T)` instead, or include 

certain scalar factors (we do not, whence "unnormalized"). 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import e 

sage: e([[1,2]]) 

[1, 2] + [2, 1] 

sage: e([[1],[2]]) 

[1, 2] - [2, 1] 

sage: e([]) 

[] 

 

There are differing conventions for the order of the symmetrizers 

and antisymmetrizers. This example illustrates our conventions:: 

 

sage: e([[1,2],[3]]) 

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

 

To obtain the product `b(T) a(T)`, one has to take the antipode 

of this:: 

 

sage: QS3 = parent(e([[1,2],[3]])) 

sage: QS3.antipode(e([[1,2],[3]])) 

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

 

.. SEEALSO:: 

 

:func:`e_hat` 

""" 

# TODO: 

# The current method only computes the e's over QQ. There should be 

# a way to compute them over other base rings as well. Be careful 

# with the cache. 

 

t = Tableau(tableau) 

if star: 

t = t.restrict(t.size()-star) 

 

if t in e_cache: 

res = e_cache[t] 

else: 

rs = t.row_stabilizer().list() 

cs = t.column_stabilizer().list() 

n = t.size() 

 

QSn = SymmetricGroupAlgebra(QQ, n) 

one = QQ.one() 

P = Permutation 

 

rd = dict((P(h), one) for h in rs) 

sym = QSn._from_dict(rd) 

 

cd = dict((P(v), v.sign()*one) for v in cs) 

antisym = QSn._from_dict(cd) 

 

res = QSn.right_action_product(antisym, sym) 

 

# Ugly hack for the case of an empty tableau, due to the 

# annoyance of Permutation(Tableau([]).row_stabilizer()[0]) 

# being [1] rather than [] (which seems to have its origins in 

# permutation group code). 

# TODO: Fix this. 

if len(tableau) == 0: 

res = QSn.one() 

 

e_cache[t] = res 

 

return res 

 

ehat_cache = {} 

def e_hat(tab, star=0): 

r""" 

The Young projection operator corresponding to the Young tableau 

``tab`` (which is supposed to contain every integer from `1` to 

its size precisely once, but may and may not be standard). This 

is an idempotent in the rational group algebra. 

 

If `n` is a nonnegative integer, and `T` is a Young tableau 

containing every integer from `1` to `n` exactly once, then 

the Young projection operator `\widehat{e}(T)` is defined by 

 

.. MATH:: 

 

\widehat{e}(T) = \frac{1}{\kappa_\lambda} a(T) b(T) \in \QQ S_n, 

 

where `\lambda` is the shape of `T`, where `\kappa_\lambda` is 

`n!` divided by the number of standard tableaux of shape 

`\lambda`, where `a(T) \in \QQ S_n` is the sum of all 

permutations in `S_n` which fix the rows of `T` (as sets), and 

where `b(T) \in \QQ S_n` is the signed sum of all permutations 

in `S_n` which fix the columns of `T` (as sets). Here, "signed" 

means that each permutation is multiplied with its sign; and 

the product on the group `S_n` is defined in such a way that 

`(pq)(i) = p(q(i))` for any permutations `p` and `q` and any 

`1 \leq i \leq n`. 

 

Note that the definition of `\widehat{e}(T)` is not uniform 

across literature. Others define it as 

`\frac{1}{\kappa_\lambda} b(T) a(T)` instead. 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import e_hat 

sage: e_hat([[1,2,3]]) 

1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1] 

sage: e_hat([[1],[2]]) 

1/2*[1, 2] - 1/2*[2, 1] 

 

There are differing conventions for the order of the symmetrizers 

and antisymmetrizers. This example illustrates our conventions:: 

 

sage: e_hat([[1,2],[3]]) 

1/3*[1, 2, 3] + 1/3*[2, 1, 3] - 1/3*[3, 1, 2] - 1/3*[3, 2, 1] 

 

.. SEEALSO:: 

 

:func:`e` 

""" 

t = Tableau(tab) 

if star: 

t = t.restrict(t.size()-star) 

if t in ehat_cache: 

res = ehat_cache[t] 

else: 

res = (1/kappa(t.shape()))*e(t) 

return res 

 

e_ik_cache = {} 

def e_ik(itab, ktab, star=0): 

""" 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import e_ik 

sage: e_ik([[1,2,3]], [[1,2,3]]) 

[1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1] 

sage: e_ik([[1,2,3]], [[1,2,3]], star=1) 

[1, 2] + [2, 1] 

""" 

it = Tableau(itab) 

kt = Tableau(ktab) 

if star: 

it = it.restrict(it.size() - star) 

kt = kt.restrict(kt.size() - star) 

 

if it.shape() != kt.shape(): 

raise ValueError("the two tableaux must be of the same shape") 

 

if kt == it: 

return e(it) 

if (it, kt) in e_ik_cache: 

return e_ik_cache[(it,kt)] 

 

pi = pi_ik(it,kt) 

QSn = pi.parent() 

res = QSn.right_action_product(e(it), pi) 

e_ik_cache[(it,kt)] = res 

return res 

 

def seminormal_test(n): 

""" 

Run a variety of tests to verify that the construction of the 

seminormal basis works as desired. The numbers appearing are 

results in James and Kerber's 'Representation Theory of the 

Symmetric Group' [JamesKerber]_. 

 

EXAMPLES:: 

 

sage: from sage.combinat.symmetric_group_algebra import seminormal_test 

sage: seminormal_test(3) 

True 

""" 

for part in partition.Partitions_n(n): 

for tab in StandardTableaux(part): 

#Theorem 3.1.10 

if not e(tab)*(1/kappa(part)) - e_hat(tab) == 0: 

raise ValueError("3.1.10 - %s"%tab) 

 

#Lemma 3.2.12 (ii) 

value = e(tab)*epsilon(tab,1)*e(tab) - e(tab)*(kappa(part)) 

if value != 0: 

print(value) 

raise ValueError("3.2.12.2 - %s" % tab) 

 

for tab2 in StandardTableaux(part): 

#3.2.8 (i) 

if e_ik(tab, tab2) - e(tab)*pi_ik(tab, tab2)*e(tab2)*(1/kappa(part)) != 0: 

raise ValueError("3.2.8.1 - %s, %s"%(tab, tab2)) 

 

#3.2.8 (ii) 

if e(tab)*e_ik(tab, tab2) - e_ik(tab, tab2)*(kappa(part)) != 0: 

raise ValueError("3.2.8.2 - %s, %s"%(tab, tab2)) 

 

if tab == tab2: 

continue 

 

if tab.last_letter_lequal(tab2): 

#Lemma 3.1.20 

if e(tab2)*e(tab) != 0: 

raise ValueError("3.1.20 - %s, %s"%(tab, tab2)) 

if e_hat(tab2)*e_hat(tab) != 0: 

raise ValueError("3.1.20 - %s, %s"%(tab, tab2)) 

return True 

 

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

 

 

def HeckeAlgebraSymmetricGroupT(R, n, q=None): 

r""" 

Return the Hecke algebra of the symmetric group `S_n` on the T-basis 

with quantum parameter ``q`` over the ring `R`. 

 

If `R` is a commutative ring and `q` is an invertible element of `R`, 

and if `n` is a nonnegative integer, then the Hecke algebra of the 

symmetric group `S_n` over `R` with quantum parameter `q` is defined 

as the algebra generated by the generators `T_1, T_2, \ldots, T_{n-1}` 

with relations 

 

.. MATH:: 

 

T_i T_{i+1} T_i = T_{i+1} T_i T_{i+1} 

 

for all `i < n-1` ("braid relations"), 

 

.. MATH:: 

 

T_i T_j = T_j T_i 

 

for all `i` and `j` such that `| i-j | > 1` ("locality relations"), 

and 

 

.. MATH:: 

 

T_i^2 = q + (q-1) T_i 

 

for all `i` (the "quadratic relations", also known in the form 

`(T_i + 1) (T_i - q) = 0`). (This is only one of several existing 

definitions in literature, not all of which are fully equivalent. 

We are following the conventions of [GS93]_.) For any permutation 

`w \in S_n`, we can define an element `T_w` of this Hecke algebra by 

setting `T_w = T_{i_1} T_{i_2} \cdots T_{i_k}`, where 

`w = s_{i_1} s_{i_2} \cdots s_{i_k}` is a reduced word for `w` 

(with `s_i` meaning the transposition `(i, i+1)`, and the product of 

permutations being evaluated by first applying `s_{i_k}`, then 

`s_{i_{k-1}}`, etc.). This element is independent of the choice of 

the reduced decomposition, and can be computed in Sage by calling 

``H[w]`` where ``H`` is the Hecke algebra and ``w`` is the 

permutation. 

 

The Hecke algebra of the symmetric group `S_n` with quantum parameter 

`q` over `R` can be seen as a deformation of the group algebra 

`R S_n`; indeed, it becomes `R S_n` when `q = 1`. 

 

.. WARNING:: 

 

The multiplication on the Hecke algebra of the symmetric group 

does *not* follow the global option ``mult`` of the 

:class:`Permutations` class (see 

:meth:`~sage.combinat.permutation.Permutations.options`). 

It is always as defined above. It does not match the default 

option (``mult=l2r``) of the symmetric group algebra! 

 

REFERENCES: 

 

.. [GS93] David M. Goldschmidt. 

*Group characters, symmetric functions, and the Hecke algebras*. 

AMS 1993. 

 

EXAMPLES:: 

 

sage: HeckeAlgebraSymmetricGroupT(QQ, 3) 

Hecke algebra of the symmetric group of order 3 on the T basis over Univariate Polynomial Ring in q over Rational Field 

 

:: 

 

sage: HeckeAlgebraSymmetricGroupT(QQ, 3, 2) 

Hecke algebra of the symmetric group of order 3 with q=2 on the T basis over Rational Field 

 

The multiplication on the Hecke algebra follows a different convention 

than the one on the symmetric group algebra does by default:: 

 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ, 3) 

sage: H3([1,3,2]) * H3([2,1,3]) 

T[3, 1, 2] 

sage: S3 = SymmetricGroupAlgebra(QQ, 3) 

sage: S3([1,3,2]) * S3([2,1,3]) 

[2, 3, 1] 

 

sage: TestSuite(H3).run() 

""" 

 

return HeckeAlgebraSymmetricGroup_t(R, n, q) 

 

class HeckeAlgebraSymmetricGroup_generic(CombinatorialAlgebra): 

def __init__(self, R, n, q=None): 

""" 

TESTS:: 

 

sage: HeckeAlgebraSymmetricGroupT(QQ, 3) 

Hecke algebra of the symmetric group of order 3 on the T basis over Univariate Polynomial Ring in q over Rational Field 

 

:: 

 

sage: HeckeAlgebraSymmetricGroupT(QQ, 3, q=1) 

Hecke algebra of the symmetric group of order 3 with q=1 on the T basis over Rational Field 

""" 

self.n = n 

self._indices = Permutations(n) 

self._name = "Hecke algebra of the symmetric group of order {}".format(n) 

self._one = self._indices(range(1,n+1)) 

 

if q is None: 

q = PolynomialRing(R, 'q').gen() 

R = q.parent() 

else: 

if q not in R: 

raise ValueError("q must be in R (= {})".format(R)) 

self._name += " with q={}".format(q) 

 

self._q = q 

 

CombinatorialAlgebra.__init__(self, R) 

# _repr_ customization: output the basis element indexed by [1,2,3] as [1,2,3] 

self.print_options(prefix="") 

 

_repr_option_bracket = False 

 

def q(self): 

""" 

EXAMPLES:: 

 

sage: HeckeAlgebraSymmetricGroupT(QQ, 3).q() 

q 

sage: HeckeAlgebraSymmetricGroupT(QQ, 3, 2).q() 

2 

""" 

return self._q 

 

 

def _coerce_start(self, x): 

""" 

EXAMPLES:: 

 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ, 3) 

sage: H3._coerce_start([2,1]) 

T[2, 1, 3] 

""" 

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

# Coerce permutations of size smaller that self.n # 

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

if x == []: 

return self.one() 

if len(x) < self.n and x in Permutations(): 

return self.monomial(self._indices(list(x) + 

list(range(len(x)+1, self.n+1)))) 

raise TypeError 

 

class HeckeAlgebraSymmetricGroup_t(HeckeAlgebraSymmetricGroup_generic): 

 

def __init__(self, R, n, q=None): 

""" 

TESTS:: 

 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ, 3) 

sage: H3 == loads(dumps(H3)) 

True 

""" 

HeckeAlgebraSymmetricGroup_generic.__init__(self, R, n, q) 

self._name += " on the T basis" 

self.print_options(prefix="T") 

 

def t_action_on_basis(self, perm, i): 

r""" 

Return the product `T_i \cdot T_{perm}`, where ``perm`` is a 

permutation in the symmetric group `S_n`. 

 

EXAMPLES:: 

 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ, 3) 

sage: H3.t_action_on_basis(Permutation([2,1,3]), 1) 

q*T[1, 2, 3] + (q-1)*T[2, 1, 3] 

sage: H3.t_action_on_basis(Permutation([1,2,3]), 1) 

T[2, 1, 3] 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ, 3, 1) 

sage: H3.t_action_on_basis(Permutation([2,1,3]), 1) 

T[1, 2, 3] 

sage: H3.t_action_on_basis(Permutation([1,3,2]), 2) 

T[1, 2, 3] 

""" 

if i not in range(1, self.n): 

raise ValueError("i (= %(i)d) must be between 1 and n (= %(n)d)" % {'i': i, 'n': self.n}) 

 

t_i = Permutation( (i, i+1) ) 

perm_i = t_i.right_action_product(perm) 

# This used to be perm_i = t_i * perm. I have changed it to 

# perm_i = t_i.right_action_product(perm) because it would 

# otherwise cause TestSuite(H3) to fail when 

# Permutations.options(mult) would be set to "r2l". 

# -- Darij, 19 Nov 2013 

 

if perm[i-1] < perm[i]: 

return self.monomial(self._indices(perm_i)) 

else: 

#Ti^2 = (q - q^(-1))*Ti - q1*q2 

q = self.q() 

z_elt = {perm_i:q, perm:q-1} 

return self._from_dict(z_elt) 

 

 

def t_action(self, a, i): 

r""" 

Return the product `T_i \cdot a`. 

 

EXAMPLES:: 

 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ, 3) 

sage: a = H3([2,1,3])+2*H3([1,2,3]) 

sage: H3.t_action(a, 1) 

q*T[1, 2, 3] + (q+1)*T[2, 1, 3] 

sage: H3.t(1)*a 

q*T[1, 2, 3] + (q+1)*T[2, 1, 3] 

""" 

t_i = lambda x: self.t_action_on_basis(x, i) 

return self._apply_module_endomorphism(a, t_i) 

 

 

def _multiply_basis(self, perm1, perm2): 

""" 

EXAMPLES:: 

 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ, 3, 1) 

sage: a = H3([2,1,3])+2*H3([1,2,3])-H3([3,2,1]) 

sage: a^2 #indirect doctest 

6*T[1, 2, 3] + 4*T[2, 1, 3] - T[2, 3, 1] - T[3, 1, 2] - 4*T[3, 2, 1] 

 

:: 

 

sage: QS3 = SymmetricGroupAlgebra(QQ, 3) 

sage: a = QS3([2,1,3])+2*QS3([1,2,3])-QS3([3,2,1]) 

sage: a^2 

6*[1, 2, 3] + 4*[2, 1, 3] - [2, 3, 1] - [3, 1, 2] - 4*[3, 2, 1] 

""" 

res = self(perm1) 

for i in perm2.reduced_word(): 

res = self.t_action(res, i) 

return res 

 

def t(self, i): 

""" 

Return the element `T_i` of the Hecke algebra ``self``. 

 

EXAMPLES:: 

 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ,3) 

sage: H3.t(1) 

T[2, 1, 3] 

sage: H3.t(2) 

T[1, 3, 2] 

sage: H3.t(0) 

Traceback (most recent call last): 

... 

ValueError: i (= 0) must be between 1 and n-1 (= 2) 

""" 

if i not in range(1, self.n): 

raise ValueError("i (= %(i)d) must be between 1 and n-1 (= %(nm)d)" % {'i': i, 'nm': self.n - 1}) 

 

P = self.basis().keys() 

return self.monomial(P(list(range(1, i)) + [i+1, i] + list(range(i+2, self.n+1)))) 

# The permutation here is simply the transposition (i, i+1). 

 

def algebra_generators(self): 

""" 

Return the generators of the algebra. 

 

EXAMPLES:: 

 

sage: HeckeAlgebraSymmetricGroupT(QQ,3).algebra_generators() 

[T[2, 1, 3], T[1, 3, 2]] 

""" 

return [self.t(_) for _ in range(1, self.n)] 

 

def jucys_murphy(self, k): 

""" 

Return the Jucys-Murphy element `J_k` of the Hecke algebra. 

 

These Jucys-Murphy elements are defined by 

 

.. MATH:: 

 

J_k = (T_{k-1} T_{k-2} \cdots T_1) (T_1 T_2 \cdots T_{k-1}). 

 

More explicitly, 

 

.. MATH:: 

 

J_k = q^{k-1} + \sum_{l=1}^{k-1} (q^l - q^{l-1}) T_{(l, k)}. 

 

For generic `q`, the `J_k` generate a maximal commutative 

sub-algebra of the Hecke algebra. 

 

.. WARNING:: 

 

The specialization `q = 1` does *not* map these elements 

`J_k` to the Young-Jucys-Murphy elements of the group 

algebra `R S_n`. (Instead, it maps the "reduced" 

Jucys-Murphy elements `(J_k - q^{k-1}) / (q - 1)` to the 

Young-Jucys-Murphy elements of `R S_n`.) 

 

EXAMPLES:: 

 

sage: H3 = HeckeAlgebraSymmetricGroupT(QQ,3) 

sage: j2 = H3.jucys_murphy(2); j2 

q*T[1, 2, 3] + (q-1)*T[2, 1, 3] 

sage: j3 = H3.jucys_murphy(3); j3 

q^2*T[1, 2, 3] + (q^2-q)*T[1, 3, 2] + (q-1)*T[3, 2, 1] 

sage: j2*j3 == j3*j2 

True 

sage: j0 = H3.jucys_murphy(1); j0 == H3.one() 

True 

sage: H3.jucys_murphy(0) 

Traceback (most recent call last): 

... 

ValueError: k (= 0) must be between 1 and n (= 3) 

""" 

if k not in range(2, self.n+1): 

if k == 1: 

return self.one() 

raise ValueError("k (= %(k)d) must be between 1 and n (= %(n)d)" % {'k': k, 'n': self.n}) 

 

q = self.q() 

P = self._indices 

v = self.sum_of_terms( ( ( P(list(range(1, l)) + [k] + list(range(l+1, k)) + [l]), 

q ** l - q ** (l-1) ) 

for l in range(1, k) ), 

distinct=True ) 

v += q ** (k-1) * self.one() 

return v 

 

#old algorithm: 

# left = 1 

# right = 1 

# for j in range(1, k): 

# left *= self.t(k-j) 

# right *= self.t(j) 

# return left*right 

 

 

# For unpickling backward compatibility (Sage <= 4.1) 

from sage.structure.sage_object import register_unpickle_override 

register_unpickle_override('sage.combinat.symmetric_group_algebra', 'HeckeAlgebraSymmetricGroupElement_t', CombinatorialFreeModule.Element) 

register_unpickle_override('sage.combinat.symmetric_group_algebra', 'SymmetricGroupAlgebraElement_n', CombinatorialFreeModule.Element)