First time here? Check out the FAQ!

Ask Your Question
1

Commutative Graded Algebra basis shows as Expression

asked 1 year ago

Hieu Nguyen gravatar image

updated 1 year ago

slelievre gravatar image

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?

Preview: (hide)

Comments

Welcome to Ask Sage! Thank you for your question.

slelievre gravatar imageslelievre ( 1 year ago )

@slelievre's answer is a good one. The name argument should be a list of strings, and I think your use of var is causing the problem.

John Palmieri gravatar imageJohn Palmieri ( 1 year ago )

1 Answer

Sort by » oldest newest most voted
2

answered 1 year ago

slelievre gravatar image

Use the inject_variables method.

It has an optional parameter verbose, which defaults to True.

Set it to False if you want less noise.

Example.

Slightly simplified version of the code in the question:

sage: L = LieAlgebra(QQ, 3, step=3)
sage: L
Free Nilpotent Lie algebra on 14 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)
over Rational Field

sage: A = GradedCommutativeAlgebra(QQ, names=L.basis())
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

Let us inject variables:

sage: A.inject_variables()
Defining 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

Or with less noise:

sage: A.inject_variables(verbose=False)

The generators are now available and have the correct parent and type:

sage: X_1
X_1

sage: parent(X_1)
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

sage: type(X_1)
<class 'sage.algebras.commutative_dga.GCAlgebra_with_category.element_class'>
Preview: (hide)
link

Comments

Thank you so much for such a descriptive explanation! That worked perfectly!

Hieu Nguyen gravatar imageHieu Nguyen ( 1 year ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 1 year ago

Seen: 157 times

Last updated: Jun 14 '23