ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 02 Dec 2014 10:38:35 +0100Trouble importing groups from GAPhttps://ask.sagemath.org/question/24674/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?Wed, 29 Oct 2014 09:22:29 +0100https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/Answer by vdelecroix for <p>I would like to use groups from the GAP library in Sage; something like:</p>
<pre><code>sage: L = gap.AllGroups(16)
sage: G = PermutationGroup(gap_group = L[1])
</code></pre>
<p>and use <code>G</code> in my sage code. But I must be doing something wrong, becuase I get:</p>
<pre><code>---------------------------------------------------------------------------
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
</code></pre>
<p>What is the correct way to do this?</p>
https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?answer=24676#post-id-24676Hello,
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 ) ]
...
VincentWed, 29 Oct 2014 15:22:00 +0100https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?answer=24676#post-id-24676Comment by Amri for <p>Hello,</p>
<p>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.</p>
<p>Note that there is also a database of transitive permutation groups that can be used as follows</p>
<pre><code>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)]
</code></pre>
<p>And this is actually directly available in Sage with</p>
<pre><code>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)]
</code></pre>
<p>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)</p>
<pre><code>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 ) ]
...
</code></pre>
<p>Vincent</p>
https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=24690#post-id-24690Thanks. 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.Wed, 29 Oct 2014 19:25:52 +0100https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=24690#post-id-24690Comment by vdelecroix for <p>Hello,</p>
<p>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.</p>
<p>Note that there is also a database of transitive permutation groups that can be used as follows</p>
<pre><code>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)]
</code></pre>
<p>And this is actually directly available in Sage with</p>
<pre><code>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)]
</code></pre>
<p>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)</p>
<pre><code>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 ) ]
...
</code></pre>
<p>Vincent</p>
https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=24695#post-id-24695@Amri answer edited.Thu, 30 Oct 2014 08:52:44 +0100https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=24695#post-id-24695Comment by Amri for <p>Hello,</p>
<p>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.</p>
<p>Note that there is also a database of transitive permutation groups that can be used as follows</p>
<pre><code>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)]
</code></pre>
<p>And this is actually directly available in Sage with</p>
<pre><code>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)]
</code></pre>
<p>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)</p>
<pre><code>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 ) ]
...
</code></pre>
<p>Vincent</p>
https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=24729#post-id-24729@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?Fri, 31 Oct 2014 17:56:08 +0100https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=24729#post-id-24729Comment by vdelecroix for <p>Hello,</p>
<p>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.</p>
<p>Note that there is also a database of transitive permutation groups that can be used as follows</p>
<pre><code>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)]
</code></pre>
<p>And this is actually directly available in Sage with</p>
<pre><code>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)]
</code></pre>
<p>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)</p>
<pre><code>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 ) ]
...
</code></pre>
<p>Vincent</p>
https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=24740#post-id-24740@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, ...)Sat, 01 Nov 2014 22:31:53 +0100https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=24740#post-id-24740Comment by alexander konovalov for <p>Hello,</p>
<p>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.</p>
<p>Note that there is also a database of transitive permutation groups that can be used as follows</p>
<pre><code>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)]
</code></pre>
<p>And this is actually directly available in Sage with</p>
<pre><code>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)]
</code></pre>
<p>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)</p>
<pre><code>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 ) ]
...
</code></pre>
<p>Vincent</p>
https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=25078#post-id-25078@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.Tue, 02 Dec 2014 10:38:35 +0100https://ask.sagemath.org/question/24674/trouble-importing-groups-from-gap/?comment=25078#post-id-25078