Commutative Graded Algebra basis shows as Expression
I am trying to create a CDGA using an existing Lie Algebra basis as follows:
sage: L = LieAlgebra(QQ, 3, step=3)
sage: gen_list = L.basis().list()
sage: gen_list
[X_1, X_2, X_3, X_12, X_13, X_23, X_112, X_113,
X_122, X_123, X_132, X_133, X_223, X_233]
To use these generators as the ones for my CGA, after poking around a bit I tried:
sage: gen_list = str(gen_list)[1:-1] # turn list to string
sage: A = GradedCommutativeAlgebra(QQ, names=var(gen_list))
sage: A
Graded Commutative Algebra with generators
('X_1', 'X_2', 'X_3', 'X_12', 'X_13', 'X_23', 'X_112', 'X_113',
'X_122', 'X_123', 'X_132', 'X_133', 'X_223', 'X_233')
in degrees (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) over Rational Field
But when I try to access a specific generator, e.g. X_1
,
its type is actually just an expression:
sage: type(X_1)
<class 'sage.symbolic.expression.Expression'>
A correct generator should have the following type:
sage: type(A.gen(0))
<class 'sage.algebras.commutative_dga.GCAlgebra_with_category.element_class'>
I have to generalize this method so I cannot define the CGA
as in the library guide using something like A.<x, y, z> = ...
.
How do I define the generators correctly to get the type that I want?
Welcome to Ask Sage! Thank you for your question.
@slelievre's answer is a good one. The
name
argument should be a list of strings, and I think your use ofvar
is causing the problem.