load "Subgroups/functions.txt";

G:=PSL(3,5);
CC:=ConjugacyClasses(G);
u:=CC[7,3];
IrrAll:=IrreducibleModules(G,GF(5));
S3:=IrrAll[2];
S3d:=Dual(S3);
S6:=SymmetricSquare(S3d);
S6d:=Dual(S6);
S8:=IrrAll[6];
S10:=OrderByDimension(CompositionFactors(TensorProduct(S3d,S6)))[2];
S10d:=Dual(S10);
S151:=OrderByDimension(CompositionFactors(SymmetricSquare(S6d)))[2];
S151d:=Dual(S151);
S152d:=ExteriorSquare(S6);
S152:=Dual(S152d);
S18:=OrderByDimension(CompositionFactors(TensorProduct(S3,S10)))[3];
S18d:=Dual(S18);
S19:=IrrAll[15];
S35:=OrderByDimension(CompositionFactors(ExteriorSquare(S10d)))[2];
S35d:=Dual(S35);
S39:=Socle(ExteriorSquare(S151d));
S39d:=Dual(S39);

Irr:=[S3,S3d,S6,S6d,S8,S152,S152d,S18,S18d,S35,S35d,S39,S39d];
labs:=["3","3^*","6","6^*","8","15_2","15_2^*","18","18^*","35","35^*","39","39^*"];

// Compute radicals. This will take some time.

A1:=S3d;
for j in [S18,S39,S39d,S152,S8,S6,S35] do
  E,rho:=Ext(A1,j); A1:=MaximalExtension(A1,j,E,rho); DescribeLayers(Dual(A1),Irr,labs);
end for;
for j in [S6,S6d,S8,S152,S152d,S18,S18d,S35,S35d,S39,S39d] do Dimension(Ext(A1,j)) eq 0; end for;

A2:=S152d;
for j in [S39,S35d,S8,S6d,S3,S18d] do
  E,rho:=Ext(A2,j); A2:=MaximalExtension(A2,j,E,rho); DescribeLayers(Dual(A2),Irr,labs);
end for;
for j in [S3,S3d,S6,S6d,S8,S18,S18d,S35,S35d,S39,S39d] do Dimension(Ext(A2,j)) eq 0; end for;

A3:=S18d;
for j in [S8,S6d,S3,S39,S35d,S152d] do
  E,rho:=Ext(A3,j); A3:=MaximalExtension(A3,j,E,rho); DescribeLayers(Dual(A3),Irr,labs);
end for;
for j in [S3,S3d,S6,S6d,S8,S152,S152d,S35,S35d,S39,S39d] do Dimension(Ext(A3,j)) eq 0; end for;

A4:=S35d;
for j in [S152d,S6d,S39,S18d,S8,S6d,S3] do
  E,rho:=Ext(A4,j); A4:=MaximalExtension(A4,j,E,rho); DescribeLayers(Dual(A4),Irr,labs);
end for;
for j in [S3,S3d,S6,S6d,S8,S152,S152d,S18,S18d,S39,S39d] do Dimension(Ext(A4,j)) eq 0; end for;

A5:=S39d;
for j in [S152,S8,S6,S3,S3d,S18,S35] do
  E,rho:=Ext(A5,j); A5:=MaximalExtension(A5,j,E,rho); DescribeLayers(Dual(A5),Irr,labs);
end for;
for j in [S3,S3d,S6,S6d,S8,S152,S152d,S18,S18d,S35,S35d] do Dimension(Ext(A5,j)) eq 0; end for;

A6:=S6;
for j in [S39d,S35,S18,S152,S8,S3d] do
  E,rho:=Ext(A6,j); A6:=MaximalExtension(A6,j,E,rho); DescribeLayers(Dual(A6),Irr,labs);
end for;
for j in [S3,S3d,S8,S152,S152d,S18,S18d,S35,S35d,S39,S39d] do Dimension(Ext(A6,j)) eq 0; end for;

// Step 1

"Action of u on module in Step 1";
Test1:=DirectSum([A3,Dual(A3)]);
ActionOfUnipotent([Test1],u);


"Now the modules for W. We run through each socle, one at a time.";
A1a:=JacobsonRadical(A1); A1a:=RemoveFromTop(A1a,Irr,Irr,[3,4,5,10,11,12,13]);
DescribeLayers(Dual(A1/A1a),Irr,labs);
A1b:=RemoveFromTop(A1a,Irr,Irr,[1,2,6,7,8,9]);
A1c:=Dual(A1/A1b);
DescribeLayers(A1c,Irr,labs);
DescribeLayers(RemoveFromTop(A1c,Irr,Irr,[3,4,5,10,11,12,13]),Irr,labs);


A2a:=JacobsonRadical(A2); A2a:=RemoveFromTop(A2a,Irr,Irr,[3,4,5,10,11,12,13]);
DescribeLayers(Dual(A2/A2a),Irr,labs);
A2b:=RemoveFromTop(A2a,Irr,Irr,[1,2,6,7]);
A2c:=Dual(A2/A2b);
DescribeLayers(A2c,Irr,labs);
DescribeLayers(RemoveFromTop(A2c,Irr,Irr,[3,4,5,10,11,12,13]),Irr,labs);


A3a:=JacobsonRadical(A3); A3a:=RemoveFromTop(A3a,Irr,Irr,[3,4,5,10,11,12,13]);
DescribeLayers(Dual(A3/A3a),Irr,labs);
A3b:=RemoveFromTop(A3a,Irr,Irr,[1,2,6,7,8,9]);
A3c:=Dual(A3/A3b);
DescribeLayers(A3c,Irr,labs);
DescribeLayers(RemoveFromTop(A3c,Irr,Irr,[3,4,5,10,11,12,13]),Irr,labs);



// Step 2
"Now on to Step 2.";

LE8:=DirectSum(Irr cat [Irr[5]]);
z:=CC[5,3];
L:=Centralizer(G,z);
EigenvaluesOfElement(LE8,z);
IrrL:=IrreducibleModules(L,GF(5));

IrrL:=[TrivialModule(L,GF(5))] cat OrderByDimension(CompositionFactors(Restriction(S6,L))); Prune(~IrrL); Prune(~IrrL);
IrrL cat:=OrderByDimension(CompositionFactors(Restriction(S3,L)));
Insert(~IrrL,4,Dual(IrrL[3]));
for i in [2,3,4] do Append(~IrrL,TensorProduct(IrrL[5],IrrL[i])); end for;
Append(~IrrL,TensorProduct(IrrL[4],SymmetricSquare(IrrL[6])));
for i in [2,3,4] do Append(~IrrL,TensorProduct(IrrL[9],IrrL[i])); end for;
Append(~IrrL,SymmetricPower(IrrL[7],3));
for i in [2,3,4] do Append(~IrrL,TensorProduct(IrrL[13],IrrL[i])); end for;
Append(~IrrL,SymmetricPower(IrrL[5],4));
for i in [2,3,4] do Append(~IrrL,TensorProduct(IrrL[17],IrrL[i])); end for;

// Check everything in Step 2: labelling is given as follows:
// dimensions of IrrL are 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5.
// eigenvalues are +1,+1,-1,-1 for dim 1,3,5 i,i,-i,-i for dim 2,4.
// labelling is +,-,+,- in all cases. So IrrL[15] is 4-, eigenvalue -i.

"Labels are i+ or i- for the module of that dimension with that sign, followed by :, then with the eigenvalue, e.g., 3+:-1 for eigenvalue -1, dimension 3, type +.";
labsL:=["1+:1","1-:1","1+:-1","1-:-1","2+:i","2-:i","2+:-i","2-:-i",
"3+:1","3-:1","3+:-1","3-:-1","4+:i","4-:i","4+:-i","4-:-i",
"5+:1","5-:1","5+:-1","5-:-1"];

"Projectives:";
for i in [1,5,9,13] do DescribeLayers(ProjectiveIndecomposableModule(IrrL[i]),IrrL,labsL); end for;

"Restrictions of simple modules 3, 6, 8, 15_2, 18, 35 and 39:";
for i in [S3,S6,S8,S152,S18,S35,S39] do DescribeLayers(Restriction(i,L),IrrL,labsL); end for;

"Now determine the action of L' on M(D8). It must act as PSL, or SL with no PSL factors, on M(D8).";

Ld:=DerivedSubgroup(L); IrrLd:=IrreducibleModules(Ld,GF(5));
SequenceToMultiset(IdentifyFactors(Restriction(LE8,Ld),IrrLd));

labsLd:=["1","2","3","4","5"];

Poss16s:=[[5,5,5,1],[5,5,3,3],[5,5,3,1,1,1],[5,5,1,1,1,1,1,1],[5,3,3,3,1,1],[5,3,3,1,1,1,1,1],[5,3,1,1,1,1,1,1,1,1],
[5,1,1,1,1,1,1,1,1,1,1,1],[3,3,3,3,3,1],[3,3,3,3,1,1,1,1],[3,3,3,1,1,1,1,1,1,1],[3,3,1,1,1,1,1,1,1,1,1,1],
[3,1,1,1,1,1,1,1,1,1,1,1,1,1]];
"We give the factors on M(D8) and the factors on L(D8).";
for i in Poss16s do i,SequenceToMultiset(IdentifyFactors(ExteriorSquare(DirectSum([IrrLd[j]:j in i])),IrrLd)); end for;

Poss16s2:=[[4,4,4,4],[4,4,4,2,2],[4,4,2,2,2,2],[4,2,2,2,2,2,2],[2,2,2,2,2,2,2,2]];
for i in Poss16s2 do i,SequenceToMultiset(IdentifyFactors(ExteriorSquare(DirectSum([IrrLd[j]:j in i])),IrrLd)); end for;

// Step 3:

// Check structure of L' on eigenspaces.
M1:=DirectSum([IrrLd[1],IrrLd[5]]);
M2:=DirectSum([IrrLd[5],ProjectiveIndecomposableModule(IrrLd[1])]);
N1:=IrrLd[4];
N2:=DirectSum([IrrLd[5],IrrLd[5],BuildLargestModule(IrrLd[3],[IrrLd[3]])]);

"Action of L' on eigenspaces:";
"1-eigenspace";
for i in IndecomposableSummands(ExteriorSquare(M1)) do DescribeLayers(i,IrrLd,labsLd); end for;
for i in IndecomposableSummands(ExteriorSquare(M2)) do DescribeLayers(i,IrrLd,labsLd); end for;
"-1-eigenspace";
for i in IndecomposableSummands(TensorProduct(M1,M2)) do DescribeLayers(i,IrrLd,labsLd); end for;
"i-eigenspace";
for i in IndecomposableSummands(TensorProduct(N1,N2)) do DescribeLayers(i,IrrLd,labsLd); end for;

// Now compute the radicals for the 39 case.

"Radicals for 39 case. Only need 3 and 35 here, as 3^* is image of 3 under graph, and 39 is the whole radical given before.";

B1a:=JacobsonRadical(A1); B1a:=RemoveFromTop(B1a,Irr,Irr,[3,4,5,6,7,8,9,10,11]);
DescribeLayers(Dual(A1/B1a),Irr,labs);

B4a:=JacobsonRadical(A4); B4a:=RemoveFromTop(B4a,Irr,Irr,[3,4,5,6,7,8,9,10,11]);
DescribeLayers(Dual(A4/B4a),Irr,labs);

// And the 35 case

"Radicals for 35 case.";
C1a:=JacobsonRadical(A1); C1a:=RemoveFromTop(C1a,Irr,Irr,[3,4,5,6,7,8,9,12,13]);
DescribeLayers(Dual(A1/C1a),Irr,labs);

C2a:=JacobsonRadical(A2); C2a:=RemoveFromTop(C2a,Irr,Irr,[1,2,3,4,5,8,9,12,13]);
DescribeLayers(Dual(A2/C2a),Irr,labs);

C3a:=JacobsonRadical(A3); C3a:=RemoveFromTop(C3a,Irr,Irr,[1,2,3,4,5,6,7,12,13]);
DescribeLayers(Dual(A3/C3a),Irr,labs);

C4a:=JacobsonRadical(A4); C4a:=RemoveFromTop(C4a,Irr,Irr,[1,2,3,4,5,6,7,8,9,12,13]);
DescribeLayers(Dual(A4/C4a),Irr,labs);

"And the submodule generated by 6*:";

C1b:=Dual(A1/C1a); C1b:=RemoveFromTop(C1b,Irr,Irr,[1,2,5,6,7,8,9,10,11,12,13]);
DescribeLayers(C1b,Irr,labs);

// Step 4:

"Now we look at Step 4.";


// Here are the \pm 1 eigenspaces.

"1-eigenspace always contains this:";
D1:=ProjectiveIndecomposableModule(IrrLd[3]);
for i in IndecomposableSummands(ExteriorSquare(D1)) do DescribeLayers(i,IrrLd,labsLd); end for;

D2a:=DirectSum([IrrLd[3],IrrLd[3]]);
D2b:=BuildLargestModule(IrrLd[3],[IrrLd[3]]);
"and either this";
for i in IndecomposableSummands(ExteriorSquare(D2a)) do DescribeLayers(i,IrrLd,labsLd); end for;
"or this";
for i in IndecomposableSummands(ExteriorSquare(D2b)) do DescribeLayers(i,IrrLd,labsLd); end for;

"-1-eigenspace is either this";
for i in IndecomposableSummands(TensorProduct(D1,D2a)) do DescribeLayers(i,IrrLd,labsLd); end for;
"or this";
for i in IndecomposableSummands(TensorProduct(D1,D2b)) do DescribeLayers(i,IrrLd,labsLd); end for;
"(They are the same.)";
// Now the half-spin

D31:=ProjectiveIndecomposableModule(IrrLd[2]);
D32:=BuildLargestModule(IrrLd[4],[IrrLd[2]]);

D41:=BuildLargestModule(IrrLd[3],[IrrLd[1]]);
D42:=Dual(D41);
D43:=DirectSum([IrrLd[3],IrrLd[1]]);

"Now the tensor product. The first part is";
for i in IndecomposableSummands(TensorProduct(D31,D41)) do DescribeLayers(i,IrrLd,labsLd); end for;

"The three options for the rest. Option 1:";
for i in IndecomposableSummands(TensorProduct(D32,D41)) do DescribeLayers(i,IrrLd,labsLd); end for;
"Option 2:";
for i in IndecomposableSummands(TensorProduct(D32,D42)) do DescribeLayers(i,IrrLd,labsLd); end for;
"Option 3:";
for i in IndecomposableSummands(TensorProduct(D32,D43)) do DescribeLayers(i,IrrLd,labsLd); end for;

"Test the statements about 8:";
E,rho:=Ext(S18,S8); T1:=MaximalExtension(S18,S8,E,rho);
not 1 in {Dimension(i):i in IndecomposableSummands(Restriction(T1,L))};

E,rho:=Ext(S39,S8); T2:=MaximalExtension(S39,S8,E,rho);
not 1 in {Dimension(i):i in IndecomposableSummands(Restriction(T2,L))};


"The smaller radicals, with 6* and 39 in the socle. 3 and 3* are as before.";

D6a:=JacobsonRadical(A6); D6a:=RemoveFromTop(D6a,Irr,Irr,[1,2,5,6,7,8,9,10,11]);
DescribeLayers(Dual(A6/D6a),Irr,labs);

D4a:=JacobsonRadical(A4); D4a:=RemoveFromTop(D4a,Irr,Irr,[1,2,5,6,7,8,9]);
DescribeLayers(Dual(A4/D4a),Irr,labs);

D5a:=JacobsonRadical(A5); D5a:=RemoveFromTop(D5a,Irr,Irr,[1,2,5,6,7,8,9,10,11]);
DescribeLayers(Dual(A5/D5a),Irr,labs);

"And with 6 and 35 in the socle:";

D1b:=JacobsonRadical(A1); D1b:=RemoveFromTop(D1b,Irr,Irr,[5,6,7,8,9,12,13]);
DescribeLayers(Dual(A1/D1b),Irr,labs);

"Dualize the next two:";
D6b:=JacobsonRadical(A6); D6b:=RemoveFromTop(D6b,Irr,Irr,[1,2,5,6,7,8,9,12,13]);
DescribeLayers(Dual(A6/D6b),Irr,labs);

D2b:=JacobsonRadical(A2); D2b:=RemoveFromTop(D2b,Irr,Irr,[1,2,5,8,9,12,13]);
DescribeLayers(Dual(A2/D2b),Irr,labs);

D3b:=JacobsonRadical(A3); D3b:=RemoveFromTop(D3b,Irr,Irr,[1,2,5,6,7,12,13]);
DescribeLayers(Dual(A3/D3b),Irr,labs);

D4b:=JacobsonRadical(A4); D4b:=RemoveFromTop(D4b,Irr,Irr,[1,2,5,6,7,8,9,12,13]);
DescribeLayers(Dual(A4/D4b),Irr,labs);

D1c:=Dual(A1/D1b);
D1c:=RemoveFromTop(D1c,Irr,Irr,[5,9,12,13]);
DescribeLayers(D1c,Irr,labs);

"Just 6 in the socle";

"This and the dual version needed";
D1d:=JacobsonRadical(A1); D1d:=RemoveFromTop(D1d,Irr,Irr,[5,6,7,8,9,10,11,12,13]);
DescribeLayers(Dual(A1/D1d),Irr,labs);

"Dualize the next two:";
D6d:=JacobsonRadical(A6); D6d:=RemoveFromTop(D6d,Irr,Irr,[1,2,5,6,7,8,9,10,11,12,13]);
DescribeLayers(Dual(A6/D6d),Irr,labs);

D2d:=JacobsonRadical(A2); D2d:=RemoveFromTop(D2d,Irr,Irr,[1,2,5,8,9,10,11,12,13]);
DescribeLayers(Dual(A2/D2d),Irr,labs);

"This and the dual version needed";
D3d:=JacobsonRadical(A3); D3d:=RemoveFromTop(D3d,Irr,Irr,[1,2,5,6,7,10,11,12,13]);
DescribeLayers(Dual(A3/D3d),Irr,labs);


// Step 5:

"1-eigenspace from Step 5";

E1:=DirectSum([IrrLd[1],IrrLd[3],BuildLargestModule(IrrLd[3],[IrrLd[3]])]);
for i in IndecomposableSummands(ExteriorSquare(E1)) do DescribeLayers(i,IrrLd,labsLd); end for;

// Step 6:

F1:=BuildLargestModule(IrrLd[3],[IrrLd[3]]);
F2:=DirectSum([IrrLd[i]:i in [1,3,3,3]]);

"1-eigenspace in Step 6 is";
for i in IndecomposableSummands(ExteriorSquare(F1)) do DescribeLayers(i,IrrLd,labsLd); end for;
for i in IndecomposableSummands(ExteriorSquare(F2)) do DescribeLayers(i,IrrLd,labsLd); end for;
F3:=BuildLargestModule(IrrLd[1],[IrrLd[3]]);
"and on the half-spin modules is";
for i in IndecomposableSummands(TensorProduct(F3,IrrLd[2])) do DescribeLayers(i,IrrLd,labsLd); end for;
for i in IndecomposableSummands(TensorProduct(F3,IrrLd[4])) do DescribeLayers(i,IrrLd,labsLd); end for;

E,rho:=Ext(S18,S8); F4:=Extension(S18,S8,E.1,rho);
E,rho:=Ext(S39,S8); F5:=Extension(S39,S8,E.1,rho);

"The restriction of 18/8 to L is";
for i in IndecomposableSummands(Restriction(F4,L)) do DescribeLayers(i,IrrL,labsL); end for;
"The restriction of 39/8 to L is";
for i in IndecomposableSummands(Restriction(F5,L)) do DescribeLayers(i,IrrL,labsL); end for;


// Step 7:

"Just the radical of P(35) to check:";

J4:=JacobsonRadical(A4); J4:=RemoveFromTop(J4,Irr,Irr,[1,2,3,4,5,6,7,8,9]);
DescribeLayers(Dual(A4/J4),Irr,labs);
