# Revision history [back]

### Coercion from PBW to universal enveloping algebra

I'm using sage.algebras.lie_algebras.poincare_birkhoff_witt to do computations in the universal enveloping algebras of some Lie algebras. I want to then use the resulting elements in the PBW basis to act on (a subalgebra) of the Lie algebra. For this I need to use the Lie algebra's bracket() method, which only works with elements of the Lie algebra. Hence I need to coerce elements of PBW back into (NC polynomials of) elements of the Lie algebra. How do I do this?

Example

sage: lie_algebra = LieAlgebra(QQ, cartan_type='A4')
sage: pbw_basis = lie_algebra.pbw_basis()
sage: pbw_basis.an_element()
>>> PBW[alpha[4]]^2*PBW[alpha[3]]^2*PBW[alpha[2]]^3 + 2*PBW[alpha[4]] + 3*PBW[alpha[3]] + 1


Then I want to obtain

>>> E[alpha[4]]^2*E[alpha[3]]^2*E[alpha[2]]^3 + 2*E[alpha[4]] + 3*E[alpha[3]] + 1


Or rather it's enough if I can convert a term like PBW[alpha[4]] to E[alpha[4]], because I want to essentially use the following function

def universal_enveloping_algebra_action(pbw_elt,e):
result=0
for term,coefficient in pbw_elt:
sub_result=e
for factor,power in term:
for _ in range(power):
sub_result=lie_algebra.bracket(factor,sub_result)
result+=sub_result
return result


Here pbw_elt is an element of the PBW basis, and e is in the Lie algebra. In this case 'factor' needs to be coerced into an element of the Lie algebra.

Right now I solved the problem by making a dictionary converting algebra generators of pbw_basis into basis elements of the Lie algebra, but it feels like there should be a much more elegant solution.