/* ****************** GaloisAction ********************* */

/* This script computes the action of the Galois Group of the splitting field 
of the 240 lines in the 'generic' case. It relies on some work that I did by hand. 
A basis for the Picard Group of the diagonal del Pezzo surface of degree 1 
consists of the lines 25,147,29,54,185,111,117,123 and the hyperplane 
"23 + 25 + 147", where the numbers stand for the corresponding row in the 
IntersectionMatrix.  The generic Galois Group has size 216 and is generated 
by <sigma,tau,phi1,phi2>. See the paper for details. I calculated it where the 
generators for Pic X above go under the generic Galois Group, by using my 
list of the 240 lines. For example:

sigma: [25,147,29,54,185,111,117,123,23] |--> [25,147,35,71,178,239,107,5,24].

What this file does is find the image lines as linear combinations of the basis 
lines of Pic X. For example let 25 = e1, 29 = e2, ... , 23 + 25 + 147 = l, where 
e1,...,e8,l is the standard basis of Z^9 = Pic X. Then we find, for example, that 
35 = -e2 - e3 -e4 -e5 -e6 + 2*l. In this way we express the action of the 
generator sigma: Pic X -> Pic X as A : Z^9 -> Z^9, where A is the 9x9 matrix 
SigmaAction.

The point is that this gives sigma as an element of W(E_8). This is the group 
of permutations of the set of 240 lines that preserves intersection products and 
fixes the canonical divisor. Recall the Galois group in question injects 
into W(E_8). All we have done is make this injection explicit.

Once we have the generators for the Galois group as elements of 
W(E_8) \subset GL(Z,9), we can see what group they generate and compute 
group cohomology. */

MatS := RMatrixSpace(Integers(),9,240);

/* Below we compute the 9x240 matrix whose rows are the generators for Pic X. */

BigList := [];
TheLines := [25,147,29,54,185,111,117,123];
for i in TheLines do
	for j in [1..240] do
		BigList := Append(BigList,IntersectionMatrix[i][j]);
	end for;
end for;
SpecialRow := IntersectionMatrix[23] + IntersectionMatrix[25] 
                           + IntersectionMatrix[147];
for i in [1..240] do
	BigList := Append(BigList,SpecialRow[i]);
end for;
MatrixBasis := MatS!BigList;

/* Now we compute the 9x240 matrices whose rows are the image lines under 
the action of a generator of the Galois Group, namely sigma,tau,phi1,phi2,phi3. */

SigmaLines := [25, 147, 35, 71, 178, 239, 107, 5];
SigmaList := [];
for i in SigmaLines do
        for j in [1..240] do
                SigmaList := Append(SigmaList,IntersectionMatrix[i][j]);
        end for;
end for;
SpecialRowSigma := IntersectionMatrix[24] + IntersectionMatrix[25] 
                                      + IntersectionMatrix[147];
for i in [1..240] do
        SigmaList := Append(SigmaList,SpecialRowSigma[i]);
end for;
SigmaMatrix := MatS!SigmaList;

TauLines := [25, 146, 150, 83, 198, 236, 230, 2];
TauList := [];
for i in TauLines do
        for j in [1..240] do
                TauList := Append(TauList,IntersectionMatrix[i][j]);
        end for;
end for;
SpecialRowTau := IntersectionMatrix[24] + IntersectionMatrix[25] 
                               + IntersectionMatrix[146];
for i in [1..240] do
        TauList := Append(TauList,SpecialRowTau[i]);
end for;
TauMatrix := MatS!TauList;

Phi1Lines := [27, 146, 148, 186, 77, 207, 141, 96];
Phi1List := [];
for i in Phi1Lines do
        for j in [1..240] do
                Phi1List := Append(Phi1List,IntersectionMatrix[i][j]);
        end for;
end for;
SpecialRowPhi1 := IntersectionMatrix[131] + IntersectionMatrix[27] 
                                + IntersectionMatrix[146];
for i in [1..240] do
        Phi1List := Append(Phi1List,SpecialRowPhi1[i]);
end for;
Phi1Matrix := MatS!Phi1List;

Phi2Lines := [145, 27, 155, 65, 196, 86, 20, 215];
Phi2List := [];
for i in Phi2Lines do
        for j in [1..240] do
                Phi2List := Append(Phi2List,IntersectionMatrix[i][j]);
        end for;
end for;
SpecialRowPhi2 := IntersectionMatrix[11] + IntersectionMatrix[145] 
                                + IntersectionMatrix[27];
for i in [1..240] do
        Phi2List := Append(Phi2List,SpecialRowPhi2[i]);
end for;
Phi2Matrix := MatS!Phi2List;

/* Finally, we compute the action by solving the system 
A*MatrixBasis = [Generator]Matrix. A is a 9x9 matrix in W(E_8) \subset GL(Z,9). */

SigmaAction := Solution(MatrixBasis,SigmaMatrix);
TauAction := Solution(MatrixBasis,TauMatrix);
Phi1Action := Solution(MatrixBasis,Phi1Matrix);
Phi2Action := Solution(MatrixBasis,Phi2Matrix);

/* Here we compute the representation of a line as a vector in Z^9 under 
the basis in MatrixBasis */

Line := [];
LineSpace := RMatrixSpace(Integers(),1,240);
for i in [1..240] do
	// Convert a line in IntersectionMatrix into a 1x240 matrix
	Linei := LineSpace!Eltseq(IntersectionMatrix[i]);
	IndividualLine := Solution(MatrixBasis,Linei);
	Line := Append(Line,IndividualLine);	
end for;
// print #Line;

/* The following is a small collection of self-explanatory functions that are 
useful to do some experimentation. */

WhichLines := function(linesInQuestion,multiplier)
	result := [];
	for j in linesInQuestion do
		for i in [1..240] do
			if Line[i] eq Line[j]*multiplier then
				result := Append(result,i);
			end if;
		end for;
	end for;
	return result;
end function;

WhichConjugates := function(i,letter)
	result := [];
	if letter eq z then
	for j in [1..240] do
		if LINES[j][1] eq LINES[i][1] then
			result := Append(result,j);
		end if;
	end for;
	else
        for j in [1..240] do
                if LINES[j][2] eq LINES[i][2] then
                	result := Append(result,j);
		end if;
        end for;
	end if;
	return result;
end function;

AddLines := function(listOfLines)
	sum := &+[Line[i] : i in listOfLines];
	return sum;
end function;