[sage-devel] categories, etc.: how to define a new algebra

52 views
Skip to first unread message

John Palmieri

unread,
May 19, 2010, 5:25:22 PM5/19/10
to sage-...@googlegroups.com, sage-comb...@googlegroups.com
Suppose I want to define a new algebra in Sage. What should I do?

- I have followed the nice coercion docs in the reference manual, and
in particular, I've set up _add_, _mul_, etc.; and also
_coerce_map_from_ and _element_constructor_.

- Should I do anything with the new categories framework? I've
defined a "category" method for the algebra, but should I do anything
else?

- I'm working on a differential graded algebra, in fact. It is a
"graded algebra with basis" (and it's actually Z x Z graded, so a
"bigraded algebra with basis"); do I need to do anything special about
this? I've defined a "basis" method already which returns the basis
in each bidegree as a Python list.

- I suppose we should have a general class of differential graded
algebras, but I don't have the time to work on it right now...

If anyone wants to take a look:

<http://sage.math.washington.edu/home/palmieri/misc/lambda_algebra.patch>

--
John

--
To post to this group, send an email to sage-...@googlegroups.com
To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Nicolas M. Thiery

unread,
May 19, 2010, 6:02:15 PM5/19/10
to sage-comb...@googlegroups.com, sage-...@googlegroups.com
On Wed, May 19, 2010 at 02:25:22PM -0700, John Palmieri wrote:
> Suppose I want to define a new algebra in Sage. What should I do?
>
> - I have followed the nice coercion docs in the reference manual, and
> in particular, I've set up _add_, _mul_, etc.; and also
> _coerce_map_from_ and _element_constructor_.
>
> - Should I do anything with the new categories framework? I've
> defined a "category" method for the algebra, but should I do anything
> else?
>
> - I'm working on a differential graded algebra, in fact. It is a
> "graded algebra with basis" (and it's actually Z x Z graded, so a
> "bigraded algebra with basis"); do I need to do anything special about
> this? I've defined a "basis" method already which returns the basis
> in each bidegree as a Python list.
>
> - I suppose we should have a general class of differential graded
> algebras, but I don't have the time to work on it right now...
>
> If anyone wants to take a look:
>
> <http://sage.math.washington.edu/home/palmieri/misc/lambda_algebra.patch>

As a short first answer, please try:

sage: A = AlgebrasWithBasis(QQ).example()
sage: A
An example of an algebra with basis: the free algebra on the generators ('a', 'b', 'c') over Rational Field
sage: A??

And then get back to us with more questions!

Cheers,
Nicolas
--
Nicolas M. Thiéry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/

John H Palmieri

unread,
May 19, 2010, 6:40:44 PM5/19/10
to sage-combinat-devel, sage-...@googlegroups.com
On May 19, 3:02 pm, "Nicolas M. Thiery" <Nicolas.Thi...@u-psud.fr>
wrote:
> On Wed, May 19, 2010 at 02:25:22PM -0700, John Palmieri wrote:
> >  - Should I do anything with the new categories framework?  I've
> > defined a "category" method for the algebra, but should I do anything
> > else?
>
> >  - I'm working on a differential graded algebra, in fact.  It is a
> > "graded algebra with basis" (and it's actually Z x Z graded, so a
> > "bigraded algebra with basis"); do I need to do anything special about
> > this?  I've defined a "basis" method already which returns the basis
> > in each bidegree as a Python list.

> As a short first answer, please try:
>
>     sage: A = AlgebrasWithBasis(QQ).example()

Yes, I saw that. It looks like I should try to define my algebra
(call it L) as a CombinatorialFreeModule and implement at least
one_basis, product_on_basis, and algebra_generators. Unfortunately,
there is no corresponding example for GradedAlgebrasWithBasis, and the
framework for graded objects doesn't seem very complete. So should I
specify the basis for the CombinatorialFreeModule using some family,
and then attach some sort of grading to the basis elements to induce a
grading on L? That seems awkward -- it is important, at least for
this example, to be able to easily extract the basis in any given
(bi)degree, so it seems better to define a function specifying the
basis in each degree. What do you think?

If that's right, then I don't see how to conveniently construct L as a
CombinatorialFreeModule; rather, it is an infinite direct sum of
(finite-dimensional) such objects, and I need to be able to consider
each piece as well as the whole.

--
John

Simon King

unread,
May 19, 2010, 6:50:50 PM5/19/10
to sage-devel
Hi John!

On 19 Mai, 23:25, John Palmieri <jhpalmier...@gmail.com> wrote:
> Suppose I want to define a new algebra in Sage. What should I do?
>
>  - I have followed the nice coercion docs in the reference manual, and
> in particular, I've set up _add_, _mul_, etc.; and also
> _coerce_map_from_ and _element_constructor_.
>
>  - Should I do anything with the new categories framework?  I've
> defined a "category" method for the algebra, but should I do anything
> else?

In order to use the full machinery, you should define a "construction
functor" (assuming that your construction is functorial). Look at
sage.categories.pushout, and while you are at it, you could review the
docs and bug fixes that I provided for it at #8800 and #8807...

I'd describe it like this:

- define a subclass of sage.categories.pushout.ConstructionFunctor. In
the init method, you must indicate the categories on which the functor
acts, by Functor.__init__(self,Rings(),Rings()) for example.

- If #8807 gets accepted, you have to define a _apply_functor method
(it tells what your construction does with objects) and perhaps a
_apply_functor_to_morphism method (it yields induced homomorphisms).
Without #8807, you need to define a call method for the objects, and
can forget about the morphisms (so, you wouldn't get a mathematical
functor)...

- Your new algebra class needs to have a construction() method: It
returns a pair (F,R), where F is an instance of your construction
functor, and R is an object, so that F(R) yields your algebra.
Example: QQ.construction() yields (FractionField, ZZ).

- Each construction functor has a rank: When trying to find the
pushout of two parent structure constructions, the construction with
the lower rank is applied first. Example: The FractionField functor
has lower rank than the PolynomialFunctor. By consequence, the pushout
of ZZ['x'] and QQ is QQ['x'] and not FractionField(ZZ['x']). So,
choose the rank carefully (it may coincide with the rank of an
existing functor)!

- You may define a "merge()" method. It may combine two concurrently
applied functors into one, inside the pushout construction (it will
only be used if two functors have the same rank). Typically, this
would be used if your construction has different implementations
(e.g., dense versus sparse); the merge() method would tell what
implementation should be used in the pushout. This is why one can add
a dense and a sparse matrix.

- You may define a "commutes()" method. Namely, if in the pushout
construction two functors of the same rank concur and don't merge,
then Sage would complain since it can't find a unique pushout. But if
you assert that the two functors commute then uniqueness is granted. I
don't know of a good example: FractionField and Completion do commute
mathematically, but they have different rank, so it doesn't matter
for the pushout.

And that's it, unless you want to do something very special (like
overloading the mul method or using an expand method)! This is
sufficient to do arithmetic relating your new algebra class and
another (existing or future) parent structure.

Cheers,
Simon

John H Palmieri

unread,
May 21, 2010, 3:33:32 PM5/21/10
to sage-combinat-devel, sage-...@googlegroups.com, sage-a...@googlegroups.com
On May 19, 3:55 pm, "Nicolas M. Thiery" <Nicolas.Thi...@u-psud.fr>
wrote:
>         Hi John!
> Yes, real support for graded enumerated sets / algebras is still to
> come. Now I really need to jump to bed; in the mean time, you may want
> to have a look at DisjointUnionEnumeratedSets!

I'm sorry, but I can't see how to use this. I'm stuck with the whole
thing, in fact. (I'm not stuck with a Sage implementation, but I am
stuck with an implementation using the new categories framework.)

Let me provide some details: my algebra L is a bigraded algebra over
GF(p) (there is one algebra L for each prime p). I don't know a
simple way to list the basis elements; instead, if I want a basis in a
particular bidegree (s,t), I build it recursively using the algebra
generators and the bases in bidegrees (s', t') for various s' < s and
t' < t. Thus, for example, I don't know offhand the dimension in each
bidegree. As a result, I don't see how to implement this with
families or DisjointUnionEnumeratedSets.

(In case it helps: at the prime 2, the basis in bidegree (s,t) is in
bijection with length s partitions (i_1, i_2, ..., i_s) of t-s that
don't increase too fast: for each j, 2i_j >= i_{j+1}. It's similar
but a bit more complicated at odd primes.)

Anyway, if you have more suggestions, I would appreciate it.

John H Palmieri

unread,
May 21, 2010, 3:42:44 PM5/21/10
to sage-devel
Hi Simon,

Thanks for your comments, but I don't think they work for me. See
below.

On May 19, 3:50 pm, Simon King <simon.k...@nuigalway.ie> wrote:
> Hi John!
>
> On 19 Mai, 23:25, John Palmieri <jhpalmier...@gmail.com> wrote:
>
> > Suppose I want to define a new algebra in Sage. What should I do?
>
> >  - I have followed the nice coercion docs in the reference manual, and
> > in particular, I've set up _add_, _mul_, etc.; and also
> > _coerce_map_from_ and _element_constructor_.
>
> >  - Should I do anything with the new categories framework?  I've
> > defined a "category" method for the algebra, but should I do anything
> > else?
>
> In order to use the full machinery, you should define a "construction
> functor" (assuming that your construction is functorial).

Well, it's not functorial in a simple (that is, easily implemented)
way. I'm working on the Lambda algebra, if that means anything to
you. If not, think of it like the Steenrod algebra. For each prime
p, there is a F_p algebra, and the ones from different primes don't
map to each other. (It's not a construction you apply to rings or
groups, just to finite prime fields.) So there's not much
functoriality here.

There is an action of this algebra on the mod p homology of any space,
but that involves Steenrod operations on (co)homology, which haven't
been implemented yet. It's on my list, but anyway, it doesn't give a
functorial construction of these algebras.

--
John
Reply all
Reply to author
Forward
0 new messages