(* This Mathematica notebook checks that h^0(2K-5L)=0 on a particular degeneration of E6 covers *)

(* We first define lines as vectors in the Minkowski space I^{6,1} *)
line=Table[0,{i,27},{j,7}];

s=1;

For[i=1,i≤6,i++, line[[s,i]]=1;s++]

For[i=1,i≤6,i++, 
line[[s,7]]=2;
For[k=1,k≤6,k++, If[k≠i,line[[s,k]]=-1]];
s++
]

For[i=1,i≤6,i++, 
For[j=i+1,j≤6,j++,
line[[s,7]]=1; line[[s,i]]=-1; line[[s,j]]=-1; s++]]

line//MatrixForm

(* Define roots, as vectors in I^{6,1} *)
root=Table[0,{i,36},{j,7}];

r=1;

For[i=1,i≤6,i++, 
For[j=i+1,j≤6,j++,
root[[r,i]]=1;root[[r,j]]=-1; r++]]

For[i=1,i≤6,i++, 
For[j=i+1,j≤6,j++,
For[k=j+1,k≤6,k++,
root[[r,7]]=1;root[[r,i]]=-1;root[[r,j]]=-1; root[[r,k]]=-1;r++]]]

root[[36,7]]=2; For[i=1,i≤6,i++, root[[36,i]]=-1]

(* Check all 36 roots *)
root//MatrixForm

Dimensions[root]

(* Define Minkowski product in I^{6,1} *)

mdot[x_,y_]:=x[[7]]*y[[7]]-x[[1]]*y[[1]]-x[[2]]*y[[2]]-x[[3]]*y[[3]]-x[[4]]*y[[4]]-x[[5]]*y[[5]]-x[[6]]*y[[6]]

(* Prods=Table[0,{i,36},{j,27}]; *)

(* For[n=1,n≤36,n++, 
For[m=1,m≤27,m++,
 Prods[[n,m]]=mdot[ root[[n]],line[[m]] ] ]] *)

(* Prods//MatrixForm *)

twroot=Table[0,{i,12},{j,7}] ;
(* 12 roots of E6, the first 6 roots chosen to form a basis *)

twroot[[1]]=root[[21]];
twroot[[2]]=root[[1]];
twroot[[3]]=root[[6]];
twroot[[4]]=root[[10]];
twroot[[5]]=root[[13]];
twroot[[6]]=root[[15]];

(* Next 6 roots *)

twroot[[7]]=root[[5]];
twroot[[8]]=root[[35]];
twroot[[9]]=root[[16]];
twroot[[10]]=root[[33]];
twroot[[11]]=root[[26]];
twroot[[12]]=root[[25]];

For[i=1,i≤12,i++, Print[twroot[[i]]] ]

(* mh is a matrix computing H_1(Gamma,k) = H^0(C, k), s=sheet, e=edge *)
(* in plain terms, this is the matrix for the directed graph Gamma. 27 vertices = 27 sheets *)

mh=Table[0, {s,27}, {e,72}]; 
e=0; (* will increase e 6 times for each of the roots *)
newline=Table[0,{k,7}]; (* will be used to identify a reflected line *)For[i=1,i≤12,i++, (* 12 ramification points, 12 twroots *)
For[s=1,s≤27,s++,
If[ mdot[twroot[[i]],line[[s]]]==1,
{e++;
mh[[s,e]]=1;
(* now find the reflected line line[[s]]+twroot[[i]] *)  
newline=line[[s]]+twroot[[i]] ;
(* find the opposite line and modify mh accordingly *)
For[s2=1,s2≤27,s2++,
If[newline==line[[s2]], mh[[s2,e]]=-1,"" ];
]
}, ""
]
]
]
(* mh//MatrixForm *)
Print["h^0(C,K)=",MatrixRank[NullSpace[mh]]]

(* Compute the number of points on each sheet. They all should be ≥4 for computing h^0(2K-5L) *)
Clear[ns];ns=Table[0,{s,27}];
For[s=1,s≤27,s++, 
For[e=1,e≤72,e++, 
ns[[s]]+=mh[[s,e]]^2 ]]
Print[ns]

(* Define points on P^1 below *)

q=Table[0,{pt,12}];

For[pt=1,pt≤12,pt++, q[[pt]]=pt^2]

q

(* Degrees of polynomials *)
degs=Table[0,{s,27}];

For[s=1,s≤27,s++, degs[[s]]=2(ns[[s]]-2) ]

Print[degs]

numofunknowns=0;

For[s=1,s≤27,s++, numofunknowns+=(degs[[s]]+1) ]

numofunknowns

numofequations=72
numofunknowns-numofequations

(* this is the expected h^0(2K)=3(g-1)=3.45 *)

(* Unknowns are x[j]. Matrix is m[e,j] *)

m=Table[0,{e,72},{j,numofunknowns}];

(* Now we are going to construct the system of linear equations with numofunknowns and numofequations. For each of 27 sheets we create variables and compute the coefficient of e-th equation in x[j], for all 1≤e≤72 equations *)

j=0;(* we will start with variable j=1 below *)

For[s=1,s≤27,s++,
For[d=0,d≤degs[[s]],d++,
j++; (* go to the next variable *)
e=0;
For[pt=1,pt≤12,pt++,
 denom=1;
For[pt2=1,pt2≤12,pt2++,
If[pt2≠pt,denom*=(pt-pt2)^2]
]
For[k=1,k≤6,k++,
e++;
m[[e,j]]=mh[[s,e]]q[[pt]]^d/denom;
]
]
]
]

Dimensions[m]

(* So what is h^0(2K)? *)

numofunknowns-MatrixRank[m]

(* Now let us repeat these computations but set the degree of each polynomial to be 5 less, to compute h^0(2K-5L) *)

degs=Table[0,{s,27}];

For[s=1,s≤27,s++, degs[[s]]=Max[-1,2(ns[[s]]-2)-5] ]

Print[degs]

numofunknowns=0;

For[s=1,s≤27,s++, numofunknowns+=(degs[[s]]+1) ]

numofunknowns

numofequations=72

(* This is the expected h^0(2K-5L): *)

numofunknowns-numofequations

m=Table[0,{e,72},{j,numofunknowns}];

j=0;(* we will start with variable j=1 below *)

For[s=1,s≤27,s++,
For[d=0,d≤degs[[s]],d++,
j++; (* go to the next variable *)
e=0;
For[pt=1,pt≤12,pt++,
 denom=1;
For[pt2=1,pt2≤12,pt2++,
If[pt2≠pt,denom*=(pt-pt2)^2]
]
For[k=1,k≤6,k++,
e++;
m[[e,j]]=mh[[s,e]]q[[pt]]^d/denom;
]
]
]
]

(* So what is h^0(2K-5L)? *)
numofunknowns-MatrixRank[m]

(* We are done with 2K-5L *)

(* Checking if a multiple of 3K-10L is zero *)

matrix=mh.Transpose[mh];

matrix//MatrixForm

MatrixRank[matrix]

range2=Range[26]

matrix2=matrix[[range2,range2]];

Det[matrix2]

range3=Flatten[Join[Range[25],{27}]]

matrix3=matrix[[range3,range3]];

Det[matrix3]

FactorInteger[41669757357466680]

vector=Table[0,{i,27}]

vector2=Table[0,{i,26}]

vector3=Table[0,{i,26}]

For[i=1,i≤27,i++, vector[[i]]=3ns[[i]]-16]

vector

vector2=vector[[range2]]

vector3=vector[[range3]]

41669757357466680

answer2=Inverse[matrix2].vector2

answer3=Inverse[matrix3].vector3

answer2-answer3

(* huge denominators => 3K-10L is not an n-torsion for n≤1000000000 at least *)