G:=SL(2,4);
G_list:=[g: g in G]; 
Q5<zeta_5>:=CyclotomicField(5);
K<nu>:=sub<Q5| zeta_5^2+zeta_5^3>;
Z_K:=MaximalOrder(K);
Z_K_2:=quo<Z_K|4>;

CT:=CharacterTable(G);     

G_FP,phi := FPGroup(G);   

G_perm,psi2 := PermutationGroup(G_FP);   

FactorNumberLists := [<ElementToSequence(x@@psi2),x> : x in G_perm];  

FactorNumberListsShort := [];   
OG1 := Order(G.1);   
OG3 := Order(G.2);
   
for k in [1..#G] do   
 if k mod 100 eq 0 then print "spy k =", k; end if;   
 fnl := FactorNumberLists[k][1];   
 i := 1;   
 while i le #fnl do   
  simplification := false;   
  if i+OG1-1 lt #fnl and SequenceToSet(fnl[i..i+OG1-1]) in [{-1},{1}] then   
   simplification := true;   
   for k in [i..i+OG1-1] do   
    Remove(~fnl,i); // sic, dann werden Eintraege in [i..i+OG1-1] der urspruenglichen Liste entfernt   
   end for;   
  end if;   
  if i+OG3-1 lt #fnl and SequenceToSet(fnl[i..i+OG3-1]) in [{-2},{2}] then   
   for k in [i..i+OG3-1] do   
    Remove(~fnl,i); // sic, dann werden Eintraege in [i..i+OG3-1] der urspruenglichen Liste entfernt   
   end for;   
  end if;   
  if not simplification then   
   i +:= 1;   
  end if;   
  if simplification and i ge 2 then   
   i +:= -1;   
  end if;   
 end while;   
 FactorNumberListsShort cat:= [<fnl,FactorNumberLists[k][2]>];    
end for;   


rep:=function(FactorNumberListsShort,Mat1,Mat2,K) 
Mat1inv:=Mat1^-1; 
Mat2inv:=Mat2^-1; 
mat := map<{-2,-1,1,2} -> MatrixRing(K,NumberOfRows(Mat1)) | [<-2,Mat2inv>, <-1,Mat1inv>, <1,Mat1>, <2,Mat2>]>;   
matrices := [<x[2]@@psi2@phi,&*([MatrixRing(K,NumberOfRows(Mat1))!1] cat [mat(i) : i in x[1]])> : x in FactorNumberListsShort]; 
return map<G->MatrixRing(K,NumberOfRows(Mat1)) |matrices>; 
end function; 
conj:=function(x,S);
S_inv:=S^-1;
return S_inv*x*S;
end function;

number_of_non_zeroes := function(B); 
 return #[B[i,j] : i in [1..NumberOfRows(B)], j in [1..NumberOfColumns(B)] | B[i,j] ne 0]; 
end function; 

load "SL_2_4_repmat";
load "SL_2_4_conj";

eta1:=rep(FactorNumberListsShort,Mat1_1,Mat2_1,K);
eta2:=rep(FactorNumberListsShort,Mat1_2,Mat2_2,K);
eta3:=rep(FactorNumberListsShort,Mat1_3,Mat2_3,K);
eta4:=rep(FactorNumberListsShort,Mat1_4,Mat2_4,K);
eta5:=rep(FactorNumberListsShort,Mat1_5,Mat2_5,K);

print("Calculation of list B of  Wedderburnimages for each group element");

B:=[<1,
          RMatrixSpace(K,3,3)! conj(eta2(g),S2*P*(&*Conj_2_2)*PermutationMatrix(K,Sym3!(2,3)(1,2)(1,3))*D2),
		  RMatrixSpace(K,3,3)!conj(eta3(g),S3*P2*(&*Conj_3_2)*D3),
		  RMatrixSpace(K,4,4)!eta4(g),
		  RMatrixSpace(K,5,5)!conj(eta5(g),S5*P5*(&*Conj_5)*PermutationMatrix(K,Sym5!(4,3)(2,3)(5,3))*D1)>: g in G_list]; 
Bs:=[[ElementToSequence(B[i][j]) : j in [1..5]]: i in [1..#G_list]]; 
Bmat:=RMatrixSpace(K,60,60)![&cat Bs[i] : i in [1..#G_list]]; 
Bmat_inv:=Bmat^-1; 
RBmat_inv:=60*Bmat_inv;
print("Calculation of the congruences");

Z_K_Bmat_mod4:=RMatrixSpace(Z_K_2,60,60)!RBmat_inv;
E_mod4,H_4:=EchelonForm(Transpose(Z_K_Bmat_mod4));
E_mod4:=MatrixRing(K,60)!MatrixRing(Z_K,60)!Transpose(E_mod4);
H_4:=MatrixRing(K,60)!MatrixRing(Z_K,60)!Transpose(H_4);

print("type: E_4; to see the congruences modulo 4");
E_4:=[[<i,Z_K!E_mod4[i,s]>: i in [1..60]| E_mod4[i,s] ne 0]: s in [1..Rank(E_mod4)]];

