"""Certified genus-one boundary exclusions at the possible nonreal boundary zero.""" from flint import arb, arb_poly, acb, ctx from fractions import Fraction from math import prod, isqrt ctx.prec = 400 def bounds_for_field(q): q = arb(q) # Use absolute composition sums whenever their geometric series converges. v = (2 * (q + 1) / (q - 1)) * ((2 * (q + 1) / (q - 1) ** 2 / (1 - q**-2)).exp()) # log product of Z(q^-j), j>=2: N/(q*(q-1)*(1-q^-1)*(1-q^-2)) c = v / (1 - q**-2) if c < q - 1: C = c / (1 - c / (q - 1)) else: C = ( 16 * ( (1 / (q - 1) + 1 / (q - 1) ** 2) + q.sqrt() / (q - 1) + (1 + q.sqrt()) * q / (q - 1) ** 2 ).exp() ) return v, C def uniform_exclusion(q, n): q = arb(q) v, C = bounds_for_field(q) r = (q ** (-n)).sqrt() if not ((n - 1) * (q + 1) * r < arb(1) / 2 and q * r <= arb(1) / 2): return False hinv = (1 + q * r) / (1 - q * r) ** 2 end = 2 * (1 + 1 / r) * C * (n - 2) * q ** (-(n - 1)) second = (n // 2) * 16 * (1 + r) ** 2 * hinv * v * (1 + C / (q - 1)) ** 2 * r return end + second < 1 def weight_limits(q, m, steps): v = [arb_poly([1]), arb_poly([1])] section_mass = arb_poly([0, 2 * (q + 1) / (q - 1)]) rows = [[]] bounds = [[]] for s in range(1, m): if s >= 2: v.append(v[-1] * arb_poly([1, 1 + steps[s]])) line = [None] lim = [None] for a in range(1, s): l = s - a p = ( sum( ( poly * (1 / (1 - q ** (a + b))) for b, poly in enumerate(rows[l]) if b ), arb_poly([]), ) * section_mass * v[a] ) line.append(p) ratios = [p[j] / v[s][j] for j in range(s)] # Each value is a positive-weighted mean of the signed coefficient ratios. lower = ratios[0] upper = ratios[0] for term in ratios[1:]: lower = lower.min(term) upper = upper.max(term) lim.append(lower.union(upper)) rows.append(line + [v[s]]) bounds.append(lim + [arb(1)]) return bounds def finite(qbase): q = arb(qbase) ranks = [n for n in range(3, 160) if not uniform_exclusion(qbase, n)] if not ranks: print(f"q={qbase}: analytic bounds cover ranks 3 to 159") return maxn = max(ranks) pw = [q**k for k in range(maxn + 2)] vstep = [None, None] + [ 2 * (q + 1) * q ** (-j) / ((1 - q ** (-j)) * (1 - q ** (1 - j))) for j in range(2, maxn + 1) ] adj = [ [None] + [-1 / (q ** (a + b) - 1) for b in range(1, maxn)] for a in range(maxn) ] limits = weight_limits(q, maxn, vstep) stats = [0, 0] def visit(num, level, rs): lo = arb(num) / 2**level hi = arb(num + 1) / 2**level w = lo.union(hi) N = 2 * (q + 1) * w mx = max(rs) # Monotone endpoints prevent long products from widening through division. vlo = [arb(1), arb(1)] vhi = [arb(1), arb(1)] for c in vstep[2 : mx + 1]: vlo.append(vlo[-1] * (1 + c * lo)) vhi.append(vhi[-1] * (1 + c * hi)) def mass_ratio(a, b): i, j = sorted((a, b)) s = i + j # bound each part with separate monotone endpoint. return (2 * (q + 1) / (q - 1) * lo * vlo[i] * vhi[j] / vhi[s]).union( 2 * (q + 1) / (q - 1) * hi * vhi[i] * vlo[j] / vlo[s] ) row = [[arb(1)]] for size in range(1, mx): line = [None] for a in range(1, size): l = size - a weight = mass_ratio(a, l) * sum( y * adj[a][b] for b, y in enumerate(row[l]) if b ) line.append(weight.intersection(limits[size][a])) row.append(line + [arb(1)]) def B(k, x): if not k: return acb(1) return sum(w / (1 - pw[a] * x) for a, w in enumerate(row[k]) if a) Dl = 2 * (q + 1) * lo Dh = 2 * (q + 1) * hi failed = [] for n in range(3, mx + 1): Dl = 2 * (q + 1) * lo + (pw[n - 1] - q) * Dl / (pw[n - 1] - 1 + Dl) Dh = 2 * (q + 1) * hi + (pw[n - 1] - q) * Dh / (pw[n - 1] - 1 + Dh) if n not in rs: continue r = 1 / pw[n].sqrt() x = ((2 - Dl) * r / 2).union((2 - Dh) * r / 2) if not x.abs_upper() < 1: failed.append(n) continue z = acb(x, (1 - x * x).sqrt()) T = r * z # Endpoint expressed relative to singleton exactly, for stability. H = (1 - (q + 1 - N) * T + q * T * T) / (1 - q * T) m = n - 1 A = H * ( 1 + sum( w * (1 - pw[n] * T) / (1 - pw[a + 1] * T) for a, w in enumerate(row[m]) if 0 < a < m ) ) for k in range(1, m // 2 + 1): l = m - k y = pw[k] * T Z = 1 + N * y / ((1 - y) * (1 - q * y)) A += ( (1 - T) * (1 - pw[n] * T) * mass_ratio(k, l) * B(k, 1 / (pw[k] * T)) * Z * B(l, pw[k + 1] * T) / (2 if k == l else 1) ) if not A.is_finite() or A.contains(0): failed.append(n) stats[0] += 1 stats[1] = max(stats[1], level) if failed: if level >= 30: raise ArithmeticError((qbase, num, level, failed)) visit(2 * num, level + 1, failed) visit(2 * num + 1, level + 1, failed) visit(0, 0, ranks) print( f"q={qbase}: {len(ranks)} interval-tested ranks up to {maxn}, {stats[0]} visited intervals, maximum depth {stats[1]}", flush=True, ) def cross_check_series(): """Test the specialized hypergeometric identity against rational compositions.""" for q, beta in [(2, Fraction(4, 3)), (3, Fraction(-5, 3)), (5, Fraction(2))]: t = Fraction(1, q) trace = beta + q / beta def poch(x, k): return prod((1 - x * t**j for j in range(k)), start=Fraction(1)) v = [1, (q + 1 - trace) / (q - 1)] rows = [{}] for l in range(1, 9): if l > 1: y = t**l v.append(v[-1] * (1 - trace * y + q * y * y) / ((1 - y) * (1 - q * y))) row = {l: v[l]} for a in range(1, l): row[a] = v[a] * sum( w / (1 - q ** (a + c)) for c, w in rows[l - a].items() ) rows.append(row) for d in range(1, 6): actual = sum(w / (1 - q ** (a + d)) for a, w in row.items()) predicted = t**l * sum( poch(beta, l - j) / poch(t, l - j) * poch(1 / beta, j) * poch(t**d / beta, j) * beta**j / (poch(t, j) * poch(t ** (d + 1), j)) for j in range(l + 1) ) if actual != predicted: raise ArithmeticError("Elliptic series mismatch") def check_unbounded_ranges(): v2, c2 = bounds_for_field(2) v64, c64 = bounds_for_field(64) if not (v2 < 2**15 and c2 < 2**19 and v64 < 3 and c64 < 4): raise ArithmeticError("Invalid uniform constants") n = 160 r = Fraction(1, 2 ** (n // 2)) error = 8 * 2**19 * n * r + 16 * 4 * 6 * 2**15 * (1 + 2**19) ** 2 * n * r large_field = ( Fraction(16, 63) + Fraction(3, 2 * 512) * 16 * 2 * 2 * 3 * Fraction(67, 63) ** 2 ) if not (3 * (n - 1) * r < Fraction(1, 2) and error < 1 and large_field < 1): raise ArithmeticError("Uniform error bound failed") def main(): check_unbounded_ranges() cross_check_series() # Enumerate every prime power in the finite field-size range. fields = set() for p in range(2, 64): if any(p % d == 0 for d in range(2, isqrt(p) + 1)): continue q = p while q < 64: fields.add(q) q *= p for q in sorted(fields): finite(q) if __name__ == "__main__": main()