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

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

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

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

RelnList:=[
(Bf*Af^-1*Bf^-1*Af*Bf*Af)^3,
Bf^-1*Af^-1*Bf^2*Af^-1*Bf^-1*Af*Bf*Af^3*Bf^-1*Af*Bf^-1*Af^2*Bf^-1*Af^-1*Bf^-1*Af^-1,
Bf*Af*Bf*Af^-1*Bf^-1*Af*Bf*Af^3*Bf^-1*Af^-1*Bf^-2*Af^-2*Bf^-1*Af^-1*Bf^2,
Af^-1*Bf^-1*Af^-1*Bf*Af^-2*Bf^-1*Af^-1*Bf*Af^-2*Bf^-1*Af^-1*Bf*Af*Bf^-1*Af^-1*Bf^-2*Af^-1,
Af*Bf*Af*Bf^-1*Af^-2*Bf^-1*Af^-1*Bf^2*Af^-2*Bf*Af^-1*Bf*Af^-1*Bf^-1*Af*Bf*Af,
Bf*Af^-1*Bf^-2*Af*Bf*Af^2*Bf^2*Af*Bf^-1*Af*Bf*Af*Bf*Af*Bf^-1*Af*Bf*Af^2,
Bf*Af*Bf^-1*Af^-1*Bf*Af*Bf^-1*Af*Bf*Af^2*Bf*Af^-2*Bf*Af^2*Bf*Af^-2*Bf*Af^-1*Bf*Af^-1,
Bf*Af^2*Bf*Af^-1*Bf^-1*Af^2*Bf^-1*Af^-2*Bf^-1*Af*Bf^-2*Af*Bf*Af*Bf^2*Af^-1*Bf^-1*Af*Bf*Af^2,
Af^-1*Bf^-1*Af^-1*Bf*Af^-1*Bf^-2*Af^-2*Bf^-1*Af^-1*Bf^2*Af^-1*Bf*Af^2*Bf*Af^-2*Bf*Af^-1*Bf*Af^-1*Bf*Af*Bf^-1*Af^-1,
(Bf*Af*Bf^-1*Af^2*Bf^-2*Af*Bf*Af)^3,
Bf*Af^-2*Bf^-1*Af^-1*Bf^2*Af^-2*Bf*Af^-1*Bf^-1*Af*Bf*Af^-1*Bf^-1*Af^-1*Bf*Af^-1*Bf^-2*Af^-1*Bf*Af^-1*Bf^-1*Af*Bf^-2*Af*Bf*Af^2,
Bf^2*Af*Bf^-1*Af*Bf*Af^2*Bf*Af^-1*Bf^-1*Af^2*Bf^-1*Af^-1*Bf^-1*Af^-2*Bf^-1*Af^-1*Bf^2*Af^-1*Bf*Af^2*Bf*Af^-1*Bf*Af*Bf^-1*Af,
Bf*Af^-1*Bf*Af^2*Bf^-1*Af^2*Bf^-2*Af*Bf*Af*Bf^-1*Af^-1*Bf*Af*Bf^-1*Af^2*Bf^-1*Af^-1*Bf^-2*Af^-1*Bf*Af*Bf^-1*Af*Bf*Af^2,
Bf*Af*Bf^-1*Af*Bf*Af*Bf^-1*Af^-1*Bf*Af^-1*Bf^-1*Af^-1*Bf*Af^-1*Bf*Af^-1*Bf*Af^-1*Bf*Af^2*Bf*Af^-2*Bf*Af*Bf^-2*Af*Bf*Af^2*Bf*Af^-1
];

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

index3aFP:=Group(AFP, BFP*AFP*BFP^-1, BFP^-1*AFP*BFP);
index3bFP:=Group(AFP*BFP^-1, AFP^-1*BFP, AFP^3);
index3cFP:=Group(BFP, AFP^3, AFP*BFP*AFP^-1, AFP^-1*BFP*AFP);
index3xFP:=Group(BFP*AFP, AFP*BFP, BFP*AFP^-2);

index3aFCA:=FactorCosetAction(GammaBarFP,index3aFP);
index3bFCA:=FactorCosetAction(GammaBarFP,index3bFP);
index3cFCA:=FactorCosetAction(GammaBarFP,index3cFP);
index3xFCA:=FactorCosetAction(GammaBarFP,index3xFP);

index3aFCA:=FactorCosetAction(GammaBarFP,index3aFP);
index3bFCA:=FactorCosetAction(GammaBarFP,index3bFP);
index3cFCA:=FactorCosetAction(GammaBarFP,index3cFP);
index3xFCA:=FactorCosetAction(GammaBarFP,index3xFP);

# Check the indexes of the subgroups

Index(GammaBarFP,index3aFP) = 3;
Index(GammaBarFP,index3bFP) = 3;
Index(GammaBarFP,index3cFP) = 3;
Index(GammaBarFP,index3xFP) = 3;

# Check normality

IsNormal(GammaBarFP,index3aFP);
IsNormal(GammaBarFP,index3bFP);
IsNormal(GammaBarFP,index3cFP);
IsNormal(GammaBarFP,index3xFP);

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

index3aFG:=FPtoFGSubgp(index3aFP);
index3bFG:=FPtoFGSubgp(index3bFP);
index3cFG:=FPtoFGSubgp(index3cFP);
index3xFG:=FPtoFGSubgp(index3xFP);

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

#From: "Donald Cartwright" <donaldc@maths.usyd.edu.au>
#To: steger@uniss.it
#Subject: Re: (a=15,p=2), Tim's presentation
#Date: Tue, 29 Jan 2008 15:33:55 +1100

ADM:=[
[1/15*Sqrt(-15)*Zm^2+1/10*(-Sqrt(-15)+5)*Zm+One(mm)/10*(-3*Sqrt(-15)-5),
Zero(mm),
Zero(mm)],
[Zero(mm),
-2/15*Sqrt(-15)*Zm^2+1/5*Sqrt(-15)*Zm+One(mm)/10*(Sqrt(-15)-5),
Zero(mm)],
[Zero(mm),
Zero(mm),
1/15*Sqrt(-15)*Zm^2+1/10*(-Sqrt(-15)-5)*Zm+One(mm)/10*(-3*Sqrt(-15)-5)]];

BDM:=[ [One(mm)/6*(Sqrt(-15)-3),
One(mm)/6*(-Sqrt(-15)-3),
One(mm)/12*(-Sqrt(-15)+3)],
[One(mm)/6*(-Sqrt(-15)+3),
One(mm)/6*(Sqrt(-15)-3),
One(mm)/6*(-Sqrt(-15)-3)], 
[One(mm)/3*(-Sqrt(-15)-3),
One(mm)/6*(-Sqrt(-15)+3),
One(mm)/6*(Sqrt(-15)-3)]];

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));
	
#####
#
# 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);;
BPDM:=DMtoPDM(BDM);;

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));

######
#
# 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) = 21*2^6;
List(ChiefSeries(GammaBarPSAMod2),Size) = [1344, 448, 64, 8, 1];
#StructureDescription(GammaBarPSAMod2)
#  = "(((C2 x C2 x C2) . (C2 x C2 x C2)) : C7) : C3";

index3aPSAMod2:=Image(FGtoPSAMod2,index3aFG);
index3bPSAMod2:=Image(FGtoPSAMod2,index3bFG);
index3cPSAMod2:=Image(FGtoPSAMod2,index3cFG);
index3xPSAMod2:=Image(FGtoPSAMod2,index3xFG);

Index(GammaBarPSAMod2,index3aPSAMod2) = 3;
index3bPSAMod2 = GammaBarPSAMod2;
index3cPSAMod2 = GammaBarPSAMod2;
index3xPSAMod2 = GammaBarPSAMod2;

######
#
# 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));
	
ChSGammaBarPSAMod3:=ChiefSeries(GammaBarPSAMod3);
Length(ChSGammaBarPSAMod3) = 7;
Mod3H1:=ChSGammaBarPSAMod3[5];
StructureDescription(Mod3H1) = "C3 x C3 x C3 x C3";
Mod3H1LAL:=LinearActionLayer(
  GammaBarPSAMod3,GeneratorsOfGroup(GammaBarPSAMod3),Pcgs(Mod3H1));
Mod3Q1:=Group(Mod3H1LAL);
Size(Mod3Q1)*Size(Mod3H1) = Size(GammaBarPSAMod3);
StructureDescription(Mod3Q1) = "C3 x SL(2,3)";

MTXMod3H1:=GModuleByMats(Mod3H1LAL,GF(3));
List(MTX.BasesSubmodules(MTXMod3H1),Size) = [0,2,4];

NormSubsMod3H1:=Filtered(NormalSubgroups(Mod3Q1),h->Size(h) = 3);
Size(NormSubsMod3H1) = 1;
Mod3H2:=NormSubsMod3H1[1];
Mod3Q2Hom:=NaturalHomomorphismByNormalSubgroup(Mod3Q1,Mod3H2);
Mod3Q2:=Image(Mod3Q2Hom);
IdSmallGroup(Mod3Q2) = IdSmallGroup(SL(2,3));

AbelianInvariants(GammaBarPSAMod3) = [3,3];
AbelianInvariants(Mod3Q1) = [3,3];
AbelianInvariants(Mod3Q2) = [3];

index3aPSAMod3:=Image(FGtoPSAMod3,index3aFG);
index3bPSAMod3:=Image(FGtoPSAMod3,index3bFG);
index3cPSAMod3:=Image(FGtoPSAMod3,index3cFG);
index3xPSAMod3:=Image(FGtoPSAMod3,index3xFG);

Index(GammaBarPSAMod3,index3aPSAMod3) = 3;
Index(GammaBarPSAMod3,index3bPSAMod3) = 3;
Index(GammaBarPSAMod3,index3cPSAMod3) = 3;
Index(GammaBarPSAMod3,index3xPSAMod3) = 3;

FGtoMod3Q1:=GroupHomomorphismByImages(FreeGp,Mod3Q1,
  [Af,Bf],Mod3H1LAL);;
ForAll(RelnList,x->IsOne(x^FGtoMod3Q1));

index3aMod3Q1:=Image(FGtoMod3Q1,index3aFG);
index3bMod3Q1:=Image(FGtoMod3Q1,index3bFG);
index3cMod3Q1:=Image(FGtoMod3Q1,index3cFG);
index3xMod3Q1:=Image(FGtoMod3Q1,index3xFG);

Index(Mod3Q1,index3aMod3Q1) = 3;
Index(Mod3Q1,index3bMod3Q1) = 3;
Index(Mod3Q1,index3cMod3Q1) = 3;
Index(Mod3Q1,index3xMod3Q1) = 3;

FGtoMod3Q2:=CompositionMapping(Mod3Q2Hom,FGtoMod3Q1);
ForAll(RelnList,x->IsOne(x^FGtoMod3Q1));

index3aMod3Q2:=Image(FGtoMod3Q2,index3aFG);
index3bMod3Q2:=Image(FGtoMod3Q2,index3bFG);
index3cMod3Q2:=Image(FGtoMod3Q2,index3cFG);
index3xMod3Q2:=Image(FGtoMod3Q2,index3xFG);

index3aMod3Q2 = Mod3Q2;
Index(Mod3Q2,index3bMod3Q2) = 3;
index3cMod3Q2 = Mod3Q2;
index3xMod3Q2 = Mod3Q2;

######
#
# 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));

Mod5H1:=NormElem(GammaBarPSAMod5,5);	
StructureDescription(Mod5H1) = "C5 x C5 x C5 x C5 x C5";
Mod5H1LAL:=LinearActionLayer(
  GammaBarPSAMod5,GeneratorsOfGroup(GammaBarPSAMod5),Pcgs(Mod5H1));
Mod5Q1:=Group(Mod5H1LAL);
#Size(Mod5Q1)*Size(Mod5H1) = Size(GammaBarPSAMod5);
IdSmallGroup(Mod5Q1) = IdSmallGroup(PGL(2,5));
IdSmallGroup(Mod5Q1) = IdSmallGroup(SymmetricGroup(5));

index3aPSAMod5:=Image(FGtoPSAMod5,index3aFG);
index3bPSAMod5:=Image(FGtoPSAMod5,index3bFG);
index3cPSAMod5:=Image(FGtoPSAMod5,index3cFG);
index3xPSAMod5:=Image(FGtoPSAMod5,index3xFG);

index3aPSAMod5 = GammaBarPSAMod5;
index3bPSAMod5 = GammaBarPSAMod5;
index3cPSAMod5 = GammaBarPSAMod5;
index3xPSAMod5 = GammaBarPSAMod5;

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

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);
#Size(GammaBarPSAMod7) = 5663616;

index3aPSAMod7:=Image(FGtoPSAMod7,index3aFG);
index3bPSAMod7:=Image(FGtoPSAMod7,index3bFG);
index3cPSAMod7:=Image(FGtoPSAMod7,index3bFG);
index3xPSAMod7:=Image(FGtoPSAMod7,index3bFG);

index3aPSAMod7 = GammaBarPSAMod7;
index3bPSAMod7 = GammaBarPSAMod7;
index3cPSAMod7 = GammaBarPSAMod7;
index3xPSAMod7 = GammaBarPSAMod7;

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

# NEVER CHECKED!

##### 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));
##### 	
##### #Size(GammaBarPSAMod11) = 212747040;
##### #Size(PGU(3,11)) = 212747040;
##### 
##### index3aPSAMod11:=Image(FGtoPSAMod11,index3aFG);
##### index3bPSAMod11:=Image(FGtoPSAMod11,index3bFG);
##### index3cPSAMod11:=Image(FGtoPSAMod11,index3cFG);
##### index3xPSAMod11:=Image(FGtoPSAMod11,index3xFG);
##### 
##### Index(GammaBarPSAMod11,index3aPSAMod11) = 3;
##### index3bPSAMod11 = GammaBarPSAMod11;
##### index3cPSAMod11 = GammaBarPSAMod11;
##### index3xPSAMod11 = GammaBarPSAMod11;

#####
#
# Consider abelianizations
#
#####

# (a=15,p=2,\{3\})
AbelianInvariants(GammaBarFP) = [2,3,3];
AbelianInvariants(GammaBarPSAMod2) = [3];
AbelianInvariants(GammaBarPSAMod3) = [3,3];
AbelianInvariants(GammaBarPSAMod5) = [2];

# (a=15,p=2,\{3\},D_3)
AbelianInvariants(index3aFP) = [2,3,7];
AbelianInvariants(index3aPSAMod2) = [7];
AbelianInvariants(index3aPSAMod3) = [3];
AbelianInvariants(index3aPSAMod5) = [2];

# (a=15,p=2,\{3\},3_3)
AbelianInvariants(index3bFP) = [2,2,2,3];
AbelianInvariants(index3bPSAMod2) = [3];
AbelianInvariants(index3bPSAMod3) = [2,2,3];
AbelianInvariants(index3bPSAMod5) = [2];

# (a=15,p=2,\{3\},(D3)_3
AbelianInvariants(index3cFP) = [2,3];
AbelianInvariants(index3cPSAMod2) = [3];
AbelianInvariants(index3cPSAMod3) = [3];
AbelianInvariants(index3cPSAMod5) = [2];

# (a=15,p=2,\{3\},(D^2 3)_3
AbelianInvariants(index3xFP) = [2,3];
AbelianInvariants(index3xPSAMod2) = [3];
AbelianInvariants(index3xPSAMod3) = [3];
AbelianInvariants(index3xPSAMod5) = [2];

