Ask Your Question

# Revision history [back]

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.