ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 31 Jan 2012 11:29:16 +0100How can I construct graded algebras?https://ask.sagemath.org/question/8622/how-can-i-construct-graded-algebras/I am trying to create a graded algebra using generators and relations. I found that sage has a category for such things:
[http://www.sagemath.org/doc/reference/sage/categories/graded_modules_with_basis.html](http://www.sagemath.org/doc/reference/sage/categories/graded_modules_with_basis.html)
but there are no constructors or examples of how to create these things. Does anyone know where I can find examples of how to construct graded algebras, or more generally how to construct non-commutative algebras?Thu, 12 Jan 2012 19:49:07 +0100https://ask.sagemath.org/question/8622/how-can-i-construct-graded-algebras/Answer by Simon King for <p>I am trying to create a graded algebra using generators and relations. I found that sage has a category for such things:</p>
<p><a href="http://www.sagemath.org/doc/reference/sage/categories/graded_modules_with_basis.html">http://www.sagemath.org/doc/reference/sage/categories/graded_modules_with_basis.html</a></p>
<p>but there are no constructors or examples of how to create these things. Does anyone know where I can find examples of how to construct graded algebras, or more generally how to construct non-commutative algebras?</p>
https://ask.sagemath.org/question/8622/how-can-i-construct-graded-algebras/?answer=13119#post-id-13119Since you ask for graded *algebras*, but refer to the category of graded *modules*: Which of the two do you need?
**General remarks on Sage's category framework**
I recommend that you study [my public worksheet](http://sagenb.org/home/pub/3837) on categories and coercion.
First of all, the purpose of categories in Sage is **not** to construct a specific object in that category. It is more or less the other way around: You implement something and inform Sage that it belongs to some category. For example, let someone implement a Python class `MyModuleClass` whose instances are graded modules. Then, `MyModuleClass.__init__` should make sure that the instance is declared as an object of the category of graded modules over the given base ring.
It is possible that some instances of `MyModuleClass` actually are algebras and not just modules. For example, the set of m by n matrices over a ring R is often just an R-module, but it is an R-algebra if `m==n`. In that situation, it is not needed that you sub-class `MyModuleClass`, but you can simply choose a different category during initialisation.
Why is that useful?
- Sometimes one needs to test whether a given object `X` is an R-module or not. Then, you can simply test it by "`if X in Modules(R): <do something>`".
- The categories in Sage can provide generic code that is available to all objects of that category - it is not needed that you implement these methods by yourself. For example, the category of commutative additive semigroups provides a method called `summation(...)`, and it is available to the rational field, since it belongs to a sub-category:
sage: QQ.summation.__module__
'sage.categories.commutative_additive_semigroups'
- In order to belong to a certain category, an object has to satisfy certain algebraic axioms. For example, elements of a commutative ring can be multiplied, and the result does not depend on the multiplication order. The category framework provides some basic tests (of course, it can't be exhaustive) that your implementation is sane:
sage: TestSuite(QQ).run(verbose=True)
running ._test_additive_associativity() . . . pass
running ._test_an_element() . . . pass
running ._test_associativity() . . . pass
running ._test_category() . . . pass
running ._test_distributivity() . . . pass
running ._test_elements() . . .
Running the test suite of self.an_element()
running ._test_category() . . . pass
running ._test_eq() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_pickling() . . . pass
pass
running ._test_elements_eq() . . . pass
running ._test_eq() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_one() . . . pass
running ._test_pickling() . . . pass
running ._test_prod() . . . pass
running ._test_some_elements() . . . pass
running ._test_zero() . . . pass
So, the category framework *helps* to implement an algebraic structure. However, it is not the location of the *actual implementation*.
**Where to find actual implementations**
If you want to find out what modules or algebras are currently implemented in Sage, then look into [sage.modules](http://www.sagemath.org/doc/reference/modules.html) or [sage.algebras](http://www.sagemath.org/doc/reference/algebras.html) (The links are to the relevant chapters of the documentation).
You will find that there are non-commutative algebras, whereas the modules currently available in Sage are only over *commutative* rings. However, this will change in upcoming versions (hopefully in sage-5.0): `Singular`, which is a computer algebra system used by Sage for polynomial arithmetic and GrÃ¶bner basis computations, also provides one- and two-sided ideals and modules over so-called *g-algebras*. If you want to have a look at the new code, consult Sage's [trac server](http://trac.sagemath.org/sage_trac/ticket/4539).Fri, 13 Jan 2012 05:22:26 +0100https://ask.sagemath.org/question/8622/how-can-i-construct-graded-algebras/?answer=13119#post-id-13119Comment by Starx for <div class="snippet"><p>Since you ask for graded <em>algebras</em>, but refer to the category of graded <em>modules</em>: Which of the two do you need?</p>
<p><strong>General remarks on Sage's category framework</strong></p>
<p>I recommend that you study <a href="http://sagenb.org/home/pub/3837">my public worksheet</a> on categories and coercion.</p>
<p>First of all, the purpose of categories in Sage is <strong>not</strong> to construct a specific object in that category. It is more or less the other way around: You implement something and inform Sage that it belongs to some category. For example, let someone implement a Python class <code>MyModuleClass</code> whose instances are graded modules. Then, <code>MyModuleClass.__init__</code> should make sure that the instance is declared as an object of the category of graded modules over the given base ring.</p>
<p>It is possible that some instances of <code>MyModuleClass</code> actually are algebras and not just modules. For example, the set of m by n matrices over a ring R is often just an R-module, but it is an R-algebra if <code>m==n</code>. In that situation, it is not needed that you sub-class <code>MyModuleClass</code>, but you can simply choose a different category during initialisation.</p>
<p>Why is that useful?</p>
<ul>
<li>Sometimes one needs to test whether a given object <code>X</code> is an R-module or not. Then, you can simply test it by "<code>if X in Modules(R): <do something></code>".</li>
<li><p>The categories in Sage can provide generic code that is available to all objects of that category - it is not needed that you implement these methods by yourself. For example, the category of commutative additive semigroups provides a method called <code>summation(...)</code>, and it is available to the rational field, since it belongs to a sub-category:</p>
<pre><code>sage: QQ.summation.__module__
'sage.categories.commutative_additive_semigroups'
</code></pre></li>
<li><p>In order to belong to a certain category, an object has to satisfy certain algebraic axioms. For example, elements of a commutative ring can be multiplied, and the result does not depend on the multiplication order. The category framework provides some basic tests (of course, it can't be exhaustive) that your implementation is sane:</p>
<pre><code>sage: TestSuite(QQ).run(verbose=True)
running ._test_additive_associativity() . . . pass
running ._test_an_element() . . . pass
running ._test_associativity() . . . pass
running ._test_category() . . . pass
running ._test_distributivity() . . . pass
running ._test_elements() . . .
Running the test suite of self.an_element()
running ._test_category() . . . pass
running ._test_eq() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_pickling() . . . pass
pass
running ._test_elements_eq() . . . pass
running ._test_eq() . . . pass
running ._test_not_implemented_methods() . . . pass
running ._test_one() . . . pass
running ._test_pickling() . . . pass
running ._test_prod() . . . pass
running ._test_some_elements() . . . pass
running ._test_zero() . . . pass
</code></pre></li>
</ul>
<p>So, the category framework <em>helps</em> to implement an algebraic structure. However, it is not the location of the <em>actual implementation</em>.</p>
<p><strong>Where to find actual implementations</strong></p>
<p>If you want to find out what modules or algebras are currently implemented in Sage, then look into <a href="http://www.sagemath.org/doc/reference/modules.html">sage.modules</a> or <a href="http://www.sagemath.org/doc/reference/algebras.html">sage.algebras</a> (The links are to the relevant chapters of the documentation).</p>
<p>You will find that there are non-commutative algebras, whereas the modules currently available in Sage are only over <em>commutative</em> rings. However, this will change in upcoming versions (hopefully in sage-5.0): <code>Singular</code>, which is a computer algebra system used by Sage for polynomial arithmetic ...<span class="expander"> <a>(more)</a></span></p></div>https://ask.sagemath.org/question/8622/how-can-i-construct-graded-algebras/?comment=20378#post-id-20378Thanks, this was very helpful. I've decided to go ahead and implement what I need myself and your worksheet will be very helpful in making my code play nice with the structure of sage.Tue, 31 Jan 2012 11:29:16 +0100https://ask.sagemath.org/question/8622/how-can-i-construct-graded-algebras/?comment=20378#post-id-20378Answer by John Palmieri for <p>I am trying to create a graded algebra using generators and relations. I found that sage has a category for such things:</p>
<p><a href="http://www.sagemath.org/doc/reference/sage/categories/graded_modules_with_basis.html">http://www.sagemath.org/doc/reference/sage/categories/graded_modules_with_basis.html</a></p>
<p>but there are no constructors or examples of how to create these things. Does anyone know where I can find examples of how to construct graded algebras, or more generally how to construct non-commutative algebras?</p>
https://ask.sagemath.org/question/8622/how-can-i-construct-graded-algebras/?answer=13120#post-id-13120Several examples of graded algebras:
- sample code at [http://trac.sagemath.org/sage_trac/ticket/9280](http://trac.sagemath.org/sage_trac/ticket/9280) (not yet merged into Sage). This is an example of how to create a simple graded algebra. Look at [this patch](http://trac.sagemath.org/sage_trac/attachment/ticket/9280/trac_9280-graded-algebras-example.patch), for example.
- the Steenrod algebra: look in `SAGE_ROOT/devel/sage/sage/algebras/steenrod/`.
Fri, 13 Jan 2012 10:31:53 +0100https://ask.sagemath.org/question/8622/how-can-i-construct-graded-algebras/?answer=13120#post-id-13120