Ticket #14111: trac_14111-qsym_tutorial-review-ts.patch

File trac_14111-qsym_tutorial-review-ts.patch, 16.3 KB (added by tscrim, 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: utf-8 -*-
     1# -*- coding: utf-8 -*-
    22r"""
    3 =====================================
    4 Tutorial for Quasisymmetric Functions
    5 =====================================
     3Introduction to Quasisymmetric Functions
    64
    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`
     5In this document we briefly explain the quasisymmetric function bases and
     6related functionality in Sage.   We assume the reader is familar with the
     7package :class:`SymmetricFunctions`.
    98
    10 Quasisymmetric functions, denoted QSym, form a subring of the power
    11 series ring in countably many variables.  QSym contains the symmetric
     9Quasisymmetric functions, denoted `QSym`, form a subring of the power
     10series ring in countably many variables. `QSym` contains the symmetric
    1211functions.  These functions first arose in the theory of
    13 $P$-partitions.  The initial ideas in this field are attributed to
    14 MacMahon, Knuth, Kreweras, Glâffrwd Thomas, Stanley.  In 1984, Gessel
     12`P`-partitions.  The initial ideas in this field are attributed to
     13MacMahon, Knuth, Kreweras, Glâffrwd Thomas, Stanley. In 1984, Gessel
    1514formalized the study of quasisymmetric functions and introduced the
    16 basis of fundamental quasisymmetric functions. In 1995, Gelfand,
     15basis of fundamental quasisymmetric functions [Ges]_. In 1995, Gelfand,
    1716Krob, Lascoux, Leclerc, Retakh, and Thibon showed that the ring of
    1817quasisymmetric functions is Hopf dual to the noncommutative symmetric
    19 functions.  Many results have built on these.   
     18functions [NCSF]_.  Many results have built on these.
    2019
    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 [Haiman-Haglund-Loehr], and plethysm of
    27 Schur functions [Loehr-Warrington].
     20One advantage of working in `QSym` is that many interesting families of
     21symmetric functions have explicit expansions in fundamental quasisymmetric
     22functions such as Schur functions [Ges]_, Macdonald polynomials
     23[HHL05]_, and plethysm of Schur functions [LW12]_.
    2824
    2925For more background see :wikipedia:`Quasisymmetric_function`.
    3026
    numbers `\QQ`. Other options include th 
    4137    sage: QSym = QuasiSymmetricFunctions(ZZ); QSym
    4238    Quasisymmetric functions over the Integer Ring
    4339
    44 All bases of QSym are indexed by compositions e.g. `[3,1,1,4]`. The
    45 convention is to use capitol letters for bases of QSym and lowercase
    46 letters for bases of Sym.  Next set up names for the  known bases by running
    47 :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. ::
     40All bases of `QSym` are indexed by compositions e.g. `[3,1,1,4]`. The
     41convention is to use capitol letters for bases of `QSym` and lowercase
     42letters for bases of the symmetric functions `Sym`.  Next set up names for the
     43known bases by running ``inject_shorthands()``. As with symmetric functions,
     44you do not need to run this commmand and you could assign these bases other
     45names. ::
    5046
    5147    sage: QSym = QuasiSymmetricFunctions(QQ)
    5248    sage: QSym.inject_shorthands()
    you could assign these bases other names 
    5450    Injecting F as shorthand for Quasisymmetric functions over the Rational Field in the Fundamental basis
    5551    Injecting dI as shorthand for Quasisymmetric functions over the Rational Field in the dualImmaculate basis
    5652
     53Now one can start constructing quasisymmetric functions.
    5754
    58 Now one can start constructing quasisymmetric functions.  Note, it is best to use variables other than M,F.  ::
     55.. NOTE::
    5956
    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]
    6162    sage: x
    6263    M[1, 2] + M[2, 1]
    6364
    64     sage: y=3*M[1,2]+M[3]^2; y
     65    sage: y = 3*M[1,2] + M[3]^2; y
    6566    3*M[1, 2] + 2*M[3, 3] + M[6]
    6667
    67     sage: F[3,1,3]+7*F[2,1]
     68    sage: F[3,1,3] + 7*F[2,1]
    6869    7*F[2, 1] + F[3, 1, 3]
    6970
    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]
    7274
    7375To convert from one basis to another is easy::
    7476
    75 
    76     sage: z=M[1,2,1]
     77    sage: z = M[1,2,1]
    7778    sage: z
    7879    M[1, 2, 1]
    7980
    To convert from one basis to another is  
    8384    sage: M(F(z))
    8485    M[1, 2, 1]
    8586
    86 To expand in variables, one can specify a finite size alphabet $x_1,x_2,\ldots, x_m$. ::
     87To expand in variables, one can specify a finite size alphabet `x_1, x_2,
     88\ldots, x_m`::
    8789
    88     sage: y=M[1,2,1]
     90    sage: y = M[1,2,1]
    8991    sage: y.expand(4)
    9092    x0*x1^2*x2 + x0*x1^2*x3 + x0*x2^2*x3 + x1*x2^2*x3
    9193
    92 The usual methods on free modules are available such as coefficients, degrees, and the support. ::
     94The usual methods on free modules are available such as coefficients, degrees,
     95and the support::
    9396
    9497    sage: z=3*M[1,2]+M[3]^2; z
    9598    3*M[1, 2] + 2*M[3, 3] + M[6]
    The usual methods on free modules are av 
    109112    sage: z.monomial_coefficients()
    110113    {[3, 3]: 2, [1, 2]: 3, [6]: 1}
    111114
    112 As with the symmetric functions package, the quasisymmetric function 1
    113 has several instantiations.  However, the most obvious way to write 1
    114 leads to an error::
     115As with the symmetric functions package, the quasisymmetric function ``1``
     116has several instantiations. However, the most obvious way to write ``1``
     117leads to an error (this is due to the semantics of python)::
    115118
    116     sage: M[[]] 
     119    sage: M[[]]
    117120    M[]
    118121    sage: M.one()
    119122    M[]
    Working with symmetric functions 
    133136The quasisymmetric functions are a ring which contains the symmetric
    134137functions as a subring.  The Monomial quasisymmetric functions are
    135138related to the monomial symmetric functions by `m_\lambda =
    136 \sum_{sort(c) = \lambda} M_c~`::
     139\sum_{sort(c) = \lambda} M_c`::
    137140
    138141    sage: SymmetricFunctions(QQ).inject_shorthands()
    139142    doctest:1075: RuntimeWarning: redefining global value `e`
    related to the monomial symmetric functi 
    145148    sage: M(s[2,1])
    146149    2*M[1, 1, 1] + M[1, 2] + M[2, 1]
    147150
    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 ::
     151There are methods to test if an expression `f` in the quasisymmetric functions
     152is a symmetric function::
    151153
    152154    sage: f = M[1,1,2] + M[1,2,1]
    153155    sage: f.is_symmetric()
    154156    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()
    157159    True
    158     sage: g.to_symmetric_function()
     160
     161If `f` is symmetric, there are methods to convert `f` to an expression in the
     162symmetric functions::
     163
     164    sage: f.to_symmetric_function()
    159165    m[3, 1]
    160166
    161167The 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 standard
    163 tableau of shape equal to the partition indexing the Schur function.
     168functions is due to [Ges]_. There is one term in the expansion for each
     169standard tableau of shape equal to the partition indexing the Schur function.
    164170::
    165171
    166172    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  
    171177    sage: s(f.to_symmetric_function())
    172178    s[3, 2]
    173179
    174 It is also possible to convert any symmetric function to the quasisymmetric function expansion in any known basis.  The converse is not true
    175 ::
     180It is also possible to convert any symmetric function to the quasisymmetric
     181function expansion in any known basis. The converse is not true::
    176182
    177183    sage: M( m[3,1,1] )
    178184    M[1, 1, 3] + M[1, 3, 1] + M[3, 1, 1]
    bases, but it is important that the base 
    204210    q*t*F[1, 1, 1] + (q+t)*F[1, 2] + (q+t)*F[2, 1] + F[3]
    205211
    206212The following will raise an error because the base ring of ``F`` is not
    207 equal to the base ring of ``Ht``
    208 ::
     213equal to the base ring of ``Ht``::
    209214
    210215    sage: F(Ht[2,1])
    211216    Traceback (most recent call last):
    212     ... 
     217    ...
    213218    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)
    214219
    215 QSym is a Hopf algebra 
     220QSym is a Hopf algebra
    216221----------------------
    217222
    218223The product on this space is commutative and is inherited from the
    product by the realization within the po 
    230235    F[1, 1, 1, 2] - F[1, 2, 2] + F[2, 1, 1, 1] - F[2, 1, 2] - F[2, 2, 1] + F[5]
    231236
    232237There 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 co-product is non-co-commutative
    235 ::
     238cutting the composition into a left half and a right half. The co-product is
     239non-co-commutative::
    236240
    237241    sage: M[1,3,1].coproduct()
    238242    M[] # M[1, 3, 1] + M[1] # M[3, 1] + M[1, 3] # M[1] + M[1, 3, 1] # M[]
    239243    sage: F[1,3,1].coproduct()
    240244    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[]
    241245
    242 .. rubric:: The duality pairing with non-commutative symmetric functions
     246.. rubric:: The Duality Pairing with Non-Commutative Symmetric Functions
    243247
    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 non-commutative 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 ::
     248These two operations endow `QSym` with the structure of a Hopf algebra. It is
     249the dual Hopf algebra of the non-commutative symmetric functions `NCSF`. Under
     250this 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]_)::
    251253
    252254    sage: S = M.dual(); S
    253255    Non-Commutative Symmetric Functions over the Rational Field in the Complete basis
    Fundamental basis of `QSym` is dual to t 
    294296
    295297Let `H` and `G` be elements of `QSym` and `h` an element of `NCSF`. Then if
    296298we represent the duality pairing with the mathematical notation `[ \cdot,
    297 \cdot ]`,
     299\cdot ]`, we have:
    298300
    299 `[H G, h] = [H \otimes G, \Delta(h)]~.`
     301.. MATH::
     302
     303    [H \cdot G, h] = [H \otimes G, \Delta(h)].
    300304
    301305For example, the coefficient of ``M[2,1,4,1]`` in ``M[1,3]*M[2,1,1]`` may be
    302306computed with the duality pairing::
    computed with the duality pairing:: 
    306310    1
    307311
    308312And the coefficient of ``S[1,3] # S[2,1,1]`` in ``S[2,1,4,1].coproduct()`` is
    309 equal to this result
    310 ::
     313equal to this result::
    311314
    312315    sage: S[2,1,4,1].coproduct()
    313316    S[] # S[2, 1, 4, 1] + ... + S[1, 3] # S[2, 1, 1] + ... + S[4, 1] # S[2, 1]
    314317
    315318The 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 ::
     319coefficient, but currently the method
     320:meth:`~sage.combinat.ncsf_qsym.generic_basis_code.BasesOfQSymOrNCSF.ParentMethods.duality_pairing()`
     321is not defined on the tensor squared space. However, we can extend this
     322functionality by applying a linear morphism to the terms in the coproduct,
     323as follows::
    320324
    321325    sage: X = S[2,1,4,1].coproduct()
    322326    sage: def linear_morphism(x, y):
    applying a linear morphism to the terms  
    324328    sage: X.apply_multilinear_morphism(linear_morphism, codomain=ZZ)
    325329    1
    326330
    327 Similarly, if `H` is an element of `QSym` and `g` and `h` are elements of `NCSF`,
    328 then
     331Similarly, if `H` is an element of `QSym` and `g` and `h` are elements of
     332`NCSF`, then
    329333
    330 `[ H, g h ] = [ \Delta(H), g \otimes h ]~.`
     334.. MATH::
    331335
    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
     338For example, the coefficient of ``R[2,3,1]`` in ``R[2,1]*R[2,1]`` is computed
     339with the duality pairing by the following command::
    335340
    336341    sage: (R[2,1]*R[2,1]).duality_pairing(F[2,3,1])
    337342    1
    the duality pairing by the following com 
    339344    R[2, 1, 2, 1] + R[2, 3, 1]
    340345
    341346This coefficient should then be equal to the coefficient of ``F[2,1] # F[2,1]``
    342 in ``F[2,3,1].coproduct()``
    343 ::
     347in ``F[2,3,1].coproduct()``::
    344348
    345349    sage: F[2,3,1].coproduct()
    346350    F[] # F[2, 3, 1] + ... + F[2, 1] # F[2, 1]  + ... + F[2, 3, 1] # F[]
    347351
    348352This can also be computed by the duality pairing on the tensor space,
    349 as above
    350 ::
     353as above::
    351354
    352355    sage: X = F[2,3,1].coproduct()
    353356    sage: def linear_morphism(x, y):
    as above 
    355358    sage: X.apply_multilinear_morphism(linear_morphism, codomain=ZZ)
    356359    1
    357360
    358 .. rubric:: The operation adjoint to multiplication by a non-commutative symmetric function
     361.. rubric:: The Operation Adjoint to Multiplication by a Non-Commutative Symmetric Function
    359362
    360363Let `g \in NCSF` and consider the linear endomorphism of `NCSF` defined by
    361364left (respectively, right) multiplication by `g`. Since there is a duality
    362365between `QSym` and `NCSF`, this linear transformation induces an operator
    363366`g^\perp` on `QSym` satisfying
    364367
    365 `[ g^\perp(H), h ] = [ H, gh ]~.`
     368.. MATH::
     369
     370    [ g^\perp(H), h ] = [ H, g \cdot h ].
    366371
    367372for any non-commutative symmetric function `h`.
    368373
    369 This is implemented by the method :meth:`~sage.combinat.ncsf_qsym.generic_basis_code.BasesOfQSymOrNCSF.ElementMethods.skew_by`.
     374This is implemented by the method
     375:meth:`~sage.combinat.ncsf_qsym.generic_basis_code.BasesOfQSymOrNCSF.ElementMethods.skew_by()`.
    370376Explicitly, if ``H`` is a quasisymmetric function and ``g``
    371377a non-commutative symmetric function, then ``H.skew_by(g)`` and
    372378``H.skew_by(g, side='right')`` are expressions that satisfy
    373 for any non-commutative symmetric function ``h``
     379for any non-commutative symmetric function ``h``.
    374380
    375381::
    376382
    377383    H.skew_by(g).duality_pairing(h) == H.duality_pairing(g*h)
    378384    H.skew_by(g, side='right').duality_pairing(h) == H.duality_pairing(h*g)
    379385
    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 ::
     386For example, ``M[J].skew_by(S[I])`` is `0` unless the composition `J`
     387begins with `I` and ``M(J).skew_by(S(I), side='right')`` is `0` unless
     388the composition `J` ends with `I`::
    385389
    386390    sage: M[3,2,2].skew_by(S[3])
    387391    M[2, 2]
    the composition ``J`` ends with ``I`` 
    398402
    399403The antipode sends the Fundamental basis element indexed by the
    400404composition `I` to `-1` to the size of `I` times the Fundamental
    401 basis element indexed by the conjugate composition to `I`
    402 ::
     405basis element indexed by the conjugate composition to `I`::
    403406
    404407    sage: F[3,2,2].antipode()
    405408    -F[1, 2, 2, 1, 1]
    We demonstrate here the defining relatio 
    416419    sage: X.apply_multilinear_morphism(lambda x,y: x.antipode()*y)
    417420    0
    418421
     422REFERENCES:
     423
     424.. [HHL05] *A combinatorial formula for Macdonald polynomials*.
     425   Haiman, Haglund, and Loehr.
     426   J. Amer. Math. Soc. 18 (2005), no. 3, 735-761.
     427
     428.. [LW12] *Quasisymmetric expansions of Schur-function plethysms*.
     429   Loehr and Warrington.
     430   Proc. Amer. Math. Soc. 140 (2012), no. 4, 1159-1171.
     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), 339-376.
    419436"""