/* ****************** lines ********************* */

/* This MAGMA script is designed to find equations that characterize the coefficients 
of the 240 lines on the Del Pezzo surface of degree 1 given by 

	w^2 = x^6 + y^6 + z^3

in the weighted projective space P(1,1,2,3). This is a degree 2 cover of
P(1,1,2) ramified at x^6 + y^6 + z^3 = 0. Intersection theory shows that if
we plug in a quadratic form z = a*x^2 + b*x*y + c*y^2 into the equation above so
that the RHS becomes a perfect square c(x,y)^2 = (r*x^3 + s*x^2*y + t*x*y^2 + u*y^3)^2
then the curves z = a*x^2 + b*x*y + c*y^2, w = c(x,y) and z = a*x^2 + b*x*y + c*y^2,
w = -c(x,y) are exceptional curves on the Del Pezzo surface. In fact, all exceptional 
curves arise in this way. */

/* The monomial ordering we give for R below will be useful */

R<r,s,t,u,a,c,b> := PolynomialRing(RationalField(), 7);
Q<x,y,z,w> := PolynomialRing(R, 4);
M := MatrixRing(R, 7);

f := (r*x^3 + s*x^2*y + t*x*y^2 + u*y^3)^2;
C := [ MonomialCoefficient(f, x^i*y^j) : j in [0..6], i in [0..6] ];
m1 := M!C;

g := x^6 + y^6 + (a*x^2 + b*x*y + c*y^2)^3;
D := [ MonomialCoefficient(g, x^i*y^j) : j in [0..6], i in [0..6] ];
m2 := M!D;

/* E is the set of coefficients that must vanish in order to get w^2 = c(x,y)^2 */

E := { m1[i,j] - m2[i,j] : j in [1..7], i in [1..7]};
I := ideal< R | E>;

gb := GroebnerBasis(I);

/* The monomial ordering given above means that the last element of the Groebner
Basis of I is a polynomial only in b (we expect this from general theory of del
Pezzo surfaces). This gives us the possible values for b. */

bvalues := gb[#gb];
factb := Factorization(bvalues);
//print factb;

/* The ideal array J below takes each factor in factb in turn and tacks it on to
I; Groebner Bases are then computed which give equations for a and c in terms of b
(again, the monomial ordering has played a role here). */

J := [ ideal<R | factb[i][1]> : i in [1..#factb] ];
lines := [ GroebnerBasis(I + J[i]) : i in [1..#factb]];

/* Next, we print the families of equations that the coefficients b,c,a,u,t,s,r
must satisfy in order to get an exceptional curve. If you count the total number of
triplets we get for (a,b,c) we get 120. Each triplet gives rise to *two* exceptional
curves (corresponding to w = +q or -q) giving a total of 240 curves, as expected. */

for n in [1..#factb] do
print "Family number", n, "of curves is characterized by:";
lines[n];
end for;

/*
The output for this file is as follows:
Family number 1 of curves is characterized by:
[
    r^2 - a^3 - 1,
    r*t - 1/2*a^2*c^4 - 2*a^2*c,
    r*u,
    r*a + 1/2*t*a^2*c^2,
    r*c^3 + r,
    s + 1/2*u*a*c^2,
    t^2 - a*c^5 - 4*a*c^2,
    t*u,
    t*a^3 + 4*t,
    t*c^3 + t,
    u^2 - c^3 - 1,
    u*a^3 + u,
    u*c^4 + 4*u*c,
    a^4 - a*c^6 - 4*a*c^3 + a,
    a^3*c^3 + a^3 + c^3 + 1,
    c^7 + 5*c^4 + 4*c,
    b
]
Family number 2 of curves is characterized by:
[
    r - u,
    s,
    t,
    u^2 - 1,
    a,
    c,
    b^3 - 2
]
Family number 3 of curves is characterized by:
[
    r + u,
    s,
    t,
    u^2 - 1,
    a,
    c,
    b^3 + 2
]
Family number 4 of curves is characterized by:
[
    r + u,
    s + 5/33*u*c*b^2 - 19/11*u*c*b + 13/11*u*c,
    t + 2/33*u*c^2*b^2 - 13/22*u*c^2*b - 8/11*u*c^2,
    u^2 + 24/11*b^2 - 36/11*b + 9/11,
    a + 5/22*c^2*b^2 - 57/22*c^2*b + 14/11*c^2,
    c^3 + 24/11*b^2 - 36/11*b + 20/11,
    b^3 - 12*b^2 + 12*b - 6
]
Family number 5 of curves is characterized by:
[
    r - u,
    s + 5/33*u*c*b^2 + 19/11*u*c*b + 13/11*u*c,
    t - 2/33*u*c^2*b^2 - 13/22*u*c^2*b + 8/11*u*c^2,
    u^2 + 24/11*b^2 + 36/11*b + 9/11,
    a + 5/22*c^2*b^2 + 57/22*c^2*b + 14/11*c^2,
    c^3 + 24/11*b^2 + 36/11*b + 20/11,
    b^3 + 12*b^2 + 12*b + 6
]
Family number 6 of curves is characterized by:
[
    r - 1/54*u*c^3*b^3 + 5/54*u*b^3,
    s - 1/24*u*c^4*b^2 + 1/6*u*c*b^2,
    t - 1/18*u*c^5*b + 5/18*u*c^2*b,
    u^2 - c^3 - 1,
    a - 1/48*c^5*b^2 + 1/12*c^2*b^2,
    c^6 - 4*c^3 - 32,
    b^6 + 108
]
Family number 7 of curves is characterized by:
[
    r - u,
    s + 29/3960*u*c*b^5 - 16/165*u*c*b^4 + 16/15*u*c*b^3 - 453/220*u*c*b^2 
    + 32/55*u*c*b - 32/55*u*c, t - 23/990*u*c^2*b^5 + 263/990*u*c^2*b^4 
    - 161/55*u*c^2*b^3 + 23/15*u*c^2*b^2 - 701/330*u*c^2*b + 46/55*u*c^2,
    u^2 + 1/55*b^5 - 1/5*b^4 + 111/55*b^3 - 6/55*b^2 + 6/55*b - 81/55,
    a - 17/3960*c^2*b^5 + 13/440*c^2*b^4 - 13/40*c^2*b^3 - 1373/660*c^2*b^2 
    - 39/220*c^2*b + 39/220*c^2, c^3 + 1/55*b^5 - 1/5*b^4 + 111/55*b^3 - 6/55*b^2 
    + 6/55*b - 26/55, b^6 - 12*b^5 + 132*b^4 - 132*b^3 + 72*b^2 - 72*b + 36
]
Family number 8 of curves is characterized by:
[
    r + u,
    s - 29/3960*u*c*b^5 - 16/165*u*c*b^4 - 16/15*u*c*b^3 - 453/220*u*c*b^2 
    - 32/55*u*c*b - 32/55*u*c, t - 23/990*u*c^2*b^5 - 263/990*u*c^2*b^4 
    - 161/55*u*c^2*b^3 - 23/15*u*c^2*b^2 - 701/330*u*c^2*b - 46/55*u*c^2,
    u^2 - 1/55*b^5 - 1/5*b^4 - 111/55*b^3 - 6/55*b^2 - 6/55*b - 81/55,
    a + 17/3960*c^2*b^5 + 13/440*c^2*b^4 + 13/40*c^2*b^3 - 1373/660*c^2*b^2 
    + 39/220*c^2*b + 39/220*c^2, c^3 - 1/55*b^5 - 1/5*b^4 - 111/55*b^3 
    - 6/55*b^2 - 6/55*b - 26/55, b^6 + 12*b^5 + 132*b^4 + 132*b^3 + 72*b^2 
    + 72*b + 36
]
*/