// p5g3q.m 
print "\nConstruct a 3-generator 5-group anti-Hughes group of class 9",
  "\nwhich satisfies 2 commutator defining relators and in which",
  "\nthe normal closure of one generator, c, is abelian.",
  "\nThen repeatedly factor out complements to c^5 in the centre",
  "\nof the group, to obtain smaller counterexamples";

F<a,b,c> := FreeGroup(3);
Q := quo < F | (c,a,b), (c,b,b,b,a) >;
d := 3; p := 5; cl := 8; // ngens; prime; class
P := pQuotient( Q, p, cl : Exponent := p );
printf "\nThe class 8 quotient of the group has order %o^%o\n",
  p, FactoredOrder(P)[1][2];
G<a,b,c> := pCoveringGroup(P); 
printf "\nThe p-covering group G has order %o^%o and class %o",
  p, FactoredOrder(G)[1][2], pClass(G);
print "\nG is generated by a, b and c; and c has order", Order(c),
  "\n[b,a] has order", Order( (b,a) ), "; [c,a] has order", Order( (c,a) ),
  "; [c,b] has order", Order( (c,b) ),
  "\ngamma_2(G) is the normal closure of < [b,a], [c,a], [c,b] >,",
  "\nand gamma_2(G) has class at most 4, so gamma_2(G) has exponent 5";

print "Also factor out the derived group of the normal closure of c";
C := ncl< G | c >; C1 := DerivedGroup(C); G<a,b,c> := quo< G | C1 >;
printf "The group now has order %o^%o", p, FactoredOrder(G)[1][2];

print "\nNow compute suitable 5th powers of elements outside <c>G'";
load twB35c5q; // should be already computed by gettestwq.m
S := [ x^p : x in testwords ];
H<a,b,c> := quo< G | S >; 
printf "The quotient group, H, has order %o^%o", p, FactoredOrder(H)[1][2];
print "\nH is generated by a, b and c; and c^5 =", c^p,
  "\nH is anti-Hughes; the normal closures of a and b both have class 4",
  "\nwhile the normal closure of c is abelian",
  "\nand this implies that <c>gamma_3(G) has class 3",
  "\nso every element cg, g in gamma_3, has order 25",
  "\nWe also have:",
  "c[b,a] has order", Order(c*(b,a)), "; c[c,a] has order",
  Order(c*(c,a)), "; c[c,b] has order", Order(c*(c,b)),
  "\nSo the Hughes subgroup is <c>G' and c^5 generates gamma_9(H)";
CurrentQ := H;

//Repeatedly factor out complements for c^5 in the centre
Z := Centre(CurrentQ);
while Order(Z) ne p do
  rank := FactoredOrder(Z)[1][2];
  printf "Z, its centre, has order %o^%o", p, rank;
  print "\nNow build a complement for c^5 in Z\n";
  ZGens := [ CurrentQ!Z.i : i in [1..rank] ];
  _, index := Max( Eltseq( c^p ) );
  ComplGens := [ ZGens[i] * (CurrentQ.index)^-Eltseq(ZGens[i])[index]
                     : i in [1..rank] ];
  NextQ<a,b,c> := quo< CurrentQ | ComplGens >;
  printf "Factor it out to get an anti-Hughes group of order %o^%o",
    p, FactoredOrder(NextQ)[1][2];
  print "\ngenerated by a, b and c; and c^5 =", c^p;
  CurrentQ := NextQ;
  Z := Centre(CurrentQ);
end while;

printf "The centre is generated by %o and has order %o^%o",
  CurrentQ!(Z.1), p, FactoredOrder(Z)[1][2];
printf "\nSo this method reduces to an anti-Hughes group with order %o^%o",
  p, FactoredOrder(CurrentQ)[1][2];
print "\nwhich is as far as we can reduce the group (by this method!)";

