Ask Your Question
1

Commutative Graded Algebra basis shows as Expression

asked 2023-06-14 03:12:20 +0100

Hieu Nguyen gravatar image

updated 2023-06-14 09:37:39 +0100

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?

edit retag flag offensive close merge delete

Comments

Welcome to Ask Sage! Thank you for your question.

slelievre gravatar imageslelievre ( 2023-06-14 09:32:25 +0100 )edit

@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 ( 2023-06-14 18:44:36 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-06-14 09:31:04 +0100

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'>
edit flag offensive delete link more

Comments

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

Hieu Nguyen gravatar imageHieu Nguyen ( 2023-06-15 05:07:54 +0100 )edit

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: 2023-06-14 03:06:11 +0100

Seen: 109 times

Last updated: Jun 14 '23