A<x,y> := PolynomialRing(GF(3),2);
P,homogenize := Homogenization(A);
print("f := The polynomial from math.mit.edu/~drew/FFFc32.txt");
f := x^11*y^5 - 2*x^11*y^4 + 2*x^11*y^3 - 5*x^10*y^6 + 7*x^10*y^5 - 6*x^10*y^4 - 2*x^10*y^3 + 10*x^9*y^7 - 5*x^9*y^6 + 3*x^9*y^5 + 5*x^9*y^4 + 6*x^9*y^3 - 4*x^9*y^2 - 10*x^8*y^8 - 10*x^8*y^7 + 5*x^8*y^6 - x^8*y^5 - 14*x^8*y^4 + 6*x^8*y^3 + 4*x^8*y^2 + 5*x^7*y^9 + 20*x^7*y^8 - 5*x^7*y^6 + 5*x^7*y^4 - 7*x^7*y^3 - 6*x^7*y^2 + 3*x^7*y - x^6*y^10 - 13*x^6*y^9 - 12*x^6*y^8 + 20*x^6*y^6 - 4*x^6*y^5 + 3*x^6*y^4 + 3*x^6*y^3 + x^6*y^2 - 3*x^6*y + 3*x^5*y^10 + 11*x^5*y^9 + 7*x^5*y^8 - 10*x^5*y^7 - 15*x^5*y^6 - 13*x^5*y^5 + 29*x^5*y^4 - 20*x^5*y^3 + 9*x^5*y^2 + x^5*y - x^5 - 3*x^4*y^10 - 5*x^4*y^9 - 6*x^4*y^8 + 14*x^4*y^7 + 25*x^4*y^6 - 33*x^4*y^5 + 16*x^4*y^4 - 12*x^4*y^3 + 3*x^4*y^2 + x^4*y + x^3*y^10 + 4*x^3*y^9 - 12*x^3*y^7 - 2*x^3*y^6 + 7*x^3*y^5 + 8*x^3*y^4 - 4*x^3*y^3 - 3*x^3*y^2 + x^3*y - 2*x^2*y^9 + 8*x^2*y^7 - 7*x^2*y^6 + 9*x^2*y^5 - 24*x^2*y^4 + 24*x^2*y^3 - 9*x^2*y^2 + x^2*y + x*y^8 - 11*x*y^6 + 25*x*y^5 - 25*x*y^4 + 14*x*y^3 - 5*x*y^2 + x*y -  y^6 + 5*y^5 - 10*y^4 + 10*y^3 - 5*y^2 + y;
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-4 is:");
[#Places(AFF,i) : i in [1..4]];     

print("");
print("12/4=3 so to show gon_{F_3} > 7 it suffices to look at divisors");
print("of the form cuspsum + D with deg D = 4.");
print("");

// It takes time to calculate the degree of a function, we can save some time
// by not recalculating the degrees of functions in RiemannRochSpace(cuspsum) everytime.
// time RiemannRochSpace(cuspsum);
// time FunctionDegrees(cuspsum);
print("Degrees of non-constant functions in RiemannRochSpace(cuspsum) are:");
FunctionDegrees(cuspsum);
print("");

print("type(D) = (4), (3,1), (2,2), (2,1,1):");
Min(&cat[FunctionDegrees(cuspsum+2*p+q+r) : p,q,r in div1 | Dimension(RiemannRochSpace(cuspsum+2*p+q+r)) gt 2]);
print("");
print("type(D) = (1,1,1,1) not needed because a function in this set and not");
print("in one of the previous ones would have to have poles of 2 at 4 distinct cusps");
print("and hence of degree 8.");
print("");
print("type(D) = ((2,1),(1,2)) and ((2,1),(1,1),(1,1)):");
Min(&cat[FunctionDegrees(cuspsum+p+q+r) : p in Places(AFF,2), q,r in div1 | Dimension(RiemannRochSpace(cuspsum+p+q+r)) gt 2]);

print("type(D) = ((2,1),(2,1)):");
&cat[FunctionDegrees(cuspsum+p+q) : p,q in Places(AFF,2) | Dimension(RiemannRochSpace(cuspsum+p+q)) gt 2];

print("type(D) = ((3,1),(1,1)):");
&cat[FunctionDegrees(cuspsum+p+q) : p in Places(AFF,3), q in div1 | Dimension(RiemannRochSpace(cuspsum+p+q)) gt 2];

print("type(D) = ((4,1)):");
&cat[FunctionDegrees(cuspsum+p) : p in Places(AFF,4) | Dimension(RiemannRochSpace(cuspsum+p)) gt 2];
