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

r""" 

Common combinatorial tools 

 

 

REFERENCES: 

 

.. [NCSF] Gelfand, Krob, Lascoux, Leclerc, Retakh, Thibon, 

*Noncommutative Symmetric Functions*, Adv. Math. 112 (1995), no. 2, 218-348. 

 

.. [QSCHUR] Haglund, Luoto, Mason, van Willigenburg, 

*Quasisymmetric Schur functions*, J. Comb. Theory Ser. A 118 (2011), 463-490. 

http://www.sciencedirect.com/science/article/pii/S0097316509001745 , 

:arXiv:`0810.2489v2`. 

 

.. [Tev2007] Lenny Tevlin, 

*Noncommutative Analogs of Monomial Symmetric Functions, 

Cauchy Identity, and Hall Scalar Product*, 

:arXiv:`0712.2201v1`. 

""" 

from sage.misc.misc_c import prod 

from sage.functions.other import factorial 

from sage.misc.cachefunc import cached_function 

from sage.combinat.composition import Composition, Compositions 

from sage.combinat.composition_tableau import CompositionTableaux 

from sage.rings.all import ZZ 

 

 

# The following might call for defining a morphism from ``structure 

# coefficients'' / matrix using something like: 

# Complete.module_morphism( coeff = coeff_pi, codomain=Psi, triangularity="finer" ) 

# the difficulty is how to best describe the support of the output. 

 

def coeff_pi(J,I): 

r""" 

Returns the coefficient `\pi_{J,I}` as defined in [NCSF]_. 

 

INPUT: 

 

- ``J`` -- a composition 

- ``I`` -- a composition refining ``J`` 

 

OUTPUT: 

 

- integer 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import coeff_pi 

sage: coeff_pi(Composition([1,1,1]), Composition([2,1])) 

2 

sage: coeff_pi(Composition([2,1]), Composition([3])) 

6 

""" 

return prod(prod(K.partial_sums()) for K in J.refinement_splitting(I)) 

 

def coeff_lp(J,I): 

r""" 

Returns the coefficient `lp_{J,I}` as defined in [NCSF]_. 

 

INPUT: 

 

- ``J`` -- a composition 

- ``I`` -- a composition refining ``J`` 

 

OUTPUT: 

 

- integer 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import coeff_lp 

sage: coeff_lp(Composition([1,1,1]), Composition([2,1])) 

1 

sage: coeff_lp(Composition([2,1]), Composition([3])) 

1 

""" 

return prod(K[-1] for K in J.refinement_splitting(I)) 

 

def coeff_ell(J,I): 

r""" 

Returns the coefficient `\ell_{J,I}` as defined in [NCSF]_. 

 

INPUT: 

 

- ``J`` -- a composition 

- ``I`` -- a composition refining ``J`` 

 

OUTPUT: 

 

- integer 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import coeff_ell 

sage: coeff_ell(Composition([1,1,1]), Composition([2,1])) 

2 

sage: coeff_ell(Composition([2,1]), Composition([3])) 

2 

""" 

return prod([len(_) for _ in J.refinement_splitting(I)]) 

 

def coeff_sp(J,I): 

r""" 

Returns the coefficient `sp_{J,I}` as defined in [NCSF]_. 

 

INPUT: 

 

- ``J`` -- a composition 

- ``I`` -- a composition refining ``J`` 

 

OUTPUT: 

 

- integer 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import coeff_sp 

sage: coeff_sp(Composition([1,1,1]), Composition([2,1])) 

2 

sage: coeff_sp(Composition([2,1]), Composition([3])) 

4 

""" 

return prod(factorial(len(K))*prod(K) for K in J.refinement_splitting(I)) 

 

def coeff_dab(I, J): 

r""" 

Return the number of standard composition tableaux of shape `I` with 

descent composition `J`. 

 

INPUT: 

 

- ``I, J`` -- compositions 

 

OUTPUT: 

 

- An integer 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import coeff_dab 

sage: coeff_dab(Composition([2,1]),Composition([2,1])) 

1 

sage: coeff_dab(Composition([1,1,2]),Composition([1,2,1])) 

0 

""" 

d = 0 

for T in CompositionTableaux(I): 

if (T.is_standard()) and (T.descent_composition() == J): 

d += 1 

return d 

 

def compositions_order(n): 

r""" 

Return the compositions of `n` ordered as defined in [QSCHUR]_. 

 

Let `S(\gamma)` return the composition `\gamma` after sorting. For 

compositions `\alpha` and `\beta`, we order `\alpha \rhd \beta` if 

 

1) `S(\alpha) > S(\beta)` lexicographically, or 

2) `S(\alpha) = S(\beta)` and `\alpha > \beta` lexicographically. 

 

INPUT: 

 

- ``n`` -- a positive integer 

 

OUTPUT: 

 

- A list of the compositions of ``n`` sorted into decreasing order 

by `\rhd` 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import compositions_order 

sage: compositions_order(3) 

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

sage: compositions_order(4) 

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

""" 

def _keyfunction(I): 

return sorted(I, reverse=True), list(I) 

return sorted(Compositions(n), key=_keyfunction, reverse=True) 

 

def m_to_s_stat(R, I, K): 

r""" 

Return the coefficient of the complete non-commutative symmetric 

function `S^K` in the expansion of the monomial non-commutative 

symmetric function `M^I` with respect to the complete basis 

over the ring `R`. This is the coefficient in formula (36) of 

Tevlin's paper [Tev2007]_. 

 

INPUT: 

 

- ``R`` -- A ring, supposed to be a `\QQ`-algebra 

- ``I``, ``K`` -- compositions 

 

OUTPUT: 

 

- The coefficient of `S^K` in the expansion of `M^I` in the 

complete basis of the non-commutative symmetric functions 

over ``R``. 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import m_to_s_stat 

sage: m_to_s_stat(QQ, Composition([2,1]), Composition([1,1,1])) 

-1 

sage: m_to_s_stat(QQ, Composition([3]), Composition([1,2])) 

-2 

sage: m_to_s_stat(QQ, Composition([2,1,2]), Composition([2,1,2])) 

8/3 

""" 

stat = 0 

for J in Compositions(I.size()): 

if (I.is_finer(J) and K.is_finer(J)): 

pvec = [0] + Composition(I).refinement_splitting_lengths(J).partial_sums() 

pp = prod( R( len(I) - pvec[i] ) for i in range( len(pvec)-1 ) ) 

stat += R((-1)**(len(I)-len(K)) / pp * coeff_lp(K,J)) 

return stat 

 

@cached_function 

def number_of_fCT(content_comp, shape_comp): 

r""" 

Return the number of Immaculate tableaux of shape 

``shape_comp`` and content ``content_comp``. 

 

See [BBSSZ2012]_, Definition 3.9, for the notion of an 

immaculate tableau. 

 

INPUT: 

 

- ``content_comp``, ``shape_comp`` -- compositions 

 

OUTPUT: 

 

- An integer 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import number_of_fCT 

sage: number_of_fCT(Composition([3,1]), Composition([1,3])) 

0 

sage: number_of_fCT(Composition([1,2,1]), Composition([1,3])) 

1 

sage: number_of_fCT(Composition([1,1,3,1]), Composition([2,1,3])) 

2 

""" 

if content_comp.to_partition().length() == 1: 

if shape_comp.to_partition().length() == 1: 

return 1 

else: 

return 0 

C = Compositions(content_comp.size()-content_comp[-1], outer = list(shape_comp)) 

s = 0 

for x in C: 

if len(x) >= len(shape_comp)-1: 

s += number_of_fCT(Composition(content_comp[:-1]),x) 

return s 

 

@cached_function 

def number_of_SSRCT(content_comp, shape_comp): 

r""" 

The number of semi-standard reverse composition tableaux. 

 

The dual quasisymmetric-Schur functions satisfy a left Pieri rule 

where `S_n dQS_\gamma` is a sum over dual quasisymmetric-Schur 

functions indexed by compositions which contain the composition 

`\gamma`. The definition of an SSRCT comes from this rule. The 

number of SSRCT of content `\beta` and shape `\alpha` is equal to 

the number of SSRCT of content `(\beta_2, \ldots, \beta_\ell)` 

and shape `\gamma` where `dQS_\alpha` appears in the expansion of 

`S_{\beta_1} dQS_\gamma`. 

 

In sage the recording tableau for these objects are called 

:class:`~sage.combinat.composition_tableau.CompositionTableaux`. 

 

INPUT: 

 

- ``content_comp``, ``shape_comp`` -- compositions 

 

OUTPUT: 

 

- An integer 

 

EXAMPLES:: 

 

sage: from sage.combinat.ncsf_qsym.combinatorics import number_of_SSRCT 

sage: number_of_SSRCT(Composition([3,1]), Composition([1,3])) 

0 

sage: number_of_SSRCT(Composition([1,2,1]), Composition([1,3])) 

1 

sage: number_of_SSRCT(Composition([1,1,2,2]), Composition([3,3])) 

2 

sage: all(CompositionTableaux(be).cardinality() 

....: == sum(number_of_SSRCT(al,be)*binomial(4,len(al)) 

....: for al in Compositions(4)) 

....: for be in Compositions(4)) 

True 

""" 

if len(content_comp) == 1: 

if len(shape_comp) == 1: 

return ZZ.one() 

else: 

return ZZ.zero() 

s = ZZ.zero() 

cond = lambda al,be: all(al[j] <= be_val 

and not any(al[i] <= k and k <= be[i] 

for k in range(al[j], be_val) 

for i in range(j)) 

for j, be_val in enumerate(be)) 

C = Compositions(content_comp.size()-content_comp[0], 

inner=[1]*len(shape_comp), 

outer=list(shape_comp)) 

for x in C: 

if cond(x, shape_comp): 

s += number_of_SSRCT(Composition(content_comp[1:]), x) 

if shape_comp[0] <= content_comp[0]: 

C = Compositions(content_comp.size()-content_comp[0], 

inner=[min(val, shape_comp[0]+1) 

for val in shape_comp[1:]], 

outer=shape_comp[1:]) 

Comps = Compositions() 

for x in C: 

if cond([shape_comp[0]]+list(x), shape_comp): 

s += number_of_SSRCT(Comps(content_comp[1:]), x) 

return s