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

r""" 

Gelfand-Tsetlin Patterns 

 

AUTHORS: 

 

- Travis Scrimshaw (2013-15-03): Initial version 

 

REFERENCES: 

 

.. [BBF] \B. Brubaker, D. Bump, and S. Friedberg. 

Weyl Group Multiple Dirichlet Series: Type A Combinatorial Theory. 

Ann. of Math. Stud., vol. 175, Princeton Univ. Press, New Jersey, 2011. 

 

.. [GC50] \I. M. Gelfand and M. L. Cetlin. 

Finite-Dimensional Representations of the Group of Unimodular Matrices. 

Dokl. Akad. Nauk SSSR **71**, pp. 825--828, 1950. 

 

.. [Tok88] \T. Tokuyama. 

A Generating Function of Strict Gelfand Patterns and Some Formulas on 

Characters of General Linear Groups. 

J. Math. Soc. Japan **40** (4), pp. 671--685, 1988. 

 

 

""" 

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

# Copyright (C) 2013 Travis Scrimshaw <tscrim@ucdavis.edu> 

# 

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

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

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

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

from __future__ import print_function 

from six.moves import range 

from six import add_metaclass 

 

from sage.structure.parent import Parent 

from sage.structure.list_clone import ClonableArray 

from sage.structure.unique_representation import UniqueRepresentation 

from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets 

from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets 

from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass 

from sage.misc.cachefunc import cached_method 

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing 

from sage.rings.all import ZZ 

from sage.combinat.partition import Partitions 

from sage.combinat.tableau import Tableau, SemistandardTableaux 

from sage.combinat.combinatorial_map import combinatorial_map 

from sage.misc.all import prod 

 

 

@add_metaclass(InheritComparisonClasscallMetaclass) 

class GelfandTsetlinPattern(ClonableArray): 

r""" 

A Gelfand-Tsetlin (sometimes written as Gelfand-Zetlin or Gelfand-Cetlin) 

pattern. They were originally defined in [GC50]_. 

 

A Gelfand-Tsetlin pattern is a triangular array: 

 

.. MATH:: 

 

\begin{array}{ccccccccc} 

a_{1,1} & & a_{1,2} & & a_{1,3} & & \cdots & & a_{1,n} \\ 

& a_{2,2} & & a_{2,3} & & \cdots & & a_{2,n} \\ 

& & a_{3,3} & & \cdots & & a_{3,n} \\ 

& & & \ddots \\ 

& & & & a_{n,n} 

\end{array} 

 

such that `a_{i,j} \geq a_{i+1,j+1} \geq a_{i,j+1}`. 

 

Gelfand-Tsetlin patterns are in bijection with semistandard Young tableaux 

by the following algorithm. Let `G` be a Gelfand-Tsetlin pattern with 

`\lambda^{(k)}` being the `(n-k+1)`-st row (note that this is a partition). 

The definition of `G` implies 

 

.. MATH:: 

 

\lambda^{(0)} \subseteq \lambda^{(1)} \subseteq \cdots \subseteq 

\lambda^{(n)}, 

 

where `\lambda^{(0)}` is the empty partition, and each skew shape 

`\lambda^{(k)}/\lambda^{(k-1)}` is a horizontal strip. Thus define `T(G)` 

by inserting `k` into the squares of the skew shape 

`\lambda^{(k)}/ \lambda^{(k-1)}`, for `k=1,\dots,n`. 

 

To each entry in a Gelfand-Tsetlin pattern, one may attach a decoration of 

a circle or a box (or both or neither). These decorations appear in the 

study of Weyl group multiple Dirichlet series, and are implemented here 

following the exposition in [BBF]_. 

 

.. NOTE:: 

 

We use the "right-hand" rule for determining circled and boxed entries. 

 

.. WARNING:: 

 

The entries in Sage are 0-based and are thought of as flushed to the 

left in a matrix. In other words, the coordinates of entries in the 

Gelfand-Tsetlin patterns are thought of as the matrix: 

 

.. MATH:: 

 

\begin{bmatrix} 

g_{0,0} & g_{0,1} & g_{0,2} & \cdots & g_{0,n-2} & g_{n-1,n-1} \\ 

g_{1,0} & g_{1,1} & g_{1,2} & \cdots & g_{1,n-2} \\ 

g_{2,0} & g_{2,1} & g_{2,2} & \cdots \\ 

\vdots & \vdots & \vdots \\ 

g_{n-2,0} & g_{n-2,1} \\ 

g_{n-1,0} 

\end{bmatrix}. 

 

However, in the discussions, we will be using the **standard** 

numbering system. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[3, 2, 1], [2, 1], [1]]); G 

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

sage: G.pp() 

3 2 1 

2 1 

1 

sage: G = GelfandTsetlinPattern([[7, 7, 4, 0], [7, 7, 3], [7, 5], [5]]); G.pp() 

7 7 4 0 

7 7 3 

7 5 

5 

sage: G.to_tableau().pp() 

1 1 1 1 1 2 2 

2 2 2 2 2 3 3 

3 3 3 4 

""" 

# Note that the width == height, so len(gt) == len(gt[0]) except 

# we don't have to check if it is the emtry GT pattern 

@staticmethod 

def __classcall_private__(self, gt): 

""" 

Return ``gt`` as a proper element of :class:`GelfandTsetlinPatterns`. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[3,2,1],[2,1],[1]]) 

sage: G.parent() 

Gelfand-Tsetlin patterns 

sage: TestSuite(G).run() 

""" 

return GelfandTsetlinPatterns()(gt) 

 

def check(self): 

""" 

Check that this is a valid Gelfand-Tsetlin pattern. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: G([[3,2,1],[2,1],[1]]).check() 

""" 

assert all( self[i-1][j] >= self[i][j] >= self[i-1][j+1] 

for i in range(1, len(self)) for j in range(len(self[i])) ) 

 

def _hash_(self): 

""" 

Return the hash value of ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: gt = G([[3,2,1],[2,1],[1]]) 

sage: hash(gt) == hash(gt) 

True 

 

Check that :trac:`14717` is fixed:: 

 

sage: GT = GelfandTsetlinPattern([[2, 1, 0], [2, 0], [1]]) 

sage: GT in {} 

False 

""" 

return hash(tuple(map(tuple, self))) 

 

def _repr_diagram(self): 

""" 

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

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: print(G([[3,2,1],[2,1],[1]])._repr_diagram()) 

3 2 1 

2 1 

1 

""" 

ret = '' 

for i, row in enumerate(self): 

if i != 0: 

ret += '\n' 

ret += ' '*i 

ret += ' '.join('%3s'%val for val in row) 

return ret 

 

def pp(self): 

""" 

Pretty print ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: G([[3,2,1],[2,1],[1]]).pp() 

3 2 1 

2 1 

1 

""" 

print(self._repr_diagram()) 

 

def _latex_(self): 

r""" 

Return a `\LaTeX` representation of ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: latex(G([[3,2,1],[2,1],[1]])) 

\begin{array}{ccccc} 

3 & & 2 & & 1 \\ 

& 2 & & 1 & \\ 

& & 1 & & 

\end{array} 

sage: latex(G([])) 

\emptyset 

""" 

n = len(self) 

if n == 0: 

return "\\emptyset" 

ret = "\\begin{array}{" + 'c'*(n*2-1) + "}\n" 

for i, row in enumerate(self): 

if i > 0: 

ret += " \\\\\n" 

ret += "& "*i 

ret += " & & ".join(repr(val) for val in row) 

ret += " &"*i 

return ret + "\n\\end{array}" 

 

@combinatorial_map(name='to semistandard tableau') 

def to_tableau(self): 

""" 

Return ``self`` as a semistandard Young tableau. 

 

The conversion from a Gelfand-Tsetlin pattern to a semistandard Young 

tableaux is as follows. Let `G` be a Gelfand-Tsetlin pattern with 

`\lambda^{(k)}` being the `(n-k+1)`-st row (note that this is a 

partition). The definition of `G` implies 

 

.. MATH:: 

 

\lambda^{(0)} \subseteq \lambda^{(1)} \subseteq \cdots \subseteq 

\lambda^{(n)}, 

 

where `\lambda^{(0)}` is the empty partition, and each skew shape 

`\lambda^{(k)} / \lambda^{(k-1)}` is a horizontal strip. Thus define 

`T(G)` by inserting `k` into the squares of the skew shape 

`\lambda^{(k)} / \lambda^{(k-1)}`, for `k=1,\dots,n`. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: elt = G([[3,2,1],[2,1],[1]]) 

sage: T = elt.to_tableau(); T 

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

sage: T.pp() 

1 2 3 

2 3 

3 

sage: G(T) == elt 

True 

""" 

ret = [] 

for i, row in enumerate(reversed(self)): 

for j, val in enumerate(row): 

if j >= len(ret): 

if val == 0: 

break 

ret.append([i+1]*val) 

else: 

ret[j].extend([i+1]*(val-len(ret[j]))) 

S = SemistandardTableaux() 

return S(ret) 

 

@cached_method 

def boxed_entries(self): 

""" 

Return the position of the boxed entries of ``self``. 

 

Using the *right-hand* rule, an entry `a_{i,j}` is boxed if 

`a_{i,j} = a_{i-1,j-1}`; i.e., `a_{i,j}` has the same value as its 

neighbor to the northwest. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[3,2,1],[3,1],[1]]) 

sage: G.boxed_entries() 

((1, 0),) 

""" 

ret = [] 

for i in range(1, len(self)): 

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

if self[i][j] == self[i-1][j]: 

ret.append((i, j)) 

return tuple(ret) 

 

@cached_method 

def circled_entries(self): 

""" 

Return the circled entries of ``self``. 

 

Using the *right-hand* rule, an entry `a_{i,j}` is circled if 

`a_{i,j} = a_{i-1,j}`; i.e., `a_{i,j}` has the same value as its 

neighbor to the northeast. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[3,2,1],[3,1],[1]]) 

sage: G.circled_entries() 

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

""" 

ret = [] 

for i in range(1, len(self)): 

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

if self[i][j] == self[i-1][j+1]: 

ret.append((i, j)) 

return tuple(ret) 

 

@cached_method 

def special_entries(self): 

""" 

Return the special entries. 

 

An entry `a_{i,j}` is special if `a_{i-1,j-1} > a_{i,j} > a_{i-1,j}`, 

that is to say, the entry is neither boxed nor circled and is **not** 

in the first row. The name was coined by [Tok88]_. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[3,2,1],[3,1],[1]]) 

sage: G.special_entries() 

() 

sage: G = GelfandTsetlinPattern([[4,2,1],[4,1],[2]]) 

sage: G.special_entries() 

((2, 0),) 

""" 

ret = [] 

for i in range(1, len(self)): 

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

if self[i-1][j] > self[i][j] and self[i][j] > self[i-1][j+1]: 

ret.append((i, j)) 

return tuple(ret) 

 

def number_of_boxes(self): 

""" 

Return the number of boxed entries. See :meth:`boxed_entries()`. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[3,2,1],[3,1],[1]]) 

sage: G.number_of_boxes() 

1 

""" 

return len(self.boxed_entries()) 

 

def number_of_circles(self): 

""" 

Return the number of boxed entries. See :meth:`circled_entries()`. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[3,2,1],[3,1],[1]]) 

sage: G.number_of_circles() 

2 

""" 

return len(self.circled_entries()) 

 

def number_of_special_entries(self): 

""" 

Return the number of special entries. See :meth:`special_entries()`. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[4,2,1],[4,1],[2]]) 

sage: G.number_of_special_entries() 

1 

""" 

return len(self.special_entries()) 

 

def is_strict(self): 

""" 

Return ``True`` if ``self`` is a strict Gelfand-Tsetlin pattern. 

 

A Gelfand-Tsetlin pattern is said to be *strict* if every row is 

strictly decreasing. 

 

EXAMPLES:: 

 

sage: GelfandTsetlinPattern([[7,3,1],[6,2],[4]]).is_strict() 

True 

sage: GelfandTsetlinPattern([[3,2,1],[3,1],[1]]).is_strict() 

True 

sage: GelfandTsetlinPattern([[6,0,0],[3,0],[2]]).is_strict() 

False 

""" 

for row in self: 

if any(row[i] == row[i+1] for i in range(len(row)-1)): 

return False 

return True 

 

def row_sums(self): 

r""" 

Return the list of row sums. 

 

For a Gelfand-Tsetlin pattern `G`, the `i`-th row sum `d_i` is 

 

.. MATH:: 

 

d_i = d_i(G) = \sum_{j=i}^{n} a_{i,j}. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[5,3,2,1,0],[4,3,2,0],[4,2,1],[3,2],[3]]) 

sage: G.row_sums() 

[11, 9, 7, 5, 3] 

sage: G = GelfandTsetlinPattern([[3,2,1],[3,1],[2]]) 

sage: G.row_sums() 

[6, 4, 2] 

""" 

return [sum(self[i][j] for j in range(len(self[i]))) \ 

for i in range(len(self))] 

 

def weight(self): 

r""" 

Return the weight of ``self``. 

 

Define the weight of `G` to be the content of the tableau to which `G` 

corresponds under the bijection between Gelfand-Tsetlin patterns and 

semistandard tableaux. More precisely, 

 

.. MATH:: 

 

\mathrm{wt}(G) = (d_n, d_{n-1}-d_n, \dots, d_1-d_2), 

 

where the `d_i` are the row sums. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPattern([[2,1,0],[1,0],[1]]) 

sage: G.weight() 

(1, 0, 2) 

sage: G = GelfandTsetlinPattern([[4,2,1],[3,1],[2]]) 

sage: G.weight() 

(2, 2, 3) 

""" 

wt = [self.row_sums()[-1]] + [self.row_sums()[i-1]-self.row_sums()[i] for i in reversed(range(1,len(self[0])))] 

return tuple(wt) 

 

def Tokuyama_coefficient(self, name='t'): 

r""" 

Return the Tokuyama coefficient attached to ``self``. 

 

Following the exposition of [BBF]_, Tokuyama's formula asserts 

 

.. MATH:: 

 

\sum_{G} (t+1)^{s(G)} t^{l(G)} 

z_1^{d_{n+1}} z_2^{d_{n}-d_{n+1}} \cdots z_{n+1}^{d_1-d_2} 

= 

s_{\lambda}(z_1,\dots,z_{n+1}) \prod_{i<j} (z_j+tz_i), 

 

where the sum is over all strict Gelfand-Tsetlin patterns with fixed 

top row `\lambda + \rho`, with `\lambda` a partition with at most 

`n+1` parts and `\rho = (n, n-1, \ldots, 1, 0)`, and `s_\lambda` is a 

Schur function. 

 

INPUT: 

 

- ``name`` -- (Default: ``'t'``) An alternative name for the 

variable `t`. 

 

EXAMPLES:: 

 

sage: P = GelfandTsetlinPattern([[3,2,1],[2,2],[2]]) 

sage: P.Tokuyama_coefficient() 

0 

sage: G = GelfandTsetlinPattern([[3,2,1],[3,1],[2]]) 

sage: G.Tokuyama_coefficient() 

t^2 + t 

sage: G = GelfandTsetlinPattern([[2,1,0],[1,1],[1]]) 

sage: G.Tokuyama_coefficient() 

0 

sage: G = GelfandTsetlinPattern([[5,3,2,1,0],[4,3,2,0],[4,2,1],[3,2],[3]]) 

sage: G.Tokuyama_coefficient() 

t^8 + 3*t^7 + 3*t^6 + t^5 

""" 

R = PolynomialRing(ZZ, name) 

t = R.gen(0) 

if not self.is_strict(): 

return R.zero() 

return (t+1)**(self.number_of_special_entries()) * t**(self.number_of_boxes()) 

 

 

class GelfandTsetlinPatterns(UniqueRepresentation, Parent): 

""" 

Gelfand-Tsetlin patterns. 

 

INPUT: 

 

- ``n`` -- The width or depth of the array, also known as the rank 

 

- ``k`` -- (Default: ``None``) If specified, this is the maximum value that 

can occur in the patterns 

 

- ``top_row`` -- (Default: ``None``) If specified, this is the fixed top 

row of all patterns 

 

- ``strict`` -- (Default: ``False``) Set to ``True`` if all patterns are 

strict patterns 

 

TESTS: 

 

Check that the number of Gelfand-Tsetlin patterns is equal to the number 

of semistandard Young tableaux:: 

 

sage: G = GelfandTsetlinPatterns(3,3) 

sage: c = 0 

sage: from sage.combinat.crystals.kirillov_reshetikhin import partitions_in_box 

sage: for p in partitions_in_box(3,3): 

....: S = SemistandardTableaux(p, max_entry=3) 

....: c += S.cardinality() 

sage: c == G.cardinality() 

True 

 

Note that the top row in reverse of the Gelfand-Tsetlin pattern is the 

shape of the corresponding semistandard Young tableau under the bijection 

described in :meth:`GelfandTsetlinPattern.to_tableau()`:: 

 

sage: G = GelfandTsetlinPatterns(top_row=[2,2,1]) 

sage: S = SemistandardTableaux([2,2,1], max_entry=3) 

sage: G.cardinality() == S.cardinality() 

True 

""" 

@staticmethod 

def __classcall_private__(cls, n=None, k=None, strict=False, top_row=None): 

""" 

Return the correct parent based upon the inputs. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: G2 = GelfandTsetlinPatterns() 

sage: G is G2 

True 

sage: G = GelfandTsetlinPatterns(3,4, strict=True) 

sage: G2 = GelfandTsetlinPatterns(int(3),int(4), strict=True) 

sage: G is G2 

True 

sage: G = GelfandTsetlinPatterns(top_row=[3,1,1]) 

sage: G2 = GelfandTsetlinPatterns(top_row=(3,1,1)) 

sage: G is G2 

True 

""" 

if top_row is not None: 

top_row = tuple(top_row) 

if any(top_row[i] < top_row[i+1] for i in range(len(top_row)-1)): 

raise ValueError("The top row must be weakly decreasing") 

if n is not None and n != len(top_row): 

raise ValueError("n must be the length of the specified top row") 

return GelfandTsetlinPatternsTopRow(top_row, strict) 

return super(GelfandTsetlinPatterns, cls).__classcall__(cls, n, k, strict) 

 

def __init__(self, n, k, strict): 

""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: TestSuite(G).run() 

sage: G = GelfandTsetlinPatterns(3) 

sage: TestSuite(G).run() 

sage: G = GelfandTsetlinPatterns(3, 3) 

sage: TestSuite(G).run() 

sage: G = GelfandTsetlinPatterns(3, 3, strict=True) 

sage: TestSuite(G).run() 

""" 

self._n = n 

self._k = k 

self._strict = strict 

# Note - if a top row is given, then n and k are not None 

if k is not None and (n is not None or strict): 

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

else: 

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

 

def __contains__(self, gt): 

""" 

Check to see if ``gt`` is in ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns() 

sage: [[3, 1],[2]] in G 

True 

sage: [[2, 3],[4]] in G 

False 

sage: [[3, 1],[0]] in G 

False 

sage: [] in G 

True 

sage: G = GelfandTsetlinPatterns(3,2) 

sage: [] in G 

False 

sage: [[2,0,0],[1,0],[1]] in G 

True 

sage: [[0,0],[0]] in G 

False 

sage: [[3,0,0],[2,0],[0]] in G 

False 

sage: G = GelfandTsetlinPatterns(3,strict=True) 

sage: [[2,1,0],[2,1],[1]] in G 

True 

sage: [[3,0,0],[3,0],[0]] in G 

False 

""" 

if not isinstance(gt, (list, tuple, GelfandTsetlinPattern)): 

return False 

# Check if it has the correct width/depth (if applicable) 

if self._n is not None and len(gt) != self._n: 

return False 

# Check if it has the correct maximum value 

if self._k is not None and any( val > self._k for row in gt for val in row ): 

return False 

# Check if it is a GT pattern 

if not all( gt[i-1][j] >= gt[i][j] >= gt[i-1][j+1] 

for i in range(1, len(gt)) for j in range(len(gt[i])) ): 

return False 

# Check if it is strict if applicable 

if self._strict and any( gt[i][j] == gt[i][j-1] for i in range(len(gt)) 

for j in range(1, len(gt[i])) ): 

return False 

return True 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: GelfandTsetlinPatterns(4) 

Gelfand-Tsetlin patterns of width 4 

sage: GelfandTsetlinPatterns(4, 3, strict=True) 

Strict Gelfand-Tsetlin patterns of width 4 and max value 3 

sage: G = GelfandTsetlinPatterns(k=3, strict=True); G 

Strict Gelfand-Tsetlin patterns with max value 3 

""" 

base = "Gelfand-Tsetlin patterns" 

if self._strict: 

base = "Strict " + base 

if self._n is not None: 

if self._k is not None: 

return base + " of width %s and max value %s"%(self._n, self._k) 

return base + " of width %s"%self._n 

if self._k is not None: 

return base + " with max value %s"%self._k 

return base 

 

def _element_constructor_(self, gt): 

""" 

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

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(3, 3, strict=True); G 

Strict Gelfand-Tsetlin patterns of width 3 and max value 3 

sage: elt = G([[3,2,1],[2,1],[1]]); elt.pp() 

3 2 1 

2 1 

1 

sage: elt.parent() 

Strict Gelfand-Tsetlin patterns of width 3 and max value 3 

""" 

if isinstance(gt, GelfandTsetlinPattern) and gt.parent() == self: 

return gt 

if isinstance(gt, Tableau): 

gt = [list(x) for x in reversed(gt.to_chain()[1:])] 

n = len(gt) 

for i in range(n): 

while len(gt[i]) < n-i: 

gt[i].append(0) 

if self._n is not None: 

if len(gt) == 0: 

gt = [[0]] 

while self._n != len(gt): 

gt.insert(0, gt[0][:] + [0]) 

return self.element_class(self, gt) 

return self.element_class(self, list(gt)) 

 

Element = GelfandTsetlinPattern 

 

def __iter__(self): 

""" 

Iterate through ``self`` by using a backtracing algorithm. 

 

EXAMPLES:: 

 

sage: L = list(GelfandTsetlinPatterns(3,3)) 

sage: c = 0 

sage: from sage.combinat.crystals.kirillov_reshetikhin import partitions_in_box 

sage: for p in partitions_in_box(3,3): 

....: S = SemistandardTableaux(p, max_entry=3) 

....: c += S.cardinality() 

sage: c == len(L) 

True 

sage: G = GelfandTsetlinPatterns(3, 3, strict=True) 

sage: all(x.is_strict() for x in G) 

True 

sage: G = GelfandTsetlinPatterns(k=3, strict=True) 

sage: all(x.is_strict() for x in G) 

True 

 

Checking iterator when the set is infinite:: 

 

sage: T = GelfandTsetlinPatterns() 

sage: it = T.__iter__() 

sage: [next(it) for i in range(10)] 

[[], 

[[1]], 

[[2]], 

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

[[3]], 

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

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

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

[[4]], 

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

sage: T = GelfandTsetlinPatterns(k=1) 

sage: it = T.__iter__() 

sage: [next(it) for i in range(10)] 

[[], 

[[0]], 

[[1]], 

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

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

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

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

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

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

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

 

Check that :trac:`14718` is fixed:: 

 

sage: T = GelfandTsetlinPatterns(1,3) 

sage: list(T) 

[[[0]], 

[[1]], 

[[2]], 

[[3]]] 

""" 

# Special cases 

if self._n is None: 

yield self.element_class(self, []) 

if self._k is None: 

# Since both `n` and `k` are none, we need special consideration 

# while iterating, so we do so by specifying the top row by 

# using the iterator for partitions 

n = 1 

while True: 

if self._strict: 

P = Partitions(n, max_slope=-1) 

else: 

P = Partitions(n) 

for p in P: 

for x in GelfandTsetlinPatterns(top_row=tuple(p), strict=self._strict): 

yield self.element_class(self, list(x)) 

n += 1 

return 

for x in range(self._k+1): 

yield self.element_class(self, [[x]]) 

n = 2 

while not self._strict or n <= self._k+1: 

for x in self._list_iter(n): 

yield self.element_class(self, x) 

n += 1 

return 

if self._n < 0: 

return 

if self._n == 0: 

yield self.element_class(self, []) 

return 

if self._n == 1: 

if self._k is not None: 

for x in range(self._k+1): 

yield self.element_class(self, [[x]]) 

else: 

k = 1 

while True: 

yield self.element_class(self, [[k]]) 

k += 1 

return 

for x in self._list_iter(self._n): 

yield self.element_class(self, x) 

 

def _list_iter(self, n): 

""" 

Fast iterator which returns Gelfand-Tsetlin patterns of width ``n`` as 

lists of lists. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(3, 1) 

sage: L = [x for x in G._list_iter(3)] 

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

True 

sage: type(L[0]) 

<... 'list'> 

""" 

# Setup the first row 

iters = [None]*n 

ret = [None]*n 

iters[0] = self._top_row_iter(n) 

ret[0] = next(iters[0]) 

min_pos = 0 

iters[1] = self._row_iter(ret[0]) 

pos = 1 

while pos >= min_pos: 

try: 

ret[pos] = next(iters[pos]) 

pos += 1 

# If we've reached 0 width, yield and backstep 

if pos == n: 

yield ret[:] 

pos -= 1 

continue 

iters[pos] = self._row_iter(ret[pos-1]) 

except StopIteration: 

pos -= 1 

 

def _top_row_iter(self, n): 

""" 

Helper iterator for the top row. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(3, 1) 

sage: for x in G._top_row_iter(3): x 

[0, 0, 0] 

[1, 0, 0] 

[1, 1, 0] 

[1, 1, 1] 

sage: G = GelfandTsetlinPatterns(3, 2, strict=True) 

sage: for x in G._top_row_iter(3): x 

[2, 1, 0] 

""" 

row = [-1]*n 

pos = 0 

while pos >= 0: 

if pos == n: 

yield row[:] 

pos -= 1 

continue 

# If it would create an invalid entry, backstep 

if ( pos > 0 and (row[pos] >= row[pos-1] \ 

or (self._strict and row[pos] == row[pos-1]-1)) ) \ 

or (self._k is not None and row[pos] >= self._k): 

row[pos] = -1 

pos -= 1 

continue 

row[pos] += 1 

pos += 1 

 

def _row_iter(self, upper_row): 

""" 

Helper iterator for any row with a row above it. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(3, 4) 

sage: for x in G._row_iter([4,2,1]): x 

[2, 1] 

[2, 2] 

[3, 1] 

[3, 2] 

[4, 1] 

[4, 2] 

sage: G = GelfandTsetlinPatterns(3, 2, strict=True) 

sage: for x in G._row_iter([2, 1, 0]): x 

[1, 0] 

[2, 0] 

[2, 1] 

""" 

row = [x-1 for x in upper_row[1:]] 

row_len = len(row) 

pos = 0 

while pos >= 0: 

if pos == row_len: 

yield row[:] 

pos -= 1 

continue 

# If it would create an invalid entry, backstep 

if ( pos > 0 and (row[pos] >= row[pos-1] \ 

or (self._strict and row[pos] == row[pos-1]-1)) ) \ 

or row[pos] >= upper_row[pos] \ 

or (self._k is not None and row[pos] >= self._k): 

row[pos] = upper_row[pos+1] - 1 

pos -= 1 

continue 

row[pos] += 1 

pos += 1 

 

def _toggle_markov_chain(self, chain_state, row, col, direction): 

""" 

Helper for coupling from the past. Advance the Markov chain one step. 

 

INPUT: 

 

- ``chain_state`` -- A GelfandTsetlin pattern represented as a list of lists 

- ``row`` -- The row of the cell being modified 

- ``col`` -- The column of the cell being modified 

- ``direction`` -- The direction to change the cell 1 = increase, 0 = decrease 

 

OUTPUT: 

 

``chain_state`` is possibly modified. 

 

TESTS: 

 

sage: G=GelfandTsetlinPatterns(3,4) 

sage: state = [[3,2,1],[3,1],[2]] 

sage: G._toggle_markov_chain(state, 0, 0, 1) 

sage: state 

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

sage: G._toggle_markov_chain(state, 1, 1, 1) 

sage: state 

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

sage: G._toggle_markov_chain(state, 0, 2, 1) 

sage: state 

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

sage: G._toggle_markov_chain(state, 0, 2, 1) 

sage: state 

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

sage: G._toggle_markov_chain(state, 0, 2, 0) 

sage: state 

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

sage: G._toggle_markov_chain(state, 0, 2, 0) 

sage: state 

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

sage: G._toggle_markov_chain(state, 0, 2, 0) 

sage: state 

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

 

""" 

if direction == 1: 

upbound = self._k 

if row != 0: 

upbound = min(upbound, chain_state[row - 1][col]) 

if self._strict and col > 0: 

upbound = min(upbound, chain_state[row][col - 1] - 1) 

if row < self._n and col > 0: 

upbound = min(upbound, chain_state[row + 1][col - 1]) 

if chain_state[row][col] < upbound: 

chain_state[row][col] += 1 

else: 

lobound = 0 

if row != 0: 

lobound = max(lobound, chain_state[row - 1][col + 1]) 

if self._strict and col < self._n - row - 1: 

lobound = max(lobound, chain_state[row][col + 1] + 1) 

if row < self._n and col < self._n - row - 1: 

lobound = max(lobound, chain_state[row + 1][col]) 

if chain_state[row][col] > lobound: 

chain_state[row][col] -= 1 

 

 

def _cftp_upper(self): 

""" 

Return the largest member of the poset of Gelfand-Tsetlin patterns having the given ``n`` and ``k``. 

 

TESTS: 

 

sage: GelfandTsetlinPatterns(3, 5)._cftp_upper() 

[[5, 5, 5], [5, 5], [5]] 

sage: GelfandTsetlinPatterns(3, 5, strict=True)._cftp_upper() 

[[5, 4, 3], [5, 4], [5]] 

""" 

if self._strict: 

return [[self._k - j for j in range(self._n - i)] for i in range(self._n)] 

else: 

return [[self._k for j in range(self._n - i)] for i in range(self._n)] 

 

def _cftp_lower(self): 

""" 

Return the smallest member of the poset of Gelfand-Tsetlin patterns having the given ``n`` and ``k``. 

 

TESTS: 

 

sage: GelfandTsetlinPatterns(3, 5)._cftp_lower() 

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

sage: GelfandTsetlinPatterns(3, 5, strict=True)._cftp_lower() 

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

""" 

if self._strict: 

return [[self._n - j - i - 1 for j in range(self._n - i)] for i in range(self._n)] 

else: 

return [[0 for j in range(self._n - i)] for i in range(self._n)] 

 

def _cftp(self, start_row): 

""" 

Implement coupling from the past. 

 

ALGORITHM: 

 

The set of Gelfand-Tsetlin patterns can partially ordered by 

elementwise domination. The partial order has unique maximum 

and minimum elements that are computed by the methods 

:meth:`_cftp_upper` and :meth:`_cftp_lower`. We then run the Markov 

chain that randomly toggles each element up or down from the 

past until the state reached from the upper and lower start 

points coalesce as described in [Propp1997]_. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(3, 5) 

sage: G._cftp(0) # random 

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

sage: G._cftp(0) in G 

True 

""" 

from sage.misc.randstate import current_randstate 

from sage.misc.randstate import seed 

from sage.misc.randstate import random 

 

count = self._n * self._k 

seedlist = [(current_randstate().long_seed(), count)] 

upper = [] 

lower = [] 

while True: 

upper = self._cftp_upper() 

lower = self._cftp_lower() 

for currseed, count in seedlist: 

with seed(currseed): 

for _ in range(count): 

for row in range(start_row, self._n): 

for col in range(self._n - row): 

direction = random() % 2 

self._toggle_markov_chain(upper, row, col, direction) 

self._toggle_markov_chain(lower, row, col, direction) 

if all(all(x == y for x,y in zip(l1, l2)) for l1, l2 in zip(upper, lower)): 

break 

count = seedlist[0][1] * 2 

seedlist.insert(0, (current_randstate().long_seed(), count)) 

return GelfandTsetlinPattern(upper) 

 

def random_element(self): 

""" 

Return a uniformly random Gelfand-Tsetlin pattern. 

 

EXAMPLES:: 

 

sage: g = GelfandTsetlinPatterns(4, 5) 

sage: g.random_element() 

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

sage: g = GelfandTsetlinPatterns(4, 5, strict=True) 

sage: g.random_element() 

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

""" 

if self._n is not None and self._k is not None: 

if self._strict and self._k+1 < self._n: 

raise ValueError('Cannot sample from empty set') 

elif self._k < 0: 

raise ValueError('Cannot sample from empty set') 

else: 

return self._cftp(0) 

else: 

raise ValueError('Cannot sample from infinite set') 

 

class GelfandTsetlinPatternsTopRow(GelfandTsetlinPatterns): 

""" 

Gelfand-Tsetlin patterns with a fixed top row. 

""" 

def __init__(self, top_row, strict): 

""" 

Initialize ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(top_row=[4,4,3,1]) 

sage: TestSuite(G).run() 

 

TESTS: 

 

Check a border case in :trac:`14765`:: 

 

sage: G = GelfandTsetlinPatterns(top_row=[]) 

sage: list(G) 

[[]] 

""" 

self._row = top_row 

n = len(top_row) 

if n == 0: 

k = 0 

else: 

k = top_row[0] 

GelfandTsetlinPatterns.__init__(self, n, k, strict) 

 

def _repr_(self): 

""" 

Return a string representation of ``self``. 

 

EXAMPLES:: 

 

sage: GelfandTsetlinPatterns(top_row=[4,4,3,1]) 

Gelfand-Tsetlin patterns with top row [4, 4, 3, 1] 

sage: GelfandTsetlinPatterns(top_row=[5,4,3,1], strict=True) 

Strict Gelfand-Tsetlin patterns with top row [5, 4, 3, 1] 

""" 

base = "Gelfand-Tsetlin patterns with top row %s"%list(self._row) 

if self._strict: 

base = "Strict " + base 

return base 

 

def __contains__(self, gt): 

""" 

Check if ``gt`` is in ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(top_row=[4,4,1]) 

sage: [[4,4,1], [4,2], [3]] in G 

True 

sage: [[4,3,1], [4,2], [3]] in G 

False 

""" 

# Check if the top row matches (if applicable) 

if gt and tuple(gt[0]) != self._row: 

return False 

return GelfandTsetlinPatterns.__contains__(self, gt) 

 

def __iter__(self): 

""" 

Iterate over ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(top_row=[4,2,1]) 

sage: list(G) 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

""" 

# If we enforce strictness, check to see if a specified top row is strict 

if self._strict and any(self._row[i] == self._row[i+1] for i in range(self._n-1)): 

return 

if self._n == 0: 

yield self.element_class(self, []) 

return 

if self._n == 1: 

yield self.element_class(self, [list(self._row)]) 

return 

# Setup the first row 

iters = [None]*self._n 

ret = [None]*self._n 

ret[0] = list(self._row) 

min_pos = 1 

iters[1] = self._row_iter(ret[0]) 

pos = 1 

while pos >= min_pos: 

try: 

ret[pos] = next(iters[pos]) 

pos += 1 

# If we've reached 0 width, yield and backstep 

if pos == self._n: 

yield self.element_class(self, ret[:]) 

pos -= 1 

continue 

iters[pos] = self._row_iter(ret[pos-1]) 

except StopIteration: 

pos -= 1 

 

def top_row(self): 

""" 

Return the top row of ``self``. 

 

EXAMPLES:: 

 

sage: G = GelfandTsetlinPatterns(top_row=[4,4,3,1]) 

sage: G.top_row() 

(4, 4, 3, 1) 

""" 

return self._row 

 

def Tokuyama_formula(self, name='t'): 

r""" 

Return the Tokuyama formula of ``self``. 

 

Following the exposition of [BBF]_, Tokuyama's formula asserts 

 

.. MATH:: 

 

\sum_{G} (t+1)^{s(G)} t^{l(G)} 

z_1^{d_{n+1}} z_2^{d_{n}-d_{n+1}} \cdots z_{n+1}^{d_1-d_2} 

= s_{\lambda} (z_1, \ldots, z_{n+1}) \prod_{i<j} (z_j+tz_i), 

 

where the sum is over all strict Gelfand-Tsetlin patterns with fixed 

top row `\lambda+\rho`, with `\lambda` a partition with at most 

`n+1` parts and `\rho = (n,n-1,\dots,1,0)`, and `s_{\lambda}` is a Schur 

function. 

 

INPUT: 

 

- ``name`` -- (Default: ``'t'``) An alternative name for the 

variable `t`. 

 

EXAMPLES:: 

 

sage: GT = GelfandTsetlinPatterns(top_row=[2,1,0],strict=True) 

sage: GT.Tokuyama_formula() 

t^3*x1^2*x2 + t^2*x1*x2^2 + t^2*x1^2*x3 + t^2*x1*x2*x3 + t*x1*x2*x3 + t*x2^2*x3 + t*x1*x3^2 + x2*x3^2 

sage: GT = GelfandTsetlinPatterns(top_row=[3,2,1],strict=True) 

sage: GT.Tokuyama_formula() 

t^3*x1^3*x2^2*x3 + t^2*x1^2*x2^3*x3 + t^2*x1^3*x2*x3^2 + t^2*x1^2*x2^2*x3^2 + t*x1^2*x2^2*x3^2 + t*x1*x2^3*x3^2 + t*x1^2*x2*x3^3 + x1*x2^2*x3^3 

sage: GT = GelfandTsetlinPatterns(top_row=[1,1,1],strict=True) 

sage: GT.Tokuyama_formula() 

0 

""" 

n = self._n 

variables = [name] + ["x%d"%i for i in range(1,n+1)] 

R = PolynomialRing(ZZ,names=variables) 

t = R.gen(0) 

x = R.gens()[1:] 

GT = GelfandTsetlinPatterns(top_row=self._row, strict=True) 

return sum((t+1)**(gt.number_of_special_entries()) * t**(gt.number_of_boxes()) * prod(x[i]**gt.weight()[i] for i in range(n)) for gt in GT) 

 

def _cftp_upper(self): 

""" 

Return the largest member of the poset of Gelfand-Tsetlin patterns having the given ``top_row``. 

 

TESTS: 

 

sage: GelfandTsetlinPatterns(top_row = [5, 4, 3])._cftp_upper() 

[[5, 4, 3], [5, 4], [5]] 

""" 

return [[self._row[j] for j in range(self._n - i)] for i in range(self._n)] 

 

def _cftp_lower(self): 

""" 

Return the smallest member of the poset of Gelfand-Tsetlin patterns having the given ``top_row``. 

 

TESTS: 

 

sage: GelfandTsetlinPatterns(top_row = [5, 4, 3])._cftp_lower() 

[[5, 4, 3], [4, 3], [3]] 

""" 

return [[self._row[i + j] for j in range(self._n - i)] for i in range(self._n)] 

 

def random_element(self): 

""" 

Return a uniformly random Gelfand-Tsetlin pattern with specified top row. 

 

EXAMPLES:: 

 

sage: g = GelfandTsetlinPatterns(top_row = [4, 3, 1, 1]) 

sage: g.random_element() 

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

sage: g = GelfandTsetlinPatterns(top_row=[4, 3, 2, 1], strict=True) 

sage: g.random_element() 

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

""" 

if self._strict: 

return self._cftp(1) 

else: 

l = [i for i in self._row if i > 0] 

return SemistandardTableaux(l, max_entry=self._n).random_element().to_Gelfand_Tsetlin_pattern()