Hey Daniel,

>
> I want to create a new monoid and a group of invertible elements of this 
> monoid. 
>

Yay, we could use more monoids in Sage.

>
> The creation of the monoid (Parent and Element) is described very well 
> in [1] (and got to understand the category framework a bit more). From 
> an object-orientated point of view, I now would inherit a class for the 
> invertible elements from both, the created monoid element and from 
> GroupElement. This class will have methods only invertible elements have. 
> My question now is, how the interplay between all theses elements (and 
> also parents) is. In particular, when I create an invertible element 
> through my monoid parent, does this already give a group element or do I 
> explicitly have to construct the element via the group parent? How is 
> this handled usually? Is there some (well written ;)) code (some 
> monoid/groups) in Sage, where I can see a similar thing going on? 
>

How I did it for free monoids/groups whose generators are indexed by 
arbitrary sets (indexed_free_*.py) and how I would suggest would be to have 
a class for the monoid element, and then have the group element inherit 
from the monoid element (plus whatever else seems appropriate) and 
implement the inverse there. In implementing the multiplication, you should 
be ending with something like

return self.__class__(self.parent(), data)

Now I would also implement _coerce_map_from_(self, P) for the group (the 
parent) which returns True when P is an instance of the monoid (the parent) 
(which I did not implement for the free group...probably should do that). 
Then I would have the group's _element_constructor_ handle elements from 
the monoid and spits out an element of the group. Then the coercion 
framework will take care of the rest.

I don't know of a specific place where this is currently for 
monoids/groups. There's code scattered throughout sage for the 
_coerce_map_from_ (ex. shuffle_algebra.py, symmetric_group_algebra.py in 
the latest beta). I hope that helps, and feel free to cc me on the ticket 
(tscrim) or ask if you have any other questions.

 

> There is also a second question I have (but much more non-specific): My 
> elements can be seen also as functions acting on some set and the monoid 
> operation corresponds to function composition. Is there a way to bring 
> this aspect in? (As this question is very vague, I'm happy with every 
> input you can provide.) 
>
>  You can implement a __call__() method to have the elements act as 
functions (although you'll have the implement the function composition and 
possible coercions manually). Alternatively it might be possible for the 
element to inherit from Map or Morphism, and in that case, the coercion 
would be done automatically and you'll want to implement _call_() (with 
only one underscore). I'd suggest trying the latter first.

Best,
Travis

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to