Skip to content

Commit

Permalink
Trac #20795: sorting the monomials in pre-Lie algebras
Browse files Browse the repository at this point in the history
Let us sort correctly the rooted trees in free pre-Lie algebras,
using the new sorting_key keyword of Combinatorial free modules.

URL: http://trac.sagemath.org/20795
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Jun 9, 2016
2 parents 0d94d7e + f562296 commit 10f6d91
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/sage/combinat/free_prelie_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from sage.combinat.free_module import (CombinatorialFreeModule,
CombinatorialFreeModuleElement)
from sage.combinat.words.alphabet import Alphabet
from sage.combinat.rooted_tree import RootedTrees, LabelledRootedTrees
from sage.combinat.rooted_tree import (RootedTrees, RootedTree,
LabelledRootedTrees,
LabelledRootedTree)
from sage.misc.lazy_attribute import lazy_attribute
from sage.misc.cachefunc import cached_method
from sage.categories.rings import Rings
Expand Down Expand Up @@ -72,7 +74,7 @@ class FreePreLieAlgebra(CombinatorialFreeModule):
sage: F = algebras.FreePreLie(ZZ, 'xyz')
sage: x,y,z = F.gens()
sage: (x * y) * z
B[x[y[], z[]]] + B[x[y[z[]]]]
B[x[y[z[]]]] + B[x[y[], z[]]]
sage: (x * y) * z - x * (y * z) == (x * z) * y - x * (z * y)
True
Expand Down Expand Up @@ -101,7 +103,7 @@ class FreePreLieAlgebra(CombinatorialFreeModule):
sage: w = F1.gen(0); w
B[[]]
sage: w * w * w * w
B[[[], [], []]] + 3*B[[[], [[]]]] + B[[[[], []]]] + B[[[[[]]]]]
B[[[[[]]]]] + B[[[[], []]]] + 3*B[[[], [[]]]] + B[[[], [], []]]
REFERENCES:
Expand Down Expand Up @@ -147,15 +149,18 @@ def __init__(self, R, names=None):
"""
if names.cardinality() == 1:
Trees = RootedTrees()
key = RootedTree.sort_key
else:
Trees = LabelledRootedTrees()
key = LabelledRootedTree.sort_key
# Here one would need LabelledRootedTrees(names)
# so that one can restrict the labels to some fixed set

self._alphabet = names
cat = MagmaticAlgebras(R).WithBasis().Graded()
CombinatorialFreeModule.__init__(self, R, Trees,
latex_prefix="",
sorting_key=key,
category=cat)

def variable_names(self):
Expand Down Expand Up @@ -274,7 +279,7 @@ def an_element(self):
sage: A = algebras.FreePreLie(QQ, 'xy')
sage: A.an_element()
B[x[x[], x[x[]]]] + B[x[x[x[x[]]]]]
B[x[x[x[x[]]]]] + B[x[x[], x[x[]]]]
"""
o = self.gen(0)
return (o * o) * (o * o)
Expand All @@ -287,18 +292,17 @@ def some_elements(self):
sage: A = algebras.FreePreLie(QQ,'@')
sage: A.some_elements()
[B[[]], B[[[]]], B[[[], [[]]]] + B[[[[[]]]]],
B[[[], []]] + B[[[[]]]], B[[[]]]]
[B[[]], B[[[]]], B[[[[[]]]]] + B[[[], [[]]]], B[[[[]]]] + B[[[], []]], B[[[]]]]
With several generators::
sage: A = algebras.FreePreLie(QQ, 'xy')
sage: A.some_elements()
[B[x[]],
B[x[x[]]],
B[x[x[], x[x[]]]] + B[x[x[x[x[]]]]],
B[x[x[], x[]]] + B[x[x[x[]]]],
B[x[x[], y[]]] + B[x[x[y[]]]]]
B[x[x[x[x[]]]]] + B[x[x[], x[x[]]]],
B[x[x[x[]]]] + B[x[x[], x[]]],
B[x[x[y[]]]] + B[x[x[], y[]]]]
"""
o = self.gen(0)
x = o * o
Expand Down Expand Up @@ -331,7 +335,7 @@ def product_on_basis(self, x, y):
sage: RT = A.basis().keys()
sage: x = RT([RT([])])
sage: A.product_on_basis(x, x)
B[[[], [[]]]] + B[[[[[]]]]]
B[[[[[]]]]] + B[[[], [[]]]]
"""
return self.sum(self.basis()[u] for u in x.graft_list(y))

Expand All @@ -352,7 +356,7 @@ def pre_Lie_product(self):
sage: RT = A.basis().keys()
sage: x = A(RT([RT([])]))
sage: A.pre_Lie_product(x, x)
B[[[], [[]]]] + B[[[[[]]]]]
B[[[[[]]]]] + B[[[], [[]]]]
"""
plb = self.pre_Lie_product_on_basis
return self._module_morphism(self._module_morphism(plb, position=0,
Expand Down

0 comments on commit 10f6d91

Please sign in to comment.