This is a collection of code that is shared by bases of noncommutative symmetric functions and quasisymmetric functions.
AUTHORS:
Bases: sage.categories.modules_with_basis.ModuleMorphismByLinearity
A class for algebra morphism defined on a free algebra from the image of the generators
Bases: sage.categories.realizations.Category_realization_of_parent
TESTS:
sage: from sage.categories.realizations import Category_realization_of_parent
sage: A = Sets().WithRealizations().example(); A
The subset algebra of {1, 2, 3} over Rational Field
sage: C = A.Realizations(); C
Category of realizations of The subset algebra of {1, 2, 3} over Rational Field
sage: isinstance(C, Category_realization_of_parent)
True
sage: C.parent_with_realization
The subset algebra of {1, 2, 3} over Rational Field
sage: TestSuite(C).run()
The maximum of the degrees of the homogeneous summands.
See also
EXAMPLES:
sage: S = NonCommutativeSymmetricFunctions(QQ).S()
sage: (x, y) = (S[2], S[3])
sage: x.degree()
2
sage: (x^3 + 4*y^2).degree()
6
sage: ((1 + x)^3).degree()
6
sage: F = QuasiSymmetricFunctions(QQ).F()
sage: (x, y) = (F[2], F[3])
sage: x.degree()
2
sage: (x^3 + 4*y^2).degree()
6
sage: ((1 + x)^3).degree()
6
TESTS:
sage: S = NonCommutativeSymmetricFunctions(QQ).S()
sage: S.zero().degree()
Traceback (most recent call last):
...
ValueError: The zero element does not have a well-defined degree.
sage: F = QuasiSymmetricFunctions(QQ).F()
sage: F.zero().degree()
Traceback (most recent call last):
...
ValueError: The zero element does not have a well-defined degree.
The duality pairing between elements of NSym and elements of QSym The complete basis is dual to the monomial basis.
INPUT:
OUTPUT:
EXAMPLES:
sage: R = NonCommutativeSymmetricFunctions(QQ).Ribbon()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: R[1,1,2].duality_pairing(F[1,1,2])
1
sage: R[1,2,1].duality_pairing(F[1,1,2])
0
sage: L = NonCommutativeSymmetricFunctions(QQ).Elementary()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: L[1,2].duality_pairing(F[1,2])
0
sage: L[1,1,1].duality_pairing(F[1,2])
1
The operation which is dual to multiplication by y, where y is an element of the dual space of self.
This is calculated through the coproduct of self and the expansion of y in the dual basis.
INPUT:
OUTPUT:
EXAMPLES:
Skewing an element of NCSF by an element of QSym:
sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: R([2,2,2]).skew_by(F[1,1])
R[1, 1, 2] + R[1, 2, 1] + R[1, 3] + R[2, 1, 1] + 2*R[2, 2] + R[3, 1] + R[4]
sage: R([2,2,2]).skew_by(F[2])
R[1, 1, 2] + R[1, 2, 1] + R[1, 3] + R[2, 1, 1] + 3*R[2, 2] + R[3, 1] + R[4]
Skewing an element of QSym by an element of NCSF:
sage: S = NonCommutativeSymmetricFunctions(QQ).S()
sage: R = NonCommutativeSymmetricFunctions(QQ).R()
sage: F = QuasiSymmetricFunctions(QQ).F()
sage: F[3,2].skew_by(R[1,1])
0
sage: F[3,2].skew_by(R[1,1], side='right')
0
sage: F[3,2].skew_by(S[1,1,1], side='right')
F[2]
sage: F[3,2].skew_by(S[1,2], side='right')
F[2]
sage: F[3,2].skew_by(S[2,1], side='right')
0
sage: F[3,2].skew_by(S[1,1,1])
F[2]
sage: F[3,2].skew_by(S[1,1])
F[1, 2]
sage: F[3,2].skew_by(S[1])
F[2, 2]
sage: S = NonCommutativeSymmetricFunctions(QQ).S()
sage: R = NonCommutativeSymmetricFunctions(QQ).R()
sage: M = QuasiSymmetricFunctions(QQ).M()
sage: M[3,2].skew_by(S[2])
0
sage: M[3,2].skew_by(S[2], side='right')
M[3]
sage: M[3,2].skew_by(S[3])
M[2]
sage: M[3,2].skew_by(S[3], side='right')
0
Returns the alternating sum of fatter compositions in a basis of the non- commutative symmetric functions.
INPUT:
OUTPUT:
EXAMPLES:
sage: NCSF=NonCommutativeSymmetricFunctions(QQ)
sage: elementary = NCSF.elementary()
sage: elementary.alternating_sum_of_fatter_compositions(Composition([2,2,1]))
L[2, 2, 1] - L[2, 3] - L[4, 1] + L[5]
sage: elementary.alternating_sum_of_fatter_compositions(Composition([1,2]))
L[1, 2] - L[3]
TESTS:
sage: complete = NonCommutativeSymmetricFunctions(ZZ).complete()
sage: I = Composition([1,1])
sage: x = complete.alternating_sum_of_fatter_compositions(I)
sage: [c.parent() for c in x.coefficients()]
[Integer Ring, Integer Ring]
Returns the alternating sum of finer compositions in a basis of the non- commutative symmetric functions.
INPUT:
OUTPUT:
EXAMPLES:
sage: NCSF = NonCommutativeSymmetricFunctions(QQ)
sage: elementary = NCSF.elementary()
sage: elementary.alternating_sum_of_finer_compositions(Composition([2,2,1]))
L[1, 1, 1, 1, 1] - L[1, 1, 2, 1] - L[2, 1, 1, 1] + L[2, 2, 1]
sage: elementary.alternating_sum_of_finer_compositions(Composition([1,2]))
-L[1, 1, 1] + L[1, 2]
TESTS:
sage: complete = NonCommutativeSymmetricFunctions(ZZ).complete()
sage: I = Composition([2])
sage: x = complete.alternating_sum_of_finer_compositions(I)
sage: [c.parent() for c in x.coefficients()]
[Integer Ring, Integer Ring]
The counit is defined by sending all elements of positive degree to zero.
EXAMPLES:
sage: S = NonCommutativeSymmetricFunctions(QQ).S()
sage: S.counit_on_basis([1,3])
0
sage: M = QuasiSymmetricFunctions(QQ).M()
sage: M.counit_on_basis([1,3])
0
TESTS:
sage: S.counit_on_basis([])
1
sage: S.counit_on_basis(Composition([]))
1
sage: M.counit_on_basis([])
1
sage: M.counit_on_basis(Composition([]))
1
Return the degree of the basis element indexed by .
INPUT:
OUTPUT:
EXAMPLES:
sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon()
sage: R.degree_on_basis(Composition([2,3]))
5
sage: M = QuasiSymmetricFunctions(QQ).Monomial()
sage: M.degree_on_basis(Composition([3,2]))
5
sage: M.degree_on_basis(Composition([]))
0
The duality pairing between elements of NSym and elements of QSym.
This is a default implementation and assumes that self.realizations_of().a_realization() is dual to self.realizations_of().dual().a_realization().
INPUT:
OUTPUT:
EXAMPLES:
sage: R = NonCommutativeSymmetricFunctions(QQ).Ribbon()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: R.duality_pairing(R[1,1,2], F[1,1,2])
1
sage: R.duality_pairing(R[1,2,1], F[1,1,2])
0
sage: F.duality_pairing(F[1,2,1], R[1,1,2])
0
sage: S = NonCommutativeSymmetricFunctions(QQ).Complete()
sage: M = QuasiSymmetricFunctions(QQ).Monomial()
sage: S.duality_pairing(S[1,1,2], M[1,1,2])
1
sage: S.duality_pairing(S[1,2,1], M[1,1,2])
0
sage: M.duality_pairing(M[1,1,2], S[1,1,2])
1
sage: M.duality_pairing(M[1,2,1], S[1,1,2])
0
sage: S = NonCommutativeSymmetricFunctions(QQ).Complete()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: S.duality_pairing(S[1,2], F[1,1,1])
0
sage: S.duality_pairing(S[1,1,1,1], F[4])
1
The duality pairing between elements of NSym and elements of QSym.
This is a default implementation that uses self.realizations_of().a_realization() and its dual basis.
INPUT:
OUTPUT:
EXAMPLES:
sage: L = NonCommutativeSymmetricFunctions(QQ).Elementary()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: L.duality_pairing_by_coercion(L[1,2], F[1,2])
0
sage: F.duality_pairing_by_coercion(F[1,2], L[1,2])
0
sage: L.duality_pairing_by_coercion(L[1,1,1], F[1,2])
1
sage: F.duality_pairing_by_coercion(F[1,2], L[1,1,1])
1
The matrix of scalar products between elements of NSym and elements of QSym.
INPUT:
OUTPUT:
EXAMPLES:
The ribbon basis of NCSF is dual to the fundamental basis of QSym:
sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: R.duality_pairing_matrix(F, 3)
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
sage: F.duality_pairing_matrix(R, 3)
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
The complete basis of NCSF is dual to the monomial basis of QSym:
sage: S = NonCommutativeSymmetricFunctions(QQ).complete()
sage: M = QuasiSymmetricFunctions(QQ).Monomial()
sage: S.duality_pairing_matrix(M, 3)
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
sage: M.duality_pairing_matrix(S, 3)
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
The matrix between the ribbon basis of NCSF and the monomial basis of QSym:
sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon()
sage: M = QuasiSymmetricFunctions(QQ).Monomial()
sage: R.duality_pairing_matrix(M, 3)
[ 1 -1 -1 1]
[ 0 1 0 -1]
[ 0 0 1 -1]
[ 0 0 0 1]
sage: M.duality_pairing_matrix(R, 3)
[ 1 0 0 0]
[-1 1 0 0]
[-1 0 1 0]
[ 1 -1 -1 1]
The matrix between the complete basis of NCSF and the fundamental basis of QSym:
sage: S = NonCommutativeSymmetricFunctions(QQ).complete()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: S.duality_pairing_matrix(F, 3)
[1 1 1 1]
[0 1 0 1]
[0 0 1 1]
[0 0 0 1]
A base case test:
sage: R.duality_pairing_matrix(M,0)
[1]
This returns the empty composition.
OUTPUT
EXAMPLES:
sage: L=NonCommutativeSymmetricFunctions(QQ).L()
sage: parent(L)
<class 'sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Elementary_with_category'>
sage: parent(L).one_basis()
[]
Skews a function by another function in the Hopf dual.
INPUT:
OUTPUT:
EXAMPLES:
sage: S = NonCommutativeSymmetricFunctions(QQ).complete()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: S.skew(S[2,2,2], F[1,1])
S[1, 1, 2] + S[1, 2, 1] + S[2, 1, 1]
sage: S.skew(S[2,2,2], F[2])
S[1, 1, 2] + S[1, 2, 1] + S[2, 1, 1] + 3*S[2, 2]
sage: R = NonCommutativeSymmetricFunctions(QQ).ribbon()
sage: F = QuasiSymmetricFunctions(QQ).Fundamental()
sage: R.skew(R[2,2,2], F[1,1])
R[1, 1, 2] + R[1, 2, 1] + R[1, 3] + R[2, 1, 1] + 2*R[2, 2] + R[3, 1] + R[4]
sage: R.skew(R[2,2,2], F[2])
R[1, 1, 2] + R[1, 2, 1] + R[1, 3] + R[2, 1, 1] + 3*R[2, 2] + R[3, 1] + R[4]
sage: S = NonCommutativeSymmetricFunctions(QQ).S()
sage: R = NonCommutativeSymmetricFunctions(QQ).R()
sage: M = QuasiSymmetricFunctions(QQ).M()
sage: M.skew(M[3,2], S[2])
0
sage: M.skew(M[3,2], S[2], side='right')
M[3]
sage: M.skew(M[3,2], S[3])
M[2]
sage: M.skew(M[3,2], S[3], side='right')
0
TESTS:
sage: R = NonCommutativeSymmetricFunctions(QQ).R()
sage: R.skew([2,1], [1])
Traceback (most recent call last):
...
AssertionError: x must be an element of Non-Commutative Symmetric Functions over the Rational Field
sage: R([2,1]).skew_by([1])
Traceback (most recent call last):
...
AssertionError: y must be an element of Quasisymmetric functions over the Rational Field
sage: F = QuasiSymmetricFunctions(QQ).F()
sage: F([2,1]).skew_by([1])
Traceback (most recent call last):
...
AssertionError: y must be an element of Non-Commutative Symmetric Functions over the Rational Field
Returns the sum of all fatter compositions.
INPUT:
OUTPUT:
EXAMPLES:
sage: L=NonCommutativeSymmetricFunctions(QQ).L()
sage: L.sum_of_fatter_compositions(Composition([2,1]))
L[2, 1] + L[3]
sage: R=NonCommutativeSymmetricFunctions(QQ).R()
sage: R.sum_of_fatter_compositions(Composition([1,3]))
R[1, 3] + R[4]
Returns the sum of all finer compositions.
INPUT:
OUTPUT:
EXAMPLES:
sage: L=NonCommutativeSymmetricFunctions(QQ).L()
sage: L.sum_of_finer_compositions(Composition([2,1]))
L[1, 1, 1] + L[2, 1]
sage: R=NonCommutativeSymmetricFunctions(QQ).R()
sage: R.sum_of_finer_compositions(Composition([1,3]))
R[1, 1, 1, 1] + R[1, 1, 2] + R[1, 2, 1] + R[1, 3]
Returns the sum of all basis elements indexed by compositions which can be shuffled to obtain a partition.
INPUT:
OUTPUT:
EXAMPLES:
sage: NCSF=NonCommutativeSymmetricFunctions(QQ)
sage: elementary = NCSF.elementary()
sage: elementary.sum_of_partition_rearrangements(Partition([2,2,1]))
L[1, 2, 2] + L[2, 1, 2] + L[2, 2, 1]
sage: elementary.sum_of_partition_rearrangements(Partition([3,2,1]))
L[1, 2, 3] + L[1, 3, 2] + L[2, 1, 3] + L[2, 3, 1] + L[3, 1, 2] + L[3, 2, 1]
sage: elementary.sum_of_partition_rearrangements(Partition([]))
L[]
TESTS:
sage: from sage.combinat.ncsf_qsym.generic_basis_code import BasesOfQSymOrNCSF
sage: QSym = QuasiSymmetricFunctions(QQ)
sage: BasesOfQSymOrNCSF(QSym).super_categories()
[Category of realizations of Quasisymmetric functions over the Rational Field,
Category of graded hopf algebras with basis over Rational Field,
Join of Category of graded hopf algebras over Rational Field and Category of realizations of hopf algebras over Rational Field]
Bases: sage.categories.category_types.Category_over_base_ring
Constructs the class of modules with internal product. This is used to give an internal product structure to the non-commutative symmetric functions.
EXAMPLES:
sage: from sage.combinat.ncsf_qsym.generic_basis_code import GradedModulesWithInternalProduct
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: R = N.ribbon()
sage: R in GradedModulesWithInternalProduct(QQ)
True
Returns the internal product of two non-commutative symmetric functions.
INPUT:
OUTPUT:
EXAMPLES:
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: S = N.complete()
sage: x = S.an_element(); x
2*S[] + 2*S[1] + 3*S[1, 1]
sage: x.internal_product(S[2])
3*S[1, 1]
sage: x.internal_product(S[1])
2*S[1]
sage: S[1,2].internal_product(S[1,2])
S[1, 1, 1] + S[1, 2]
Internal product as an endomorphism of self.
This is constructed by extending the method internal_product_on_basis() bilinearly, if available, or using the method internal_product_by_coercion().
OUTPUT:
EXAMPLES:
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: S = N.complete()
sage: S.internal_product
Generic endomorphism of Non-Commutative Symmetric Functions over the Rational Field in the Complete basis
sage: S.internal_product(S[2,2], S[1,2,1])
2*S[1, 1, 1, 1] + S[1, 1, 2] + S[2, 1, 1]
sage: S.internal_product(S[2,2], S[1,2])
0
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: R = N.ribbon()
sage: R.internal_product
<bound method ....internal_product_by_coercion ...>
sage: R.internal_product_by_coercion(R[1, 1], R[1,1])
R[2]
sage: R.internal_product(R[2,2], R[1,2])
0
The internal product of the two basis elements indexed by I and J (optional)
INPUT:
- I, J – compositions indexing two elements of the basis of self
Returns the internal product of the corresponding basis elements. If this method is implemented, the internal product is defined from it by linearity.
EXAMPLES:
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: S = N.complete()
sage: S.internal_product_on_basis([2,2], [1,2,1])
2*S[1, 1, 1, 1] + S[1, 1, 2] + S[2, 1, 1]
sage: S.internal_product_on_basis([2,2], [2,1])
0
Bases: sage.categories.realizations.RealizationsCategory
TESTS:
sage: from sage.categories.covariant_functorial_construction import CovariantConstructionCategory
sage: class FooBars(CovariantConstructionCategory):
... _functor_category = "FooBars"
sage: Category.FooBars = lambda self: FooBars.category_of(self)
sage: C = FooBars(ModulesWithBasis(ZZ))
sage: C
Category of foo bars of modules with basis over Integer Ring
sage: C.base_category()
Category of modules with basis over Integer Ring
sage: latex(C)
\mathbf{FooBars}(\mathbf{ModulesWithBasis}_{\Bold{Z}})
sage: import __main__; __main__.FooBars = FooBars # Fake FooBars being defined in a python module
sage: TestSuite(C).run()
alias of Realizations.ParentMethods
EXAMPLES:
sage: from sage.combinat.ncsf_qsym.generic_basis_code import GradedModulesWithInternalProduct
sage: GradedModulesWithInternalProduct(ZZ).super_categories()
[Category of graded modules over Integer Ring]