// p7g2q11mo.m : This program is an analogue of p7exp.m
print "\nConstruct a 2-generator anti-Hughes 7-group of class 14",
  "\nwhich satisfies 11 commutator defining relators and in which",
  "\nthe normal closures of the generators both have class 7.",
  "\nThen repeatedly factor out complements to [b,a]^7 in the centre",
  "\nof the group, to obtain smaller counterexamples";

F<a,b> := FreeGroup(2); p := 7;
Q := quo < F | (b,a,a,a,a,b), (b,a,a,a,a,a,b), (b,a,a,a,a,a,a,b),
               (b,a,a,a,a,a,a,a,b), (b,a,b,b,b,a), (b,a,b,b,b,b,a),
               (b,a,b,b,b,b,b,a), (b,a,b,b,b,b,b,b,a), (b,a,a,a,b,a,b,a),
               (b,a,a,a,b,b,b,b,b), (b,a,a,a,b,a,b,b,a,a,b) >;

P := pQuotientProcess( Q, p, p : Exponent :=p ); 
NextClass( ~P : Exponent := p, MaxOccurrence := [p,p] );
NextClass( ~P : Exponent := p, MaxOccurrence := [p,p] );
NextClass( ~P : Exponent := p, MaxOccurrence := [p,p] );
NextClass( ~P : Exponent := p, MaxOccurrence := [p,p] );
NextClass( ~P : Exponent := p, MaxOccurrence := [p,p] );
NextClass( ~P : Exponent := p, MaxOccurrence := [p,p] );

printf "\nThe class 13 quotient of the group has order %o^%o\n",
  p, FactoredOrder(P)[1][2];

NextClass( ~P : Exponent := 0, MaxOccurrence := [p,p] );
G<a,b> := ExtractGroup(P); 
printf "\nThe p-covering group G has order %o^%o and class %o\n",
  p, FactoredOrder(G)[1][2], pClass(G);
print  "\nG is generated by a and b; and [b,a] has order", Order( (b,a) ),
  "\n[b,a,a] has order", Order( (b,a,a) ),
  "; [b,a,b] has order", Order( (b,a,b) ),
  "\ngamma_3(G) is the normal closure of < [b,a,a], [b,a,b] >,",
  "\nand gamma_3(G) has class at most 4, so gamma_3(G) has exponent 7";

print "\nNow compute suitable 7th powers of elements outside the derived group";
load "tw7.m"; // should be already computed
S := [ x^7 : x in testwords ];
H<a,b> := quo< G | S >;
printf "The quotient group H has order %o^%o", p, FactoredOrder(H)[1][2];
print "\nH is generated by a and b; and [b,a] has order", Order( (b,a) ),
  "\nH is anti-Hughes; the normal closures of a and b both have class 7
   \n[b,a]^7 generates gamma_14(H)";

CurrentQ:=H;

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

printf "\nThe 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!)";
