#!/usr/bin/env python3 """Exact local recheck of the binned certificate's least-margin cell. No certificate code is imported. Input constants and the already-certified global h and f(1) intervals are taken from the copied exact certificate. This is a spot check, not a recertification of those two global intervals. For beta of class (0,3,1) and a in [3/5,3/5+1/79200], the constant part of the fragmentation has only two or three rough fragments. The h part vanishes at a=3/5. Above it, Lemma K leaves only contributions from a rough fragment in (1/10,a-1/2]. These contributions are bounded separately by simplex volumes. All bounds use integers/Fractions. Floats are printed only for readability. """ import os for name in ("OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS", "MKL_NUM_THREADS", "NUMEXPR_NUM_THREADS", "FLINT_NUM_THREADS"): os.environ[name] = "1" from pathlib import Path from fractions import Fraction as Q from math import factorial import ast import hashlib import json from flint import fmpz_poly, ctx ctx.threads = 1 HERE = Path(__file__).resolve().parent SOURCE = HERE / "../../full/certb_e11a10b3_M79200.json" data = json.loads(SOURCE.read_text()) C = {ast.literal_eval(k): Q(v) for k, v in data["classes"].items()} M, SCALE = 79200, 10**20 a0, a1 = Q(3, 5), Q(3, 5) + Q(1, M) alpha, eta = Q(1, 10), Q(1, 11) target = int(a0 * M) # Only input cells below a1 can affect convolution values through a1. ncells = target + 1 def ceil_div(n, d): return -((-n) // d) def times(x, y): p = [a*b for a in x for b in y] return min(p), max(p) def add(x, y): return x[0] + y[0], x[1] + y[1] def rough_cells(cap): lo, hi = [0]*ncells, [0]*ncells for i in range(int(alpha*M), int(cap*M)): lo[i] = (M*SCALE) // (i+1) hi[i] = ceil_div(M*SCALE, i) return lo, hi def convolve_grid(x, y, divisor): """Step convolution / divisor, with outward-rounded grid bounds.""" denominator = SCALE*M*divisor answer = [] for side in range(2): product = fmpz_poly(x[side]) * fmpz_poly(y[side]) rounding = (lambda n: n // denominator) if side == 0 else (lambda n: ceil_div(n, denominator)) answer.append([0] + [rounding(int(product[i-1])) for i in range(1, ncells+1)]) return answer def cell_bounds(grid): return ([min(grid[0][i], grid[0][i+1]) for i in range(ncells)], [max(grid[1][i], grid[1][i+1]) for i in range(ncells)]) def target_interval(grid): return (Q(min(grid[0][target:target+2]), SCALE), Q(max(grid[1][target:target+2]), SCALE)) base_sum = (Q(0), Q(0)) details = [] for b, cap in enumerate((Q(1,4), Q(1,3), Q(1,2)), start=1): r = rough_cells(cap) p2 = convolve_grid(r, r, 2) p3 = convolve_grid(cell_bounds(p2), r, 3) for fragments, grid in ((2, p2), (3, p3)): total_rough = fragments + 3 coefficient = C.get((0,total_rough,b), Q(0)) - C.get((0,total_rough,b+1), Q(0)) interval = target_interval(grid) base_sum = add(base_sum, times((coefficient, coefficient), interval)) details.append({"cap": str(cap), "fragments": fragments, "abel_coefficient": str(coefficient), "density_interval": list(map(str, interval))}) # Base corresponds to L=-1 for all two- and three-rough fragmentations. base = times((-a1, -a0), base_sum) def rough_density_upper(k, total): slack = total-k*alpha if slack < 0: return Q(0) return alpha**(-k) * slack**(k-1) / (factorial(k)*factorial(k-1)) delta = a1-Q(3,5) # L_3=-1+#{rough singleton <= a-1/2}. Marking that singleton changes 1/3! to 1/2!. c6_max = max(abs(C.get((0,6,b),Q(0))) for b in range(1,4)) constant_correction = a1*c6_max*(delta/alpha)*rough_density_upper(2, a1-alpha) # With one small fragment, L equals the count of those low rough singletons: # the -1 term is cancelled by the always-admissible small singleton complement. # Mark one rough singleton; the remaining rough density is R_{r-1}. hmax = max(abs(Q(v)) for v in data["h"]) h_correction = (a1*hmax*(delta/alpha)*((alpha-eta)/eta) * sum(rough_density_upper(r-1, a1-alpha-eta) for r in range(2,6))) # h is negative, while its multiplicity and density are nonnegative. spot = (base[0]-constant_correction-h_correction, base[1]+constant_correction) prime_upper = Q(data["f1"][1]) margin = 1 + spot[0]/abs(prime_upper) assert margin > Q(51,625) assert spot[0] > Q(-1005740,1000000) assert spot[1] < Q(-1004773,1000000) result = { "input": str(SOURCE.relative_to(HERE)), "input_sha256": hashlib.sha256(SOURCE.read_bytes()).hexdigest(), "arithmetic": "exact integer polynomial products and rational interval operations", "threads": ctx.threads, "cell": [str(a0),str(a1)], "beta_class": [0,3,1], "density_details": details, "base_f_interval": list(map(str,base)), "constant_correction_abs_upper": str(constant_correction), "h_correction_abs_upper": str(h_correction), "f_interval": list(map(str,spot)), "f1_upper_from_input": str(prime_upper), "scaled_margin_lower": str(margin), "decimal_displays_not_bounds": { "a": [float(a0),float(a1)], "f": list(map(float,spot)), "constant_correction": float(constant_correction), "h_correction": float(h_correction), "scaled_margin_lower": float(margin), }, } (HERE / "spot_least_cell.json").write_text(json.dumps(result,indent=2)+"\n") print(json.dumps(result["decimal_displays_not_bounds"], indent=2)) print("PASS: exact interval has scaled margin > 0.0816; input h and f(1) bounds are assumed.")