Ask Your Question

Trouble importing groups from GAP

asked 2014-10-29 03:22:29 -0500

I would like to use groups from the GAP library in Sage; something like:

sage: L = gap.AllGroups(16)
sage: G = PermutationGroup(gap_group = L[1])

and use G in my sage code. But I must be doing something wrong, becuase I get:

NameError                                 Traceback (most recent call last)
<ipython-input-32-14053049143a> in <module>()
----> 1 G = PermutationGroup(gap_group = L[Integer(1)])

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup.pyc in PermutationGroup(gens, gap_group, domain, canonicalize, category)
    335         raise TypeError("gens must be a tuple, list, or GapElement")
    336     return PermutationGroup_generic(gens=gens, gap_group=gap_group, domain=domain,
--> 337                                     canonicalize=canonicalize, category=category)

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/groups/perm_gps/permgroup.pyc in __init__(self, gens, gap_group, canonicalize, domain, category)
    405         if domain is None:
--> 406             gens = [standardize_generator(x) for x in gens]
    407             domain = set()
    408             for x in gens:

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/groups/perm_gps/ in sage.groups.perm_gps.permgroup_element.standardize_generator (build/cythonized/sage/groups/perm_gps/permgroup_element.c:3761)()

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/groups/perm_gps/ in sage.groups.perm_gps.permgroup_element.string_to_tuples (build/cythonized/sage/groups/perm_gps/permgroup_element.c:3362)()

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/misc/sage_eval.pyc in sage_eval(source, locals, cmds, preparse)
    197         return locals['_sage_eval_returnval_']
    198     else:
--> 199         return eval(source, sage.all.__dict__, locals)

/home/amri/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/all.pyc in <module>()

NameError: name 'f1' is not defined

What is the correct way to do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-10-29 09:22:00 -0500

updated 2014-10-30 02:51:59 -0500


You made a mistake. The database of AllGroups is about all groups up to isomorphisms. Some of them are given by their presentation, others as permutation groups... but there is no canonical way to convert all of them to a permutation group.

Note that there is also a database of transitive permutation groups that can be used as follows

sage: G = gap.TransitiveGroup(12,5)
sage: PermutationGroup(gap_group = G)
Permutation Group with generators [(1,5,9)(2,6,10)(3,7,11)(4,8,12), (1,7)(2,8)(3,9)(4,10)(5,11)(6,12), (1,8,7,2)(3,6,9,12)(4,11,10,5)]

And this is actually directly available in Sage with

sage: G = TransitiveGroup(12,4)
sage: G
Transitive group number 4 of degree 12
sage: G.gens()
[(1,9,5)(2,4,3)(6,8,7)(10,12,11), (1,11,6)(2,9,7)(3,10,5)(4,8,12)]

EDIT: there is also the possibility to look at the list of groups of given size up to isomorphisms but I think that it can be done only through the gap interface (or in gap directly)

sage: groups = gap.AllGroups(12)
sage: for g in groups:
....:     print g
....:     print gap.ConjugacyClasses(g)
Group( [ f1, f2, f3 ] )
[ ConjugacyClass( Group( [ f1, f2, f3 ] ), <identity> of ... ), 
  ConjugacyClass( Group( [ f1, f2, f3 ] ), f1 ), 
  ConjugacyClass( Group( [ f1, f2, f3 ] ), f2 ), 
  ConjugacyClass( Group( [ f1, f2, f3 ] ), f3 ), 
  ConjugacyClass( Group( [ f1, f2, f3 ] ), f1*f2 ), 
  ConjugacyClass( Group( [ f1, f2, f3 ] ), f2*f3 ) ]


edit flag offensive delete link more


Thanks. So there is no easy way to iterate over isomorphism classes of groups of a given order? I don't really care about their actions. I just need access to methods like centralizer and conjugacy_classes.

Amri gravatar imageAmri ( 2014-10-29 13:25:52 -0500 )edit

@Amri answer edited.

vdelecroix gravatar imagevdelecroix ( 2014-10-30 02:52:44 -0500 )edit

@vdelecroix Thanks. Am I correct in concluding that wrapping them to Sage objects in such a way that all the methods work uniformly will require quite a bit of work?

Amri gravatar imageAmri ( 2014-10-31 11:56:08 -0500 )edit

@Amri yes, it is a bit of work. You basically have to write down a Python class which would be a wrapper over the GAP group. There are several examples of this in the source code if you are interested (FreeGroup, FinitelyPresentedGroup, ...)

vdelecroix gravatar imagevdelecroix ( 2014-11-01 16:31:53 -0500 )edit

@Amri in GAP, you can iterate over all groups of a given order (if Small Group Library provides them) - see SmallGroup and NrSmallGroups. Then you may use Image(IsomorphismPermGroup(G)) on the GAP side to get a permutation group before importing it into Sage.

alexander konovalov gravatar imagealexander konovalov ( 2014-12-02 03:38:35 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-10-29 03:22:29 -0500

Seen: 107 times

Last updated: Oct 30 '14