Embedding as a subgroup Suppose I am given two finite groups $G$ and $H$ (not too large: let's say their orders are around $10000$ and $100$ respectively, and the order of $H$ divides the order of $G$).  These may be represented as groups of permutations with known, fairly small, sets of generators.  I would like to find, if possible, a subgroup of $G$ isomorphic to $H$.  And if this is not possible, I'd like to find a subgroup $K$ of $G$ with a homomorphism of $H$ onto $K$ having as small a kernel as possible.
How could I go about this?
 A: There are several ways you could attempt this, and finding the most efficient method for the types of groups you are interested in might require some experimentation. One way would be to start by finding all (conjugacy classes of) subgroups of $G$ of order dividing $|H|$ and then test them in decreasing order of size for being quotients of $H$.
My inclination would be to try first the simple-minded method of just computing all homomorphisms form $H$ to $G$. I tried that in Magma with a couple fo groups and it worked very quickly. There is a Magma function ${\mathtt {Homomorphisms}}$, which computes the homomorphisms from a finitely presented group to a finite group, up to conjugacy of the image. It finds surjective homomorphisms by default, but there is an option to turn that off. Here is a randomish example with $G$ a simple group of order $20160$ and $H$ a group of order $120$.
I am sure you can do a similar computation in GAP, but I am slightly less familiar with the relevant functions, so I expect someone else could help you with that. Or you could write to the GAP forum mailing list.
> G:=PSL(3,4);                                 
> H:=SmallGroup(120,30);
> H:=FPGroup(H);
> time homs:=Homomorphisms(H,G:Surjective:=false);
   Time: 0.220
> [ Order(Kernel(h)) : h in homs ];
  [ 120, 60, 60, 20, 60, 30, 30, 30, 30, 30, 30, 30, 30, 12, 12, 15, 15,
    15, 15, 15, 15 ]

So in this example, computing the homomorphisms took $0.220$ seconds, and the smallest kernels have order $12$.
Here is another example with the same $G$:
> H:=SmallGroup(120,5); 
> H:=FPGroup(H);
> time homs:=Homomorphisms(H,G:Surjective:=false);
  Time: 0.040
> [ Order(Kernel(h)) : h in homs ];
  [ 120, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ]

The group $H$ there was ${\rm SL}(2,5)$ and it has found homomorphisms to $A_5$.
In fact I see now that $G$ has no subgroups of order $120$, so perhaps this was a bad choice!
Added later: I have experimented some more, and I see now that the approach above is too naive and works very badly for some types of groups $G$. I tried
>   G:=DirectProduct(SmallGroup(100,2),SmallGroup(100,5));
>   H:=SmallGroup(100,4);

and the homomorphism computation did not finish in ten minutes. However, the alternative approach of first finding the subgroups of $G$ of order dividing $|H|$ worked fine. Here is how I did that. 
> S := [s`subgroup : s in Subgroups(G : OrderDividing := Order(H)) ];
> S := Reverse(S);
> H:=FPGroup(H);
> for s in S do                                                          
    homs := Homomorphisms(H,s);  
    if #homs ne 0 then "Found homomorphism, kernel size", #Kernel(homs[1]); 
      break;
  end if; end for;
Found homomorphism, kernel size 25

