# Quasisymmetric functions¶

REFERENCES:

 [Ges] I. Gessel, Multipartite P-partitions and inner products of skew Schur functions, Contemp. Math. 34 (1984), 289-301. http://people.brandeis.edu/~gessel/homepage/papers/multipartite.pdf
 [MR] C. Malvenuto and C. Reutenauer, Duality between quasi-symmetric functions and the Solomon descent algebra, J. Algebra 177 (1995), no. 3, 967-982. http://www.mat.uniroma1.it/people/malvenuto/Duality.pdf
 [Reiner2013] Victor Reiner, Hopf algebras in combinatorics, 17 January 2013. http://www.math.umn.edu/~reiner/Classes/HopfComb.pdf
 [Mal1993] Claudia Malvenuto, Produits et coproduits des fonctions quasi-symetriques et de l’algebre des descentes, thesis, November 1993. http://www1.mat.uniroma1.it/people/malvenuto/Thesis.pdf
 [Haz2004] (1, 2, 3, 4) Michiel Hazewinkel, Explicit polynomial generators for the ring of quasisymmetric functions over the integers. Arxiv math/0410366v1
 [Rad1979] David E. Radford, A natural ring basis for the shuffle algebra and an application to group schemes, J. Algebra 58 (1979), 432-454.

AUTHOR:

• Jason Bandlow
• Franco Saliola
• Chris Berg
• Darij Grinberg
class sage.combinat.ncsf_qsym.qsym.QuasiSymmetricFunctions(R)

The Hopf algebra of quasisymmetric functions.

Let $$R$$ be a commutative ring with unity. The $$R$$-algebra of quasi-symmetric functions may be realized as an $$R$$-subalgebra of the ring of power series in countably many variables $$R[[x_1, x_2, x_3, \ldots]]$$. It consists of those formal power series $$p$$ which are degree-bounded (i. e., the degrees of all monomials occuring with nonzero coefficient in $$p$$ are bounded from above, although the bound can depend on $$p$$) and satisfy the following condition: For every tuple $$(a_1, a_2, \ldots, a_m)$$ of positive integers, the coefficient of the monomial $$x_{i_1}^{a_1} x_{i_2}^{a_2} \cdots x_{i_m}^{a_m}$$ in $$p$$ is the same for all strictly increasing sequences $$(i_1 < i_2 < \cdots < i_m)$$ of positive integers. (In other words, the coefficient of a monomial in $$p$$ depends only on the sequence of nonzero exponents in the monomial. If “sequence” were to be replaced by “multiset” here, we would obtain the definition of a symmetric function.)

The $$R$$-algebra of quasi-symmetric functions is commonly called $$\mathrm{QSym}_R$$ or occasionally just $$\mathrm{QSym}$$ (when $$R$$ is clear from the context or $$\ZZ$$ or $$\QQ$$). It is graded by the total degree of the power series. Its homogeneous elements of degree $$k$$ form a free $$R$$-submodule of rank equal to the number of compositions of $$k$$ (that is, $$2^{k-1}$$ if $$k \geq 1$$, else $$1$$).

The two classical bases of $$\mathrm{QSym}$$, the monomial basis $$(M_I)_I$$ and the fundamental basis $$(F_I)_I$$, are indexed by compositions $$I = (I_1, I_2, \cdots, I_\ell )$$ and defined by the formulas:

$\begin{split}M_I = \sum_{1 \leq i_1 < i_2 < \cdots < i_\ell} x_{i_1}^{I_1} x_{i_2}^{I_2} \cdots x_{i_\ell}^{I_\ell}\end{split}$

and

$F_I = \sum_{(j_1, j_2, \ldots, j_n)} x_{j_1} x_{j_2} \cdots x_{j_n}$

where in the second equation the sum runs over all weakly increasing $$n$$-tuples $$(j_1, j_2, \ldots, j_n)$$ of positive integers (where $$n$$ is the size of $$I$$) which increase strictly from $$j_r$$ to $$j_{r+1}$$ if $$r$$ is a descent of the composition $$I$$.

These bases are related by the formula

$$F_I = \sum_{J \leq I} M_J$$

where the inequality $$J \leq I$$ indicates that $$J$$ is finer than $$I$$.

The $$R$$-algebra of quasi-symmetric functions is a Hopf algebra, with the coproduct satisfying

$\Delta M_I = \sum_{k=0}^{\ell} M_{(I_1, I_2, \cdots, I_k)} \otimes M_{(I_{k+1}, I_{k+2}, \cdots , I_{\ell})}$

for every composition $$I = (I_1, I_2, \cdots , I_\ell )$$.

It is possible to define an $$R$$-algebra of quasi-symmetric functions in a finite number of variables as well (but it is not a bialgebra). These quasi-symmetric functions are actual polynomials then, not just power series.

Chapter 5 of [Reiner2013] and Section 11 of [HazWitt1] are devoted to quasi-symmetric functions, as are Malvenuto’s thesis [Mal1993] and part of Chapter 7 of [Sta1999].

The implementation of the quasi-symmetric function Hopf algebra

We realize the $$R$$-algebra of quasi-symmetric functions in Sage as a graded Hopf algebra with basis elements indexed by compositions.

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: QSym.category()
Join of Category of graded hopf algebras over Rational Field and Category of monoids with realizations and Category of coalgebras over Rational Field with realizations


The most standard two bases for this $$R$$-algebra are the monomial and fundamental bases, and are accessible by the M() and F() methods:

sage: M = QSym.M()
sage: F = QSym.F()
sage: M(F[2,1,2])
M[1, 1, 1, 1, 1] + M[1, 1, 1, 2] + M[2, 1, 1, 1] + M[2, 1, 2]
sage: F(M[2,1,2])
F[1, 1, 1, 1, 1] - F[1, 1, 1, 2] - F[2, 1, 1, 1] + F[2, 1, 2]


The product on this space is commutative and is inherited from the product on the realization within the ring of power series:

sage: M[3]*M[1,1] == M[1,1]*M[3]
True
sage: M[3]*M[1,1]
M[1, 1, 3] + M[1, 3, 1] + M[1, 4] + M[3, 1, 1] + M[4, 1]
sage: F[3]*F[1,1]
F[1, 1, 3] + F[1, 2, 2] + F[1, 3, 1] + F[1, 4] + F[2, 1, 2] + F[2, 2, 1] + F[2, 3] + F[3, 1, 1] + F[3, 2] + F[4, 1]
sage: M[3]*F[2]
M[1, 1, 3] + M[1, 3, 1] + M[1, 4] + M[2, 3] + M[3, 1, 1] + M[3, 2] + M[4, 1] + M[5]
sage: F[2]*M[3]
F[1, 1, 1, 2] - F[1, 2, 2] + F[2, 1, 1, 1] - F[2, 1, 2] - F[2, 2, 1] + F[5]


There is a coproduct on $$\mathrm{QSym}$$ as well, which in the Monomial basis acts by cutting the composition into a left half and a right half. The coproduct is not co-commutative:

sage: M[1,3,1].coproduct()
M[] # M[1, 3, 1] + M[1] # M[3, 1] + M[1, 3] # M[1] + M[1, 3, 1] # M[]
sage: F[1,3,1].coproduct()
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[]


The duality pairing with non-commutative symmetric functions

These two operations endow the quasi-symmetric functions $$\mathrm{QSym}$$ with the structure of a Hopf algebra. It is the graded dual Hopf algebra of the non-commutative symmetric functions $$NCSF$$. Under this duality, the Monomial basis of $$\mathrm{QSym}$$ is dual to the Complete basis of $$NCSF$$, and the Fundamental basis of $$\mathrm{QSym}$$ is dual to the Ribbon basis of $$NCSF$$ (see [MR]).

sage: S = M.dual(); S
Non-Commutative Symmetric Functions over the Rational Field in the Complete basis
sage: M[1,3,1].duality_pairing( S[1,3,1] )
1
sage: M.duality_pairing_matrix( S, degree=4 )
[1 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 1]
sage: F.duality_pairing_matrix( S, degree=4 )
[1 0 0 0 0 0 0 0]
[1 1 0 0 0 0 0 0]
[1 0 1 0 0 0 0 0]
[1 1 1 1 0 0 0 0]
[1 0 0 0 1 0 0 0]
[1 1 0 0 1 1 0 0]
[1 0 1 0 1 0 1 0]
[1 1 1 1 1 1 1 1]
sage: NCSF = M.realization_of().dual()
sage: R = NCSF.Ribbon()
sage: F.duality_pairing_matrix( R, degree=4 )
[1 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 1]
sage: M.duality_pairing_matrix( R, degree=4 )
[ 1  0  0  0  0  0  0  0]
[-1  1  0  0  0  0  0  0]
[-1  0  1  0  0  0  0  0]
[ 1 -1 -1  1  0  0  0  0]
[-1  0  0  0  1  0  0  0]
[ 1 -1  0  0 -1  1  0  0]
[ 1  0 -1  0 -1  0  1  0]
[-1  1  1 -1  1 -1 -1  1]


Let $$H$$ and $$G$$ be elements of $$\mathrm{QSym}$$, and $$h$$ an element of $$NCSF$$. Then, if we represent the duality pairing with the mathematical notation $$[ \cdot, \cdot ]$$,

$$[H G, h] = [H \otimes G, \Delta(h)]~.$$

For example, the coefficient of M[2,1,4,1] in M[1,3]*M[2,1,1] may be computed with the duality pairing:

sage: I, J = Composition([1,3]), Composition([2,1,1])
sage: (M[I]*M[J]).duality_pairing(S[2,1,4,1])
1


And the coefficient of S[1,3] # S[2,1,1] in S[2,1,4,1].coproduct() is equal to this result:

sage: S[2,1,4,1].coproduct()
S[] # S[2, 1, 4, 1] + ... + S[1, 3] # S[2, 1, 1] + ... + S[4, 1] # S[2, 1]


The duality pairing on the tensor space is another way of getting this coefficient, but currently the method duality_pairing is not defined on the tensor squared space. However, we can extend this functionality by applying a linear morphism to the terms in the coproduct, as follows:

sage: X = S[2,1,4,1].coproduct()
sage: def linear_morphism(x, y):
....:   return x.duality_pairing(M[1,3]) * y.duality_pairing(M[2,1,1])
sage: X.apply_multilinear_morphism(linear_morphism, codomain=ZZ)
1


Similarly, if $$H$$ is an element of $$\mathrm{QSym}$$ and $$g$$ and $$h$$ are elements of $$NCSF$$, then

$[ H, g h ] = [ \Delta(H), g \otimes h ].$

For example, the coefficient of R[2,3,1] in R[2,1]*R[2,1] is computed with the duality pairing by the following command:

sage: (R[2,1]*R[2,1]).duality_pairing(F[2,3,1])
1
sage: R[2,1]*R[2,1]
R[2, 1, 2, 1] + R[2, 3, 1]


This coefficient should then be equal to the coefficient of F[2,1] # F[2,1] in F[2,3,1].coproduct():

sage: F[2,3,1].coproduct()
F[] # F[2, 3, 1] + ... + F[2, 1] # F[2, 1]  + ... + F[2, 3, 1] # F[]


This can also be computed by the duality pairing on the tensor space, as above:

sage: X = F[2,3,1].coproduct()
sage: def linear_morphism(x, y):
....:   return x.duality_pairing(R[2,1]) * y.duality_pairing(R[2,1])
sage: X.apply_multilinear_morphism(linear_morphism, codomain=ZZ)
1


The operation dual to multiplication by a non-commutative symmetric function

Let $$g \in NCSF$$ and consider the linear endomorphism of $$NCSF$$ defined by left (respectively, right) multiplication by $$g$$. Since there is a duality between $$\mathrm{QSym}$$ and $$NCSF$$, this linear transformation induces an operator $$g^{\perp}$$ on $$\mathrm{QSym}$$ satisfying

$[ g^{\perp}(H), h ] = [ H, gh ].$

for any non-commutative symmetric function $$h$$.

This is implemented by the method skew_by(). Explicitly, if H is a quasi-symmetric function and g a non-commutative symmetric function, then H.skew_by(g) and H.skew_by(g, side='right') are expressions that satisfy, for any non-commutative symmetric function h, the following equalities:

H.skew_by(g).duality_pairing(h) == H.duality_pairing(g*h)
H.skew_by(g, side='right').duality_pairing(h) == H.duality_pairing(h*g)


For example, M[J].skew_by(S[I]) is $$0$$ unless the composition J begins with I and M(J).skew_by(S(I), side='right') is $$0$$ unless the composition J ends with I. For example:

sage: M[3,2,2].skew_by(S[3])
M[2, 2]
sage: M[3,2,2].skew_by(S[2])
0
sage: M[3,2,2].coproduct().apply_multilinear_morphism( lambda x,y: x.duality_pairing(S[3])*y )
M[2, 2]
sage: M[3,2,2].skew_by(S[3], side='right')
0
sage: M[3,2,2].skew_by(S[2], side='right')
M[3, 2]


The counit

The counit is defined by sending all elements of positive degree to zero:

sage: M[3].degree(), M[3,1,2].degree(), M.one().degree()
(3, 6, 0)
sage: M[3].counit()
0
sage: M[3,1,2].counit()
0
sage: M.one().counit()
1
sage: (M[3] - 2*M[3,1,2] + 7).counit()
7
sage: (F[3] - 2*F[3,1,2] + 7).counit()
7


The antipode

The antipode sends the Fundamental basis element indexed by the composition $$I$$ to $$-1$$ to the size of $$I$$ times the Fundamental basis element indexed by the conjugate composition to $$I$$.

sage: F[3,2,2].antipode()
-F[1, 2, 2, 1, 1]
sage: Composition([3,2,2]).conjugate()
[1, 2, 2, 1, 1]
sage: M[3,2,2].antipode()
-M[2, 2, 3] - M[2, 5] - M[4, 3] - M[7]


We demonstrate here the defining relation of the antipode:

sage: X = F[3,2,2].coproduct()
sage: X.apply_multilinear_morphism(lambda x,y: x*y.antipode())
0
sage: X.apply_multilinear_morphism(lambda x,y: x.antipode()*y)
0


The relation with symmetric functions

The quasi-symmetric functions are a ring which contain the symmetric functions as a subring. The Monomial quasi-symmetric functions are related to the monomial symmetric functions by

$m_\lambda = \sum_{\mathrm{sort}(I) = \lambda} M_I.$

There are methods to test if an expression in the quasi-symmetric functions is a symmetric function and, if it is, send it to an expression in the symmetric functions:

sage: f = M[1,1,2] + M[1,2,1]
sage: f.is_symmetric()
False
sage: g = M[3,1] + M[1,3]
sage: g.is_symmetric()
True
sage: g.to_symmetric_function()
m[3, 1]


The expansion of the Schur function in terms of the Fundamental quasi-symmetric functions is due to [Ges]. There is one term in the expansion for each standard tableau of shape equal to the partition indexing the Schur function.

sage: f = F[3,2] + F[2,2,1] + F[2,3] + F[1,3,1] + F[1,2,2]
sage: f.is_symmetric()
True
sage: f.to_symmetric_function()
5*m[1, 1, 1, 1, 1] + 3*m[2, 1, 1, 1] + 2*m[2, 2, 1] + m[3, 1, 1] + m[3, 2]
sage: s = SymmetricFunctions(QQ).s()
sage: s(f.to_symmetric_function())
s[3, 2]


It is also possible to convert a symmetric function to a quasi-symmetric function:

sage: m = SymmetricFunctions(QQ).m()
sage: M( m[3,1,1] )
M[1, 1, 3] + M[1, 3, 1] + M[3, 1, 1]
sage: F( s[2,2,1] )
F[1, 1, 2, 1] + F[1, 2, 1, 1] + F[1, 2, 2] + F[2, 1, 2] + F[2, 2, 1]


It is possible to experiment with the quasi-symmetric function expansion of other bases, but it is important that the base ring be the same for both algebras.

sage: R = QQ['t']
sage: Qp = SymmetricFunctions(R).hall_littlewood().Qp()
sage: QSymt = QuasiSymmetricFunctions(R)
sage: Ft = QSymt.F()
sage: Ft( Qp[2,2] )
F[1, 2, 1] + t*F[1, 3] + (t+1)*F[2, 2] + t*F[3, 1] + t^2*F[4]

sage: K = QQ['q','t'].fraction_field()
sage: Ht = SymmetricFunctions(K).macdonald().Ht()
sage: Fqt = QuasiSymmetricFunctions(Ht.base_ring()).F()
sage: Fqt(Ht[2,1])
q*t*F[1, 1, 1] + (q+t)*F[1, 2] + (q+t)*F[2, 1] + F[3]


The following will raise an error because the base ring of F is not equal to the base ring of Ht:

sage: F(Ht[2,1])
Traceback (most recent call last):
...
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)


The map to the ring of polynomials

The quasi-symmetric functions can be seen as an inverse limit of a subring of a polynomial ring as the number of variables increases. Indeed, there exists a projection from the quasi-symmetric functions onto the polynomial ring $$R[x_1, x_2, \ldots, x_n]$$. This projection is defined by sending the variables $$x_{n+1}, x_{n+2}, \cdots$$ to $$0$$, while the remaining $$n$$ variables remain fixed. Note that this projection sends $$M_I$$ to $$0$$ if the length of the composition $$I$$ is higher than $$n$$.

sage: M[1,3,1].expand(4)
x0*x1^3*x2 + x0*x1^3*x3 + x0*x2^3*x3 + x1*x2^3*x3
sage: F[1,3,1].expand(4)
x0*x1^3*x2 + x0*x1^3*x3 + x0*x1^2*x2*x3 + x0*x1*x2^2*x3 + x0*x2^3*x3 + x1*x2^3*x3
sage: M[1,3,1].expand(2)
0


TESTS:

sage: QSym = QuasiSymmetricFunctions(QQ); QSym
Quasisymmetric functions over the Rational Field
sage: QSym.base_ring()
Rational Field

class Bases(parent_with_realization)

Category of bases of quasi-symmetric functions.

EXAMPLES:

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: QSym.Bases()
Category of bases of Quasisymmetric functions over the Rational Field

ElementMethods

alias of Bases.ElementMethods

ParentMethods

alias of Bases.ParentMethods

super_categories()

Return the super categories of bases of the Quasi-symmetric functions.

OUTPUT:

• a list of categories

TESTS:

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: QSym.Bases().super_categories()
[Category of bases of Non-Commutative Symmetric Functions or Quasisymmetric functions over the Rational Field, Category of commutative rings]

class QuasiSymmetricFunctions.Fundamental(QSym)

The Hopf algebra of quasi-symmetric functions in the Fundamental basis.

EXAMPLES:

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: F = QSym.F()
sage: M = QSym.M()
sage: F(M[2,2])
F[1, 1, 1, 1] - F[1, 1, 2] - F[2, 1, 1] + F[2, 2]
sage: s = SymmetricFunctions(QQ).s()
sage: F(s[3,2])
F[1, 2, 2] + F[1, 3, 1] + F[2, 2, 1] + F[2, 3] + F[3, 2]
sage: (1+F[1])^3
F[] + 3*F[1] + 3*F[1, 1] + F[1, 1, 1] + 2*F[1, 2] + 3*F[2] + 2*F[2, 1] + F[3]
sage: F[1,2,1].coproduct()
F[] # F[1, 2, 1] + F[1] # F[2, 1] + F[1, 1] # F[1, 1] + F[1, 2] # F[1] + F[1, 2, 1] # F[]


The following is an alias for this basis:

sage: QSym.Fundamental()
Quasisymmetric functions over the Rational Field in the Fundamental basis


TESTS:

sage: F(M([]))
F[]
sage: F(M(0))
0
sage: F(s([]))
F[]
sage: F(s(0))
0

Element

alias of Fundamental.Element

antipode_on_basis(compo)

Return the antipode to a Fundamental quasi-symmetric basis element.

INPUT:

• compo – composition

OUTPUT:

• The result of the antipode applied to the quasi-symmetric Fundamental basis element indexed by compo.

EXAMPLES:

sage: F = QuasiSymmetricFunctions(QQ).F()
sage: F.antipode_on_basis(Composition([2,1]))
-F[2, 1]

coproduct_on_basis(compo)

Return the coproduct to a Fundamental quasi-symmetric basis element.

Combinatorial rule: quasi-deconcatenation.

INPUT:

• compo – composition

OUTPUT:

• The application of the coproduct to the Fundamental quasi-symmetric function indexed by the composition compo.

EXAMPLES:

sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: F[4].coproduct()
F[] # F[4] + F[1] # F[3] + F[2] # F[2] + F[3] # F[1] + F[4] # F[]
sage: F[2,1,3].coproduct()
F[] # F[2, 1, 3] + F[1] # F[1, 1, 3] + F[2] # F[1, 3] + F[2, 1] # F[3] + F[2, 1, 1] # F[2] + F[2, 1, 2] # F[1] + F[2, 1, 3] # F[]


TESTS:

sage: F.coproduct_on_basis(Composition([2,1,3]))
F[] # F[2, 1, 3] + F[1] # F[1, 1, 3] + F[2] # F[1, 3] + F[2, 1] # F[3] + F[2, 1, 1] # F[2] + F[2, 1, 2] # F[1] + F[2, 1, 3] # F[]
F[] # F[]

dual()

Return the dual basis to the Fundamental basis. This is the ribbon basis of the non-commutative symmetric functions.

OUTPUT:

• The ribbon basis of the non-commutative symmetric functions.

EXAMPLES:

sage: F = QuasiSymmetricFunctions(QQ).F()
sage: F.dual()
Non-Commutative Symmetric Functions over the Rational Field in the Ribbon basis

class QuasiSymmetricFunctions.HazewinkelLambda(QSym)

The Hazewinkel lambda basis of the quasi-symmetric functions.

This basis goes back to [Haz2004], albeit it is indexed in a different way here. It is a multiplicative basis in a weak sense of this word (the product of any two basis elements is a basis element, but of course not the one obtained by concatenating the indexing compositions).

In [Haz2004], Hazewinkel showed that the $$\mathbf{k}$$-algebra $$\mathrm{QSym}$$ is a polynomial algebra. (The proof is correct but rests upon an unproven claim that the lexicographically largest term of the $$n$$-th shuffle power of a Lyndon word is the $$n$$-fold concatenatenation of this Lyndon word with itself, occuring $$n!$$ times in that shuffle power. But this can be deduced from Section 2 of [Rad1979].) More precisely, he showed that $$\mathrm{QSym}$$ is generated, as a free commutative $$\mathbf{k}$$-algebra, by the elements $$\lambda^n(M_I)$$, where $$n$$ ranges over the positive integers, and $$I$$ ranges over all compositions which are Lyndon words and whose entries have gcd $$1$$. Here, $$\lambda^n$$ denotes the $$n$$-th lambda operation as explained in lambda_of_monomial().

Thus, products of these generators form a $$\mathbf{k}$$-module basis of $$\mathrm{QSym}$$. We index this basis by compositions here. More precisely, we define the Hazewinkel lambda basis $$(\mathrm{HWL}_I)_I$$ (with $$I$$ ranging over all compositions) as follows:

Let $$I$$ be a composition. Let $$I = I_1 I_2 \ldots I_k$$ be the Chen-Fox-Lyndon factorization of $$I$$ (see lyndon_factorization() ). For every $$j \in \{1, 2, \ldots , k\}$$, let $$g_j$$ be the gcd of the entries of the Lyndon word $$I_j$$, and let $$J_j$$ be the result of dividing the entries of $$I_j$$ by this gcd. Then, $$\mathrm{HWL}_I$$ is defined to be $$\prod_{j=1}^{k} \lambda^{g_j} (M_{J_j})$$.

Todo

The conversion from the M basis to the HWL basis is currently implemented in the naive way (inverting the base-change matrix in the other direction). This matrix is not triangular (not even after any permutations of the bases), and there could very well be a faster method (the one given by Hazewinkel?).

EXAMPLES:

sage: QSym = QuasiSymmetricFunctions(ZZ)
sage: HWL = QSym.HazewinkelLambda()
sage: M = QSym.M()
sage: M(HWL([2]))
M[1, 1]
sage: M(HWL([1,1]))
2*M[1, 1] + M[2]
sage: M(HWL([1,2]))
M[1, 2]
sage: M(HWL([2,1]))
3*M[1, 1, 1] + M[1, 2] + M[2, 1]
sage: M(HWL(Composition([])))
M[]
sage: HWL(M([1,1]))
HWL[2]
sage: HWL(M(Composition([2])))
HWL[1, 1] - 2*HWL[2]
sage: HWL(M([1]))
HWL[1]


TESTS:

Transforming from the M-basis into the HWL-basis and back returns us to where we started:

sage: all( M(HWL(M[I])) == M[I] for I in Compositions(3) )
True
sage: all( HWL(M(HWL[I])) == HWL[I] for I in Compositions(4) )
True


Checking the HWL basis elements corresponding to Lyndon words:

sage: all( M(HWL[Composition(I)])
....:      == M.lambda_of_monomial([i // gcd(I) for i in I], gcd(I))
....:      for I in LyndonWords(e=3, k=2) )
True

product_on_basis(I, J)

The product on Hazewinkel Lambda basis elements.

The product of the basis elements indexed by two compositions $$I$$ and $$J$$ is the basis element obtained by concatenating the Lyndon factorizations of the words $$I$$ and $$J$$, then reordering the Lyndon factors in nonincreasing order, and finally concatenating them in this order (giving a new composition).

INPUT:

• I, J – compositions

OUTPUT:

• The product of the Hazewinkel Lambda quasi-symmetric functions indexed by I and J, expressed in the Hazewinkel Lambda basis.

EXAMPLES:

sage: HWL = QuasiSymmetricFunctions(QQ).HazewinkelLambda()
sage: c1 = Composition([1, 2, 1])
sage: c2 = Composition([2, 1, 3, 2])
sage: HWL.product_on_basis(c1, c2)
HWL[2, 1, 3, 2, 1, 2, 1]
sage: HWL.product_on_basis(c1, Composition([]))
HWL[1, 2, 1]
sage: HWL.product_on_basis(Composition([]), Composition([]))
HWL[]


TESTS:

sage: M = QuasiSymmetricFunctions(QQ).M()
sage: all( all( M(HWL[I] * HWL[J]) == M(HWL[I]) * M(HWL[J])
....:           for I in Compositions(3) )
....:      for J in Compositions(3) )
True

class QuasiSymmetricFunctions.Monomial(QSym)

The Hopf algebra of quasi-symmetric function in the Monomial basis.

EXAMPLES:

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: M = QSym.M()
sage: F = QSym.F()
sage: M(F[2,2])
M[1, 1, 1, 1] + M[1, 1, 2] + M[2, 1, 1] + M[2, 2]
sage: m = SymmetricFunctions(QQ).m()
sage: M(m[3,1,1])
M[1, 1, 3] + M[1, 3, 1] + M[3, 1, 1]
sage: (1+M[1])^3
M[] + 3*M[1] + 6*M[1, 1] + 6*M[1, 1, 1] + 3*M[1, 2] + 3*M[2] + 3*M[2, 1] + M[3]
sage: M[1,2,1].coproduct()
M[] # M[1, 2, 1] + M[1] # M[2, 1] + M[1, 2] # M[1] + M[1, 2, 1] # M[]


The following is an alias for this basis:

sage: QSym.Monomial()
Quasisymmetric functions over the Rational Field in the Monomial basis


TESTS:

sage: M(F([]))
M[]
sage: M(F(0))
0
sage: M(m([]))
M[]

Element

alias of Monomial.Element

antipode_on_basis(compo)

Return the result of the antipode applied to a quasi-symmetric Monomial basis element.

INPUT:

• compo – composition

OUTPUT:

• The result of the antipode applied to the composition compo, expressed in the Monomial basis.

EXAMPLES:

sage: M = QuasiSymmetricFunctions(QQ).M()
sage: M.antipode_on_basis(Composition([2,1]))
M[1, 2] + M[3]
sage: M.antipode_on_basis(Composition([]))
M[]

coproduct_on_basis(compo)

Return the coproduct of a Monomial basis element.

Combinatorial rule: deconcatenation.

INPUT:

• compo – composition

OUTPUT:

• The coproduct applied to the Monomial quasi-symmetric function indexed by compo, expressed in the Monomial basis.

EXAMPLES:

sage: M=QuasiSymmetricFunctions(QQ).Monomial()
sage: M[4,2,3].coproduct()
M[] # M[4, 2, 3] + M[4] # M[2, 3] + M[4, 2] # M[3] + M[4, 2, 3] # M[]
sage: M.coproduct_on_basis(Composition([]))
M[] # M[]

dual()

Return the dual basis to the Monomial basis. This is the complete basis of the non-commutative symmetric functions.

OUTPUT:

• The complete basis of the non-commutative symmetric functions.

EXAMPLES:

sage: M = QuasiSymmetricFunctions(QQ).M()
sage: M.dual()
Non-Commutative Symmetric Functions over the Rational Field in the Complete basis

lambda_of_monomial(I, n)

Return the image of the monomial quasi-symmetric function $$M_I$$ under the lambda-map $$\lambda^n$$, expanded in the monomial basis.

The ring of quasi-symmetric functions over the integers, $$\mathrm{QSym}_{\ZZ}$$ (and more generally, the ring of quasi-symmetric functions over any binomial ring) becomes a $$\lambda$$-ring (with the $$\lambda$$-structure inherited from the ring of formal power series, so that $$\lambda^i(x_j)$$ is $$x_j$$ if $$i = 1$$ and $$0$$ if $$i > 1$$).

The Adams operations of this $$\lambda$$-ring are the Frobenius endomorphisms $$\mathbf{f}_n$$ (see frobenius() for their definition). Using these endomorphisms, the $$\lambda$$-operations can be explicitly computed via the formula

$\exp \left(- \sum_{n=1}^{\infty} \frac{1}{n} \mathbf{f}_n(x) t^n \right) = \sum_{j=0}^{\infty} (-1)^j \lambda^j(x) t^j$

in the ring of formal power series in a variable $$t$$ over the ring of quasi-symmetric functions. In particular, every composition $$I = (I_1, I_2, \cdots, I_\ell )$$ satisfies

$\exp \left(- \sum_{n=1}^{\infty} \frac{1}{n} M_{(nI_1, nI_2, \cdots, nI_\ell )} t^n \right) = \sum_{j=0}^{\infty} (-1)^j \lambda^j(M_I) t^j$

(corrected version of Remark 2.4 in [Haz2004]).

The quasi-symmetric functions $$\lambda^i(M_I)$$ with $$n$$ ranging over the positive integers and $$I$$ ranging over the reduced Lyndon compositions (i. e., compositions which are Lyndon words and have the gcd of their entries equal to $$1$$) form a set of free polynomial generators for $$\mathrm{QSym}$$. See [Haz2004] for a major part of the proof.

INPUT:

• I – composition
• n – nonnegative integer

OUTPUT:

The quasi-symmetric function $$\lambda^n(M_I)$$, expanded in the monomial basis over the ground ring of self.

EXAMPLES:

sage: M = QuasiSymmetricFunctions(CyclotomicField()).Monomial()
sage: M.lambda_of_monomial([1, 2], 2)
2*M[1, 1, 2, 2] + M[1, 1, 4] + M[1, 2, 1, 2] + M[1, 3, 2] + M[2, 2, 2]
sage: M.lambda_of_monomial([1, 1], 2)
3*M[1, 1, 1, 1] + M[1, 1, 2] + M[1, 2, 1] + M[2, 1, 1]
sage: M = QuasiSymmetricFunctions(Integers(19)).Monomial()
sage: M.lambda_of_monomial([1, 2], 3)
6*M[1, 1, 1, 2, 2, 2] + 3*M[1, 1, 1, 2, 4] + 3*M[1, 1, 1, 4, 2]
+ M[1, 1, 1, 6] + 4*M[1, 1, 2, 1, 2, 2] + 2*M[1, 1, 2, 1, 4]
+ 2*M[1, 1, 2, 2, 1, 2] + 2*M[1, 1, 2, 3, 2] + 4*M[1, 1, 3, 2, 2]
+ 2*M[1, 1, 3, 4] + M[1, 1, 4, 1, 2] + M[1, 1, 5, 2]
+ 2*M[1, 2, 1, 1, 2, 2] + M[1, 2, 1, 1, 4] + M[1, 2, 1, 2, 1, 2]
+ M[1, 2, 1, 3, 2] + 4*M[1, 2, 2, 2, 2] + M[1, 2, 2, 4] + M[1, 2, 4, 2]
+ 2*M[1, 3, 1, 2, 2] + M[1, 3, 1, 4] + M[1, 3, 2, 1, 2] + M[1, 3, 3, 2]
+ M[1, 4, 2, 2] + 3*M[2, 1, 2, 2, 2] + M[2, 1, 2, 4] + M[2, 1, 4, 2]
+ 2*M[2, 2, 1, 2, 2] + M[2, 2, 1, 4] + M[2, 2, 2, 1, 2] + M[2, 2, 3, 2]
+ 2*M[2, 3, 2, 2] + M[2, 3, 4] + M[3, 2, 2, 2]


The map $$\lambda^0$$ sends everything to $$1$$:

sage: M = QuasiSymmetricFunctions(ZZ).Monomial()
sage: all( M.lambda_of_monomial(I, 0) == M.one()
....:      for I in Compositions(3) )
True


The map $$\lambda^1$$ is the identity map:

sage: M = QuasiSymmetricFunctions(QQ).Monomial()
sage: all( M.lambda_of_monomial(I, 1) == M(I)
....:      for I in Compositions(3) )
True
sage: M = QuasiSymmetricFunctions(Integers(5)).Monomial()
sage: all( M.lambda_of_monomial(I, 1) == M(I)
....:      for I in Compositions(3) )
True
sage: M = QuasiSymmetricFunctions(ZZ).Monomial()
sage: all( M.lambda_of_monomial(I, 1) == M(I)
....:      for I in Compositions(3) )
True

product_on_basis(I, J)

The product on Monomial basis elements.

The product of the basis elements indexed by two compositions $$I$$ and $$J$$ is the sum of the basis elements indexed by compositions in the stuffle product (also called the overlapping shuffle product) of $$I$$ and $$J$$.

INPUT:

• I, J – compositions

OUTPUT:

• The product of the Monomial quasi-symmetric functions indexed by I and J, expressed in the Monomial basis.

EXAMPLES:

sage: M = QuasiSymmetricFunctions(QQ).Monomial()
sage: c1 = Composition([2])
sage: c2 = Composition([1,3])
sage: M.product_on_basis(c1, c2)
M[1, 2, 3] + M[1, 3, 2] + M[1, 5] + M[2, 1, 3] + M[3, 3]
sage: M.product_on_basis(c1, Composition([]))
M[2]

class QuasiSymmetricFunctions.Quasisymmetric_Schur(QSym)

The Hopf algebra of quasi-symmetric function in the Quasisymmetric Schur basis.

The basis of Quasisymmetric Schur functions is defined in [QSCHUR].

EXAMPLES:

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: QS = QSym.QS()
sage: F = QSym.F()
sage: M = QSym.M()
sage: F(QS[1,2])
F[1, 2]
sage: M(QS[1,2])
M[1, 1, 1] + M[1, 2]
sage: s = SymmetricFunctions(QQ).s()
sage: QS(s[2,1,1])
QS[1, 1, 2] + QS[1, 2, 1] + QS[2, 1, 1]

QuasiSymmetricFunctions.a_realization()

Return the realization of the Monomial basis of the ring of quasi-symmetric functions.

OUTPUT:

• The Monomial basis of quasi-symmetric functions.

EXAMPLES:

sage: QuasiSymmetricFunctions(QQ).a_realization()
Quasisymmetric functions over the Rational Field in the Monomial basis

QuasiSymmetricFunctions.dual()

Return the dual Hopf algebra of the quasi-symmetric functions, which is the non-commutative symmetric functions.

OUTPUT:

• The non-commutative symmetric functions.

EXAMPLES:

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: QSym.dual()
Non-Commutative Symmetric Functions over the Rational Field

class QuasiSymmetricFunctions.dualImmaculate(QSym)

The dual immaculate basis of the quasi-symmetric functions.

This basis first appears in [BBSSZ2012].

REFERENCES:

 [BBSSZ2012] Chris Berg, Nantel Bergeron, Franco Saliola, Luis Serrano, Mike Zabrocki, A lift of the Schur and Hall-Littlewood bases to non-commutative symmetric functions, Arxiv 1208.5191v3.

EXAMPLES:

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: dI = QSym.dI()
sage: dI([1,3,2])*dI([1])  # long time (6s on sage.math, 2013)
dI[1, 1, 3, 2] + dI[2, 3, 2]
sage: dI([1,3])*dI([1,1])
dI[1, 1, 1, 3] + dI[1, 1, 4] + dI[1, 2, 3] - dI[1, 3, 2] - dI[1, 4, 1] - dI[1, 5] + dI[2, 3, 1] + dI[2, 4]
sage: dI([3,1])*dI([2,1])  # long time (7s on sage.math, 2013)
dI[1, 1, 5] - dI[1, 4, 1, 1] - dI[1, 4, 2] - 2*dI[1, 5, 1] - dI[1, 6] - dI[2, 4, 1] - dI[2, 5] - dI[3, 1, 3] + dI[3, 2, 1, 1] + dI[3, 2, 2] + dI[3, 3, 1] + dI[4, 1, 1, 1] + 2*dI[4, 2, 1] + dI[4, 3] + dI[5, 1, 1] + dI[5, 2]
sage: F = QSym.F()
sage: dI(F[1,3,1])
-dI[1, 1, 1, 2] + dI[1, 1, 2, 1] - dI[1, 2, 2] + dI[1, 3, 1]
sage: F(dI(F([2,1,3])))
F[2, 1, 3]

QuasiSymmetricFunctions.from_polynomial(f, check=True)

Return the quasi-symmetric function in the Monomial basis corresponding to the quasi-symmetric polynomial f.

INPUT:

• f – a polynomial in finitely many variables over the same base ring as self. It is assumed that this polynomial is quasi-symmetric.
• check – boolean (default: True), checks whether the polynomial is indeed quasi-symmetric.

OUTPUT:

• quasi-symmetric function in the Monomial basis

EXAMPLES:

sage: P = PolynomialRing(QQ, 'x', 3)
sage: x = P.gens()
sage: f = x[0] + x[1] + x[2]
sage: QSym = QuasiSymmetricFunctions(QQ)
sage: QSym.from_polynomial(f)
M[1]


Beware of setting check=False:

sage: f = x[0] + 2*x[1] + x[2]
sage: QSym.from_polynomial(f, check=True)
Traceback (most recent call last):
...
ValueError: x0 + 2*x1 + x2 is not a quasi-symmetric polynomial
sage: QSym.from_polynomial(f, check=False)
M[1]


To expand the quasi-symmetric function in a basis other than the Monomial basis, the following shorthands are provided:

sage: M = QSym.Monomial()
sage: f = x[0]**2+x[1]**2+x[2]**2
sage: g = M.from_polynomial(f); g
M[2]
sage: F = QSym.Fundamental()
sage: F(g)
-F[1, 1] + F[2]
sage: F.from_polynomial(f)
-F[1, 1] + F[2]


#### Previous topic

Non-Commutative Symmetric Functions

#### Next topic

Symmetric Functions in Non-Commuting Variables