// wallcl9.m 
print "\nConstruct the largest class 9 quotient of Wall's 3-generator",
  "\nanti-Hughes 5-group.",
  "\nThen repeatedly factor out complements to c^5 in the centre",
  "\nof the group, to obtain smaller counterexamples";

p := 5;
F<a,b,c> := FreeGroup(3);
Q := quo < F | (b,a,a,a,b,a,b,a), (b,a,a,a,b,a,b,b), (b,a,a,a,b,b,a,b),
               (b,a,a,b,b,a,b,b) >;
P := pQuotientProcess( Q, p, 2 : Exponent := p );
NextClass( ~P : Exponent := p, MaxOccurrence := [0,0,1] );
NextClass( ~P : Exponent := p, MaxOccurrence := [0,0,1] );
NextClass( ~P : Exponent := p, MaxOccurrence := [0,0,1] );
NextClass( ~P : Exponent := p, MaxOccurrence := [0,0,1] );
NextClass( ~P : Exponent := p, MaxOccurrence := [0,0,1] );
NextClass( ~P : Exponent := p, MaxOccurrence := [0,0,1] );
// Note: this implementation of the p-quotient algorithm uses
// the lower exponent-$p$-central series so we must allow
// 2 (not 1) occurrences of c in the covering group
// to allow the order of c to become 25 in the cover
NextClass( ~P : Exponent := 0, MaxOccurrence := [0,0,2] );
G<a,b,c> := ExtractGroup(P); 
printf "\nThe p-covering group G has order %o^%o and class %o",
  FactoredOrder(G)[1][1], 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",
  "\n(This became non-trivial in the p-cover computation)";
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 twB35c5mo441; // 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 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'";
  "\nNow factor out a complement for c^5 in the multiplier";

cl9start := pRanks(H)[8] + 1;
lastg := FactoredOrder(H)[1][2];
alive := lastg;
// Since the exponent of H.alive is nonzero in c^5 we
// choose a complement of H.alive
print "\nFactoring out a complement of", H.alive,
  "gives us a smaller anti-Hughes group";
CurrentQ<a,b,c> := quo< H | [ H.i : i in [cl9start..alive-1] ] >;
printf "CurrentQ with order %o^%o",
  FactoredOrder(CurrentQ)[1][1], FactoredOrder(CurrentQ)[1][2];
print "\nCurrentQ is generated by a, b and c; and c^5 =", c^p, "\n";

Z := Center(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 := Center(CurrentQ);
end while;

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

