I'm trying to access the left and right elements in a free lie algebra element, whose monomials are stored as binary trees. Thus I want a method (like exists in the source for lie_algebra_element) which would return something like
sage: L = LieAlgebra(QQ, 3, 'x')
sage: x0,x1,x2 = L.gens()
sage: Lyn = FL.Lyndon()
sage: a = Lyn.graded_basis(3)[2]; a
[[x0, x1], x1]
sage: a._left
[x0,x1]
sage: a._right
x1
Of course the last 4 lines are fake. One way of seeing this is the following:
sage: isinstance(a, LyndonBracket)
False
sage: isinstance(a, LieBracket)
False
How do I fix this "the right way" ? My current solution is just to set
sage: a_tree = eval(repr(a)); a_tree
[[x0, x1], x1]
But this feels extremely wrong.
sage: a_tree = a.list()[0][0]; a_tree
[[x0, x1], x1]
sage: isinstance(a_tree, sage.algebras.lie_algebras.lie_algebra_element.LyndonBracket)
True
sage: a_tree._left
[x0, x1]
sage: a_tree._right
x1sage: x1 == a_tree._right
False
sage: type(a)
<class 'sage.algebras.lie_algebras.free_lie_algebra.FreeLieAlgebra.Lyndon_with_category.element_class'>sage: b = a.support()[0]
sage: type(b)
<class 'sage.algebras.lie_algebras.lie_algebra_element.LyndonBracket'>
sage: b[0]
[x0, x1]
sage: b[1]
x1
sage: b._left
[x0, x1]
sage: b._right
x1sage: Lyn(b) # This currently does not work