# Trouble importing groups from GAP

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)
338
339

/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)
404
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/permgroup_element.so 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/permgroup_element.so 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)
200
201

/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 close merge delete

Sort by » oldest newest most voted

Hello,

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 ) ]
...


Vincent

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.

( 2014-10-29 19:25:52 +0100 )edit

( 2014-10-30 08:52:44 +0100 )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?

( 2014-10-31 17:56:08 +0100 )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, ...)

( 2014-11-01 22:31:53 +0100 )edit
1

@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.

( 2014-12-02 10:38:35 +0100 )edit