#!/usr/bin/env python3 """ Checker for the certificates of Table 16 (permissible exponents for k = 13) of the paper "Explicit linear bounds in Waring's problem" (Section C.8). Usage: python3 check_k13_certificates.py k13_certificates.json Only the Python standard library is used, and all arithmetic is exact (fractions.Fraction). The data. Exponents are written as functions of the real moment order u (so that lambda_s of the paper is the value at u = 2s). The file contains * the table T on the grid u = 0, 1/4, 1/2, ..., 120 (exact rationals; between grid points T is interpolated linearly, which is Hoelder's inequality, and beyond the grid T(u) = u - 13); * for 155 grid points u in (4, 58] a certificate: an iterative scheme (t, J, b_1, ..., b_(J-1), m, b_w), its parameters phi_1 >= ... >= phi_J >= 0 as exact rationals, and the cases of [VW2000, Theorem 3.4] used for I_m and I_(m+1) in the final step; * the numbers delta_r of [VW2000, Section 23] that enter the case conditions; * the entries lambda_s, 3 <= s <= 29, of Table 16 as published. What is checked. (1) Every certificate satisfies 0 <= phi_(i+1) <= phi_i <= 1/13 and the linear conditions of its cases, and the bound B_u(T) of its scheme (see `bound` below), evaluated exactly with the table T as input, is at most T(u). The smallest margin T(u) - B_u(T) is reported. (2) The schemes read T only at orders <= 58, and T(u) >= u/2 for u <= 4 (where u/2 is the true exponent). (3) For every grid point w in (4, 58] the deficit d(w) = max(0, c(w) - T(w)) is computed, where c(w) is the least chord at w of the points (v, T(v)) with v certified or v = 4 (with the value 2). The largest deficit is reported, and it is checked to be smaller than the smallest margin in (1). (4) Every published entry lambda_s is at least T(2s) + d(2s). Why this suffices. Each bound B_u(T) is a maximum of expressions in which the values of T enter with nonnegative coefficients whose sum is at most 1 (the coefficients are 1 - phi_1, q_j = 1 - phi_1 - ... - phi_j, c q_J with 0 <= c <= 1, and averages of these). So B_u is nondecreasing, and B_u(T + E) <= B_u(T) + sup E. Let lambda* be the least permissible exponent, a convex function of u; the scheme gives lambda*(u) <= B_u(lambda*) at every certified u. Let M be the largest value of lambda* - T at the certified points, and suppose that M > 0. By convexity of lambda* and linearity of T between grid points, lambda* - T <= M + max d on (0, 58], and so, at a certified point u where M is attained, M <= B_u(lambda*) - T(u) <= B_u(T) + M + max d - T(u) <= M + max d - margin(u) < M, by (3). Hence M <= 0: the table T is valid at the certified points, and lambda* <= T + d everywhere, which by (4) gives the published entries. The bounds at some certified points read T at larger orders (through the final step), so an induction on u would not do; this fixed point argument replaces it. The scheme (the steps (a)-(d) of Section C.8). With S_j = phi_1 + ... + phi_j, h_j = j - (k - 1) S_j and q_j = 1 - S_j, and mu = T: (a) first differencing step, of order u with real t <= 1, a_1 = u - 2t: E_0 = t + (1 - phi_1) mu(a_1) + phi_1 a_1; (d) final step with Hoelder between I_m and I_(m+1) and a moment of f of order p/c, where F = t, p = a_1 if J = 1, and F = 1, p = b_(J-1) otherwise, a = (F - 2^(m+1) b_w)/2^m, c = 1 - a - b_w, and (tau, chi) from the cases: L_n = 2^n - n - chi_n + (2^n - 1) h_J + tau_n S_J (n = m, m + 1), y_J = a L_m + b_w L_(m+1) + c q_J mu(p/c); for J = 1 the bound is max(E_0, (u - 3t) phi_1 + y_J); (c) for J >= 2, with D_j(v) = 1 + h_(j-1) + phi_j + q_j mu(v), put y = max(y_J, D_J(b_(J-1))), and for j = J - 1, ..., 2 replace y by max((q_j mu(2 b_(j-1) - b_j) + h_j + (b_j - 1) phi_(j+1) + y)/2, D_j(b_(j-1))); (b) second level, with x = t/2 and v = (a_1 - x b_1)/(1 - x): the bound is max(E_0, (u - 3t) phi_1 + x (h_1 + (b_1 - 1) phi_2 + y) + (1 - x) q_1 mu(v)). Here the b_j are even integers with b_j = b_1 - 2(j - 1). The formulas are those of the program that produced the certificates (certify13.py of the k = 13 bundle), restated here without its linear programming. """ import sys, json from fractions import Fraction as Fr K = 13 def load(path): d = json.load(open(path)) grid = [(Fr(u), Fr(v)) for u, v in d["grid"]] step = Fr(d["grid_step"]) D26 = {int(r): Fr(v) for r, v in d["delta26"].items()} certs = d["certificates"] table16 = {int(s): Fr(v) for s, v in d["table16"].items()} return grid, step, D26, certs, table16 class Table: """T on the grid, linear between grid points, u - K beyond; records the orders at which it is read.""" def __init__(self, grid, step): self.u = [u for u, _ in grid] self.v = [v for _, v in grid] self.h = step assert all(self.u[i] == i * step for i in range(len(self.u))) self.reads = [] def __call__(self, w): w = Fr(w) self.reads.append(w) if w <= 0: return Fr(0) if w >= self.u[-1]: return w - K i = int(w / self.h) if self.u[i] == w: return self.v[i] return self.v[i] + (self.v[i + 1] - self.v[i]) * (w - self.u[i]) / self.h def case_params(J, m, label, D26): """(tau, chi, conditions) for a case of [VW2000, Theorem 3.4]; a condition (coef, rhs) means sum coef_i phi_i <= rhs.""" Jc = (K - J - m + 1) // 2 e, nu = J % 2, J // 2 S = {i: Fr(1) for i in range(1, J + 1)} if label in ("-", "Ia"): return Fr(0), Fr(0), [] if label == "III": return Fr(1), Fr(0), [] def cond(name): if name == "i": if not J <= Jc + 1: raise ValueError("condition (i) fails") return [] if name == "iii": out = [] for I in range(3, J + 1): co = {i: Fr(1) for i in range(1, I + 1)} co[I - 1] += K co[I] += K out.append((co, Fr(2))) return out if name == "ii": if Jc != 1: raise ValueError("condition (ii) needs J_c = 1") return [({1: K + D26[J + e]}, Fr(1))] if name == "abg": return [] if name == "delta": return [(S, Fr(1, 3))] raise ValueError(name) if label.startswith("Ib["): a, b = label[3:-1].split(",") return Fr(0), Fr(0), cond(a) + cond(b) if label.startswith("II["): return Fr(1), Fr(1, 3), cond(label[3:-1]) + [({i: Fr(-1) for i in S}, Fr(-1, 3))] if label.startswith("Ic["): if Jc != 1: raise ValueError("case Ic needs J_c = 1") parts = label[3:-1].split(",") if parts[0] == "gen": sig, c = D26[J] / J, [] else: sig = (D26[nu] + D26[nu + e]) / J c = [({1: K + D26[2 * (nu + f)] - 2 * D26[nu + f]}, Fr(1)) for f in sorted({0, e})] if len(parts) > 1: c.append((S, Fr(1, 3) / (1 - sig))) return sig, Fr(0), c raise ValueError(label) def bound(mu, cert, D26): """the bound of the scheme of a certificate, with the table mu as input (exact), after checking its conditions""" u, t, J, m = Fr(cert["u"]), Fr(cert["t"]), int(cert["J"]), int(cert["m"]) b = [Fr(x) for x in cert["b"]] bw = Fr(cert["bw"]) ph = [None] + [Fr(p) for p in cert["phi"]] if len(ph) != J + 1 or len(b) != max(J - 1, 0): raise ValueError("malformed certificate") if not (0 < t <= 1) or bw < 0: raise ValueError("t or b_w out of range") for j in range(1, len(b)): if b[j] != b[j - 1] - 2: raise ValueError("b_j are not b_1 - 2(j - 1)") if any(x.denominator != 1 or x % 2 for x in b): raise ValueError("b_j must be even integers") for i in range(1, J + 1): if not 0 <= ph[i] <= Fr(1, K): raise ValueError("phi out of range") if i < J and ph[i + 1] > ph[i]: raise ValueError("phi not decreasing") S = lambda j: sum(ph[1:j + 1], Fr(0)) h = lambda j: j - (K - 1) * S(j) q = lambda j: 1 - S(j) a1 = u - 2 * t E0 = t + mu(a1) * (1 - ph[1]) + a1 * ph[1] F = t if J == 1 else Fr(1) p = a1 if J == 1 else b[-1] a = (F - 2 ** (m + 1) * bw) / 2 ** m c = 1 - a - bw if a < 0 or not 0 <= c <= 1: raise ValueError("Hoelder weights out of range") lab_m, lab_n = cert["case"].split("|") tm, xm, cm = case_params(J, m, lab_m, D26) if a > 0 else (Fr(0), Fr(0), []) tn, xn, cn = case_params(J, m + 1, lab_n, D26) if bw > 0 else (Fr(0), Fr(0), []) for co, rhs in cm + cn: if sum(v * ph[i] for i, v in co.items()) > rhs: raise ValueError("a condition of the case fails") Lm = 2 ** m - m - xm + (2 ** m - 1) * h(J) + tm * S(J) Ln = 2 ** (m + 1) - (m + 1) - xn + (2 ** (m + 1) - 1) * h(J) + tn * S(J) yJ = (a * Lm if a > 0 else 0) + (bw * Ln if bw > 0 else 0) + c * mu(p / c) * q(J) if J == 1: return max(E0, (u - 3 * t) * ph[1] + yJ) D = lambda j, v: 1 + h(j - 1) + ph[j] + mu(v) * q(j) y = max(yJ, D(J, b[J - 2])) for j in range(J - 1, 1, -1): pj, bj = b[j - 2], b[j - 1] y = max((mu(2 * pj - bj) * q(j) + h(j) + (bj - 1) * ph[j + 1] + y) / 2, D(j, pj)) x = t / 2 v = (a1 - x * b[0]) / (1 - x) return max(E0, (u - 3 * t) * ph[1] + x * (h(1) + (b[0] - 1) * ph[2] + y) + (1 - x) * mu(v) * q(1)) def main(): grid, step, D26, certs, table16 = load(sys.argv[1] if len(sys.argv) > 1 else "k13_certificates.json") T = Table(grid, step) val = dict(grid) # (1) the certificates margins, cert_u = [], set() for cert in certs: u = Fr(cert["u"]) if not (4 < u <= 58) or u not in val: raise SystemExit(f"certificate at an order outside the grid range: {u}") B = bound(T, cert, D26) if B > val[u]: raise SystemExit(f"FAILED at u = {u}: bound {float(B):.10f} > table {float(val[u]):.10f}") margins.append(val[u] - B) cert_u.add(u) print(f"(1) {len(certs)} certificates checked; the smallest margin T(u) - B_u(T) is {float(min(margins)):.3e}") # (2) orders read, and small orders top = max(T.reads) ok2 = top <= 58 and all(v >= w / 2 for w, v in grid if w <= 4) print(f"(2) the schemes read T at orders up to {float(top)}; T(u) >= u/2 for u <= 4: {ok2}") if not ok2: raise SystemExit("FAILED (2)") # (3) deficits of the other grid points anchors = sorted([(Fr(4), Fr(2))] + [(u, val[u]) for u in cert_u]) def least_chord(w): best = None left = [(a, va) for a, va in anchors if a < w] right = [(b_, vb) for b_, vb in anchors if b_ > w] for a, va in left: for b_, vb in right: ch = va + (vb - va) * (w - a) / (b_ - a) if best is None or ch < best: best = ch return best deficit = {} for w, v in grid: if 4 < w <= 58 and w not in cert_u: c = least_chord(w) if c is None: raise SystemExit(f"FAILED: no chord at {w}") deficit[w] = max(Fr(0), c - v) dmax = max(deficit.values()) print(f"(3) {len(deficit)} other grid points in (4, 58]; the largest deficit is {float(dmax):.3e}; " f"smaller than the smallest margin: {dmax < min(margins)}") if not dmax < min(margins): raise SystemExit("FAILED (3)") # (4) the published entries bad, raised = [], [] for s, lam in sorted(table16.items()): w = Fr(2 * s) need = val[w] + deficit.get(w, Fr(0)) if lam < need: bad.append(s) if lam > val[w]: raised.append(s) print(f"(4) entries lambda_s of Table 16 checked for 3 <= s <= 29: {len(table16)}; entries above the grid value " f"(raised to cover a deficit): {raised}; failures: {bad}") if bad: raise SystemExit("FAILED (4)") print("ALL CHECKS PASSED: the entries of Table 16 are permissible exponents for k = 13, given the validity of the " "steps (a)-(d) and of the cases of [VW2000, Theorem 3.4].") if __name__ == "__main__": main()