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

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

r""" 

Coxeter Groups 

""" 

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

# Copyright (C) 2009 Nicolas M. Thiery <nthiery at users.sf.net> 

# 2015 Christian Stump <christian.stump at gmail.com 

# 

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

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

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

# With contributions from Dan Bump, Steve Pon, Qiang Wang, Anne Schilling, Christian Stump, Mark Shimozono 

from six.moves import range 

 

from sage.misc.abstract_method import abstract_method 

from sage.misc.cachefunc import cached_method, cached_in_parent_method 

from sage.misc.lazy_import import LazyImport 

from sage.misc.constant_function import ConstantFunction 

from sage.misc.misc import attrcall, uniq 

from sage.categories.category_singleton import Category_singleton 

from sage.categories.enumerated_sets import EnumeratedSets 

from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets 

from sage.categories.generalized_coxeter_groups import GeneralizedCoxeterGroups 

from sage.structure.element import have_same_parent, parent 

from sage.misc.flatten import flatten 

from copy import copy 

 

class CoxeterGroups(Category_singleton): 

r""" 

The category of Coxeter groups. 

 

A *Coxeter group* is a group `W` with a distinguished (finite) 

family of involutions `(s_i)_{i\in I}`, called the *simple 

reflections*, subject to relations of the form `(s_is_j)^{m_{i,j}} = 1`. 

 

`I` is the *index set* of `W` and `|I|` is the *rank* of `W`. 

 

See :Wikipedia:`Coxeter_group` for details. 

 

EXAMPLES:: 

 

sage: C = CoxeterGroups(); C 

Category of coxeter groups 

sage: C.super_categories() 

[Category of generalized coxeter groups] 

 

sage: W = C.example(); W 

The symmetric group on {0, ..., 3} 

 

sage: W.simple_reflections() 

Finite family {0: (1, 0, 2, 3), 1: (0, 2, 1, 3), 2: (0, 1, 3, 2)} 

 

Here are some further examples:: 

 

sage: FiniteCoxeterGroups().example() 

The 5-th dihedral group of order 10 

sage: FiniteWeylGroups().example() 

The symmetric group on {0, ..., 3} 

sage: WeylGroup(["B", 3]) 

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

 

Those will eventually be also in this category:: 

 

sage: SymmetricGroup(4) 

Symmetric group of order 4! as a permutation group 

sage: DihedralGroup(5) 

Dihedral group of order 10 as a permutation group 

 

.. TODO:: add a demo of usual computations on Coxeter groups. 

 

.. SEEALSO:: 

 

- :mod:`sage.combinat.root_system` 

- :class:`WeylGroups` 

- :class:`GeneralizedCoxeterGroups` 

 

.. WARNING:: 

 

It is assumed that morphisms in this category preserve the 

distinguished choice of simple reflections. In particular, 

subobjects in this category are parabolic subgroups. In this 

sense, this category might be better named ``Coxeter 

Systems``. In the long run we might want to have two distinct 

categories, one for Coxeter groups (with morphisms being just 

group morphisms) and one for Coxeter systems:: 

 

sage: CoxeterGroups().is_full_subcategory(Groups()) 

False 

sage: from sage.categories.generalized_coxeter_groups import GeneralizedCoxeterGroups 

sage: CoxeterGroups().is_full_subcategory(GeneralizedCoxeterGroups()) 

True 

 

TESTS:: 

 

sage: W = CoxeterGroups().example() 

sage: TestSuite(W).run() 

""" 

 

def super_categories(self): 

""" 

EXAMPLES:: 

 

sage: CoxeterGroups().super_categories() 

[Category of generalized coxeter groups] 

""" 

return [GeneralizedCoxeterGroups()] 

 

def additional_structure(self): 

r""" 

Return ``None``. 

 

Indeed, all the structure Coxeter groups have in addition to 

groups (simple reflections, ...) is already defined in the 

super category. 

 

.. SEEALSO:: :meth:`Category.additional_structure` 

 

EXAMPLES:: 

 

sage: CoxeterGroups().additional_structure() 

""" 

return None 

 

Finite = LazyImport('sage.categories.finite_coxeter_groups', 'FiniteCoxeterGroups') 

Algebras = LazyImport('sage.categories.coxeter_group_algebras', 'CoxeterGroupAlgebras') 

 

class ParentMethods: 

@abstract_method 

def coxeter_matrix(self): 

""" 

Return the Coxeter matrix associated to ``self``. 

 

EXAMPLES:: 

 

sage: G = WeylGroup(['A',3]) 

sage: G.coxeter_matrix() 

[1 3 2] 

[3 1 3] 

[2 3 1] 

""" 

 

@cached_method 

def index_set(self): 

""" 

Return the index set of ``self``. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroup([[1,3],[3,1]]) 

sage: W.index_set() 

(1, 2) 

sage: W = CoxeterGroup([[1,3],[3,1]], index_set=['x', 'y']) 

sage: W.index_set() 

('x', 'y') 

sage: W = CoxeterGroup(['H',3]) 

sage: W.index_set() 

(1, 2, 3) 

""" 

return self.coxeter_matrix().index_set() 

 

def coxeter_diagram(self): 

""" 

Return the Coxeter diagram of ``self``. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroup(['H',3], implementation="reflection") 

sage: G = W.coxeter_diagram(); G 

Graph on 3 vertices 

sage: G.edges() 

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

sage: CoxeterGroup(G) is W 

True 

sage: G = Graph([(0, 1, 3), (1, 2, oo)]) 

sage: W = CoxeterGroup(G) 

sage: W.coxeter_diagram() == G 

True 

sage: CoxeterGroup(W.coxeter_diagram()) is W 

True 

""" 

return self.coxeter_matrix().coxeter_graph() 

 

def coxeter_type(self): 

""" 

Return the Coxeter type of ``self``. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroup(['H',3]) 

sage: W.coxeter_type() 

Coxeter type of ['H', 3] 

""" 

return self.coxeter_matrix().coxeter_type() 

 

def __iter__(self): 

r""" 

Returns an iterator over the elements of this Coxeter group. 

 

EXAMPLES:: 

 

sage: D5 = FiniteCoxeterGroups().example(5) 

sage: sorted(list(D5)) # indirect doctest (but see :meth:`._test_enumerated_set_iter_list`) 

[(), 

(1,), 

(1, 2), 

(1, 2, 1), 

(1, 2, 1, 2), 

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

(2,), 

(2, 1), 

(2, 1, 2), 

(2, 1, 2, 1)] 

 

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

sage: g = iter(W) 

sage: next(g) 

[1 0 0] 

[0 1 0] 

[0 0 1] 

sage: next(g) 

[-1 1 1] 

[ 0 1 0] 

[ 0 0 1] 

sage: next(g) 

[ 1 0 0] 

[ 1 -1 1] 

[ 0 0 1] 

""" 

return iter(self.weak_order_ideal(predicate = ConstantFunction(True))) 

 

def _element_constructor_(self, x, **args): 

""" 

Construct an element of ``self`` from ``x``. 

 

EXAMPLES:: 

 

sage: W1 = WeylGroup("G2",prefix="s") 

sage: W2 = CoxeterGroup("G2") 

sage: W3 = CoxeterGroup("G2", implementation="permutation") 

sage: W1(W2.an_element()) 

s1*s2 

sage: W2(W1.an_element()) 

[ 2 -a] 

[ a -1] 

sage: W1(W3.an_element()) 

s1 

sage: s1,s2 = W1.simple_reflections() 

sage: W = CoxeterGroup("A1") 

sage: W(s1*s2) 

Traceback (most recent call last): 

... 

ValueError: ... 

""" 

P = parent(x) 

if P in CoxeterGroups(): 

try: 

return self.from_reduced_word(x.reduced_word()) 

except KeyError: 

# Unable to convert using the reduced word 

# because of an incompatible index 

pass 

return self.element_class(self, x, **args) 

 

def weak_order_ideal(self, predicate, side ="right", category = None): 

""" 

Returns a weak order ideal defined by a predicate 

 

INPUT: 

 

- ``predicate``: a predicate on the elements of ``self`` defining an 

weak order ideal in ``self`` 

- ``side``: "left" or "right" (default: "right") 

 

OUTPUT: an enumerated set 

 

EXAMPLES:: 

 

sage: D6 = FiniteCoxeterGroups().example(5) 

sage: I = D6.weak_order_ideal(predicate = lambda w: w.length() <= 3) 

sage: I.cardinality() 

7 

sage: list(I) 

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

 

We now consider an infinite Coxeter group:: 

 

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

sage: I = W.weak_order_ideal(predicate = lambda w: w.length() <= 2) 

sage: list(iter(I)) 

[ 

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

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

] 

 

Even when the result is finite, some features of 

:class:`FiniteEnumeratedSets` are not available:: 

 

sage: I.cardinality() # todo: not implemented 

5 

sage: list(I) # todo: not implemented 

 

unless this finiteness is explicitly specified:: 

 

sage: I = W.weak_order_ideal(predicate = lambda w: w.length() <= 2, 

....: category = FiniteEnumeratedSets()) 

sage: I.cardinality() 

5 

sage: list(I) 

[ 

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

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

] 

 

.. rubric:: Background 

 

The weak order is returned as a :class:`SearchForest`. 

This is achieved by assigning to each element `u1` of the 

ideal a single ancestor `u=u1 s_i`, where `i` is the 

smallest descent of `u`. 

 

This allows for iterating through the elements in 

roughly Constant Amortized Time and constant memory 

(taking the operations and size of the generated objects 

as constants). 

 

TESTS: 

 

We iterate over each level (i.e., breadth-first-search in the 

search forest), see :trac:`19926`:: 

 

sage: W = CoxeterGroup(['A',2]) 

sage: [x.length() for x in W] 

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

""" 

from sage.combinat.backtrack import SearchForest 

def succ(u): 

for i in u.descents(positive = True, side = side): 

u1 = u.apply_simple_reflection(i, side) 

if i == u1.first_descent(side = side) and predicate(u1): 

yield u1 

return 

from sage.categories.finite_coxeter_groups import FiniteCoxeterGroups 

default_category = FiniteEnumeratedSets() if self in FiniteCoxeterGroups() else EnumeratedSets() 

return SearchForest((self.one(),), succ, algorithm='breadth', 

category = default_category.or_subcategory(category)) 

 

@cached_method 

def coxeter_element(self): 

""" 

Return a Coxeter element. 

 

The result is the product of the simple reflections, in some order. 

 

.. NOTE:: 

 

This implementation is shared with well generated 

complex reflection groups. It would be nicer to put it 

in some joint super category; however, in the current 

state of the art, there is none where it's clear that 

this is the right construction for obtaining a Coxeter 

element. 

 

In this context, this is an element having a regular 

eigenvector (a vector not contained in any reflection 

hyperplane of ``self``). 

 

EXAMPLES:: 

 

sage: CoxeterGroup(['A', 4]).coxeter_element().reduced_word() 

[1, 2, 3, 4] 

sage: CoxeterGroup(['B', 4]).coxeter_element().reduced_word() 

[1, 2, 3, 4] 

sage: CoxeterGroup(['D', 4]).coxeter_element().reduced_word() 

[1, 2, 4, 3] 

sage: CoxeterGroup(['F', 4]).coxeter_element().reduced_word() 

[1, 2, 3, 4] 

sage: CoxeterGroup(['E', 8]).coxeter_element().reduced_word() 

[1, 3, 2, 4, 5, 6, 7, 8] 

sage: CoxeterGroup(['H', 3]).coxeter_element().reduced_word() 

[1, 2, 3] 

 

This method is also used for well generated finite complex 

reflection groups:: 

 

sage: W = ReflectionGroup((1,1,4)) # optional - gap3 

sage: W.coxeter_element().reduced_word() # optional - gap3 

[1, 2, 3] 

 

sage: W = ReflectionGroup((2,1,4)) # optional - gap3 

sage: W.coxeter_element().reduced_word() # optional - gap3 

[1, 2, 3, 4] 

 

sage: W = ReflectionGroup((4,1,4)) # optional - gap3 

sage: W.coxeter_element().reduced_word() # optional - gap3 

[1, 2, 3, 4] 

 

sage: W = ReflectionGroup((4,4,4)) # optional - gap3 

sage: W.coxeter_element().reduced_word() # optional - gap3 

[1, 2, 3, 4] 

 

TESTS:: 

 

sage: WeylGroup(['A', 4]).coxeter_element().reduced_word() 

[1, 2, 3, 4] 

sage: SymmetricGroup(3).coxeter_element() 

(1,3,2) 

""" 

return self.prod(self.simple_reflections()) 

 

@cached_method 

def standard_coxeter_elements(self): 

r""" 

Return all standard Coxeter elements in ``self``. 

 

This is the set of all elements in self obtained from any 

product of the simple reflections in ``self``. 

 

.. NOTE:: 

 

- ``self`` is assumed to be well-generated. 

- This works even beyond real reflection groups, but the conjugacy 

class is not unique and we only obtain one such class. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(4) # optional - gap3 

sage: sorted(W.standard_coxeter_elements()) # optional - gap3 

[(1,7,6,12,23,20)(2,8,17,24,9,5)(3,16,10,19,15,21)(4,14,11,22,18,13), 

(1,10,4,12,21,22)(2,11,19,24,13,3)(5,15,7,17,16,23)(6,18,8,20,14,9)] 

""" 

if not self.is_irreducible() or not self.is_well_generated(): 

raise ValueError("this method is available for irreducible, well-generated complex reflection groups") 

from sage.combinat.permutation import Permutations 

return set(self.from_reduced_word(w) for w in Permutations(self._index_set)) 

 

def grassmannian_elements(self, side="right"): 

""" 

Return the left or right Grassmannian elements of ``self`` 

as an enumerated set. 

 

INPUT: 

 

- ``side`` -- (default: ``"right"``) ``"left"`` or ``"right"`` 

 

EXAMPLES:: 

 

sage: S = CoxeterGroups().example() 

sage: G = S.grassmannian_elements() 

sage: G.cardinality() 

12 

sage: G.list() 

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

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

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

sage: sorted(tuple(w.descents()) for w in G) 

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

sage: G = S.grassmannian_elements(side = "left") 

sage: G.cardinality() 

12 

sage: sorted(tuple(w.descents(side = "left")) for w in G) 

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

""" 

order_side = "left" if side == "right" else "right" 

return self.weak_order_ideal(attrcall("is_grassmannian", side=side), 

side=order_side) 

 

def _test_reduced_word(self, **options): 

""" 

Run sanity checks on :meth:`CoxeterGroups.ElementMethods.reduced_word` and 

:meth:`~sage.categories.complex_reflection_or_generalized_coxeter_groups.ComplexReflectionOrGeneralizedCoxeterGroups.ParentMethods.from_reduced_word` 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: W._test_reduced_word() 

""" 

tester = self._tester(**options) 

s = self.simple_reflections() 

for x in tester.some_elements(): 

red = x.reduced_word() 

tester.assertEqual(self.from_reduced_word(red), x) 

tester.assertEqual(self.prod((s[i] for i in red)), x) 

 

def simple_projection(self, i, side = 'right', length_increasing = True): 

r""" 

INPUT: 

 

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

 

Returns the simple projection `\pi_i` (or `\overline\pi_i` if `length_increasing` is False). 

 

See :meth:`.simple_projections` for the options and for 

the definition of the simple projections. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: W 

The symmetric group on {0, ..., 3} 

sage: s = W.simple_reflections() 

sage: sigma=W.an_element() 

sage: sigma 

(1, 2, 3, 0) 

sage: u0=W.simple_projection(0) 

sage: d0=W.simple_projection(0,length_increasing=False) 

sage: sigma.length() 

3 

sage: pi=sigma*s[0] 

sage: pi.length() 

4 

sage: u0(sigma) 

(2, 1, 3, 0) 

sage: pi 

(2, 1, 3, 0) 

sage: u0(pi) 

(2, 1, 3, 0) 

sage: d0(sigma) 

(1, 2, 3, 0) 

sage: d0(pi) 

(1, 2, 3, 0) 

 

""" 

if not (i in self.index_set() or i == 0): 

raise ValueError("%s is not 0 and not in the Dynkin node set %s"%(i, self.index_set())) 

return lambda x: x.apply_simple_projection(i, side = side, length_increasing = length_increasing) 

 

@cached_method 

def simple_projections(self, side = 'right', length_increasing = True): 

r""" 

Returns the family of simple projections, also known as 0-Hecke or Demazure operators. 

 

INPUT: 

 

- ``self`` - a Coxeter group `W` 

- ``side`` - 'left' or 'right' (default: 'right') 

- ``length_increasing`` - a boolean (default: True) specifying 

whether the operator increases or decreases length 

 

Returns the simple projections of `W`, as a family. 

 

To each simple reflection `s_i` of `W`, corresponds a 

*simple projection* `\pi_i` from `W` to `W` defined by: 

 

`\pi_i(w) = w s_i` if `i` is not a descent of `w` 

`\pi_i(w) = w` otherwise. 

 

The simple projections `(\pi_i)_{i\in I}` move elements 

down the right permutohedron, toward the maximal element. 

They satisfy the same braid relations as the simple reflections, 

but are idempotents `\pi_i^2=\pi` not involutions `s_i^2 = 1`. As such, 

the simple projections generate the `0`-Hecke monoid. 

 

By symmetry, one can also define the projections 

`(\overline\pi_i)_{i\in I}` (when the option ``length_increasing`` is False): 

 

`\overline\pi_i(w) = w s_i` if `i` is a descent of `w` 

`\overline\pi_i(w) = w` otherwise. 

 

as well as the analogues acting on the left (when the option ``side`` is 'left'). 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: W 

The symmetric group on {0, ..., 3} 

sage: s = W.simple_reflections() 

sage: sigma=W.an_element() 

sage: sigma 

(1, 2, 3, 0) 

sage: pi=W.simple_projections() 

sage: pi 

Finite family {0: <function <lambda> at ...>, 1: <function <lambda> at ...>, 2: <function <lambda> ...>} 

sage: pi[1](sigma) 

(1, 3, 2, 0) 

sage: W.simple_projection(1)(sigma) 

(1, 3, 2, 0) 

""" 

from sage.sets.family import Family 

return Family(self.index_set(), lambda i: self.simple_projection(i, side = side, length_increasing = length_increasing)) 

 

def demazure_product(self,Q): 

r""" 

Returns the Demazure product of the list ``Q`` in ``self``. 

 

INPUT: 

 

- ``Q`` is a list of elements from the index set of ``self``. 

 

This returns the Coxeter group element that represents the composition of 0-Hecke or Demazure operators. 

See :meth:`CoxeterGroups.ParentMethods.simple_projections`. 

 

EXAMPLES:: 

 

sage: W = WeylGroup(['A',2]) 

sage: w = W.demazure_product([2,2,1]) 

sage: w.reduced_word() 

[2, 1] 

 

sage: w = W.demazure_product([2,1,2,1,2]) 

sage: w.reduced_word() 

[1, 2, 1] 

 

sage: W = WeylGroup(['B',2]) 

sage: w = W.demazure_product([2,1,2,1,2]) 

sage: w.reduced_word() 

[2, 1, 2, 1] 

 

""" 

return self.one().apply_demazure_product(Q) 

 

def bruhat_interval(self, x, y): 

""" 

Return the list of ``t`` such that ``x <= t <= y``. 

 

EXAMPLES:: 

 

sage: W = WeylGroup("A3", prefix="s") 

sage: [s1,s2,s3]=W.simple_reflections() 

sage: W.bruhat_interval(s2,s1*s3*s2*s1*s3) 

[s1*s2*s3*s2*s1, s2*s3*s2*s1, s3*s1*s2*s1, s1*s2*s3*s1, 

s1*s2*s3*s2, s3*s2*s1, s2*s3*s1, s2*s3*s2, s1*s2*s1, 

s3*s1*s2, s1*s2*s3, s2*s1, s3*s2, s2*s3, s1*s2, s2] 

 

sage: W = WeylGroup(['A',2,1], prefix="s") 

sage: [s0,s1,s2]=W.simple_reflections() 

sage: W.bruhat_interval(1,s0*s1*s2) 

[s0*s1*s2, s1*s2, s0*s2, s0*s1, s2, s1, s0, 1] 

""" 

if x == 1: 

x = self.one() 

if y == 1: 

y = self.one() 

if x == y: 

return [x] 

ret = [] 

if not x.bruhat_le(y): 

return ret 

ret.append([y]) 

while ret[-1] != []: 

nextlayer = [] 

for z in ret[-1]: 

for t in z.bruhat_lower_covers(): 

if t not in nextlayer: 

if x.bruhat_le(t): 

nextlayer.append(t) 

ret.append(nextlayer) 

return flatten(ret) 

 

def bruhat_interval_poset(self, x, y, facade=False): 

r""" 

Return the poset of the Bruhat interval between ``x`` and ``y`` 

in Bruhat order. 

 

EXAMPLES:: 

 

sage: W = WeylGroup("A3", prefix="s") 

sage: s1,s2,s3 = W.simple_reflections() 

sage: W.bruhat_interval_poset(s2, s1*s3*s2*s1*s3) 

Finite poset containing 16 elements 

 

sage: W = WeylGroup(['A',2,1], prefix="s") 

sage: s0,s1,s2 = W.simple_reflections() 

sage: W.bruhat_interval_poset(1, s0*s1*s2) 

Finite poset containing 8 elements 

 

TESTS:: 

 

sage: W.bruhat_interval_poset(s0*s1*s2, s0*s1*s2) 

Finite poset containing 1 elements 

""" 

if x == 1: 

x = self.one() 

if y == 1: 

y = self.one() 

from sage.combinat.posets.posets import Poset 

if x == y: 

return Poset([[x], []]) 

if not x.bruhat_le(y): 

return Poset() 

curlayer = set([y]) 

d = {} 

while curlayer: 

nextlayer = set() 

for z in curlayer: 

for t in z.bruhat_lower_covers(): 

if not x.bruhat_le(t): 

continue 

if t in d: 

d[t].append(z) 

else: 

d[t] = [z] 

if t not in nextlayer: 

nextlayer.add(t) 

curlayer = nextlayer 

 

from sage.graphs.graph import DiGraph 

return Poset(DiGraph(d, format='dict_of_lists', 

data_structure='static_sparse'), 

cover_relations=True, 

facade=facade) 

 

def bruhat_graph(self, x=None, y=None, edge_labels=False): 

r""" 

Return the Bruhat graph as a directed graph, with an edge `u \to v` 

if and only if `u < v` in the Bruhat order, and `u = r \cdot v`. 

 

The Bruhat graph `\Gamma(x,y)`, defined if `x \leq y` in the 

Bruhat order, has as its vertices the Bruhat interval 

`\{ t | x \leq t \leq y \}`, and as its edges are the pairs 

`(u, v)` such that `u = r \cdot v` where `r` is a reflection, 

that is, a conjugate of a simple reflection. 

 

REFERENCES: 

 

Carrell, The Bruhat graph of a Coxeter group, a conjecture of Deodhar, 

and rational smoothness of Schubert varieties. Algebraic groups and 

their generalizations: classical methods (University Park, PA, 1991), 

53--61, Proc. Sympos. Pure Math., 56, Part 1, Amer. Math. Soc., 

Providence, RI, 1994. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroup(['H',3]) 

sage: G = W.bruhat_graph(); G 

Digraph on 120 vertices 

 

sage: W = CoxeterGroup(['A',2,1]) 

sage: s1, s2, s3 = W.simple_reflections() 

sage: W.bruhat_graph(s1, s1*s3*s2*s3) 

Digraph on 6 vertices 

 

sage: W.bruhat_graph(s1, s3*s2*s3) 

Digraph on 0 vertices 

 

sage: W = WeylGroup("A3", prefix="s") 

sage: s1, s2, s3 = W.simple_reflections() 

sage: G = W.bruhat_graph(s1*s3, s1*s2*s3*s2*s1); G 

Digraph on 10 vertices 

 

Check that the graph has the correct number of edges 

(see :trac:`17744`):: 

 

sage: len(G.edges()) 

16 

""" 

if x is None or x == 1: 

x = self.one() 

if y is None: 

if self.is_finite(): 

y = self.long_element() 

else: 

raise TypeError("infinite groups must specify a maximal element") 

elif y == 1: 

y = self.one() 

 

# Sort bruhat_interval in weakly decreasing order of length. 

# We do this so we do not need to check the length in the 

# for loops below. 

g = sorted(self.bruhat_interval(x, y), key=lambda w: -w.length()) 

d = [] 

 

if self.is_finite(): 

ref = self.reflections() 

for i,u in enumerate(g): 

for v in g[:i]: 

w = u * v.inverse() 

if w in ref: 

if edge_labels: 

d.append((u, v, w)) 

else: 

d.append((u, v)) 

else: 

for i,u in enumerate(g): 

for v in g[:i]: 

w = u * v.inverse() 

if w.is_reflection(): 

if edge_labels: 

d.append((u, v, w)) 

else: 

d.append((u, v)) 

 

from sage.graphs.graph import DiGraph 

return DiGraph(d) 

 

def canonical_representation(self): 

r""" 

Return the canonical faithful representation of ``self``. 

 

EXAMPLES:: 

 

sage: W = WeylGroup("A3") 

sage: W.canonical_representation() 

Finite Coxeter group over Integer Ring with Coxeter matrix: 

[1 3 2] 

[3 1 3] 

[2 3 1] 

""" 

from sage.groups.matrix_gps.coxeter_group import CoxeterMatrixGroup 

return CoxeterMatrixGroup(self.coxeter_matrix(), 

index_set=self.index_set()) 

 

def elements_of_length(self, n): 

r""" 

Return all elements of length `n`. 

 

EXAMPLES:: 

 

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

sage: [len(list(A.elements_of_length(i))) for i in [0..5]] 

[1, 3, 6, 9, 12, 15] 

 

sage: W = CoxeterGroup(['H',3]) 

sage: [len(list(W.elements_of_length(i))) for i in range(4)] 

[1, 3, 5, 7] 

 

sage: W = CoxeterGroup(['A',2]) 

sage: [len(list(W.elements_of_length(i))) for i in range(6)] 

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

""" 

I = self.weak_order_ideal(ConstantFunction(True), side='right') 

return I.elements_of_depth_iterator(n) 

 

def random_element_of_length(self, n): 

r""" 

Return a random element of length ``n`` in ``self``. 

 

Starts at the identity, then chooses an upper cover at random. 

 

Not very uniform: actually constructs a uniformly random 

reduced word of length `n`. Thus we most likely get 

elements with lots of reduced words! 

 

EXAMPLES:: 

 

sage: A = AffinePermutationGroup(['A', 7, 1]) 

sage: p = A.random_element_of_length(10) 

sage: p in A 

True 

sage: p.length() == 10 

True 

 

sage: W = CoxeterGroup(['A', 4]) 

sage: p = W.random_element_of_length(5) 

sage: p in W 

True 

sage: p.length() == 5 

True 

""" 

from sage.misc.prandom import randint 

x = self.one() 

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

antiD = x.descents(positive=True) 

rnd = randint(0, len(antiD) - 1) 

x = x.apply_simple_reflection_right(antiD[rnd]) 

return x 

 

# TODO: Groups() should have inverse() call __invert__ 

# With strong doc stating that this is just a convenience for the user 

# and links to ~ / __invert__ 

 

# parabolic_subgroup 

 

def _test_simple_projections(self, **options): 

""" 

Runs sanity checks on :meth:`.simple_projections` 

and :meth:`CoxeterGroups.ElementMethods.apply_simple_projection` 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: W._test_simple_projections() 

""" 

tester = self._tester(**options) 

for side in ['left', 'right']: 

pi = self.simple_projections(side = side) 

opi = self.simple_projections(side = side, length_increasing = False) 

for i in self.index_set(): 

for w in tester.some_elements(): 

tester.assertTrue( pi[i](w) == w.apply_simple_projection(i, side = side)) 

tester.assertTrue( pi[i](w) == w.apply_simple_projection(i, side = side, length_increasing = True )) 

tester.assertTrue(opi[i](w) == w.apply_simple_projection(i, side = side, length_increasing = False)) 

tester.assertTrue( pi[i](w).has_descent(i, side = side)) 

tester.assertTrue(not opi[i](w).has_descent(i, side = side)) 

tester.assertEqual(set([pi[i](w), opi[i](w)]), 

set([w, w.apply_simple_reflection(i, side = side)])) 

 

def _test_has_descent(self, **options): 

""" 

Runs sanity checks on the method 

:meth:`CoxeterGroups.ElementMethods.has_descent` of the 

elements of self. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: W._test_has_descent() 

""" 

tester = self._tester(**options) 

s = self.simple_reflections() 

for i in self.index_set(): 

tester.assertTrue(not self.one().has_descent(i)) 

tester.assertTrue(not self.one().has_descent(i, side = 'left')) 

tester.assertTrue(not self.one().has_descent(i, side = 'right')) 

tester.assertTrue(self.one().has_descent(i, positive = True)) 

tester.assertTrue(self.one().has_descent(i, positive = True, side = 'left')) 

tester.assertTrue(self.one().has_descent(i, positive = True, side = 'right')) 

for j in self.index_set(): 

tester.assertEqual(s[i].has_descent(j, side = 'left' ), i==j) 

tester.assertEqual(s[i].has_descent(j, side = 'right'), i==j) 

tester.assertEqual(s[i].has_descent(j ), i==j) 

tester.assertEqual(s[i].has_descent(j, positive = True, side = 'left' ), i!=j) 

tester.assertEqual(s[i].has_descent(j, positive = True, side = 'right'), i!=j) 

tester.assertEqual(s[i].has_descent(j, positive = True, ), i!=j) 

if i == j: 

continue 

u = s[i] * s[j] 

v = s[j] * s[i] 

tester.assertTrue((s[i]*s[j]).has_descent(i, side = 'left' )) 

tester.assertTrue((s[i]*s[j]).has_descent(j, side = 'right')) 

tester.assertEqual((s[i]*s[j]).has_descent(j, side = 'left' ), u == v) 

tester.assertEqual((s[i]*s[j]).has_descent(i, side = 'right'), u == v) 

 

def _test_descents(self, **options): 

""" 

Run sanity checks on the method 

:meth:`CoxeterGroups.ElementMethods.descents` of the 

elements of ``self``. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: W._test_descents() 

""" 

tester = self._tester(**options) 

s = self.simple_reflections() 

tester.assertEqual(len(self.one().descents(side='right')), 0) 

tester.assertEqual(len(self.one().descents(side='left')), 0) 

for i in self.index_set(): 

si = s[i] 

tester.assertEqual([i], si.descents(side='left')) 

tester.assertEqual([i], si.descents(side='right')) 

tester.assertNotIn(i, si.descents(positive=True, side='left')) 

tester.assertNotIn(i, si.descents(positive=True, side='right')) 

 

class ElementMethods: 

def has_descent(self, i, side = 'right', positive=False): 

""" 

Returns whether i is a (left/right) descent of self. 

 

See :meth:`.descents` for a description of the options. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: s = W.simple_reflections() 

sage: w = s[0] * s[1] * s[2] 

sage: w.has_descent(2) 

True 

sage: [ w.has_descent(i) for i in [0,1,2] ] 

[False, False, True] 

sage: [ w.has_descent(i, side = 'left') for i in [0,1,2] ] 

[True, False, False] 

sage: [ w.has_descent(i, positive = True) for i in [0,1,2] ] 

[True, True, False] 

 

This default implementation delegates the work to 

:meth:`.has_left_descent` and :meth:`.has_right_descent`. 

""" 

if not isinstance(positive, bool): 

raise TypeError("%s is not a boolean"%(bool)) 

if side == 'right': 

return self.has_right_descent(i) != positive 

if side != 'left': 

raise ValueError("%s is neither 'right' nor 'left'"%(side)) 

return self.has_left_descent(i) != positive 

 

# @abstract_method(optional = True) 

def has_right_descent(self, i): 

""" 

Returns whether ``i`` is a right descent of self. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example(); W 

The symmetric group on {0, ..., 3} 

sage: w = W.an_element(); w 

(1, 2, 3, 0) 

sage: w.has_right_descent(0) 

False 

sage: w.has_right_descent(1) 

False 

sage: w.has_right_descent(2) 

True 

""" 

return (~self).has_left_descent(i) 

 

def has_left_descent(self, i): 

""" 

Returns whether `i` is a left descent of self. 

 

This default implementation uses that a left descent of 

`w` is a right descent of `w^{-1}`. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example(); W 

The symmetric group on {0, ..., 3} 

sage: w = W.an_element(); w 

(1, 2, 3, 0) 

sage: w.has_left_descent(0) 

True 

sage: w.has_left_descent(1) 

False 

sage: w.has_left_descent(2) 

False 

 

TESTS:: 

 

sage: w.has_left_descent.__module__ 

'sage.categories.coxeter_groups' 

""" 

return (~self).has_right_descent(i) 

 

def first_descent(self, side = 'right', index_set=None, positive=False): 

""" 

Returns the first left (resp. right) descent of self, as 

ane element of ``index_set``, or ``None`` if there is none. 

 

See :meth:`.descents` for a description of the options. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: s = W.simple_reflections() 

sage: w = s[2]*s[0] 

sage: w.first_descent() 

0 

sage: w = s[0]*s[2] 

sage: w.first_descent() 

0 

sage: w = s[0]*s[1] 

sage: w.first_descent() 

1 

""" 

if index_set is None: 

index_set = self.parent().index_set() 

for i in index_set: 

if self.has_descent(i, side = side, positive = positive): 

return i 

return None 

 

def descents(self, side = 'right', index_set=None, positive=False): 

""" 

INPUT: 

 

- ``index_set`` - a subset (as a list or iterable) of the nodes of the Dynkin diagram; 

(default: all of them) 

- ``side`` - 'left' or 'right' (default: 'right') 

- ``positive`` - a boolean (default: ``False``) 

 

Returns the descents of self, as a list of elements of the 

index_set. 

 

The ``index_set`` option can be used to restrict to the 

parabolic subgroup indexed by ``index_set``. 

 

If positive is ``True``, then returns the non-descents 

instead 

 

TODO: find a better name for ``positive``: complement? non_descent? 

 

Caveat: the return type may change to some other iterable 

(tuple, ...) in the future. Please use keyword arguments 

also, as the order of the arguments may change as well. 

 

EXAMPLES:: 

 

sage: W=CoxeterGroups().example() 

sage: s=W.simple_reflections() 

sage: w=s[0]*s[1] 

sage: w.descents() 

[1] 

sage: w=s[0]*s[2] 

sage: w.descents() 

[0, 2] 

 

TODO: side, index_set, positive 

""" 

if index_set is None: 

index_set=self.parent().index_set() 

return [ i for i in index_set if self.has_descent(i, side = side, positive = positive) ] 

 

def is_grassmannian(self, side = "right"): 

""" 

INPUT: 

 

- ``side`` - "left" or "right" (default: "right") 

 

Tests whether ``self`` is Grassmannian, i.e. it has at 

most one descent on the right (resp. on the left). 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example(); W 

The symmetric group on {0, ..., 3} 

sage: s = W.simple_reflections() 

sage: W.one().is_grassmannian() 

True 

sage: s[1].is_grassmannian() 

True 

sage: (s[1]*s[2]).is_grassmannian() 

True 

sage: (s[0]*s[1]).is_grassmannian() 

True 

sage: (s[1]*s[2]*s[1]).is_grassmannian() 

False 

 

sage: (s[0]*s[2]*s[1]).is_grassmannian(side = "left") 

False 

sage: (s[0]*s[2]*s[1]).is_grassmannian(side = "right") 

True 

sage: (s[0]*s[2]*s[1]).is_grassmannian() 

True 

""" 

return len(self.descents(side = side)) <= 1 

 

def reduced_word_reverse_iterator(self): 

""" 

Return a reverse iterator on a reduced word for ``self``. 

 

EXAMPLES:: 

 

sage: W=CoxeterGroups().example() 

sage: s = W.simple_reflections() 

sage: sigma = s[0]*s[1]*s[2] 

sage: rI=sigma.reduced_word_reverse_iterator() 

sage: [i for i in rI] 

[2, 1, 0] 

sage: s[0]*s[1]*s[2]==sigma 

True 

sage: sigma.length() 

3 

 

.. SEEALSO:: 

 

:meth:`.reduced_word` 

 

Default implementation: recursively remove the first right 

descent until the identity is reached (see :meth:`.first_descent` and 

:meth:`~sage.categories.complex_reflection_or_generalized_coxeter_groups.ComplexReflectionOrGeneralizedCoxeterGroups.ElementMethods.apply_simple_reflection`). 

""" 

while True: 

i = self.first_descent() 

if i is None: 

return 

self = self.apply_simple_reflection(i, 'right') 

yield i 

 

def reduced_word(self): 

r""" 

Return a reduced word for ``self``. 

 

This is a word `[i_1,i_2,\ldots,i_k]` of minimal length 

such that 

`s_{i_1} s_{i_2} \cdots s_{i_k} = \operatorname{self}`, 

where the `s_i` are the simple reflections. 

 

EXAMPLES:: 

 

sage: W=CoxeterGroups().example() 

sage: s=W.simple_reflections() 

sage: w=s[0]*s[1]*s[2] 

sage: w.reduced_word() 

[0, 1, 2] 

sage: w=s[0]*s[2] 

sage: w.reduced_word() 

[2, 0] 

 

.. SEEALSO:: 

 

- :meth:`.reduced_words`, :meth:`.reduced_word_reverse_iterator`, 

- :meth:`length`, :meth:`reduced_word_graph` 

""" 

result = list(self.reduced_word_reverse_iterator()) 

return list(reversed(result)) 

 

#def lex_min_reduced_word(w): 

# return list(reversed((w.inverse()).reduced_word())) 

 

def support(self): 

r""" 

Return the support of ``self``, that is the simple reflections that 

appear in the reduced expressions of ``self``. 

 

OUTPUT: 

 

The support of ``self`` as a set of integers 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: w = W.from_reduced_word([1,2,1]) 

sage: w.support() 

{1, 2} 

""" 

return set(self.reduced_word()) 

 

def has_full_support(self): 

r""" 

Return whether ``self`` has full support. 

 

An element is said to have full support if its support contains 

all simple reflections. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: w = W.from_reduced_word([1,2,1]) 

sage: w.has_full_support() 

False 

sage: w = W.from_reduced_word([1,2,1,0,1]) 

sage: w.has_full_support() 

True 

""" 

return self.support() == set(self.parent().index_set()) 

 

def reduced_words(self): 

r""" 

Return all reduced words for ``self``. 

 

See :meth:`reduced_word` for the definition of a reduced 

word. 

 

EXAMPLES:: 

 

sage: W=CoxeterGroups().example() 

sage: s=W.simple_reflections() 

sage: w=s[0]*s[2] 

sage: w.reduced_words() 

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

sage: W=WeylGroup(['E',6]) 

sage: w=W.from_reduced_word([2,3,4,2]) 

sage: w.reduced_words() 

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

 

TODO: the result should be full featured finite enumerated 

set (e.g. counting can be done much faster than iterating). 

 

.. SEEALSO:: 

 

:meth:`.reduced_word`, :meth:`.reduced_word_reverse_iterator`, 

:meth:`length`, :meth:`reduced_word_graph` 

""" 

descents = self.descents() 

if descents == []: 

return [[]] 

else: 

return [ r + [i] 

for i in self.descents() 

for r in (self.apply_simple_reflection(i)).reduced_words() 

] 

 

def reduced_word_graph(self): 

r""" 

Return the reduced word graph of ``self``. 

 

The reduced word graph of an element `w` in a Coxeter group 

is the graph whose vertices are the reduced words for `w` 

(see :meth:`reduced_word` for a definition of this term), 

and which has an `m`-colored edge between two reduced words 

`x` and `y` whenever `x` and `y` differ by exactly one 

length-`m` braid move (with `m \geq 2`). 

 

This graph is always connected (a theorem due to Tits) and 

has no multiple edges. 

 

EXAMPLES:: 

 

sage: W = WeylGroup(['A',3], prefix='s') 

sage: w0 = W.long_element() 

sage: G = w0.reduced_word_graph() 

sage: G.num_verts() 

16 

sage: len(w0.reduced_words()) 

16 

sage: G.num_edges() 

18 

sage: len([e for e in G.edges() if e[2] == 2]) 

10 

sage: len([e for e in G.edges() if e[2] == 3]) 

8 

 

TESTS:: 

 

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

sage: pp = WeylGroup(['A',3]).from_reduced_word(p.reduced_word()) 

sage: pp.reduced_word_graph() 

Graph on 3 vertices 

 

sage: w1 = W.one() 

sage: G = w1.reduced_word_graph() 

sage: G.num_verts() 

1 

sage: G.num_edges() 

0 

 

.. SEEALSO:: 

 

:meth:`.reduced_words`, :meth:`.reduced_word_reverse_iterator`, 

:meth:`length`, :meth:`reduced_word` 

""" 

R = self.reduced_words() 

from sage.graphs.graph import Graph 

# Special case for when the graph does not contain any edges 

if len(R) == 1: 

return Graph({tuple(R[0]): []}, immutable=True) 

 

P = self.parent() 

edges = [] 

for i,x in enumerate(R): 

x = tuple(x) 

for y in R[i:]: 

y = tuple(y) 

# Check that the reduced expressions differ by only 

# a single braid move 

i = 0 

while i < len(x) and x[i] == y[i]: 

i += 1 

if i == len(x): 

continue 

a, b = x[i], y[i] 

m = P.coxeter_matrix()[a,b] 

subword = [a,b] * (m // 2) 

subword2 = [b,a] * (m // 2) 

if m % 2 != 0: 

subword.append(a) 

subword2.append(b) 

if (x[i:i+m] != tuple(subword) 

or y[i:i+m] != tuple(subword2) 

or x[i+m:] != y[i+m:]): 

continue 

edges.append([x, y, m]) 

G = Graph(edges, immutable=True, format="list_of_edges") 

colors = {2: 'blue', 3: 'red', 4: 'green'} 

G.set_latex_options(edge_labels=True, color_by_label=lambda x: colors[x]) 

return G 

 

def length(self): 

r""" 

Return the length of ``self``. 

 

This is the minimal length of 

a product of simple reflections giving ``self``. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: s1 = W.simple_reflection(1) 

sage: s2 = W.simple_reflection(2) 

sage: s1.length() 

1 

sage: (s1*s2).length() 

2 

sage: W = CoxeterGroups().example() 

sage: s = W.simple_reflections() 

sage: w = s[0]*s[1]*s[0] 

sage: w.length() 

3 

sage: W = CoxeterGroups().example() 

sage: sum((x^w.length()) for w in W) - expand(prod(sum(x^i for i in range(j+1)) for j in range(4))) # This is scandalously slow!!! 

0 

 

.. SEEALSO:: 

 

:meth:`.reduced_word` 

 

.. TODO:: 

 

Should use reduced_word_iterator (or reverse_iterator) 

""" 

return len(self.reduced_word()) 

 

def reflection_length(self): 

""" 

Return the reflection length of ``self``. 

 

The reflection length is the length of the shortest expression 

of the element as a product of reflections. 

 

.. SEEALSO:: 

 

:meth:`absolute_length` 

 

EXAMPLES:: 

 

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

sage: s = W.simple_reflections() 

sage: (s[1]*s[2]*s[3]).reflection_length() 

3 

 

sage: W = SymmetricGroup(4) 

sage: s = W.simple_reflections() 

sage: (s[3]*s[2]*s[3]).reflection_length() 

1 

 

""" 

return self.absolute_length() 

 

def absolute_length(self): 

""" 

Return the absolute length of ``self``. 

 

The absolute length is the length of the shortest expression 

of the element as a product of reflections. 

 

For permutations in the symmetric groups, the absolute 

length is the size minus the number of its disjoint 

cycles. 

 

.. SEEALSO:: 

 

:meth:`absolute_le` 

 

EXAMPLES:: 

 

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

sage: s = W.simple_reflections() 

sage: (s[1]*s[2]*s[3]).absolute_length() 

3 

 

sage: W = SymmetricGroup(4) 

sage: s = W.simple_reflections() 

sage: (s[3]*s[2]*s[1]).absolute_length() 

3 

""" 

M = self.canonical_matrix() 

return (M - 1).image().dimension() 

 

def absolute_le(self, other): 

r""" 

Return whether ``self`` is smaller than ``other`` in the absolute 

order. 

 

A general reflection is an element of the form `w s_i w^{-1}`, 

where `s_i` is a simple reflection. The absolute order is defined 

analogously to the weak order but using general reflections rather 

than just simple reflections. 

 

This partial order can be used to define noncrossing partitions 

associated with this Coxeter group. 

 

.. SEEALSO:: 

 

:meth:`absolute_length` 

 

EXAMPLES:: 

 

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

sage: s = W.simple_reflections() 

sage: w0 = s[1] 

sage: w1 = s[1]*s[2]*s[3] 

sage: w0.absolute_le(w1) 

True 

sage: w1.absolute_le(w0) 

False 

sage: w1.absolute_le(w1) 

True 

""" 

if self == other: 

return True 

if self.absolute_length() >= other.absolute_length(): 

return False 

return self.absolute_length() + (self.inverse() * other).absolute_length() == other.absolute_length() 

 

def absolute_covers(self): 

r""" 

Return the list of covers of ``self`` in absolute order. 

 

.. SEEALSO:: 

 

:meth:`absolute_length` 

 

EXAMPLES:: 

 

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

sage: s = W.simple_reflections() 

sage: w0 = s[1] 

sage: w1 = s[1]*s[2]*s[3] 

sage: w0.absolute_covers() 

[ 

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

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

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

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

] 

""" 

W = self.parent() 

return [self * t for t in W.reflections() 

if self.absolute_length() < (self * t).absolute_length()] 

 

def canonical_matrix(self): 

r""" 

Return the matrix of ``self`` in the canonical faithful 

representation. 

 

This is an `n`-dimension real faithful essential representation, 

where `n` is the number of generators of the Coxeter group. 

Note that this is not always the most natural matrix 

representation, for instance in type `A_n`. 

 

EXAMPLES:: 

 

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

sage: s = W.simple_reflections() 

sage: (s[1]*s[2]*s[3]).canonical_matrix() 

[ 0 0 -1] 

[ 1 0 -1] 

[ 0 1 -1] 

""" 

G = self.parent().canonical_representation() 

return G.prod(G.simple_reflection(i) for i in self.reduced_word()).matrix() 

 

def coset_representative(self, index_set, side = 'right'): 

r""" 

INPUT: 

 

- ``index_set`` - a subset (or iterable) of the nodes of the Dynkin diagram 

- ``side`` - 'left' or 'right' 

 

Returns the unique shortest element of the Coxeter group 

$W$ which is in the same left (resp. right) coset as 

``self``, with respect to the parabolic subgroup $W_I$. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example(5) 

sage: s = W.simple_reflections() 

sage: w = s[2]*s[1]*s[3] 

sage: w.coset_representative([]).reduced_word() 

[2, 3, 1] 

sage: w.coset_representative([1]).reduced_word() 

[2, 3] 

sage: w.coset_representative([1,2]).reduced_word() 

[2, 3] 

sage: w.coset_representative([1,3] ).reduced_word() 

[2] 

sage: w.coset_representative([2,3] ).reduced_word() 

[2, 1] 

sage: w.coset_representative([1,2,3] ).reduced_word() 

[] 

sage: w.coset_representative([], side = 'left').reduced_word() 

[2, 3, 1] 

sage: w.coset_representative([1], side = 'left').reduced_word() 

[2, 3, 1] 

sage: w.coset_representative([1,2], side = 'left').reduced_word() 

[3] 

sage: w.coset_representative([1,3], side = 'left').reduced_word() 

[2, 3, 1] 

sage: w.coset_representative([2,3], side = 'left').reduced_word() 

[1] 

sage: w.coset_representative([1,2,3], side = 'left').reduced_word() 

[] 

 

""" 

while True: 

i = self.first_descent(side = side, index_set = index_set) 

if i is None: 

return self 

self = self.apply_simple_reflection(i, side = side) 

 

def apply_simple_projection(self, i, side = 'right', length_increasing = True): 

r""" 

INPUT: 

 

- ``i`` - an element of the index set of the Coxeter group 

- ``side`` - 'left' or 'right' (default: 'right') 

- ``length_increasing`` - a boolean (default: True) specifying 

the direction of the projection 

 

Returns the result of the application of the simple 

projection `\pi_i` (resp. `\overline\pi_i`) on ``self``. 

 

See :meth:`CoxeterGroups.ParentMethods.simple_projections` 

for the definition of the simple projections. 

 

EXAMPLES:: 

 

sage: W=CoxeterGroups().example() 

sage: w=W.an_element() 

sage: w 

(1, 2, 3, 0) 

sage: w.apply_simple_projection(2) 

(1, 2, 3, 0) 

sage: w.apply_simple_projection(2, length_increasing=False) 

(1, 2, 0, 3) 

sage: W = WeylGroup(['C',4],prefix="s") 

sage: v = W.from_reduced_word([1,2,3,4,3,1]) 

sage: v 

s1*s2*s3*s4*s3*s1 

sage: v.apply_simple_projection(2) 

s1*s2*s3*s4*s3*s1*s2 

sage: v.apply_simple_projection(2, side='left') 

s1*s2*s3*s4*s3*s1 

sage: v.apply_simple_projection(1, length_increasing = False) 

s1*s2*s3*s4*s3 

 

""" 

if self.has_descent(i, side = side, positive = length_increasing): 

return self.apply_simple_reflection(i, side=side) 

return self 

 

def binary_factorizations(self, predicate = ConstantFunction(True)): 

""" 

Returns the set of all the factorizations `self = u v` such 

that `l(self) = l(u) + l(v)`. 

 

Iterating through this set is Constant Amortized Time 

(counting arithmetic operations in the Coxeter group as 

constant time) complexity, and memory linear in the length 

of `self`. 

 

One can pass as optional argument a predicate p such that 

`p(u)` implies `p(u')` for any `u` left factor of `self` 

and `u'` left factor of `u`. Then this returns only the 

factorizations `self = uv` such `p(u)` holds. 

 

EXAMPLES: 

 

We construct the set of all factorizations of the maximal 

element of the group:: 

 

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

sage: s = W.simple_reflections() 

sage: w0 = W.from_reduced_word([1,2,3,1,2,1]) 

sage: w0.binary_factorizations().cardinality() 

24 

 

The same number of factorizations, by bounded length:: 

 

sage: [w0.binary_factorizations(lambda u: u.length() <= l).cardinality() for l in [-1,0,1,2,3,4,5,6]] 

[0, 1, 4, 9, 15, 20, 23, 24] 

 

The number of factorizations of the elements just below 

the maximal element:: 

 

sage: [(s[i]*w0).binary_factorizations().cardinality() for i in [1,2,3]] 

[12, 12, 12] 

sage: w0.binary_factorizations(lambda u: False).cardinality() 

0 

 

TESTS:: 

 

sage: w0.binary_factorizations().category() 

Category of finite enumerated sets 

""" 

from sage.combinat.backtrack import SearchForest 

W = self.parent() 

if not predicate(W.one()): 

from sage.sets.finite_enumerated_set import FiniteEnumeratedSet 

return FiniteEnumeratedSet([]) 

s = W.simple_reflections() 

def succ(u_v): 

(u, v) = u_v 

for i in v.descents(side = 'left'): 

u1 = u * s[i] 

if i == u1.first_descent() and predicate(u1): 

yield (u1, s[i]*v) 

return SearchForest(((W.one(), self),), succ, category = FiniteEnumeratedSets()) 

 

@cached_in_parent_method 

def bruhat_lower_covers(self): 

""" 

Returns all elements that ``self`` covers in (strong) Bruhat order. 

 

If ``w = self`` has a descent at `i`, then the elements that 

`w` covers are exactly `\{ws_i, u_1s_i, u_2s_i,..., u_js_i\}`, 

where the `u_k` are elements that `ws_i` covers that also 

do not have a descent at `i`. 

 

EXAMPLES:: 

 

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

sage: w = W.from_reduced_word([3,2,3]) 

sage: print([v.reduced_word() for v in w.bruhat_lower_covers()]) 

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

 

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

sage: print([v.reduced_word() for v in W.simple_reflection(1).bruhat_lower_covers()]) 

[[]] 

sage: print([v.reduced_word() for v in W.one().bruhat_lower_covers()]) 

[] 

sage: W = WeylGroup(["B",4,1]) 

sage: w = W.from_reduced_word([0,2]) 

sage: print([v.reduced_word() for v in w.bruhat_lower_covers()]) 

[[2], [0]] 

 

We now show how to construct the Bruhat poset:: 

 

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

sage: covers = tuple([u, v] for v in W for u in v.bruhat_lower_covers() ) 

sage: P = Poset((W, covers), cover_relations = True) 

sage: P.show() 

 

Alternatively, one can just use:: 

 

sage: P = W.bruhat_poset() 

 

The algorithm is taken from Stembridge's 'coxeter/weyl' package for Maple. 

""" 

desc = self.first_descent() 

if desc is not None: 

ww = self.apply_simple_reflection(desc) 

return [u.apply_simple_reflection(desc) for u in ww.bruhat_lower_covers() if not u.has_descent(desc)] + [ww] 

else: 

return [] 

 

@cached_in_parent_method 

def bruhat_upper_covers(self): 

r""" 

Returns all elements that cover ``self`` in (strong) Bruhat order. 

 

The algorithm works recursively, using the 'inverse' of the method described for 

lower covers :meth:`bruhat_lower_covers`. Namely, it runs through all `i` in the 

index set. Let `w` equal ``self``. If `w` has no right descent `i`, then `w s_i` is a cover; 

if `w` has a decent at `i`, then `u_j s_i` is a cover of `w` where `u_j` is a cover 

of `w s_i`. 

 

EXAMPLES:: 

 

sage: W = WeylGroup(['A',3,1], prefix="s") 

sage: w = W.from_reduced_word([1,2,1]) 

sage: w.bruhat_upper_covers() 

[s1*s2*s1*s0, s1*s2*s0*s1, s0*s1*s2*s1, s3*s1*s2*s1, s2*s3*s1*s2, s1*s2*s3*s1] 

 

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

sage: w = W.long_element() 

sage: w.bruhat_upper_covers() 

[] 

 

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

sage: w = W.from_reduced_word([1,2,1]) 

sage: S = [v for v in W if w in v.bruhat_lower_covers()] 

sage: C = w.bruhat_upper_covers() 

sage: set(S) == set(C) 

True 

""" 

Covers = [] 

for i in self.parent().index_set(): 

if i in self.descents(): 

Covers += [ x.apply_simple_reflection(i) for x in self.apply_simple_reflection(i).bruhat_upper_covers() 

if i not in x.descents() ] 

else: 

Covers += [ self.apply_simple_reflection(i) ] 

return uniq(Covers) 

 

@cached_in_parent_method 

def bruhat_lower_covers_reflections(self): 

r""" 

Returns all 2-tuples of lower_covers and reflections (``v``, ``r``) where ``v`` is covered by ``self`` and ``r`` is the reflection such that ``self`` = ``v`` ``r``. 

 

ALGORITHM: 

 

See :meth:`.bruhat_lower_covers` 

 

EXAMPLES:: 

 

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

sage: w = W.from_reduced_word([3,1,2,1]) 

sage: w.bruhat_lower_covers_reflections() 

[(s1*s2*s1, s1*s2*s3*s2*s1), (s3*s2*s1, s2), (s3*s1*s2, s1)] 

 

""" 

i = self.first_descent() 

if i is None: 

return [] 

wi = self.apply_simple_reflection(i) 

return [(u.apply_simple_reflection(i),r.apply_conjugation_by_simple_reflection(i)) for u,r in wi.bruhat_lower_covers_reflections() if not u.has_descent(i)] + [(wi, self.parent().simple_reflection(i))] 

 

def lower_cover_reflections(self, side = 'right'): 

r""" 

Returns the reflections ``t`` such that ``self`` covers ``self`` ``t``. 

 

If ``side`` is 'left', ``self`` covers ``t`` ``self``. 

 

EXAMPLES:: 

 

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

sage: w = W.from_reduced_word([3,1,2,1]) 

sage: w.lower_cover_reflections() 

[s1*s2*s3*s2*s1, s2, s1] 

sage: w.lower_cover_reflections(side = 'left') 

[s2*s3*s2, s3, s1] 

 

""" 

 

if side == 'left': 

self = self.inverse() 

return [x[1] for x in self.bruhat_lower_covers_reflections()] 

 

@cached_in_parent_method 

def bruhat_upper_covers_reflections(self): 

r""" 

Returns all 2-tuples of covers and reflections (``v``, ``r``) where ``v`` covers ``self`` and ``r`` is the reflection such that ``self`` = ``v`` ``r``. 

 

ALGORITHM: 

 

See :meth:`.bruhat_upper_covers` 

 

EXAMPLES:: 

 

sage: W = WeylGroup(['A',4], prefix="s") 

sage: w = W.from_reduced_word([3,1,2,1]) 

sage: w.bruhat_upper_covers_reflections() 

[(s1*s2*s3*s2*s1, s3), (s2*s3*s1*s2*s1, s2*s3*s2), (s3*s4*s1*s2*s1, s4), (s4*s3*s1*s2*s1, s1*s2*s3*s4*s3*s2*s1)] 

 

""" 

 

Covers = [] 

for i in self.parent().index_set(): 

wi = self.apply_simple_reflection(i) 

if i in self.descents(): 

Covers += [(u.apply_simple_reflection(i), r.apply_conjugation_by_simple_reflection(i)) for u,r in wi.bruhat_upper_covers_reflections() if i not in u.descents()] 

else: 

Covers += [(wi,self.parent().simple_reflection(i))] 

return uniq(Covers) 

 

def cover_reflections(self, side = 'right'): 

r""" 

Returns the set of reflections ``t`` such that ``self`` ``t`` covers ``self``. 

 

If ``side`` is 'left', ``t`` ``self`` covers ``self``. 

 

EXAMPLES:: 

 

sage: W = WeylGroup(['A',4], prefix="s") 

sage: w = W.from_reduced_word([3,1,2,1]) 

sage: w.cover_reflections() 

[s3, s2*s3*s2, s4, s1*s2*s3*s4*s3*s2*s1] 

sage: w.cover_reflections(side = 'left') 

[s4, s2, s1*s2*s1, s3*s4*s3] 

 

""" 

 

if side == 'left': 

self = self.inverse() 

return [x[1] for x in self.bruhat_upper_covers_reflections()] 

 

@cached_in_parent_method 

def bruhat_le(self, other): 

""" 

Bruhat comparison 

 

INPUT: 

 

- other -- an element of the same Coxeter group 

 

OUTPUT: a boolean 

 

Returns whether ``self`` <= ``other`` in the Bruhat order. 

 

EXAMPLES:: 

 

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

sage: u = W.from_reduced_word([1,2,1]) 

sage: v = W.from_reduced_word([1,2,3,2,1]) 

sage: u.bruhat_le(u) 

True 

sage: u.bruhat_le(v) 

True 

sage: v.bruhat_le(u) 

False 

sage: v.bruhat_le(v) 

True 

sage: s = W.simple_reflections() 

sage: s[1].bruhat_le(W.one()) 

False 

 

The implementation uses the equivalent condition that any 

reduced word for ``other`` contains a reduced word for 

``self`` as subword. See Stembridge, A short derivation of 

the Möbius function for the Bruhat order. J. Algebraic 

Combin. 25 (2007), no. 2, 141--148, Proposition 1.1. 

 

Complexity: `O(l * c)`, where `l` is the minimum of the 

lengths of `u` and of `v`, and `c` is the cost of the low 

level methods :meth:`first_descent`, :meth:`has_descent`, 

:meth:`~sage.categories.complex_reflection_or_generalized_coxeter_groups.ComplexReflectionOrGeneralizedCoxeterGroups.ElementMethods.apply_simple_reflection`), 

etc. Those are typically `O(n)`, where `n` is the rank of the 

Coxeter group. 

 

TESTS: 

 

We now run consistency tests with permutations and 

:meth:`bruhat_lower_covers`:: 

 

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

sage: P4 = Permutations(4) 

sage: def P4toW(w): return W.from_reduced_word(w.reduced_word()) 

sage: for u in P4: 

....: for v in P4: 

....: assert u.bruhat_lequal(v) == P4toW(u).bruhat_le(P4toW(v)) 

 

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

sage: P = W.bruhat_poset() # This is built from bruhat_lower_covers 

sage: Q = Poset((W, attrcall("bruhat_le"))) # long time (10s) 

sage: all( u.bruhat_le(v) == P.is_lequal(u,v) for u in W for v in W ) # long time (7s) 

True 

sage: all( P.is_lequal(u,v) == Q.is_lequal(u,v) for u in W for v in W) # long time (9s) 

True 

""" 

if not have_same_parent(self, other): 

raise TypeError("%s and %s do not have the same parent"%(self, other)) 

# could first compare the length, when that information is cheap 

desc = other.first_descent() 

if desc is not None: 

return self.apply_simple_projection(desc, length_increasing = False).bruhat_le(other.apply_simple_reflection(desc)) 

else: 

return self == other 

 

def weak_le(self, other, side = 'right'): 

""" 

comparison in weak order 

 

INPUT: 

 

- other -- an element of the same Coxeter group 

- side -- 'left' or 'right' (default: 'right') 

 

OUTPUT: a boolean 

 

Returns whether ``self`` <= ``other`` in left 

(resp. right) weak order, that is if 'v' can be obtained 

from 'v' by length increasing multiplication by simple 

reflections on the left (resp. right). 

 

EXAMPLES:: 

 

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

sage: u = W.from_reduced_word([1,2]) 

sage: v = W.from_reduced_word([1,2,3,2]) 

sage: u.weak_le(u) 

True 

sage: u.weak_le(v) 

True 

sage: v.weak_le(u) 

False 

sage: v.weak_le(v) 

True 

 

Comparison for left weak order is achieved with the option ``side``:: 

 

sage: u.weak_le(v, side = 'left') 

False 

 

The implementation uses the equivalent condition that any 

reduced word for `u` is a right (resp. left) prefix of 

some reduced word for `v`. 

 

Complexity: `O(l * c)`, where `l` is the minimum of the 

lengths of `u` and of `v`, and `c` is the cost of the low 

level methods :meth:`first_descent`, :meth:`has_descent`, 

:meth:`~sage.categories.complex_reflection_or_generalized_coxeter_groups.ComplexReflectionOrGeneralizedCoxeterGroups.ElementMethods.apply_simple_reflection`), 

etc. Those are typically `O(n)`, where `n` is the rank of the 

Coxeter group. 

 

We now run consistency tests with permutations:: 

 

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

sage: P4 = Permutations(4) 

sage: def P4toW(w): return W.from_reduced_word(w.reduced_word()) 

sage: for u in P4: # long time (5s on sage.math, 2011) 

....: for v in P4: 

....: assert u.permutohedron_lequal(v) == P4toW(u).weak_le(P4toW(v)) 

....: assert u.permutohedron_lequal(v, side='left') == P4toW(u).weak_le(P4toW(v), side='left') 

""" 

if not have_same_parent(self, other): 

raise TypeError("%s and %s do not have the same parent"%(self,other)) 

# could first compare the length, when that information is cheap 

prefix_side = 'left' if side == 'right' else 'right' 

 

while True: 

desc = self.first_descent(side = prefix_side) 

if desc is None: 

return True 

if not other.has_descent(desc, side = prefix_side): 

return False 

self = self.apply_simple_reflection(desc, side = prefix_side) 

other = other.apply_simple_reflection(desc, side = prefix_side) 

 

def weak_covers(self, side = 'right', index_set = None, positive = False): 

""" 

Returns all elements that ``self`` covers in weak order. 

 

INPUT: 

 

- side -- 'left' or 'right' (default: 'right') 

- positive -- a boolean (default: False) 

- index_set -- a list of indices or None 

 

OUTPUT: a list 

 

EXAMPLES:: 

 

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

sage: w = W.from_reduced_word([3,2,1]) 

sage: [x.reduced_word() for x in w.weak_covers()] 

[[3, 2]] 

 

To obtain instead elements that cover self, set ``positive = True``:: 

 

sage: [x.reduced_word() for x in w.weak_covers(positive = True)] 

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

 

To obtain covers for left weak order, set the option side to 'left':: 

 

sage: [x.reduced_word() for x in w.weak_covers(side='left')] 

[[2, 1]] 

sage: w = W.from_reduced_word([3,2,3,1]) 

sage: [x.reduced_word() for x in w.weak_covers()] 

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

sage: [x.reduced_word() for x in w.weak_covers(side='left')] 

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

 

Covers w.r.t. a parabolic subgroup are obtained with the option ``index_set``:: 

 

sage: [x.reduced_word() for x in w.weak_covers(index_set = [1,2])] 

[[2, 3, 2]] 

""" 

return [ self.apply_simple_reflection(i, side=side) 

for i in self.descents(side=side, index_set = index_set, positive = positive) ] 

 

def coxeter_sorting_word(self,c): 

r""" 

Return the ``c``-sorting word of ``self``. 

 

For a Coxeter element `c` and an element `w`, the `c`-sorting 

word of `w` is the lexicographic minimal reduced expression of 

`w` in the infinite word `c^\infty`. 

 

INPUT: 

 

- ``c``-- a Coxeter element. 

 

OUTPUT: 

 

the ``c``-sorting word of ``self`` as a list of integers. 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: c = W.from_reduced_word([0,2,1]) 

sage: w = W.from_reduced_word([1,2,1,0,1]) 

sage: w.coxeter_sorting_word(c) 

[2, 1, 2, 0, 1] 

""" 

if hasattr(c,"reduced_word"): 

c = c.reduced_word() 

elif not isinstance(c,list): 

c = list(c) 

n = self.parent().rank() 

pi = self 

l = pi.length() 

i = 0 

sorting_word = [] 

while l > 0: 

s = c[i] 

if pi.has_left_descent(s): 

pi = pi.apply_simple_reflection_left(s) 

l -= 1 

sorting_word.append(s) 

i += 1 

if i == n: 

i = 0 

return sorting_word 

 

def is_coxeter_sortable(self,c,sorting_word=None): 

r""" 

Return whether ``self`` is ``c``-sortable. 

 

Given a Coxeter element `c`, an element `w` is `c`-sortable if 

its `c`-sorting word decomposes into a sequence of weakly 

decreasing subwords of `c`. 

 

INPUT: 

 

- ``c`` -- a Coxeter element. 

- ``sorting_word`` -- sorting word (default: None) used to 

not recompute the ``c``-sorting word if already computed. 

 

OUTPUT: 

 

is ``self`` ``c``-sortable 

 

EXAMPLES:: 

 

sage: W = CoxeterGroups().example() 

sage: c = W.from_reduced_word([0,2,1]) 

sage: w = W.from_reduced_word([1,2,1,0,1]) 

sage: w.coxeter_sorting_word(c) 

[2, 1, 2, 0, 1] 

sage: w.is_coxeter_sortable(c) 

False 

sage: w = W.from_reduced_word([0,2,1,0,2]) 

sage: w.coxeter_sorting_word(c) 

[2, 0, 1, 2, 0] 

sage: w.is_coxeter_sortable(c) 

True 

sage: W = CoxeterGroup(['A',3]) 

sage: c = W.from_reduced_word([1,2,3]) 

sage: len([w for w in W if w.is_coxeter_sortable(c)]) # number of c-sortable elements in A_3 (Catalan number) 

14 

""" 

if hasattr(c,"reduced_word"): 

c = c.reduced_word() 

elif not isinstance(c,list): 

c = list(c) 

if sorting_word is None: 

sorting_word = self.coxeter_sorting_word(c) 

n = len(c) 

containment_list = [ True ]*n 

l = 0 

i = 0 

while l < len(sorting_word): 

s = c[i] 

t = sorting_word[l] 

if s == t: 

l += 1 

if not containment_list[i]: 

return False 

else: 

containment_list[i] = False 

i += 1 

if i == n: 

i = 0 

return True 

 

def apply_demazure_product(self, element, side = 'right', length_increasing = True): 

r""" 

Returns the Demazure or 0-Hecke product of ``self`` with another Coxeter group element. 

 

See :meth:`CoxeterGroups.ParentMethods.simple_projections`. 

 

INPUT: 

 

- ``element`` -- either an element of the same Coxeter 

group as ``self`` or a tuple or a list (such as a 

reduced word) of elements from the index set of the 

Coxeter group. 

 

- ``side`` -- 'left' or 'right' (default: 'right'); the 

side of ``self`` on which the element should be 

applied. If ``side`` is 'left' then the operation is 

applied on the left. 

 

- ``length_increasing`` -- a boolean (default True) 

whether to act length increasingly or decreasingly 

 

EXAMPLES:: 

 

sage: W = WeylGroup(['C',4],prefix="s") 

sage: v = W.from_reduced_word([1,2,3,4,3,1]) 

sage: v.apply_demazure_product([1,3,4,3,3]) 

s4*s1*s2*s3*s4*s3*s1 

sage: v.apply_demazure_product([1,3,4,3],side='left') 

s3*s4*s1*s2*s3*s4*s2*s3*s1 

sage: v.apply_demazure_product((1,3,4,3),side='left') 

s3*s4*s1*s2*s3*s4*s2*s3*s1 

sage: v.apply_demazure_product(v) 

s2*s3*s4*s1*s2*s3*s4*s2*s3*s2*s1 

 

""" 

 

# if self and element have the same parent 

if self.parent().is_parent_of(element): 

the_word = element.reduced_word() 

else: 

# check for a list or tuple of elements of the index set 

if isinstance(element, (tuple)): 

element = [x for x in element] 

if not isinstance(element, (list)): 

raise TypeError("Bad Coxeter group element input: %s"%(element)) 

I = self.parent().index_set() 

if not all(i in I for i in element): 

raise ValueError("%s does not have all its members in the index set of the %s"%(element, self.parent())) 

# the copy is so that if we need to reverse the list, the original will not 

# get reversed 

the_word = copy(element) 

if side == 'left': 

the_word.reverse() 

for i in the_word: 

self = self.apply_simple_projection(i, side = side, length_increasing = length_increasing) 

return self 

 

def min_demazure_product_greater(self, element): 

r""" 

Finds the unique Bruhat-minimum element ``u`` such that ``v`` $\le$ ``w`` * ``u`` where ``v`` is ``self``, ``w`` is ``element`` and ``*`` is the Demazure product. 

 

INPUT: 

 

- ``element`` is either an element of the same Coxeter group as ``self`` or a list (such as a reduced word) of elements from the index set of the Coxeter group. 

 

EXAMPLES:: 

 

sage: W = WeylGroup(['A',4],prefix="s") 

sage: v = W.from_reduced_word([2,3,4,1,2]) 

sage: u = W.from_reduced_word([2,3,2,1]) 

sage: v.min_demazure_product_greater(u) 

s4*s2 

sage: v.min_demazure_product_greater([2,3,2,1]) 

s4*s2 

sage: v.min_demazure_product_greater((2,3,2,1)) 

s4*s2 

 

""" 

 

# if self and element have the same parent 

if self.parent().is_parent_of(element): 

the_word = element.reduced_word() 

# else require that ``element`` is a list or tuple of index_set elements 

else: 

if not isinstance(element, (tuple,list)): 

raise TypeError("Bad Coxeter group element input: %s"%(element)) 

I = self.parent().index_set() 

if not all(i in I for i in element): 

raise ValueError("%s does not have all its members in the index set of the %s"%(element, self.parent())) 

the_word = element 

for i in the_word: 

if self.has_descent(i, side = 'left'): 

self = self.apply_simple_reflection(i, side = 'left') 

return self 

 

def deodhar_factor_element(self, w, index_set): 

r""" 

Returns Deodhar's Bruhat order factoring element. 

 

INPUT: 

 

- ``w`` is an element of the same Coxeter group ``W`` as ``self`` 

- ``index_set`` is a subset of Dynkin nodes defining a parabolic subgroup ``W'`` of ``W`` 

 

It is assumed that ``v = self`` and ``w`` are minimum length coset representatives 

for ``W/W'`` such that ``v`` $\le$ ``w`` in Bruhat order. 

 

OUTPUT: 

 

Deodhar's element ``f(v,w)`` is the unique element of ``W'`` such that, 

for all ``v'`` and ``w'`` in ``W'``, ``vv'`` $\le$ ``ww'`` in ``W`` if and only if 

``v'`` $\le$ ``f(v,w) * w'`` in ``W'`` where ``*`` is the Demazure product. 

 

EXAMPLES:: 

 

sage: W = WeylGroup(['A',5],prefix="s") 

sage: v = W.from_reduced_word([5]) 

sage: w = W.from_reduced_word([4,5,2,3,1,2]) 

sage: v.deodhar_factor_element(w,[1,3,4]) 

s3*s1 

sage: W=WeylGroup(['C',2]) 

sage: w=W.from_reduced_word([2,1]) 

sage: w.deodhar_factor_element(W.from_reduced_word([2]),[1]) 

Traceback (most recent call last): 

... 

ValueError: [2, 1] is not of minimum length in its coset for the parabolic subgroup with index set [1] 

 

REFERENCES: 

 

- [Deo1987a]_ 

""" 

 

if self != self.coset_representative(index_set): 

raise ValueError("%s is not of minimum length in its coset for the parabolic subgroup with index set %s"%(self.reduced_word(),index_set)) 

if w != w.coset_representative(index_set): 

raise ValueError("%s is not of minimum length in its coset for the parabolic subgroup with index set %s"%(w.reduced_word(),index_set)) 

if not self.bruhat_le(w): 

raise ValueError("Must have %s <= %s"%(self.reduced_word(), w.reduced_word())) 

if w.is_one(): 

return w 

i = w.first_descent(side = 'left') 

sw = w.apply_simple_reflection(i, side = 'left') 

sv = self.apply_simple_reflection(i, side = 'left') 

if self.has_descent(i, side = 'left'): 

return sv.deodhar_factor_element(sw, index_set) 

dsp = self.deodhar_factor_element(sw, index_set) 

des = sv.first_descent(side = 'right', index_set = index_set) 

if des is None: 

return dsp 

return dsp.apply_simple_projection(des, side = 'left') 

 

def deodhar_lift_up(self, w, index_set): 

""" 

Letting ``v = self``, given a Bruhat relation ``v W'`` $\le$ ``w W'`` among cosets 

with respect to the subgroup ``W'`` given by the Dynkin node subset ``index_set``, 

returns the Bruhat-minimum lift ``x`` of ``wW'`` such that ``v`` $\le$ ``x``. 

 

INPUT: 

 

- ``w`` is an element of the same Coxeter group ``W`` as ``self``. 

- ``index_set`` is a subset of Dynkin nodes defining a parabolic subgroup ``W'``. 

 

OUTPUT: 

 

The unique Bruhat-minimum element ``x`` in ``W`` such that ``x W' = w W'`` 

and ``v`` $\le$ ``x``. 

 

.. SEEALSO:: :meth:`sage.categories.coxeter_groups.CoxeterGroups.ElementMethods.deodhar_lift_down` 

 

EXAMPLES:: 

 

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

sage: v = W.from_reduced_word([1,2,3]) 

sage: w = W.from_reduced_word([1,3,2]) 

sage: v.deodhar_lift_up(w, [3]) 

s1*s2*s3*s2 

 

""" 

 

vmin = self.coset_representative(index_set) 

wmin = w.coset_representative(index_set) 

if not vmin.bruhat_le(wmin): 

raise ValueError("Must have %s <= %s mod the parabolic subgroup with index set %s"%(self.reduced_word(), w.reduced_word(), index_set)) 

vJ = vmin.inverse() * self 

dsp = vmin.deodhar_factor_element(wmin,index_set) 

return wmin * vJ.min_demazure_product_greater(dsp) 

 

def deodhar_lift_down(self, w, index_set): 

r""" 

Letting ``v = self``, given a Bruhat relation ``v W'`` $\ge$ ``w W'`` among cosets 

with respect to the subgroup ``W'`` given by the Dynkin node subset ``index_set``, 

returns the Bruhat-maximum lift ``x`` of ``wW'`` such that ``v`` $\ge$ ``x``. 

 

INPUT: 

 

- ``w`` is an element of the same Coxeter group ``W`` as ``self``. 

- ``index_set`` is a subset of Dynkin nodes defining a parabolic subgroup ``W'``. 

 

OUTPUT: 

 

The unique Bruhat-maximum element ``x`` in ``W`` such that ``x W' = w W'`` 

and ``v $\ge$ ``x``. 

 

.. SEEALSO:: :meth:`sage.categories.coxeter_groups.CoxeterGroups.ElementMethods.deodhar_lift_up` 

 

EXAMPLES:: 

 

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

sage: v = W.from_reduced_word([1,2,3,2]) 

sage: w = W.from_reduced_word([3,2]) 

sage: v.deodhar_lift_down(w, [3]) 

s2*s3*s2 

 

""" 

 

vmin = self.coset_representative(index_set) 

wmin = w.coset_representative(index_set) 

if not wmin.bruhat_le(vmin): 

raise ValueError("Must have %s <= %s mod the parabolic subgroup with index set %s"%(w.reduced_word(), self.reduced_word(), index_set)) 

 

vJ = vmin.inverse() * self 

dsp = wmin.deodhar_factor_element(vmin,index_set) 

return wmin * dsp.apply_demazure_product(vJ) 

 

@cached_in_parent_method 

def inversions_as_reflections(self): 

r""" 

Returns the set of reflections ``r`` such that ``self`` ``r < self``. 

 

EXAMPLES:: 

 

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

sage: w = W.from_reduced_word([3,1,2,1]) 

sage: w.inversions_as_reflections() 

[s1, s1*s2*s1, s2, s1*s2*s3*s2*s1] 

 

""" 

 

i = self.first_descent() 

if i is None: 

return [] 

wi = self.apply_simple_reflection(i) 

return [self.parent().simple_reflection(i)]+[u.apply_conjugation_by_simple_reflection(i) for u in wi.inversions_as_reflections()] 

 

def left_inversions_as_reflections(self): 

r""" 

Returns the set of reflections ``r`` such that ``r`` ``self`` < ``self``. 

 

EXAMPLES:: 

 

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

sage: w = W.from_reduced_word([3,1,2,1]) 

sage: w.left_inversions_as_reflections() 

[s1, s3, s1*s2*s3*s2*s1, s2*s3*s2] 

 

""" 

 

return self.inverse().inversions_as_reflections() 

 

def lower_covers(self, side = 'right', index_set = None): 

""" 

Returns all elements that ``self`` covers in weak order. 

 

INPUT: 

 

- side -- 'left' or 'right' (default: 'right') 

- index_set -- a list of indices or None 

 

OUTPUT: a list 

 

EXAMPLES:: 

 

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

sage: w = W.from_reduced_word([3,2,1]) 

sage: [x.reduced_word() for x in w.lower_covers()] 

[[3, 2]] 

 

To obtain covers for left weak order, set the option side to 'left':: 

 

sage: [x.reduced_word() for x in w.lower_covers(side='left')] 

[[2, 1]] 

sage: w = W.from_reduced_word([3,2,3,1]) 

sage: [x.reduced_word() for x in w.lower_covers()] 

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

 

Covers w.r.t. a parabolic subgroup are obtained with the option ``index_set``:: 

 

sage: [x.reduced_word() for x in w.lower_covers(index_set = [1,2])] 

[[2, 3, 2]] 

sage: [x.reduced_word() for x in w.lower_covers(side='left')] 

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

""" 

return self.weak_covers(side = side, index_set = index_set, positive = False) 

 

def upper_covers(self, side = 'right', index_set = None): 

""" 

Returns all elements that cover ``self`` in weak order. 

 

INPUT: 

 

- side -- 'left' or 'right' (default: 'right') 

- index_set -- a list of indices or None 

 

OUTPUT: a list 

 

EXAMPLES:: 

 

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

sage: w = W.from_reduced_word([2,3]) 

sage: [x.reduced_word() for x in w.upper_covers()] 

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

 

To obtain covers for left weak order, set the option ``side`` to 'left':: 

 

sage: [x.reduced_word() for x in w.upper_covers(side = 'left')] 

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

 

Covers w.r.t. a parabolic subgroup are obtained with the option ``index_set``:: 

 

sage: [x.reduced_word() for x in w.upper_covers(index_set = [1])] 

[[2, 3, 1]] 

sage: [x.reduced_word() for x in w.upper_covers(side = 'left', index_set = [1])] 

[[1, 2, 3]] 

""" 

return self.weak_covers(side = side, index_set = index_set, positive = True)