#####
#
# This is GAP code
# 
# The file is ~steger/donald/SU21/a23p2/a23p2-23-proj.gap
#
# See file ~steger/donald/SU21/a23p2/D.txt for the definition of the
# division algebra $\D$ and for all the notation.
#
#####

Read("/home/steger/donald/SU21/a23p2/a23p2-proj.gap");
Read("/home/steger/donald/SU21/NormElem.gap");

#####
#
# Free group
#
######

FreeGp:=FreeGroup("A","B");
Af:=FreeGp.1;
Bf:=FreeGp.2;

Read("/home/steger/donald/SU21/a23p2/a23p2-23-RelnList.gap");


GammaBarFP:=FreeGp/RelnList;;
AFP:=GammaBarFP.1;
BFP:=GammaBarFP.2;

# Free group versions of these subgroups
FPtoFGSubgp:=g->Group(List(GeneratorsOfGroup(g),UnderlyingElement));

#####
#
# Generators of $(a=23,p=2,\{23\})$
#
#####

#From: "Donald Cartwright" <donaldc@maths.usyd.edu.au>
#To: "steger@uniss.it" <steger@uniss.it>
#Subject: The two (23,2) groups
#Date: Thu, 31 Jan 2008 00:23:54 +1100

ADM:=One(mm)*[
[1/46*(Sqrt(-23)-23)*Zm^2+1/23*(5*Sqrt(-23)+46)*Zm+1/46*(7*Sqrt(-23)-23),
1/23*(5*Sqrt(-23)-30)*Zm^2+1/23*(-Sqrt(-23)-1)*Zm+1/46*(-15*Sqrt(-23)+63),
2/23*Sqrt(-23)*Zm^2-3/23*Sqrt(-23)*Zm+1/46*(5*Sqrt(-23)+69)],
[-2/23*Sqrt(-23)*Zm^2+1/23*(3*Sqrt(-23)+23)*Zm+1/23*(9*Sqrt(-23)+69),
1/23*(-4*Sqrt(-23)+23)*Zm^2+1/23*(6*Sqrt(-23)-46)*Zm+1/46*(13*Sqrt(-23)-69),
1/46*(7*Sqrt(-23)+69)*Zm^2-1/23*Sqrt(-23)*Zm+1/46*(-13*Sqrt(-23)-23)],
[1/23*(-17*Sqrt(-23)-9)*Zm^2+1/23*(4*Sqrt(-23)+2)*Zm+1/23*(3*Sqrt(-23)+29),
-2/23*Sqrt(-23)*Zm^2+1/23*(3*Sqrt(-23)-23)*Zm+1/23*(9*Sqrt(-23)+69),
1/46*(7*Sqrt(-23)-23)*Zm^2-11/23*Sqrt(-23)*Zm+1/46*(3*Sqrt(-23)-23)]];;

BDM:=One(mm)*[
[-2/23*Sqrt(-23)*Zm^2+1/92*(-11*Sqrt(-23)-23)*Zm+1/92*(13*Sqrt(-23)-23),
0,
0],
[0,
1/92*(7*Sqrt(-23)-69)*Zm^2+1/92*(Sqrt(-23)+69)*Zm+1/92*(3*Sqrt(-23)+23),
0],
[0,
0,
1/92*(Sqrt(-23)+69)*Zm^2+1/46*(5*Sqrt(-23)-23)*Zm+1/92*(7*Sqrt(-23)-69)]];;

ADMVec:=DMtoDMVec(ADM);;
BDMVec:=DMtoDMVec(BDM);;

ADMVec in DMVec;
BDMVec in DMVec;

IsOne(iotaDM(ADM)*ADM);
IsOne(iotaDM(BDM)*BDM);
	
# Check that the relations hold (projectively) for all our matrix
# generators

GammaBarDM:=Group(ADM,BDM);;
DMHom:=GroupHomomorphismByImages(FreeGp,GammaBarDM,
  [Af,Bf],[ADM,BDM]);;
#ForAll(RelnList,x->IsPOne(x^DMHom)); time; # 7916839
	
#####
#
# Construct matrices for the group generators acting on~$\D$ by
# conjugation.
#
#####

DMtoPDM:=mtx->TransposedMat(
  List(basisDM,
    bmtx->Coefficients(basisDMVec,DMtoDMVec(mtx*bmtx*mtx^-1))
));

APDM:=DMtoPDM(ADM);; time; #220329
BPDM:=DMtoPDM(BDM);; time; #61964

IsZero(LieBracket(iotaPDM,APDM));
IsZero(LieBracket(iotaPDM,BPDM));

GammaBarPDM:=Group(APDM,BPDM);;
FGtoPDM:=GroupHomomorphismByImages(FreeGp,GammaBarPDM,
  [Af,Bf],[APDM,BPDM]);;
ForAll(RelnList,x->IsOne(x^FGtoPDM));

######
#
# Find the matrices for the group generators acting by conjugation on
# the self-adjoint, traceless part of~$\D$.
#
#####

PDMtoPSA:=mtx->TransposedMat(
  List(DMVecSelfAdjBasis,SAVec->
    Coefficients(DMVecSelfAdjBasis,mtx*SAVec)
));

APSA0:=PDMtoPSA(APDM);;
BPSA0:=PDMtoPSA(BPDM);;

#####
#
# Adjust the basis of the self-adjoint part of~$\D$ so that
# the group generators correspond to integral matrices.
#
#####

GammaBarPSA0:=Group(APSA0,BPSA0);;

ILatPSA0:=InvariantLattice(GammaBarPSA0)^-1;
APSA:=APSA0^ILatPSA0;
BPSA:=BPSA0^ILatPSA0;

GammaBarPSA:=Group(APSA,BPSA);;
FGtoPSA:=GroupHomomorphismByImages(FreeGp,GammaBarPSA,
  [Af,Bf],[APSA,BPSA]);;
ForAll(RelnList,x->IsOne(x^FGtoPSA));

#APSA:=
#[ [   -228,    111,    -11,      9,    100,    148,     17,     11 ],
#  [     28,     63,     -1,     -1,     -6,   -111,     -4,     15 ],
#  [    566,     62,     19,    -22,   -226,   -780,    -48,     44 ],
#  [    276,   -186,     12,    -11,   -114,   -108,    -24,    -24 ],
#  [   -437,     74,    -17,     17,    180,    451,     36,     -8 ],
#  [     53,     67,      0,     -2,    -16,   -147,     -6,     17 ],
#  [  -1196,    178,    -46,     47,    491,   1266,     99,    -28 ],
#  [    230,    115,      6,     -9,    -85,   -426,    -21,     36 ]
#  ];
#
#BPSA:=
#[ [  -16,  -23,    0,    0,    5,   49,    2,   -6 ],
#  [    0,  -20,    0,    0,    0,   28,    0,   -5 ],
#  [    0,  -46,    1,    0,    0,   64,    0,  -12 ],
#  [    0,    0,    0,    1,    0,    0,    0,    0 ],
#  [  -23,    0,    0,    0,    7,   23,    3,    0 ],
#  [    0,  -23,    0,    0,    0,   33,    0,   -6 ],
#  [  -69,    0,    0,    0,   23,   69,    8,    0 ],
#  [    0,  -46,    0,    0,    0,   69,    0,  -13 ] ];

######
#
# Do calculations $\mod 2$
#
######

toMod2:=x->x*One(GF(2));
toMod2M:=mtx->fOnM(toMod2,mtx);

APSAMod2:=toMod2M(APSA);;
BPSAMod2:=toMod2M(BPSA);;

GammaBarPSAMod2:=Group(APSAMod2,BPSAMod2);;
FGtoPSAMod2:=GroupHomomorphismByImages(FreeGp,GammaBarPSAMod2,
  [Af,Bf],[APSAMod2,BPSAMod2]);;
ForAll(RelnList,x->IsOne(x^FGtoPSAMod2));
	
Size(GammaBarPSAMod2) = 7*2^6;
ChSGammaBarPSAMod2:=ChiefSeries(GammaBarPSAMod2);
Length(ChSGammaBarPSAMod2) = 4;
List(ChSGammaBarPSAMod2,Size)=[7*2^6,2^6,2^3,1];
Mod2H1:=ChSGammaBarPSAMod2[2];
Mod2H0:=ChSGammaBarPSAMod2[3];
Mod2H0 = Center(Mod2H1);
StructureDescription(Mod2H0) = "C2 x C2 x C2";
StructureDescription(Mod2H1/Mod2H0) = "C2 x C2 x C2";
#StructureDescription(GammaBarPSAMod2)
#  = "((C2 x C2 x C2) . (C2 x C2 x C2)) : C7";

######
#
# Do calculations $\mod 3$
#
######

toMod3:=x->x*One(GF(3));
toMod3M:=mtx->fOnM(toMod3,mtx);

APSAMod3:=toMod3M(APSA);;
BPSAMod3:=toMod3M(BPSA);;

GammaBarPSAMod3:=Group(APSAMod3,BPSAMod3);;
FGtoPSAMod3:=GroupHomomorphismByImages(FreeGp,GammaBarPSAMod3,
  [Af,Bf],[APSAMod3,BPSAMod3]);;
ForAll(RelnList,x->IsOne(x^FGtoPSAMod3));
		
Size(GammaBarPSAMod3) = 5616;
#IsomorphismGroups(PGL(3,3),GammaBarPSAMod3); time; #35052

######
#
# Do calculations $\mod 5$
#
######

toMod5:=x->x*One(GF(5));
toMod5M:=mtx->fOnM(toMod5,mtx);

APSAMod5:=toMod5M(APSA);;
BPSAMod5:=toMod5M(BPSA);;

GammaBarPSAMod5:=Group(APSAMod5,BPSAMod5);;
FGtoPSAMod5:=GroupHomomorphismByImages(FreeGp,GammaBarPSAMod5,
  [Af,Bf],[APSAMod5,BPSAMod5]);;
ForAll(RelnList,x->IsOne(x^FGtoPSAMod5));

ChSGammaBarPSAMod5:=ChiefSeries(GammaBarPSAMod5); #11672
#IsomorphismGroups(PSU(3,5),ChSGammaBarPSAMod5[2]); time; #15125

######
#
# Do calculations $\mod 7$
#
######

# Not tried yet!

##### toMod7:=x->x*One(GF(7));
##### toMod7M:=mtx->fOnM(toMod7,mtx);
##### 
##### APSAMod7:=toMod7M(APSA);;
##### BPSAMod7:=toMod7M(BPSA);;
##### 
##### GammaBarPSAMod7:=Group(APSAMod7,BPSAMod7);;
##### FGtoPSAMod7:=GroupHomomorphismByImages(FreeGp,GammaBarPSAMod7,
#####   [Af,Bf],[APSAMod7,BPSAMod7]);;
##### ForAll(RelnList,x->IsOne(x^FGtoPSAMod7));
##### 	
##### #IsomorphismGroups(PGU(3,7),GammaBarPSAMod7); time; #
##### #Size(GammaBarPSAMod7) = 5663616; time; #

######
#
# Do calculations $\mod 11$
#
######

# Not done yet!

##### toMod11:=x->x*One(GF(11));
##### toMod11M:=mtx->fOnM(toMod11,mtx);
##### 
##### APSAMod11:=toMod11M(APSA);;
##### BPSAMod11:=toMod11M(BPSA);;
##### 
##### GammaBarPSAMod11:=Group(APSAMod11,BPSAMod11);;
##### FGtoPSAMod11:=GroupHomomorphismByImages(FreeGp,GammaBarPSAMod11,
#####   [Af,Bf],[APSAMod11,BPSAMod11]);;
##### ForAll(RelnList,x->IsOne(x^FGtoPSAMod11));
##### 
##### 
##### #ChSGammaBarPSAMod11:=ChiefSeries(GammaBarPSAMod11); time;
##### #List(ChSGammaBarPSAMod11,Size) =
##### #  [(11^3+1)*(11^2-1)*11^3,(11^3+1)*(11^2-1)*11^3/3,1];
##### #Size(GammaBarPSAMod11) = 212747040;	
##### #
##### ##### According to both theory and evidence:
##### ##### StructureDescription(GammaBarPSAMod11) = "PGU(3,11)"

######
#
# Do calculations $\mod 23$
#
######

toMod23:=x->x*One(GF(23));
toMod23M:=mtx->fOnM(toMod23,mtx);

APSAMod23:=toMod23M(APSA);;
BPSAMod23:=toMod23M(BPSA);;

GammaBarPSAMod23:=Group(APSAMod23,BPSAMod23);;
FGtoPSAMod23:=GroupHomomorphismByImages(FreeGp,GammaBarPSAMod23,
  [Af,Bf],[APSAMod23,BPSAMod23]);;
ForAll(RelnList,x->IsOne(x^FGtoPSAMod23));

Read("/home/steger/donald/SU21/NormElem2.gap");
Mod23H1:=Group(NormElem2(GammaBarPSAMod23,23)); time;
Mod23Q1:=QGroup(GammaBarPSAMod23,Mod23H1,23);
StructureDescription(Mod23H1) = "C23 x C23 x C23";

FGtoMod23Q1:=GroupHomomorphismByImages(FreeGp,Mod23Q1,
  [Af,Bf],GeneratorsOfGroup(Mod23Q1));;
ForAll(RelnList,x->IsOne(x^FGtoMod23Q1));

ChSeriesMod23Q1:=ChiefSeries(Mod23Q1);
List(ChSeriesMod23Q1,Size) = [22*23*24*23^2,2*23^2,23^2,1];

Mod23H2:=ChSeriesMod23Q1[3];
Mod23H2LAL:=LinearActionLayer(
  Mod23Q1,GeneratorsOfGroup(Mod23Q1),Pcgs(Mod23H2));
Mod23Q2:=Group(Mod23H2LAL);
FGtoMod23Q2:=GroupHomomorphismByImages(FreeGp,Mod23Q2,
  [Af,Bf],Mod23H2LAL);;
ForAll(RelnList,x->IsOne(x^FGtoMod23Q2));
IsNaturalSL(Mod23Q2);

#IsomorphismGroups(SL(2,23),Mod23Q2); time; #5504
	
#####
#
# Consider abelianization
#
#####

# (a=23,p=2,\{23\})
AbelianInvariants(GammaBarFP) = [3,7];
AbelianInvariants(GammaBarPSAMod2) = [7];
AbelianInvariants(GammaBarPSAMod5) = [3];
AbelianInvariants(Mod23Q1) = [];
