A<x,y> := PolynomialRing(GF(2),2);
P,homogenize := Homogenization(A);
print("f := The polynomial from math.mit.edu/~drew/FFFc43.txt reduced mod 2");
f := (y^7+y^6+y^5+y^4+y^2+y+1)*(y^10+y^9+y^8+y^6+y^4+y^3+1)*y*x^11+(y^21+y^20+y^17+y^16+y^15+y^13+y^9+y^8+y^7+y^6+y^2+y+1)*(y+1)^2*y*x^9+(y^2+y+1)^5*(y+1)^9*y*x^6+(y^2+y+1)*(y+1)^8*(y^5+y^4+y^3+y+1)*x^3+(y^2+y+1)*(y+1)^9*y^5*x^2+(y+1)^3*y^7*(y^4+y+1)*x^23+(y^2+y+1)*y^6*(y^8+y^6+y^5+y+1)*x^21+(y^9+y^8+y^7+y^2+1)*(y+1)^8*y^5*x^15+(y^17+y^15+y^14+y^13+y^10+y^5+y^4+y^3+y^2+y+1)*y^2*(y^5+y^4+y^3+y+1)*x^13+(y+1)^3*(y^5+y^4+y^3+y^2+1)^2*y^4*x^18+x^19*y^6+(y^2+y+1)*(y+1)^8*y^2*(y^7+y^6+y^5+y^3+y^2+y+1)*x^5+(y^2+y+1)*(y+1)^9*y*(y^8+y^7+y^6+y^3+y^2+y+1)*x^4+(y^2+y+1)*(y+1)^3*y^6*(y^3+y+1)*x^22+(y^7+y^6+y^5+y^2+1)*(y+1)*y^5*(y^3+y+1)*x^20+(y^2+y+1)*(y+1)^3*(y^9+y^7+y^4+y^2+1)*y^4*x^17+(y+1)^6*(y^5+y^4+y^3+y^2+1)*y^3*(y^5+y^4+y^3+y+1)*x^16+(y+1)^10*y^6*x+(y+1)*y^8*x^26+(y+1)^2*y^8*x^25+(y+1)^4*y^7*x^24+(y+1)^11*y^4+(y^2+y+1)*(y+1)*y*(y^13+y^10+y^7+y^6+1)*(y^3+y+1)*x^10+(y^2+y+1)^3*(y^8+y^7+y^5+y^4+1)*(y+1)*y*(y^8+y^7+y^6+y^5+y^2+y+1)*x^12+(y+1)^8*y*(y^6+y^4+y^3+y+1)*(y^4+y+1)*x^7+(y+1)^3*(y^13+y^12+y^7+y^6+y^4+y+1)*y*(y^7+y+1)*x^8+(y^9+y^4+1)*(y+1)^5*(y^3+y^2+1)*y^2*(y^3+y+1)*x^14 ;
f := homogenize(f);
XF2 := Scheme(ProjectiveSpace(P),f);
FF := FunctionField(XF2);
AFF := AlgorithmicFunctionField(FF);
plc1 := Places(AFF,1);
cuspsum := &+ plc1;

function FunctionDegrees(divisor)
    constantField := ConstantField(FunctionField(divisor));
    space,map := RiemannRochSpace(divisor);
    return [Degree(map(i)) : i in space | map(i) notin constantField];
end function;
function Run(s)
   return {Sort(FunctionDegrees(D)) : D in s};
end function;

print("This file will show that X1(43)(F2) has no functions of degree <= 16");
print("so the F2-gonality and hence the Q-gonality of X1(43) is at least 17");
print("The number of places of X1(43)(F2) of degrees 1..9 is:");
[#Places(AFF,i) : i in [1..9]];
// [ 21, 0, 0, 0, 0, 0, 6, 42, 105 ]

// Say f is a function of degree <= 16, since f^(-1)({0,1,infinity}) contains
// all 21 rational points, by the pigeon hole principle we may assume that
// f^(-1)({infinity} contains at least 7 distinct rational points, and so
// the remaining polar-part of f has degree at most 9.
// There are no places of degrees 2-6, so the polar-part of f must consist
// of rational places and at most one degree >1 place (of degree 9, 8, or 7).

// Degree >1 places: [9]
// Rat-places: [] (only multiplicities >1 are listed).
Run({ (cuspsum + P1) : P1 in Places(AFF,9) });

// Degree >1 places: [8]
// Rat-places: [2] (only multiplicities >1 are listed).
Run({ (cuspsum + P1 + plc1[1]) : P1 in Places(AFF,8) });

// Degree >1 places: [7]
// Rat-places: [2, 2] (only multiplicities >1 are listed).
Run({ (2*cuspsum + plc1[1] + P1) : P1 in Places(AFF,7) });

// In the remainder of this file, we may assume that all poles of f
// are rational places. So we partition the deg(f)=16 as [16], [15,1], ...
// The partitions where all multiplicities are <= 3 are covered by:
Run({ 3*cuspsum - 4*plc1[1] });

// The partitions that have at most two multiplicities > 1 are covered by:
Run({ cuspsum + 4*P1 + 8*plc1[1] : P1 in plc1 });

// Partitions with one multiplicity >2 but more than two multiplicities > 1 are covered by:
// Run({ 2*cuspsum + 6*plc1[1] });
// We can skip this because it is also covered by the next case:

// Partitions with two multiplicity >2 plus 1 or 2 multiplicity=2 are covered by:
Run({ 2*cuspsum + 5*plc1[1] + 3*P1 : P1 in plc1 });

// Partitions not yet covered with 3 multiplicities > 1 are covered by:
Run({ 2*cuspsum + 4 * plc1[1] + 2 * (&+PQ)  : PQ in Subsets(SequenceToSet(plc1[2..21]),2) });
// and
Run({ cuspsum + 3 * plc1[1] + 2 * (&+plc1[2..11] + P) : P in plc1[12..21]  });
// and
Run({ cuspsum + 3 * plc1[1] + 2 * (&+plc1[12..21] + P) : P in plc1[2..11]  });

