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

r""" 

Subword complex 

 

Fix a Coxeter system `(W,S)`. The subword complex `\mathcal{SC}(Q,w)` 

associated to a word `Q \in S^*` and an element `w \in W` is the 

simplicial complex whose ground set is the set of positions in `Q` and whose 

facets are complements of sets of positions defining a reduced 

expression for `w`. 

 

A subword complex is a shellable sphere if and only if the Demazure 

product of `Q` equals `w`, otherwise it is a shellable ball. 

 

The code is optimized to be used with ReflectionGroup, it works as well 

with CoxeterGroup, but many methods fail for WeylGroup. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',3]); I = list(W.index_set()) # optional - gap3 

sage: Q = I + W.w0.coxeter_sorting_word(I); Q # optional - gap3 

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

 

sage: S = SubwordComplex(Q,W.w0) # optional - gap3 

sage: for F in S: print("{} {}".format(F, F.root_configuration())) # optional - gap3 

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

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

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

(0, 6, 7) [(1, 0, 0), (0, 0, 1), (0, -1, -1)] 

(0, 7, 8) [(1, 0, 0), (0, -1, 0), (0, 0, -1)] 

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

(1, 3, 8) [(1, 1, 0), (-1, 0, 0), (0, 0, -1)] 

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

(2, 4, 6) [(1, 1, 1), (-1, 0, 0), (0, -1, 0)] 

(3, 4, 5) [(0, 1, 0), (0, 0, 1), (-1, -1, -1)] 

(3, 5, 8) [(0, 1, 0), (-1, -1, 0), (0, 0, -1)] 

(4, 5, 6) [(0, 1, 1), (-1, -1, -1), (0, -1, 0)] 

(5, 6, 7) [(-1, 0, 0), (0, 0, 1), (0, -1, -1)] 

(5, 7, 8) [(-1, 0, 0), (0, -1, 0), (0, 0, -1)] 

 

Testing that the implementation also works with CoxeterGroup:: 

 

sage: W = CoxeterGroup(['A',3]); I = list(W.index_set()) 

sage: Q = I + W.w0.coxeter_sorting_word(I); Q 

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

sage: S = SubwordComplex(Q,W.w0); S 

Subword complex of type ['A', 3] for Q = (1, 2, 3, 1, 2, 3, 1, 2, 1) and pi = [1, 2, 3, 1, 2, 1] 

sage: P = S.increasing_flip_poset(); P; len(P.cover_relations()) 

Finite poset containing 14 elements 

21 

 

The root configuration works:: 

 

sage: for F in S: print("{} {}".format(F, F.root_configuration())) 

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

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

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

(0, 6, 7) [(1, 0, 0), (0, 0, 1), (0, -1, -1)] 

(0, 7, 8) [(1, 0, 0), (0, -1, 0), (0, 0, -1)] 

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

(1, 3, 8) [(1, 1, 0), (-1, 0, 0), (0, 0, -1)] 

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

(2, 4, 6) [(1, 1, 1), (-1, 0, 0), (0, -1, 0)] 

(3, 4, 5) [(0, 1, 0), (0, 0, 1), (-1, -1, -1)] 

(3, 5, 8) [(0, 1, 0), (-1, -1, 0), (0, 0, -1)] 

(4, 5, 6) [(0, 1, 1), (-1, -1, -1), (0, -1, 0)] 

(5, 6, 7) [(-1, 0, 0), (0, 0, 1), (0, -1, -1)] 

(5, 7, 8) [(-1, 0, 0), (0, -1, 0), (0, 0, -1)] 

 

And the weight configuration also works:: 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]) 

sage: F.extended_weight_configuration() 

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

sage: F.extended_weight_configuration(coefficients=(1,2)) 

[(4/3, 2/3), (4/3, 8/3), (-2/3, 2/3), (4/3, 8/3), (-2/3, 2/3)] 

 

One finally can compute the brick polytope, using all functionality 

on weight configurations, though it does not realize to live in 

real space:: 

 

sage: W = CoxeterGroup(['A',3]); I = list(W.index_set()) 

sage: Q = I + W.w0.coxeter_sorting_word(I) 

sage: S = SubwordComplex(Q,W.w0) 

sage: S.brick_polytope() 

A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 14 vertices 

 

sage: W = CoxeterGroup(['H',3]); I = list(W.index_set()) 

sage: Q = I + W.w0.coxeter_sorting_word(I) 

sage: S = SubwordComplex(Q,W.w0) 

sage: S.brick_polytope() 

doctest:...: RuntimeWarning: the polytope is build with rational vertices 

A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 32 vertices 

 

AUTHORS: 

 

- Christian Stump: initial version 

- Vincent Pilaud: greedy flip algorithm, minor improvements, documentation 

 

REFERENCES: 

 

.. [KnuMil] Knutson and Miller. *Subword complexes in Coxeter groups*. Adv. Math., 184(1):161-176, 2004. 

.. [PilStu] Pilaud and Stump. *Brick polytopes of spherical subword complexes and generalized associahedra*. Adv. Math. 276:1-61, 2015. 

""" 

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

# Copyright (C) 2015 Christian Stump <christian.stump@gmail.com> 

# 

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

# The full text of the GPL is available at: 

# 

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

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

# python3 

from __future__ import division, print_function 

from six.moves import range 

 

from copy import copy 

from sage.misc.cachefunc import cached_method 

from sage.structure.element import Element 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.homology.simplicial_complex import SimplicialComplex, Simplex 

from sage.categories.simplicial_complexes import SimplicialComplexes 

from sage.geometry.polyhedron.constructor import Polyhedron 

from sage.geometry.cone import Cone 

from sage.combinat.subword_complex_c import _flip_c, _construct_facets_c 

 

 

class SubwordComplexFacet(Simplex, Element): 

r""" 

A facet of a subword complex. 

 

Facets of the subword complex `\mathcal{SC}(Q,w)` are complements 

of sets of positions in `Q` defining a reduced expression for `w`. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: F = SC[0]; F # optional - gap3 

(0, 1) 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: F = SC[0]; F 

(0, 1) 

 

TESTS:: 

 

sage: type(F) # optional - gap3 

<class 'sage.combinat.subword_complex.SubwordComplex_with_category.element_class'> 

""" 

 

# standard functions 

 

def __init__(self, parent, positions, facet_test=True): 

r""" 

Initializes a facet of the subword complex ``parent``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: F = SC([1,2]); F 

(1, 2) 

 

TESTS:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC([1,3]) # optional - gap3 

Traceback (most recent call last): 

... 

ValueError: The given iterable [1, 3] is not a facet of the Subword complex of type ['A', 2] for Q = (1, 2, 1, 2, 1) and pi = [1, 2, 1] 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: TestSuite(SC).run() # optional - gap3 

""" 

if facet_test and positions not in parent: 

raise ValueError("The given iterable %s is not a facet of the %s" % (positions, parent)) 

Simplex.__init__(self, sorted(positions)) 

Element.__init__(self, parent) 

self._extended_root_conf_indices = None 

self._extended_weight_conf = None 

 

# roots 

 

def _extended_root_configuration_indices(self): 

r""" 

Return the indices of the roots in ``self.group().roots()`` of 

the extended root configuration of ``self``. 

 

Let `Q = q_1 \dots q_m \in S^*` and `w \in W`. The extended 

root configuration of a facet `I` of `\mathcal{SC}(Q,w)` is 

the sequence `\mathsf{r}(I, 1), \dots, \mathsf{r}(I, m)` of 

roots defined by `\mathsf{r}(I, k) = \Pi Q_{[k-1] 

\smallsetminus I} (\alpha_{q_k})`, where `\Pi Q_{[k-1] 

\smallsetminus I}` is the product of the simple reflections 

`q_i` for `i \in [k-1] \smallsetminus I` in this order. 

 

.. SEEALSO:: 

 

:meth:`extended_root_configuration` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F._extended_root_configuration_indices() # optional - gap3 

[0, 2, 3, 2, 1] 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: F = SC([1,2]); F 

(1, 2) 

sage: F._extended_root_configuration_indices() 

[0, 1, 3, 1, 2] 

""" 

if self._extended_root_conf_indices is None: 

self._extended_root_conf_indices = _extended_root_configuration_indices(self.parent().group(), self.parent().word(), self) 

return self._extended_root_conf_indices 

 

def _root_configuration_indices(self): 

r""" 

Return the indices of the roots in ``self.group().roots()`` of 

the root configuration of ``self``. 

 

Let `Q = q_1 \dots q_m \in S^*` and `w \in W`. The root 

configuration of a facet `I = [i_1, \dots, i_n]` of 

`\mathcal{SC}(Q,w)` is the sequence `\mathsf{r}(I, i_1), 

\dots, \mathsf{r}(I, i_n)` of roots defined by `\mathsf{r}(I, 

k) = \Pi Q_{[k-1] \smallsetminus I} (\alpha_{q_k})`, where 

`\Pi Q_{[k-1] \smallsetminus I}` is the product of the simple 

reflections `q_i` for `i \in [k-1] \smallsetminus I` in this 

order. 

 

.. SEEALSO:: 

 

:meth:`root_configuration` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F._root_configuration_indices() # optional - gap3 

[2, 3] 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: F = SC([1,2]); F 

(1, 2) 

sage: F._root_configuration_indices() # optional - gap3 

[1, 3] 

""" 

indices = self._extended_root_configuration_indices() 

return [indices[i] for i in self] 

 

def extended_root_configuration(self): 

r""" 

Return the extended root configuration of ``self``. 

 

Let `Q = q_1 \dots q_m \in S^*` and `w \in W`. The extended 

root configuration of a facet `I` of `\mathcal{SC}(Q,w)` is 

the sequence `\mathsf{r}(I, 1), \dots, \mathsf{r}(I, m)` of 

roots defined by `\mathsf{r}(I, k) = \Pi Q_{[k-1] 

\smallsetminus I} (\alpha_{q_k})`, where `\Pi Q_{[k-1] 

\smallsetminus I}` is the product of the simple reflections 

`q_i` for `i \in [k-1] \smallsetminus I` in this order. 

 

The extended root configuration is used to perform flips efficiently. 

 

.. SEEALSO:: 

 

:meth:`flip` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F.extended_root_configuration() # optional - gap3 

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]); F 

(1, 2) 

sage: F.extended_root_configuration() 

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

""" 

Phi = self.parent().group().roots() 

return [Phi[i] for i in self._extended_root_configuration_indices()] 

 

def root_configuration(self): 

r""" 

Return the root configuration of ``self``. 

 

Let `Q = q_1 \dots q_m \in S^*` and `w \in W`. The root 

configuration of a facet `I = [i_1, \dots, i_n]` of 

`\mathcal{SC}(Q,w)` is the sequence `\mathsf{r}(I, i_1), 

\dots, \mathsf{r}(I, i_n)` of roots defined by `\mathsf{r}(I, 

k) = \Pi Q_{[k-1] \smallsetminus I} (\alpha_{q_k})`, where 

`\Pi Q_{[k-1] \smallsetminus I}` is the product of the simple 

reflections `q_i` for `i \in [k-1] \smallsetminus I` in this 

order. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F.root_configuration() # optional - gap3 

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]); F 

(1, 2) 

sage: F.root_configuration() # optional - gap3 

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

""" 

Phi = self.parent().group().roots() 

return [Phi[i] for i in self._root_configuration_indices()] 

 

def kappa_preimage(self): 

r""" 

Return the fiber of ``self`` under the `\kappa` map. 

 

The `\kappa` map sends an element `w \in W` to the unique 

facet of `I \in \mathcal{SC}(Q,w)` such that the root 

configuration of `I` is contained in `w(\Phi^+)`. 

In other words, `w` is in the preimage of ``self`` under 

`\kappa` if and only if `w^{-1}` sends every root in the 

root configuration to a positive root. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F.kappa_preimage() # optional - gap3 

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

 

sage: F = SC([0,4]); F # optional - gap3 

(0, 4) 

sage: F.kappa_preimage() # optional - gap3 

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

 

sage: F = SC([1,2]); F 

(1, 2) 

sage: F.kappa_preimage() 

[ 

[-1 1] 

[ 0 1] 

] 

 

sage: F = SC([0,4]); F 

(0, 4) 

sage: F.kappa_preimage() 

[ 

[ 1 0] [-1 1] 

[ 1 -1], [-1 0] 

] 

""" 

W = self.parent().group() 

N = len(W.long_element(as_word=True)) 

root_conf = self._root_configuration_indices() 

return [~w for w in W 

if all(w.action_on_root_indices(i, side="left") < N 

for i in root_conf)] 

 

def is_vertex(self): 

r""" 

Return ``True`` if ``self`` is a vertex of the brick polytope 

of ``self.parent``. 

 

A facet is a vertex of the brick polytope if its root cone is 

pointed. Note that this property is always satisfied for 

root-independent subword complexes. 

 

.. SEEALSO:: 

 

:meth:`root_cone` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',1]) # optional - gap3 

sage: w = W.from_reduced_word([1]) # optional - gap3 

sage: SC = SubwordComplex([1,1,1],w) # optional - gap3 

sage: F = SC([0,1]); F.is_vertex() # optional - gap3 

True 

sage: F = SC([0,2]); F.is_vertex() # optional - gap3 

False 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1,2,1],w) # optional - gap3 

sage: F = SC([0,1,2,3]); F.is_vertex() # optional - gap3 

True 

sage: F = SC([0,1,2,6]); F.is_vertex() # optional - gap3 

False 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1,2,1],w) 

sage: F = SC([0,1,2,3]); F.is_vertex() 

True 

sage: F = SC([0,1,2,6]); F.is_vertex() 

False 

""" 

S = self.parent() 

if S.is_root_independent(): 

return True 

return self.root_cone().is_strictly_convex() 

 

@cached_method 

def root_cone(self): 

r""" 

Return the polyhedral cone generated by the root configuration 

of ``self``. 

 

.. SEEALSO:: 

 

:meth:`root_configuration` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',1]) # optional - gap3 

sage: w = W.from_reduced_word([1]) # optional - gap3 

sage: SC = SubwordComplex([1,1,1],w) # optional - gap3 

sage: F = SC([0,2]); F.root_cone() # optional - gap3 

1-d cone in 1-d lattice N 

 

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

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

sage: SC = SubwordComplex([1,1,1],w) 

sage: F = SC([0,2]); F.root_cone() 

1-d cone in 1-d lattice N 

""" 

return Cone(self.root_configuration()) 

 

def upper_root_configuration(self): 

r""" 

Return the positive roots of the root configuration of ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F.root_configuration() # optional - gap3 

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

sage: F.upper_root_configuration() # optional - gap3 

[(1, 0)] 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]); F 

(1, 2) 

sage: F.upper_root_configuration() 

[(1, 0)] 

""" 

conf = self._root_configuration_indices() 

W = self.parent().group() 

Phi = W.roots() 

N = len(Phi) // 2 

return [Phi[i - N] for i in conf if i >= N] 

 

# weights 

 

def extended_weight_configuration(self, coefficients=None): 

r""" 

Return the extended weight configuration of ``self``. 

 

Let `Q = q_1 \dots q_m \in S^*` and `w \in W`. The extended 

weight configuration of a facet `I` of `\mathcal{SC}(Q,w)` is 

the sequence `\mathsf{w}(I, 1), \dots, \mathsf{w}(I, m)` of 

weights defined by `\mathsf{w}(I, k) = \Pi Q_{[k-1] 

\smallsetminus I} (\omega_{q_k})`, where `\Pi Q_{[k-1] 

\smallsetminus I}` is the product of the simple reflections 

`q_i` for `i \in [k-1] \smallsetminus I` in this order. 

 

The extended weight configuration is used to compute the brick vector. 

 

INPUT: 

 

- coefficients -- (optional) a list of coefficients used to 

scale the fundamental weights 

 

.. SEEALSO:: 

 

:meth:`brick_vector` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]) # optional - gap3 

sage: F.extended_weight_configuration() # optional - gap3 

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

sage: F.extended_weight_configuration(coefficients=(1,2)) # optional - gap3 

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]) 

sage: F.extended_weight_configuration() 

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

sage: F.extended_weight_configuration(coefficients=(1,2)) 

[(4/3, 2/3), (4/3, 8/3), (-2/3, 2/3), (4/3, 8/3), (-2/3, 2/3)] 

""" 

if coefficients is not None or self._extended_weight_conf is None: 

W = self.parent().group() 

I = W.index_set() 

Lambda = W.fundamental_weights() 

if coefficients is not None: 

coeff = {I[i]: coefficients[i] 

for i in range(len(coefficients))} 

Lambda = {li: coeff[li] * Lambda[li] for li in Lambda.keys()} 

Q = self.parent().word() 

V_weights = [] 

pi = W.one() 

for i, wi in enumerate(Q): 

fund_weight = Lambda[wi] 

V_weights.append(pi*fund_weight) 

if i not in self: 

pi = pi.apply_simple_reflection_right(wi) 

if self._extended_weight_conf is None: 

self._extended_weight_conf = V_weights 

return V_weights 

else: 

return self._extended_weight_conf 

 

def weight_configuration(self): 

r""" 

Return the weight configuration of ``self``. 

 

Let `Q = q_1 \dots q_m \in S^*` and `w \in W`. The weight 

configuration of a facet `I = [i_1, \dots, i_n]` of 

`\mathcal{SC}(Q,w)` is the sequence `\mathsf{w}(I, i_1), 

\dots, \mathsf{w}(I, i_n)` of weights defined by 

`\mathsf{w}(I, k) = \Pi Q_{[k-1] \smallsetminus I} 

(\omega_{q_k})`, where `\Pi Q_{[k-1] \smallsetminus I}` is the 

product of the simple reflections `q_i` for `i \in [k-1] 

\smallsetminus I` in this order. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F.weight_configuration() # optional - gap3 

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]); F 

(1, 2) 

sage: F.weight_configuration() 

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

""" 

extended_configuration = self.extended_weight_configuration() 

return [extended_configuration[i] for i in self] 

 

@cached_method 

def weight_cone(self): 

r""" 

Return the polyhedral cone generated by the weight 

configuration of ``self``. 

 

.. SEEALSO:: 

 

:meth:`weight_configuration` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: WC = F.weight_cone(); WC # optional - gap3 

2-d cone in 2-d lattice N 

sage: WC.rays() # optional - gap3 

N( 1, 2), 

N(-1, 1) 

in 2-d lattice N 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]); F 

(1, 2) 

sage: WC = F.weight_cone(); WC 

2-d cone in 2-d lattice N 

""" 

return Cone(self.weight_configuration()) 

 

def brick_vector(self, coefficients=None): 

r""" 

Return the brick vector of ``self``. 

 

This is the sum of the weight vectors in the extended weight 

configuration. 

 

INPUT: 

 

- coefficients -- (optional) a list of coefficients used to 

scale the fundamental weights 

 

.. SEEALSO:: 

 

:meth:`extended_weight_configuration` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F.extended_weight_configuration() # optional - gap3 

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

sage: F.brick_vector() # optional - gap3 

(2/3, 7/3) 

sage: F.brick_vector(coefficients=[1,2]) # optional - gap3 

(4/3, 11/3) 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]) 

sage: F.brick_vector() 

(4/3, 14/3) 

sage: F.brick_vector(coefficients=[1,2]) 

(8/3, 22/3) 

""" 

return sum(self.extended_weight_configuration(coefficients=coefficients)) 

 

# flip 

 

def flip(self, i, return_position=False): 

r""" 

Return the facet obtained after flipping position ``i`` in ``self``. 

 

INPUT: 

 

- ``i`` -- position in the word `Q` (integer). 

- ``return_position`` -- boolean (default: ``False``) tells 

whether the new position should be returned as well. 

 

OUTPUT: 

 

- The new subword complex facet. 

- The new position if ``return_position`` is ``True``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

sage: F.flip(1) # optional - gap3 

(2, 3) 

sage: F.flip(1, return_position=True) # optional - gap3 

((2, 3), 3) 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]); F 

(1, 2) 

sage: F.flip(1) 

(2, 3) 

sage: F.flip(1, return_position=True) 

((2, 3), 3) 

""" 

S = self.parent() 

F = set(list(self)) 

R = list(self._extended_root_configuration_indices()) 

j = _flip_c(self.parent().group(), F, R, i) # F and R are changed here 

new_facet = S.element_class(self.parent(), F) 

new_facet._extended_root_conf_indices = tuple(R) 

if return_position: 

return new_facet, j 

else: 

return new_facet 

 

# plot and show 

 

def plot(self, list_colors=[], labels=[], thickness=3, fontsize=14, 

shift=(0, 0), compact=False, roots=True, **args): 

r""" 

In type `A` or `B`, plot a pseudoline arrangement representing 

the facet ``self``. 

 

Pseudoline arrangements are graphical representations of 

facets of types A or B subword complexes. 

 

INPUT: 

 

- ``list_colors`` -- list (default: ``[]``) to change the colors 

of the pseudolines. 

- ``labels`` -- list (default: ``[]``) to change the labels 

of the pseudolines. 

- ``thickness`` -- integer (default: ``3``) for the thickness 

of the pseudolines. 

- ``fontsize`` -- integer (default: ``14``) for the size 

of the font used for labels. 

- ``shift`` -- couple of coordinates (default: ``(0,0)``) 

to change the origin. 

- ``compact`` -- boolean (default: ``False``) to require 

a more compact representation. 

- ``roots`` -- boolean (default: ``True``) to print 

the extended root configuration. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F.plot() # optional - gap3 

Graphics object consisting of 26 graphics primitives 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1],w) 

sage: F = SC([1,2]); F.plot() 

Graphics object consisting of 26 graphics primitives 

 

sage: W = ReflectionGroup(['B',3]) # optional - gap3 

sage: c = W.from_reduced_word([1,2,3]) # optional - gap3 

sage: Q = c.reduced_word()*2 + W.w0.coxeter_sorting_word(c) # optional - gap3 

sage: SC = SubwordComplex(Q, W.w0) # optional - gap3 

sage: F = SC[15]; F.plot() # optional - gap3 

Graphics object consisting of 52 graphics primitives 

 

TESTS:: 

 

sage: W = ReflectionGroup(['D',4]) # optional - gap3 

sage: c = W.from_reduced_word([1,2,3,4]) # optional - gap3 

sage: Q = c.reduced_word() + W.w0.coxeter_sorting_word(c) # optional - gap3 

sage: SC = SubwordComplex(Q, W.w0) # optional - gap3 

sage: F = SC[1]; F.plot() # optional - gap3 

Traceback (most recent call last): 

... 

ValueError: Plotting is currently only implemented for irreducibles types A, B, and C. 

 

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

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

sage: Q = c.reduced_word() + W.w0.coxeter_sorting_word(c) 

sage: SC = SubwordComplex(Q, W.w0) 

sage: F = SC[1]; F.plot() 

Traceback (most recent call last): 

... 

ValueError: Plotting is currently only implemented for irreducibles types A, B, and C. 

 

REFERENCES: [PilStu]_ 

""" 

# check that the type is A or B 

# TODO in a better way 

S = self.parent() 

Q = S.word() 

W = S.group() 

n = W.rank() 

 

error_msg = "Plotting is currently only implemented for irreducibles types A, B, and C." 

if S._cartan_type is not None: 

cartan_type = S._cartan_type 

type = cartan_type.type() 

G = cartan_type.coxeter_matrix().coxeter_graph() 

else: 

type = None 

 

if type not in ['A','B','C'] or not G.is_connected(): 

raise ValueError(error_msg) 

 

# organization of the indexing 

# TODO: this might be better done in CoxeterType directly. 

index_set = None 

for a in G.vertex_iterator(): 

if G.degree(a) == 1: 

b = G.neighbors(a)[0] 

if ( type == "A" or G.edge_label(a,b) == 4 ): 

index_set = [a,b] 

break 

assert index_set is not None, "Bug in the plot method" 

while G.degree(b) == 2: 

for c in G.neighbors(b): 

# picking the other neighbors of b 

if c != a: 

index_set.append(c) 

a = b 

b = c 

break 

 

# import plot facilities 

from sage.plot.line import line 

from sage.plot.text import text 

from sage.plot.colors import colors 

from sage.combinat.permutation import Permutation 

 

# get properties 

x = 1 

if type == 'A': 

last = n 

else: 

last = n - 1 

permutation = Permutation(range(1, last + 2)) 

x_max = .5 

 

# list the pseudolines to be drawn 

pseudolines = [[(shift[0], shift[1] + i), .5] for i in range(last + 1)] 

pseudolines_type_B = [[] for i in range(last + 1)] 

contact_points = [] 

root_labels = [] 

pseudoline_labels = [] 

if labels is not False: 

pseudoline_labels += [(pseudoline, 

(shift[0] - .1, shift[1] + pseudoline), 

"center") for pseudoline in range(last + 1)] 

if roots: 

extended_root_conf = self.extended_root_configuration() 

for position in range(len(Q)): 

y = index_set.index(Q[position]) 

if type in ['B','C'] and y == 0: 

pseudoline = permutation(1) - 1 

x = pseudolines[pseudoline].pop() 

if compact: 

x_max = max(x + 1, x_max) 

else: 

x = x_max 

x_max += 1 

if position in self: 

pseudolines[pseudoline] += [(shift[0] + x + 1, 

shift[1]), x + 1] 

contact_points += [[(shift[0] + x + .5, shift[1] - .2), 

(shift[0] + x + .5, shift[1])]] 

else: 

pseudolines_type_B[pseudoline] = pseudolines[pseudoline] + [(shift[0] + x + .5, shift[1]), (shift[0] + x + .5, shift[1] - .2)] 

pseudolines[pseudoline] = [(shift[0] + x + .6, shift[1] - .2), (shift[0] + x + .6, shift[1]), .5] 

if roots: 

root_labels.append((extended_root_conf[position], 

(shift[0] + x + .25, shift[1] - .2))) 

else: 

if type in ['B','C']: 

y -= 1 

pseudoline1 = permutation(y + 1) - 1 

pseudoline2 = permutation(y + 2) - 1 

x = max(pseudolines[pseudoline1].pop(), 

pseudolines[pseudoline2].pop()) 

if compact: 

x_max = max(x + 1, x_max) 

else: 

x = x_max 

x_max += 1 

if position in self: 

pseudolines[pseudoline1] += [(shift[0] + x + 1, 

shift[1] + y), x + 1] 

pseudolines[pseudoline2] += [(shift[0] + x + 1, 

shift[1] + y + 1), x + 1] 

contact_points += [[(shift[0] + x + .5, shift[1] + y), 

(shift[0] + x + .5, shift[1] + y + 1)]] 

else: 

pseudolines[pseudoline1] += [(shift[0] + x + .6, 

shift[1] + y), 

(shift[0] + x + .6, 

shift[1] + y + 1), x + 1] 

pseudolines[pseudoline2] += [(shift[0] + x + .5, 

shift[1] + y + 1), 

(shift[0] + x + .5, 

shift[1] + y), x + 1] 

permutation = permutation._left_to_right_multiply_on_left(Permutation((y + 1, y + 2))) 

if roots: 

root_labels.append((extended_root_conf[position], 

(shift[0] + x + .35, 

shift[1] + y + .5))) 

if labels is not False: 

pseudoline_labels += [(pseudoline1, (shift[0] + x + .35, 

shift[1] + y + .05), 

"bottom"), 

(pseudoline2, (shift[0] + x + .35, 

shift[1] + y + .95), 

"top")] 

 

# transform list to real lines 

list_colors += ['red', 'blue', 'green', 'orange', 'yellow', 'purple'] 

list_colors += list(colors) 

thickness = max(thickness, 2) 

L = line([(1, 1)]) 

for contact_point in contact_points: 

L += line(contact_point, rgbcolor=[0, 0, 0], 

thickness=thickness - 1) 

for pseudoline in range(last + 1): 

pseudolines[pseudoline].pop() 

pseudolines[pseudoline].append((shift[0] + x_max, 

shift[1] + permutation.inverse()(pseudoline + 1) - 1)) 

L += line(pseudolines[pseudoline], color=list_colors[pseudoline], 

thickness=thickness) 

if type in ['B','C']: 

L += line(pseudolines_type_B[pseudoline], 

color=list_colors[pseudoline], 

thickness=thickness, linestyle="--") 

for root_label in root_labels: 

L += text(root_label[0], root_label[1], rgbcolor=[0, 0, 0], 

fontsize=fontsize, vertical_alignment="center", 

horizontal_alignment="right") 

if len(labels) < last + 1: 

labels = list(range(1, last + 2)) 

for pseudoline_label in pseudoline_labels: 

L += text(labels[pseudoline_label[0]], pseudoline_label[1], 

color=list_colors[pseudoline_label[0]], 

fontsize=fontsize, 

vertical_alignment=pseudoline_label[2], 

horizontal_alignment="right") 

if labels is not False: 

for pseudoline in range(last): 

L += text(labels[pseudoline], 

(shift[0] + x_max + .1, 

shift[1] + permutation.inverse()(pseudoline + 1) - 1), 

color=list_colors[pseudoline], fontsize=fontsize, 

vertical_alignment="center", 

horizontal_alignment="left") 

L.axes(False) 

return L 

 

def show(self, *kwds, **args): 

""" 

Show the facet ``self``. 

 

.. SEEALSO:: 

 

:meth:`plot` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1],w) # optional - gap3 

sage: F = SC([1,2]); F.show() # optional - gap3 

<BLANKLINE> 

""" 

return self.plot().show(*kwds, **args) 

 

class SubwordComplex(UniqueRepresentation, SimplicialComplex): 

r""" 

Fix a Coxeter system `(W,S)`. The subword complex 

`\mathcal{SC}(Q,w)` associated to a word `Q \in S^*` and an 

element `w \in W` is the simplicial complex whose ground set is the set of 

positions in `Q` and whose facets are complements of sets of 

positions defining a reduced expression for `w`. 

 

A subword complex is a shellable sphere if and only if the 

Demazure product of `Q` equals `w`, otherwise it is a shellable 

ball. 

 

.. WARNING:: 

 

This implementation only works for groups build using ``CoxeterGroup``, 

and does not work with groups build using ``WeylGroup``. 

 

EXAMPLES: 

 

As an example, dual associahedra are subword complexes in type 

`A_{n-1}` given by the word `[1, \dots, n, 1, \dots, n, 1, \dots, 

n-1, \dots, 1, 2, 1]` and the permutation `w_0`. 

 

:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w); SC # optional - gap3 

Subword complex of type ['A', 2] for Q = (1, 2, 1, 2, 1) and pi = [1, 2, 1] 

sage: SC.facets() # optional - gap3 

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w); SC 

Subword complex of type ['A', 2] for Q = (1, 2, 1, 2, 1) and pi = [1, 2, 1] 

sage: SC.facets() 

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

 

REFERENCES: [KnuMil]_, [PilStu]_ 

""" 

 

# standard functions 

 

@staticmethod 

def __classcall__(cls, Q, w, algorithm="inductive"): 

r""" 

Making the input hashable. 

 

TESTS:: 

 

sage: W = ReflectionGroup(['B',2]) # optional - gap3 

sage: S = SubwordComplex((1,2)*3,W.w0) # optional - gap3 

sage: T = SubwordComplex([1,2]*3,W.w0) # optional - gap3 

sage: S is T # optional - gap3 

True 

 

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

sage: S = SubwordComplex((1,2)*3,W.w0) 

sage: T = SubwordComplex([1,2]*3,W.w0) 

sage: S is T 

True 

""" 

Q = tuple(Q) 

return super(SubwordComplex, cls).__classcall__(cls, Q, w, algorithm=algorithm) 

 

def __init__(self, Q, w, algorithm="inductive"): 

r""" 

Initialize the subword complex `\mathcal{SC}(Q,w)`. 

 

INPUT: 

 

- ``Q`` -- word on the simple generators of the Coxeter group. 

- ``w`` -- element of the Coxeter group. 

- ``algorithm`` -- (default: ``"inductive"``) choice of the 

algorithm to generate the subword complex. Options are 

``"inductive"`` or ``"greedy"``. The second option is 

recommended when `|Q|` is closed to `\ell(w) + \mathrm{rank}(W)`. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',3]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,3,1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,3,1,2,3,1,2,1], w); SC # optional - gap3 

Subword complex of type ['A', 3] for Q = (1, 2, 3, 1, 2, 3, 1, 2, 1) and pi = [1, 2, 1, 3, 2, 1] 

sage: len(SC) # optional - gap3 

14 

 

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

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

sage: SC = SubwordComplex([1,2,3,1,2,3,1,2,1], w); SC 

Subword complex of type ['A', 3] for Q = (1, 2, 3, 1, 2, 3, 1, 2, 1) and pi = [1, 2, 3, 1, 2, 1] 

sage: len(SC) 

14 

 

TESTS: 

 

Check for methods from the enumerated sets category:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: list(SC) # optional - gap3 

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: list(SC) 

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

 

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

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

sage: SC = SubwordComplex([1,2,2,2,1], w) 

sage: len(SC) 

2 

""" 

W = w.parent() 

I = W.index_set() 

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

raise ValueError("All elements in Q = %s must be contained in the index set %s" % (Q, I)) 

self._Q = Q 

self._pi = w 

if algorithm == "inductive": 

Fs = _construct_facets_c(Q, w) 

elif algorithm == "greedy": 

Fs, Rs = _greedy_flip_algorithm(Q, w) 

else: 

raise ValueError("The optional argument algorithm can be " 

"either inductive or greedy") 

if Fs == []: 

raise ValueError("The word %s does not contain a reduced expression for %s" % (Q, w.reduced_word())) 

cat = SimplicialComplexes().Finite().Enumerated() 

SimplicialComplex.__init__(self, maximal_faces=Fs, 

maximality_check=False, 

category=cat) 

self.__custom_name = 'Subword complex' 

self._W = W 

try: 

T = W.coxeter_matrix().coxeter_type() 

self._cartan_type = T.cartan_type() 

except AttributeError: 

self._cartan_type = None 

self._facets_dict = None 

if algorithm == "greedy": 

_facets_dict = {} 

for i in range(len(Fs)): 

X = self(Fs[i], facet_test=False) 

X._extended_root_conf_indices = Rs[i] 

_facets_dict[tuple(sorted(Fs[i]))] = X 

self._facets_dict = _facets_dict 

else: 

self._facets_dict = {} 

 

def _repr_(self): 

r""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SubwordComplex([1,2,1,2,1], w) # optional - gap3 

Subword complex of type ['A', 2] for Q = (1, 2, 1, 2, 1) and pi = [1, 2, 1] 

 

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

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

sage: SubwordComplex([1,2,1,2,1], w) 

Subword complex of type ['A', 2] for Q = (1, 2, 1, 2, 1) and pi = [1, 2, 1] 

""" 

if self._cartan_type is None: 

return "Subword complex of unknown type for Q = {} and pi = {}".format(self._Q, self._pi.reduced_word()) 

else: 

return 'Subword complex of type {} for Q = {} and pi = {}'.format(self.cartan_type(), self._Q, self._pi.reduced_word()) 

 

def __eq__(self, other): 

r""" 

Compare the subword complexes ``self`` and ``other``. 

 

INPUT: 

 

- ``other`` -- another subword complex. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC1 = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC2 = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC1 == SC2 # optional - gap3 

True 

 

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

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

sage: SC1 = SubwordComplex([1,2,1,2,1], w) 

sage: SC2 = SubwordComplex([1,2,1,2,1], w) 

sage: SC1 == SC2 

True 

""" 

return self is other 

 

def __call__(self, F, facet_test=True): 

r""" 

Create a facet of ``self``. 

 

INPUT: 

 

- ``F`` -- an iterable of positions. 

- ``facet_test`` -- boolean (default: ``True``) tells whether or 

not the facet ``F`` should be tested before creation. 

 

OUTPUT: 

 

the facet of ``self`` at positions given by ``F``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: F = SC([1,2]); F # optional - gap3 

(1, 2) 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: F = SC([1,2]); F 

(1, 2) 

""" 

if hasattr(F,"parent") and F.parent() is self: 

return F 

return self.element_class(self, F, facet_test=facet_test) 

 

Element = SubwordComplexFacet 

 

def __contains__(self, F): 

r""" 

Tests if ``self`` contains a given iterable ``F``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.facets() # optional - gap3 

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

sage: [0,1] in SC # optional - gap3 

True 

sage: [0,2] in SC # optional - gap3 

False 

sage: [0,1,5] in SC # optional - gap3 

False 

sage: [0] in SC # optional - gap3 

False 

sage: ['a','b'] in SC # optional - gap3 

False 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.facets() 

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

sage: [0,1] in SC 

True 

sage: [0,2] in SC 

False 

sage: [0,1,5] in SC 

False 

sage: [0] in SC 

False 

sage: ['a','b'] in SC 

False 

""" 

W = self.group() 

Q = self.word() 

if not all(i in list(range(len(Q))) for i in F): 

return False 

return W.from_reduced_word(Qi for i, Qi in enumerate(Q) if i not in F) == self.pi() 

 

# getting the stored properties 

 

def group(self): 

r""" 

Return the group associated to ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.group() # optional - gap3 

Irreducible real reflection group of rank 2 and type A2 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.group() 

Finite Coxeter group over Integer Ring with Coxeter matrix: 

[1 3] 

[3 1] 

""" 

return self._W 

 

def cartan_type(self): 

r""" 

Return the Cartan type of ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.cartan_type() # optional - gap3 

['A', 2] 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.cartan_type() 

['A', 2] 

""" 

if self._cartan_type is None: 

raise ValueError("No Cartan type defined for {}".format(self._W)) 

else: 

return self._cartan_type 

 

def word(self): 

r""" 

Return the word in the simple generators associated to ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.word() # optional - gap3 

(1, 2, 1, 2, 1) 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.word() 

(1, 2, 1, 2, 1) 

""" 

return copy(self._Q) 

 

def pi(self): 

r""" 

Return the element in the Coxeter group associated to ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.pi().reduced_word() # optional - gap3 

[1, 2, 1] 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.pi().reduced_word() 

[1, 2, 1] 

""" 

return self._pi 

 

def facets(self): 

r""" 

Return all facets of ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.facets() # optional - gap3 

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.facets() 

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

""" 

if self._facets_dict: 

return [self._facets_dict[tuple(F)] for F in self._facets] 

else: 

return [self(F, facet_test=False) for F in self._facets] 

 

def __iter__(self): 

r""" 

Return an iterator on the facets of ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: for I in SC: print(I) # optional - gap3 

(0, 1) 

(0, 4) 

(1, 2) 

(2, 3) 

(3, 4) 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: for I in SC: print(I) 

(0, 1) 

(0, 4) 

(1, 2) 

(2, 3) 

(3, 4) 

""" 

return iter(self.facets()) 

 

def greedy_facet(self, side="positive"): 

r""" 

Return the negative (or positive) greedy facet of ``self``. 

 

This is the lexicographically last (or first) facet of ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.greedy_facet(side="positive") # optional - gap3 

(0, 1) 

sage: SC.greedy_facet(side="negative") # optional - gap3 

(3, 4) 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.greedy_facet(side="positive") 

(0, 1) 

sage: SC.greedy_facet(side="negative") 

(3, 4) 

""" 

return self.element_class(self, _greedy_facet(self.word(), 

self.pi(), side=side)) 

 

# topological properties 

 

def is_sphere(self): 

r""" 

Return ``True`` if the subword complex ``self`` is a sphere. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',3]) # optional - gap3 

sage: w = W.from_reduced_word([2,3,2]) # optional - gap3 

sage: SC = SubwordComplex([3,2,3,2,3], w) # optional - gap3 

sage: SC.is_sphere() # optional - gap3 

True 

 

sage: SC = SubwordComplex([3,2,1,3,2,3], w) # optional - gap3 

sage: SC.is_sphere() # optional - gap3 

False 

 

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

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

sage: SC = SubwordComplex([3,2,3,2,3], w) 

sage: SC.is_sphere() 

True 

""" 

W = self._pi.parent() 

w = W.demazure_product(self._Q) 

return w == self._pi 

 

def is_ball(self): 

r""" 

Return ``True`` if the subword complex ``self`` is a ball. 

 

This is the case if and only if it is not a sphere. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',3]) # optional - gap3 

sage: w = W.from_reduced_word([2,3,2]) # optional - gap3 

sage: SC = SubwordComplex([3,2,3,2,3], w) # optional - gap3 

sage: SC.is_ball() # optional - gap3 

False 

 

sage: SC = SubwordComplex([3,2,1,3,2,3], w) # optional - gap3 

sage: SC.is_ball() # optional - gap3 

True 

 

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

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

sage: SC = SubwordComplex([3,2,3,2,3], w) 

sage: SC.is_ball() 

False 

""" 

return not self.is_sphere() 

 

def is_pure(self): 

r""" 

Return ``True`` since all subword complexes are pure. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',3]) # optional - gap3 

sage: w = W.from_reduced_word([2,3,2]) # optional - gap3 

sage: SC = SubwordComplex([3,2,3,2,3], w) # optional - gap3 

sage: SC.is_pure() # optional - gap3 

True 

 

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

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

sage: SC = SubwordComplex([3,2,3,2,3], w) 

sage: SC.is_pure() 

True 

""" 

return True 

 

def dimension(self): 

r""" 

Return the dimension of ``self``. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC.dimension() # optional - gap3 

1 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: SC.dimension() 

1 

""" 

return self._facets[0].dimension() 

 

# root and weight 

 

@cached_method 

def is_root_independent(self): 

r""" 

Return ``True`` if ``self`` is root-independent. 

 

This means that the root configuration 

of any (or equivalently all) facets is linearly independent. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC.is_root_independent() # optional - gap3 

True 

 

sage: SC = SubwordComplex([1,2,1,2,1,2], W.w0) # optional - gap3 

sage: SC.is_root_independent() # optional - gap3 

False 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: SC.is_root_independent() 

True 

""" 

from sage.matrix.all import matrix 

M = matrix(self.greedy_facet(side="negative").root_configuration()) 

return M.rank() == max(M.ncols(), M.nrows()) 

 

@cached_method 

def is_double_root_free(self): 

r""" 

Return ``True`` if ``self`` is double-root-free. 

 

This means that the root configurations 

of all facets do not contain a root twice. 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.is_double_root_free() # optional - gap3 

True 

 

sage: SC = SubwordComplex([1,1,2,2,1,1], w) # optional - gap3 

sage: SC.is_double_root_free() # optional - gap3 

True 

 

sage: SC = SubwordComplex([1,2,1,2,1,2], w) # optional - gap3 

sage: SC.is_double_root_free() # optional - gap3 

False 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.is_double_root_free() 

True 

""" 

if not self.is_root_independent(): 

size = self.dimension() + 1 

for F in self: 

conf = F._root_configuration_indices() 

if len(set(conf)) < size: 

return False 

return True 

 

def kappa_preimages(self): 

""" 

Return a dictionary containing facets of ``self`` as keys, 

and list of elements of ``self.group()`` as values. 

 

.. SEEALSO:: 

 

:meth:`kappa_preimage <sage.combinat.subword_complex.SubwordComplexFacet.kappa_preimage>` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: kappa = SC.kappa_preimages() # optional - gap3 

sage: for F in SC: print("{} {}".format(F, [w.reduced_word() for w in kappa[F]])) # optional - gap3 

(0, 1) [[]] 

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

(1, 2) [[1]] 

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

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

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: kappa = SC.kappa_preimages() 

sage: for F in SC: print("{} {}".format(F, [w.reduced_word() for w in kappa[F]])) 

(0, 1) [[]] 

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

(1, 2) [[1]] 

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

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

""" 

return {F: F.kappa_preimage() for F in self} 

 

def brick_fan(self): 

r""" 

Return the brick fan of ``self``. 

 

It is the normal fan of the brick polytope of ``self``. It is 

formed by the cones generated by the weight configurations of 

the facets of ``self``. 

 

.. SEEALSO:: 

 

:func:`weight_cone <sage.combinat.subword_complex.SubwordComplexFacet.weight_cone>` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], w) # optional - gap3 

sage: SC.brick_fan() # optional - gap3 

Rational polyhedral fan in 2-d lattice N 

 

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

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

sage: SC = SubwordComplex([1,2,1,2,1], w) 

sage: SC.brick_fan() 

Rational polyhedral fan in 2-d lattice N 

""" 

from sage.geometry.fan import Fan 

return Fan([F.weight_cone() for F in self]) 

 

# brick polytope 

 

def brick_vectors(self, coefficients=None): 

r""" 

Return the list of all brick vectors of facets of ``self``. 

 

INPUT: 

 

- coefficients -- (optional) a list of coefficients used to 

scale the fundamental weights 

 

.. SEEALSO:: 

 

:func:`brick_vector <sage.combinat.subword_complex.SubwordComplexFacet.brick_vector>` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC.brick_vectors() # optional - gap3 

[(5/3, 7/3), (5/3, 1/3), (2/3, 7/3), (-1/3, 4/3), (-1/3, 1/3)] 

sage: SC.brick_vectors(coefficients=(1,2)) # optional - gap3 

[(7/3, 11/3), (7/3, 2/3), (4/3, 11/3), (-2/3, 5/3), (-2/3, 2/3)] 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: SC.brick_vectors() 

[(10/3, 14/3), (10/3, 2/3), (4/3, 14/3), (-2/3, 8/3), (-2/3, 2/3)] 

sage: SC.brick_vectors(coefficients=(1,2)) 

[(14/3, 22/3), (14/3, 4/3), (8/3, 22/3), (-4/3, 10/3), (-4/3, 4/3)] 

""" 

return [F.brick_vector(coefficients=coefficients) for F in self] 

 

def minkowski_summand(self, i): 

r""" 

Return the `i` th Minkowski summand of ``self``. 

 

INPUT: 

 

`i` -- an integer defining a position in the word `Q` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC.minkowski_summand(1) # optional - gap3 

A 0-dimensional polyhedron in QQ^2 defined as the convex hull of 1 vertex 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: SC.minkowski_summand(1) 

A 0-dimensional polyhedron in QQ^2 defined as the convex hull of 1 vertex 

""" 

G = self.group() 

from sage.rings.all import QQ 

if G.coxeter_matrix().is_crystallographic(): 

min_sum = [[QQ(v) for v in F.extended_weight_configuration()[i]] for F in self] 

else: 

from sage.rings.all import CC 

from warnings import warn 

warn("the polytope is build with rational vertices", RuntimeWarning) 

min_sum = [[QQ(CC(v)) for v in F.extended_weight_configuration()[i]] for F in self] 

return Polyhedron(min_sum) 

 

def brick_polytope(self, coefficients=None): 

r""" 

Return the brick polytope of ``self``. 

 

This polytope is the convex hull of the brick vectors of ``self``. 

 

INPUT: 

 

- coefficients -- (optional) a list of coefficients used to 

scale the fundamental weights 

 

.. SEEALSO:: 

 

:meth:`brick_vectors` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: X = SC.brick_polytope(); X # optional - gap3 

A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 5 vertices 

 

sage: Y = SC.brick_polytope(coefficients=[1,2]); Y # optional - gap3 

A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 5 vertices 

 

sage: X == Y # optional - gap3 

False 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: X = SC.brick_polytope(); X 

A 2-dimensional polyhedron in QQ^2 defined as the convex hull of 5 vertices 

 

sage: W = ReflectionGroup(['H',3]) # optional - gap3 

sage: c = W.index_set(); Q = c + tuple(W.w0.coxeter_sorting_word(c)) # optional - gap3 

sage: SC = SubwordComplex(Q,W.w0) # optional - gap3 

sage: SC.brick_polytope() # optional - gap3 

A 3-dimensional polyhedron in QQ^3 defined as the convex hull of 32 vertices 

""" 

BV = self.brick_vectors(coefficients=coefficients) 

G = self.group() 

from sage.rings.all import QQ 

if G.coxeter_matrix().is_crystallographic(): 

BV = [[QQ(v) for v in V] for V in BV] 

else: 

from sage.rings.all import CC 

from warnings import warn 

warn("the polytope is build with rational vertices", RuntimeWarning) 

BV = [[QQ(CC(v).real()) for v in V] for V in BV] 

return Polyhedron(BV) 

 

def barycenter(self): 

""" 

Return the barycenter of the brick polytope of ``self``. 

 

.. SEEALSO:: 

 

:meth:`brick_polytope` 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC.barycenter() # optional - gap3 

(2/3, 4/3) 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: SC.barycenter() 

(4/3, 8/3) 

""" 

facets = self.facets() 

if not self.is_root_independent(): 

facets = [F for F in facets if F.is_vertex()] 

return sum(F.brick_vector() for F in facets) / len(facets) 

 

# cambrian constructions 

 

def cover_relations(self, label=False): 

""" 

Return the set of cover relations in the associated poset. 

 

INPUT: 

 

- label -- boolean (default ``False``) whether or not to label 

the cover relations by the position of flip 

 

OUTPUT: 

 

a list of pairs of facets 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC.cover_relations() # optional - gap3 

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

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

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

((0, 4), (3, 4)), 

((2, 3), (3, 4))] 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: SC.cover_relations() 

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

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

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

((0, 4), (3, 4)), 

((2, 3), (3, 4))] 

""" 

N = len(self.group().long_element(as_word=True)) 

F = self.greedy_facet(side="positive") 

Fs = set([F]) 

seen = set([F]) 

covers = [] 

while Fs: 

F = Fs.pop() 

seen.add(F) 

conf = F._extended_root_configuration_indices() 

for i in F: 

if conf[i] < N: 

G = F.flip(i) 

if label: 

covers.append((F, G, i)) 

else: 

covers.append((F, G)) 

if G not in seen: 

Fs.add(G) 

return covers 

 

def increasing_flip_graph(self, label=True): 

""" 

Return the increasing flip graph of the subword complex. 

 

OUTPUT: 

 

a directed graph 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC.increasing_flip_graph() # optional - gap3 

Digraph on 5 vertices 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: SC.increasing_flip_graph() 

Digraph on 5 vertices 

""" 

from sage.graphs.digraph import DiGraph 

return DiGraph(self.cover_relations(label=label)) 

 

def interval(self, I, J): 

""" 

Return the interval [I,J] in the increasing flip graph subword complex. 

 

INPUT: 

 

- I, J -- two facets 

 

OUTPUT: 

 

a set of facets 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: F = SC([1,2]) # optional - gap3 

sage: SC.interval(F, F) # optional - gap3 

{(1, 2)} 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: F = SC([1,2]) 

sage: SC.interval(F, F) 

{(1, 2)} 

""" 

G = self.increasing_flip_graph() 

paths = G.all_paths(I, J) 

return set(K for path in paths for K in path) 

 

def increasing_flip_poset(self): 

""" 

Return the increasing flip poset of the subword complex. 

 

OUTPUT: 

 

a poset 

 

EXAMPLES:: 

 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) # optional - gap3 

sage: SC.increasing_flip_poset() # optional - gap3 

Finite poset containing 5 elements 

 

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

sage: SC = SubwordComplex([1,2,1,2,1], W.w0) 

sage: SC.increasing_flip_poset() 

Finite poset containing 5 elements 

""" 

from sage.combinat.posets.posets import Poset 

cov = self.cover_relations() 

if not self.is_root_independent(): 

Fs = [F for F in self if F.is_vertex()] 

cov = [(a, b) for a, b in cov if a in Fs and b in Fs] 

return Poset(((), cov), facade=True) 

 

def _greedy_facet(Q, w, side="negative", n=None, pos=0, l=None, elems=[]): 

r""" 

Return the (positive or negative) *greedy facet* of the subword 

complex `SC(Q, w)`. 

 

INPUT: 

 

- `Q` -- a word 

- `w` -- an element in the Coxeter group 

- side -- optional, either 'negative' (default) or 'positive' 

- n -- an integer (optional, defaults to the length of Q) 

- pos -- an integer (optional, default 0) 

- l -- an integer (optional, defaults to the length of w) 

- elems -- a list (optional) 

 

OUTPUT: 

 

- a set 

 

EXAMPLES:: 

 

sage: from sage.combinat.subword_complex import _greedy_facet 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: Q = [1,2,1,2,1] # optional - gap3 

sage: w = W.from_reduced_word([1, 2, 1]) # optional - gap3 

sage: _greedy_facet(Q, w) # optional - gap3 

{3, 4} 

 

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

sage: Q = [1,2,1,2,1] 

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

sage: _greedy_facet(Q, w) 

{3, 4} 

""" 

if side == "negative": 

pass 

elif side == "positive": 

Q = Q[::-1] 

w = w.inverse() 

else: 

raise ValueError("The optional argument side is not positive " 

"or negative") 

 

if n is None: 

n = len(Q) 

if l is None: 

l = w.length() 

 

if l == 0: 

return elems + list(range(pos, n)) 

elif n < l: 

return [] 

 

s = Q[pos] 

 

if w.has_left_descent(s): 

X = _greedy_facet(Q, w.apply_simple_reflection_left(s), 

n=n, pos=pos + 1, l=l - 1, elems=elems) 

else: 

X = [] 

 

if X == []: 

X = _greedy_facet(Q, w, n=n, pos=pos + 1, l=l, elems=elems + [pos]) 

 

if side == "positive": 

X = [n - 1 - i for i in X] 

Q = Q[::-1] 

w = w.inverse() 

 

return set(X) 

 

def _extended_root_configuration_indices(W, Q, F): 

""" 

Return the extended root configuration indices of the facet `F`. 

 

INPUT: 

 

- `W` -- a Coxeter group 

- `Q` -- a word representing an element of `W` 

- `F` -- a facet of the subword complex 

 

OUTPUT: 

 

a list of root indices 

 

EXAMPLES:: 

 

sage: from sage.combinat.subword_complex import _extended_root_configuration_indices 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: Q = [1,2,1,2,1] # optional - gap3 

sage: SC = SubwordComplex(Q, w) # optional - gap3 

sage: F = SC([1,2]) # optional - gap3 

sage: _extended_root_configuration_indices(W, Q, F) # optional - gap3 

[0, 2, 3, 2, 1] 

 

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

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

sage: Q = [1,2,1,2,1] 

sage: SC = SubwordComplex(Q, w) 

sage: F = SC([1,2]) 

sage: _extended_root_configuration_indices(W, Q, F) 

[0, 1, 3, 1, 2] 

""" 

V_roots = [] 

pi = W.one() 

for i, wi in enumerate(Q): 

V_roots.append(pi.action_on_root_indices(W.simple_root_index(wi),side="left")) 

if i not in F: 

pi = pi.apply_simple_reflection_right(wi) 

return V_roots 

 

def _greedy_flip_algorithm(Q, w): 

""" 

INPUT: 

 

- Q -- a word in a Coxeter group W 

- w -- an element of W 

 

OUTPUT: 

 

a pair: the list of facets and the list of extended root conf. indices 

 

EXAMPLES:: 

 

sage: from sage.combinat.subword_complex import _greedy_flip_algorithm 

sage: W = ReflectionGroup(['A',2]) # optional - gap3 

sage: Q = [1,2,1,2,1] # optional - gap3 

sage: w = W.from_reduced_word([1,2,1]) # optional - gap3 

sage: _greedy_flip_algorithm(Q, w) # optional - gap3 

([{0, 1}, [1, 2], [2, 3], [3, 4], [0, 4]], 

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

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

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

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

[0, 1, 2, 0, 4]]) 

 

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

sage: Q = [1,2,1,2,1] 

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

sage: _greedy_flip_algorithm(Q, w) 

([{0, 1}, [1, 2], [2, 3], [3, 4], [0, 4]], 

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

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

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

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

[0, 2, 1, 0, 5]]) 

""" 

W = w.parent() 

F = _greedy_facet(Q, w, side="positive") 

R = _extended_root_configuration_indices(W, Q, F) 

facet_list = [F] 

extended_root_conf_indices_list = [R] 

flip_to_ancestors = [-1] 

next_index = 0 

while flip_to_ancestors != []: 

has_new_child = False 

for i in sorted(F): 

if (not has_new_child) and (i >= next_index): 

j = _flip_c(W, F, R, i, side="positive") 

if j != i: 

flip_to_ancestors.append(j) 

next_index = i + 1 

has_new_child = True 

facet_list.append([x for x in F]) 

extended_root_conf_indices_list.append([x for x in R]) 

if not has_new_child: 

i = flip_to_ancestors.pop() 

if i != -1: 

j = _flip_c(W, F, R, i, side="negative") 

next_index = j + 1 

return facet_list, extended_root_conf_indices_list