Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orbits of tuples and sets #14291

Closed
nathanncohen mannequin opened this issue Mar 17, 2013 · 63 comments
Closed

Orbits of tuples and sets #14291

nathanncohen mannequin opened this issue Mar 17, 2013 · 63 comments

Comments

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Mar 17, 2013

A small patch to let us compute the orbits of sets and tuples by exposing it from GAP.

Apply :

  1. attachment: trac_14291-v2.patch
  2. attachment: trac_14291_reviewer.patch

CC: @dimpase

Component: group theory

Author: Nathann Cohen, Volker Braun

Reviewer: Volker Braun

Merged: sage-5.10.beta0

Issue created by migration from https://trac.sagemath.org/ticket/14291

@nathanncohen nathanncohen mannequin added this to the sage-5.9 milestone Mar 17, 2013
@nathanncohen nathanncohen mannequin assigned wdjoyner Mar 17, 2013
@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 17, 2013

comment:1

There is a small problem with cached functions right now... -_-

Nathann

@nathanncohen nathanncohen mannequin added the s: needs review label Mar 17, 2013
@dimpase
Copy link
Member

dimpase commented Mar 17, 2013

comment:2

this looks weird:

def orbit(self, point, onsets = False, ontuples = False): 

What about

def orbit(self, point, action = "onpoints"): 

(or "OnPoints" ?) which is the default,
and then sort out the cases action = "onsets", etc. ?

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 17, 2013

comment:3

Totally right...

Just updated it ! And the function only takes tuples as arguments now. I so hate it when design decisions have to be changed for technical issues -_-.

Nathann

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 17, 2013

Attachment: trac_14291.patch.gz

@dimpase
Copy link
Member

dimpase commented Mar 19, 2013

comment:4

There are more useful permutation group actions, see http://www.gap-system.org/Manuals/doc/ref/chap41.html

Namely, OnPairs, OnSetsSets, OnSetsDisjointSets, OnSetsTuples, OnTuplesSets, OnTuplesTuples all should work just fine.

One has to canonize the representative to start with, for some of them, see here. E.g.

Orbit(SymmetricGroup(5),Set([[2,4],[1,3]]),OnSetsSets);

is OK, but

Orbit(SymmetricGroup(5),[[2,4],[1,3]],OnSetsSets);

gives an error.

Less sure about OnIndeterminates.

There is also a support for user-defined actions, but this would mean either specifying a piece of GAP code, or providing a callback, which seems to be too crazy to implement.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 19, 2013

comment:5

Helloooooooo !!

There are more useful permutation group actions, see http://www.gap-system.org/Manuals/doc/ref/chap41.html

Yepyep, I saw them but I really only need OnTuples and OnSets myself, and as I do not really see how I could use the others I do not think that it would be wise to expose them myself. Soooo unless you want to write that additional patch yourslf, ... :-)

Nathann

@dimpase

This comment has been minimized.

@dimpase
Copy link
Member

dimpase commented Mar 19, 2013

comment:7

Replying to @nathanncohen:

Helloooooooo !!

There are more useful permutation group actions, see http://www.gap-system.org/Manuals/doc/ref/chap41.html

Yepyep, I saw them but I really only need OnTuples and OnSets myself, and as I do not really see how I could use the others I do not think that it would be wise to expose them myself. Soooo unless you want to write that additional patch yourslf, ... :-)

OK, needs your review now :-P

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 19, 2013

comment:8

OK, needs your review now :-P

Cool :-P

Well, for a start sage -coverage will not like the documentation of supported_actions at all. Why do you want to create a function just to list them ? Why don't you just include in the methods, or make it a variable in the module ? (anyway you still have to split cases in orbits in order to know what to return).

Would it be possible to add a link toward GAP's documentation where all those actions are defined ?

Nathann

@dimpase
Copy link
Member

dimpase commented Mar 19, 2013

comment:9

Attachment: 14291_reviewer.patch.gz

Replying to @nathanncohen:

OK, needs your review now :-P

Cool :-P

Well, for a start sage -coverage will not like the documentation of supported_actions at all. Why do you want to create a function just to list them ? Why don't you just include in the methods, or make it a variable in the module ? (anyway you still have to split cases in orbits in order to know what to return).

made it a variable...

Would it be possible to add a link toward GAP's documentation where all those actions are defined ?

added...

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 19, 2013

Attachment: trac_14291-rev2.patch.gz

@nathanncohen

This comment has been minimized.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 19, 2013

comment:10

Some small modifications to the documentation. Besides this :

  1. What would you think of making supported_actions a variable of the module itself ? And what of making it a hidden variable ?

  2. What would you think of sorting the input when it represents a set ?.. GAP's error message when it is fed with an unsorted list is not that clear :

Error, OnSets: <set> must be a set (not a list (plain,cyc,nsort,imm))

I will do that if you agree with it.

Nathann

@dimpase
Copy link
Member

dimpase commented Mar 19, 2013

comment:11

Replying to @nathanncohen:

Some small modifications to the documentation. Besides this :

  1. What would you think of making supported_actions a variable of the module itself ? And what of making it a hidden variable ?

The current setup allows it to be extended by the user. One can install via gap.eval() a GAP function, say, "OnBlah", and then use it. You can't do this with a module variable.

  1. What would you think of sorting the input when it represents a set ?.. GAP's error message when it is fed with an unsorted list is not that clear :
Error, OnSets: <set> must be a set (not a list (plain,cyc,nsort,imm))

I will do that if you agree with it.

sure this can be done as you prefer. However, there is a more serious issue with self.action:

sage: G = PermutationGroup([ [('c','d')], [('a','c')] ])
sage: xx=G.orbit(('a','c'),"OnPairs")
sage: G.action(xx,"OnPairs")
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-4-540be1338037> in <module>()
----> 1 G.action(xx,"OnPairs")
...

Indeed, _domain_to_gap[x] needs to be applied onto such orbits. I am thinking that one should have recursive function version of
_domain_to_gap[x] and of _domain_from_gap[x] to deal with things like sets, sets of sets, etc in one go rather
than call them explicitly.

One can also (or instead) attach such a pair of functions to each action in supported_actions to do this rewriting.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 20, 2013

comment:12

The current setup allows it to be extended by the user. One can install via gap.eval() a GAP function, say, "OnBlah", and then use it. You can't do this with a module variable.

Well, if a action is being used that is not already in the source code, then there is no way for Sage to guess how to translate the result before returning it, is there ?

Otherwise we could just get rid of this list, cross our fingers when GAP is fed with something we ha not thought of, as it would raise an Exception in the worst case ?..

sure this can be done as you prefer. However, there is a more serious issue with self.action:

Arg. Right :-/

Indeed, _domain_to_gap[x] needs to be applied onto such orbits. I am thinking that one should have recursive function version of
_domain_to_gap[x] and of _domain_from_gap[x] to deal with things like sets, sets of sets, etc in one go rather
than call them explicitly.

One can also (or instead) attach such a pair of functions to each action in supported_actions to do this rewriting.

Hmmmm... I don't like it very much to be honest... In these situations I think that a bit of code duplication is better than a weird generic way to handle it.

Nathann

@dimpase
Copy link
Member

dimpase commented Mar 20, 2013

comment:13

I just added a new patch (to be applied on top of the rest) that solves these issues. Please have a look if you like it. (It still needs to be cleaned a bit, and more tests ought to be added). It doesn't use the supported_actions list.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 20, 2013

comment:14

HMmmmmmmmmm :-/

I'm sorry to say this because I like that code, but I just fixed doctests in homology/simplicial_complex where an automorphism group is defined over the elements of a simplicial complex... And I am afraid that you will find both 'a', 'b', and ['a','b'] as elements of the domain :-/

Nathann

@dimpase
Copy link
Member

dimpase commented Mar 21, 2013

comment:15

Replying to @nathanncohen:

HMmmmmmmmmm :-/

I'm sorry to say this because I like that code, but I just fixed doctests in homology/simplicial_complex where an automorphism group is defined over the elements of a simplicial complex... And I am afraid that you will find both 'a', 'b', and ['a','b'] as elements of the domain :-/

Well, this is trivial to fix, just swap the actions in try/except blocks in dom_to_gap internal functions.

By the way, why would one keep several actions in case of simplicial complexes, on letters and on pairs, etc? This is akin to keeping actions on vertices and edges in case of automorphisms of (simple) graphs, right? Was that a poor design in the first place?
Besides, this seems to be inefficient to keep permutations in dictionaries.

Nathann

@dimpase
Copy link
Member

dimpase commented Mar 21, 2013

comment:16

Attachment: ducktype_design.patch.gz

OK, updated as I mentioned in my previous comment, with more examples added.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Mar 21, 2013

comment:17

Helloooooooooooooo !!!

Well, this does not solve the problem either Dima. In case of doubt between an element (a,b,c) and the list of elements (a,b,c) it will return the ELEMENT (a,b,c), but it it computes the orbit of a which happens to be (a,b,c) then returning an ELEMENT (a,b,c) instead of the list (a,b,c) is a mistake too :-/

Nathann

@vbraun
Copy link
Member

vbraun commented Apr 11, 2013

Changed author from Nathann Cohen to Nathann Cohen, Volker Braun

@vbraun
Copy link
Member

vbraun commented Apr 11, 2013

Reviewer: Volker Braun

@vbraun

This comment has been minimized.

@vbraun
Copy link
Member

vbraun commented Apr 11, 2013

comment:42

I've cleaned up some stuff and beautified the output containers (as we talked about before):

sage: S3 = groups.permutation.Symmetric(3) 
sage: S3.orbit((1,2), action = "OnSets") 
({1, 2}, {2, 3}, {1, 3}) 
sage: S3.orbit((1,2), action = "OnTuples") 
((1, 2), (2, 3), (2, 1), (3, 1), (1, 3), (3, 2)) 

I'm fine with everything else, so if you agree with the reviewer patch feel free to set it to positive review.

For the patchbot:
Apply trac_14291-v2.patch, trac_14291_reviewer.patch

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 11, 2013

comment:43

Helloooooooooooooooo !!!

There is a "permutatino" somewhere. Could you also replace x = sorted(x) with ``x.sort()` ?

This being said, your patch does not apply on my version of Sage... But I still use beta1, perhaps that's the reason why.

Nathann

@vbraun
Copy link
Member

vbraun commented Apr 11, 2013

Attachment: trac_14291_reviewer.2.patch.gz

Updated patch

@vbraun
Copy link
Member

vbraun commented Apr 11, 2013

comment:44

Ok, fixed. Applies cleanly on sage-5.9.beta5.

@vbraun
Copy link
Member

vbraun commented Apr 11, 2013

comment:46

Ok all doctests pass on sage-5.9.beta5.

Patchbot:
Apply trac_14291-v2.patch, trac_14291_reviewer.patch

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 11, 2013

comment:47

Ok all doctests pass on sage-5.9.beta5.

Doesn't apply on my beta5 :-/

Do you have anything else applied ?

Nathann

@vbraun
Copy link
Member

vbraun commented Apr 11, 2013

comment:48

Ok was based on an older version of your patch (we can't switch to git fast enough ;-)

Works now.

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 11, 2013

comment:49

Well, then... :-)

Nathann

@jdemeyer jdemeyer modified the milestones: sage-5.9, sage-5.10 Apr 12, 2013
@dimpase
Copy link
Member

dimpase commented Apr 12, 2013

comment:51

I'm glad to hear that it's done, and sorry for dropping silent on this - too many deadlines lately.

Dima

@jdemeyer
Copy link

comment:52

The documentation doesn't build properly:

dochtml.log:[groups   ] /mazur/release/merger/sage-5.10.beta0/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup.py:docstring of sage.groups.perm_gps.permgroup.PermutationGroup_generic.orbit:12: ERROR: Unknown target name: "http://www.gap-system.org/manuals/doc/ref/chap41.html".

@vbraun
Copy link
Member

vbraun commented Apr 12, 2013

comment:53

I've replaced the link (which is not stable as the GAP chapter numbers can change) with a reference to our gap.help('Group Actions') command.

@vbraun
Copy link
Member

vbraun commented Apr 12, 2013

Attachment: trac_14291_reviewer.patch.gz

Updated patch

@jdemeyer
Copy link

Merged: sage-5.10.beta0

@nathanncohen
Copy link
Mannequin Author

nathanncohen mannequin commented Apr 15, 2013

comment:55

Cooooooooool :-D

Nathann

@dimpase
Copy link
Member

dimpase commented Apr 27, 2013

comment:56

Shouldn't "OnSets" return sorted things? See e.g. the related issue on #14283.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants