Shuffle algebras#
AUTHORS:
Frédéric Chapoton (2013-03): Initial version
Matthieu Deneufchatel (2013-07): Implemented dual PBW basis
- class sage.algebras.shuffle_algebra.DualPBWBasis(R, names)[source]#
Bases:
CombinatorialFreeModule
The basis dual to the Poincaré-Birkhoff-Witt basis of the free algebra.
We recursively define the dual PBW basis as the basis of the shuffle algebra given by
\[\begin{split}S_w = \begin{cases} w & |w| = 1, \\ x S_u & w = xu \text{ and } w \in \mathrm{Lyn}(X), \\ \displaystyle \frac{S_{\ell_{i_1}}^{\ast \alpha_1} \ast \cdots \ast S_{\ell_{i_k}}^{\ast \alpha_k}}{\alpha_1! \cdots \alpha_k!} & w = \ell_{i_1}^{\alpha_1} \cdots \ell_{i_k}^{\alpha_k} \text{ with } \ell_1 > \cdots > \ell_k \in \mathrm{Lyn}(X). \end{cases}\end{split}\]where \(S \ast T\) denotes the shuffle product of \(S\) and \(T\) and \(\mathrm{Lyn}(X)\) is the set of Lyndon words in the alphabet \(X\).
The definition may be found in Theorem 5.3 of [Reu1993].
INPUT:
R
– ringnames
– names of the generators (string or an alphabet)
EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: S The dual Poincare-Birkhoff-Witt basis of Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field sage: S.one() S[] sage: S.one_basis() word: sage: T = ShuffleAlgebra(QQ, 'abcd').dual_pbw_basis(); T The dual Poincare-Birkhoff-Witt basis of Shuffle Algebra on 4 generators ['a', 'b', 'c', 'd'] over Rational Field sage: T.algebra_generators() (S[a], S[b], S[c], S[d])
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> S The dual Poincare-Birkhoff-Witt basis of Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field >>> S.one() S[] >>> S.one_basis() word: >>> T = ShuffleAlgebra(QQ, 'abcd').dual_pbw_basis(); T The dual Poincare-Birkhoff-Witt basis of Shuffle Algebra on 4 generators ['a', 'b', 'c', 'd'] over Rational Field >>> T.algebra_generators() (S[a], S[b], S[c], S[d])
- class Element[source]#
Bases:
IndexedFreeModuleElement
An element in the dual PBW basis.
- expand()[source]#
Expand
self
in words of the shuffle algebra.EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: f = S('ab') + S('bab') sage: f.expand() B[ab] + 2*B[abb] + B[bab]
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> f = S('ab') + S('bab') >>> f.expand() B[ab] + 2*B[abb] + B[bab]
- algebra_generators()[source]#
Return the algebra generators of
self
.EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: S.algebra_generators() (S[a], S[b])
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> S.algebra_generators() (S[a], S[b])
- antipode(elt)[source]#
Return the antipode of the element
elt
.EXAMPLES:
sage: A = ShuffleAlgebra(QQ, 'ab') sage: S = A.dual_pbw_basis() sage: w = S('abaab').antipode(); w S[abaab] - 2*S[ababa] - S[baaba] + 3*S[babaa] - 6*S[bbaaa] sage: w.antipode() S[abaab]
>>> from sage.all import * >>> A = ShuffleAlgebra(QQ, 'ab') >>> S = A.dual_pbw_basis() >>> w = S('abaab').antipode(); w S[abaab] - 2*S[ababa] - S[baaba] + 3*S[babaa] - 6*S[bbaaa] >>> w.antipode() S[abaab]
- coproduct(elt)[source]#
Return the coproduct of the element
elt
.EXAMPLES:
sage: A = ShuffleAlgebra(QQ, 'ab') sage: S = A.dual_pbw_basis() sage: S('ab').coproduct() S[] # S[ab] + S[a] # S[b] + S[ab] # S[] sage: S('ba').coproduct() S[] # S[ba] + S[a] # S[b] + S[b] # S[a] + S[ba] # S[]
>>> from sage.all import * >>> A = ShuffleAlgebra(QQ, 'ab') >>> S = A.dual_pbw_basis() >>> S('ab').coproduct() S[] # S[ab] + S[a] # S[b] + S[ab] # S[] >>> S('ba').coproduct() S[] # S[ba] + S[a] # S[b] + S[b] # S[a] + S[ba] # S[]
- counit(S)[source]#
Return the counit of
S
.EXAMPLES:
sage: F = ShuffleAlgebra(QQ,'ab').dual_pbw_basis() sage: (3*F.gen(0)+5*F.gen(1)**2).counit() 0 sage: (4*F.one()).counit() 4
>>> from sage.all import * >>> F = ShuffleAlgebra(QQ,'ab').dual_pbw_basis() >>> (Integer(3)*F.gen(Integer(0))+Integer(5)*F.gen(Integer(1))**Integer(2)).counit() 0 >>> (Integer(4)*F.one()).counit() 4
- degree_on_basis(w)[source]#
Return the degree of the element
w
.EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: [S.degree_on_basis(x.leading_support()) for x in S.some_elements() if x != 0] [0, 1, 1, 2]
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> [S.degree_on_basis(x.leading_support()) for x in S.some_elements() if x != Integer(0)] [0, 1, 1, 2]
- expansion()[source]#
Return the morphism corresponding to the expansion into words of the shuffle algebra.
EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: f = S('ab') + S('aba') sage: S.expansion(f) 2*B[aab] + B[ab] + B[aba]
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> f = S('ab') + S('aba') >>> S.expansion(f) 2*B[aab] + B[ab] + B[aba]
- expansion_on_basis(w)[source]#
Return the expansion of \(S_w\) in words of the shuffle algebra.
INPUT:
w
– a word
EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: S.expansion_on_basis(Word()) B[] sage: S.expansion_on_basis(Word()).parent() Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field sage: S.expansion_on_basis(Word('abba')) 2*B[aabb] + B[abab] + B[abba] sage: S.expansion_on_basis(Word()) B[] sage: S.expansion_on_basis(Word('abab')) 2*B[aabb] + B[abab]
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> S.expansion_on_basis(Word()) B[] >>> S.expansion_on_basis(Word()).parent() Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field >>> S.expansion_on_basis(Word('abba')) 2*B[aabb] + B[abab] + B[abba] >>> S.expansion_on_basis(Word()) B[] >>> S.expansion_on_basis(Word('abab')) 2*B[aabb] + B[abab]
- gen(i)[source]#
Return the
i
-th generator ofself
.EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: S.gen(0) S[a] sage: S.gen(1) S[b]
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> S.gen(Integer(0)) S[a] >>> S.gen(Integer(1)) S[b]
- gens()[source]#
Return the algebra generators of
self
.EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: S.algebra_generators() (S[a], S[b])
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> S.algebra_generators() (S[a], S[b])
- one_basis()[source]#
Return the indexing element of the basis element \(1\).
EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: S.one_basis() word:
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> S.one_basis() word:
- product(u, v)[source]#
Return the product of two elements
u
andv
.EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: a,b = S.gens() sage: S.product(a, b) S[ba] sage: S.product(b, a) S[ba] sage: S.product(b^2*a, a*b*a) 36*S[bbbaaa]
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> a,b = S.gens() >>> S.product(a, b) S[ba] >>> S.product(b, a) S[ba] >>> S.product(b**Integer(2)*a, a*b*a) 36*S[bbbaaa]
- shuffle_algebra()[source]#
Return the associated shuffle algebra of
self
.EXAMPLES:
sage: S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() sage: S.shuffle_algebra() Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field
>>> from sage.all import * >>> S = ShuffleAlgebra(QQ, 'ab').dual_pbw_basis() >>> S.shuffle_algebra() Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field
- some_elements()[source]#
Return some typical elements.
EXAMPLES:
sage: F = ShuffleAlgebra(QQ,'xyz').dual_pbw_basis() sage: F.some_elements() [0, S[], S[x], S[y], S[z], S[zx]]
>>> from sage.all import * >>> F = ShuffleAlgebra(QQ,'xyz').dual_pbw_basis() >>> F.some_elements() [0, S[], S[x], S[y], S[z], S[zx]]
- class sage.algebras.shuffle_algebra.ShuffleAlgebra(R, names, prefix)[source]#
Bases:
CombinatorialFreeModule
The shuffle algebra on some generators over a base ring.
Shuffle algebras are commutative and associative algebras, with a basis indexed by words. The product of two words \(w_1 \cdot w_2\) is given by the sum over the shuffle product of \(w_1\) and \(w_2\).
See also
For more on shuffle products, see
shuffle_product
andshuffle()
.REFERENCES:
INPUT:
R
– ringnames
– generator names (string or an alphabet)
EXAMPLES:
sage: F = ShuffleAlgebra(QQ, 'xyz'); F Shuffle Algebra on 3 generators ['x', 'y', 'z'] over Rational Field sage: mul(F.gens()) B[xyz] + B[xzy] + B[yxz] + B[yzx] + B[zxy] + B[zyx] sage: mul([ F.gen(i) for i in range(2) ]) + mul([ F.gen(i+1) for i in range(2) ]) B[xy] + B[yx] + B[yz] + B[zy] sage: S = ShuffleAlgebra(ZZ, 'abcabc'); S Shuffle Algebra on 3 generators ['a', 'b', 'c'] over Integer Ring sage: S.base_ring() Integer Ring sage: G = ShuffleAlgebra(S, 'mn'); G Shuffle Algebra on 2 generators ['m', 'n'] over Shuffle Algebra on 3 generators ['a', 'b', 'c'] over Integer Ring sage: G.base_ring() Shuffle Algebra on 3 generators ['a', 'b', 'c'] over Integer Ring
>>> from sage.all import * >>> F = ShuffleAlgebra(QQ, 'xyz'); F Shuffle Algebra on 3 generators ['x', 'y', 'z'] over Rational Field >>> mul(F.gens()) B[xyz] + B[xzy] + B[yxz] + B[yzx] + B[zxy] + B[zyx] >>> mul([ F.gen(i) for i in range(Integer(2)) ]) + mul([ F.gen(i+Integer(1)) for i in range(Integer(2)) ]) B[xy] + B[yx] + B[yz] + B[zy] >>> S = ShuffleAlgebra(ZZ, 'abcabc'); S Shuffle Algebra on 3 generators ['a', 'b', 'c'] over Integer Ring >>> S.base_ring() Integer Ring >>> G = ShuffleAlgebra(S, 'mn'); G Shuffle Algebra on 2 generators ['m', 'n'] over Shuffle Algebra on 3 generators ['a', 'b', 'c'] over Integer Ring >>> G.base_ring() Shuffle Algebra on 3 generators ['a', 'b', 'c'] over Integer Ring
Shuffle algebras commute with their base ring:
sage: K = ShuffleAlgebra(QQ,'ab') sage: a,b = K.gens() sage: K.is_commutative() True sage: L = ShuffleAlgebra(K,'cd') sage: c,d = L.gens() sage: L.is_commutative() True sage: s = a*b^2 * c^3; s (12*B[abb]+12*B[bab]+12*B[bba])*B[ccc] sage: parent(s) Shuffle Algebra on 2 generators ['c', 'd'] over Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field sage: c^3 * a * b^2 (12*B[abb]+12*B[bab]+12*B[bba])*B[ccc]
>>> from sage.all import * >>> K = ShuffleAlgebra(QQ,'ab') >>> a,b = K.gens() >>> K.is_commutative() True >>> L = ShuffleAlgebra(K,'cd') >>> c,d = L.gens() >>> L.is_commutative() True >>> s = a*b**Integer(2) * c**Integer(3); s (12*B[abb]+12*B[bab]+12*B[bba])*B[ccc] >>> parent(s) Shuffle Algebra on 2 generators ['c', 'd'] over Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field >>> c**Integer(3) * a * b**Integer(2) (12*B[abb]+12*B[bab]+12*B[bba])*B[ccc]
Shuffle algebras are commutative:
sage: c^3 * b * a * b == c * a * c * b^2 * c True
>>> from sage.all import * >>> c**Integer(3) * b * a * b == c * a * c * b**Integer(2) * c True
We can also manipulate elements in the basis and coerce elements from our base field:
sage: F = ShuffleAlgebra(QQ, 'abc') sage: B = F.basis() sage: B[Word('bb')] * B[Word('ca')] B[bbca] + B[bcab] + B[bcba] + B[cabb] + B[cbab] + B[cbba] sage: 1 - B[Word('bb')] * B[Word('ca')] / 2 B[] - 1/2*B[bbca] - 1/2*B[bcab] - 1/2*B[bcba] - 1/2*B[cabb] - 1/2*B[cbab] - 1/2*B[cbba]
>>> from sage.all import * >>> F = ShuffleAlgebra(QQ, 'abc') >>> B = F.basis() >>> B[Word('bb')] * B[Word('ca')] B[bbca] + B[bcab] + B[bcba] + B[cabb] + B[cbab] + B[cbba] >>> Integer(1) - B[Word('bb')] * B[Word('ca')] / Integer(2) B[] - 1/2*B[bbca] - 1/2*B[bcab] - 1/2*B[bcba] - 1/2*B[cabb] - 1/2*B[cbab] - 1/2*B[cbba]
- algebra_generators()[source]#
Return the generators of this algebra.
EXAMPLES:
sage: A = ShuffleAlgebra(ZZ,'fgh'); A Shuffle Algebra on 3 generators ['f', 'g', 'h'] over Integer Ring sage: A.algebra_generators() Family (B[f], B[g], B[h]) sage: A = ShuffleAlgebra(QQ, ['x1','x2']) sage: A.algebra_generators() Family (B[x1], B[x2])
>>> from sage.all import * >>> A = ShuffleAlgebra(ZZ,'fgh'); A Shuffle Algebra on 3 generators ['f', 'g', 'h'] over Integer Ring >>> A.algebra_generators() Family (B[f], B[g], B[h]) >>> A = ShuffleAlgebra(QQ, ['x1','x2']) >>> A.algebra_generators() Family (B[x1], B[x2])
- antipode_on_basis(w)[source]#
Return the antipode on the basis element
w
.EXAMPLES:
sage: A = ShuffleAlgebra(QQ,'abc') sage: W = A.basis().keys() sage: A.antipode_on_basis(W("acb")) -B[bca]
>>> from sage.all import * >>> A = ShuffleAlgebra(QQ,'abc') >>> W = A.basis().keys() >>> A.antipode_on_basis(W("acb")) -B[bca]
- coproduct_on_basis(w)[source]#
Return the coproduct of the element of the basis indexed by the word
w
.The coproduct is given by deconcatenation.
INPUT:
w
– a word
EXAMPLES:
sage: F = ShuffleAlgebra(QQ,'ab') sage: F.coproduct_on_basis(Word('a')) B[] # B[a] + B[a] # B[] sage: F.coproduct_on_basis(Word('aba')) B[] # B[aba] + B[a] # B[ba] + B[ab] # B[a] + B[aba] # B[] sage: F.coproduct_on_basis(Word()) B[] # B[]
>>> from sage.all import * >>> F = ShuffleAlgebra(QQ,'ab') >>> F.coproduct_on_basis(Word('a')) B[] # B[a] + B[a] # B[] >>> F.coproduct_on_basis(Word('aba')) B[] # B[aba] + B[a] # B[ba] + B[ab] # B[a] + B[aba] # B[] >>> F.coproduct_on_basis(Word()) B[] # B[]
- counit(S)[source]#
Return the counit of
S
.EXAMPLES:
sage: F = ShuffleAlgebra(QQ,'ab') sage: S = F.an_element(); S B[] + 2*B[a] + 3*B[b] + B[bab] sage: F.counit(S) 1
>>> from sage.all import * >>> F = ShuffleAlgebra(QQ,'ab') >>> S = F.an_element(); S B[] + 2*B[a] + 3*B[b] + B[bab] >>> F.counit(S) 1
- degree_on_basis(w)[source]#
Return the degree of the element
w
.EXAMPLES:
sage: A = ShuffleAlgebra(QQ, 'ab') sage: [A.degree_on_basis(x.leading_support()) for x in A.some_elements() if x != 0] [0, 1, 1, 2]
>>> from sage.all import * >>> A = ShuffleAlgebra(QQ, 'ab') >>> [A.degree_on_basis(x.leading_support()) for x in A.some_elements() if x != Integer(0)] [0, 1, 1, 2]
- dual_pbw_basis()[source]#
Return the dual PBW of
self
.EXAMPLES:
sage: A = ShuffleAlgebra(QQ, 'ab') sage: A.dual_pbw_basis() The dual Poincare-Birkhoff-Witt basis of Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field
>>> from sage.all import * >>> A = ShuffleAlgebra(QQ, 'ab') >>> A.dual_pbw_basis() The dual Poincare-Birkhoff-Witt basis of Shuffle Algebra on 2 generators ['a', 'b'] over Rational Field
- gen(i)[source]#
Return the
i
-th generator of the algebra.INPUT:
i
– an integer
EXAMPLES:
sage: F = ShuffleAlgebra(ZZ,'xyz') sage: F.gen(0) B[x] sage: F.gen(4) Traceback (most recent call last): ... IndexError: argument i (= 4) must be between 0 and 2
>>> from sage.all import * >>> F = ShuffleAlgebra(ZZ,'xyz') >>> F.gen(Integer(0)) B[x] >>> F.gen(Integer(4)) Traceback (most recent call last): ... IndexError: argument i (= 4) must be between 0 and 2
- gens()[source]#
Return the generators of this algebra.
EXAMPLES:
sage: A = ShuffleAlgebra(ZZ,'fgh'); A Shuffle Algebra on 3 generators ['f', 'g', 'h'] over Integer Ring sage: A.algebra_generators() Family (B[f], B[g], B[h]) sage: A = ShuffleAlgebra(QQ, ['x1','x2']) sage: A.algebra_generators() Family (B[x1], B[x2])
>>> from sage.all import * >>> A = ShuffleAlgebra(ZZ,'fgh'); A Shuffle Algebra on 3 generators ['f', 'g', 'h'] over Integer Ring >>> A.algebra_generators() Family (B[f], B[g], B[h]) >>> A = ShuffleAlgebra(QQ, ['x1','x2']) >>> A.algebra_generators() Family (B[x1], B[x2])
- one_basis()[source]#
Return the empty word, which index of \(1\) of this algebra, as per
AlgebrasWithBasis.ParentMethods.one_basis()
.EXAMPLES:
sage: A = ShuffleAlgebra(QQ,'a') sage: A.one_basis() word: sage: A.one() B[]
>>> from sage.all import * >>> A = ShuffleAlgebra(QQ,'a') >>> A.one_basis() word: >>> A.one() B[]
- product_on_basis(w1, w2)[source]#
Return the product of basis elements
w1
andw2
, as perAlgebrasWithBasis.ParentMethods.product_on_basis()
.INPUT:
w1
,w2
– Basis elements
EXAMPLES:
sage: A = ShuffleAlgebra(QQ,'abc') sage: W = A.basis().keys() sage: A.product_on_basis(W("acb"), W("cba")) B[acbacb] + B[acbcab] + 2*B[acbcba] + 2*B[accbab] + 4*B[accbba] + B[cabacb] + B[cabcab] + B[cabcba] + B[cacbab] + 2*B[cacbba] + 2*B[cbaacb] + B[cbacab] + B[cbacba] sage: (a,b,c) = A.algebra_generators() sage: a * (1-b)^2 * c 2*B[abbc] - 2*B[abc] + 2*B[abcb] + B[ac] - 2*B[acb] + 2*B[acbb] + 2*B[babc] - 2*B[bac] + 2*B[bacb] + 2*B[bbac] + 2*B[bbca] - 2*B[bca] + 2*B[bcab] + 2*B[bcba] + B[ca] - 2*B[cab] + 2*B[cabb] - 2*B[cba] + 2*B[cbab] + 2*B[cbba]
>>> from sage.all import * >>> A = ShuffleAlgebra(QQ,'abc') >>> W = A.basis().keys() >>> A.product_on_basis(W("acb"), W("cba")) B[acbacb] + B[acbcab] + 2*B[acbcba] + 2*B[accbab] + 4*B[accbba] + B[cabacb] + B[cabcab] + B[cabcba] + B[cacbab] + 2*B[cacbba] + 2*B[cbaacb] + B[cbacab] + B[cbacba] >>> (a,b,c) = A.algebra_generators() >>> a * (Integer(1)-b)**Integer(2) * c 2*B[abbc] - 2*B[abc] + 2*B[abcb] + B[ac] - 2*B[acb] + 2*B[acbb] + 2*B[babc] - 2*B[bac] + 2*B[bacb] + 2*B[bbac] + 2*B[bbca] - 2*B[bca] + 2*B[bcab] + 2*B[bcba] + B[ca] - 2*B[cab] + 2*B[cabb] - 2*B[cba] + 2*B[cbab] + 2*B[cbba]
- some_elements()[source]#
Return some typical elements.
EXAMPLES:
sage: F = ShuffleAlgebra(ZZ,'xyz') sage: F.some_elements() [0, B[], B[x], B[y], B[z], B[xz] + B[zx]]
>>> from sage.all import * >>> F = ShuffleAlgebra(ZZ,'xyz') >>> F.some_elements() [0, B[], B[x], B[y], B[z], B[xz] + B[zx]]
- to_dual_pbw_element(w)[source]#
Return the element \(w\) of
self
expressed in the dual PBW basis.INPUT:
w
– an element of the shuffle algebra
EXAMPLES:
sage: A = ShuffleAlgebra(QQ, 'ab') sage: f = 2 * A(Word()) + A(Word('ab')); f 2*B[] + B[ab] sage: A.to_dual_pbw_element(f) 2*S[] + S[ab] sage: A.to_dual_pbw_element(A.one()) S[] sage: S = A.dual_pbw_basis() sage: elt = S.expansion_on_basis(Word('abba')); elt 2*B[aabb] + B[abab] + B[abba] sage: A.to_dual_pbw_element(elt) S[abba] sage: A.to_dual_pbw_element(2*A(Word('aabb')) + A(Word('abab'))) S[abab] sage: S.expansion(S('abab')) 2*B[aabb] + B[abab]
>>> from sage.all import * >>> A = ShuffleAlgebra(QQ, 'ab') >>> f = Integer(2) * A(Word()) + A(Word('ab')); f 2*B[] + B[ab] >>> A.to_dual_pbw_element(f) 2*S[] + S[ab] >>> A.to_dual_pbw_element(A.one()) S[] >>> S = A.dual_pbw_basis() >>> elt = S.expansion_on_basis(Word('abba')); elt 2*B[aabb] + B[abab] + B[abba] >>> A.to_dual_pbw_element(elt) S[abba] >>> A.to_dual_pbw_element(Integer(2)*A(Word('aabb')) + A(Word('abab'))) S[abab] >>> S.expansion(S('abab')) 2*B[aabb] + B[abab]