Generic code for bases

This is a collection of code that is shared by bases of noncommutative symmetric functions and quasisymmetric functions.

AUTHORS:

  • Jason Bandlow
  • Franco Saliola
  • Chris Berg
class sage.combinat.ncsf_qsym.generic_basis_code.AlgebraMorphism(domain, on_generators, position=0, codomain=None, category=None, anti=False)

Bases: sage.modules.with_basis.morphism.ModuleMorphismByLinearity

A class for algebra morphism defined on a free algebra from the image of the generators

class sage.combinat.ncsf_qsym.generic_basis_code.BasesOfQSymOrNCSF(parent_with_realization)

Bases: sage.categories.realizations.Category_realization_of_parent

class ElementMethods

Bases: object

degree()

The maximum of the degrees of the homogeneous summands.

See also

homogeneous_degree()

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
degree_negation()

Return the image of self under the degree negation automorphism of the parent of self.

The degree negation is the automorphism which scales every homogeneous element of degree \(k\) by \((-1)^k\) (for all \(k\)).

Calling degree_negation(self) is equivalent to calling self.parent().degree_negation(self).

EXAMPLES:

sage: NSym = NonCommutativeSymmetricFunctions(ZZ)
sage: S = NSym.S()
sage: f = 2*S[2,1] + 4*S[1,1] - 5*S[1,2] - 3*S[[]]
sage: f.degree_negation()
-3*S[] + 4*S[1, 1] + 5*S[1, 2] - 2*S[2, 1]

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: dI = QSym.dualImmaculate()
sage: f = -3*dI[2,1] + 4*dI[2] + 2*dI[1]
sage: f.degree_negation()
-2*dI[1] + 4*dI[2] + 3*dI[2, 1]

Todo

Generalize this to all graded vector spaces?

duality_pairing(y)

The duality pairing between elements of \(NSym\) and elements of \(QSym\).

The complete basis is dual to the monomial basis with respect to this pairing.

INPUT:

  • y – an element of the dual Hopf algebra of self

OUTPUT:

  • The result of pairing self with y.

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
skew_by(y, side='left')

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:

  • y – an element of the dual Hopf algebra of self
  • side – (Default=’left’) Either ‘left’ or ‘right’

OUTPUT:

  • The result of skewing self by y, on the side side

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
class ParentMethods

Bases: object

alternating_sum_of_compositions(n)

Alternating sum over compositions of n.

Note that this differs from the method alternating_sum_of_finer_compositions() because the coefficient of the composition \(1^n\) is positive. This method is used in the expansion of the elementary generators into the complete generators and vice versa.

INPUT:

  • n – a positive integer

OUTPUT:

  • The expansion of the complete generator indexed by n into the elementary basis.

EXAMPLES:

sage: L=NonCommutativeSymmetricFunctions(QQ).L()
sage: L.alternating_sum_of_compositions(0)
L[]
sage: L.alternating_sum_of_compositions(1)
L[1]
sage: L.alternating_sum_of_compositions(2)
L[1, 1] - L[2]
sage: L.alternating_sum_of_compositions(3)
L[1, 1, 1] - L[1, 2] - L[2, 1] + L[3]
sage: S=NonCommutativeSymmetricFunctions(QQ).S()
sage: S.alternating_sum_of_compositions(3)
S[1, 1, 1] - S[1, 2] - S[2, 1] + S[3]
alternating_sum_of_fatter_compositions(composition)

Return the alternating sum of fatter compositions in a basis of the non-commutative symmetric functions.

INPUT:

  • composition – a composition

OUTPUT:

  • The alternating sum of the compositions fatter than composition, in the basis self. The alternation is upon the length of the compositions, and is normalized so that composition has coefficient \(1\).

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]
alternating_sum_of_finer_compositions(composition, conjugate=False)

Return the alternating sum of finer compositions in a basis of the non-commutative symmetric functions.

INPUT:

  • composition – a composition
  • conjugate – (default: False) a boolean

OUTPUT:

  • The alternating sum of the compositions finer than composition, in the basis self. The alternation is upon the length of the compositions, and is normalized so that composition has coefficient \(1\). If the variable conjugate is set to True, then the conjugate of composition is used instead of composition.

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]
counit_on_basis(I)

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
degree_negation(element)

Return the image of element under the degree negation automorphism of self.

The degree negation is the automorphism which scales every homogeneous element of degree \(k\) by \((-1)^k\) (for all \(k\)).

INPUT:

  • element – element of self

EXAMPLES:

sage: NSym = NonCommutativeSymmetricFunctions(ZZ)
sage: S = NSym.S()
sage: f = 2*S[2,1] + 4*S[1,1] - 5*S[1,2] - 3*S[[]]
sage: S.degree_negation(f)
-3*S[] + 4*S[1, 1] + 5*S[1, 2] - 2*S[2, 1]

sage: QSym = QuasiSymmetricFunctions(QQ)
sage: dI = QSym.dualImmaculate()
sage: f = -3*dI[2,1] + 4*dI[2] + 2*dI[1]
sage: dI.degree_negation(f)
-2*dI[1] + 4*dI[2] + 3*dI[2, 1]

Todo

Generalize this to all graded vector spaces?

degree_on_basis(I)

Return the degree of the basis element indexed by \(I\).

INPUT:

  • I – a composition

OUTPUT:

  • The degree of the non-commutative symmetric function basis element of self indexed by I. By definition, this is the size of the composition I.

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
duality_pairing(x, y)

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:

  • x – an element of self
  • y – an element in the dual basis of self

OUTPUT:

  • The result of pairing the function x from self with the function y from the dual basis of self

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
duality_pairing_by_coercion(x, y)

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:

  • x – an element of self
  • y – an element in the dual basis of self

OUTPUT:

  • The result of pairing the function x from self with the function y from the dual basis of self

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
duality_pairing_matrix(basis, degree)

The matrix of scalar products between elements of NSym and elements of QSym.

INPUT:

  • basis – A basis of the dual Hopf algebra
  • degree – a non-negative integer

OUTPUT:

  • The matrix of scalar products between the basis self and the basis basis in the dual Hopf algebra in degree degree.

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]
one_basis()

Return the empty composition.

OUTPUT:

  • The empty composition.

EXAMPLES:

sage: L=NonCommutativeSymmetricFunctions(QQ).L()
sage: parent(L)
<class 'sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Elementary_with_category'>
sage: parent(L).one_basis()
[]
skew(x, y, side='left')

Return a function x in self skewed by a function y in the Hopf dual of self.

INPUT:

  • x – a non-commutative or quasi-symmetric function; it is an element of self
  • y – a quasi-symmetric or non-commutative symmetric function; it is an element of the dual algebra of self
  • side – (default: 'left') either 'left' or 'right'

OUTPUT:

  • The result of skewing the element x by the Hopf algebra element y (either from the left or from the right, as determined by side), written in the basis self.

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
sum_of_fatter_compositions(composition)

Return the sum of all fatter compositions.

INPUT:

  • composition – a composition

OUTPUT:

  • the sum of all basis elements which are indexed by compositions fatter (coarser?) than composition.

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]
sum_of_finer_compositions(composition)

Return the sum of all finer compositions.

INPUT:

  • composition – a composition

OUTPUT:

  • The sum of all basis self elements which are indexed by compositions finer than composition.

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]
sum_of_partition_rearrangements(par)

Return the sum of all basis elements indexed by compositions which can be sorted to obtain a given partition.

INPUT:

  • par – a partition

OUTPUT:

  • The sum of all self basis elements indexed by compositions which are permutations of par (without multiplicity).

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[]
super_categories()
sage.combinat.ncsf_qsym.generic_basis_code.GradedModulesWithInternalProduct

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