#!/usr/bin/env python3 """Certificate for Appendix A of "Fourier zeros and the Schottky problem I" (Lemmas A.3 and A.4; see Appendix C). Exact arithmetic in Z[a,b,c,d] (SymPy). For u = (0, a, a+b, a+b+c, a+b+c+d) the script 1. forms the 120 coefficients w_p = V / prod_i (u_{p_{i+1}} - u_{p_i}), V = prod_{i p[j]) def sigma(p, e): """+1 if the labels of e occur in increasing order in p, else -1.""" i, j = e return 1 if p.index(i) < p.index(j) else -1 # 1. the coefficients w_p V = sp.prod([u[j] - u[i] for i, j in edges]) w = {} for p in itertools.permutations(labels): den = sp.prod([u[p[i + 1]] - u[p[i]] for i in range(4)]) quo, rem = sp.div(sp.expand(V), sp.expand(den), a, b, c, d) if rem != 0: check('w_p is a polynomial for p=%s' % (p,), False) w[p] = sp.expand(quo) check('the 120 coefficients w_p are polynomials in a,b,c,d', len(w) == 120) # 2. the factorization of P(q) T = [sp.Integer(0)] * 11 for p, wp in w.items(): T[inv(p)] += wp T = [sp.expand(t) for t in T] A = T[0] B = sp.expand(T[1] + 2 * A) C = sp.expand(T[2] + 2 * B + A) quartic = [A, B, C, B, A] sextic = [1, -2, -1, 4, -1, -2, 1] # (q-1)^4 (q+1)^2 qq = sp.symbols('q') assert sp.Poly(sp.expand((qq - 1)**4 * (qq + 1)**2), qq).all_coeffs() == sextic for k in range(11): conv = sum(quartic[i] * sextic[k - i] for i in range(5) if 0 <= k - i <= 6) check('coefficient of q^%d in the factorization of P' % k, sp.expand(conv - T[k]) == 0) # 3. signs for name, pol in (('A', A), ('2A+C-2B', 2 * A + C - 2 * B), ('2A+C+2B', 2 * A + C + 2 * B), ('2A-C', 2 * A - C)): co = sp.Poly(sp.expand(pol), a, b, c, d).coeffs() print(' %-8s: %d monomials, coefficients between %d and %d' % (name, len(co), min(co), max(co))) check('%s is non-zero with positive coefficients' % name, len(co) > 0 and min(co) > 0) # 4. the Hessian def L(e, f): common = set(e) & set(f) if common: (x,) = set(e) - common (y,) = set(f) - common r, s = sorted(set(labels) - set(e) - set(f)) return (u[x] - u[y]) * (u[r] - u[s]) (m,) = set(labels) - set(e) - set(f) i, j = e k, l = f return (u[m] - u[i]) * (u[m] - u[j]) - (u[m] - u[k]) * (u[m] - u[l]) n_entries = 0 all_H = True for x, e in enumerate(edges): for f in edges[x:]: H = sp.expand(sum((-1)**inv(p) * wp * sigma(p, e) * sigma(p, f) for p, wp in w.items())) if e == f: good = (H == 0) else: be, bf = u[e[1]] - u[e[0]], u[f[1]] - u[f[0]] good = (sp.expand(H - 16 * be * bf * L(e, f)**2) == 0) all_H = all_H and good n_entries += 1 check('the %d entries of H agree with the closed formulas' % n_entries, all_H and n_entries == 55) print('ALL CHECKS PASSED' if ok else 'SOME CHECK FAILED') sys.exit(0 if ok else 1)