# what is the equivalent command of gap in sage

gap command,

g1:=Group((2, 3)(4, 5));
g2:=Group((1, 5)(3, 4));
cg:=AllHomomorphisms(g1,g2);


i see that sage seems need to define GF or other things, what is the sage command of above gap command

i am finding an input for this function

K.<x> = FunctionField(cg);

edit retag close merge delete

Sort by » oldest newest most voted

Here is the beginning of an attempt (unfortunately not a solution). You can construct the groups as follows:

sage: g1 = PermutationGroup([[(2, 3), (4, 5)]])
sage: g1
Permutation Group with generators [(2,3)(4,5)]
sage: g2 = PermutationGroup([[(1, 5), (3, 4)]])
sage: g2
Permutation Group with generators [(1,5)(3,4)]


However, i could not find the Sage equivalent of AllHomomorphisms. So we can try to pass from Sage to Gap to Sage again:

sage: G1 = gap(g1)
sage: G2 = gap(g2)
sage: CG = gap.function_call('AllHomomorphisms',[G,H])
sage: CG
[ GroupHomomorphismByImages( Group( [ (2,3)(4,5) ] ), Group(
[ (1,5)(3,4) ] ), [ (2,3)(4,5) ], [ () ] ),
GroupHomomorphismByImages( Group( [ (2,3)(4,5) ] ), Group(
[ (1,5)(3,4) ] ), [ (2,3)(4,5) ], [ (1,5)(3,4) ] ) ]
sage: cg = CG.sage()
NotImplementedError: Unable to parse output: [ GroupHomomorphismByImages( Group( [ (2,3)(4,5) ] ), Group(      [ (1,5)(3,4) ] ), [ (2,3)(4,5) ], [ () ] ),    GroupHomomorphismByImages( Group( [ (2,3)(4,5) ] ), Group(      [ (1,5)(3,4) ] ), [ (2,3)(4,5) ], [ (1,5)(3,4) ] ) ]


So, you have to tell Sage that it is a list:

sage: list(cg)
[GroupHomomorphismByImages( Group( [ (2,3)(4,5) ] ), Group( [ (1,5)(3,4) ] ),
[ (2,3)(4,5) ], [ () ] ),
GroupHomomorphismByImages( Group( [ (2,3)(4,5) ] ), Group( [ (1,5)(3,4) ] ),
[ (2,3)(4,5) ], [ (1,5)(3,4) ] )]


Then we can access some element of the list:

sage: M = list(cg)
sage: M
GroupHomomorphismByImages( Group( [ (2,3)(4,5) ] ), Group( [ (1,5)(3,4) ] ),
[ (2,3)(4,5) ], [ () ] )
sage: type(M)
<class 'sage.interfaces.gap.GapElement'>


But this particular morphism can not be put back into Sage:

sage: M.sage()
NotImplementedError: Unable to parse output: GroupHomomorphismByImages( Group( [ (2,3)(4,5) ] ), Group( [ (1,5)(3,4) ] ),  [ (2,3)(4,5) ], [ () ] )


Note that there exists a PermutationGroupMorphism_im_gens that works similarly to gap's GroupHomomorphismByImages, so the last step could be to parse M.str() and use PermutationGroupMorphism_im_gens as a replacement of GroupHomomorphismByImages (see PermutationGroupMorphism_im_gens? for the documentation).

This is of course unsatisfactory handiwork. The right way is of course to interface GroupHomomorphismByImages in Sage.

more

i run cg = CG.sage() list(cg) M = list(cg), in cloud sage got error, can not run

if uisng gap function can not work, how about how to use sage's own function to do? how to do?

from sage.groups.perm_gps.permgroup_morphism import PermutationGroupMorphism_from_gap phi = PermutationGroupMorphism_im_gens(G1, G2, map(G2, G1.gens())) phi FunctionField(phi);

when run in cloud sage, got error, how to do?

i would like to understand the mechanism, which book do this FunctionField reference from?