x:=Indeterminate(GF(2));
x.name:="x";;
f:=x^23-1;
Factors(f);
f:=First(Factors(f),i->Degree(i)>1);
RequirePackage("guava");
cod:=GeneratorPolCode(f,23,GF(2));
IsPerfectCode(cod);
ext:=ExtendedCode(cod);
WeightDistribution(ext);
m24:=AutomorphismGroup(ext); m24.name:="m24";
Size(m24);
Transitivity(m24,[1..24]);
m22a:=Stabilizer(m24,[23,24],OnSets);
Size(m22a);
m22a:=Operation(m22a,[1..22]);m22a.name:="m22a";;
Size(m22a);
s:=SylowSubgroup(m22a,2);;
a:=AgGroup(s);
n:=Filtered(NormalSubgroups(a),i->Size(i)=16
        and IsElementaryAbelian(i));
n:=List(n,i->Image(a.bijection,i));;
e:=Filtered(n,i->IsRegular(i,PermGroupOps.MovedPoints(i)));;
Length(e);
e:=e[1];;
h:=Normalizer(m22a,e);;
mop:=Operation(m22a,RightCosets(m22a,h),OnRight);;
DegreeOperation(mop,[1..100]);
ophom:=OperationHomomorphism(m22a,mop);;
dp:=DirectProduct(m22a,mop);;
emb1:=Embedding(m22a,dp,1);;
emb2:=Embedding(mop,dp,2);;
diag:=List(m22a.generators,
           i->Image(emb1,i)*Image(emb2,Image(ophom,i)));;
diag:=Group(diag,());;
diag.name:="M22.2-99";
RequirePackage("grape");
gamma:=NullGraph(diag,100);
AddEdgeOrbit(gamma,[1,100]);AddEdgeOrbit(gamma,[100,1]);
hexad:=First(Orbits(h,[1..22]),i->Length(i)=6);
for i in hexad do AddEdgeOrbit(gamma,[i,23]);
AddEdgeOrbit(gamma,[23,i]); od;
Adjacency(gamma,23);
stab:=Stabilizer(diag,23);;
orbs:=Orbits(stab,[24..99]);;
orbreps:=List(orbs,i->i[1]);
Intersection(hexad,Adjacency(gamma,24));
Intersection(hexad,Adjacency(gamma,39));
AddEdgeOrbit(gamma,[23,39]); AddEdgeOrbit(gamma,[39,23]);
IsSimpleGraph(gamma);
Adjacency(gamma,23);
IsDistanceRegular(gamma);
aug:=AutGroupGraph(gamma);;
Size(aug);
DisplayCompositionSeries(aug);
hs:=DerivedSubgroup(aug);;
ct:=CharTable("U3(5)");;ct2:=CharTable("U3(5).2");;
cths:=CharTable("hs");;
ct.orders;ct2.orders;cths.orders;
repeat e1:=Random(hs);until OrderPerm(e1)=12;
e2:=e1^6;;
ct2.classes[2];
cths.orders[21];
cths.powermap[3][cths.powermap[2][21]];
cths.classes[2];
cnt:=0;;repeat u:=Subgroup(aug,[e1,e2^Random(hs)]);cnt:=cnt+1;
until Index(hs,u)=176;cnt;
hsop:=Operation(hs,CanonicalRightTransversal(hs,u),
OnCanonicalCosetElements(hs,u));;
IsPrimitive(hsop,[1..176]);
ophom:=OperationHomomorphism(hs,hsop);;
dp:=DirectProduct(hs,hsop);;
emb1:=Embedding(hs,dp,1);;
emb2:=Embedding(hsop,dp,2);;
diag:=List(hs.generators,i->Image(emb1,i)*Image(emb2,Image(ophom,i)));;
diag:=Group(diag,());;diag.name:="hs-276";;
adj:=Adjacency(gamma,1);
t:=Stabilizer(diag,[1,adj[1]],OnSets);;
cnt:=0;;repeat s:=Subgroup(diag,[Random(t),Random(t)]);cnt:=cnt+1;
until Size(s)=Size(t);cnt;t:=s;;
aus:=t.operations.AutomorphismGroup(t);;
Size(aus);
inner:=Subgroup(aus,aus.innerAutomorphisms);;
Index(aus,inner);
rt:=RightTransversal(aus,inner);;
automs:=Filtered(rt,i->i^2 in inner and not i in inner);;
Length(automs);
List(automs,i->Order(aus,i));
ot:=Orbits(t,[1..276]);;
List(ot,Length);
PermutationByAutomorphism := function(grp,aut,dom)
local op,oh,p,s,sim,simp,rt,rtim,extelm,l1,l2;
  # We compute the action on the given domain and transfer the
  # automorphism to this permutation action
  op:=Operation(grp,dom);
  oh:=OperationHomomorphism(grp,op);
  aut:=GroupHomomorphismByImages(op,op,op.generators,List(op.generators,
         i->Image(oh,Image(aut,PreImagesRepresentative(oh,i)))));
  aut.isMapping:=true; # just to save time (otherwise GAP will test that
                 # it is indeed a homomorphism, but we know this already)

  # compute stabilizer and images
  s:=Stabilizer(op,1);
  sim:=Image(aut,s);

  # is the image a stabilizer? It is if it has an orbit of length 1
  simp:=Filtered(Orbits(sim,[1..Length(dom)]),i->Length(i)=1);
  if Length(simp)=0 then
    return false; # it cannot be induced by a permutation action
  fi;

  # the permutation can be obtained by the induced action on the right
  # cosets.
  simp:=simp[1][1]; #image base point
  rt:=RightTransversal(op,s);
  rtim:=List(rt,i->Image(aut,i));
  l1:=List(rt,i->1^i);l2:=List(rtim,i->simp^i);

  # we got the images, make a permutation from them.
  if Length(Orbits(grp,dom))=1 then
    extelm:=MappingPermListList(l1,l2);
  else
    # if we have two orbits, we have to ensure they get swapped
    extelm:=MappingPermListList(Concatenation(l1,l2),Concatenation(l2,l1));
  fi;

  # test whether the computed element indeed fulfills the specifictions
  # (This is a safety test only)
  if ForAny(op.generators,i->i^extelm<>i^aut) then
    Error("something went wrong");
  fi;

  # finally move the points acted on to the original domain.
  return extelm^MappingPermListList([1..Length(dom)],dom);
end;

lo:=First(ot,i->Length(i)=120);;
automs:=Filtered(automs,i->PermutationByAutomorphism(t,i,lo)<>false);;
Length(automs);
autom:=automs[1];;
pos:=Filtered([1..Length(ot)],i->Length(ot[i])=56);
perms:=List(ot{Difference([1..5],pos)},
             i->PermutationByAutomorphism(t,autom,i));;
element:=Product(perms)*PermutationByAutomorphism(t,
                           autom,Concatenation(ot{pos}));;
ot[1];
1^element;
element:=element*(1,79);;
co3:=Group(Concatenation(diag.generators,[element]),());;
Size(co3);
DisplayCompositionSeries(co3);
quit;
