[sage-combinat-devel] Re: an example of a graded algebra with basis

2010-06-22 Thread Andrew Mathas
Hi John,

I am currently writing some code to compute in some graded module --
there is a graded algebra lurking in the background for which I have
generators and relations but it is highly non-trivial to describe how
the algebra acts on its homogeneous basis and to rewrite the
generators in terms of this basis so I am not really interested in
coding up the algebra just yet. Still, I'd be  happy to work with you
on this.

I had a look through your code and it looks good. Some comments:
  o you seem to have a positive grading built in, but a Z-grading is
more natural in many ways.
 Some people will be interested in grading by arbitrary groups or
even monoids so some
 flexibility should be allowed here. To capture the greatest
generality the degree function
 probably should be allowed to be a morphism, or even just a
method on the indexing set
for the basis/generating set? (The latter is what I am doing.)

  o Is it necessary to code up _latex_ for the elements? I thought
that this should be inherited from
 AlgebrasWithBasis?

  o the only generic function that I have added apart from degree() is
a homogeneous_components()
function. What I have currently is the following method:


def homogeneous_components(self):
  r Returns a dictionary of the homogeneous components.

  EXAMPLES::
sage: G=GradedSpechtModule(3,[3,2])
Graded Specht module S(3,2) with e=3.
sage: a=G.an_element()
sage: a.homogeneous_components()
{0: 2*[125/34] + 3*[134/25], 1: [135/24]}

  
  hom={}
  for (tab,coeff) in self:
d=tab.degree(self.parent().e)
if d in hom: hom[d]+=self.parent().term(tab,coeff)
else: hom[d]=self.parent().term(tab,coeff)
  return hom

I just threw this in playing around  am not sure that it will
be useful in practice.

In my current implementation -- which is still very much a template --
I am hacking CombinatorialFreeModule. My degree function is actually a
method on tableaux, so it is not defined explicitly. Having seen your
code it's clear that I really ought to implement a
GradedCombinatorialFreeModule/GradedModuleWithBasis class..

One idea is that we could try and develop the GradedAlgebraWithBasis
and GradedModuleWithBasis in parallel. That way we can fine tune what
we're both doing and hopefully arrive at a good design... I'm likely
to be overloaded for the next few weeks, but can probably do something
after this.

Andrew

On Jun 20, 5:45 am, John H Palmieri jhpalmier...@gmail.com wrote:
 I have a simple example of a graded algebra with basis.  Please take a
 look at

 http://trac.sagemath.org/sage_trac/ticket/9280

 and provide feedback.  Since the details for graded algebras are not
 very well fleshed out anywhere, I had to make some things up, and
 others might not agree with my decisions.  Since I'm proposing adding
 this as an example in  sage.categories.examples, it ought to be done
 right, whatever that means.

 --
 John

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-de...@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.



[sage-combinat-devel] Re: an example of a graded algebra with basis

2010-06-22 Thread John H Palmieri
On Jun 22, 3:36 am, Andrew Mathas a.mat...@usyd.edu.au wrote:
 Hi John,

 I am currently writing some code to compute in some graded module --
 there is a graded algebra lurking in the background for which I have
 generators and relations but it is highly non-trivial to describe how
 the algebra acts on its homogeneous basis and to rewrite the
 generators in terms of this basis so I am not really interested in
 coding up the algebra just yet. Still, I'd be  happy to work with you
 on this.

Great!

 I had a look through your code and it looks good. Some comments:
   o you seem to have a positive grading built in, but a Z-grading is
 more natural in many ways.

In general I agree with you, but for a polynomial algebra, if you have
one generator in a positive degree and another in a negative degree,
then some of the graded pieces will be infinite-dimensional, and that
seems awkward, if nothing else.

      Some people will be interested in grading by arbitrary groups or
 even monoids so some flexibility should be allowed here.

Right.  In principle, where I have a line like

  Family(NN, self._basis_fcn)

you could put

  Family(M, self._basis_fcn)

where M is any (commutative?) monoid.  In practice, it may not work so
well yet -- I tried using cartesian_product((NN, NN)) and it didn't
work -- but I think things are progressing.

 To capture the greatest
 generality the degree function
      probably should be allowed to be a morphism, or even just a
 method on the indexing set
     for the basis/generating set? (The latter is what I am doing.)

Sounds good to me.  (Remember, in my patch I'm trying to implement an
example, not the general case.  But we could add comments about this
sort of thing to my example.)

   o Is it necessary to code up _latex_ for the elements? I thought
 that this should be inherited from
      AlgebrasWithBasis?

My basis is given by tuples of integers, and their latex method
doesn't produce anything resembling monomials: the default method
would give something like B[(2,0,3)].  I could have made a separate
class of monomials first, then used them as basis elements, but I
chose to use tuples as the raw data.

   o the only generic function that I have added apart from degree() is
 a homogeneous_components()
     function. What I have currently is the following method:

     def homogeneous_components(self):
       r Returns a dictionary of the homogeneous components.

       EXAMPLES::
         sage: G=GradedSpechtModule(3,[3,2])
         Graded Specht module S(3,2) with e=3.
         sage: a=G.an_element()
         sage: a.homogeneous_components()
         {0: 2*[125/34] + 3*[134/25], 1: [135/24]}

       
       hom={}
       for (tab,coeff) in self:
         d=tab.degree(self.parent().e)
         if d in hom: hom[d]+=self.parent().term(tab,coeff)
         else: hom[d]=self.parent().term(tab,coeff)
       return hom

     I just threw this in playing around  am not sure that it will
 be useful in practice.

Seems like it might be useful.

 In my current implementation -- which is still very much a template --
 I am hacking CombinatorialFreeModule. My degree function is actually a
 method on tableaux, so it is not defined explicitly. Having seen your
 code it's clear that I really ought to implement a
 GradedCombinatorialFreeModule/GradedModuleWithBasis class.

I think something like that is probably needed, but I didn't have the
time to think about all of the details behind implementing it.  It was
easier for me to write a simple example using what's already present
in Sage.  (Actually, first I've been working on rewriting the Steenrod
algebra code in Sage using the new category framework, and I wanted to
make it into a graded algebra.  From what I've learned doing that, I
produced the example, in the hope that it's helpful to other people.)

One issue I've had: if I define the nth graded piece (using
__getitem__, for example) as a CombinatorialFreeModule on a subset of
the basis, then I couldn't figure out how to easily multiply elements
of that: it's just a free module, with no _mul_ or product method
defined.  It's easy to set up coercion so that multiplying an element
of a graded piece with an element of the whole algebra is defined, but
not so easy when multiplying an element of one piece with an element
of another. Part of the structure of GradedCombinatorialFreeModule
should allow this, so that you can work with the pieces, then
reassemble them using sums, products, etc.

 One idea is that we could try and develop the GradedAlgebraWithBasis
 and GradedModuleWithBasis in parallel. That way we can fine tune what
 we're both doing and hopefully arrive at a good design... I'm likely
 to be overloaded for the next few weeks, but can probably do something
 after this.

Sounds okay.  I hope some other people chime in with ideas as well.

  John

 Andrew

 On Jun 20, 5:45 am, John H Palmieri jhpalmier...@gmail.com wrote:



  I have a simple example of a graded algebra with