canonical ideal working

This commit is contained in:
jgarnek 2024-01-22 18:50:58 +00:00
parent 9376f28100
commit 1891b447b6

View File

@ -17,7 +17,7 @@ class as_polyform:
"""Find coordinates of the given holomorphic form self in terms of the basis forms in a list holo."""
AS = self.curve
if basis == 0:
basis = AS.holomorphic_differentials_basis()
basis = AS.holo_polydifferentials_basis(mult = self.mult)
RxyzQ, Rxyz, x, y, z = AS.fct_field
# We need to have only polynomials to use monomial_coefficients in linear_representation_polynomials,
# and sometimes basis elements have denominators. Thus we multiply by them.
@ -51,8 +51,9 @@ def as_symmetric_power_basis(AS, n, threshold = 8):
result = []
for i in indices_nonrepeating:
tensor_form = [B0[i[j]] for j in range(n)]
tensor_form = [1] + tensor_form
result += [tensor_form]
print(binomial(g + n - 1, n), len(result))
result = [as_symmetric_product_forms([a]) for a in result]
return result
def as_canonical_ideal(AS, n, threshold=8):
@ -61,30 +62,22 @@ def as_canonical_ideal(AS, n, threshold=8):
g = AS.genus()
RxyzQ, Rxyz, x, y, z = AS.fct_field
from itertools import product
#B1 = as_symmetric_power_basis(AS, n, threshold = 8)
B1 = [[B0[i[j]] for j in range(n)] for i in product(*indices)]
B1 = as_symmetric_power_basis(AS, n, threshold = 8)
B2 = AS.holo_polydifferentials_basis(n, threshold = threshold)
g = AS.genus()
r = len(B2)
M = matrix(F, len(B1), r)
for i in range(0, len(B1)):
atuple = B1[i]
c = Rxyz(1)
for a in atuple:
c = c*a.form
c = as_reduction(AS, c)
c = as_function(AS, c)
c = as_polyform(c, n)
c = B1[i].multiply()
#return M, c.coordinates(basis=B2)
M[i, :] = vector(c.coordinates(basis=B2))
K = M.kernel().basis()
result = []
for v in K:
coeffs = {tuple(b) : 0 for b in B1}
for i in range(r):
if v[i] != 0:
coeffs[tuple(B1[i])] += v[i]
result += [as_symmetric_product_forms(B1, coeffs)]
kernel_vector = 0*B1[0]
for i in range(len(v)):
kernel_vector += v[i]*B1[i]
result += [kernel_vector]
return result
as_cover.canonical_ideal = as_canonical_ideal
@ -94,61 +87,17 @@ def as_canonical_ideal_polynomials(AS, n, threshold=8):
as_cover.canonical_ideal_polynomials = as_canonical_ideal_polynomials
class as_tensor_product_forms:
def __init__(self, pairs_of_forms, coeffs):
self.pairs = pairs_of_forms
self.coeffs = coeffs #dictionary
self.curve = pairs_of_forms[0][0].curve
def coordinates(self, basis = 0):
AS = self.curve
g = AS.genus()
F = AS.base_ring
if basis == 0:
basis = AS.holomorphic_differentials_basis()
result = matrix(F, g, g)
for (omega1, omega2) in self.pairs:
c = omega1.coordinates(basis = basis)
d = omega2.coordinates(basis = basis)
for i in range(g):
for j in range(g):
result[i, j] += self.coeffs[(omega1, omega2)]*c[i]*d[j]
return result
def __repr__(self):
result = ''
for (omega1, omega2) in self.pairs:
if self.coeffs[(omega1, omega2)] !=0:
result += str(self.coeffs[(omega1, omega2)]) + ' * ' + str(omega1) + '' + str(omega2) + ' + '
return result
def polynomial(self):
AS = self.curve
F = AS.base_ring
g = AS.genus()
M = self.coordinates()
Rg = PolynomialRing(F, 'X', g)
X = Rg.gens()
return sum(M[i, j] * X[i]*X[j] for i in range(g) for j in range(g))
def group_action(self, elt):
p = self.base_ring.characteristic()
n = self.height
elt1 = [p^n - a for a in elt]
pairs_of_forms2 = [(a.group_action(elt), b.group_action(elt1)) for (a, b) in pairs_of_forms]
coeffs2 = {(a.group_action(elt), b.group_action(elt1)) : self.coeffs[(a, b)] for (a, b) in pairs_of_forms}
return as_tensor_product_forms(pairs_of_forms2, self.coeffs)
class as_symmetric_product_forms:
def __init__(self, tuples_of_forms, coeffs):
self.n = len(tuples_of_forms[0])
self.tuples = tuples_of_forms
self.coeffs = coeffs #dictionary
self.curve = tuples_of_forms[0][0].curve
def __init__(self, forms_and_coeffs):
'''Elements of forms_and_coeffs are of the form [coeff, form1, ..., formn]'''
self.n = len(forms_and_coeffs[0]) - 1
self.tuples = forms_and_coeffs
self.curve = forms_and_coeffs[0][1].curve
def coordinates(self, basis = 0):
AS = self.curve
g = AS.genus()
n = self.n
F = AS.base_ring
if basis == 0:
basis = AS.holomorphic_differentials_basis()
@ -156,26 +105,39 @@ class as_symmetric_product_forms:
indices = [list(range(g)) for i in range(self.n)]
result = {i : 0 for i in product(*indices)}
for atuple in self.tuples:
coors = [omega.coordinates(basis = basis) for omega in atuple]
coors = [omega.coordinates(basis = basis) for omega in atuple[1:]]
for i in product(*indices):
aux_product = 1
for j in range(n):
aux_product *= coors[j][i[j]]
result[i] += self.coeffs[tuple(atuple)]*aux_product
result[i] += atuple[0]*aux_product
return result
def __repr__(self):
result = ''
for atuple in self.tuples:
if self.coeffs[tuple(atuple)] !=0:
result += str(self.coeffs[tuple(atuple)]) + ' * '
for j in range(self.n):
if atuple[0] !=0:
result += str(atuple[0]) + ' * '
for j in range(1, self.n+1):
result += "(" + str(atuple[j]) + ")"
if j != self.n-1:
if j != self.n:
result + ''
result += ' + '
return result
def __add__(self, other):
return as_symmetric_product_forms(self.tuples + other.tuples)
def __rmul__(self, other):
AS = self.curve
F = AS.base_ring
if isinstance(other, int) or other in ZZ or other in F:
aux_tuples = []
for atuple in self.tuples:
atuple1 = [other * atuple[0]] + atuple[1:]
aux_tuples += [atuple1]
return as_symmetric_product_forms(aux_tuples)
def multiply(self):
n = self.n
AS = self.curve
@ -183,10 +145,12 @@ class as_symmetric_product_forms:
result = as_polyform(0*AS.x, n)
for atuple in self.tuples:
aux_product = Rxyz(1)
for fct in atuple:
for fct in atuple[1:]:
aux_product = aux_product * fct.form
aux_product = as_function(AS, aux_product)
result += as_polyform(self.coeffs[tuple(atuple)]*aux_product, n)
aux_product = as_reduction(AS, aux_product)
aux_product = as_function(AS, aux_product)
result += as_polyform(atuple[0]*aux_product, n)
return result
def polynomial(self):
@ -210,21 +174,11 @@ class as_symmetric_product_forms:
def group_action(self, elt):
p = self.base_ring.characteristic()
n = self.height
elt1 = [p^n - a for a in elt]
pairs_of_forms2 = [(a.group_action(elt), b.group_action(elt1)) for (a, b) in pairs_of_forms]
coeffs2 = {(a.group_action(elt), b.group_action(elt1)) : self.coeffs[(a, b)] for (a, b) in pairs_of_forms}
return as_tensor_product_forms(pairs_of_forms2, self.coeffs)
aux_tuples = []
for atuple in self.tuples:
aux_tuple = atuple[0] + [a.group_action(elt) for a in atuple[1:]]
aux_tuples += [aux_tuple]
return as_symmetric_product_forms(aux_tuples)
def non_decreasing(L):
return all(x<=y for x, y in zip(L, L[1:]))
def as_multiply_forms(list_of_forms):
n = len(list_of_forms)
AS = list_of_forms[0].curve
RxyzQ, Rxyz, x, y, z = AS.fct_field
aux_product = Rxyz(1)
for fct in list_of_forms:
aux_product = aux_product * fct.form
aux_product = as_function(AS, aux_product)
aux_product = as_polyform(aux_product, n)
return aux_product