Ticket #14111: trac_14111qsym_tutorialreviewts.patch
File trac_14111qsym_tutorialreviewts.patch, 16.3 KB (added by , 8 years ago) 


sage/combinat/ncsf_qsym/__init__.py
# HG changeset patch # User Travis Scrimshaw <tscrim@ucdavis.edu> # Date 1362169656 28800 # Node ID 150d27ffba76327f76023478cee7addf5b690dc8 # Parent b7d846049591f3fb81f8be2f0bd981e7ca85698d #14111: Review patch for QSym tutorial. diff git a/sage/combinat/ncsf_qsym/__init__.py b/sage/combinat/ncsf_qsym/__init__.py
a b 1 import tutorial 
sage/combinat/ncsf_qsym/tutorial.py
diff git a/sage/combinat/ncsf_qsym/tutorial.py b/sage/combinat/ncsf_qsym/tutorial.py old mode 100755 new mode 100644
a b 1 1# * coding: utf8 *1 # * coding: utf8 * 2 2 r""" 3 ===================================== 4 Tutorial for Quasisymmetric Functions 5 ===================================== 3 Introduction to Quasisymmetric Functions 6 4 7 In this document we briefly explain the quasisymmetric function bases and related functionality in Sage. We assume the reader is familar with the package 8 :class:`SymmetricFunctions` 5 In this document we briefly explain the quasisymmetric function bases and 6 related functionality in Sage. We assume the reader is familar with the 7 package :class:`SymmetricFunctions`. 9 8 10 Quasisymmetric functions, denoted QSym, form a subring of the power11 series ring in countably many variables. QSymcontains the symmetric9 Quasisymmetric functions, denoted `QSym`, form a subring of the power 10 series ring in countably many variables. `QSym` contains the symmetric 12 11 functions. These functions first arose in the theory of 13 $P$partitions. The initial ideas in this field are attributed to14 MacMahon, Knuth, Kreweras, Glâffrwd Thomas, Stanley. 12 `P`partitions. The initial ideas in this field are attributed to 13 MacMahon, Knuth, Kreweras, Glâffrwd Thomas, Stanley. In 1984, Gessel 15 14 formalized the study of quasisymmetric functions and introduced the 16 basis of fundamental quasisymmetric functions .In 1995, Gelfand,15 basis of fundamental quasisymmetric functions [Ges]_. In 1995, Gelfand, 17 16 Krob, Lascoux, Leclerc, Retakh, and Thibon showed that the ring of 18 17 quasisymmetric functions is Hopf dual to the noncommutative symmetric 19 functions . Many results have built on these.18 functions [NCSF]_. Many results have built on these. 20 19 21 22 23 One advantage of working in QSym is that many 24 interesting families of symmetric functions have explicit expansions 25 in fundamental quasisymmetric functions such as Schur functions 26 [Ges]_, Macdonald polynomials [HaimanHaglundLoehr], and plethysm of 27 Schur functions [LoehrWarrington]. 20 One advantage of working in `QSym` is that many interesting families of 21 symmetric functions have explicit expansions in fundamental quasisymmetric 22 functions such as Schur functions [Ges]_, Macdonald polynomials 23 [HHL05]_, and plethysm of Schur functions [LW12]_. 28 24 29 25 For more background see :wikipedia:`Quasisymmetric_function`. 30 26 … … numbers `\QQ`. Other options include th 41 37 sage: QSym = QuasiSymmetricFunctions(ZZ); QSym 42 38 Quasisymmetric functions over the Integer Ring 43 39 44 All bases of QSym are indexed by compositions e.g. `[3,1,1,4]`.The45 convention is to use capitol letters for bases of QSymand lowercase46 letters for bases of Sym. Next set up names for the known bases by running47 :meth:`QuasiSymmetricFunctions.inject_shorthands`. 48 As with symmetric functions, you do not need to run this commmand and 49 you could assign these bases other names.::40 All bases of `QSym` are indexed by compositions e.g. `[3,1,1,4]`. The 41 convention is to use capitol letters for bases of `QSym` and lowercase 42 letters for bases of the symmetric functions `Sym`. Next set up names for the 43 known bases by running ``inject_shorthands()``. As with symmetric functions, 44 you do not need to run this commmand and you could assign these bases other 45 names. :: 50 46 51 47 sage: QSym = QuasiSymmetricFunctions(QQ) 52 48 sage: QSym.inject_shorthands() … … you could assign these bases other names 54 50 Injecting F as shorthand for Quasisymmetric functions over the Rational Field in the Fundamental basis 55 51 Injecting dI as shorthand for Quasisymmetric functions over the Rational Field in the dualImmaculate basis 56 52 53 Now one can start constructing quasisymmetric functions. 57 54 58 Now one can start constructing quasisymmetric functions. Note, it is best to use variables other than M,F.::55 .. NOTE:: 59 56 60 sage: x = M[2,1]+M[1,2] 57 It is best to use variables other than ``M`` and ``F``. 58 59 :: 60 61 sage: x = M[2,1] + M[1,2] 61 62 sage: x 62 63 M[1, 2] + M[2, 1] 63 64 64 sage: y =3*M[1,2]+M[3]^2; y65 sage: y = 3*M[1,2] + M[3]^2; y 65 66 3*M[1, 2] + 2*M[3, 3] + M[6] 66 67 67 sage: F[3,1,3] +7*F[2,1]68 sage: F[3,1,3] + 7*F[2,1] 68 69 7*F[2, 1] + F[3, 1, 3] 69 70 70 sage: 3*F[2,1,2]+F[3]^2 71 F[1, 2, 2, 1] + F[1, 2, 3] + 2*F[1, 3, 2] + F[1, 4, 1] + F[1, 5] + 3*F[2, 1, 2] + 2*F[2, 2, 2] + 2*F[2, 3, 1] + 2*F[2, 4] + F[3, 2, 1] + 3*F[3, 3] + 2*F[4, 2] + F[5, 1] + F[6] 71 sage: 3*F[2,1,2] + F[3]^2 72 F[1, 2, 2, 1] + F[1, 2, 3] + 2*F[1, 3, 2] + F[1, 4, 1] + F[1, 5] + 3*F[2, 1, 2] 73 + 2*F[2, 2, 2] + 2*F[2, 3, 1] + 2*F[2, 4] + F[3, 2, 1] + 3*F[3, 3] + 2*F[4, 2] + F[5, 1] + F[6] 72 74 73 75 To convert from one basis to another is easy:: 74 76 75 76 sage: z=M[1,2,1] 77 sage: z = M[1,2,1] 77 78 sage: z 78 79 M[1, 2, 1] 79 80 … … To convert from one basis to another is 83 84 sage: M(F(z)) 84 85 M[1, 2, 1] 85 86 86 To expand in variables, one can specify a finite size alphabet $x_1,x_2,\ldots, x_m$. :: 87 To expand in variables, one can specify a finite size alphabet `x_1, x_2, 88 \ldots, x_m`:: 87 89 88 sage: y =M[1,2,1]90 sage: y = M[1,2,1] 89 91 sage: y.expand(4) 90 92 x0*x1^2*x2 + x0*x1^2*x3 + x0*x2^2*x3 + x1*x2^2*x3 91 93 92 The usual methods on free modules are available such as coefficients, degrees, and the support. :: 94 The usual methods on free modules are available such as coefficients, degrees, 95 and the support:: 93 96 94 97 sage: z=3*M[1,2]+M[3]^2; z 95 98 3*M[1, 2] + 2*M[3, 3] + M[6] … … The usual methods on free modules are av 109 112 sage: z.monomial_coefficients() 110 113 {[3, 3]: 2, [1, 2]: 3, [6]: 1} 111 114 112 As with the symmetric functions package, the quasisymmetric function 1113 has several instantiations. However, the most obvious way to write 1114 leads to an error ::115 As with the symmetric functions package, the quasisymmetric function ``1`` 116 has several instantiations. However, the most obvious way to write ``1`` 117 leads to an error (this is due to the semantics of python):: 115 118 116 sage: M[[]] 119 sage: M[[]] 117 120 M[] 118 121 sage: M.one() 119 122 M[] … … Working with symmetric functions 133 136 The quasisymmetric functions are a ring which contains the symmetric 134 137 functions as a subring. The Monomial quasisymmetric functions are 135 138 related to the monomial symmetric functions by `m_\lambda = 136 \sum_{sort(c) = \lambda} M_c ~`::139 \sum_{sort(c) = \lambda} M_c`:: 137 140 138 141 sage: SymmetricFunctions(QQ).inject_shorthands() 139 142 doctest:1075: RuntimeWarning: redefining global value `e` … … related to the monomial symmetric functi 145 148 sage: M(s[2,1]) 146 149 2*M[1, 1, 1] + M[1, 2] + M[2, 1] 147 150 148 There are methods to test if an expression in the quasisymmetric functions is a symmetric 149 function and, if it is, send it to an expression in the symmetric functions. 150 :: 151 There are methods to test if an expression `f` in the quasisymmetric functions 152 is a symmetric function:: 151 153 152 154 sage: f = M[1,1,2] + M[1,2,1] 153 155 sage: f.is_symmetric() 154 156 False 155 sage: g= M[3,1] + M[1,3]156 sage: g.is_symmetric()157 sage: f = M[3,1] + M[1,3] 158 sage: f.is_symmetric() 157 159 True 158 sage: g.to_symmetric_function() 160 161 If `f` is symmetric, there are methods to convert `f` to an expression in the 162 symmetric functions:: 163 164 sage: f.to_symmetric_function() 159 165 m[3, 1] 160 166 161 167 The expansion of the Schur function in terms of the Fundamental quasisymmetric 162 functions is due to [Ges]_. There is one term in the expansion for each standard163 tableau of shape equal to the partition indexing the Schur function.168 functions is due to [Ges]_. There is one term in the expansion for each 169 standard tableau of shape equal to the partition indexing the Schur function. 164 170 :: 165 171 166 172 sage: f = F[3,2] + F[2,2,1] + F[2,3] + F[1,3,1] + F[1,2,2] … … tableau of shape equal to the partition 171 177 sage: s(f.to_symmetric_function()) 172 178 s[3, 2] 173 179 174 It is also possible to convert any symmetric function to the quasisymmetric function expansion in any known basis. The converse is not true175 ::180 It is also possible to convert any symmetric function to the quasisymmetric 181 function expansion in any known basis. The converse is not true:: 176 182 177 183 sage: M( m[3,1,1] ) 178 184 M[1, 1, 3] + M[1, 3, 1] + M[3, 1, 1] … … bases, but it is important that the base 204 210 q*t*F[1, 1, 1] + (q+t)*F[1, 2] + (q+t)*F[2, 1] + F[3] 205 211 206 212 The following will raise an error because the base ring of ``F`` is not 207 equal to the base ring of ``Ht`` 208 :: 213 equal to the base ring of ``Ht``:: 209 214 210 215 sage: F(Ht[2,1]) 211 216 Traceback (most recent call last): 212 ... 217 ... 213 218 TypeError: do not know how to make x (= McdHt[2, 1]) an element of self (=Quasisymmetric functions over the Rational Field in the Fundamental basis) 214 219 215 QSym is a Hopf algebra 220 QSym is a Hopf algebra 216 221  217 222 218 223 The product on this space is commutative and is inherited from the … … product by the realization within the po 230 235 F[1, 1, 1, 2]  F[1, 2, 2] + F[2, 1, 1, 1]  F[2, 1, 2]  F[2, 2, 1] + F[5] 231 236 232 237 There is a coproduct on this ring as well, which in the Monomial basis acts by 233 cutting the composition into a left half and a right half. The 234 coproduct is noncocommutative 235 :: 238 cutting the composition into a left half and a right half. The coproduct is 239 noncocommutative:: 236 240 237 241 sage: M[1,3,1].coproduct() 238 242 M[] # M[1, 3, 1] + M[1] # M[3, 1] + M[1, 3] # M[1] + M[1, 3, 1] # M[] 239 243 sage: F[1,3,1].coproduct() 240 244 F[] # F[1, 3, 1] + F[1] # F[3, 1] + F[1, 1] # F[2, 1] + F[1, 2] # F[1, 1] + F[1, 3] # F[1] + F[1, 3, 1] # F[] 241 245 242 .. rubric:: The duality pairing with noncommutative symmetric functions246 .. rubric:: The Duality Pairing with NonCommutative Symmetric Functions 243 247 244 These two operations endow the quasisymmetric functions `QSym` with the 245 structure of a Hopf algebra. It is the dual Hopf algebra of the 246 noncommutative symmetric functions `NCSF`. Under this duality, the 247 Monomial basis of `QSym` is dual to the Complete basis of `NCSF`, and the 248 Fundamental basis of `QSym` is dual to the Ribbon basis of `NCSF` (see 249 [MR]_) 250 :: 248 These two operations endow `QSym` with the structure of a Hopf algebra. It is 249 the dual Hopf algebra of the noncommutative symmetric functions `NCSF`. Under 250 this duality, the Monomial basis of `QSym` is dual to the Complete basis of 251 `NCSF`, and the Fundamental basis of `QSym` is dual to the Ribbon basis of 252 `NCSF` (see [MR]_):: 251 253 252 254 sage: S = M.dual(); S 253 255 NonCommutative Symmetric Functions over the Rational Field in the Complete basis … … Fundamental basis of `QSym` is dual to t 294 296 295 297 Let `H` and `G` be elements of `QSym` and `h` an element of `NCSF`. Then if 296 298 we represent the duality pairing with the mathematical notation `[ \cdot, 297 \cdot ]`, 299 \cdot ]`, we have: 298 300 299 `[H G, h] = [H \otimes G, \Delta(h)]~.` 301 .. MATH:: 302 303 [H \cdot G, h] = [H \otimes G, \Delta(h)]. 300 304 301 305 For example, the coefficient of ``M[2,1,4,1]`` in ``M[1,3]*M[2,1,1]`` may be 302 306 computed with the duality pairing:: … … computed with the duality pairing:: 306 310 1 307 311 308 312 And the coefficient of ``S[1,3] # S[2,1,1]`` in ``S[2,1,4,1].coproduct()`` is 309 equal to this result 310 :: 313 equal to this result:: 311 314 312 315 sage: S[2,1,4,1].coproduct() 313 316 S[] # S[2, 1, 4, 1] + ... + S[1, 3] # S[2, 1, 1] + ... + S[4, 1] # S[2, 1] 314 317 315 318 The duality pairing on the tensor space is another way of getting this 316 coefficient, but currently the method ``duality_pairing`` is not defined on 317 the tensor squared space. However, we can extend this functionality by 318 applying a linear morphism to the terms in the coproduct, as follows 319 :: 319 coefficient, but currently the method 320 :meth:`~sage.combinat.ncsf_qsym.generic_basis_code.BasesOfQSymOrNCSF.ParentMethods.duality_pairing()` 321 is not defined on the tensor squared space. However, we can extend this 322 functionality by applying a linear morphism to the terms in the coproduct, 323 as follows:: 320 324 321 325 sage: X = S[2,1,4,1].coproduct() 322 326 sage: def linear_morphism(x, y): … … applying a linear morphism to the terms 324 328 sage: X.apply_multilinear_morphism(linear_morphism, codomain=ZZ) 325 329 1 326 330 327 Similarly, if `H` is an element of `QSym` and `g` and `h` are elements of `NCSF`,328 then331 Similarly, if `H` is an element of `QSym` and `g` and `h` are elements of 332 `NCSF`, then 329 333 330 `[ H, g h ] = [ \Delta(H), g \otimes h ]~.` 334 .. MATH:: 331 335 332 For example, the coefficient of ``R[2,3,1]`` in ``R[2,1]*R[2,1]`` is computed with 333 the duality pairing by the following command 334 :: 336 [ H, g \cdot h ] = [ \Delta(H), g \otimes h ]. 337 338 For example, the coefficient of ``R[2,3,1]`` in ``R[2,1]*R[2,1]`` is computed 339 with the duality pairing by the following command:: 335 340 336 341 sage: (R[2,1]*R[2,1]).duality_pairing(F[2,3,1]) 337 342 1 … … the duality pairing by the following com 339 344 R[2, 1, 2, 1] + R[2, 3, 1] 340 345 341 346 This coefficient should then be equal to the coefficient of ``F[2,1] # F[2,1]`` 342 in ``F[2,3,1].coproduct()`` 343 :: 347 in ``F[2,3,1].coproduct()``:: 344 348 345 349 sage: F[2,3,1].coproduct() 346 350 F[] # F[2, 3, 1] + ... + F[2, 1] # F[2, 1] + ... + F[2, 3, 1] # F[] 347 351 348 352 This can also be computed by the duality pairing on the tensor space, 349 as above 350 :: 353 as above:: 351 354 352 355 sage: X = F[2,3,1].coproduct() 353 356 sage: def linear_morphism(x, y): … … as above 355 358 sage: X.apply_multilinear_morphism(linear_morphism, codomain=ZZ) 356 359 1 357 360 358 .. rubric:: The operation adjoint to multiplication by a noncommutative symmetric function361 .. rubric:: The Operation Adjoint to Multiplication by a NonCommutative Symmetric Function 359 362 360 363 Let `g \in NCSF` and consider the linear endomorphism of `NCSF` defined by 361 364 left (respectively, right) multiplication by `g`. Since there is a duality 362 365 between `QSym` and `NCSF`, this linear transformation induces an operator 363 366 `g^\perp` on `QSym` satisfying 364 367 365 `[ g^\perp(H), h ] = [ H, gh ]~.` 368 .. MATH:: 369 370 [ g^\perp(H), h ] = [ H, g \cdot h ]. 366 371 367 372 for any noncommutative symmetric function `h`. 368 373 369 This is implemented by the method :meth:`~sage.combinat.ncsf_qsym.generic_basis_code.BasesOfQSymOrNCSF.ElementMethods.skew_by`. 374 This is implemented by the method 375 :meth:`~sage.combinat.ncsf_qsym.generic_basis_code.BasesOfQSymOrNCSF.ElementMethods.skew_by()`. 370 376 Explicitly, if ``H`` is a quasisymmetric function and ``g`` 371 377 a noncommutative symmetric function, then ``H.skew_by(g)`` and 372 378 ``H.skew_by(g, side='right')`` are expressions that satisfy 373 for any noncommutative symmetric function ``h`` 379 for any noncommutative symmetric function ``h``. 374 380 375 381 :: 376 382 377 383 H.skew_by(g).duality_pairing(h) == H.duality_pairing(g*h) 378 384 H.skew_by(g, side='right').duality_pairing(h) == H.duality_pairing(h*g) 379 385 380 For example, ``M[J].skew_by(S[I])`` is `0` unless the composition ``J`` 381 begins with ``I`` and ``M(J).skew_by(S(I), side='right')`` is `0` unless 382 the composition ``J`` ends with ``I`` 383 384 :: 386 For example, ``M[J].skew_by(S[I])`` is `0` unless the composition `J` 387 begins with `I` and ``M(J).skew_by(S(I), side='right')`` is `0` unless 388 the composition `J` ends with `I`:: 385 389 386 390 sage: M[3,2,2].skew_by(S[3]) 387 391 M[2, 2] … … the composition ``J`` ends with ``I`` 398 402 399 403 The antipode sends the Fundamental basis element indexed by the 400 404 composition `I` to `1` to the size of `I` times the Fundamental 401 basis element indexed by the conjugate composition to `I` 402 :: 405 basis element indexed by the conjugate composition to `I`:: 403 406 404 407 sage: F[3,2,2].antipode() 405 408 F[1, 2, 2, 1, 1] … … We demonstrate here the defining relatio 416 419 sage: X.apply_multilinear_morphism(lambda x,y: x.antipode()*y) 417 420 0 418 421 422 REFERENCES: 423 424 .. [HHL05] *A combinatorial formula for Macdonald polynomials*. 425 Haiman, Haglund, and Loehr. 426 J. Amer. Math. Soc. 18 (2005), no. 3, 735761. 427 428 .. [LW12] *Quasisymmetric expansions of Schurfunction plethysms*. 429 Loehr and Warrington. 430 Proc. Amer. Math. Soc. 140 (2012), no. 4, 11591171. 431 432 .. [KT97] *Noncommutative symmetric functions IV: Quantum linear groups and 433 Hecke algebras at* `q = 0`. 434 Krob and Thibon. 435 Journal of Algebraic Combinatorics 6 (1997), 339376. 419 436 """