A<x,y> := PolynomialRing(GF(2),2);
P,homogenize := Homogenization(A);
print("f := The polynomial from math.mit.edu/~drew/FFFc31.txt reduced mod 2:");
f := (x+1)^3*x^4*y^13+(x+1)^2*x^5*y^12+(x+1)*(x^4+x+1)*x^4*y^11+x^9*y^10+(x+1)*(x^10+x^7+1)*y^9+(x^8+x^5+x^3+x+1)*x^3*y^8+(x+1)*(x^2+x+1)^2*(x^8+x^6+x^5+x^2+1)*y^7+(x+1)^6*x^4*(x^3+x+1)*y^6+(x^4+x^3+1)*(x+1)^3*(x^3+x+1)^2*y^5+(x+1)^2*(x^9+x^7+x^5+x+1)*x^2*y^4+(x+1)^9*y^3+(x^5+x^3+x^2+x+1)*x^4*y^2+(x+1)*x^3*y+x^2;

f := homogenize(f);
XF2 := Scheme(ProjectiveSpace(P),f);
FF := FunctionField(XF2);
AFF := AlgorithmicFunctionField(FF);
plc1 := Places(AFF,1);
divgrp := DivisorGroup(AFF);
div1 := [divgrp ! i : i in plc1];
cuspsum := &+ div1;
load "function_degrees.m";

print("The number of places of degrees 1-6:");
[#Places(AFF,i) : i in [1..6]];
// [ 15, 0, 0, 0, 3, 15 ]

// Our goal is to show that X1(31) has no non-constant functions of degree <12
// over F2 and hence over Q.

// Say f is a function of degree <= 11, since f^(-1)({0,1,infinity}) contains
// all 15 rational points, by the pigeon hole principle we may assume that
// f^(-1)({infinity} contains at least 5 distinct rational points, and so
// the remaining polar-part of f has degree at most 6.

// This contains one place of each diamond-orbit of rational places. In
// this case there is only one such orbit.
orbs := [plc1[1]];




// Degree >1 places: [5]
// Rat-places: [2] (only multiplicities >1 are listed).
s := {(cuspsum + P1 + 1*Q1) : P1 in Places(AFF,5), Q1 in orbs};
print "The number of RR-computations to be done for this case is:",
#s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [6]
// Rat-places: [] (only multiplicities >1 are listed).
s := {(cuspsum + P1) : P1 in Places(AFF,6)};
print "The number of RR-computations to be done for this case is:",
#s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: []
// Rat-places: [2, 2, 2, 2, 3] (only multiplicities >1 are listed).
s := {(cuspsum + 1*Q1+1*Q2+1*Q3+1*Q4+2*Q5) : Q1 in plc1, Q2 in plc1, Q3 in plc1, Q4 in plc1, Q5 in orbs};
print "The number of RR-computations to be done for this case is:",
#s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

