"""Direct genus-two point counts over F_107 and its quadratic extension.""" import json P = 107 PARAMETERS = [17, 98, 99] def chi(a): a %= P if not a: return 0 w = pow(a, (P - 1) // 2, P) assert w in (1, P - 1) return 1 if w == 1 else -1 def mul(a, b): return ((a[0] * b[0] - a[1] * b[1]) % P, (a[0] * b[1] + a[1] * b[0]) % P) def power(a, n): z = (1, 0) while n: if n & 1: z = mul(z, a) a = mul(a, a) n //= 2 return z def C3(t): return (t**3 - 3 * t) % P def quartic_certificate(t, sign): vals = [((u + 2 * sign) * (u**3 - 3 * u - t)) % P for u in range(P)] signs = [chi(v) for v in vals] counts = {str(a): signs.count(a) for a in [-1, 0, 1]} total = sum(signs) count = P + 2 + total # monic quartic has two rational points at infinity return {'sign': sign, 'values_u_0_through_106': vals, 'legendre_sequence': ''.join('+' if a == 1 else '-' if a == -1 else '0' for a in signs), 'counts': counts, 'character_sum': total, 'point_count': count, 'frobenius_trace': P + 1 - count} def genus_two_counts(t): sums = [0, 0] histograms = [] h1 = {str(a): 0 for a in [-1, 0, 1]} for x in range(P): a = chi(x**6 - t*x**3 + 1) sums[0] += a h1[str(a)] += 1 histograms.append(h1) h2 = {str(a): 0 for a in [-1, 0, 1]} for a in range(P): for b in range(P): x3 = mul(mul((a, b), (a, b)), (a, b)) x6 = mul(x3, x3) f = ((x6[0] - t*x3[0] + 1) % P, (x6[1] - t*x3[1]) % P) norm = (f[0]*f[0] + f[1]*f[1]) % P # chi_{p^2}(f) = chi_p(Norm(f)), including f=0. c = chi(norm) sums[1] += c h2[str(c)] += 1 histograms.append(h2) n1, n2 = P + 2 + sums[0], P*P + 2 + sums[1] a1 = P + 1 - n1 a2_numerator = n2 - P*P - 1 + a1*a1 assert a2_numerator % 2 == 0 a2 = a2_numerator // 2 return {'character_sums': sums, 'histograms': histograms, 'N1': n1, 'N2': n2, 'frobenius_coefficients_descending': [1, -a1, a2, -P*a1, P*P]} if __name__ == '__main__': residues = sorted({x*x % P for x in range(1, (P+1)//2)}) assert len(residues) == (P-1)//2 and chi(-1) == -1 for x in range(P): assert chi(x) == (0 if x == 0 else 1 if x in residues else -1) roots = [x for x in range(P) if C3(x) == 47] assert roots == PARAMETERS and C3(47) == P-1 alpha = (77, 8) zeta = (53, 9) lifts = [(62, 3), (49, 75), (103, 29)] assert power(alpha, 3) == zeta and power(zeta, 3) == (1, 0) and zeta != (1, 0) assert power(alpha, 9) == (1, 0) and power(alpha, 3) != (1, 0) assert mul(lifts[0], zeta) == lifts[1] and mul(lifts[1], zeta) == lifts[2] lift_checks = [] for t, x in zip(PARAMETERS, lifts): norm = (x[0]*x[0] + x[1]*x[1]) % P assert norm == 1 and 2*x[0] % P == t assert power(x, 3) == alpha and power(x, 27) == (1, 0) and power(x, 9) != (1, 0) lift_checks.append({'t': t, 'coordinates': list(x), 'norm': norm, 'cube': list(power(x, 3)), 'order': 27}) cases = [] for t in PARAMETERS: assert (t*t - 4) % P != 0 plus, minus = quartic_certificate(t, 1), quartic_certificate(t, -1) a, b = plus['frobenius_trace'], minus['frobenius_trace'] product = [1, -(a+b), a*b+2*P, -P*(a+b), P*P] direct = genus_two_counts(t) assert product == [1, 0, 133, 0, 11449] == direct['frobenius_coefficients_descending'] assert direct['N1'] == 108 and direct['N2'] == 11716 # Elementary root-fiber character identity used in the written proof. for u in range(P): left = sum(chi(x) for x in range(1, P) if (x*x-u*x+1) % P == 0) right = chi(u+2)+chi(u-2) assert left == right cases.append({'t': t, 'smooth': True, 'plus_quotient': plus, 'minus_quotient': minus, 'product_coefficients_descending': product, 'independent_direct_counts': direct}) out = { 'p': P, 'quadratic_residues_nonzero': residues, 'C3_47': C3(47), 'roots_C3_equals_47': roots, 'alpha_coordinates': list(alpha), 'alpha_order': 9, 'zeta_coordinates': list(zeta), 'zeta_order': 3, 'lift_checks': lift_checks, 'cases': cases, } print(json.dumps(out, indent=2))