"""alt4.py -- order r - 5's alternation certificate: does the real least height at d = 4 equal a three-point dual, and does its last depth at or below H_ch grow as C r^(3/2), C below 2 sqrt(2 exp 1)? The question, the hand step, the predictions, the kill and the controls were frozen before this file's code (below, copied). THE ENGINE. Flipped. d = 2e, s = r - 1 - d, B_k = (1 + x)^(J+d-k)(1 - x)^(s+k), all of degree N = J + r - 1, B_d the champion. The symmetric class is B_0/4^e + sum_i a_i B_(2i), i = 1..e. lp(): min over a of max |.| over the indices 0..N//2 (the mirror half repeats them), in floats of the exact entries over H = max |B_d|, its active set read off the dual's marginals. cert(): at e + 1 indices, w the signed e x e minors of (B_2, .., B_d), D = |det[B_0; B_2; ..; B_d]|/(4^e sum |w|), in exact integers: holds iff |det| > 4^e H sum |w|. QUESTION. At order s = r - 5 (d = 4), does the real least height (LP) equal a three-point dual, and does its last depth at or below H_ch grow as C r^(3/2) with C below 2 sqrt(2 exp 1) = 4.66329 (the Gaussian envelope's hand LP constant 2/sqrt(W(1/e)) = 3.79005, a TRANSPLANT from that picture, not re-derived on the lattice)? BY HAND. Flipped. B_k = (1 + x)^(J+4-k)(1 - x)^(s+k), k = 0..4, all of degree N = J + r - 1; B_4 the champion. The class is B_0/16 + sum_(k>=1) y_k B_k ((1 + x)^4/16 = 1 at x = 1, B_k k >= 1 vanish there more). Reversal at degree N sends B_k to (-1)^(s+k) B_k, so the average of P and its signed reversal keeps the even k alone and no larger height: the real least is min over (a, b) of max |B_0/16 + a B_2 + b B_4|. With w at three indices i < j < k solving w.B_2 = w.B_4 = 0 (w the 2x2 minors of (B_2, B_4), signed), |w.P| = |w.B_0|/16 for every (a, b), so height >= D3 = |det[B_0; B_2; B_4]_(ijk)|/(16 (|m_i| + |m_j| + |m_k|)), free of (a, b); the LP's optimum is a three-point alternation, D3 at its active set equals it. In integers, D3 > H_ch iff |det| > 16 H_ch sum |m|. d = 2's two-point pair is the same at e = 1: B_0/4 + a B_2. Gaussian envelope: g = ((b + 1/2 - y^2/4) + i a y/2) e^(-y^2/4), a = 0 optimal, |g| peaks at y = 0 and y^2 = 4(1 + beta), beta = W(1/e) = 0.278465: y = +-2.2604 in units of sqrt(J)/2 from the centre (a slip, as frozen: 2 sqrt(1 + beta) = 2.2614). PREDICTIONS (frozen). P1 the symmetric LP equals bandheight.real_least (four free) to 1e-9 relative at (r, J) = (9, 88), (12, 150), (15, 250), s = r - 5. P2 D3 at the LP's active triple equals the LP to 1e-9 relative at every cell read; D3 <= LP at 50 random triples (the lemma). P3 J4(r), the last depth with D3 <= H_ch walking down, at r = 20, 30, 50, 75, 100: J4/r^1.5 in [2.5, 4.4] each, J4/r^1.5 at r = 100 within 0.5 of 3.79. P4 the C-grid crossing (C step 0.01, J = ceil(C r^1.5)) at r = 200, 400 in [3.0, 4.4]. P5 the active triple: one index within 0.3 of y = 0, the others within 0.4 of |y| = 2.26, at r = 100 and 200 at the crossing. KILL. K1: the C-grid crossing at r = 400 or J4/r^1.5 at r = 100 is above 4.663 (the printed line "KILL K1: ..."). K2: P2 fails at any cell (the certificate is not the LP's dual, nothing is read). CONTROLS. Positive: the engine at e = 1 (B_0/4 + a B_2, two points) reproduces the two-point walk's J^D = 347, 707, 1533 at r = 20, 30, 50 (read by a separate exact two-point engine). PLANT: one index of the active triple moved by one lowers D3 below the LP at every cell read (read in the direction it pushes: a weaker certificate, crossing later). FINDINGS (copied from the printed output). K1 and K2 miss; P1..P5 hold. (1) CONTROLS: the symmetric LP is real_least's to 1.68e-15 relative (2.650651735247, 2.241423829649, 2.450274229853); D3 at the active triple equals it to 5.03e-16, and the 150 random triples sit at least 1.626 below. At e = 1 the walks' last failures are 347, 707, 1533 from tops 489, 891, 1906, the two-point engine's. (2) THE READ, P3: J4 = 265, 528, 1216, 2296, 3600 at r = 20, 30, 50, 75, 100, each the last failure below its printed top; J4/r^1.5 = 2.9628, 3.2133, 3.4394, 3.5349, 3.6000, rising; J4/s^1.5 = 4.5615, 4.2240, 4.0282, 3.9203, 3.8879, falling, closing from either side on a limit near the hand 3.79005: alt4proof.py proves limsup J4/r^1.5 <= 3.79005 by hand; the lower side is unproved. Along every walk D3 at the LP's active triple is the LP (least D/t 1.000000000). (3) FAR, P4: the last failing C on the grid is 3.68 at r = 200 (J = 10409, D3/H 0.997687) and 3.72 at r = 400 (J = 29760, 0.995296); in s, 3.68 (200/195)^1.5 = 3.822 and 3.72 (400/395)^1.5 = 3.791, by hand from the print. The grid fails at 3.72 and passes at every C from 3.73 to 5.00; if no depth between its points fails, r = 400's last failure lies in [3.72, 3.73) in r, [3.791, 3.801) in s, and if both normalizations are monotone in r the limit lies in [3.72, 3.801]. (4) P5: the triple is two indices near y = -2.26 and one near 0, the two adjacent (y apart by 2/sqrt(J)) at every r read but r = 50 (-2.523, -2.121, about 7 indices apart): y = (-2.433, -2.4, -0.167) at r = 100, (-2.372, -2.352, -0.118) at r = 200, (-2.301, -2.29, -0.075) at r = 400. (5) THE PLANT lowers D3 at 4 of 4, 4 of 4, 6 of 6, 3 of 4 and 4 of 4 moves at r = 20, 30, 50, 75, 100 (a move onto the pair's other index not counted). At r = 75 the move that keeps D3 at the LP takes the centre index N//2 to N - N//2, its mirror, the same constraint: 3 of 3 genuine moves lower D3, so every genuine move lowers D3 at every r read. (6) THE SLACK at C = 2 sqrt(2 exp 1): D3/H = 1.838326, 1.669135, 1.595588, 1.562630 at r = 50, 100, 200, 400 (J = 1649, 4664, 13190, 37307), D3 the LP, the triple as at the crossing, falling; if D3/H scales as C^(d/2) = C^2 (the d log J of Lambda_s, a TRANSPLANT) its limit is (4.66329/C_lim)^2, 1.505 to 1.571 over (3)'s window C_lim in [3.72, 3.801], untraced. CHANGED AFTER THE FREEZE. The plant's "at every cell" was implemented as a count of its moves a cell, printed, not asserted; (5) reads it. At the audit its count was given its denominator (a move onto the pair's other index had been skipped silently) and P2's print its own diff (it had carried P1's). The far stage's print at C = 2 sqrt(2 exp 1) was added after its first run. On moving to its served home, the QUESTION's, BY HAND's and CONTROLS' references to an unserved two-point engine were reworded, their content unchanged. RUN RECORD. Bare: 3/3, 17.7 s, peak 78.8 MB. --far 50 100 200 400: 112.8 s, peak 650.2 MB. The two-point engine, first a script of its own, is two_point() here, and the positive control walks it beside the e = 1 arm from the same top: bare 3/3, 22.6 s. RUN: python alt4.py [--far [r ...]] """ import math import os import random import sys import time os.environ.setdefault("OPENBLAS_NUM_THREADS", "1") import numpy as np # noqa: E402 from scipy.optimize import linprog # noqa: E402 from losses import coeffs # noqa: E402 CHECKS = [] CL = 2 * math.sqrt(2 * math.e) def check(name, ok, detail=""): CHECKS.append(bool(ok)) tail = f" ({detail})" if detail else "" print(f" {'PASS' if ok else 'FAIL'} {name}{tail}", flush=True) def basis(r, J, e): """[B_0, B_2, .., B_2e] as exact integer lists.""" d = 2 * e s = r - 1 - d return [coeffs(J + d - k, s + k) for k in range(0, d + 1, 2)] def det(M): """Exact determinant of a small integer matrix (Bareiss).""" M = [row[:] for row in M] n = len(M) sign, prev = 1, 1 for k in range(n - 1): if M[k][k] == 0: sw = next((i for i in range(k + 1, n) if M[i][k] != 0), None) if sw is None: return 0 M[k], M[sw] = M[sw], M[k] sign = -sign for i in range(k + 1, n): for j in range(k + 1, n): M[i][j] = (M[i][j] * M[k][k] - M[i][k] * M[k][j]) // prev prev = M[k][k] return sign * M[n - 1][n - 1] def cert(Bs, idx, H): """(holds, D/H) at the indices idx, exact.""" e = len(Bs) - 1 top = det([[B[i] for i in idx] for B in Bs]) w = [] for c in range(len(idx)): rest = [i for t, i in enumerate(idx) if t != c] w.append(abs(det([[B[i] for i in rest] for B in Bs[1:]])) if e else 1) den = 4 ** e * H * sum(w) if den == 0: return False, 0.0 return abs(top) > den, abs(top) / den def lp(Bs, H): """(t, a, active): the symmetric class's least height over H, floats, and the e + 1 indices of largest dual weight.""" e = len(Bs) - 1 half = len(Bs[0]) // 2 + 1 F0 = np.array([v / (4 ** e * H) for v in Bs[0][:half]]) A = np.array([[v / H for v in B[:half]] for B in Bs[1:]]).T ones = np.ones((half, 1)) cost = np.zeros(e + 1) cost[-1] = 1 res = linprog(cost, A_ub=np.vstack([np.hstack([A, -ones]), np.hstack([-A, -ones])]), b_ub=np.concatenate([-F0, F0]), bounds=[(None, None)] * e + [(0, None)], method="highs") if res.status != 0: raise RuntimeError("LP: " + res.message) m = np.abs(res.ineqlin.marginals) wt = m[:half] + m[half:] act = sorted(int(i) for i in np.argsort(-wt)[:e + 1]) return float(res.x[-1]), res.x[:e], act def read(r, J, e): """(holds, D/H, t, active) at one depth.""" Bs = basis(r, J, e) H = max(abs(v) for v in Bs[-1]) t, _, act = lp(Bs, H) holds, D = cert(Bs, act, H) return holds, D, t, act, Bs, H def yoff(i, r, J): return (i - (J + r - 1) / 2) / (math.sqrt(J) / 2) def walk(r, e, top): """(last failing depth walking down from top, least D/t above it).""" worst = math.inf for J in range(top, r, -1): holds, D, t, _, _, _ = read(r, J, e) if not holds: return J, worst worst = min(worst, D / t) return None, worst def two_point(r, J): """Whether the two-point certificate holds at depth J, read at every sign change of the champion B_2 and every zero of it, in exact integers and with no LP: a pair n, n + 1 holds iff |A_n B_(n+1) - A_(n+1) B_n| > 4 H (|B_n| + |B_(n+1)|), a zero iff |A_n| > 4 H, A = B_0 and H = max |B_2|.""" A, B = basis(r, J, 1) H = max(abs(v) for v in B) for n in range(len(B)): if B[n] == 0 and abs(A[n]) > 4 * H: return True if (n + 1 < len(B) and B[n] * B[n + 1] < 0 and abs(A[n] * B[n + 1] - A[n + 1] * B[n]) > 4 * H * (abs(B[n]) + abs(B[n + 1]))): return True return False def locate(r, e, C): J = int(1.15 * C * r ** 1.5) + 10 while not (read(r, J, e)[0] and read(r, int(0.97 * J), e)[0]): J = int(J * 1.08) return J def controls(): print("CONTROLS", flush=True) import bandheight worst = 0.0 for r, J in ((9, 88), (12, 150), (15, 250)): s = r - 5 t4, S0, _, _ = bandheight.real_least(J, r, s) Bs = basis(r, J, 2) H = max(abs(v) for v in Bs[-1]) # real_least's column 0 is (1 + x)^J (1 - x)^s with c'(1) = 1, our # B_0/16 has the same normalization: heights compare directly t, _, _ = lp(Bs, H) worst = max(worst, abs(t - t4 * S0 / H) / t) print(f" r = {r}, J = {J}: symmetric LP {t:.12f}, real_least " f"{t4 * S0 / H:.12f}", flush=True) check("P1: the symmetric LP equals bandheight.real_least, s = r - 5", worst < 1e-9, f"max rel diff {worst:.2e}") random.seed(11) lemma, worst2 = math.inf, 0.0 for r, J in ((9, 88), (12, 150), (15, 250)): Bs = basis(r, J, 2) H = max(abs(v) for v in Bs[-1]) t, _, act = lp(Bs, H) _, D = cert(Bs, act, H) print(f" r = {r}, J = {J}: D3 at the active {act} = {D:.12f}, " f"t {t:.12f}", flush=True) lemma = min(lemma, t - max(cert(Bs, sorted(random.sample( range(len(Bs[0]) // 2 + 1), 3)), H)[1] for _ in range(50))) worst2 = max(worst2, abs(D - t) / t) check("P2: D3 at the LP's active triple equals the LP; D3 <= LP at 50 " "random triples a cell", worst2 < 1e-9 and lemma >= -1e-12, f"max rel diff {worst2:.2e}, least t - D3 {lemma:.3e}") rows = {} for r, want in ((20, 347), (30, 707), (50, 1533)): top = locate(r, 1, CL) jd, w = walk(r, 1, top) tp = next((J for J in range(top, r, -1) if not two_point(r, J)), None) rows[r] = (jd, tp) print(f" e = 1, r = {r}: last failure {jd} from top {top}, the " f"two-point engine's {tp} (recorded {want}); least D/t above " f"{w:.9f}", flush=True) check("POSITIVE: at e = 1 the engine's last failure is the two-point " "engine's, 347, 707, 1533", [rows[r] for r in (20, 30, 50)] == [(347, 347), (707, 707), (1533, 1533)], str(rows)) return all(CHECKS) def plant(r, J): """(moves lowering D3, moves counted): each index of the active triple moved by one, a move onto another index of it not counted.""" holds, D, t, act, Bs, H = read(r, J, 2) low = n = 0 for c in range(3): for dlt in (-1, 1): idx = act[:] idx[c] += dlt if len(set(idx)) == 3: n += 1 low += cert(Bs, sorted(idx), H)[1] < t * (1 - 1e-9) return low, n def main(): t0 = time.time() if not controls(): print("CONTROL FAILED: nothing below is read.") return 1 print("THE READ: e = 2 (order r - 5)", flush=True) j4 = {} for r in (20, 30, 50, 75, 100): t1 = time.time() top = locate(r, 2, 3.79) jd, w = walk(r, 2, top) j4[r] = jd _, D, t, act, _, _ = read(r, jd + 1, 2) ys = [round(yoff(i, r, jd + 1), 3) for i in act] pl = plant(r, jd + 1) print(f" r = {r}: J4 = {jd} from top {top}, J4/r^1.5 " f"{jd / r ** 1.5:.4f}, J4/s^1.5 {jd / (r - 5) ** 1.5:.4f}; " f"least D/t above {w:.9f}; at J4 + 1 the triple at y = {ys}, " f"D/H {D:.6f}; plant lowers D at {pl[0]} of {pl[1]} moves " f"({time.time() - t1:.1f} s)", flush=True) k1 = j4[100] / 100 ** 1.5 > CL print(f"KILL K1 (r = 100 part): J4/r^1.5 {j4[100] / 1000:.4f} " f"{'above' if k1 else 'below'} {CL:.5f}: " f"{'KILLED' if k1 else 'HOLDS'}") print(f"{sum(CHECKS)}/{len(CHECKS)} checks, {time.time() - t0:.1f} s") return 0 if all(CHECKS) else 1 def far(rs=(200, 400)): for r in rs: t1 = time.time() last = None for c100 in range(300, 501): J = math.ceil(c100 / 100 * r ** 1.5) holds, D, t, act, _, _ = read(r, J, 2) if not holds: last = (c100 / 100, J, D, t, act) Jl = math.ceil(CL * r ** 1.5) hl, Dl, tl, al, _, _ = read(r, Jl, 2) print(f" r = {r}: at C = 2 sqrt(2 exp 1), J = {Jl}: D3/H {Dl:.6f}, " f"LP {tl:.6f}, holds {hl}, triple y " f"{[round(yoff(i, r, Jl), 3) for i in al]}", flush=True) ys = None if last: ys = [round(yoff(i, r, last[1]), 3) for i in last[4]] print(f" r = {r}: last failing C on the grid 3.00..5.00: " f"{last[:4] if last else None}, triple y {ys} " f"({time.time() - t1:.1f} s)", flush=True) if r == 400: k1 = last is not None and last[0] > CL print(f"KILL K1 (r = 400 part): {'KILLED' if k1 else 'HOLDS'}") if __name__ == "__main__": if "--far" in sys.argv: far([int(a) for a in sys.argv[2:]] or (200, 400)) sys.exit(0) sys.exit(main())