22 KiB
22 KiB
class superelliptic:
def __init__(self, f, m, p):
R.<x> = PolynomialRing(GF(p))
self.polynomial = R(f)
self.exponent = m
self.characteristic = p
def __repr__(self):
f = self.polynomial
m = self.exponent
p = self.characteristic
return 'Superelliptic curve with the equation y^' + str(m) + ' = ' + str(f)+' over finite field with ' + str(p) + ' elements.'
def genus(self):
r = self.polynomial.degree()
m = self.exponent
delta = GCD(r, m)
return 1/2*((r-1)*(m-1) - delta + 1)
def basis_holomorphic_differentials(self, j = 'all'):
f = self.polynomial
m = self.exponent
p = self.characteristic
r = f.degree()
delta = GCD(r, m)
basis = {}
if j == 'all':
k = 0
for j in range(1, m):
for i in range(1, r):
if (r*j - m*i >= delta):
basis[k] = superelliptic_form(C, x^(i-1)/y^j)
k = k+1
return basis
else:
k = 0
for i in range(1, r):
if (r*j - m*i >= delta):
basis[k] = superelliptic_form(C, x^(i-1)/y^j)
k = k+1
return basis
def basis_de_rham(self, j = 'all'):
f = self.polynomial
m = self.exponent
p = self.characteristic
r = f.degree()
delta = GCD(r, m)
#?????
basis = {}
if j == 'all':
for j in range(1, m):
holo = baza_holo(m, f, j, p)
for k in range(0, len(holo)):
baza[k] = holo[k]
def reduction(C, g):
p = C.characteristic
R.<x, y> = PolynomialRing(GF(p), 2)
RR = FractionField(R)
f = C.polynomial
r = f.degree()
m = C.exponent
g = RR(g)
g1 = g.numerator()
g2 = g.denominator()
R1.<x> = PolynomialRing(GF(p))
R2 = FractionField(R1)
R3.<y> = PolynomialRing(R2)
(A, B, C) = xgcd(R3(g2), R3(y^m - f))
g = R3(g1*B/A)
while(g.degree(R(y)) >= m):
d = g.degree(R(y))
G = coff(g, d)
i = floor(d/m)
g = g - G*y^d + f^i * y^(d%m) *G
return(R3(g))
def reduction_form(C, g):
p = C.characteristic
R.<x, y> = PolynomialRing(GF(p), 2)
RR = FractionField(R)
f = C.polynomial
r = f.degree()
m = C.exponent
g = reduction(C, g)
g1 = RR(0)
R1.<x> = PolynomialRing(GF(p))
R2 = FractionField(R1)
R3.<y> = PolynomialRing(R2)
g = R3(g)
for j in range(0, m):
if j==0:
G = coff(g, 0)
g1 += G
else:
G = coff(g, j)
g1 += RR(y^(j-m)*f*G)
return(g1)
class superelliptic_function:
def __init__(self, C, g):
R.<x, y> = PolynomialRing(GF(p), 2)
RR = FractionField(R)
f = C.polynomial
r = f.degree()
m = C.exponent
self.curve = C
g = reduction(C, g)
self.function = g
def __repr__(self):
return str(self.function)
def jth_component(self, j):
g = self.function
R.<x, y> = PolynomialRing(GF(p), 2)
g = R(g)
return g.coefficient(y^j)
def __add__(self, other):
C = self.curve
g1 = self.function
g2 = other.function
g = reduction(C, g1 + g2)
return superelliptic_function(C, g)
def __sub__(self, other):
C = self.curve
g1 = self.function
g2 = other.function
g = reduction(C, g1 - g2)
return superelliptic_function(C, g)
def __mul__(self, other):
C = self.curve
g1 = self.function
g2 = other.function
g = reduction(C, g1 * g2)
return superelliptic_function(C, g)
def __truediv__(self, other):
C = self.curve
g1 = self.function
g2 = other.function
g = reduction(C, g1 / g2)
return superelliptic_function(C, g)
def diffn(self):
C = self.curve
f = C.polynomial
m = C.exponent
g = self.function
A = g.derivative(x)
B = g.derivative(y)*f.derivative(x)/(m*y^(m-1))
return superelliptic_form(C, A+B)
class superelliptic_form:
def __init__(self, C, g):
R.<x, y> = PolynomialRing(GF(p), 2)
RR = FractionField(R)
g = RR(reduction_form(C, g))
self.form = g
self.curve = C
def __add__(self, other):
C = self.curve
g1 = self.form
g2 = other.form
g = reduction(C, g1 + g2)
return superelliptic_form(C, g)
def __sub__(self, other):
C = self.curve
g1 = self.form
g2 = other.form
g = reduction(C, g1 - g2)
return superelliptic_form(C, g)
def __repr__(self):
g = self.form
if len(str(g)) == 1:
return str(g) + ' dx'
return '('+str(g) + ') dx'
def jth_component(self, j):
g = self.form
R1.<x> = PolynomialRing(GF(p))
R2 = FractionField(R1)
R3.<y> = PolynomialRing(R2)
R4 = FractionField(R3)
R5.<y_inv> = PolynomialRing(R2)
g = R4(g)
g = g(y = 1/y_inv)
g = R5(g)
return coff(g, j)
def is_regular_on_U0(self):
C = self.curve
p = C.characteristic
m = C.exponent
R.<x> = PolynomialRing(GF(p))
for j in range(1, m):
if self.jth_component(j) not in R:
return 0
return 1
def is_regular_on_Uinfty(self):
C = self.curve
p = C.characteristic
m = C.exponent
f = C.polynomial
r = f.degree()
delta = GCD(m, r)
M = m/delta
R = r/delta
for j in range(1, m):
A = self.jth_component(j)
d = degree_of_rational_fctn(A)
if(-d*M + j*R -(M+1)<0):
return 0
return 1
class superelliptic_cech:
def __init__(self, omega, fct):
self.omega0 = omega
self.omega8 = omega - diffn(fct)
self.f = fct
def degree_of_rational_fctn(f):
R.<x> = PolynomialRing(GF(p))
RR = FractionField(R)
f = RR(f)
f1 = f.numerator()
f2 = f.denominator()
d1 = f1.degree()
d2 = f2.degree()
return(d1 - d2)
def coff(f, d):
lista = f.coefficients(sparse = false)
if len(lista) <= d:
return 0
return lista[d]
def cut(f, i):
coeff = f.coefficients(sparse = false)
return sum(x^(j-i-1) * coeff[j] for j in range(i+1, f.degree() + 1))
[0;31m---------------------------------------------------------------------------[0m [0;31mNameError[0m Traceback (most recent call last) [0;32m<ipython-input-87-fb238ae380ad>[0m in [0;36m<module>[0;34m()[0m [0;32m----> 1[0;31m [0;32mclass[0m [0msuperelliptic[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 2[0m [0;32mdef[0m [0m__init__[0m[0;34m([0m[0mself[0m[0;34m,[0m [0mf[0m[0;34m,[0m [0mm[0m[0;34m,[0m [0mp[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 3[0m [0mR[0m [0;34m=[0m [0mPolynomialRing[0m[0;34m([0m[0mGF[0m[0;34m([0m[0mp[0m[0;34m)[0m[0;34m,[0m [0mnames[0m[0;34m=[0m[0;34m([0m[0;34m'x'[0m[0;34m,[0m[0;34m)[0m[0;34m)[0m[0;34m;[0m [0;34m([0m[0mx[0m[0;34m,[0m[0;34m)[0m [0;34m=[0m [0mR[0m[0;34m.[0m[0m_first_ngens[0m[0;34m([0m[0;36m1[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [1;32m 4[0m [0mself[0m[0;34m.[0m[0mpolynomial[0m [0;34m=[0m [0mR[0m[0;34m([0m[0mf[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [1;32m 5[0m [0mself[0m[0;34m.[0m[0mexponent[0m [0;34m=[0m [0mm[0m[0;34m[0m[0;34m[0m[0m [0;32m<ipython-input-87-fb238ae380ad>[0m in [0;36msuperelliptic[0;34m()[0m [1;32m 53[0m [0;32mfor[0m [0mj[0m [0;32min[0m [0mrange[0m[0;34m([0m[0mInteger[0m[0;34m([0m[0;36m1[0m[0;34m)[0m[0;34m,[0m [0mm[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 54[0m [0mholo[0m [0;34m=[0m [0mbaza_holo[0m[0;34m([0m[0mm[0m[0;34m,[0m [0mf[0m[0;34m,[0m [0mj[0m[0;34m,[0m [0mp[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0;32m---> 55[0;31m [0;32mfor[0m [0mk[0m [0;32min[0m [0mrange[0m[0;34m([0m[0mInteger[0m[0;34m([0m[0;36m0[0m[0;34m)[0m[0;34m,[0m [0mlen[0m[0;34m([0m[0mholo[0m[0;34m)[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 56[0m [0mbaza[0m[0;34m[[0m[0mk[0m[0;34m][0m [0;34m=[0m [0mholo[0m[0;34m[[0m[0mk[0m[0;34m][0m[0;34m[0m[0;34m[0m[0m [1;32m 57[0m [0;34m[0m[0m [0;31mNameError[0m: name 'holo' is not defined
C = superelliptic(x^3 + x + 2, 2, 5)
omega = superelliptic_form(C, (x^2+x)/y + 3*x^3)
omega
((-2*x^3*y + x^2 + x)/y) dx
licz = 0
m = 2
p = 5
R1.<x> = PolynomialRing(GF(p))
f = R1(x^3 + x + 4)
r = f.degree()
C = superelliptic(f, m, p)
for i in range(0, r):
for j in range(1, m):
omega = superelliptic_form(C, x^i/y^j)
if (omega.is_regular_on_U0() and omega.is_regular_on_Uinfty()):
print(omega)
licz += 1
print(licz, C.genus())
print(C.basis_holomorphic_differentials())
(1/y) dx 1 1 {0: (1/y) dx}
p = 5
R.<x, y> = PolynomialRing(GF(p), 2)
g = x^6*y^2 + y^2
omega = diffn(superelliptic_function(C, y^2))
omega.jth_component(0)
3*x^2 + 1
R.<x, y> = PolynomialRing(GF(p), 2)
g1 = x^3*y^7 + x^2*y^9
g2 = x^2*y + y^6
R1.<x> = PolynomialRing(GF(p))
R2 = FractionField(R1)
R3.<y> = PolynomialRing(R2)
xgcd(R3(g1), R3(g2))[1]*R3(g1) + xgcd(R3(g1), R3(g2))[2]*R3(g2)
y
H = HyperellipticCurve(x^5 - x + 1)
H
Hyperelliptic Curve over Finite Field of size 5 defined by y^2 = x^5 + 4*x + 1
f = x^3 + x + 2
f.derivative(x)
-2*x^2 + 1
p = 5
R1.<x> = PolynomialRing(GF(p))
R2 = FractionField(R1)
R3.<y> = PolynomialRing(R2)
g = y^2/x + y/(x+1)
g = 1/y+x/y^2
R3.<z> = PolynomialRing(R2)
g(y = 1/z)
x*z^2 + z
f
x^3 + x + 4
f.coefficient()
[0;31m---------------------------------------------------------------------------[0m [0;31mAttributeError[0m Traceback (most recent call last) [0;32m<ipython-input-62-e054c182ec1a>[0m in [0;36m<module>[0;34m()[0m [0;32m----> 1[0;31m [0mf[0m[0;34m.[0m[0mcoefficient[0m[0;34m([0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m [0;32m/opt/sagemath-9.1/local/lib/python3.7/site-packages/sage/structure/element.pyx[0m in [0;36msage.structure.element.Element.__getattr__ (build/cythonized/sage/structure/element.c:4614)[0;34m()[0m [1;32m 485[0m [0mAttributeError[0m[0;34m:[0m [0;34m'LeftZeroSemigroup_with_category.element_class'[0m [0mobject[0m [0mhas[0m [0mno[0m [0mattribute[0m [0;34m'blah_blah'[0m[0;34m[0m[0;34m[0m[0m [1;32m 486[0m """ [0;32m--> 487[0;31m [0;32mreturn[0m [0mself[0m[0;34m.[0m[0mgetattr_from_category[0m[0;34m([0m[0mname[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 488[0m [0;34m[0m[0m [1;32m 489[0m [0mcdef[0m [0mgetattr_from_category[0m[0;34m([0m[0mself[0m[0;34m,[0m [0mname[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m/opt/sagemath-9.1/local/lib/python3.7/site-packages/sage/structure/element.pyx[0m in [0;36msage.structure.element.Element.getattr_from_category (build/cythonized/sage/structure/element.c:4723)[0;34m()[0m [1;32m 498[0m [0;32melse[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [1;32m 499[0m [0mcls[0m [0;34m=[0m [0mP[0m[0;34m.[0m[0m_abstract_element_class[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 500[0;31m [0;32mreturn[0m [0mgetattr_from_other_class[0m[0;34m([0m[0mself[0m[0;34m,[0m [0mcls[0m[0;34m,[0m [0mname[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 501[0m [0;34m[0m[0m [1;32m 502[0m [0;32mdef[0m [0m__dir__[0m[0;34m([0m[0mself[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m [0;32m/opt/sagemath-9.1/local/lib/python3.7/site-packages/sage/cpython/getattr.pyx[0m in [0;36msage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2614)[0;34m()[0m [1;32m 392[0m [0mdummy_error_message[0m[0;34m.[0m[0mcls[0m [0;34m=[0m [0mtype[0m[0;34m([0m[0mself[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [1;32m 393[0m [0mdummy_error_message[0m[0;34m.[0m[0mname[0m [0;34m=[0m [0mname[0m[0;34m[0m[0;34m[0m[0m [0;32m--> 394[0;31m [0;32mraise[0m [0mAttributeError[0m[0;34m([0m[0mdummy_error_message[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m [0m[1;32m 395[0m [0mattribute[0m [0;34m=[0m [0;34m<[0m[0mobject[0m[0;34m>[0m[0mattr[0m[0;34m[0m[0;34m[0m[0m [1;32m 396[0m [0;31m# Check for a descriptor (__get__ in Python)[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m [0;31mAttributeError[0m: 'sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint' object has no attribute 'coefficient'